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

int main() {
    ll h,w,k;
    cin>>h>>w>>k;
    VV s(h,V(w,0));
    rep(i,h){
        string str;
        cin>>str;
        rep(j,w)s[i][j]=str[j]-'0';
    }
    ll ans=1e9;
    rep(bit,(1<<(h-1))){
        V tate(h,0);
        ll cnt=0;
        rep(j,h-1){
            tate[j]=cnt;
            if(bit&(1<<j)){
                cnt++;
            }
        }
        tate[h-1]=cnt;
        V value(cnt+1,0);
        ll tans=cnt;
        bool f=false;
        bool can=true;
        rep(x,w){
            if(!can)break;
            rep(y,h){
                value[tate[y]]+=s[y][x];
                if(value[tate[y]]>k){
                    tans++;
                    f=true;
                    break;
                }
            }
            if(f){
                f=false;
                rep(j,cnt+1)value[j]=0;
                rep(y,h){
                    value[tate[y]]+=s[y][x];
                    if(value[tate[y]]>k)can=false;
                }
            }
        }
        if(can)ans=min(ans,tans);
    }
    cout<<ans<<endl;
}


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

using namespace std;

const int mod = 998244353;
const int INF = 1e6;

long long add(long long a, long long b) {
    long long res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

long long sub(long long a, long long b) {
    long long res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

long long mul(long long a, long long b) {
    return (((a % mod) * (b % mod)) % mod);
}

long long potolok(long long a, long long b){   // округление вверх для целых
    return (a + b - 1) / b;
}


long long gcd(long long x, long long y){
    if(y == 0){
        return x;
    }
    if(x > y){
         return gcd(y, x % y);
    }
    else{
         return gcd(x, y % x);
    }
}

bool cmpr(int x, int y){            // сортировка по абсолютной величине
    if(abs(x) < abs(y)) return true;
    else{
        return false;
    }
}

bool comp(pair<int, int> x, pair<int, int> y){  // сортировка по первой компоненте
    if(x.first < y.first)return true;
    else if(x.first == y.first){
        if(x.second < y.second)return true;
        else return false;
    }
    else{
        return false;
    }
}

int cnt(string &s, string &p, int m, int n){
    if((m == 0 && n == 0) || n == 0){
        return 1;
    }
    if(m == 0){
        return 0;
    }
    if(s[m - 1] == p[n - 1]){
        return cnt(s, p, m - 1, n - 1) + cnt(s, p, m - 1, n);
    }
    else{
        return cnt(s, p, m - 1, n);
    }
}

int div(int n){
    int ans = 0;
    vector<int> used(n + 1, 0);
    for(int i = 1;i <= sqrt(n);i++){
        if(n % i == 0 && (!used[i] && !used[n / i])){
            if(i * i == n){
                ans++;
            }
            else{
                ans += 2;
            }
        }
    }
    return ans;
}

void solve(){
    int k;
    cin >> k;
    string s = "";
    for(int i = 0;i < k;i++){
        s += "ACL";
    }
    cout << s << endl;
}

int main(){
    int t = 1;
    while(t--){
        solve();
    }
 }


Measured memory_bytes: 3636
import java.util.Scanner

import scala.collection.immutable
import scala.collection.mutable.ArrayBuffer


object Main {

  class UnionFind(val n: Int) {

    sealed trait Node

    final case class Root(count: Int) extends Node

    // TODO: rank実装
    final case class NonRoot(parentIndex: Int) extends Node

    private val nodes: ArrayBuffer[Node] = ArrayBuffer.fill(n)(Root(count = 1))

    private def rootNode(index: Int): (Int, Root) = {
      nodes(index) match {
        case root: Root => (index, root) // nodes(index) == root
        case nonRoot: NonRoot =>
          val (rootIndex, root) = rootNode(nonRoot.parentIndex)
          nodes(index) = NonRoot(parentIndex = rootIndex) // 経路圧縮
          (rootIndex, root)
      }
    }

    private def root(index: Int): Int = rootNode(index)._1

    def sameCount(x: Int): Int = rootNode(x)._2.count

    def same(x: Int, y: Int): Boolean = root(x) == root(y)


    def unite(x: Int, y: Int): Unit = {
      val (xRootIndex, xRoot) = rootNode(x)
      val (yRootIndex, yRoot) = rootNode(y)
      if (xRootIndex != yRootIndex) {
        // xとyが同じ集合に属していない
        // xRootの親をyRootにする TODO: ランク実装
        nodes(xRootIndex) = NonRoot(parentIndex = yRootIndex)
        nodes(yRootIndex) = Root(count = xRoot.count + yRoot.count)
      }
    }

  }

  // A番目の島とB番目の島をつないだ橋
  case class Bridge(a: Int, b: Int)

  def read(): (Int, Int, immutable.IndexedSeq[Bridge]) = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val bridges = for (i <- 0 until m) yield {
      // 0-originにする
      val a = sc.nextInt() - 1
      val b = sc.nextInt() - 1
      Bridge(a, b)
    }
    (n, m, bridges)
  }

  def solve(n: Int, m: Int, bridges: IndexedSeq[Bridge]): IndexedSeq[Long] = {
    val reverseBridges = bridges.reverse
    val uf = new UnionFind(n)
    val numConnectedPairsDiff = for (bridge <- reverseBridges) yield {
      val diff =
        if (uf.same(bridge.a, bridge.b)) 0.toLong
        else uf.sameCount(bridge.a).toLong * uf.sameCount(bridge.b).toLong
      uf.unite(bridge.a, bridge.b)
      diff
    }
    val numConnectedPairs = numConnectedPairsDiff.scanLeft(0.toLong)(_ + _)
    numConnectedPairs.reverse.tail.map(x => n.toLong * (n.toLong - 1) / 2 - x)
  }

  def output(result: IndexedSeq[Long]): Unit = {
    for (elem <- result) {
      println(elem)
    }

  }

  def main(args: Array[String]): Unit = {
    val (n, m, bridges) = read()
    val result = solve(n, m, bridges)
    output(result)
  }
}

Measured memory_bytes: 116736
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <cstdlib>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e6 + 10;
const int EPS = 1e-9;
const ll MOD = 1e9 + 7;

ll a[N];
ll pref[N];

int solve() {
	ll m, v, p, n;
	cin >> n >> m >> v >> p;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());
	pref[0] = 0;
	for (int i = 1; i <= n; i++) {
		pref[i] = pref[i - 1] + a[i - 1];
	}

	for (int i = 0; i < n; i++) {
		if (i < p) continue;
		ll left_v = max(0ll, v - (n - i) - (p - 1)); // cnt for each pers
		ll newval = a[i] + m;
		if (newval < a[p - 1]) {
			return i;
		}
		ll sum = pref[i] - pref[p - 1];
		sum = newval * (i - (p - 1)) - sum;
		if (left_v * m > sum) {
			return i;
		}
	}
	return n;
}

int main() {
//	auto trash = freopen("a.in", "r", stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout <<	solve();
}

Measured memory_bytes: 5120
#include <stdio.h>
int main(void){
    // Your code here!
    double r,S,l;
    double pi=3.14159265359;
    
    scanf("%lf",&r);
    
    S=r*r*pi;
    l=2*r*pi;
    
    printf("%.6f %.6f\n",S,l);
    
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

template <typename T>
T gcd(T a, T b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];
  vector<int> gcdl(n + 1), gcdr(n + 1);
  rep (i, n) gcdl[i + 1] = gcd(gcdl[i], a[i]);
  rrep (i, n) gcdr[i] = gcd(gcdr[i + 1], a[i]);
  int maxi = 0;
  rep (i, n) {
    const int l = gcdl[i], r = gcdr[i + 1];
    if (l && r) maxi = max(maxi, gcd(l, r));
    else maxi = max({maxi, l, r});
  }
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
using namespace std;
void yes();
int main()
{
    string S;
    const string keyen("keyence");
    getline(cin, S);
    int st = S.length() - 1;

    if(S.length()<7){
        cout << "NO";
        return 0;
    }
    if(S.substr(0,7)=="keyence"){
        yes();
        return 0;
    }
    else if(S.substr(st-6,7)=="keyence"){
        yes();
        return 0;
    }

    for(int i=0;i<5;i++){
        if(S.substr(0,6-i)==keyen.substr(0,6-i)){
            if(S.substr(st-i,i+1)==keyen.substr(6-i,i+1)){
                yes();
                return 0;
            }
        }
    }

    cout << "NO";    
}
void yes()
{
    cout << "YES";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
a = []
for i in range(N):
    a.append(list(map(int, input().split())))

current_position = [0, 0]
t = 0
flag = True
for i in range(N):
    diff_x = abs(a[i][1] - current_position[0])
    diff_y = abs(a[i][2] - current_position[1])
    p = (a[i][0] - t) - (diff_x + diff_y)
    if p >= 0 and p % 2 == 0:
        pass
    else:
        flag = False
        break
    t = a[i][0]
    current_position[0] = a[i][1]
    current_position[1] = a[i][2]
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 27300
"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	lines.shift();
	var line, t = 0, h = 0;
	while(line = lines.shift()){
		line = line.split(" ");
		if(line[0] > line[1]) t += 3;
		else if(line[0] == line[1]) t += 1, h += 1;
		else h += 3;
	}
	console.log(t, h);
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; ++i) { cin >> L[i]; }
	sort(L.begin(), L.end());

	int sum = 0;
	for (int i = 0; i < N - 1; ++i) {
		sum += L[i];
	}

	if (sum > L[N - 1]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char s[100001],b[100001];
    int i,c;
    while(scanf("%s",&s)!=EOF)
    {
       c=strlen(s);
       for(i=0;i<=c/2;i++)
       {
          b[i]=s[2*i];
       }
       printf("%s\n",b);
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#define ll long long
using namespace std;
int n;
ll a[100001];
ll go(ll mi){
    ll left = mi;
    for(int i = 0 ; i < n ; ++i){
        left = (left/a[i]) * a[i];
    }
    return  left;
}
int main(){
    cin.sync_with_stdio(false);
    cin >> n;
    for(int i = 0 ; i < n ; ++i) cin >> a[i];
    ll b = 1;
    ll e = 1e18;
    ll ans = 0;
    while(b <= e){
        ll mi = (b + e)/2;
        if(go(mi) > 1){
            ans = mi;
            e = mi - 1;
        } else
            b = mi + 1;
    }
    if(go(ans) == 2){
        cout << ans << " ";
        b = ans;
        e = 1e18;
        while(b <= e){
            ll mi = (b + e)/2;
            if(go(mi) > 2){
                ans = mi - 1;
                e = mi - 1;
            } else
                b = mi + 1;
        }
        cout << ans << endl;
    } else
        cout << "-1";
    
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		
		String S = scan.next();
		
		String a =S.substring(0, 1)+Integer.toString(S.substring(1, S.length()-1).length())
		+S.substring(S.length()-1, S.length());
		
		System.out.println(a);
		
	}
}

Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main(void){
    int a;
    
    while (cin >> a){if(a==-1) break;
        else if (0<=a && 10>a) cout << 4280-1150 <<endl;
        else if (10<=a && 20>a) cout <<4280-(1150+(a-10)*125) <<endl;
        else if (20<=a && 30>a) cout << 4280-(1150+1250+(a-20)*140)<<endl;
        else cout << 4280-(1150+1250+1400+(a-30)*160) <<endl;
        
    }
}


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

using namespace std;

int main() {
	int  n,x;
	cin >> n >> x;

	int d = 0;

	for (int i = 0; i < n; i++) {
		int l;
		cin >> l;
		d += l;
		//cout << "i:" << i << " d:" << d << " l:" << l << endl;
		if (d > x) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << n + 1 << endl;

	return 0;
}

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

class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String data;
    List<String> rectangle_list = new ArrayList<String>();
    while(true){
      data = br.readLine();
      if(data.equals("0 0")){
        break;
      }
      rectangle_list.add(data);
    }

    int height = 0;
    int width  = 0;
    String[] tmp = new String[2];
    for(String rectangle: rectangle_list){
      tmp = rectangle.split(" ");
      height = Integer.parseInt(tmp[0]);
      width  = Integer.parseInt(tmp[1]);
      frame(width);
      for(int i = 0; i < height-2; i++ ){
        System.out.print("#");
        for(int j = 0; j < width-2; j++){
          System.out.print(".");
        }
        System.out.println("#");
      }
      frame(width);
      System.out.println();
    }
  }


  static void frame(int width){
    for(int i=0; i<width; i++){
      System.out.print("#");
    }
    System.out.println();
  }
}



Measured memory_bytes: 30664
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, k;
  while (cin >> n >> k, n) {
    vi v(n);
    rep(i, n) cin >> v[i];
    int s    = accumulate(v.begin(), v.begin() + k, 0);
    int maxi = s;
    rep(i, n - k) {
      s += v[i + k] - v[i];
      cmax(maxi, s);
    }
    cout << maxi << endl;
  }
}

Measured memory_bytes: 3556
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
cnt = 0
for i in range(n):
    a = list(map(int, input().split()))
    sum = c
    for j in range(m):
        sum += a[j] * b[j]
    if sum > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <vector>
using namespace std;

int main(void){
  stack<int> slopes;
  stack<pair<int, int>> lakes;
  int sum = 0;
  char ch; 
  for (int i = 0; (cin >> ch); i++) {
    if (ch == '\\') slopes.push(i);
    else if (ch == '/' && slopes.size() > 0) {
      int j = slopes.top(); slopes.pop();
      sum += i - j;
      
      int a = i - j;
      while (lakes.size() > 0 && lakes.top().first > j) {
        a += lakes.top().second; lakes.pop();
      }
      lakes.push(make_pair(j, a));
    }
  }
  
  vector<int> vec;
  while (!lakes.empty()) { vec.push_back(lakes.top().second); lakes.pop(); }
  
  cout << sum << endl;
  int n = vec.size();
  cout << n;
  for (int i = 0; i < n; i++) {
    cout << " " << vec.back(); vec.pop_back();
  }
  cout << endl;
  
  return 0;
}

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

int main(){
    int d[3][3]={{0,0,0}, {0,0,0}, {0,0,0}};
    int a[3][3];
    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    rep(h,n){
        int b;
        cin >> b;
        rep(i,3){
            rep(j,3){
                if(a[i][j]==b) d[i][j]=1;
            }
        }
    }
    bool check = false;
    //よこ
    rep(i,3){
        int c=0;
        rep(j,3){
            c+=d[i][j];
        }
        if(c==3) check = true;
    }
    //たて
    rep(j,3){
        int c= 0;
        rep(i,3){
            c+=d[i][j];
        }
        if(c==3) check=true;
    }
    //ななめ
    int c = 0;
    rep(i,3){
        c+=d[i][2-i];
    }
    if(c==3)check=true;
    c = 0;
    rep(i,3){
        c+=d[i][i];
    }
    if(c==3) check=true;

    if(check==true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    int N; cin >> N;
    vi a, b, c;
    rep(i, 0, N){
        int _a;
        cin >> _a;
        a.pb(_a);
    }
    ll cnt = 0; 
    rep(i, 0, N){
        int _b;
        cin >> _b;
        cnt += _b;
        b.pb(_b);
    }
    rep(i, 0, N-1){
        int _c;
        cin >> _c;
        c.pb(_c);
    }
    rep(i, 0, N-1){
        if(a[i+1] == a[i] + 1){
            cnt += c[a[i]-1];
        }
    }
    cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 256
use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        n: usize,
        k: usize,
        mut a: [i64; n],  // Vec<(i32, i32, i32)>
    }

    for i in 0..n - k {
        if a[i] < a[i + k] {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


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

vector<pair<int, int>> v[16];

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        for (int j = 0; j < x; j++) {
            int a, b; cin >> a >> b;
            a--;
            v[i].push_back({a, b});
        }
    }
    int ans = 0;
    for (int mask = 0; mask < (1 << n); mask++) {
        bool ok = true;
        for (int j = 0; j < n; j++) {
            if ((mask >> j) & 1) {
                for (auto p : v[j]) {
                    int v = (mask >> p.first) & 1;
                    if (v != p.second) ok = false;
                }
            }
        }
        if (ok && __builtin_popcount(mask) > ans)
            ans = __builtin_popcount(mask);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/perl
#abc087_a.pl
#Sun Jan 28 20:19:58 2018
#

use warnings;
use strict;

my $temp = <STDIN>;
chomp $temp;
my $x = $temp;

my $temp1 = <STDIN>;
chomp $temp1;
my $a = $temp1;

my $temp2 = <STDIN>;
chomp $temp2;
my $b = $temp2;

my $ans = ($x-$a)%$b;

print $ans,"\n";

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n1 = Integer.parseInt(sc.next());
    int n2 = Integer.parseInt(sc.next());

    int ans = 6 / (n1 * n2);


    System.out.println(ans);


  }
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;

constexpr int inf = 1ll<<61;
constexpr int mod = 1e9+7;

main(){
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];

  map<int,int> f,g;
  rep(i,n){
    if(i&1) f[a[i]]++;
    else g[a[i]]++;
  }
  pii x1=pii(-1,0),x2=pii(-1,0),y1=pii(-1,0),y2=pii(-1,0);
  for(auto x : f){
    if(x.second > x1.second){
      x2 = x1;
      x1 = x;
    }else if(x.second > x2.second){
      x2 = x;
    }
  }
  for(auto x : g){
    if(x.second > y1.second){
      y2 = y1;
      y1 = x;
    }else if(x.second > y2.second){
      y2 = x;
    }
  }
  dump(x1,x2,y1,y2);
  if(x1.first != y1.first){
    cout << n - x1.second - y1.second << endl;
    return 0;
  }else{
    if(x1.second + y2.second > x2.second + y1.second and x1.first != y2.second){
      cout << n - x1.second - y2.second << endl;
      return 0;
    }else if(x1.second + y2.second <= x2.second + y1.second and x2.first != y1.second){
      cout << n - x2.second - y1.second << endl;
      return 0;
    }
  }
  return 1;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int main() {
	makei(A); 
	makei(B);
	if (A < 9 && B < 9)say("Yay!");
	else say(":(");
}

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

using namespace std;

vector<string> taps = {"RUD", "LUD"};

int main(){
    string moves;
    cin >> moves;
    for (int i = 0; i < moves.size();++i){
        if (taps[i % 2].find(moves[i]) == string::npos)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int INF = 2147483647;
 const ll MOD = 1000000007;
 // const ll INF = 1000000000000000000LL;


int main() {
	int h,w,k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	vector<vector<int>> ans(h,vector<int>(w));

	int bango = 1;
	bool flag = false;
	int sx=0,sy=0,gx=0,gy = 0;
	bool is_ichigo = false;
	vector<int> kouho_gy;
	rep(i,h){
		rep(j,w){
				if(s[i][j]=='#') {
					kouho_gy.push_back(i);
					break;					
				}
		}
	}

	rep(i,kouho_gy.size()){
		gy = kouho_gy[i];
		rep(j,w){
			if(s[gy][j]=='#'){
				gx = j;
				for(int k = sx;k<=gx;k++){
					for(int l = sy;l<=gy;l++){
						ans[l][k] = bango;
					}
				}
				bango++;
				sx = j+1;
			}
		}
		sy = gy+1;
		sx = 0;
	}

	rep(i,h){
		rep(j,w){
			if(ans[i][j]==0)
				ans[i][j] = ans[i][j-1];
		}
	}

	rep(i,h){
		rep(j,w){
			if(ans[i][j]==0)
				ans[i][j] = ans[i-1][j];
		}
	}

	rep(i,h){
		rep(j,w){
			cout << ans[i][j] << ' ';
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 4164
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long ll;

int main() {
	int w, h;
	while ( cin >> h >> w, h || w ) {
		for (int y = 0; y < h; ++y) {
			for (int x = 0; x < w; ++x) {
				if (x == 0 || y == 0 || x == w-1 || y == h-1) {
					cout << '#';
				}
				else {
					cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long N,i;
    cin>>N;
    long long p[N];
    for(i=0;i<N;i++){
        cin>>p[i];
    }
    sort(p,p+N);
    long long sum=0;
    for(i=0;i<N-1;i++){
        sum+=p[i];
    }
    sum+=p[N-1]/2;
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
const int SIZE =1e5;
ll power(ll x, ll n, ll M=MOD){
    ll res = 1;
    if(n > 0){
        res = power(x, n / 2, M);
        if(n%2 == 0)res = (res * res) % M;
        else res = (((res * res) % M) * x) % M;
    }
    return res;
}

//Mは素数
ll mod_inv(ll n, ll M=MOD){
    return power(n, M-2, M);
}
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, m; cin >> n >> m;
   vector<ll> mPi(m+1,1);
   rep(i,m){
      mPi[i+1] = mPi[i] * (m-i);
      mPi[i+1] %= MOD;
   }
   vector<ll> nCi(n+1,1);
   rep(i,n){
      nCi[i+1] = nCi[i] * (n-i);
      nCi[i+1] %= MOD;
      nCi[i+1] *= mod_inv(i+1);
      nCi[i+1] %= MOD;
   }
   vector<ll> mPn(n+1,1);
   mPn[0] = (mPi[n]);
   rep(i,n){
      mPn[i+1] = mPn[i] * mod_inv(m-i);
      mPn[i+1] %= MOD;
   }
   ll ans = 0;
   for (int i = 0; i <= n; i++)
   {
      ll x;
      if (i%2==0) x=nCi[i];
      else x = MOD-nCi[i];
      x *= mPi[n];
      x %= MOD;
      x *= mPn[i];
      x %= MOD;
      ans += x;
      ans %= MOD;
   }
   cout << ans << endl;
   
}

Measured memory_bytes: 14640
// https://atcoder.jp/contests/abc059/tasks/arc072_a

#include "algorithm"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VL as(N);
  rep(i, N) cin >> as[i];

  ll res = INF;

  {
    // sums[0] > 0
    ll r = 0;
    ll cur = 0;

    rep(i, N) {
      cur += as[i];

      if (i % 2 == 0 && cur <= 0) {
        r += 1 - cur;
        cur += 1 - cur;
      } else if (i % 2 == 1 && cur >= 0) {
        r += 1 + cur;
        cur -= 1 + cur;
      }
    }

    chmin(res, r);
  }

  {
    // sums[0] < 0
    ll r = 0;
    ll cur = 0;

    rep(i, N) {
      cur += as[i];

      if (i % 2 == 1 && cur <= 0) {
        r += 1 - cur;
        cur += 1 - cur;
      } else if (i % 2 == 0 && cur >= 0) {
        r += 1 + cur;
        cur -= 1 + cur;
      }
    }

    chmin(res, r);
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1024
// A - One Card Poker

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	string ans;

	if (A == B) ans = "Draw";
	else if (A == 1) ans = "Alice";
	else if (B == 1) ans = "Bob";
	else {
		if (A > B) ans = "Alice";
		else ans = "Bob";
	}

	cout << ans << endl;

	return 0;
}

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

A = [30000 * i for i in range(1, N+1)]
R = [0 for i in range(N)]
for i in range(N):
    R[P[i]-1] = i+1
B = [30000 * (N-i) + R[i-1] for i in range(1, N+1)]

print(" ".join(map(str, A)))
print(" ".join(map(str, B)))

Measured memory_bytes: 7996
#include<bits/stdc++.h>
#define mx 100000
#define pb push_back
#define siz(v) v.size();
typedef unsigned long  ull;
typedef long long int lli;
using namespace std;

int main()
{
 	ios_base::sync_with_stdio(0);
 	cin.tie(0); cin.tie(0);
	
	double a;
	 double pi =4*atan(1);
	cin>>a;
	cout<<fixed<<setprecision(20)<<(2*pi*a)<<"\n";






 return 0;
 }


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int w, h ,n;
  cin >> w >> h >> n;
  vector<vector<int>> m(h, vector<int>(w));
  int x, y, a;
  for(int i=0; i<n; ++i){
    cin >> x >> y >> a;
    for(int i=0; i<h; ++i){
      for(int j=0; j<w; ++j){
        if(a == 1 && j < x) m[i][j] = 1;
        if(a == 2 && j >= x) m[i][j] = 1;
        if(a == 3 && i < y) m[i][j] = 1;
        if(a == 4 && i >= y) m[i][j] = 1;
      }
    }
  }
  int ans = 0;
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j) if(!m[i][j]) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3548
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);

		int a, b;
		a = scan.nextInt();
		b = scan.nextInt();

		//IMPOSSIBLE
		int sa;
		if (a > b) {
			sa = a + b;
		} else {
			sa = b + a;
		}

		int ans;
		if (myMod(sa, 2) == 0) {
			//偶数

			ans = sa / 2;
			System.out.println(ans);
		} else {
			System.out.println("IMPOSSIBLE");
		}

	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。ｓ
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param a 基数
	 * @param n 乗数
	 * @param primeNumMod 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myModPow(long a, long n, long primeNumMod) {

		long ans = 1;

		//乗数が0の場合→1
		if (n == 0)
			return 1;

		if (primeNumMod == 0) {
			//modを使わないとき

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= a;
					n = n / 2;
				} else {
					//累乗が奇数の時
					ans *= a;
					n--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= myMod(a, primeNumMod);
					n = n / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(a, primeNumMod);
					n--;

				}
			}

			return myMod(ans, primeNumMod);

		}

	}

}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;


int main() {
	lli n, i, j, k, m;
	vector<ll> a;

	cin >> n;
	SIZE(a, n);
	m = 0;
	rep(i, n) {
		cin >> a[i];
		if (a[i] < 0)m++;
	}
	sort(ALL(a));
	j = 0;
	k = pow(10, 9) + 1;
	rep(i, n) {
		j += abs(a[i]);
		k = min(k, abs(a[i]));
	}
	if (m % 2 == 0)cout << j;
	else cout << j - k * 2;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code


int main()
{
  int n;
  cin>>n;
  int x = n;
  int d = 0;
  while(n != 0)
  {
    d += (n %10);
    n = n /10;
  }
  if(x % d == 0) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 256
a = int(input())
b = int(input())

if a == 1 and b == 2:
  print("3")
  
elif a == 1 and b == 3:
  print("2")
  
elif a == 2 and b == 1:
  print("3")
  
elif a == 2 and b == 3:
  print("1")

elif a == 3 and b == 1:
  print("2")
  
else:
  print("1")
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int n,ans=0;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++){
   	 cin>>a[i];
     if(i%2==0&&a[i]%2==1) ans++;
   }
   cout<<ans;
}

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

class D
{
	static void Main()
	{
		Console.ReadLine();
		var d = Console.ReadLine().Select((c, i) => new { c, i }).ToLookup(_ => _.c, _ => _.i);

		var r = 0;
		foreach (var i1 in d.Select(g => g.First()))
			foreach (var i2 in d.Select(g => g.FirstOrDefault(x => x > i1)).Where(x => x > 0))
				r += d.Count(g => g.Any(x => x > i2));
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 14048
#include<bits/stdc++.h>
#define x first
#define y second
#define size(a) (ll)(a).size()

typedef long long ll;
typedef long double ld;

using namespace std;
int n;
string s;


int main()
{
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");


    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cin >> n;
    vector<ll> A(n), B(n);

    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    for (int i = 0; i < n; ++i) {
        cin >> B[i];
    }

    sort(B.rbegin(), B.rend());
    bool is_ok = true;
    ll bad_num = -1;

    int prevA = -1;
    int left_board = -1;
    int right_board = -1;
    int bad_pos = -1;
    for (int i = 0; i < n; ++i) {
        if (is_ok) {
            if (A[i] != prevA) {
                prevA = A[i];
                left_board = i;
            }

            if (A[i] == B[i]) {
                is_ok = false;
                bad_pos = i;
                bad_num = A[i];
            }
        } else {
            if (A[i] != prevA) {
                right_board = i - 1;
                break;
            }
        }
    }

    if (is_ok) {
        cout << "Yes\n";
        for (int i = 0; i < n; ++i) {
            cout << B[i] << ' ';
        }
        return 0;
    } else {
        if (right_board == -1) {
            right_board = n - 1;
        }
    }

    int left_board2 = -1, right_board2 = -1;
    for (int i = bad_pos; i >= 0; --i) {
        if (B[i] != bad_num) {
            left_board2 = i + 1;
            break;
        }
    }

    if (left_board2 == -1) {
        left_board2 = 0;
    }

    for (int i = bad_pos; i < n; ++i) {
        if (B[i] != bad_num) {
            right_board2 = i - 1;
            break;
        }
    }

    if (right_board2 == -1) {
        right_board2 = n - 1;
    }

   // cout << left_board << ' ' << right_board << ' '<< left_board2 << ' ' << right_board2;
    ll gr1 = max(left_board, left_board2);
    ll gr2 = min(right_board, right_board2);

    if (right_board - left_board + 1 + right_board2 - left_board2 + 1 > n) {
        cout << "No";
        return 0;
    }

    if (left_board >= left_board2) {
        for (int i = 0; i < left_board2 && gr1 <= gr2; ++i) {
            swap(B[i], B[gr1]);
            ++gr1;
        }
    } else {
        for (int i = 0; i < left_board && gr1 <= gr2; ++i) {
            swap(A[i], A[gr1]);
            ++gr1;
        }
    }

    if (right_board > right_board2) {
        for (int i = n - 1; i > right_board && gr1 <= gr2; --i) {
            swap(A[i], A[gr2]);
            --gr2;
        }
    } else {
        for (int i = n - 1; i > right_board2 && gr1 <= gr2; --i) {
            swap(B[i], B[gr2]);
            --gr2;
        }
    }

    cout << "Yes\n";

    vector<pair<int, int>> Num(n);

    for (int i = 0; i < n; i++) {
        Num[i].x = A[i];
        Num[i].y = B[i];
    }

    sort(Num.begin(), Num.end());
    for (int i = 0; i < n; ++i) {
        cout << Num[i].y << ' ';
    }



}


Measured memory_bytes: 7960
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

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

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

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    vll a(M),b(M);
    vvll next(N);
    for(ll i=0;i<M;i++){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        next[a[i]].push_back(b[i]);
        next[b[i]].push_back(a[i]);
    }
    
    vll open;
    open.push_back(0);
    vll done(N,-1);
    done[0]=0;
    while(open.size()>0){
        ll node=open[0];
        open.erase(open.begin());
        for(ll i=0;i<next[node].size();i++){
            if(done[next[node][i]]==-1){
                done[next[node][i]]=done[node]+1;
                if(done[node]==0)open.push_back(next[node][i]);
            }
        }
    }
    if(done[N-1]!=-1)printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    
    return 0;
}


Measured memory_bytes: 19048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes() {
  cout << "Yes" << endl;
  exit(0);
}

void no() {
  cout << "No" << endl;
  exit(0);
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n + 1);
  REP(i, n) { cin >> a[i + 1]; }
  REP(i, n) {
    if (a[i] < a[i + 1]) {
      a[i + 1]--;
    } else if (a[i] > a[i + 1]) {
      no();
    }
  }
  yes();
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

	static char[] tango;
	static String str;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			str = cin.next();
			String c = cin.next();
			if(c.equals("X")){
				break;
			}
			tango = new char[300];
			System.out.println(CamelCase(c.charAt(0)));
		}
	}
	static String CamelCase(char c){
		String res = "";
		int wordCnt=0;
		int before=0;
		boolean under=false;;
		String[] words = new String[100];
		for(int i = 0; i < 100; i++){
			words[i]="";
		}
		for(int i = 0; i < str.length(); i++){
			if(str.charAt(i)=='_'){
				under=true;
				words[wordCnt]=str.substring(before, i);
				before = i+1;
				wordCnt++;
			}

		}
		if(under){
			words[wordCnt]=str.substring(before, str.length());
			wordCnt++;
		}
		else{
			for(int i = 1; i < str.length();i++){
				char a = str.charAt(i);
				if(a <= 'Z' && a >= 'A'){
					words[wordCnt++]=str.substring(before, i);
					before=i;
				}
			}
			words[wordCnt++]=str.substring(before, str.length());
		}
		for(int i = 0; i < wordCnt; i++){
			//System.out.println(words[i]);
		}
		if(c == 'L'){
			for(int i = 0; i < wordCnt; i++){
				if(i==0){
					char a = words[i].charAt(0);
					a = Character.toLowerCase(a);
					words[i] = a + words[i].substring(1, words[i].length());
				}
				else{
					char a = words[i].charAt(0);
					a = Character.toUpperCase(a);
					words[i] = a + words[i].substring(1, words[i].length());
				}
				res += words[i];
			}
		}
		else if(c == 'U'){
			for(int i = 0; i < wordCnt; i++){
				char a = words[i].charAt(0);
				a = Character.toUpperCase(a);
				words[i] = a + words[i].substring(1, words[i].length());
				res += words[i];
			}
			
		}
		else if(c == 'D'){
			for(int i = 0; i < wordCnt; i++){
				char a = words[i].charAt(0);
				a = Character.toLowerCase(a);
				words[i] = a + words[i].substring(1, words[i].length());
				if(i!=0){
					res += "_";
				}
				res += words[i];
			}
		}
		return res;
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
int n,m,z,x,y,fa[2000010],num[2000010],ans;
int find(int x)
{
	while (x!=fa[x]) x=fa[x]=fa[fa[x]];
	return x;
}
int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++) fa[i]=i;
	while(m--)
	{
		cin>>x>>y;
		int a=find(x),b=find(y);
		fa[a]=b;
	}
	for (int i=1;i<=n;i++) num[find(i)]++;
	for (int i=1;i<=n;i++) ans=max(ans,num[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5140
N, M = list(map(int, input().split()))
if abs(N-M)>1:
  print(0)
  exit()

mod = 1000000007

def modfact(N):
  answer=1
  while N>=2:
    answer=(answer*N)%mod
    N-=1
  return answer

if (N-M)%2==0:
  print((2*modfact(N)**2)%mod)
else:
  print((modfact(min(N,M))**2*max(N,M))%mod)


Measured memory_bytes: 3060
class Alter:
    def __init__(self, N, C):
        self.N = N
        self.C = C

        whites = 0
        for c in C:
            if c == "W":
                whites += 1
        self.white_count = whites
        self.red_count = N - whites

    def solve(self):
        result = 0
        if self.white_count == self.red_count:
            for i in range(self.red_count):
                if self.C[i] == "W":
                    result += 1
            print(result)
        elif self.white_count > self.red_count:
            for i in range(self.red_count):
                if self.C[i] == "W":
                    result += 1
            print(result)
        else:
            for i in range(self.white_count):
                w_i = self.N - i - 1
                if self.C[w_i] == "R":
                    result += 1
            print(result)

N = int(input())

c_line = input()
C = [None] * N
for i, c in enumerate(c_line):
    C[i] = c

alter = Alter(N, C)
alter.solve()


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

class dice{
public:
    int face[6];

    dice(){}

    void rollN(){
        int c = face[0];
        face[0] = face[1];
        face[1] = face[5];
        face[5] = face[4];
        face[4] = c;
    }

    void rollS(){
        int c = face[0];
        face[0] = face[4];
        face[4] = face[5];
        face[5] = face[1];
        face[1] = c;
    }

    void rollW(){
        int c = face[0];
        face[0] = face[2];
        face[2] = face[5];
        face[5] = face[3];
        face[3] = c;
    }

    void rollE(){
        int c = face[0];
        face[0] = face[3];
        face[3] = face[5];
        face[5] = face[2];
        face[2] = c;
    }

};

int main() {
    dice A;
    rep(i, 6){
        cin >> A.face[i];
    }

    string S; cin >> S;
    rep(i, S.size()){
        if (S[i] == 'N') A.rollN();
        if (S[i] == 'S') A.rollS();
        if (S[i] == 'W') A.rollW();
        if (S[i] == 'E') A.rollE();
    }

    cout << A.face[0] << endl;
}


Measured memory_bytes: 3224
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int sx = 0, sy = 0, tx = 0, ty = 0;
    cin >> sx >> sy >> tx >> ty;
    string pass = "";
    int x = tx - sx, y = ty - sy;
    for (int i=0; i<y; i++) {
        pass += 'U';
    }
    for (int i=0; i<x; i++) {
        pass += 'R';
    }
    for (int i=0; i<y; i++) {
        pass += 'D';
    }
    for (int i=0; i<x; i++) {
        pass += 'L';
    }
    pass += 'L';
    for (int i=0; i<y+1; i++) {
        pass += 'U';
    }
    for (int i=0; i<x+1; i++) {
        pass += 'R';
    }
    pass += 'D';
    pass += 'R';
    for (int i=0; i<y+1; i++) {
        pass += 'D';
    }
    for (int i=0; i<x+1; i++) {
        pass += 'L';
    }
    pass += 'U';
    cout << pass << endl;
    return 0;
}


Measured memory_bytes: 256
object Main{
    def main(args: Array[String]){
        val numlist = io.StdIn.readLine().split(" ").map(_.toInt).toList
        val a = numlist(0)
        val b = numlist(1)
        val k = numlist(2)
        (a to b).foreach(i => if (i < a + k || i > b - k) println(i))
    }
}

Measured memory_bytes: 27316
#include <bits/stdc++.h>
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define ROF(i,b,a) for (int i = (b)-1; i >= a; --i)
using namespace std;

const int N = 2e5+10;

int n, cnt[2], zero;
long long ans;
char t[N];

signed main() {
	scanf("%s", t);
	n = strlen(t);
	FOR(i,0,n) cnt[t[i]-'0']++;
	for (int i = 0; i < n; ) {
		if (t[i] == '1' && t[i+1] == '1') {
			ans += cnt[0];
			i += 2;
			continue;
		}
		if (t[i] == '0') {
			++zero;
		} else {
			ans += i/2-(i-zero)/2;
			ans += cnt[0]-zero;
		}
		++i;
	}
	FOR(i,0,cnt[1]) {
		ans += i/2+1;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4028
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>
using namespace std;

void print_table(int A[],int n){
  for(int i=0;i<n;i++){
    cout << (i==0 ? "" : " ") << A[i];
  }
  cout << endl;
}

int main(){
  int buf1,n,v,A[100],j;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
  print_table(A,n);

  for(int i=1;i<n;i++){
    v = A[i];
    j = i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    print_table(A,n);
  }
}


Measured memory_bytes: 3076