akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

string s;

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

    int x = s.size();
    if(x <= n)
        cout << s << "\n";

    else
    {
        for(int i = 0; i < n; i ++)
            cout << s[i];

        cout << "...\n";
    }

    return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 400005
char s[MAXN],t[MAXN];
int d[300];
int main()
{
	scanf("%s%s",s,t);
	int len=strlen(s);
	memset(d,-1,sizeof(d));
	for(int i=0;i<len;i++)
	{
		if(d[s[i]-'a']==-1) d[s[i]-'a']=t[i]-'a';
		else
		{
			if(d[s[i]-'a']!=t[i]-'a')
			{
				printf("No\n");
				return 0;
			}
		}
	}
	memset(d,-1,sizeof(d));
	for(int i=0;i<len;i++)
	{
		if(d[t[i]-'a']==-1) d[t[i]-'a']=s[i]-'a';
		else
		{
			if(d[t[i]-'a']!=s[i]-'a')
			{
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}


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

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

	cin.ignore(256, '\n');

	string altar; cin >> altar;

	int ops{ 0 };

	for (int white_start = 0, red_start = altar.size() - 1; true; ++ops)
	{
		int i_red = red_start;
		for (; i_red > white_start + 1 && altar[i_red] != 'R'; --i_red);

		int i_white = white_start;
		for (; i_white < i_red - 1 && altar[i_white] != 'W'; ++i_white);

		if (altar[i_red] != 'R' || altar[i_white] != 'W') { break; }

		white_start = i_white + 1;
		red_start = i_red - 1;
	}
	
	cout << ops << '\n';
}

Measured memory_bytes: 3748
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 998244353;
const ll HIGHINF = (ll)1e18;

int n;
V<int> a;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    ll suma = accumulate(ALL(a), 0LL);

    ll ans = 1;
    for (int i = 0; i < n; i++) ans = ans * 3 % MOD;

    vvll dp(n + 1, vll(suma + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < suma; j++) {
            dp[i + 1][j] += dp[i][j] * 2 % MOD;
            if (dp[i + 1][j] >= MOD) dp[i + 1][j] -= MOD;
            if (j + a[i] <= suma) {
                dp[i + 1][j + a[i]] += dp[i][j];
                if (dp[i + 1][j + a[i]] >= MOD) dp[i + 1][j] -= MOD;
            }
        }
    }

    ll rem = 0;
    for (int i = (suma + 1) / 2; i <= suma; i++) {
        rem += dp[n][i];
        if (rem >= MOD) rem -= MOD;
    }
    rem = rem * 3 % MOD;

    vvll dp2(n + 1, vll(suma + 1, 0));
    dp2[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < suma; j++) {
            dp2[i + 1][j] += dp2[i][j];
            if (dp2[i + 1][j] >= MOD) dp2[i + 1][j] -= MOD;
            if (j + a[i] <= suma) {
                dp2[i + 1][j + a[i]] += dp2[i][j];
                if (dp2[i + 1][j + a[i]] >= MOD) dp2[i + 1][j] -= MOD;
            }
        }
    }

    ans -= rem;
    if (ans < 0) ans += MOD;
    if (!(suma & 1)) ans += 3 * dp2[n][suma / 2] % MOD;
    if (ans >= MOD) ans -= MOD;

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 423872
#include <iostream>
#include <cstdio>
#include <map>
#include <cmath>
#include <queue>
#include <cstring>

using namespace std;
const int maxn = 1e7+5;
typedef long long ll;

map<int,int>mp;
int num[maxn];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    ll ans = 0;
    num[0] = 0;
    //mp[0] = 1;
    for(int i=1; i<=n; i++)
    {
        int a;
        scanf("%d",&a);
//        if(a%m==0)
//            ans++;
        num[i] = (num[i-1] + a)%m;
        if(num[i] == 0)
            ans++;
        ans += mp[num[i]];
        mp[num[i]] ++;

    }

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


    return 0;
}


Measured memory_bytes: 3584
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	a, b, h := ReadInt(), ReadInt(), ReadInt()
	fmt.Println((a + b) * h / 2)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 1840
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

int N;
int tanka[] = {5,7,5,7,7};

int f(){
	vector<int>a(N);
	string s;
	REP(i,N){
		cin>>s;
		a[i] = s.size();
	}
	int now = 0,tmp = 0;
	REP(i,N){
		now = i;
		tmp = 0;
		REP(j,5){
			while(tmp<tanka[j]){
				tmp += a[now];
				now++;
			}
			if(tmp>tanka[j])break;
			else if(j==4)return i+1;
			tmp = 0;
		}
	}
}

signed main(){
	vector<int>ans;
	while(cin>>N,N)ans.push_back(f());
	for(auto e:ans)cout<<e<<endl;
}


Measured memory_bytes: 3148
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] x = new long[n];
        for(int i = 0; i < n; i++){
            x[i] = sc.nextLong();
        }
        long ans = 0;
        boolean isZero = false;
        while(!isZero){
            isZero = true;
            long prev = 0;
            for(int i = 0; i < n; i++){
                if(prev <= 0 && x[i] > 0){
                    ans++;
                    isZero = false;
                    prev = x[i];
                    x[i]--;
                }else if (prev > 0 && x[i] > 0){
                    prev = x[i];
                    x[i]--;
                }else{
                    prev = x[i];
                }
                
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include  <list>
#include  <utility>
#include  <memory>
#include  <cstring>
#include  <fstream>
#include  <numeric>
using namespace std;
long long a[200003],s[200003];
int main(){
  long long n,ans=0;
  cin>>n;
  for (long long i=1;i<=n;i++){
    long long x;
    cin>>x;
    s[i]=s[i-1]+x;
    a[i]=a[i-1]^x;
  }
  long long l=1;
  for (long long i=1;i<=n;i++){
  	for (;(s[i]-s[l-1])!=(a[i]^a[l-1]);l++);
    ans+=i-l+1;
  }
  cout<<ans;
  return 0;
}

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

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

using namespace std;

// selectionSort(A, N) // N個の要素を含む0-オリジンの配列A
//     for i が 0 から N-1 まで
//         minj = i
//         for j が i から N-1 まで
//             if A[j] < A[minj]
//                 minj = j
//         A[i] と A[minj] を交換

int selectionSort(int A[], int n) {
    int i, j, tmp;
    int m_j;
    int cnt = 0;
    bool flag = false;
    
    rep(i, 0, n) {
        m_j = i;
        rep(j, i, n) {
            if (A[m_j] > A[j]) {
                m_j = j;
                flag = true;
            }
        }
        if (flag) cnt++;
        tmp = A[i];
        A[i] = A[m_j];
        A[m_j] = tmp;
        flag = false;
    }

    rep(i, 0, n) { 
        if (i == n-1) printf("%d", A[i]);
        else printf("%d ", A[i]);
    }
    cout << endl;

    return cnt++;
}

int main () {
    int i, n; cin >> n;
    int A[n];
    rep(i, 0, n) cin >> A[i];
    
    printf("%d\n", selectionSort(A, n));
}


Measured memory_bytes: 3228
// D - Gathering Children
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	string s;
	cin >> s;
	int n = s.size();
	vector<int> ans(n);

	for (int i = 0; i < n; ) {
		int l = i, m, r;
		while (i < n && s[i] == 'R') i++;
		m = i;
		while (i < n && s[i] == 'L') i++;
		r = i;
		ans[m] = (m - l) / 2 + (r - m) - (r - m) / 2;
		ans[m - 1] = (m - l) - (m - l) / 2 + (r - m) / 2;
	}

	for (int i = 0; i < n; i++) cout << (i ? " " : "") << ans[i];
	cout << "\n";

	return 0;
}


Measured memory_bytes: 1024
program answer
  implicit none
  integer :: i, a, b, an, j, ans
  character(len=1000) :: S, T
  read(*,*) S
  read(*,*) T
  a=len_trim(S)
  b=len_trim(T)

  !do i = 1, a
   !  if(S(i:i+b-1)==T) then
    !    write(*,*) 0
    !    stop
    ! end if
  !end do

  ans=0
  do i = 1, a-b+1
     an=0
     do j = 0, b-1
        if(S(i+j:i+j)==T(j+1:j+1)) then
           an=an+1
        end if
     end do
     ans=max(ans,an)
  end do

  write(*,*) b-ans
  stop
 end program answer

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(3e2 + 5);
const int MAX_ELEM = (int)(3e2 + 5);
const ll MOD = (ll)(998244353);

int n;
int a[MAX_N];

ll dp_single[2][MAX_N * MAX_ELEM];
ll dp_double[2][MAX_N * MAX_ELEM];

int max_size;
int acc;

ll ans;

ll calc_whole() {
  ll ret = 1LL;
  for (int i = 0; i < n; ++i) {
    ret *= 3;
    ret %= MOD;
  }
  return ret;
}

ll calc_single() {
  dp_single[0][0] = 1LL;

  for (int i = 1; i <= n; ++i) {
    int last_ind = (i - 1) % 2;
    int cur_ind = i % 2;

    for (int j = 0; j <= max_size; ++j) dp_single[cur_ind][j] = 0;

    for (int j = 0; j <= max_size; ++j) {
      dp_single[cur_ind][j + a[i]] += dp_single[last_ind][j]; // paint a[i] as red;
      dp_single[cur_ind][j + a[i]] %= MOD;

      dp_single[cur_ind][j] += 2 * dp_single[last_ind][j]; // paint a[i] as green or blue, sum of red don't change
      dp_single[cur_ind][j] %= MOD;
    }
  }

  int half = (acc - 1) / 2 + 1;

  int n_ind = n % 2;

  ll ret = 0LL;
  for (int i = half; i <= max_size; ++i) {
    ret += dp_single[n_ind][i];
    ret %= MOD;
  }

  return ret;
}

ll calc_double() {
  dp_double[0][0] = 1LL;

  for (int i = 1; i <= n; ++i) {
    int last_ind = (i - 1) % 2;
    int cur_ind = i % 2;

    for (int j = 0; j <= max_size; ++j) dp_double[cur_ind][j] = 0;

    for (int j = 0; j <= max_size; ++j) {
      dp_double[cur_ind][j + a[i]] += dp_double[last_ind][j]; // paint a[i] as red;
      dp_double[cur_ind][j + a[i]] %= MOD;

      dp_double[cur_ind][j] += dp_double[last_ind][j]; // paint a[i] as some-color not red, sum of red don't change
      dp_double[cur_ind][j] %= MOD;
    }
  }

  int n_ind = n % 2;

  if (acc % 2 == 0) {
    return dp_double[n_ind][acc / 2];
  }
  else {
    return 0LL;
  }
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {
    scanf("%d", &(a[i]));
  }

  max_size = MAX_ELEM * n;
  acc = accumulate(a + 1, a + n + 1, 0);

  ll num_whole = calc_whole();
  ll num_single = calc_single();
  ll num_double = calc_double();

  ans = 0LL;

  ans += num_whole;
  ans %= MOD;

  ans -= 3 * num_single;
  ans %= MOD;

  ans += 3 * num_double;
  ans %= MOD;

  if (ans < 0) ans += MOD;

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

  return 0;
}


Measured memory_bytes: 3200
#include <cstdio>

using namespace std;

int main() {
  char s[19];
  scanf("%s", s);
  int cnt = 0;
  for (int i = 0; s[i]; ++i) {
    cnt += s[i] == 'x';
  }
  puts(15 - cnt >= 8 ? "YES" : "NO");
}


Measured memory_bytes: 128
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{fastout, input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize, abc: (i64, i64, i64),
        ss: [String; n],
    }

    let (mut a, mut b, mut c) = abc;

    let mut res = "Yes\n".to_string();

    for i in 0..n {
        let s = &ss[i];
        match s.as_str() {
            "AC" => {
                let first_mod = if i < n-1 && (&ss[i+1] == "AB") {
                    true
                } else {
                    false
                };
                if !modify(&mut a, &mut c, "A\n", "C\n", &mut res, first_mod) {
                    println!("No");
                    return;
                }
            }
            "AB" => {
                let first_mod = if i < n-1 && (&ss[i+1] == "AC") {
                    true
                } else {
                    false
                };
                if !modify(&mut a, &mut b, "A\n", "B\n", &mut res, first_mod) {
                    println!("No");
                    return;
                }
            }
            "BC" => {
                let first_mod = if i < n-1 && (&ss[i+1] == "AB") {
                    true
                } else {
                    false
                };
                if !modify(&mut b, &mut c, "B\n", "C\n", &mut res, first_mod) {
                    println!("No");
                    return;
                }
            }
            _ => unreachable!(),
        }
    }

    print!("{}", res);

}

fn modify(x: &mut i64, y: &mut i64, sx: &str, sy: &str, res: &mut String, first_mod: bool) -> bool {
    if *x == 0 && *y == 0 {
        return false;
    }
    if *x == 0 {
        *x += 1;
        *y -= 1;
        res.push_str(sx);
        return true;
    }
    if *y == 0 {
        *x -= 1;
        *y += 1;
        res.push_str(sy);
        return true;
    }
    if first_mod {
        *x += 1;
        *y -= 1;
        res.push_str(sx);
        return true;
    }
    *x -= 1;
    *y += 1;
    res.push_str(sy);
    true
}

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

int main()
{
	int n,a[25],ans=0;
	cin >> n;
	for (int i = 1; i <=n; i++) {
		int k;
		cin >> k;
		a[k] = i;
	}
	for (int i = 1; i <= n; i++) {
		int b;
		cin >> b;
		ans += b;
	}
	for (int i = 1; i < n; i++) {
		int c;
		cin >> c;
		if (a[i + 1] == a[i] + 1)
			ans += c;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
sc = [0]*m
for i in range(m):
    sc[i] = list(map(int,input().split()))
ans = 10**5
z = 10**5
if n == 1:
    z = 0
for i in range(min(10**(n-1),z),10**n):
    x = list(str(i))
    sw = 1
    for j in range(m):
        if x[sc[j][0]-1] == str(sc[j][1]):
            pass
        else:
            sw = 0
            break
    if sw == 1:
        ans = min(ans,i)
if ans == 10**5:
    print(-1)
else:
    print(ans)

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

using P = pair<ll, ll>;
using Pd = pair<pair<ll, ll>, ll>;
ll L;

const int MAX_N = 310;
ll G[MAX_N][MAX_N];

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

  ll N, M;
  cin >> N >> M >> L;

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

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

  ll Q;
  cin >> Q;
  vector<P> st;
  ll s, t;
  for(int i = 0; i < Q; i++){
    cin >> s >> t;
    s--;
    t--;
    st.push_back(P(s, t));
  }

  vector<vector<ll>> ans(N);
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      ans[i].push_back(INF);
    }
  }

  vector<vector<P>> d(N, vector<P>(N, {INF, INF}));

  for(int s = 0; s < N; s++){
    // ダイクストラっぽいことをやる

    d[s][s] = {0, 0};
    priority_queue<pair<P, ll>, vector<pair<P, ll>>, greater<pair<P, ll>>> que;

    que.push(make_pair(P(0, 0), s));

    while(!que.empty()){
      auto p = que.top();
      que.pop();
      
      ll v = p.second;
      ll cnt = p.first.first;
      ll dis = p.first.second;

      if(p.first > d[s][v]) continue;

      for(ll i = 0; i < N; i++){
        ll e = G[v][i];
        if(i == v) continue;
        if(e > L) continue;

        ll newdv = dis + e;
        
        P np = {0, 0};
        if(newdv > L) np = {cnt + 1, e};
        else np = {cnt, newdv};

        if(chmin(d[s][i], np)) que.push(make_pair(np, i));
      }
    }
  }

  ll tmpans = 0;
  for(int i = 0; i < Q; i++){
    tmpans =d[st[i].first][st[i].second].first; 
    if(tmpans >= INF){
      cout << -1 << endl;;
    }else{
      cout << tmpans << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 6640
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int Y, X, T, lastY=0, lastX=0, lastT=0, N;
	scanf("%d", &N);
	while(N--){
		scanf("%d %d %d", &T, &X, &Y);
		int diff = (T - lastT) - abs(Y - lastY) - abs(X - lastX);
		if(diff < 0 || diff % 2 == 1){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}


Measured memory_bytes: 128
#include<stdio.h>


int main()
{

    int a,b,c,i,j=0,sum=0,max,x,min,count1=0,count2=0,P;

    scanf("%d%d%d",&a,&b,&c);

    int A[b+1],B[a+1];
    
    
    for(i=0; i<a+1; i++){
        
        B[i]=0;
    }
        

    for(i=1;i<=b;i++){

        scanf("%d",&A[i]);

        B[A[i]]=1;

    }






    for(i=c;i>0;i--){

        if(B[i]==1) count1++;


    }

    for(i=c;i<a+1;i++){

        if(B[i]==1) count2++;


    }

    if(count1>count2) printf("%d\n",count2);

    else printf("%d\n",count1);







    return 0;

}



Measured memory_bytes: 1720
n, m, c = list(map(int, input().split()))
b = list(map(int, input().split()))
a = []
for _ in range(n):
  a.append(list(map(int, input().split())))

ans = 0
for h in range(n):
  if sum([a[h][i] * b[i] for i in range(m)]) + c > 0:
    ans += 1

print(ans)


Measured memory_bytes: 3060
s = gets.chomp
k = gets.to_i

rl = s.chars.slice_when { |i, j| i != j }.map { |e| e.size }
count = k * rl.map { |e| e / 2 }.inject(:+)

if rl.size == 1
  puts s.size * k / 2
elsif s[0] == s[-1]
  puts count - (k - 1) * (rl[0] / 2 + rl[-1] / 2 - (rl[0] + rl[-1]) / 2)
else
  puts count
end

Measured memory_bytes: 1788
#include <cstdio>

//input
int a, b;

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

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

void solve(){
	printf("%d %d\n", gcd(a, b), lcm(a, b));
}

int main(int argc, char const *argv[]){

	while(scanf("%d %d", &a, &b) != EOF){
		solve();
	}

	return 0;
}

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f;
const int MOD=1000000007;

char s[2000][2000];
int id[2000][2000];
int dist[1100][1100];

int d[30][30];
ll dp[1<<22][22];

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

int main(){
	int h,w,K;cin>>h>>w>>K;
	vector<P>v;
	int sid=0;
	int eid=0;
	rep(i,h){
		scanf("%s",s[i]);
		rep(j,w){
			if(s[i][j]=='a'||s[i][j]=='s'||s[i][j]=='e'){
				id[i][j]=v.size();
				if(s[i][j]=='s')sid=v.size();
				if(s[i][j]=='e')eid=v.size();
				v.push_back(P(i,j));
			}
		}
	}
	memset(d,0x3f,sizeof(d));
	rep(i,v.size()){
		queue<P>que;
		memset(dist,0x3f,sizeof(dist));
		dist[v[i].first][v[i].second]=0;
		que.push(P(v[i].first,v[i].second));
		while(!que.empty()){
			P p=que.front();que.pop();
			rep(k,4){
				int nx=p.first+dx[k],ny=p.second+dy[k];
				if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]!='#'&&dist[nx][ny]>dist[p.first][p.second]+1){
					dist[nx][ny]=dist[p.first][p.second]+1;
					que.push(P(nx,ny));
				}
			}
		}
		rep(j,v.size()){
			d[i][j]=dist[v[j].first][v[j].second];
		}
	}
	memset(dp,0x3f,sizeof(dp));
	dp[1<<sid][sid]=0;
	rep(i,1<<v.size())rep(j,v.size()){
		if(dp[i][j]==INFL)continue;
		rep(k,v.size()){
			if(i>>k&1)continue;
			if(d[j][k]==INF)continue;
			dp[i|1<<k][k]=min(dp[i|1<<k][k],dp[i][j]+d[j][k]);
		}
	}
	ll Min=INFL;
	rep(i,1<<v.size()){
		if(__builtin_popcount(i)>=K+2)Min=min(Min,dp[i][eid]);
	}
	if(Min==INFL)puts("-1");
	else cout<<Min<<endl;
}


Measured memory_bytes: 370456
#include <stdio.h>
long long s;
int main(void){
    scanf("%lld",&s);
    printf("%lld %lld %lld %lld %lld %lld\n",0,0,1,1000000000,(s-1)/1000000000+1,((s-1)/1000000000+1)*1000000000-s);
}

Measured memory_bytes: 128
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

int main()
{
    int a, b;
    string s;
    cin >> a >> b >> s;
    for (int i = 0; i < a; i++)
    {
        if (s[i] - '0' < 0 || s[i] - '0' > 10)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    if (s[a] != '-')
    {
        cout << "No" << endl;
        return 0;
    }
    for (int i = a + 1; i < a + b + 1; i++)
    {
        if (s[i] - '0' < 0 || s[i] - '0' > 10)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///

int h, w;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		cin >> w >> h;
		if (!w)break;
		vector<vector<vvi>> v(w, vector<vvi>(h, vvi(w, vi(h, INF))));
		REP(i, 2 * h - 1) {
			if (i % 2 == 0) {
				REP(j, w - 1) {
					cin >> v[j][i / 2][j + 1][i / 2];
					v[j + 1][i / 2][j][i / 2] = v[j][i / 2][j + 1][i / 2];
				}
			}
			else {
				REP(j, w) {
					cin >> v[j][(i - 1) / 2][j][(i + 1) / 2];
					v[j][(i + 1) / 2][j][(i - 1) / 2] = v[j][(i - 1) / 2][j][(i + 1) / 2];
				}
			}
		}
		queue<pii> q;
		q.push({ 0,0 });
		vvi level(w, vi(h, INF));
		level[0][0] = 0;
		while (!q.empty()) {
			auto c = q.front(); q.pop();
			int cx = c.first, cy = c.second;
			REP(i, 4) {
				int nx = cx + dx[i * 2], ny = cy + dy[2 * i];
				if (nx < w&&ny < h&&nx >= 0 && ny >= 0 && v[cx][cy][nx][ny] == 0 && level[nx][ny]==INF) {
					q.push({ nx,ny });
					level[nx][ny] = level[cx][cy] + 1;
				}
			}
		}

		if (level[w - 1][h - 1] == INF)cout << 0 << endl;
		else cout << level[w - 1][h - 1] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 7284
#include<iostream>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b){
    return b==0 ? a : gcd(b, a%b);
}

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

int main(){
    ll a, b;
    cin >> a >> b;
    cout << lcm(a,b) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**9
    n,m=MI()
    s=[LI() for _ in range(n)]
    c=[LI() for _ in range(m)]
    ans=[0]*n
    for si,(sx,sy) in enumerate(s):
        mn=inf
        mi=0
        for ci,(cx,cy) in enumerate(c):
            d=abs(cx-sx)+abs(cy-sy)
            if d<mn:
                mn=d
                mi=ci
        ans[si]=mi
    for a in ans:
        print(a+1)

main()

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

int main() {
  int N;
  cin >> N;
  vector<long> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  if(A.size() != N){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
  
  return 0;
}


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

int main() {
    int n = 0;
    scanf("%d\n", &n);
    char s[n][12];
    for (int i=0; i<n; i++) {
        fgets(s[i], 12, stdin);
        int length = strlen(s[i]);
        s[i][length-1] = '\0';
        if (i == 0) continue;
        else {
            if (s[i][0] != s[i-1][strlen(s[i-1])-1]) {
                printf("No\n");
                return 0;
            }
            for (int j=0; j<i; j++) {
                if (!strcmp(s[i], s[j])) {
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#undef		FILE_INPUT_DEFINE
#ifdef		FILE_INPUT_DEFINE
#include	<fstream>
#endif		// FILE_INPUT_DEFINE

#include	<iostream>
#include	<cstdio>

using namespace std;

#define		MAX		100000
int		A[MAX];

void swap(int a, int b)
{
	int		temp = A[a];

	A[a] = A[b];
	A[b] = temp;
}

int		Partition(int p, int r)
{
	int		x = A[r];
	int		i = p - 1;

	for (int j = p; j < r; ++j)
	{
		if (A[j] <= x)
		{
			i = i + 1;
			swap(i, j);
		}
	}

	swap(i + 1, r);

	return (i + 1);
}

int main()
{
#ifdef		FILE_INPUT_DEFINE
	// input from txt
	std::ifstream in(R"(C:\Temp\input.txt)");
	std::cin.rdbuf(in.rdbuf());
#endif		// FILE_INPUT_DEFINE

	int		n;
	cin >> n;

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

	int ans = Partition(0, n - 1);

	for (int i = 0; i < n; ++i)
	{
		if (i != 0)		cout << " ";
		if (i != ans)
		{
			cout << A[i];
		}
		else
		{
			cout << "[" << A[i] << "]";
		}
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;

int main(void) {
    i64 n, m, ans = 0;
    cin >> n >> m;
    vector<i64> c(n + 2);
    for (i64 i = 0; i < m; i++) {
        i64 l, r;
        cin >> l >> r;
        c[l]++;
        c[r + 1]--;
    }
    for (i64 i = 1; i < n + 2; i++) {
        c[i] += c[i - 1];
    }
    for (i64 i = 1; i < n + 1; i++) {
        if (c[i] == m) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int a, b, c; cin >> a >> b >> c;
    if(a==b)cout << c << ln;
    else if(a==c)cout << b << ln;
    else cout << a << ln;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

const long double eps = 1e-9;
const int INF = 2e9;

char dx[250], dy[250];
vector <int> x, y;
vector <char> d;
int n;

inline long double eval(long double t) {
    long double xmx = -INF, ymx = -INF, xmn = INF, ymn = INF;

    for(int i = 1; i <= n; i++) {
        long double cx = x[i] + dx[d[i]] * t;
        long double cy = y[i] + dy[d[i]] * t;

        xmx = max(xmx, cx);
        ymx = max(ymx, cy);
        xmn = min(xmn, cx);
        ymn = min(ymn, cy);
    }

    return 1.0 * (xmx - xmn) * (ymx - ymn);
}

int X[250][2], Y[250][2];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    dx['L'] = -1, dx['R'] = 1;
    dy['U'] = 1, dy['D'] = -1;

    cin >> n;

    for(i = 0; i < 250; i++) {
        X[i][0] = INF, X[i][1] = -INF;
        Y[i][0] = INF, Y[i][1] = -INF;
    }

    x.resize(n + 1), y.resize(n + 1);
    d.resize(n + 1);

    for(i = 1; i <= n; i++) {
        cin >> x[i] >> y[i] >> d[i];
        X[d[i]][0] = min(X[d[i]][0], x[i]);
        X[d[i]][1] = max(X[d[i]][1], x[i]);
        Y[d[i]][0] = min(Y[d[i]][0], y[i]);
        Y[d[i]][1] = max(Y[d[i]][1], y[i]);
    }

    /*long double l = 0, r = 2e8;
    long double ans = eval(0);

    while(r - l > eps) {
        long double mid = (l + r) * 0.5;
        long double a = eval(mid), b = eval(mid + eps);

        ans = min(ans, min(a, b));

        if(a - b >= 0) {
            l = mid;
        }
        else {
            r = mid;
        }
    }*/

    long double ans = eval(0);
    int res = 0;

    for(int step = 1 << 28; step; step >>= 1) {
        long double a = eval((res + step) * 0.5);
        long double b = eval((res + step + 1) * 0.5);
        ans = min(ans, min(a, b));
        if(a - b >= 0) {
            res += step;
        }
    }

    ans = min(ans, eval((res + 1) * 0.5));

    cout << fixed << setprecision(20) << ans;

    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];

int main() {
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    ll ans = 0;
    rep(i, 0, n){
        if(a[i] % 2 == 0) {
            ll tmp = a[i];
            while (true) {
                ans++;
                tmp = tmp >> 1;
                if(tmp % 2)break;
            }
        }
    }
    cout << ans << endl;
   return 0;
}

Measured memory_bytes: 6012
#include<stdio.h>
#include<stdlib.h>

typedef struct Node{
  int key;
  struct Node *right, *left, *parent;
}Node;

Node *root, *NIL;

Node * find(Node *u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
   y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }

  z->parent = y;
  if(y == NIL){
    root = z;
  }
 else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%s",com);
    if(com[0] == 'f'){
      scanf("%d",&x);
      Node *t = find(root, x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(com[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
  preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
long n;
vector<vector<int>> alb(50,vector<int>(26,0));
int f(int ab){
    unsigned int min = -1;
    for(int i = 0; i < n; i++){
        if(alb[i][ab] < min)
            min = alb[i][ab];
    }
    return min;
}
int main(){
    cin>>n;
    vector<string> v(n);
    for(int i = 0; i < n; i++)
        cin>>v[i];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < v[i].size(); j++){
            alb[i][v[i][j]-'a']++;
        }
    }
    for(int i = 0; i < 26; i++){
        int num = f(i);
        string o(num,i+'a');
        cout<<o;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  string key[16];
  string consist[] = {"KIH", "B", "R"};
  for (int i = 0; i < 1 << 4; i ++) {
    int i_ = i;
    string kj = "";
    for (int j = 0; j < 4; j ++) {
      if (i_ % 2) kj += "A";
      i_ /= 2;
      if (j < 3) kj += consist[j];
    }
    key[i] = kj;
  }
  for (int i = 0; i < 16; i ++) {
    if (S == key[i]) {
      cout << "YES" << endl;
      return 0;
    }
    //cout << key[i] << endl;
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}


template <typename T>
void vecOutPadding(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}

template <typename T>
void matOut(vector<vector<T>>& mat) {
	for (const auto& row : mat) {
		for (const T& col : row)
			cout << col << " ";
		cout << endl;
	}
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int N;
	cin >> N;
	vi a(N);
	cin >> a;

	int ans = 0;
	for (int i = 1; i < N; i++) {
		if (a[i - 1] == a[i]) {
			ans++;
			a[i] = -100;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
while True:
	H,W=map(int,input().split())
	if H==0 and W==0:
		break
	for i in range(H):
		for j in range(W):
			if i==0 or i==H-1:
				print("#",end="")
			else:
				if j==0 or j==W-1:
					print("#",end="")	
				else:	
					print(".",end="")
		print()
	print()


Measured memory_bytes: 7000
s=input()
l=[]
L=[s[0]]
for i in range(2,len(s)-1):
    if s[i]=='C':
        L.append(s[i])
    else:
        l.append(s[i])
komoji=''.join(l)
komoji+=(s[1]+s[len(s)-1])

print('AC' if L==['A','C'] and str.islower(komoji) else 'WA')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
int f(char a,char b, char c){
	return ((a!='s'&&a==b&&a==c)?a:0);
}
int main(){
	std::string s;
	int i,j;
	while(getline(std::cin,s)){
		char c=(f(s[0],s[4],s[8])||f(s[2],s[4],s[6]))?s[4]:0;
		if(!c){
			for(i=0;i<3;i++){
				c=f(s[i],s[i+3],s[i+6]);
				if(c)break;
				j=i*3;
				c=f(s[j],s[j+1],s[j+2]);
				if(c)break;
			}
			if(!c)c='d';
		}
		std::cout<<c<<"\n";
	}
}

Measured memory_bytes: 1164
import bisect


def main():
    N = int(input())
    L = list(map(int, input().split(' ')))
    L.sort()
    cnt = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            index = bisect.bisect_left(L, L[i] + L[j])
            cnt += max([0, index - j - 1])
    print(cnt)


if __name__ == '__main__':
    main()

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n; scanf("%d", &n);
  int a, p; long long ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a);
    if (a > i) {
      puts("-1");
      return;
    }
    if (i && a-p > 1) {
      puts("-1");
      return;
    }
    if (i && a <= p) ans += p;
    p = a;
  }
  ans += p;
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3824
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	int a,b,c;
	cin>>a>>b>>c;
	set<int> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	cout<<s.size();
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3644
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

x ? (a,b) = if x then a else b

main = do
 [n] <- readLnInt
 [a,b] <- readLnInt
 putStr $ (solve [n,a,b])?("OK","NG")

solve [n,a,b]
 | (b`div`n)*n >= a = True
 | otherwise = False


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

// 最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

// 最小公倍数(overflowに注意した)
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll n, m;
vector<ll> a;

ll maeshori(){
    // かくa[i]は、2で割れる回数が等しいことが条件なので、予め割れるだけわる。
    // (これがoverflow対策になる。)
    for(int i=0; i<n; i++){
        a[i] /= 2;
    }
    while(a[0] % 2 == 0){
        for(int i=0; i<n; i++){
            if(a[i] % 2 != 0) return 0;
            a[i] /= 2;
        }
        // 同時にmも2で割っておく
        m /= 2;
    } 
    // a[0] で判定しているので、まだ2が生き残っているかもしれない。
    for(int i=0; i<n; i++){
        if(a[i] % 2 == 0) return 0;
    }
    ll ans;
    ll Xmin = 1;
    for(int i=0; i<n; i++){
        Xmin = lcm(Xmin, a[i]);
    }
    if(m - Xmin < 0) return 0;
    ans = (m / Xmin + 1) / 2;
    return ans;
}
int main(void){
    
    cin >> n >> m;
    a.resize(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    ll ans;
    ans = maeshori();
    cout << ans << endl;
    return 0;
}

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

int main(){
    int A, B, C;
    scanf("%d%d%d",&A,&B,&C);

    int nokori;
    int ans;

    if (A >= B && A >= C){
        nokori = A*2-B-C;
    }
    else if (B >= A && B >= C){
        nokori = B*2-A-C;
    }
    else if (C >= A && C >= B){
        nokori = C*2-A-B;
    }

    if(nokori%2){
        ans = nokori / 2 + 2;
    }
    else{
        ans = nokori / 2;
    }

    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void debug() { std::cerr << '\n'; }
template <class H, class... T> void debug(H &&head, T &&... args) {
    std::cerr << head;
    sizeof...(args) == 0 ? std::cerr << "" : std::cerr << ' ';
    debug(std::forward<T>(args)...);
}
template <class T> void debug(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cerr << v[i];
        i == v.size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
    }
}
template <class T> void debug(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cerr << v[i][j];
            j == v[i].size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
        }
    }
}

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

    int a, b;
    cin >> a >> b;
    int now = 1;
    int ans = 0;
    while (now < b) {
        now += a - 1;
        ans++;
    }
    print(ans);

    return 0;
}

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

int main(int argc, char *argv[]) {
	int a=0;
	int b=0;
	while(scanf("%d%d", &a, &b)!=EOF){
	int c = a+b;
	int i=0;
	int count=0;
	for(i=0; i<a+b; i++){
		c /= 10;
		count ++;
		if(c<1)
			break;
	}
	printf("%d\n", count);
}
}


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

typedef long long ll;

int main(){
    string s;

    cin >> s;

    int year = stoi(s.substr(0,4));
    int month = stoi(s.substr(5,2));

    bool flag = true;
    if (year <= 2018){
        flag = false;
    } else if (year == 2019 && month <= 4){
        flag = false;
    }

    if (!flag) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i <= (b); i++ )
#define per(i, a, b) for ( int i = (b); i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans = -1, h, w, d[1005][1005];
char a[1005][1005];
int dx[] = {0, 0, -1, 1}, dy[] = {-1, 1, 0, 0};

int main(void) {
    cin >> h >> w;
    rep(i, 0, h-1) scanf("%s", a[i]);
    memset(d, 0x3f, sizeof(d));

    queue<pair<int, int> > q;
    rep(i, 1, h) rep(j, 1, w) {
        if (a[i-1][j-1]=='#') {
            d[i][j] = 0;
            q.push(mp(i, j));
        }
    }

    while (!q.empty()) {
        auto p = q.front(); q.pop();
        int sy = p.first, sx = p.second;
        rep(r, 0, 3) {
            int ty = sy + dy[r], tx = sx + dx[r];
            if (tx<1 || tx>w || ty<1 || ty>h) continue;
            if (d[sy][sx] + 1 < d[ty][tx]) {
                d[ty][tx] = d[sy][sx] + 1;
                q.push(mp(ty, tx));
            }
        } 
    }

    /*
    rep(i, 1, h) rep(j, 1, w) {
        if (a[i-1][j-1]=='#') d[i][j] = 0;
    }

    自分の解答
    rep(hi, 1, h) {
        rep(wi, 1, w) d[hi][wi] = min(d[hi][wi], d[hi][wi-1]+1);
        per(wi, 1, w) d[hi][wi] = min(d[hi][wi], d[hi][wi+1]+1);
    }

    rep(wi, 1, w) {
        rep(hi, 1, h) d[hi][wi] = min(d[hi][wi], d[hi-1][wi]+1);
        per(hi, 1, h) d[hi][wi] = min(d[hi][wi], d[hi+1][wi]+1);
    }

    */

   rep(i, 1, h) rep(j, 1, w) ans = max(ans, d[i][j]);
   
   cout << ans << endl;

	return 0;
}


Measured memory_bytes: 13328
#include <stdio.h>
#include <stdlib.h>

int main() {
    int n;
    float v[1000] = {},ans;
    int i,j,temp;
    
    scanf("%d",&n);
    for(i = 0; i < n; i++)
        scanf("%f",&v[i]);
    
    for (i = 0; i < (n-1); i++) {
        for (j = (n-1); j > i; j--) {
            if (v[j-1] > v[j]) {
                temp = v[j-1];
                v[j-1] = v[j];
                v[j] = temp;
            }
        }
    }
    
    ans = v[0];
    for (i = 0; i < (n-1); i++) {
    if(ans <= v[i+1])
        ans = (ans + v[i+1]) /2;
    else if(ans < v[i+2])
        ans = (ans + v[i+2]) /2;
    else
        ans = (ans + v[i+1]) /2;
    }
    printf("%f",ans);
}


Measured memory_bytes: 128
W, H, x, y, r = gets.chop.split(' ').map(&:to_i)

if (x-r) < 0
  puts "No"
elsif (x+r) > W
  puts "No"
elsif (y-r) < 0
  puts "No"
elsif (y+r) > H
  puts "No"
else
  puts "Yes"
end



Measured memory_bytes: 6876
#include<iostream>
#include<stdio.h>
#include <iomanip>


using namespace std;


int main() {
	double L;
	cin >> L;
	//double k = (L / 3.0) * (L / 3.0) * (L / 3.0);
	//printf("%.8f", k);
	cout << fixed << setprecision(8) << (L / 3.0) * (L / 3.0) * (L / 3.0) << endl;
	return 0;
}


Measured memory_bytes: 256