akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

int main(){
 while(true){
  int n;
  cin >> n;

  if(n==0) break;

  int len[n];
  for(int i=0; i<n; i++){
   string w;
   cin >> w;
   len[i] = w.size();
  }

  for(int i=0; i<n; i++){
   bool flag = false;
   int sta = 0; //区切り
   int sum = 0; //文字数の合計

   for(int j=i; j<n; j++){
    sum = sum + len[j];
    
    if(sum==5 || sum==12 || sum==17 || sum==24 || sum==31){
     sta++;
    }

    if(sta==5){
     flag = true;
     break;
    //}else if(sum>=31){
    // break;
    }
   }

   if(flag){
    cout << i+1 << endl;
    break;
   }
  }
 }

 return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define int long long
int MOD=1000000007;
int dp[50][1<<17];
int n,x,y,z,ms;
int dfs(int v,int b){
  if(~dp[v][b]) return dp[v][b];
  int flg=1;
  flg&=(b>>(x+y+z-1))&1;
  flg&=(b>>(y+z-1))&1;
  flg&=(b>>(z-1))&1;
  
  if(flg) return 0;
  if(v==n) return 1;
  int res=0;
  for(int i=1;i<=10;i++){
    int nb=(b<<i)&ms;
    (res+=dfs(v+1,nb+((1<<(i-1))&ms)))%=MOD;
  }
  //cout<<v<<" "<<bitset<17>(b)<<":"<<res<<endl;
  return dp[v][b]=res;
}
signed main(){
  cin>>n>>x>>y>>z;
  ms=(1LL<<(x+y+z))-1;
  int ans=1;
  for(int i=0;i<n;i++) (ans*=10)%=MOD;
  memset(dp,-1,sizeof(dp));
  ans=(ans+MOD-dfs(0,0))%MOD;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 51456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

string s;

int main()
{
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
        cout << "Bad" << endl;
    else
        cout << "Good" << endl;
}


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

typedef long long ll;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)

#define INT(n) int n;assert(0<scanf("%d",&n))
#define STR(s) string s;cin>>s
const int MOD = 1e9 + 7;

int main(){
  INT(n); STR(s);
  vector<int> cnt(26, 0);
  REP(i, n){cnt[s[i] - 'a']++;}
  ll ans = 1;
  REP(i, 26){
    ans *= (cnt[i] + 1);
    ans %= MOD;
  }
  ans += (MOD - 1);
  ans %= MOD;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 512
n,m=gets.split.map &:to_i;
e=[];
loop{s=gets.split.map &:to_i;break if s[0]==0;s[0]-=1;s[1]-=1;e<<s}
gets.to_i.times{b=gets.split.map &:to_i;c=[0]*n;
e.map{|s,t,u|c[s]+=b[t]*u}
puts c*' '
}


Measured memory_bytes: 14708
package main

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

func main() {
	N := ReadInt()
	A := ReadInts(N)

	B := append([]int{}, A...)
	sort.Ints(B)
	max1 := B[N-1]
	max2 := B[N-2]

	for i := 0; i < N; i++ {
		if A[i] == max1 {
			fmt.Println(max2)
		} else {
			fmt.Println(max1)
		}
	}
}

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 }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int c[3][3];
    REP(i,3){
        REP(j,3){
            cin >> c[i][j];
        }
    }
    bool flag = true;
    int b1 = c[0][0];
    int b2 = c[0][1];
    int b3 = c[0][2];
    int a2 = c[1][0]-b1;
    int a3 = c[2][0]-b1;
    if(c[1][1]!=a2+b2)flag = false;
    if(c[1][2]!=a2+b3)flag = false;
    if(c[2][1]!=a3+b2)flag = false;
    if(c[2][2]!=a3+b3)flag = false;
    if(flag)COUT("Yes");
    else COUT("No");
    return 0;
}


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

struct UnionFind {
    std::vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) std::swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};


int main() {
    int cities, roads, rails;

    std::cin >> cities >> roads >> rails;

    UnionFind a(cities), b(cities);

    for (int i = 0; i < roads; i++) {
        int x, y;
        std::cin >> x >> y;
        x--;
        y--;
        a.unionSet(x, y);
    }

    for (int i = 0; i < rails; i++) {
        int x, y;
        std::cin >> x >> y;
        x--;
        y--;
        b.unionSet(x, y);
    }

    std::map<std::pair<int, int>, int> c;
    for (int i = 0; i < cities; i++) {
        c[{a.root(i), b.root(i)}]++;
    }

    for (int i = 0; i < cities; i++) {
        std::cout << c[{a.root(i), b.root(i)}];
        if (i != cities - 1) std::cout << " ";
    }

    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 13568
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let mut vec: Vec<u16> = line.split_whitespace().map(|s| s.parse::<u16>().unwrap()).collect();
    vec.sort();
    println!("{} {} {}", vec[0], vec[1], vec[2]);
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    vector<lint> A(N), B(M);
    for_(i,0,N) cin >> A[i];
    for_(i,0,M) cin >> B[i];

    vector<lint> C = convolution<998244353>(A, B);
    for_(i,0,N+M-1) cout << C[i] << (i<N+M-2 ? " " : "\n");
}

Measured memory_bytes: 27196
import sys

ERROR_INPUT = 'input is invalid'


def main():
    n = get_length()
    arr = get_array(length=n)

    sourtLi, count = selectionSort(li=arr, length=n)
    print(*sourtLi)
    print(count)
    return 0


def get_length():
    n = int(input())
    if n < 0 or n > 100:
        print(ERROR_INPUT)
        sys.exit(1)
    else:
        return n


def get_array(length):
    nums = input().split(' ')
    return [str2int(string=n) for n in nums]


def str2int(string):
    n = int(string)
    if n < 0 or n > 100:
        print(ERROR_INPUT)
        sys.exit(1)
    else:
        return n


def selectionSort(li, length):
    count = 0

    for i in range(0, length - 1):
        min_index = i
        for j in range(i, length):
            if li[j] < li[min_index]:
                min_index = j

        if i != min_index:
            li[i], li[min_index] = li[min_index], li[i]
            count += 1

    return li, count


main()

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

int main() {
  int N;
  cin >> N;
  vector<ll> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];
  int ans = 0;
  sort(L.begin(), L.end());
  for (int i = 0; i < N-2; i++) {
    for (int j = i+1; j < N-1; j++) {
      for (int k = j+1; k < N; k++) {
        if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
          if (L[k] < L[i] + L[j]) ans++;
        }
      }
    }
  }
  cout << ans << endl;
}


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

					using namespace std;
					typedef long long ll;
					ll s;
					int n;
					int main()
					{
						cin >> n;
						for(int i = 1; i <= n; i++)
							if(i % 3 && i % 5)
								s += i;
						cout << s;
					}

Measured memory_bytes: 3620
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < n; i++) {
			set.add(sc.nextInt());
		}
		sc.close();

		int d = -1;
		int now = x;
		while (true) {
			if (!set.contains(now)) {
				System.out.println(now);
				return;
			}
			now += d;
			d *= -1;
			if (d < 0) {
				d--;
			} else {
				d++;
			}
		}
	}
}


Measured memory_bytes: 36036
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N,K,Q = map(int, input().split())

point = [K-Q]*N

for i in range(Q):
    a = int(input())
    point[a-1]+=1

for i in range(N):
    if point[i]>0:
        print("Yes")
    else:
        print("No")

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N,X,D;
LL m[55];
int p[55],z[55];
LL w[55],v[55];
LL dp[51*51*51];

int main(){
	cin >> N >> X >> D >> m[0];
	repp(i,1,N){
		cin >> m[i] >> p[i];
		--p[i];
		z[i] = i;
	}
	repm(i,N-1,0){
		w[i] += m[i];
		++v[i];
		w[p[i]] += w[i];
		v[p[i]] += v[i];
	}
	w[0] += m[0];
	++v[0];
	fill(dp,dp+N*N*N+1,X+1);
	dp[0] = 0;
	repp(i,0,N) repp(j,0,i?min(N,D):N) repm(k,N*N*N,-1) dp[v[i]+k] = min(dp[v[i]+k],w[i]+dp[k]);
	sort(z,z+N,[&](const int &a , const int &b){return w[a]*v[b] < w[b]*v[a];});
	int ans = 0;
	repp(i,0,N*N*N+1) if(dp[i] <= X){
		int r = X-dp[i] , n = i;
		repp(j,0,N){
			int m = min(r/w[z[j]],(LL)max(0,z[j]?D-N:X));
			r -= m * w[z[j]];
			n += m * v[z[j]];
		}
		ans = max(ans,n);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <stack>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 10000000000000000;

const int MOD = 1000000007;

#define MAX_N 100100
typedef pair<int, int> P;
typedef pair<ll, ll> llP;

class UnionFindTree{
private:
    int par[MAX_N];
    int urank[MAX_N];
    int size[MAX_N];
public:
    int init(int n);
    int find(int x);
    int unite(int x, int y);
    int same(int x, int y);
    int parnum(int x){return par[x];}
    int ranknum(int x){return urank[x];}
    int sizenum(int x){return size[find(x)];}
};

int UnionFindTree::init(int n){
    REP(i, n){
        par[i] = i;
        urank[i] = 0;
        size[i] = 1;
    }
    return 0;
}

int UnionFindTree::find(int x){
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
}

int UnionFindTree::unite(int x, int y){
    x = find(x);
    y = find(y);
    
    if(x == y)return 0;
    if(urank[x] < urank[y]){
        par[x] = y;
        size[y] += size[x];
    }else{
        par[y] = x;
        size[x] += size[y];
        if(urank[x] == urank[y])urank[x] ++;
    }
    return 0;
}

int UnionFindTree::same(int x, int y){
    return find(x) == find(y);
}


int main(){
    int dp[100100] = {0};
    int N, K;
    cin >> N >> K;
    int x[100100];
    REP(i, N){
        cin >> x[i];
    }
    int fu[100100] = {0};
    int sei[100100] = {0};
    int saishou[100100] = {0};
    REP(saidainohajimari, N - K + 1){
        fu[saidainohajimari] = max(0, -x[saidainohajimari]);
        sei[saidainohajimari] = max(0, x[saidainohajimari + K - 1]);
        saishou[saidainohajimari] = sei[saidainohajimari] + fu[saidainohajimari] + min(sei[saidainohajimari] , fu[saidainohajimari]);
    }
    
    int saishoujikan = INF;
    REP(i, N - K + 1){
        saishoujikan = min(saishoujikan, saishou[i]);
    }
    printf("%d\n", saishoujikan);
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

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

  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    ll start = i, end = n / i * i, number = n / i;
    ans += (start + end ) * number / 2;
  }
  cout<<ans<<endl;
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main(void) {
	int r[50] = { 0 };
	int n, m;
	int a;
	cin >> n >> m;

	for (int i = 0; i < m * 2; i++) {
		cin >> a;
		r[a - 1]++;
	}
	for (int i = 0; i < n; i++) {
		cout << r[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  int N, X, m;
  cin >> N >> X;
  int ans = N;
  vector<int> vec(N);

  for (int i = 0; i < N; i++){
    cin >> m;
    vec.at(i) = m;
  }

  int diff = X - accumulate(vec.begin(), vec.end(), 0);
  int div = diff / *std::min_element(vec.begin(), vec.end());
  ans += div;

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    
    ll mx = 0;
    vint p, m;
    rep(i, n) {
        mx += abs(a[i]);
        if (a[i] >= 0) p.push_back(a[i]);
        else  m.push_back(a[i]);
    }

    sort(rall(p));
    sort(all(m));
    if (m.empty()) {
        m.push_back(p.back());
        p.pop_back();
    }
    if (p.empty()) {
        p.push_back(m.back());
        m.pop_back();
    }

    ll sum = m[0];
    vll x, y;

    rep(i, p.size()-1) {
        x.push_back(sum);
        y.push_back(p[i]);
        sum -= p[i];
    }
    x.push_back(p.back());
    y.push_back(sum);
    sum = p.back() - sum;

    srep(i, 1, m.size()) {
        x.push_back(sum);
        y.push_back(m[i]);
        sum -= m[i];
    }

    cout << sum << endl;
    rep(i, n-1) {
        cout << x[i] << " " << y[i] << endl;
    }

    return 0;
}

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

using namespace std;

int main(void)
{
	int n;
	char w[200010*4];
	cin>>w;
	//cout<<w<<endl;
	n = strlen(w);
	int k;
	int ans = 0;
	for(int i = 0; i < n; i++){
		k = w[i] - '0';
		//cout<<"k = "<<k<<endl;
		if(k < 0 || k > 9) break;
		ans += k;
		if( ans >= 9) ans -= 9;
	}
	if(ans % 9 == 0 || ans == 0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 3756
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n-1)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//解説写し
int dp[5005][5005];
int main() {
  int n;
  cin >>n;
  string s;
  cin>>s;
  for(int i=n-1;i>=0;--i){
    for(int j=n-1;j>=0;--j){
      if(s[i]!=s[j])dp[i][j]=0;
      else dp[i][j]=dp[i+1][j+1]+1;
    }
  }
  int kotae=0;
  rep(i,n){
    rep(j,n){
      if(i>=j)continue;
      int tmp=min(dp[i][j],j-i);
      kotae=max(kotae,tmp);
    }
  }       
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 98048
n,k = gets.split.map(&:to_i)
p = gets.split.map(&:to_i)
data = [0]

(0..n-1).each do |i|
  data[i+1] = data[i] + (p[i] + 1)/2.0
end

ans = 0
(n-k+1).times do |i|
  buf = data[i+k] - data[i]
  ans = [ans, buf].max
end
puts ans


Measured memory_bytes: 20304
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;

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

    set<int> s;
    for (int i = 0; i < 3; i++) {
        int a;
        cin >> a;

        s.insert(a);
    }

    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            char[] cList = args.get(0).toCharArray();
            Arrays.sort(cList);
            System.out.println(cList[0] == cList[1] && cList[2] == cList[3] && cList[0] != cList[2] ? "Yes" : "No");
        };
    }

}


Measured memory_bytes: 27984
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N, H, W;
  cin >> N >> H >> W;
  
  int ans = 0;
  int A, B;
  for( int i = 0; i < N; i++ ){
    cin >> A >> B;
    if( A >= H && B >= W ) ans++;
  }
  cout << ans << endl;
}



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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inar ll ar[n];for(ll i=0;i<n;i++) cin>>ar[i];
#define loop for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL);
  #define endl "\n"
  #define inf ll(1e19)
  #define mod int(1000000007)
 typedef long long int ll;
using namespace std;
int main()
{
int ar[3][3];
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
cin>>ar[i][j];
int n;
cin>>n;
for(int k=0;k<n;k++){
int dig;
cin>>dig;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++)	{
if(ar[i][j]==dig)
ar[i][j]=0;
}}}
int flag=0;
for(int i=0;i<3;i++)
{
	int fl=0;
int fl2=0;
	for(int j=0;j<3;j++)
{
	if(ar[i][j]==0)
	fl++;
	if(ar[j][i]==0)
	fl2++;
}
if(fl==3 or fl2==3)
flag++;
}
/*for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cout<<ar[i][j]<<" ";}
cout<<endl;}*/
if(ar[0][0]==0 and ar[1][1]==0 and ar[2][2]==0)
flag++;
else if(ar[0][2]==0 and ar[1][1]==0 and ar[2][0]==0)
flag++;
if(flag>0)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}


	
	
	
	
	
	



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

using namespace std;

int dp[(1 << 8)+1][8];
int gragh[8][8];

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		gragh[a - 1][b - 1]++;
		gragh[b - 1][a - 1]++;
	}

	dp[1][0] = 1;
	for (int i = 1; i < (1 << n); i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				if (!((i >> k)&1) && gragh[j][k]>0) {
					dp[i + (1 << k)][k] += dp[i][j];
				}
			}
			if (i == (1 << n) - 1) {
				dp[1 << n][0] += dp[i][j];
			}
		}
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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


int n, k;
int a[105000];

int main()
{
	cin >> n >> k;
	int pos = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] == 1)pos = i;
	}


	int m = ceil((double)(pos - 1) / (double)(k - 1));

	int s = m*(k - 1) + 1;

	int u = ceil((double)(n - s) / (double)(k - 1));
	//cout << m << " " <<s<<" "<< u << endl;

	cout << m + u << endl;


	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int x[9<<14];
    int i=0;
    int j=0;
    int min=9<<25;
    
    for(;~scanf("%d",x+i);i++){
        ;
    }
    
    for(j=2;j<x[0]-x[1]+3;j++){
        min=fmin(x[j+x[1]-1]-x[j]+fmin(abs(x[j]),abs(x[j+x[1]-1])),min);
    }
    printf("%d",min);
}

Measured memory_bytes: 2548
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int R, C;
int t[12][10010];

int solve() {
  int mxCnt = 0;
  // 2^10 * 10^4 * 10
  // 1000 * 10^5
  // ひっくり返す 行 を全て試す
  for (int S = 0; S < (1<<R); ++S) {
    int curCnt = 0;
    // i 列に着目する
    for (int i = 0; i < C; ++i) {
      // ひっくり返す場合
      int rCnt = 0;
      for (int j = 0; j < R; ++j)
        if (((S >> j & 1) + t[j][i] + 1) % 2 == 0)
          ++rCnt;
      // ひっくり返さない場合
      int nrCnt = 0;
      for (int j = 0; j < R; ++j)
        if (((S >> j & 1) + t[j][i]) % 2 == 0)
          ++nrCnt;
      curCnt += max(rCnt, nrCnt);
    }
    mxCnt = max(mxCnt, curCnt);
  }
  return mxCnt;
}

int main() {
  while (scanf("%d%d", &R, &C), R | C) {
    for (int i = 0; i < R; ++i)
      for (int j = 0; j < C; ++j)
        scanf("%d", t[i] + j);
    printf("%d\n", solve());
  }
  return 0;
}

Measured memory_bytes: 1580
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
	int N = nextInt();

	vector<int> A;
	inputVector(A, N);

	int ret = 0;
	for (int i = 0; i < N; i++) {
		ret += A[i] / 2;
		if (i < N - 1 && A[i] % 2 && A[i + 1] > 0) {
			ret++;
			A[i + 1]--;
		}
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1400
#include <algorithm>
#include <cstdio>
typedef long long LL;
const int N = 100500;
int A[N], B[N];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  ++k;
  for (int i = 0; i < n; ++i) scanf("%d%d", &A[i], &B[i]);
  LL ans = 0;
  for (int i = 31; i >= 0; --i) if ((k >> i) & 1) {
    int l = ((k >> i) << i) - 1;
    LL anst = 0;
    for (int j = 0; j < n; ++j) if ((A[j] & l) == A[j]) 
      anst += B[j];
    ans = std::max(ans, anst);
  }
  printf("%lld\n", ans);
  return 0;
}


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

vector<ll>v;
void solve(){
    for(ll x=1; x<=999; x++){
        v.push_back((x*(x+1))/2);
    }
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    solve();
    ll c=b-a;
    cout<<v[c-1]-b;
    return 0;
}


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

int main() {
    int n;
    scanf("%d", &n);
    char** s = (char**)calloc(n, sizeof(char*));
    int i;
    for (i = 0; i < n; i++) {
        s[i] = (char*)calloc(100, sizeof(char));
        scanf("%s", s[i]);
    }

    int m;
    scanf("%d", &m);
    char** t = (char**)calloc(m, sizeof(char*));
    for (i = 0; i < m; i++) {
        t[i] = (char*)calloc(100, sizeof(char));
        scanf("%s", t[i]);
    }

    int j;
    int maxscore = 0;
    for (i = 0; i < n; i++) {
        int curscore = 0;
        for (j = i; j < n; j++) {
            if (strcmp(s[i], s[j]) == 0) {
                curscore++;
            }
        }
        for (j = 0; j < m; j++) {
            if (strcmp(s[i], t[j]) == 0) {
                curscore--;
            }
        }

        if (curscore > maxscore) {
            maxscore = curscore;
        }
    }
    printf("%d\n", maxscore);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _boost ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fi first
#define se second
#define clz __builtin_clz
#define clzll __builtin_clzll
#define bp __builtin_popcount
#define _unique(x) sort((x).begin(),(x).end()),(x).erase(unique((x).begin(), (x).end()),(x.end()))
#define all(x) (x).begin(),(x).end()
#define _rand(i,j) uniform_int_distribution<int>(i, j)(rng___)
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;
template < typename _T, typename _T2> string to_string(pair<_T,_T2> x) {return "<"+to_string(x.fi)+", "+to_string(x.se)+">";}
template < typename _T> string to_string(vector<_T> vec) {string s="[ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]=']';s[s.size()-2]=' '; return s;}
template < typename _T> string to_string(set<_T> vec) {string s="{ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T, typename _T2> string to_string(map<_T,_T2> vec) {string s="{ "; for(auto el:vec)s+="mp["+to_string(el.fi)+"]= "+to_string(el.se)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T > inline void _DBG(const char *s, _T x){cerr << s << " = " << to_string(x) << "\n";}
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a){while(*s != ',') cerr << *s++;cerr << " = " << to_string(x) << "\n";_DBG(s + 1, a...);}
#ifdef LOCAL
#define _print(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define _print(...) ;//cout<<2;//(__VA_ARGS__)
#endif
mt19937 rng___(chrono::steady_clock::now().time_since_epoch().count());


const LL MOD = 1e9+7;//998244353;
const LL LLINF = 1e18+7;
const int N=1e5+8;

int main()
{
    _boost;
    int h,w;
    cin>>h>>w;
    vector<vector<int>>board (h+1,vector<int>(w+1));
    vector<vector<LL>>ways (h+1,vector<LL>(w+1,0));
    ways[1][1]=1;
    for(int i=0;i<h;i++)
    {
        string s;
        cin>>s;
        for(int j=0;j<w;j++)
        {
            board[i+1][j+1]=s[j]=='.';
        }
    }
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            //if(i==1&&j==1)continue;
            if(!board[i][j]) continue;
            ways[i][j]=(ways[i][j]+ways[i-1][j]+ways[i][j-1])%MOD;
        }
    }
    cout<<ways[h][w];
}




Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n, a;
    cin >> n >> a;
    int hasu = n % 500;
    if(hasu <= a) {
        cout <<"Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3584
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;
int main(){

	map<char,int> l;
	
	l['q']=1;
	l['w']=1;
	l['e']=1;
	l['r']=1;
	l['t']=1;
	l['a']=1;
	l['s']=1;
	l['d']=1;
	l['f']=1;
	l['g']=1;
	l['z']=1;
	l['x']=1;
	l['c']=1;
	l['v']=1;
	l['b']=1;
	l['y']=2;
	l['u']=2;
	l['i']=2;
	l['o']=2;
	l['p']=2;
	l['h']=2;
	l['j']=2;
	l['k']=2;
	l['l']=2;
	l['n']=2;
	l['m']=2;
	
	string s;
	int k;
	
	while(cin>>s,s!="#"){
		k=l[s[0]];
		int c=0;
		for(int i=1;i<s.size();i++){
		//	cout<<c<<k<<endl;
		//	cout<<s[i]<<l[s[i]]<<endl;
			if(k==1){
				if(l[s[i]]!=1){
					k=l[s[i]];
					c++;
				}
			}
			else{
				if(l[s[i]]!=2){
					k=l[s[i]];
					c++;
				}
			}
		}
		cout<<c<<endl;
	}
}

Measured memory_bytes: 1188
N = input()
if N[-1] == "3":
    print("bon")
elif N[-1] == "0":
    print("pon")
elif N[-1] == "1":
    print("pon")
elif N[-1] == "6":
    print("pon")
elif N[-1] == "8":
    print("pon")
else:
    print("hon")

Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int n,x,y;
    cin>>n>>x>>y;
    vector<vector<int>> e(n);
    rep(i,1,n){
        e[i].push_back(i-1);
        e[i-1].push_back(i);
    }
    e[x-1].push_back(y-1);
    e[y-1].push_back(x-1);
    vector<vector<int>> memo(n,vector<int>(n,-1));
    rep(i,n){
        memo[i][i]=0;
        queue<int> que;
        que.push(i);
        while(!que.empty()){
            int it=que.front();que.pop();
            rep(j,e[it].size()){
                int next=e[it][j];
                if(memo[i][next]!=-1)continue;
                memo[i][next]=memo[i][it]+1;
                que.push(next);
            }
        }
    }
    map<int,int> mp;
    rep(i,n){
        rep(j,n){
            mp[memo[i][j]]++;
        }
    }
    rep(i,1,n){
        cout<<mp[i]/2<<endl;
    }
}


Measured memory_bytes: 31872
from collections import defaultdict

n,p = map(int,input().split())
a = 1
d = defaultdict(int)
for i in range(2,10**6+1):
    if p == 1:
        break
    while p%i == 0:
        p //= i
        d[i] += 1
if p>1:
    d[p] += 1
for i,j in d.items():
    if j >= n:
        a *= i**(j//n)
print(a)




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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> n;
	cout << "ABC" << n;
}

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

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846


const int MOD=1e9+7;
    ll mod(ll x){
        return (x%MOD + MOD)%MOD;
    }
    ll mmod(ll a , ll b){
        return mod(mod(a)*mod(b));
    }

int main()
{
    ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
    ll n,k;
    cin>>n>>k;
    ll ans=1;
    vector<ll> pos,neg,db;
    for(ll i=0;i<n;i++){
        ll a;
        cin>>a;
        if(a>0) pos.push_back(a);
        else neg.push_back(a);
    }
    if(pos.size()){
        if(k%2==1){
            sort(pos.begin(),pos.end());
            ans=mmod(ans,pos[pos.size()-1]);
            pos.pop_back();
            k-=1;
        }
        sort(pos.begin(),pos.end(),greater<>());
        sort(neg.begin(),neg.end());
        for(ll i=0;i+1<pos.size();i+=2){
            db.push_back((pos[i]*pos[i+1]));
        }
        for(ll i=0;i+1<neg.size();i+=2){
            db.push_back((neg[i]*neg[i+1]));
        }
        if(pos.size()%2 && neg.size()%2){
            db.push_back((pos.back()*neg.back()));
        }
        sort(db.begin(),db.end(),greater<>());
        for(ll i=0;i<(k/2);i++){
            ans=mmod(ans,db[i]);
        }
        cout<<ans<<endl;
        return 0;
    }
    else{
        sort(neg.begin(),neg.end());
        if(k%2==1)reverse(neg.begin(),neg.end());
        for(ll i=0;i<k;i++){
            ans=mmod(ans,neg[i]);
        }
        cout<<ans<<endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 6564
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int a[222];
for(int i=1;i<=n*2;i++)
{
cin>>a[i];
}
for(int i=1;i<n*2;i++)
for(int j=i+1;j<=n*2;j++)
if(a[i]>a[j])swap(a[i],a[j]);
int ans=0;
for(int i=1;i<=n*2;i+=2)
ans+=a[i]>a[i+1]?a[i+1]:a[i];
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
using namespace std;

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector< vector<int> > m;
    for (int i = 0; i <= N; i++) {
        vector<int> v;
        for (int j = 0; j <= N; j++) v.push_back(0);
        m.push_back(v);
    }
    for (int i = 0; i < M; i++) {
        int L, R;
        cin >> L >> R;
        m[L][R] += 1;
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            m[i][j] += m[i][j - 1];
        }
    }

    vector< vector<int> > ans(N, vector<int>(N, 0));
    for (int i = 1; i <= N; i++) {
        for (int j = i; j <= N; j++) {
            for (int k = i; k <= j; k++) {
                ans[i - 1][j - 1] += m[k][j];
            }
        }
    }

    vector< pair<int, int> > queries;
    for (int i = 0; i < Q; i++) {
        int p, q;
        cin >> p >> q;
        queries.push_back(make_pair(p, q));
    }

    for (int i = 0; i < Q; i++) {
        pair<int, int> query = queries[i];
        int p = query.first;
        int q = query.second;
        cout << ans[p - 1][q - 1] << "\n";
    }

    return 0;
}


Measured memory_bytes: 3836
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 D, T, S;
  std::cin >> D >> T >> S;
  std::cout << (S * T >= D ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

typedef pair<int,int> P;

bool judge(vector<int> vec){
	bool flag = true;
	int s[6] = {0,9,12,15,18,21};
	int num[6] = {9,3,3,3,3,9};
	for(int i = 0;i < 6;i++){
		for(int j = 0;j < num[i];j++){
			if(vec[j + s[i]] != vec[s[i]]) flag = false;
		}
	}
	return flag;
}

signed main(){
	int n;
	P a[4][5] = {
		{P(12,17),P(6,21),P(7,22),P(8,23),P(9,11)},
		{P(18,11),P(2,21),P(5,24),P(8,27),P(12,14)},
		{P(14,15),P(2,29),P(1,28),P(0,27),P(18,20)},
		{P(9,20),P(0,23),P(3,26),P(6,29),P(15,17)}
	};
	cin >> n;
	for(int i = 0;i < n;i++){
		int ans = -1;
		vector<int> p(30);
		for(int j = 0;j < 30;j++) cin >> p[j];
		if(judge(p)){
			cout << 0 << endl;
			continue;
		}
		queue<vector<int> > que;
		map<vector<int>,int> mp;
		mp[p] = 0;
		que.push(p);
		while(!que.empty()){
			vector<int> q = que.front();que.pop();
			for(int j = 0;j < 4;j++){
				vector<int> tmp = q;
				for(int k = 0;k < 5;k++) swap(tmp[a[j][k].first],tmp[a[j][k].second]);
				if(mp.find(tmp) != mp.end()) continue;
				else if(judge(tmp)){
					ans = mp[q] + 1;
					break;
				}else{
					mp[tmp] = mp[q] + 1;
					que.push(tmp);
				}
			}
			if(ans != -1) break;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main (){
    int n;
    scanf("%d",&n);
    int a[20];
    int cnt=0;
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n-2;i++)if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]<a[i-1]&&a[i]>a[i+1]))cnt++;
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 256
n = int(input())

stack = [0]
ans = 0
while stack:
    tmp = stack.pop()
    if tmp <= n:
        if len(set(str(tmp))) == 3:
            ans += 1
        stack += [tmp * 10 + 3, tmp * 10 + 5, tmp * 10 + 7]

print(ans)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left, bisect_right
sys.setrecursionlimit(10**6)

N=int(sys.stdin.readline().strip())
A=[None]+map(int, sys.stdin.readline().split())

al=[ [] for _ in range(N+1) ]	#隣接リスト
for i in range(N-1):
	u,v=map(int, sys.stdin.readline().split())
	al[u].append(v)
	al[v].append(u)

LIS=[ float("inf") for _ in range(N+1)] 
LIS[0]=float("-inf")
ans={}  #頂点i:LISの長さ

def dfs(cur,par):
    idx=bisect_left(LIS, A[cur])
    old=LIS[idx]    #LISの更新前の値をoldに持っておく
    LIS[idx]=A[cur]
    ans[cur]=bisect_left(LIS, float("inf"))-1 #LISの長さ
    for to in al[cur]:
        if par==to: continue    #遷移先が親であれば、遷移しない
        dfs(to,cur)
    LIS[idx]=old    #oldの値を戻して、LIS配列を頂点curまで遷移した時点の状態に復元する
        
dfs(1,-1)

for i in range(1,N+1):
    print ans[i]

Measured memory_bytes: 379576
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#include <unordered_map>
#define int long long

using namespace std;

typedef pair<int, int> pa;
typedef long long ll;
typedef long double ld;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    int sm = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 && i % 5) {
            sm += i;
        }
    }
    cout << sm;
}

Measured memory_bytes: 3636
N,M = map(int,input().split())
I = set()
n = set()
for i in range(M):
    a,b = map(int,input().split())
    if a == 1:
        I.add(b)
    if b == 1:
        I.add(a)
    if a == N:
        n.add(b)
    if b == N:
        n.add(a)
if  I & n == set():
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Measured memory_bytes: 24072
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <functional>
const int INF =1e5;
const int MOD = 1e9 + 7;
using namespace std;
typedef pair<int,int> P;
typedef long long lint;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) (x).begin(),(x).end()

int main(){
    int x,a,b;
    cin>>x>>a>>b;
    cout<<(x-a)%b<<endl;
    
    return 0;

}


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

ll gcd(ll a, ll b){
	ll r;
	while(b){
		r=a%b;
		a=b;
		b=r;
	}
	return a;
}


int main(){
	ll n,k,p,t;
	cin >> n >> k;
	cin >> p;
	t=p;
	int tmp;
	for(int i=2;i<=n;i++){
		cin >> tmp;
		p=gcd(p,tmp);
		t=t>tmp?t:tmp;
	}
	if(k%p || k>t)cout << "IMPOSSIBLE\n";
	else cout << "POSSIBLE\n";
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		int sum=0;
		for(int i = 0; i < n; i++){
			int x,y,h,w;
			cin>>x>>y>>h>>w;
			int l=x+y+h;
			if(l<=60&&w<=2){
				sum+=600;
			}
			else if(l<=80&&w<=5){
				sum+=800;
			}
			else if(l<=100&&w<=10){
				sum+=1000;
			}
			else if(l<=120&&w<=15){
				sum+=1200;
			}
			else if(l<=140&&w<=20){
				sum+=1400;
			}
			else if(l<=160&&w<=25){
				sum+=1600;
			}
		}
		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    string s;
    int  a, b;
    cin >> a >> b >> s;
    for(int i = 0; i < a; i++){
        if(i == b-1){
            cout << char(s[i] + 32);
        }
        else
        {
            cout << s[i];
        }
        
    }
    
    cout << endl;
}


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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 3e2+5;

ld dp[N][N][N];
int n;

ld solve(int c1, int c2, int c3) {
	if(dp[c1][c2][c3]>=0)
		return dp[c1][c2][c3];
	// cout<<c1<<" "<<c2<<" "<<c3<<endl;
	int c0 = n-c1-c2-c3;
	ld cv = 0;
	ld p1 = c1*1.0/n;
	ld p2 = c2*1.0/n;
	ld p3 = c3*1.0/n;
	ld p0 = c0*1.0/n;
	if(c1>0)
		cv += p1*(solve(c1-1, c2, c3)+1);
	if(c2>0)
		cv += p2*(solve(c1+1, c2-1, c3)+1);
	if(c3>0)
		cv += p3*(solve(c1, c2+1, c3-1)+1);
	cv += p0;
	dp[c1][c2][c3]=cv/(1-p0);
	return dp[c1][c2][c3];
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	memset(dp, -1, sizeof(dp));
	dp[0][0][0]=0;
	cin>>n;
	int x;
	int c1=0, c2=0, c3=0;
	for(int i=0;i<n;i++) {
		cin>>x;
		if(x==1)
			c1++;
		if(x==2)
			c2++;
		if(x==3)
			c3++;
	}

	cout<<setprecision(15)<<solve(c1,c2,c3);

	return 0;
}

Measured memory_bytes: 447164
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}


int main()
{
	ll N = 0, i = 0;
	ll ans = 0;
	scanf("%lld", &N);
	for (i = 1; i <= N; i++) {
		if ((i%3 == 0) && (i%5 == 0)) {
			//ans += i; //fixxbuff;
		} else if (i%3 == 0) {
			//ans += i; //fixxbuff;
		} else if (i%5 == 0) {
			//ans += i; //fixxbuff;
		} else {
			ans += i;
		}
	}
	printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1732
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)2e9 + 1;
const ll mod = (ll)1e9 + 7;

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

	cout << a * a * 3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    int n, ans = 0;
    string s;
    cin >> n >> s;
    map<char, int> l, r;
    for (int i = 0; i < n; i++)
    {
        r[s[i]]++;
    }
    for (int i = 0; i < n; i++)
    {
        char c = s[i];
        int tmp = 0;
        l[c]++;
        r[c]--;
        if (l.size() < r.size())
        {
            for (auto x : l)
            {
                if (x.second != 0 && r[x.first] != 0)
                {
                    tmp++;
                }
            }
        }
        else
        {
            for (auto x : r)
            {
                if (x.second != 0 && l[x.first] != 0)
                {
                    tmp++;
                }
            }
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256