akhauriyash/Code-Regression huggingface dataset:
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define BIG_MOD 1000000007

#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> a(M);
	vector<int> cnt(N, -1);  // -1で初期化
	REP(i, M) {
		cin >> a[i];
		a[i]--;
		cnt[a[i]] = 0;
	}

	if (cnt[0] == -1 ) {
		cnt[0] = 1;
	}
	if (N >= 2 && cnt[1] == -1) {
		cnt[1] = cnt[0] + 1;
	}

	for (int i = 2; i < N; i++) {
		if (cnt[i] == -1) {
			cnt[i] = (cnt[i - 1] + cnt[i - 2]) % BIG_MOD;
		}
	}

	cout << cnt[N - 1] << endl;

	return 0;
}


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

using namespace std;

int const maxn = 2e5 + 5;
int suff[2 * maxn];

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, c, pref = 0, R = -1;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    s = "0" + s;
    for (int i = n; i >= 1; --i) {
        if (s[i] == 'o') suff[i] = suff[i + c + 1] + 1;
        else suff[i] = suff[i + 1];
    }
    set < int > Q;
    for (int i = 1; i <= n; ++i) {
        if (s[i] == 'x') continue;
        if (pref + suff[max(R, i + 1)] < k) cout << i << '\n';
        if (i >= R) {
            R = i + c + 1, pref++;
        }
    }
    return 0;
}



Measured memory_bytes: 2640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n,d; cin>>n>>d;
	d = 2*d+1;
	cout<<(n+d-1)/d<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	if N < 2 {
		fmt.Println(0)
		return
	}

	max, ln := 0, 0
	cur, right := nextInt(), nextInt()
	for i := 1; i < N; i++ {
		if i > 1 {
			cur = right
			right = nextInt()
		}

		//fmt.Println(cur, right)
		if cur >= right {
			ln++
			max = maxInt(max, ln)
		} else {
			ln = 0
		}
	}

	fmt.Println(max)
}


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

int main() {
	string str;
	int num[26],x;
	char a;

	for (int i = 0;i < 26;i++)
		num[i] = 0;

	while (cin >> str) {
		for (int i = 0;i < str.length();i++) {
			str[i] = tolower(str[i]);
			if (str[i] >= 'a'&&str[i] <= 'z') {
				x = str[i] - 'a';
				num[x]++;
			}
		}
	}
	for (int i = 0;i < 26;i++) {
		a = 'a' + i;
		cout << a << " : " << num[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1180
MOD = 998244353

N, K = map(int, input().split())
seg = [tuple(map(int, input().split())) for _ in range(K)]
dp = [0] * (N+1)
dp[0] = 1
for i in range(N):
    for s, t in seg:
        if (i+s) <= N:dp[i+s] += dp[i]
        if (i+t+1) <= N:dp[i+t+1] -= dp[i]
    dp[0] = 0
    dp[i+1] += dp[i]
    dp[i+1] %= MOD
    
print(dp[N-1])

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int n, p;

int main()
{
  while(cin >> n >> p, n){
    int cnt = p;
    vi d(n, 0);
    bool ok = true;
    while(ok){
      rep(i, n){
        if(cnt){
          cnt -= 1;
          d[i] += 1;
          if(d[i] == p){
            cout << i << endl;
            ok = false;
            break;
          }
        }
        else{
          swap(cnt, d[i]);
        }
      }
    }
  }

  return 0;
}

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

int main() {
    int n, cnt = 0;
    string s;
    cin >> n >> s;
    for(int i = 0; i < n - 2; i++) {
        if(s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C')
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<double>arr(n);
    for(int i=0; i<n; i++)
     cin>>arr[i];
    for(int i=0; i<n; i++)
    {
    	arr[i]=(arr[i]+1)/2;
	}
	double sum=0;
	for(int i=0; i<k; i++)
	{
		sum+=arr[i];
	}
	double ans=sum;
    for(int i=k; i<n; i++){
    	sum=sum-arr[i-k];
    	sum+=arr[i];
    	ans=max(ans,sum);
	}
	cout<<fixed<<setprecision(8)<<ans;
	return 0;
}

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

const int mod = 1e9+7;
char maze[1010][1010];
int dp[1010][1010];
int n,m;
int topdown(int i,int j)
{
    if(i+1==n and j+1==m)
    {
        dp[i][j]=1;
        return 1;
    }
    if(dp[i][j]!=-1)
    {
        return dp[i][j];
    }
    int ans=0;
    if(i+1<n and maze[i+1][j]!='#')
    {
        ans+=topdown(i+1,j)%mod;
    }
    if(j+1<m and maze[i][j+1]!='#')
    {
        ans+=topdown(i,j+1)%mod;
    }
    dp[i][j]=ans%mod;
    return dp[i][j];
}

int main()
{
    cin>>n>>m;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>maze[i][j];
        }
    }
    cout<<topdown(0,0)<<endl;
    return 0;
}

Measured memory_bytes: 8684
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define F first
#define S second
#define mset(x,v) memset(x, v, sizeof(x))
#define left(x) 2*x
#define right(x) (2*x) + 1
#define ALL(t) (t).begin(),(t).end() 
#define ret return 0
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define rev(s) reverse(s.begin(),s.end())
#define WL(t) while(t --)
#define MOD 1000000007
bool is(int x)
{
      int p=(int)sqrt(x);
      if(p*p==x)
      return true;
      else
      return false;
}
int main()
{
      boost;
      string a,b;
      cin>>a>>b;
      a+=b;
      ll c=stoi(a);
      if(is(c))
      cout<<"Yes"<<endl;
      else
      cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 101
#define MAX 2001

int main(){
  int i,j,k;
  int n,cnt=0;
  int g[N][N],c[N],d[N],pi[N];
  int min;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&g[i][j]);
    }
  }
  for(i=0;i<n;i++){
    c[i]=0;
    pi[i]=-1;
    d[i]=MAX;
  }
  d[0]=0;

  while(1){
    min=MAX;
    for(i=0;i<n;i++){
      if(c[i]!=2 && d[i]<min){
        min=d[i];
        k=i;
      }
    }
    if(min==MAX)
      break;
    c[k]=2;
    for(i=0;i<n;i++){
      if(g[k][i]!=-1 && c[i]!=2 && g[k][i]<d[i]){
        pi[i]=k;
        d[i]=g[k][i];
        c[i]=1;
      }
    }
  }
  for(i=0;i<n;i++){
    if(pi[i]!=-1)cnt+=g[i][pi[i]];
  }
  printf("%d\n",cnt);
  return 0;
}

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

using namespace std;

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

const int N = 1e5 + 5;

ii a[N];
int n,m;
ll ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> m;
  for (int i = 1 ; i <= n ; i++)
    cin >> a[i].first >> a[i].second;
  sort(a + 1,a + n + 1);
  for (int i = 1 ; i <= n ; i++) {
    if (m == 0)
      break;
    if (m > a[i].second) {
      ans += (ll)a[i].first * a[i].second;
      m -= a[i].second;
    }
    else {
      ans += (ll) m * a[i].first;
      m = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAX (10000)
using namespace std;

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s) {
  queue<int> q;
  q.push(s);
  V[s] = true;
  
  while ( !q.empty() ) {
    int u = q.front(); q.pop();
    out.push_back(u);
    for ( int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      indeg[v]--;
      if ( indeg[v] == 0 && !V[v]){
	V[v] = true;
	q.push(v);
      }
    }
  }

}

void tsort() {
  for ( int i = 0; i< N; i++) {
    indeg[i] = 0;
  }

  for ( int u = 0; u < N; u++) {
    for ( int i = 0; i< G[u].size(); i++){
      int v = G[u][i];
      indeg[v]++;
    }
  }

  for ( int u = 0; u < N ; u++) {
    if(indeg[u] == 0 && !V[u]) {
      bfs(u);
    }
  }

  for (list<int>::iterator it = out.begin(); it != out.end(); it++) {
    cout << *it << endl;
  }
}

main()
{
  int s, t, M;
  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    V[i] = false;
  }
  for(int i = 0; i < M; i++) {
    cin >> s >> t;
    G[s].push_back(t);
  }
  
  tsort();

  return (0);
}



Measured memory_bytes: 4124
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int H, W, h, w;
    cin >> H >> W >> h >> w;
    H -= h, W -= w;
    cout << H * W << endl;
}

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

int ctoi(char c){
  if('0' <= c && c<= '9')return(c-'0');
  return -1;
}
int main() {
  string s; cin>>s;
  int n=s.size();
  vector<ll> v(n);
  rep(i,n){
    v[i]=ctoi(s.at(i));
  }
  ll ans=0;
  rep(i,n){
    rep(j,n-i-1){
      ans+= v[i]* pow(10,j)* pow(2,n-2-j); 
    }
    ans+=v[i]*pow(10,n-i-1)*pow(2,i);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
// VC, AC

#include <bits/stdc++.h>
using namespace std;

// Utility
#define ALL(X) (X).begin(), (X).end()
#define RANGE(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T>            istream& operator>>(istream& i, vector<T>& x)    { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#define DD(X) std::cout << #X ": " << (X) << std::endl << std::flush
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T>            ostream& operator<<(ostream& o, const vector<T>& x)    { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const set<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  auto solve = [&]() -> ll {
    if (k <= a) {
      return k;
    }
    if (k <= a + b) {
      return a;
    }
    return a - (k - (a + b));
  };
  cout << solve() << endl;
}

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

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

const int N = 100+7;
int a[N];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	double sum = 0;
	for(int i = 0 ; i < n ; i++) {scanf("%d",a+i);sum +=a[i];}
	int cnt = 0;
	sum /= 4.0*m;
	for(int i = 0 ; i < n ; i++)
	{
		if (!(a[i] < sum)) cnt++;
	}
	if (cnt >= m) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
import sys
from itertools import permutations
from math import factorial

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def distance(p, q):
    return sum((px - qx) ** 2.0 for px, qx in zip(p, q)) ** 0.5


def main():
    N = int(readline())
    C = [tuple(map(int, readline().split())) for _ in range(N)]

    dist = [[0] * N for _ in range(N)]
    for i in range(N):
        for j in range(i + 1, N):
            dist[i][j] = dist[j][i] = distance(C[i], C[j])

    ans = 0
    for perm in permutations(range(N)):
        for i in range(N - 1):
            ans += dist[perm[i]][perm[i + 1]]

    print(ans / factorial(N))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <stdio.h>

int main(void){
	int a,b,c,i,kaisu;
	
	scanf("%d",&kaisu);
	for(i=0;i < kaisu;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(a*a + b*b == c*c){
			printf("YES\n");
		}else if(a*a + c*c == b*b){
			printf("YES\n");
		}else if(b*b + c*c == a*a){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <climits>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP1(i,n) for(ll i=1;i<=(ll)(n);i++)

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

int main() {
	ll n;
    cin >> n;
    ll sum = 0;

    REP1(i,n){
        REP1(j,n){
            REP1(k,n){
                sum += gcd(gcd(i,j),k);
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3628
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import static java.lang.Math.*;

public class Main {

	static int[][] d;
	static final int INF = 1 << 24;

	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		while(true){
			int n = si(),m = si(),s = si()-1,g1 = si()-1,g2 = si()-1;
			if(n==0) break;
			d = new int[n][n];
			for(int i = 0; i < n; i++){Arrays.fill(d[i],INF); d[i][i] = 0;}
			for (int i = 0; i < m; i++) d[si()-1][si()-1]=si();
			warshallFloyd(n);
			int mincost = INF;
			for (int i = 0; i < n; i++) mincost = min(d[s][i]+d[i][g1]+d[i][g2],mincost);
			out.println(mincost);
		}
		out.flush();
	}

	static void warshallFloyd(int n){
		for (int i = 0; i < n ; i++) {
			for (int j = 0; j < n ; j++) {
				for (int j2 = 0; j2 < n; j2++) {
					d[j][j2] = min(d[j][j2],d[j][i]+d[i][j2]);
				}
			}
		}
	}

	static int si() {
		return Integer.parseInt(scan.next());
	}
}

Measured memory_bytes: 68800
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
    string s;
    while(cin>>s){
		int ioi=0,joi=0;
		REP(i,s.size()-2){
			if(s[i+1]=='O'&&s[i+2]=='I'){
				if(s[i]=='I'){
					ioi++;
				}else if(s[i]=='J'){
					joi++;
				}
			}
		}
        cout<<joi<<endl<<ioi<<endl;
    }
}

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

int main(){
  int n, m;
  std::cin >> n >> m;
  vector<bool> ans(n, 0);
  vector<int> num(n, 1);
  ans[0] = 1;
  int from, to;
  for (int i = 0; i < m; i++) {
    std::cin >> from >> to;
    from--, to--;
    if(ans[from] == true)ans[to] = true;
    num[to]++;
    num[from]--;
    if(num[from] == 0)ans[from] = false;
  }
  int hoge = 0;
  for (int i = 0; i < n; i++) {
    if(ans[i] > 0 and num[i] > 0)hoge++;
  }
  std::cout << hoge << std::endl;
  return 0;
}



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

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

class Mod{
  public:
    ll mod;
    // mod must be a prime number
    Mod(ll m){
        mod = m;
    }
    //a^p
    ll modpow(ll a, ll p){
        if(p == 0) return 1;
        if(p%2 == 0){
            ll half = modpow(a, p/2);
            return half * half % mod;
        }
        else return a * modpow(a,p-1) % mod;
    }

    //nCr
    ll comb(ll n, ll r){
        if(r > n-r) return comb(n,n-r);
        ll mul = 1;
        ll div = 1;
        for (int i = 0;i < r;i++){
            mul *= n-i;
            mul %= mod;
            div *= i+1;
            div %= mod;
        }
        return mul * modpow(div,mod-2) % mod;
    }
};

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

    ll mod = 1e9+7;
    ll tt = 1;
    ll N,K; cin >> N >> K;
    ll ans = 0;

    Mod m(mod);

    for (int i = K;i <= N+1;i++){
        ans += (N+1-i)*i+1;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;

}

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

int main(){
    string s; cin >> s;
    ll sum = 0;
    rep(i,s.size()) sum += s[i]-'0';
    if(sum%9==0){
        cout << "Yes" << endl;
    }else cout << "No" << endl;
}

Measured memory_bytes: 3764
int main(){
    int N;
    long long t;
    scanf("%d%lld",&N,&t);
    if(N==1)printf("%lld",t);
    else {
          long long T;
          long long max,min,num;
        for(int i=1;i<N;i++){
            scanf("%lld",&T);
            if(T>t){max = T;min = t;}
            else {max = t;min = T;}
                num = max;
                while(num%min!=0){
                   num += max;
                }
                t = num;
        }
        printf("%lld",num);
    }
    return 0;
}



Measured memory_bytes: 128
x=[]
for i in range (1,int(input())+1):
  if i%3==0:
    x.append(str(i))
  elif i%10==3:
    x.append(str(i))
  elif 30<=i%100<40:
    x.append(str(i))
  elif 300<=i%1000<400:
    x.append(str(i))
  elif 3000<=i%10000<4000:
    x.append(str(i))
print(""," ".join(list(map(str,x))))


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


def main():
    from math import ceil

    s = int(input())

    # See:
    # https://www.youtube.com/watch?v=eFQGwwdAVWg
    # KeyInsight
    # 1つ目の点を原点に固定する
    # 2つ目のx座標を10^9，3つ目のx座標を1で固定
    # 面積は外積で求められる |x2y3 - y2x3| / 2
    # y3 = [s / x2]
    # y2 = x2y3 - s
    y3 = ceil(s / 10 ** 9)
    y2 = ((10 ** 9) * y3) - s
    print(0, 0, 10 ** 9, y2, 1, y3)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main()
{
    int N, M;
    map<string, int> s, t;
    string str;
    cin >> N;
    for(int i=0;i<N;++i){
        cin >> str;
        s[str] += 1;
    }
    cin >> M;
    for(int i=0;i<M;++i){
        cin >> str;
        t[str] += 1;
    }

    int ans=0;
    for(auto& item : s){
        if(t.find(item.first) != t.end()){
            ans = ans < item.second - t[item.first] ? item.second - t[item.first] : ans;
        }
        else{
            ans = ans < item.second ? item.second : ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# ABC 131: B – Bite Eating
N, L = [int(s) for s in input().split()]
tastes = [L + i - 1 for i in range(1, N + 1)]

index = 0
taste = 500

for i in range(N):
    if abs(tastes[i]) < taste:
        index = i
        taste = abs(tastes[i])

tastes.pop(index)
print(sum(tastes))

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

int main(){
  int N,cnt=0;
  cin >> N;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      if(N % i == 0 && N / i == j){
	cnt++;
      }
    }
  }
  if(cnt == 0){
    cout << "No";
  }else{
    cout << "Yes";
  }
  return 0;
}

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

using namespace std;

bool isOK(const vector<int>& w, int k, int p) {
  int i = 0;
  for (int j = 0; j < k; j++) {
    int s = 0;
    while (s + w[i] <= p) {
      s += w[i];
      i++;
      if (i == w.size()) {
        return true;
      }
    }
  }
  return i >= w.size();
}

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

  int n, k;
  cin >> n >> k;
  vector<int> w(n);
  int s = 0;
  for (int i = 0; i < n; i++) {
    cin >> w[i];
    s += w[i];
  }
  // (l, r]
  int l = 0;
  int r = s;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (isOK(w, k, mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << r << endl;
  return 0;
}



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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

// ====================================================================

int main() {
  ll s, c;
  cin >> s >> c;
  ll ans = min(s, c / 2);
  s -= ans;
  c -= ans * 2;
  ans += c / 4;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,in,out,m=0,i,a=100;
	for(;scanf("%d",&n)&&n;m=0,a=100){
		for(i=1;i<=12;i++){
			scanf("%d %d",&in,&out);
			m+=in-out;
			if(m>=n&&a>i)a=i;
		}
		if(a==100)printf("NA\n");
		else printf("%d\n",a);
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <typename T>
struct edge {
    int from, to;
    T cost;

    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const {return to;}
};

class UnionFind {
    vector<int> uni;
    int n;
public:
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }
};

template<typename T>
vector<edge<T>> kruskal(vector<edge<T>> &G, int V) {
    sort(begin(G), end(G), [](const edge< T > &a, const edge< T > &b) { return (a.cost < b.cost); });
    UnionFind tree(V);
    vector<edge<T>> ret;
    for(auto &e : G) {
        if(tree.unite(e.from, e.to)) ret.emplace_back(e);
    }
    return (ret);
}

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }
int main() {
    int n, m;
    cin >> n >> m;
    vector<edge<ll>> e;
    for (int i = 0; i < m; ++i) {
        int a, b; ll c;
        scanf("%d %d %lli", &a, &b ,&c);
        a--; b--;
        e.emplace_back(a, b, c);
    }
    auto v = kruskal(e, n);
    auto cost = make_v(n, n, 0LL);
    ll S = 0;
    vector<vector<pair<int, ll>>> G(n);
    for (auto &&i : v) {
        S += i.cost;
        G[i.from].emplace_back(i.to, i.cost);
        G[i.to].emplace_back(i.from, i.cost);
    }
    for (int st = 0; st < n; ++st) {
        stack<int> s;
        vector<int> visited(n, 0);
        s.emplace(st);
        while(!s.empty()){
            int a = s.top(); s.pop();
            visited[a]++;
            for (auto &&i : G[a]) {
                if(!visited[i.first]) {
                    s.emplace(i.first);
                    cost[st][i.first]
                        = max(cost[st][a], i.second);
                }
            }
        }
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int s, t;
        scanf("%d %d", &s, &t);
        cout << S-cost[s-1][t-1] << "\n";
    }
    return 0;
}


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

signed main()
{
	int N, A, B;
	cin >> N >> A >> B;
	vector<int> X(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}
	int res = 0;
	for (int i = 1; i < N; i++) {
		res += min((X[i] - X[i - 1]) * A, B);
	}
	cout << res << endl;
	return 0;
}


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

int main() {
   int n;
   cin>>n;
   int a[n];
   int x=0;
   for(int i=0;i<n;i++)
   cin>>a[i],x^=a[i];
   for(int i=0;i<n;i++)
   cout<<(x^a[i])<<" ";
   cout<<"\n";
	return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  cout << (a + b > 9 ? "error" : to_string(a + b)) << '\n';
  return 0;
}

Measured memory_bytes: 256
main(void){
    
    int x[301],y[301];
    int a,b,c,i=0;
    
    while(1){
        scanf("%d %d",&x[i],&y[i]);
        if(x[i]==0 && y[i]==0){
            break;
        }
        i++;
    }
    
    for(a=0;a<i;a++){
        for(b=0;b<x[a];b++){
            for(c=0;c<y[a];c++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    
}


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

int main()
{
  int N,M;
  cin >> N >> M;
  vector<int> H(N);
  for(int i = 0;i < N;i++){
    cin >> H[i];
  }
  vector<vector<int>> path(N);
  for(int i = 0;i < M;i++){
    int A,B;
    cin >> A >> B;
    path[A-1].push_back(B-1);
    path[B-1].push_back(A-1);
  }
  int x = 0;
  for(int i = 0;i < N;i++){
    bool ans = true;
    int y = path[i].size();
    for(int j = 0;j < y;j++){
      if(H[i] <= H[path[i][j]]) ans = false;
    }
    if(ans) x++;
  }
  cout << x << endl;
}


Measured memory_bytes: 8804
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	while(true){
		int n;
		cin>>n;
		if(n==0)break;
		string c;
		cin>>c;
		int mai[10];
		for(int i=0;i<n;i++){
			mai[i]=0;
		}
		int ba=0;
		int turn=0;
		for(int i=0;i<c.size();i++){
			if(c[i]=='M')
				mai[turn]++;
			else if(c[i]=='S'){
				mai[turn]++;
				ba+=mai[turn];
				mai[turn]=0;
			}
			else{
				mai[turn]++;
				mai[turn]+=ba;
				ba=0;
			}
			turn++;
			turn%=n;
		}
		sort(mai,mai+n);
		for(int i=0;i<n;i++){
			cout<<mai[i]<<" ";
		}
		cout<<ba<<endl;
	}
	return 0;
}

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

using namespace std;
#define int long long
#define N 666666
vector<int> ans;
int a[N],b[N];
int arr1[N],arr2[N];
signed main(){
	int n,k,c;
	string s;
	cin>>n>>k>>c>>s;
	int cnt1=0,cnt2=0;
	for(int i=0;i<n;i++){
		if(s[i]=='o'){
			arr1[cnt1++]=i;
			i+=c;
		}
		if(cnt1>k)	break;
		 
	}
/*	for(int i=0;i<k;i++) cout<<arr1[i]<<" ";
	cout<<'\n';*/
	for(int i=n-1;i>=0;i--){
		if(s[i]=='o'){
			arr2[cnt2++]=i;
			i-=c;
		}
		if(cnt2>k) break;
	}
	for(int i=0;i<k;i++){
		if(arr1[i]==arr2[k-i-1]){
			ans.push_back(arr1[i]);
		}
	}
	for(int i=0;i<ans.size();i++)
		cout<<ans[i]+1<<'\n';
	return 0;
}
/*
11 3 2

ooxxxoxxxoo
ooxxxoxxxoo
*/

Measured memory_bytes: 9076
#include<stdio.h>
int main() {
  double a, b, c, d, e, f;
  while (scanf("%lg %lg %lg %lg %lg %lg", &a, &b, &c, &d, &e, &f) != EOF) {
    printf("%.3f %.3f\n", (c * e - b * f) / (a * e - b * d) ? (c * e - b * f) / (a * e - b * d) : 0, (c * d - a * f) / (b * d - a * e) ? (c * d - a * f) / (b * d - a * e) : 0);
  }
  return 0;
}

Measured memory_bytes: 648
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] arr = new int[N];
        int[] dist = new int[N];
        int result = 0;
        

        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }

        int first = K - arr[N-1] + arr[0];
        dist[0] = first;

        for(int j = 1; j < N; j++) {
            dist[j] = arr[j] - arr[j-1];
        }
        Arrays.sort(dist);

        for(int k = 0; k < N-1; k++) {
            result += dist[k];
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 79452
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;


int main() {
    int N, M;
    cin >> N >> M;
    vector<int>numM(M, 0);

    for (int i = 0; i < N; i++) {
        int L;
        cin >> L;
        for (int j = 0; j < L; j++) {
            int suki;
            cin >> suki;
            numM[suki - 1]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < M; i++) {
        if (numM[i] == N)ans++;
    }

    cout << ans << "\n";


}

Measured memory_bytes: 256
n=int(input())
s=input()
ans=[]
list=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
for i in range(len(s)):
    if list.index(s[i])+n <= 25:
        ans.append(list[list.index(s[i])+n])
    else:
        ans.append(list[list.index(s[i])+n-26])
print(*ans,sep='')

Measured memory_bytes: 4852
num = int(input())
val = [int(x) for x in input().split()]

res = True
cnt = 0
while res:
    for i in range(0, len(val)):
        if val[i] % 2 != 0:
            res = False
            break
        else:
            val[i] = val[i]/2
    if res:
        cnt +=1

print(cnt)


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ll N;

void dfs(string cur) {
    if ((ll)cur.size() == N) {
        cout << cur << "\n";
        return;
    }
    ll mx = 0;
    for (const auto& c : cur) {
        mx = max(mx, (ll)(c - 'a'));
    }
    for (ll i = 0; i <= mx + 1; i++) {
        dfs(cur + (char)('a' + i));
    }
}

void solve() {
    cin >> N;
    dfs("a");
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int h1, s1, h2, s2;
	cin >> h1 >> s1 >> h2 >> s2;
	while (h1 > 0 and h2 > 0) {
		h2 = h2 - s1;
		h1 = h1 - s2;
	}
	if (h2 <= 0) {
		cout << "Yes" << endl;
	}
	else if (h2 > 0) {
		cout << "No" << endl;
	}
	else if (h1 > 0) {
		cout << "Yes" << endl;
	}
	else if ( h1 <= 0) {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;
  cin>>N;
  vl a(N);
  rep(i,N){
    cin>>a[i];
    a[i]-=i+1;
  }
  sort(all(a));
  ll b=a[N/2];
  ll ans=0;
  rep(i,N){
    ans+=abs(a[i]-b);
  }
  cout<<ans<<endl;
}

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

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

const ll INF = 1e15;

int main(){
  ll Q,H,S,D,N;
  cin >> Q >> H >> S >> D >> N;
  vector<ll> cost{Q, H, S, D};
  vector<ll> step{1, 2, 4, 8};
  ll zatu = 0;
  ll six = 6;
  if(N>=six){
    ll M = N-six;
    if(M%2){
      M--;
      N++;
      six++;
    }
    zatu = M / 2 * min(min(8*Q, 4*H) , min(2*S, D));
  }
  N = min(N, six);
  N*=4;
  vector<ll> dp(N+1, INF);
  dp[0] = 0;
  for(int q=3;q>=0;q--)
    for(int i=0;i<=N-step[q];i++)
      dp[i+step[q]] = min(dp[i+step[q]], dp[i] + cost[q]);
  /*for(int i=0;i<=N;i++){
    cout << dp[i] << " ";
  }
  cout << endl;*/
  cout << dp[N] + zatu << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;

			HashSet<Dice> set = new HashSet<Dice>();

			for(int i=0;i<n;i++){
				set.add(new Dice(sc.next(),sc.next(),sc.next(),sc.next(),sc.next(),sc.next()));
			}

			System.out.println(n - set.size());
		}
	}
}

class Dice{
	String t,b,w,e,n,s;

	Dice(String t,String s,String e,String w,String n,String b){
		this.t = t;
		this.s = s;
		this.e = e;
		this.w = w;
		this.n = n;
		this.b = b;
	}

	public boolean equals(Object o){
		Dice d = (Dice)o;

		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				for(int k=0;k<4;k++){
					if(this.equals2(d)) return true;
					d.move(0);
				}
				d.move(1);
			}
			d.move(2);
		}

		return false;
	}

	boolean equals2(Dice d){
		return
			t.equals(d.t) && b.equals(d.b) && w.equals(d.w) &&
			e.equals(d.e) && n.equals(d.n) && s.equals(d.s);
	}

	public int hashCode(){
		return 0;
	}

	void move(int dir){
		Dice d = this.copy();

		switch(dir){
		case 0:
			t = d.s;
			b = d.n;
			n = d.t;
			s = d.b;
			break;

		case 1:
			t = d.w;
			b = d.e;
			w = d.b;
			e = d.t;
			break;

		case 2:
			w = d.s;
			e = d.n;
			n = d.w;
			s = d.e;
			break;
		}
	}

	public String toString(){
		return String.format("[%s,%s,%s,%s,%s,%s]",t,s,e,w,n,b);
	}

	Dice copy(){
		return new Dice(t,s,e,w,n,b);
	}
}

Measured memory_bytes: 12000
#define _GLIBCXX_DEBUG //GCC環境での[]デバッグ
#include <bits/stdc++.h> //全ての標準ライブラリ
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
int sumVector (const std::vector<int>& v){ //int配列計算
    int sum = 0;
    rep(i, v.size()) sum += v.at(i);
    return sum; 
}
int main(void){
    int N , cnt = 0;
    cin >> N;
    std::vector<int> mochi(N);
    rep(i,N) cin >> mochi[i];
    sort(mochi.begin(), mochi.end(), std::greater<int>());
    // rep(i, N){
    //     cout << mochi[i];
    // }
    rep(i, N){
        if(i == 0) {
        cnt++;
        continue;
        }
        else if(mochi[i] < mochi[i-1]) {
             cnt++;
             //cout << i;
            
        }
        else if(mochi[i] == mochi[i-1]) continue;
    }
    cout << cnt;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int change[24][6] = {
	{0,1,2,3,4,5},
	{0,2,4,1,3,5},
	{0,4,3,2,1,5},
	{0,3,1,4,2,5},
	{5,2,1,4,3,0},
	{5,4,2,3,1,0},
	{5,3,4,1,2,0},
	{5,1,3,2,4,0},
	{1,2,0,5,3,4},
	{1,0,3,2,5,4},
	{1,3,5,0,2,4},
	{1,5,2,3,0,4},
	{4,0,2,3,5,1},
	{4,3,0,5,2,1},
	{4,5,3,2,0,1},
	{4,2,5,0,3,1},
	{2,0,1,4,5,3},
	{2,4,0,5,1,3},
	{2,5,4,1,0,3},
	{2,1,5,0,4,3},
	{3,1,0,5,4,2},
	{3,0,4,1,5,2},
	{3,4,5,0,1,2},
	{3,5,1,4,0,2}
};
int n, x[100][6][24];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i][0][0] >> x[i][1][0] >> x[i][2][0] >> x[i][3][0] >> x[i][4][0] >> x[i][5][0];
		for (int j = 0; j < 24; j++) {
			for (int k = 0; k < 6; k++) {
				x[i][k][j] = x[i][change[j][k]][0];
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i != j) {
				for (int k = 0; k < 24; k++) {
					for (int l = 0; l < 24; l++) {
						for (int m = 0; m < 6; m++) {
							if (x[i][m][k] != x[j][m][l]) {
								goto A;
							}
						}
						goto TRUE;
					A:;
					}
				}
			}
		}
	}
	goto FALSE;
TRUE:;
	cout << "No" << endl; goto Exit;
FALSE:; cout << "Yes" << endl;
Exit:;
	return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

/*
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};
*/


class UnionFind {
  private:
    vector<I> data;
 
  public:
    I root(I x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    UnionFind(I size) : data(size, -1) { }
    bool same(I x, I y) { return root(x) == root(y); }
    I size(I x) { return -data[root(x)]; }
   
    bool unite(I x, I y) {
      x = root(x); y = root(y);
      if (x != y) {
        if (data[y] < data[x]) swap(x, y);
        data[x] += data[y]; data[y] = x;
        return true;
      }
      else {
        return false;
      }
    }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n,k,l;
  cin >> n >> k >> l;
  UnionFind pq(n+1), rs(n+1);
  REP(i,k){
    I p,q;
    cin >> p >> q;
    pq.unite(p,q);
  }
  REP(i,l){
    I r,s;
    cin >> r >> s;
    rs.unite(r,s);
  }
  vector<P> t(n+1);
  REP(i,n+1){
    if (i==0) continue;
    t.at(i).first = pq.root(i);
    t.at(i).second = rs.root(i);
  }
  vector<P> tmp(n+1);
  tmp = t;
  SORT(tmp);
  REP(i,n+1){
    if (i==0) continue;
    P p = t.at(i);
    I lo = lower_bound(ALL(tmp), p) - tmp.begin();
    I up = upper_bound(ALL(tmp), p) - tmp.begin();
    I an = upper_bound(ALL(tmp), p) - lower_bound(ALL(tmp), p);
    if (i < n){
      cout << an << " ";
    }else{
      cout << an << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 9984
alpha = [chr(i) for i in range(97,97 + 26)]

def Count(s,t):
	ret = 0
	for i in alpha:
		if i in s and i in t:ret+=1
	return ret

n = int(input())
s = input()

ans = 0
for i in range(1,n):
	ans = max(ans,Count(s[:i],s[i:]))
print(ans)

Measured memory_bytes: 3064
//#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

//ifstream cin("x.in"); ofstream cout("x.out");

const int nmax = 300 + 5;

string s;
int d[nmax + 1][nmax + 1][nmax + 1];

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

    int n = (int)s.size();
    s = '#' + s;

    int ans = 0;

    for (int i = 1; i <= n; ++ i) {
        for (int j = n; j > i; -- j) {
            for (int k = 0; k <= q; ++ k) {
                d[ i ][ j ][ k ] = max(d[i - 1][ j ][ k ], d[ i ][j + 1][ k ]);

                if (k - 1 >= 0)
                    d[ i ][ j ][ k ] = max(d[ i ][ j ][ k ], d[ i ][ j ][k - 1]);

                if (s[ i ] == s[ j ])
                    d[ i ][ j ][ k ] = max(d[ i ][ j ][ k ], d[i - 1][j + 1][ k ] + 2);
                else if (k > 0)
                    d[ i ][ j ][ k ] = max(d[ i ][ j ][ k ], d[i - 1][j + 1][k - 1] + 2);
            }

            ans = max(ans, d[ i ][i + 1][ q ]);
            ans = max(ans, d[ i ][i + 2][ q ] + 1);
        }
    }

    if (n == 1)
        ans = 1;

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 110592
#include <stdio.h>

int N, A[112345];
int cou;

int main(void)
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) { scanf("%d", &A[i]); }

	for (int i = 0; i < N; ++i)
	{
		if (A[i] % 2 == 1)
		{
			++cou;
		}
	}

	if (cou % 2 == 0)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
int main() {
  string N;
  cin >> N;
  long long int sum=0;
  for(int i=0;i<N.size();i++){
    sum+=N[i]-'0';
  }
  if(sum%9==0){
    Yes();
  }
  else{
    No();
  }
  //cout << sum;
  cout << endl;
  return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define dl double
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define each(i, n) for(auto&& i: n)
#define co(n) cout << fixed << setprecision(n)

int main() {
  int N, K, a = 0;
  cin >> N >> K;
  ve(int) h(N);
  rep(i, N) {
    cin >> h.at(i);
  }
  rep(i, N) {
    if(h.at(i) >= K) {
      a++;
    }
  }
  cout << a << endl;
} 

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

int main()
{
    ll k;
    while(cin >> k)
    {
        ll ro = k / 50;
        ll yu = k % 50;
        ll ty = ro - yu;
        cout << 50 << endl;
        for(int i = 0;i < 50;i++)
        {
            if(i < yu)
            cout <<  i + ty + 51;
            else
            cout << i + ty;
            if(i != 49)
            cout << " ";
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 384
<?php
// Your code here!
$inp = fgets(STDIN);
$inp = explode(" ",$inp);
list($n,$a,$b) = array_map(function($a){return (int)$a;},$inp);
$s = trim(fgets(STDIN));
$ca = 0;
$co = 0;
$ss = str_split($s) ;
$ans = "";
foreach ($ss as $c)
{
    
    if($c == "a")
    {
        $ca += 1;
        if($ca <= $a + $b)
        {
            $ans .= ("Yes".PHP_EOL);
        }
        else
        {
            $ans .=("No".PHP_EOL);
        }
    }
    else if($c == "b")
    {
        
        $co += 1;
        if($co <= $b and $ca < $a + $b)
        {
            $ans .=("Yes".PHP_EOL);
            $ca += 1;
        }
        else
        {
            $ans .=("No".PHP_EOL);
        }
        
    }
    else
    {
        $ans .=("No".PHP_EOL);
    }
}
echo($ans);
?>


Measured memory_bytes: 22284
//47
#include<iostream>
#include<sstream>
#include<string>
#include<map>
#include<algorithm>
#include<set>

using namespace std;

int main(){
  for(string si;getline(cin,si),si!="";){
    string s;
    do{
      s+=si;
      getline(cin,si);
    }while(si!="");
    string k;
    getline(cin,k);

    bool ap[128]={};
    for(int i=0;i<k.size();){
      if(ap[k[i]]++){
	k.erase(i,1);
      }else{
	i++;
      }
    }

    cin.ignore();
    map<char,int> m;
    int f=0,l=1<<30;
    int n=0;
    set<long long> st;
    for(int i=0;i<s.size();i++){
      for(int j=0;j<k.size();j++){
	if(k[j]==s[i]){
	  m[s[i]]=i;
	}
      }
      if(m.size()!=k.size())continue;
      int cl=0,cf=1<<30;
      for(int j=0;j<k.size();j++){
	cl=max(cl,m[k[j]]);
	cf=min(cf,m[k[j]]);
      }
      if(!st.insert((long long)cl<<32|cf).second)continue;
      if(cl-cf<=l-f){
	if(cl-cf<l-f){
	  f=cf;
	  l=cl;
	  n=0;
	}
	n++;
      }
    }
    cout<<n<<endl<<endl;
    if(n){
      string t=s.substr(f,l-f+1);
      for(int i=0;i<t.size();i+=72){
	cout<<t.substr(i,72)<<endl;
      }
      cout<<endl;
    }
  }
  return 0;
}
    

Measured memory_bytes: 3424
import Control.Applicative ((<$>), (<*>))
import Control.Monad (replicateM, unless)
import Data.List (transpose)
import Data.Vector.Unboxed (Vector, (!), (//))
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve n <$> replicateM n (map read <$> words <$> getLine) >>= print
    main

solve :: Int -> [[Int]] -> Int
solve n ts = case hs of
              (h : _) -> h
              _ -> 0
  where v1 = V.fromList (map minimum ts)
        v2 = V.fromList (map maximum (transpose ts))
        hs = [h1 | i <- [0..n-1], j <- [0..n-1], let h1 = v1 ! i, let h2 = v2 ! j, h1 == h2]



Measured memory_bytes: 4680