akhauriyash/Code-Regression huggingface dataset:
//abc169_d.cpp
//Sun May 31 20:45:43 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n;
	cin >> n;

	map<ll,ll> mp;
	ll a = 2;
	ll temp = n;
	while (n>=a*a){ //iの素因数分解ここから
		if (temp%a == 0){
			auto itr = mp.find(a);
			if (itr != mp.end()){
				mp[a]++;
			}else {
				mp[a] = 1;
			}
			temp = temp/a;
		}else {
			a++;
		}
	}
	if (temp != 1){
		auto itr = mp.find(temp);
		if (itr != mp.end()){
			mp[temp]++;
		}else {
			mp[temp] = 1;
		}
	}

	ll ans = 0;
	for (auto itr=mp.begin();itr!=mp.end();++itr){
		ll x = itr->second;
		ll tmp = 0;
		ll limit = 0;
		for (ll i=1;i<10;i++){
			limit += i;
			if (x<limit){
				tmp = i-1;
				break;
			}
//			cout << x << " " << i << " " << limit << endl;
		}
		ans += tmp;
//		cout << itr->first << " " << x << " " << tmp <<endl;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3632
while 1:
    rec = str(input())
    if rec == '0':
        break
    #Rec = list(rec.split())
    
    Acount = rec[1:].count('A')
    Bcount = rec[1:].count('B')
    #print('*', Acount, Bcount)
    
    if Acount < Bcount:
        print(Acount, Bcount+1)
    else:
        print(Acount+1, Bcount)


Measured memory_bytes: 5556
#include <stdio.h>

int round1000(int n)
{
	if (n % 1000 > 0)
		return n / 1000 * 1000 + 1000;
	else
		return n;
}

int main()
{
	int i, sum, n;

	scanf("%d", &n);

	sum = 100000;
	for (i = 0; i < n; i++) {
		sum *= 105;
		sum /= 100;
		sum = round1000(sum);
	}
	printf("%d\n", sum);



	return 0;
}

Measured memory_bytes: 0
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Monsters Battle Royale
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int as[MAX_N];

/* subroutines */

int gcd(int m, int n) {
  if (m < n) swap(m, n);
  while (n > 0) {
    int r = m % n;
    m = n;
    n = r;
  }
  return m;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) scanf("%d", as + i);

  int g = as[0];
  for (int i = 1; i < n; i++) g = gcd(g, as[i]);

  printf("%d\n", g);
  return 0;
}


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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #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; }
//Write From this Line
const ll mod = 1e9+7;

int main()
{
	int n;
	cin >> n;
	ll ans = 1;
	map<int,int> fact;
	for(int N = 1; N <= n; N ++){
		ll num = N;
		for(int i = 2; i * i <= N; i++){
			while(num%i==0){
				fact[i] ++;
				num /= i;
			}
		}
		if(num != 1) fact[num] ++;
	}
	for(auto x:fact){
		ans *= x.second+1;
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static int[] A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        A = sc.nextIntArray(N);
        System.out.println( solve() );
    }


    static long solve() {
        long ans = 0;
        for (int a : A) {
            ans += a-1;
        }
        return ans;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;
        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
typedef long long ll;
vector<int> num(10000001,2);

void sieve(ll n){
  for(int i=2;i*i<=n;++i){
    for(int j=i;i*j<=n;++j){
      num.at(i*j)+=2;
      if(i==j) num.at(i*j)--;
    }
  }
  num.at(1)=1;
}

int main(){
  ll n,ans=0;cin>>n;
  sieve(n);
  for(ll i=1;i<=n;i++) ans+=i*(ll)num.at(i);
  cout<<ans;
}

Measured memory_bytes: 42072
#include<bits/stdc++.h>
using ll = long long;
using namespace std;

int main(){
    ll x, y; cin >> x >> y;
    int ans=1;
    int count = 1;
    while(true){
        if(x*2 <= y){
            ans++;
            x = x*2;
        }else{
            break;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define N 200005
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;





void solve()
{
	int x,n;
	cin>>x>>n;
	
	map<int,int>mp;
	vector<int>a(n);
	
	for(int i=0;i<n;i++)
	{
	cin>>a[i];
	mp[a[i]]++;
	}
	
	if(mp[x]==0)
	{
	cout<<x<<endl;
	return ;
	}
	
	int p=x-1;
	int q=x+1;
	
	while(mp[p]!=0)
	p--;
	
	while(mp[q]!=0)
	q++;
	
	int d1=x-p;
	
	int d2=q-x;
	
	if(d1<=d2)
	cout<<p<<endl;
	else
	cout<<q<<endl;
	
	
}
signed main()
{
    
	nuenxfiu
	//TT
	solve();
     return 0;
}

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


using ll = long long;
const ll INF = 1LL << 50;


int main() {
  int N, M;
  cin >> N >> M;

  const int NMAX = 1000;
  const int MMAX = 2000;

  int a[MMAX], b[MMAX];
  ll c[MMAX];

  for (int i=0; i<M; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    c[i] = -c[i];
  }

  ll dist[NMAX];

  for (int i=0; i<N; ++i) {
    dist[i] = INF;
  }

  dist[0] = 0;

  for (int loop=0; loop<N-1; ++loop) {
    for (int i=0; i<M; ++i) {
      if (dist[a[i]-1] == INF) continue;

      if (dist[b[i]-1] > dist[a[i]-1] + c[i]) {
        dist[b[i]-1] = dist[a[i]-1] + c[i];
      }
    }
  }

  bool negative[NMAX];

  for (int i=0; i<N; ++i) {
    negative[i] = false;
  }

  for (int loop=0; loop<N; ++loop) {
    for (int i=0; i<M; ++i) {
      if (dist[a[i]-1] == INF) continue;

      if (dist[b[i]-1] > dist[a[i]-1] + c[i]) {
        dist[b[i]-1] = dist[a[i]-1] + c[i];
        negative[b[i]-1] = true;
      }

      // if (negative[a[i]-1]) {
      //   negative[b[i]-1] = true;
      // }
    }
  }

  if (negative[N-1]) {
    cout << "inf" << endl;
  }
  else {
    cout << -dist[N-1] << endl;
  }
}


Measured memory_bytes: 256
# 072b
class Atc_072b:
    def __init__(self, s: str) -> str:
        self.s = s

    def odd(self):
        s_odd = ""
        for i in range(0, len(self.s)):
            if i % 2 == 0:
                s_odd += self.s[i]
        return s_odd


s_input = input()
print(Atc_072b(s_input).odd())


Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> x(n);for(int i=0;i<n;i++)cin>>x[i];
  int l;cin>>l;
  int q;cin>>q;
  int d1[n+1],d2[n+1];
  for(int i=0;i<n;i++){
    int now=x[i];
    d1[i]=upper_bound(x.begin(),x.end(),x[i]+l)-x.begin()-1;
  }
  d1[n-1]=n;
  d1[n]=n;
  int h=pow(n,0.5);
  //cout<<h;return 0;
  for(int i=0;i<n;i++){
    d2[i]=n;
    int num=i;
    for(int j=0;j<h;j++){
      num=d1[num];
    }
    d2[i]=num;
  }
  //for(int i=0;i<n;i++)cout<<d1[i]<<" "<<d2[i]<<endl;
  for(int i=0;i<q;i++){
    int a,b;cin>>a>>b;a--;b--;
    if(a>b)swap(a,b);
    int ans=0;
    int c=0;
    for(int j=a;;){
      int num=d2[j];
      if(num>b){
        int now=j;
        for(int k=j;;k++){
          ans++;
          now=d1[now];
          if(now>=b){
            cout<<ans<<endl;
            c=1;
            break;
          }
        }
      }
      ans+=h;
      if(num==b){
        cout<<ans<<endl;
        c=1;
      }
      if(c==1)break;
      j=num;
    }
  }
}

Measured memory_bytes: 2048
k = gets.to_i
ar = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

puts ar[k-1]


Measured memory_bytes: 1788
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String inputText = sc.nextLine();
		HashSet<String> set = new HashSet<>();
		for(int i = 0; i < inputText.length(); i++) {
			set.add(String.valueOf(inputText.charAt(i)));
		}
		if(set.size() == 26) {
			System.out.println("None");
		}else {
			char c = 'a';
			for(int i = 0; i < 26; i++) {
				if(set.contains(String.valueOf(c))) {
					c++;
					continue;
				}
				System.out.println(c);
				break;
			}			
		}

		
		
		
		
		
	}	

}



Measured memory_bytes: 30400
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int n,i,q;
    cin>>n;
    map<long long int,long long int> m;
    long long int sum=0;
    for(i=0;i<n;i++)
    {
        long int temp;
        cin>>temp;
        m[temp]++;
        sum+=temp;
    }
    cin>>q;
    while(q--)
    {
        long long int a,b;
        cin>>a>>b;
        sum-=m[a]*a;
        sum+=b*m[a];
        m[b]+=m[a];
        m.erase(a);
        cout<<sum<<"\n";
    }
}

Measured memory_bytes: 7540
N = int(input())
L = []
for i in range(N):
    a = int(input())
    L.append(a)

L.sort()
ptr = 0
temp = 0
num = 1
ans = 0
while ptr < N:
    cc = L[ptr]
    f = 0
    while ptr < N and L[ptr] == cc:#同じ数字が続く終了条件
        f += 1
        ptr += 1
    ans += f%2

print(ans)

Measured memory_bytes: 7388
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {

		int n;
		List<String> 	mesList = new ArrayList<String>();
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

		n = Integer.parseInt(bufferedReader.readLine());

		for(int i = 0; i < n; i++){
			mesList.add(bufferedReader.readLine());
		}

		for(String mes : mesList)	System.out.println(mes.replaceAll("Hoshino", "Hoshina"));

	}
}

Measured memory_bytes: 9404
s=input()
for bit in range(1<<3):
    l=s[0]
    for i in range(3):
        if bit & (1<<i):
            l+='+'+s[i+1]
        else:
            l+='-'+s[i+1]
    if eval(l)==7:
        print(l+'=7')
        exit()

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

using namespace std;

const int M= 1e5 + 5;
int n, t[M], ans;

int main () {
  cin >> n >> t[0];
  int k = 0;
  for (int i = 1; i < n; i++) {
    cin >> t[i];
    if (t[i] <= t[i-1]) k++;
    else k = 0;
    ans = max (ans, k);
  }
  ans = max (ans, k);
  cout << ans << endl;
}

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

unsigned long long gcd(unsigned long long a, unsigned long long b)
{

  if (a == 0 || b == 0){
    return max(a,b);
  }else{
    if (a < b){
      unsigned long long k = b % a;
      return gcd(a, k);
    }else{
      unsigned long long k = a % b;
      return gcd(b, k);
    }
  }
}

unsigned long long lcm(unsigned long long a, unsigned long long b){
  unsigned long long g = gcd(a,b);
  return (a/g) * (b/g) * g;
}


int main()
{
  int n;
  unsigned long long t[100];

  cin >> n;

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

  if (n == 1){
    cout << t[0];
  }else{

    unsigned long long acc = lcm(t[0], t[1]);
    
    for (int i = 2; i < n; i++){
      acc = lcm(acc, t[i]);
    }
    
    cout << acc;
  }

  return 0;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const ll INF = 1e18;
const int MAXN = 120000;

ll dp[MAXN];
ll h[MAXN];
int n;

int k;

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> h[i];
	fill(dp, dp + n, INF);
	dp[0] = 0;
	for (int i = 0; i < n - 1; ++i) {
		for (int j = 1; i + j < n && j <= k; ++j) {
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[n - 1] << "\n";
	return 0;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int V[55];
int main(){
	int out=0,n,K;
	cin>>n>>K;rep(i,n) cin>>V[i];
	rep(i,n+1) repk(j,i,n+1){
		vector<int> v;
		int sum=0,rest=K-i-(n-j);
		if(rest<0) continue;
		rep(k,i) v.pub(V[k]),sum+=V[k];
		repk(k,j,n) v.pub(V[k]),sum+=V[k];
		if(v.size()<1) continue;
		sort(all(v));
		rep(k,min(rest,(int)v.size())){
			if(v[k]<0) sum-=v[k];
		}
		out=max(out,sum);
	}
	cout<<out<<endl;
}

Measured memory_bytes: 256
(* 素集合データ構造 *)
module UnionFind = struct
  module Make (Set : sig
    type t
    val union : t -> t -> t
  end) : sig
    type t
    (* 与えられた集合から素集合データ構造を作る *)
    val make : Set.t -> t
    (* 与えられた素集合同士が同一かどうか判定する *)
    val equal : t -> t -> bool
    (* 与えられた素集合同士を合併する *)
    val unite : t -> t -> unit
    (* 与えられた素集合に属する要素を列挙する *)
    val elements : t -> Set.t
  end = struct
    type t = node ref
    and node =
      | Root of int * Set.t (* 木の高さと要素の集合の二つ組 *)
      | Link of t

    let make s = ref @@ Root (0, s)

    let rec find uf =
      match !uf with
      | Root _ -> uf
      | Link parent ->
          let root = find parent in
          uf := Link root; root

    let equal uf uf' = find uf == find uf'

    let unite uf uf' =
      let root = find uf in
      let root' = find uf' in
      if root != root' then begin
        let Root (rank, elts) = !root in
        let Root (rank', elts') = !root' in
        let root, root' =
          if rank <= rank'
          then root, root'
          else root', root in
        root := Link root';
        root' := Root (rank' + (if rank = rank' then 1 else 0), Set.union elts elts')
      end

    let elements uf =
      match find uf with
      | { contents = Root (_, elts) } -> elts
  end
end

module UF = UnionFind.Make (struct
  type t = int
  let union = ( + )
end)

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let uf = Array.init n @@ fun _ -> UF.make 1 in
  for i = 0 to m - 1 do
    Scanf.scanf "%d %d\n" @@ fun a b ->
      UF.unite uf.(a - 1) uf.(b - 1)
  done;
  Printf.printf "%d\n" @@
  Array.fold_right (fun uf -> max @@ UF.elements uf) uf min_int


Measured memory_bytes: 26876
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <cstring>

#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3c3c3c3c;
const ll LINF = 1ll*INF*INF*2;

const int MAX_N = 100001;
int n;
ll input[MAX_N];
int sz[MAX_N];
int par[MAX_N];
ll sum[MAX_N];

vector<pair<ll, int>> v;

int main(void) {
	scanf("%d", &n);
	ll temp;
	for(int i=1; i<=n; i++) {
		scanf("%lld", &temp);
		v.push_back(make_pair(temp, i));
	}

	sort(all(v));
	for(int i=0; i<n; i++) input[i] = v[i].first;
	for(int i=0; i<n; i++) sz[i] = 1;

	for(int i=n-1; i>0; i--) {
		ll temp = input[i]+sz[i]+sz[i]-n;
		int idx = lower_bound(input, input+n, temp)-input;
		if(input[idx] != temp) {
			printf("-1");
			return 0;
		}

		par[i] = idx;
		sz[idx]+=sz[i];
		sum[idx]+=sum[i]+sz[i];
	}

	if(sum[0] != input[0]) {
		printf("-1");
		return 0;
	}

	for(int i=1; i<n; i++) {
		printf("%d %d\n", v[par[i]].second, v[i].second);
	}
}


Measured memory_bytes: 5488
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    intmax_t N, K;
    intmax_t ans = 0;

    scanf("%jd%jd", &N, &K);

    if (K == 1) {
        ans = 0;
    } else {
        ans = N - K;
    }

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


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		int N = int.Parse(Console.ReadLine());
        string res = "Yes";
        // スペース区切りの整数の入力
		string[] words = new string[N];
        // 初期化
        for (int i = 0; i < N; i++){
            words[i] = "";
        }
        for (int i = 0; i < N; i++){

            string s = Console.ReadLine();
            // 検索
            for (int j = 0; j < i; j++){
                if (s == words[j]){
                    res = "No";
                }
            }
            // 代入
            words[i] = s;
            // しりとり
            if (i > 0){
                string t = words[i-1];
                int t_ind = t.Length - 1;
                string t_ = t.Substring(t_ind);
                string s_ = s.Substring(0, 1);
                if (t_ != s_){
                    res = "No";
                }
            }
        }
        //出力
        Console.WriteLine(res);
	}
}

Measured memory_bytes: 13140
#!/usr/bin/env python
# -*- coding: utf-8 -*-

S = input()

r1 = 0
r2 = 0
for i in range(len(S)):
    if int(S[i]) == (i % 2):
        r1 += 1
    else:
        r2 += 1
print(min(r1, r2))


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

int main(){
    int h, w;
    while(1){
        cin >> h >> w;
        if ( h == 0 && w == 0) break;
        for (int i = 0; i < h; i++){
            if (i == 0 || i == h - 1){
                for (int j = 0; j < w; j++) cout << "#"; 
            }
            else{
                cout << "#";
                for (int j = 0; j < w - 2; j++){
                    cout << ".";
                }
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

int H, W, K;
vector<string> cake(300);
vector<vector<int>> strawberry(300, vector<int>());
vector<vector<int>> cut_cake(300, vector<int>(300));
int i, j, k, l, m;
int num = 1;
int last, upper;

int main(){
    cin >> H >> W >> K;

    /*ケーキを取得*/
    for(int x = 0; x < H; x++) cin >> cake[x];  //cakeゲット


    /*イチゴの詳細な位置を管理*/
    for(int x = 0; x < H; x++){
        for(int y = 0; y < W; y++){
            if(cake[x][y] == '#') strawberry[x].push_back(y);  //イチゴの位置
        }
        if(strawberry[x].size() > 0) last = x;  //最後にイチゴが出現する列を取得
    }


    /*各行の最終イチゴ位置を左からW番目に修正*/
    for(int x = 0; x < H; x++){
      if(strawberry[x].size() == 0) continue;
      strawberry[x][strawberry[x].size()-1] = W-1;  //ラストイチゴ
    }


    i = 0; //iはカット始め
    while(i < H){
        j = 0;  //jはカット幅
        while(strawberry[i+j].size() == 0) ++j;  //カット幅j+1
        l = 0; //前回のイチゴの位置　初期は0とする
        upper = i + j;  //カット最後
        for(k = 0; k < strawberry[i+j].size(); k++){
            while(l <= strawberry[i+j][k]){
                if(i+j == last) upper = H-1;
                for(m = i; m <= upper; m++) cut_cake[m][l] = num;
                l += 1;
            }
            ++num;
        }
        i = upper + 1;  //次のカット始め
    }

    for(int x = 0; x < H; x++){
      for(int y = 0; y < W; y++) cout << cut_cake[x][y] << " ";
      cout << endl;
    }

    return 0;

}

Measured memory_bytes: 1920
#include <iostream>

int main(int argc, char const *argv[])
{
    int A=5,B=3;
    int ans;
    std::cin >> A >> B;
    if(A > B){
        ans = A+(A-1);
    }else if(B > A){
        ans = B+(B-1);
    }else{
        ans = A+B;
    }
    std::cout << ans << std::endl;

    return 0;
}

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

int main(){
    double n, m;

    cin >> n >> m;

    if(m - 2*n > 0){
        long long a = n + (m - 2*n)/4;
        printf("%lld\n", a);
    }
    else{
        long long a = m/2;
        printf("%lld\n", a);
    }

    return 0;
}

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

int main(){
  string s;
  cin>>s;
  if(s.size()<4)
    return 0*puts("No");
  if(s.substr(0,4)!="YAKI")
    return 0*puts("No");
  puts("Yes");
    
  return 0;
}

Measured memory_bytes: 256
S = input()
s1 = int(S[:2])
s2 = int(S[2:])

if 12>=s1>0 and 12>=s2>0:
    print('AMBIGUOUS')
elif 12>=s1>0:
    print('MMYY')
elif 12>=s2>0:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
from heapq import heappush, heappop

n, m = map(int, input().split())
arbeit = [[] for _ in range(m)]
for _ in range(n):
    a, b = map(int, input().split())
    if a > m:
        continue
    heappush(arbeit[a-1], -b)

ans = 0
next_vals = []
for i in range(m):
    if any(arbeit[i]):
        b = heappop(arbeit[i])
        heappush(next_vals, (b, i))
    if any(next_vals):
        b, i = heappop(next_vals)
        ans -= b
        if any(arbeit[i]):
            b = heappop(arbeit[i])
            heappush(next_vals, (b, i))
print(ans)

Measured memory_bytes: 93880
#include<stdio.h>
int main(void){
  long long int i,n,x=1;
  scanf("%lld",&n);
  for(i=2;i*i<=n;i++){
    if(n%i==0) x=i;
  }
  printf("%lld\n",x+n/x-2);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 100000007
typedef long long ll;
using namespace std;

int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(i==4)cout<<" ";
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll A[2019];
int main() {
    string S;
    cin >> S;
    int N = 0;
    ll ans = 0, t = 1;
    A[0] = 1;
    for (int i = S.size(); i--;) {
        N = (N + (S[i] - '0') * t) % 2019;
        ans += A[N]++;
        t = t * 10 % 2019;
    }
    cout << ans << endl;
}

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

class Tree {
public:
    int num = -1;
    Tree* left;
    Tree* right;

    Tree(int _num, Tree* _left=nullptr, Tree* _right=nullptr) :
        num(_num), left(_left), right(_right){}

    string to_str() {
        string ret = "[" + to_string(num) + "]";

        if (left != nullptr) {
            ret = "(" + left->to_str() + ")" + ret;
        } else {
            ret = "()" + ret;
        }

        if (right != nullptr) {
            ret += "(" + right->to_str() + ")";
        } else {
            ret += "()";
        }
        return ret;
    }
};

Tree* parse(string s) {
    if (s == "") return nullptr;

    int paren= 1;
    int left_idx = 1;
    while (paren) {
        if (s[left_idx] == '(') paren++;
        else if (s[left_idx] == ')') paren--;
        left_idx++;
    }
    string left_str = s.substr(1, left_idx-2);

    int num_idx = left_idx + 1;
    while (s[num_idx] != ']') num_idx++;
    int num = atoi(s.substr(left_idx + 1, num_idx - left_idx - 1).c_str());

    string right_str = s.substr(num_idx + 2, s.size() - num_idx - 3);

    Tree *left = parse(left_str);
    Tree *right = parse(right_str);
    Tree *ret = new Tree(num, left, right);
    return ret;
}

Tree* add(Tree* a, Tree* b){
    Tree* left = nullptr;
    if (a->left != nullptr && b->left != nullptr) {
        left = add(a->left, b->left);
    }

    int num = a->num + b->num;

    Tree* right = nullptr;
    if (a->right != nullptr && b->right != nullptr) {
        right = add(a->right, b->right);
    }

    Tree *ret = new Tree(num, left, right);
    return ret;
}

int main() {
    string a, b;
    cin >> a >> b;

    auto tree_a = parse(a);
    auto tree_b = parse(b);
    auto add_tree = add(tree_a, tree_b);
    cout << add_tree->to_str() << endl;
}



Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;
 
int main(){
    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(all(d));
    cout << d[n/2]-d[(n/2)-1] << endl;
return 0;
}

Measured memory_bytes: 640
def main():
    import sys
    input = sys.stdin.buffer.readline
    n = int(input())
    if (m:= n%10) in [2,4,5,7,9]:
        print('hon')
    elif m in [0,1,6,8]:
        print('pon')
    elif m == 3:
        print('bon')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin>>H>>W;
  vector<string> s(H);
  for (int i=0; i<H; i++)
    cin>>s[i];
  
  vector <int> dx{-1,0,-1,0,-1,1,1,1};
  vector <int> dy{-1,-1,0,1,1,1,0,-1};
  
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      if (s[i][j]=='.'){
        int count=0;
        for (int d=0; d<8; d++){
          if (i+dy[d]>=0 && i+dy[d]<H &&
              j+dx[d]>=0 && j+dx[d]<W ){
            if (s[i+dy[d]][j+dx[d]]=='#')
              count++;
          }
        }
        s[i][j]=char(count+'0');
      }
    }
  }
  
  for (int i=0;i<H;i++)
    cout<<s[i]<<endl;
}
        
            

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

int main(void){

    double r,l,m,pi;
    pi = 3.141592653589;
    cin >> r;
    l = 2 * pi * r;
    m = r * r * pi;
    printf("%.6lf %.6lf\n", m, l);
}


Measured memory_bytes: 3192
import java.util.Scanner;
class Main {
    public static void main(String[] args){
       Scanner scan = new Scanner(System.in);
       int x;
       for(int i = 1;; i++){
         x = scan.nextInt();
         if(x == 0) {
            break;
         }else{
            System.out.println("Case " + i + ": " + x);
         }
       }
    }
}

Measured memory_bytes: 41564
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] c = new int[n - 1];
		int[] s = new int[n - 1];
		int[] f = new int[n - 1];
		for(int i = 0 ; i < n - 1 ; i++) {
			c[i] = sc.nextInt();
			s[i] = sc.nextInt();
			f[i] = sc.nextInt();
		}
		for(int i = 0 ; i < n - 1 ; i++) {
			int time = s[i] + c[i];
			for(int j = i + 1 ; j < n - 1 ; j++) {
				int temp = s[j];
				while(true) {
					if(time == temp) {
						time = temp;
						break;
					}
					else if(time < temp) {
						time = temp;
						break;
					}
					temp += f[j];
				}
				time += c[j];
			}
			System.out.println(time);
		}
		System.out.println(0);
	}
}


Measured memory_bytes: 28036
n = int(input())
L = [[0]*10 for _ in range(10)]
for i in range(1,n+1):
    s = str(i)
    a,b = int(s[0]),int(s[-1])
    L[a][b] += 1
cnt = 0
for i in range(1,10):
    for j in range(1,10):
        cnt += L[i][j]*L[j][i]
print(cnt)


Measured memory_bytes: 3060
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
using namespace std;
int main(){
	
	string c[9];
	int	 p[9];
	int  s[9];
	
	for(int i=0;i<9;i++){
		int a,b;
		cin>>c[i];
		
		cin>>a>>b;
		
		p[i]=a+b;
		
		s[i]=200*a+300*b;
		
	}
	
	for(int i=0;i<9;i++)
		cout<<c[i]<<" "<<p[i]<<" "<<s[i]<<endl;
	
	
	
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
using namespace std;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }
template <typename X, typename T> auto make_vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_vectors(X x, Y y, Z z, Zs... zs) { auto cont = make_vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

int solve(int h, int w, const vector<vector<bool> > & f) {
    auto hr = make_vectors(h, w, int());
    REP (y, h) {
        for (int l = 0; l < w; ) {
            int r = l;
            while (r < w and not f[y][r]) ++ r;
            REP3 (m, l, r) {
                hr[y][m] = r - l;
            }
            l = r + 1;
        }
    }

    auto vr = make_vectors(h, w, int());
    REP (x, w) {
        for (int l = 0; l < h; ) {
            int r = l;
            while (r < h and not f[r][x]) ++ r;
            REP3 (m, l, r) {
                vr[m][x] = r - l;
            }
            l = r + 1;
        }
    }

    int ans = 0;
    REP (y, h) REP (x, w) {
        chmax(ans, hr[y][x] + vr[y][x] - 1);
    }
    return ans;
}

int main() {
    int h, w; cin >> h >> w;
    auto f = make_vectors(h, w, bool());
    REP (y, h) REP (x, w) {
        char c; cin >> c;
        f[y][x] = (c == '#');
    }
    cout << solve(h, w, f) << endl;
    return 0;
}


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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e3 + 10;

typedef pair<ll,int>    ii;

struct Edge {
    int v, c;
    ll  cost;

    Edge(int _v,int _c,ll  _cost) : v(_v), c(_c), cost(_cost)   {}
};

vector<int>  g[N];
vector<Edge> E;

void addEdge(int u,int v,int c,ll cost) {
    g[u].pb(sz(E));     E.pb(v,c, cost);
    g[v].pb(sz(E));     E.pb(u,0,-cost);
}

int S, T;
int p[N];
ll  d[N];

bool inc()  {
    for(int i = 0 ; i <= T ; ++i)
        d[i] = 1e18,
        p[i] = -1;

    d[S] = 0;
    p[S] = 1e9;

    vector<bool> inq(T + 1,0);
    queue<int>   qu;

    qu.push(S);

    while (qu.size())   {
        int u = qu.front(); qu.pop();
        inq[u] = 0;

        for(int i : g[u])   {
            int v = E[i].v;
            int C = E[i].cost;

            if (d[v] > d[u] + C && E[i].c > 0)  {
                d[v] = d[u] + C;
                p[v] = i;
                if(!inq[v]) {
                    inq[v] = 1;
                    qu.push(v);
                }
            }
        }
    }
    return  p[T] >= 0;
}
ll  MCMF()  {
    static int Flow = 0;
    static ll  Cost = 0;

    while (inc())   {
        int F = 1e9;
        for(int u = T ; u != S ;)   {
            int i = p[u];
            F = min(E[i].c,F);
            u = E[i ^ 1].v;
        }
        for(int u = T ; u != S ;)   {
            int i = p[u];
            E[i].c -= F;    i ^= 1;
            E[i].c += F;    u = E[i].v;
        }

        Flow += F;
        Cost += d[T] * F;
    }
    return  Cost;
}

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

    int n;  cin >> n;

    S = 0;
    T = 5 + n +n;

    int tot = 4;

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

        addEdge(S,++tot,c,0);

        for(int j = 0 ; j < 4 ; ++j)    {
            ll  C = 0;
            if (j & 1)  C -= x;
            else        C += x;
            if (j & 2)  C -= y;
            else        C += y;

            addEdge(tot,j + 1,c,C);
        }
    }
    for(int i = 0 ; i < n ; ++i)    {
        int x;  cin >> x;
        int y;  cin >> y;
        int c;  cin >> c;

        addEdge(++tot,T,c,0);

        for(int j = 0 ; j < 4 ; ++j)    {
            ll  C = 0;
            if (j & 1)  C += x;
            else        C -= x;
            if (j & 2)  C += y;
            else        C -= y;

            addEdge(j + 1,tot,c,C);
        }
    }
    cout << -MCMF() << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<double> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = K; i < N; i++) {
    if (A.at(i) > A.at(i-K)) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 4760
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll rui[222222];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  ll ans=0;
  vi A(n);
  for(auto &a:A){cin>>a;a--;}
  for(int i=1;i<=n;i++){
    rui[i]+=rui[i-1]+A[i-1];
  }
  map<ll,ll>cnt;
  for(int i=0;i<n+1;i++){
    if(i >= k)cnt[rui[i-k]%k]--;
    ans += cnt[rui[i]%k];
    cnt[rui[i]%k]++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 15872
N, M = map(int, input().split())
PS = [list(input().split()) for _ in range(M)]

C0 = [0 for _ in range(N + 1)]  # 正答フラグ
C1 = [0 for _ in range(N + 1)]  # WA数

for p, s in PS:
    if C0[int(p)] == 0:
        if s == "AC":
            C0[int(p)] = 1  # 正解フラグを1にする
        else:
            C1[int(p)] += 1  # wa数を増やす


num_ac = sum(C0)
num_wa = sum([i * j for i, j in zip(C0, C1)])

print(num_ac, num_wa)


Measured memory_bytes: 101720
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;
#define         rep(i,n)       for (int i = 0;i<(int)(n);i++)
#define         pi             3.14159265359
#define         nl             printf("\n")
#define         gcd(a,b)       __gcd(a,b)
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         pf             printf
#define         sf             scanf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
typedef long long int ll;

int main()
{

    FIO;
    int i,j,k,temp,n,f=0,x;int ans=0;
    cin>>n;
    int arr[n];
    rep(i,n)
        {
            cin>>arr[i];
            j=i;
            while(j--)
            {
                ans=ans+arr[i]*arr[j];
            }
        }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC081_C();
        }

        static void ABC081_C()
        {
            var NK = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = NK[0];
            var K = NK[1];
            var Ai = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var balls = new int[N + 1];
            for (var i = 0; i < N; i++)
                balls[Ai[i]] += 1;

            var list = balls.Where(x => x > 0).OrderByDescending(x => x).ToArray();
            var count = 0;
            if (list.Length <= K)
            {
                Console.WriteLine(count);
                return;
            }

            for (var i = 0; i < K; i++)
                count += list[i];
            Console.WriteLine(N - count);
        }
    }
}

Measured memory_bytes: 36420
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int fastpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

class Combination
{
public:

    vec fact, invfact;
    int MAX_N, mod;

    Combination(int MAX_N, int mod): MAX_N(MAX_N), mod(mod) {
        initialize();
    }

    void initialize(){
        fact = vec(MAX_N + 1);
        invfact = vec(MAX_N + 1);
        fact[0] = 1;
        FOR(i, 1, MAX_N + 1){
            fact[i] = (fact[i - 1] * i) % mod;
        }
        invfact[MAX_N] = fastpow(fact[MAX_N], mod - 2, mod);
        IREP(i, MAX_N){
            invfact[i] = (invfact[i + 1] * (i + 1)) % mod;
        }
    }

    int nCr(int n, int r){
        if(r > n || r < 0 || n < 0) return 0;
        if(n > MAX_N){
            MAX_N = n;
            initialize();
        }
        int a = fact[n];
        a = (a * invfact[r]) % mod;
        a = (a * invfact[n - r]) % mod;
        return a;
    }
};

int mod = 1000000007;

signed main(){

    int N, M; cin >> N >> M;
    
    int n = 2;
    map<int, int> m;
    while(M > 1){
        while(M % n == 0){
            m[n] += 1;
            M /= n;
        }
        n++;
    }
    vec l;
    for(auto p: m) l.push_back(p.second);

    Combination C(N, mod);
    int ans = 1;
    REP(i, l.size()){
        ans *= C.nCr(N - 1 + l[i], l[i]);
        ans %= mod;
    }
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

typedef long long ll;

int main(){
	int N;
	cin >> N;
	ll X[N], Y[N];
	for(int i=0; i<N; i++){
		cin >> X[i] >> Y[i];
		if(i>0 && (abs((X[i]+Y[i])%2) != abs((X[i-1]+Y[i-1])%2))){
			cout << -1 << endl;
			return 0;
		}
	}
	if((X[0]+Y[0])%2 == 0){
		cout << 32 << endl;
		ll d[32];
		d[0] = 1;
		d[1] = 1;
		for(int i=2; i<32; i++){
			d[i] = d[i-1]*2;
		}
		for(int i=31; i>=0; i--){
			cout << d[i] << " ";
		}
		cout << endl;
		for(int i=0; i<N; i++){
			X[i] = X[i] + 1;
			Y[i] = Y[i];
			for(int j=31; j>0; j--){
				if((abs(X[i]-d[j])+abs(Y[i])) <= d[j]-1){
					X[i] = X[i] - d[j];
					cout << "R";
				}else if((abs(X[i]+d[j])+abs(Y[i])) <= d[j]-1){
					X[i] = X[i] + d[j];
					cout << "L";
				}else if((abs(X[i])+abs(Y[i]-d[j])) <= d[j]-1){
					Y[i] = Y[i] - d[j];
					cout << "U";
				}else{
					Y[i] = Y[i] + d[j];
					cout << "D";
				}
			}
			cout << "L" << endl;
		}
	}else{
		cout << 31 << endl;
		ll dd[31];
		dd[0] = 1;
		for(int i=1; i<31; i++){
			dd[i] = dd[i-1]*2;
		}
		for(int i=30; i>=0; i--){
			cout << dd[i] << " ";
		}
		cout << endl;
		for(int i=0; i<N; i++){
			for(int j=30; j>=0; j--){
				if((abs(X[i]-dd[j])+abs(Y[i])) <= dd[j]-1){
					X[i] = X[i] - dd[j];
					cout << "R";
				}else if((abs(X[i]+dd[j])+abs(Y[i])) <= dd[j]-1){
					X[i] = X[i] + dd[j];
					cout << "L";
				}else if((abs(X[i])+abs(Y[i]-dd[j])) <= dd[j]-1){
					Y[i] = Y[i] - dd[j];
					cout << "U";
				}else{
					Y[i] = Y[i] + dd[j];
					cout << "D";
				}
			}
			cout << endl;
		}
	}
	return 0;
}

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

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

#define frep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) frep(i, 0, (n))
#define rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100010;
const int INF = 1e9;
const int MOD = 1000000007;
const string END = "\n";

void solve(){
	int n; cin >> n;
	string s; cin >> s;
	int black[200002], white[200002];
	black[0] = 0;
	white[0] = 0;
	rep(i, n){
		if(s[i] == '#'){
			black[i+1] = black[i] + 1;
			white[i+1] = white[i];
		}else if(s[i] == '.'){
			black[i+1] = black[i];
			white[i+1] = white[i] + 1;
		}
	}
	int ans = INF;
	rep(i, n+1){
		ans = min(ans, black[i] + white[n] - white[i]);
	}
	cout << ans << END;
}

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


Measured memory_bytes: 2196
college = Array.new(4).map { [  
                               ['', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                               ['', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                               ['', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
                             ] }

input = []

gets.to_i.times do
  input << gets.split(' ').map(&:to_i)
end

input.each do |e|
  b, f, r, v = e
  college[b - 1][f - 1][r] = college[b - 1][f - 1][r] + v
end

college.each_with_index do |ary, i|
  puts ary.map{ |e| e.join(' ') }.join("\n")
  break if college.size - 1 == i
  puts '#' * 20
end

Measured memory_bytes: 8788
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <stdlib.h>
#include <time.h>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long
#define INF 2000000000

using namespace std;
vector<ll> memo(87, -1);
ll luca(int x) {
	if (x == 0)return 2;
	else if (x == 1)return 1;

	if(memo[x]==-1) return memo[x]=luca(x - 1) + luca(x - 2);
	else return memo[x];
}

int main() {
	int n;
	cin >> n;
	//n--;
	cout << luca(n) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  vector<int> vec(A);
  int sum=0;
  for(int i=0;i<A;i++){
    cin >> vec[i];
  }
    sort(vec.begin(),vec.end());
  for(int i=0;i<B;i++){
    sum += vec[A-1-i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    char s[3];
    scanf("%s",s);
    for(int i = 0; i < 3; i++){
        if(s[i] == '1'){s[i] = '9';}
        else if(s[i] == '9'){s[i] = '1';}
    }
    printf("%s\n", s);
    return 0;
}

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

/*
#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")*/

#define I inline void 
#define S struct 
#define vi vector<int> 
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std ; 
using ll = long long ; 
using ld = long double ; 

const int N = 1e5 + 7 , mod = 1e9 + 7 ; 
const int inf = N ; 
// How interesting!

int n ;
ll dp[N] ; 

ll solve(int x){
        if(x == 0)
                return 1 ;
        if(x < 0)
                return 0 ; 
        if(~dp[x])
                return dp[x] ;
        ll ret = 0; 
        for(int i = 3 ; i <= x ;i++){
                ret += solve(x - i) ; 
                ret %= mod ;
        }
        return dp[x] = ret ; 
}

int main(){
        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ;
        memset(dp , -1 , sizeof dp) ; 
        //freopen("in.in" , "r" , stdin) ;
        cin >> n; 
        cout<< solve(n) %mod; 
        return 0 ; 
}

Measured memory_bytes: 4424
N = int(input())
steps = list(map(int, input().split(" ")))

costs = [None] * N
costs[0] = 0
costs[1] = abs(steps[1] - steps[0])
if N > 2:
    costs[2] = min(abs(steps[2] - steps[0]), costs[1] + abs(steps[2] - steps[1]))

for i in range(3, N):
    cost1 = costs[i-1] + abs(steps[i-1] - steps[i])
    cost2 = costs[i-2] + abs(steps[i-2] - steps[i])
    costs[i] = min(cost1, cost2)

print(costs[N-1])


Measured memory_bytes: 13900
n=int(input())
s1=input()
s2=input()
if s1[0]!=s2[0]:
    ans=6
else:
    ans=3
mod=10**9+7
for i in range(1,n):
    if s1[i]==s1[i-1]:
        continue
    elif s1[i]==s2[i] and s1[i-1]==s2[i-1]:
        ans*=2
    elif s1[i]==s2[i] and s1[i-1]!=s2[i-1]:
        ans*=1
    elif s1[i]!=s2[i] and s1[i-1]==s2[i-1]:
        ans*=2
    else:
        ans*=3
print(ans%mod)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			string[] s = Console.ReadLine().Split(' ');
			int H = int.Parse(s[0]);
			int W = int.Parse(s[1]);
			string[,] table = new string[H, W];
			char ansW = ' ';
			int ansH = 0;
			for (int i = 0; i < H; i++)
			{
				s = Console.ReadLine().Split(' ');
				for (int j = 0; j < W; j++)
				{
					table[i, j] = s[j];
					if (table[i, j] == "snuke")
					{
						ansW = Convert.ToChar(Convert.ToInt32('A') + j);
						ansH = i + 1;
						break;
					}
				}
			}
			Console.WriteLine("{0}{1}",ansW,ansH);
		}
	}
}


Measured memory_bytes: 2904