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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	ll q,h,s,d,n;
	cin >> q >> h >> s >> d >> n;

	ll one = min({4*q,2*h,s});
	ll two = min({8*q,4*h,2*s,d});
	
	ll ans = two * (n/2) + one * (n%2);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

struct edge {
    int to, cost;
};

struct Maze {
    const int inf = 1<<29;
    int H, W;
    int cost1=1, cost2=inf, cost3=inf, cost4=inf;
    vector<string> maze;
    Maze(int H, int W, vector<string> maze) : H(H), W(W), maze(maze) {}
    vector<int> di={1,0,-1,0}, dj={0,1,0,-1};
    vector<vector<edge>> G;
    void Ginit() {
        G.resize(H*W);
        for(int i=0;i<H;++i) {
            for(int j=0;j<W;++j) {
                for (int k=0;k<4;k++) {
                    int ni = i + di[k];
                    int nj = j + dj[k];
                    if(0<=ni&&ni<H&&0<=nj&&nj<W) {
                        int cost=0;
                        if(maze[i][j]=='.'&&maze[ni][nj]=='.') cost=cost1;
                        else if(maze[i][j]=='.'&&maze[ni][nj]=='#') cost=cost2;
                        else if(maze[i][j]=='#'&&maze[ni][nj]=='.') cost=cost3;
                        else if(maze[i][j]=='#'&&maze[ni][nj]=='#') cost=cost4;
                        G[i*W+j].push_back((edge){nj*W+nj,cost});
                    }
                }
            }
        }
    }

    vector<vector<int>> d;
    void dinit() {
        d.resize(H*W);
        for(int i=0;i<H*W;++i) d[i].resize(H*W);
        for(int i=0;i<H*W;++i) {
            for(int j=0;j<H*W;++j) d[i][j] = inf;
            d[i][i] = 0;
        }
        for(int i=0;i<H;++i) {
            for(int j=0;j<W;++j) {
                for (int k=0;k<4;k++) {
                    int ni = i + di[k];
                    int nj = j + dj[k];
                    if(0<=ni&&ni<H&&0<=nj&&nj<W) {
                        int cost=0;
                        if(maze[i][j]=='.'&&maze[ni][nj]=='.') cost=cost1;
                        else if(maze[i][j]=='.'&&maze[ni][nj]=='#') cost=cost2;
                        else if(maze[i][j]=='#'&&maze[ni][nj]=='.') cost=cost3;
                        else if(maze[i][j]=='#'&&maze[ni][nj]=='#') cost=cost4;
                        d[i*W+j][ni*W+nj] = cost;
                    }
                }
            }
        }
    }

};

int main() {
    int H, W; cin >> H >> W;
    vector<string> maze(H);
    REP(i,H) cin >> maze[i];
    Maze MZ(H,W,maze); MZ.dinit();
    REP(k,H*W)REP(i,H*W)REP(j,H*W) MZ.d[i][j] = min(MZ.d[i][j],MZ.d[i][k]+MZ.d[k][j]);
    int ans = 0;
    REP(i,H*W)REP(j,H*W) {
        if(MZ.d[i][j]!=(1<<29)) ans = max(ans,MZ.d[i][j]);
    }
    // REP(i,H*W){REP(j,H*W) cout << MZ.d[i][j] << ' ';cout << endl;}
    cout << ans << endl;
}

Measured memory_bytes: 896
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    if (s.endsWith("s")) {
        println(s + "es")
    } else {
        println(s + "s")
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 35728
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

H,W = LI()
S = [list(map(str, input())) for _ in range(H)]

count = [[0]*W for _ in range(H)]
for i in range(H)[::-1]:
    for j in range(W)[::-1]:
        if i==H-1 and j==W-1:
            if S[i][j] == '#':
                count[i][j] = 1
            else:
                count[i][j] = 0
        elif i==H-1:
            if S[i][j+1]=='.' and S[i][j]=='#':
                count[i][j] = count[i][j+1]+1
            else:
                count[i][j] = count[i][j+1]
        elif j==W-1:
            if S[i+1][j]=='.' and S[i][j]=='#':
                count[i][j] = count[i+1][j]+1
            else:
                count[i][j] = count[i+1][j]
        else:
            if S[i][j+1]=='.' and S[i][j]=='#':
                one = count[i][j+1]+1
            else:
                one = count[i][j+1]
            if S[i+1][j]=='.' and S[i][j]=='#':
                two = count[i+1][j]+1
            else:
                two = count[i+1][j]
            count[i][j] = min(one,two)

print(count[0][0])

Measured memory_bytes: 43888
/* IPT1_7_A_C: Spread Sheet */

#include <iostream>

int main() {
    int n_row, n_col;
    std::cin >> n_row >> n_col;

    int table[n_row + 1][n_col + 1];
    for (int row = 0; row < n_row; row++) {
        for (int col = 0; col < n_col; col++) {
            std::cin >> table[row][col];
        }
    }

    int sum_per_rows[n_row];
    int sum_per_cols[n_col];
    int sum_all = 0;
    std::fill_n(sum_per_rows, n_row, 0);
    std::fill_n(sum_per_cols, n_col, 0);

    for (int row = 0; row < n_row; row++) {
        for (int col = 0; col < n_col; col++) {
            int cell = table[row][col];
            sum_per_rows[row] += cell;
            sum_per_cols[col] += cell;
            sum_all += cell;
        }
        table[row][n_col] = sum_per_rows[row];
    }
    table[n_row][n_col] = sum_all;

    for (int col = 0; col < n_col; col++) {
        table[n_row][col] = sum_per_cols[col];
    }

    for (int row = 0; row <= n_row; row++) {
        std::cout << table[row][0];
        for (int col = 1; col <= n_col; col++) {
            std::cout << " " << table[row][col];
        }
        std::cout << std::endl;
    }
}

Measured memory_bytes: 1200
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = INT_MAX/3;

int main(){
    int H, W;
    cin >> H >> W;
    while(H!=0 || W!=0){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if((i+j)%2 == 0){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl ;
        }
        cout << endl;
        cin >> H >> W;
    }
    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;

int n,a[20],b[20],dp[300010][60];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	for(int i=0;i<=(1<<n)-1;i++) for(int j=1;j<=50;j++) dp[i][j]=INF;
	dp[0][1]=0;
	for(int i=0;i<(1<<n)-1;i++){
		int sum=__builtin_popcount(i);
		for(int j=1;j<=50;j++) if(dp[i][j]!=INF){
			int num=0;
			for(int k=n;k>=1;k--){
				if(i&(1<<(k-1))) num++;
				else{
					int ch=abs(k-(sum+1));
					int cur=0;
					if(ch%2==0) cur=a[k];
					else cur=b[k];
					if(cur>=j){
						dp[i|(1<<(k-1))][cur]=min(dp[i|(1<<(k-1))][cur],dp[i][j]+num);
					}
				}
			}
		}
	}
	int minv=INF;
	for(int i=1;i<=50;i++) minv=min(minv,dp[(1<<n)-1][i]);
	if(minv==INF) minv=-1;
	cout<<minv<<endl;
	return 0;
}

Measured memory_bytes: 63872
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}


	public void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int a[] = new int[N];

		int max=-Integer.MAX_VALUE;
		int maxi = -1;
		int min=Integer.MAX_VALUE;
		int mini = -1;
		for(int i=0; i<N; i++) {
			a[i]=sc.nextInt();
			if(max<a[i]) {
				max=a[i];
				maxi=i;
			}
			if(min>a[i]) {
				min=a[i];
				mini=i;
			}
		}
		System.out.println(2*N-1);
		if(Math.abs(max)>=Math.abs(min)) {
			for(int i=0; i<N; i++) {
				System.out.println((maxi+1)+" "+(i+1));
			}
			for(int i=0; i<N-1; i++) {
				System.out.println((i+1) + " "+ (i+2));
			}
		}else {
			for(int i=0; i<N; i++) {
				System.out.println((mini+1)+" "+(i+1));
			}
			for(int i=N-1; i>=1; i--) {
				System.out.println((i+1) + " "+ i);
			}
		}

		sc.close();
	}
}


Measured memory_bytes: 39128
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll n;
	cin >> n;
	vector<ll> p(n);
	rep(i, n) cin >> p[i];

	ll ans = 0;
	for(ll i = 1; i < n - 1; i++) {
		if(p[i] != max(p[i-1], max(p[i], p[i+1])) && p[i] != min(p[i-1], min(p[i], p[i+1]))) {
			ans++;
		}
	}

	cout << ans << endl;
}


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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


const int INF = 1 << 29;

auto solve() {
    int N;
    cin>>N;
    vi a(N);
    for(auto&&e: a) cin>>e;

    bool sec = true;
    for(auto&&e: a) {
        if(e % 2 == 1)
            sec = false;
    }

    return !sec;
}


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

    cout << (solve() ? "first" : "second") << endl;
//    solve();
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int a,b,e,n;
  int c[301],i,d[1000],m[1000],k[1000],r[1000];
  while(1){
    scanf("%d %d %d",&a,&b,&e);
    if(!(a||b||e))break;
    scanf("%d",&n);
    for(i=1;i<=a+b+e;i++)c[i]=2;
    for(i=0;i<n;i++){
      scanf("%d %d %d %d",&d[i],&m[i],&k[i],&r[i]);
      if(r[i]){
	c[d[i]]=1;
	c[m[i]]=1;
	c[k[i]]=1;
      }
    }
    for(i=0;i<n;i++){
      if(r[i])continue;
      if(c[d[i]]*c[m[i]]*c[k[i]]==2){
	if(c[d[i]]==2)c[d[i]]=0;
	if(c[m[i]]==2)c[m[i]]=0;
	if(c[k[i]]==2)c[k[i]]=0;
      }
    }
    for(i=1;i<=a+b+e;i++)printf("%d\n",c[i]);
  }
  return 0;
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
        static void SolveA()
        {
            var abk = ReadAndParseLongArr();
            long a = abk[0];
            long b = abk[1];
            long k = abk[2];
            for(int i=0;i<k;++i)
            {
                if( i % 2 == 0)
                {
                    if( a % 2 == 1)
                    {
                        a--;
                    }
                    long a2 = a / 2;
                    a = a - a2;
                    b = b + a2;

                }
                else
                {
                    if (b % 2 == 1)
                    {
                        b--;
                    }
                    long b2 = b / 2;
                    b = b - b2;
                    a = a + b2;
                }
            }

            Console.WriteLine(a + " " + b);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=998244353,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void extended_euclid(ll x,ll y,ll *c,ll *a,ll *b){
  ll a0,a1,a2,b0,b1,b2,r0,r1,r2,q;r0=x;r1=y;a0=1;a1=0;b0=0;b1=1;
  while(r1>0){q=r0/r1;r2=r0%r1;a2=a0-q*a1;b2=b0-q*b1;r0=r1;r1=r2;a0=a1;a1=a2;b0=b1;b1=b2;}
  *c=r0;*a=a0;*b=b0;
}

ll get_inv(ll n, ll p){
  ll a,b,c;
  extended_euclid(n,p,&c,&a,&b);
  if(a<p) a+=p;
  return a%p;
}

int N=1<<18;
class StarrySkyTree{
public:
  ll Mi[555555],A[555555];
  void init(){memset(Mi,0,sizeof(Mi)),memset(A,0,sizeof(A));}
  void add(int a,int b,ll x,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      A[k]+=x;
      A[k]%=MAX;
      while(k){
        k=(k-1)/2;
        Mi[k]=min(Mi[k*2+1]+A[k*2+1],Mi[k*2+2]+A[k*2+2])%MAX;
      }
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
  ll getMin(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return MAX;if(a<=l&&r<=b)return (Mi[k]+A[k])%MAX;
    ll left=getMin(a,b,k*2+1,l,(l+r)/2),right=getMin(a,b,k*2+2,(l+r)/2,r);
    return (min(left,right)+A[k])%MAX;
  }
};

StarrySkyTree t,r;

void Main() {
  t.init();
  r.init();
  ll n,m,a;
  cin >> n >> m >> a;
  t.add(0,1,1);
  r.add(0,1,1);
  rep(i,m) {
    ll x=t.getMin(i,i+1);
    t.add(i+1,min(m,i+n+1),x*a%MAX*get_inv(100,MAX)%MAX*get_inv(n,MAX)%MAX);
    t.add(min(m,i+n+1),i+n+1,x*get_inv(n,MAX)%MAX);
  }
  ll ans=0;
  REP(i,m,m+n+1) {
    ans+=t.getMin(i,i+1);
    ans%=MAX;
  }
  pr(ans);
}

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



Measured memory_bytes: 20600
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;

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

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

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

double fix(double a){
	if(a < 0) return a+360;
	if(a >= 360) return a-360;
	return a;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	pair<double, int> gpa[114514];
	int res[114514] = {};
	cin >> N;
	REP(i, N){
		cin >> gpa[i].first;
		gpa[i].second = i;
	}
	sort(gpa, gpa+N);
	REP(i, N){
		int s = i;
		while(gpa[s].first == gpa[i].first){
			s++;
		}
		FOR(j, i, s){
			res[gpa[j].second] = i*3+(s-i-1);
		}
		i = s-1;
	}
	REP(i, N){
		cout << res[i] << endl;
	}
}

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

int main(){
  string c;
  cin >> c;

  if(c[0] == 'a' || c[0] == 'i' || c[0] == 'u' || c[0] == 'e'|| c[0] == 'o'){
    std::cout << "vowel" << std::endl;
  }else{
    std::cout << "consonant" << std::endl;
  }
}


Measured memory_bytes: 256
n,W=map(int,input().split())
v=[]
w=[]

for i in range(n):
    temp_w,temp_v=map(int,input().split())
    w.append(temp_w)
    v.append(temp_v)
    

dp=[[0]*(W+1) for _ in range(n+1)]

for i in range(n):
    for j in range(W+1):
        if j>=w[i]:
            dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j])
        else:
            dp[i+1][j]=max(dp[i][j],dp[i+1][j])
print(dp[n][W])


Measured memory_bytes: 147508
s = input()
d = {}
for i in range(len(s)):
    if s[i] not in d:
        d[s[i]] = 1
    else:
        d[s[i]] += 1
for v in d.values():
    if v != 2:
        print("No")
        exit()
print("Yes" if len(d) == 2 else "No")


Measured memory_bytes: 2940
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007



int main() {
  string s;
  cin >> s;
  vector<int> d(27, 0);

  rep(i, s.size()) {
    d.at(s.at(i) - 'a') ++;
  }

  bool f = false;

  rep(i, 26) {
    if (d.at(i) == 0) {
      char c = 'a' + i;
      cout << c << endl;
      f = true;
      break;
    }
  }

  if (!f) cout << "None" << endl;

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

vector<int> node[100000];

void getdepth(int depth,int id,int out[]){
    out[id] = depth;
    for(int i = 0;i < node[id].size();i++){
        getdepth(depth + 1,node[id][i],out);
    }
}

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

    for(int i = 0;i < n;i++){
        int id,k;
        scanf("%d%d",&id,&k);
        for(int j = 0;j < k;j++){
            int c;
            scanf("%d",&c);
            node[id].pb(c);
        }
    }

    int parent[n];
    for(int i = 0;i < n;i++){
        parent[i] = -1;
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < node[i].size();j++){
            parent[node[i][j]] = i;
        }
    }

    vector<int> root;
    for(int i = 0;i < n;i++)
        if(parent[i] == -1){
            root.pb(i);
        }

    int depth[n];
    for(int i = 0;i < root.size();i++)
        getdepth(0,root[i],depth);

    for(int i = 0;i < n;i++){
        printf("node %d: parent = %d, depth = %d, ",i,parent[i],depth[i]);
        if(parent[i] == -1)
            printf("root");
        else if(node[i].size())
            printf("internal node");
        else
            printf("leaf");
        printf(", [");
        for(int j = 0;j < node[i].size();j++){
            printf("%d",node[i][j]);
            if(j < node[i].size() - 1)
                printf(", ");
        }
        printf("]\n");
    }
    return 0;
}

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

int input(int &n, int &k) {
	return scanf("%d %d", &n, &k);
}

int main() {
	int n, k;
	while (input(n, k)) {
		if (n == 0 && k == 0) break;
		vector<int> card(k);
		for (int i = 0; i < k; i++) {
			int c;
		   	scanf("%d", &c);
		   	card[i] = c;
		}
		sort(card.begin(), card.end());
		if (card[0] == 0) {
			int longest[2] = {0, 0};  // longest[0]: don't use zero, longest[1]: use zero
			int cur_len[2] = {1, 1};  // cur_len[0]: don't use zero, cur_len[1]: use zero
			for (int i = 1; i < k-1; i++) {
				if (card[i+1] == card[i] + 1) {
					cur_len[0]++;
					cur_len[1]++;
				} else if (card[i+1] == card[i] + 2) {
					longest[0] = max(longest[0], cur_len[0]);
					longest[1] = max(longest[1], cur_len[1]);
					cur_len[1] = cur_len[0] + 2;
					cur_len[0] = 1;
				} else {
					longest[0] = max(longest[0], cur_len[0]);
					cur_len[0] = 1;
					longest[1] = max(longest[1], cur_len[1]);
					cur_len[1] = 1;
				}
			}
			longest[0] = max(longest[0], cur_len[0]);
			longest[1] = max(longest[1], cur_len[1]);
			if (n != k) longest[0]++;
			printf("%d\n", max(longest[0], longest[1]));
		} else {
			int longest = 0;
			int cur_len = 1;
			for (int i = 0; i < k-1; i++) {
				if (card[i+1] == card[i] + 1) {
					cur_len++;
				} else {
					longest = max(longest, cur_len);
					cur_len = 1;
				}
			}
			longest = max(longest, cur_len);
			printf("%d\n", longest);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  string s, t;
  cin >> s >> t;
  int count = 0;
  rep(i, s.size()) {
    if (s[i] != t[i]) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3920
#include<stdio.h>

int main(void)
{
	int a, b, c,d,e,f;

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

	c = a + b;
	d = a - b;
	e = a * b;
	
	if (c > d)
	{
		if (c > e)
			f = c;
		else if (e > c)f = e;

	}
	else
	{
		if (d > e)
			f = d;
		else if (e > c)
			f = e;

	}


		
				

		printf("%d", f);

	return 0;
}


Measured memory_bytes: 128
import sys
x, y = [int(i) for i in input().split()]
z = [0]*2

if y % 2 != 0:
  print('No')
  sys.exit()

for i in range(1, x+1):
  z[0] += 2
  z[1] += 4

if y >= z[0] and y <= z[1]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9192
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main(){
    int N; cin >> N;
    string s; cin >> s;
    int r=0, b=0;
    for(int i=0; i<N; i++){
        if(s[i]=='R') r++;
        if(s[i]=='B') b++;
    }
    if(r>b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int, int> P;
string s;
bool overflow = false;
P num(int& p){
  if(s[p] == 'i'){
    p += 1;
    return P(0, 1);
  }
  bool minus = false;
  if(s[p] == '-'){
    minus = true;
    p += 1;
  }
  int res = 0;
  while(isdigit(s[p])){
    res = res * 10 + (s[p] - '0');
    p += 1;
    if(res > 10000) overflow = true;
  }
  return P((minus)?(-res):(res),0);
}
P expr(int& p){
  stack<P> result;
  if(s[p] == '('){
    p += 1;
    result.push(expr(p));
    p += 1;
  }else{
    result.push(num(p));
  }
  if(abs(result.top().first) > 10000 || abs(result.top().second) > 10000) overflow = true;
  while(p < s.size() && s[p] != ')'){
    char ope = s[p++];
    P number;
    if(s[p] == '('){
      p += 1;
      number = expr(p);
      p += 1;
    }else{
      number = num(p);
    }
    if(ope == '+') result.push(number);
    else if(ope == '-') result.push(P(-number.first, -number.second));
    else{
      P last = result.top(); result.pop();
      result.push(P(last.first*number.first - last.second*number.second, last.first*number.second+last.second*number.first));
    }
    if(abs(result.top().first) > 10000 || abs(result.top().second) > 10000) overflow = true;
  }
  P res = P(0,0);
  stack<P> result2;
  while(!result.empty()) result2.push(result.top()), result.pop();
  while(!result2.empty()){
    res = P(res.first + result2.top().first, res.second + result2.top().second); result2.pop();
    if(abs(res.first) > 10000 || abs(res.second) > 10000) overflow = true;
  }
  return res;
}

int main(){
  while(cin>>s){
    int p = 0;
    overflow = false;
    P ans = expr(p);
    if(overflow) cout<<"overflow"<<endl;
    else if(ans.first != 0 && ans.second != 0){
      if(true)printf("%d%+di\n",ans.first, ans.second);
      else printf("%d%ci\n",ans.first, (ans.second>0)?'+':'-');
    }
    else if(ans.first == 0 && ans.second != 0){
      if(true) printf("%di\n", ans.second);
      else printf("%ci\n",(ans.second>0)?'+':'-');
    }
    else if(ans.first != 0 && ans.second == 0) printf("%d\n", ans.first);
    else printf("%d\n", 0);
  }
  return 0;
}

Measured memory_bytes: 0
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int N = s.size();
	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		if ((s[i] + i) % 2 == 0) ++cnt;
	}
	cout << min(cnt, N - cnt) << endl;
	return 0;
}

Measured memory_bytes: 3780
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
string a[101];int n,i;
int main(){
    scanf("%d%*d",&n);
    for(i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(i=1;i<=n;i++)
        cout<<a[i];
    return 0;
}

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

int main(){
  int h, r;
  cin >> h >> r;
  if(h >= 0){
    cout << 1 << endl;
  }else if((h + r) == 0){
    cout << 0 << endl;
  }else{
    cout << -1 << endl;
  }
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int H, W; cin >> H >> W;
	vector<string> C(H);
	for(int i = 0; i < H; i++) cin >> C[i];
	for(int i = 0; i < H; i++) for(int j = 0; j < 2; j++) cout << C[i] << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>

int main() {
	int p=0, tmp=0, tmp0=0, tmp1=0, tmp2=0, outp=0;
	char str[1000];
	scanf("%d", &p);
	gets(str);
	while (tmp<p) {
		gets(str);
		tmp0=0;
		while (1) {
			if (str[tmp0]=='\0'&&str[tmp0]!=' ') break;
			tmp0++;
		}
		tmp2=tmp0;
		tmp0=0;
		while (str[(tmp0+6)]!='\0') {
			if (str[(tmp0)]=='H'&&str[(tmp0+1)]=='o'&&str[(tmp0+2)]=='s'&&str[(tmp0+3)]=='h'&&str[(tmp0+4)]=='i'&&str[(tmp0+5)]=='n'&&str[(tmp0+6)]=='o') {
				str[(tmp0+6)]='a';
			}
			tmp0++;
		}
		puts(str);
		tmp++;
	}
	return 0;
}

Measured memory_bytes: 580
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int H = sc.nextInt();
        int W = sc.nextInt();
        //        int[] X = new int[N];
        //        for (int i = 0; i < N; i++) {
        //            X[i] = sc.nextInt();
        //        }
        System.out.println((N - H + 1) * (N - W + 1));
        sc.close();
    }
}

Measured memory_bytes: 21844
#include<iostream>

using namespace std;

bool judge(int A,int B,int C){
  if(A >= B+C) return false;
  else if(B >= C+A) return false;
  else if(C >= A+B) return false;
  else if(A == B) return false;
  else if(B == C) return false;
  else if(C == A) return false;
  else return true;
}

int main(void){
  int N,ans = 0;

  cin >> N;
  if(N < 3){
    cout << '0' << endl;
    return 0;
  }

  int L[N];

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

  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(judge(L[i],L[j],L[k]))
          ans++;
      }
    }
  }

  cout << ans << endl;
}


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

namespace program{
    public class AtCoder{
        public static void Main(string[] args){
            // 整数の入力
            var input = Console.ReadLine().Split(' ');
    		long A = long.Parse(input[0]);
    		long B = long.Parse(input[1]);
    		long N = long.Parse(input[2]);
    		var answerX = B - 1;
    		if(answerX > N) answerX = N;
    		var answer = (long)(A * answerX / B) - A * (long)(answerX / B);
    		Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 17888
#include <stdio.h>

int main(){
    int n;
    int ans  =0;
    scanf("%d",&n);
    for(int i=1;i<=n-1;i++){
        int temp = n - i;

        int mult = 1;
        for (int i=2;temp>1 && i*i<=temp;i++){
            int ctr= 0;
            while(temp%i==0){
                temp /=i;
                ctr++;
            }
            if(ctr){
                mult*=(ctr+1);
            }
        }
        if(temp!=1){
            mult *= 2;
        }
        ans += mult;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1736
N = int(input())
L = list(map(int, input().split()))
L2 = list(set(L))

if len(L2) < 3:
  print("0")
  exit()

idx = dict()
for i in L:
  if i in idx:
    idx[i] = idx[i] + 1
  else:
    idx[i] = 1
    
def quicksort(arr):
  if len(set(arr)) <2:
    return arr
  center = arr.pop(0)
  left = []
  right = []
  for i in arr:
    if i < center:
      left.append(i)
    else:
      right.append(i)
  left = quicksort(left)
  right = quicksort(right)
  left.append(center)
  left += right
  return left

L2 = quicksort(L2)

res = 0
l = len(L2)

for i in range(l-2):
  for j in range(i+1,l-1):
    for k in range(j+1,l):
      if L2[i] + L2[j] > L2[k]:
        res += idx[L2[i]] * idx[L2[j]] * idx[L2[k]]

print(res)



Measured memory_bytes: 67464
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(int i=0;i<n;i++)
#define repf(i,f,n) for(int i=f;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())



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


int main() {

  string acgt = "ACGT";

  int N,Q;
  cin >> N >> Q;

  string S;
  cin >> S;

  vint cnts = vint(N,0);
  int cnt = 0;
  bool aflag = false;

  rep(i,N){
    if(S[i]=='C' && aflag){
      cnt++;
    }
    if(S[i]=='A'){
      aflag=true;
    }else{
      aflag=false;
    }

    cnts[i] = cnt;
  }

  // int l[Q], r[Q];
  int l,r;
  rep(i,Q){
    cin >> l >> r;


    cout << cnts[r-1]-cnts[l-1] << endl;



  }





}

















//


Measured memory_bytes: 1408
from operator import itemgetter
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
AB.sort(key=itemgetter(1))

ok = 0
ans = 0
for a, b in AB:
    if a >= ok:
        ans += 1
        ok = b
print(ans)


Measured memory_bytes: 29152
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N, A, B; std::cin >> N >> A >> B;
  std::cout << std::min(N*A, B) << std::endl;

  return 0;
}


Measured memory_bytes: 256
using System;

class Program {
  static void Main() {
    var L = int.Parse(Console.ReadLine());
    var a = int.Parse(Console.ReadLine());
    var b = int.Parse(Console.ReadLine());
    var c = int.Parse(Console.ReadLine());
    var d = int.Parse(Console.ReadLine());
    var m = Math.Max((a + c - 1) / c, (b + d - 1) / d);
    Console.WriteLine(L - m);
  }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    double sum = 0;
    for(int i=0;i < N;i++) cin >> X[i];
    vector<int> ans(100,0);
    for(int i=0;i < 100;i++){
        for(int j=0;j < N;j++){
            ans[i] += (X[j] - i - 1)*(X[j] - i - 1);
        }
    }
    int answer = 100000000;
    for(int i=0;i < 100;i++){
        answer = min(answer,ans[i]);
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
n,p,q=map(int,input().split())
M2=-10*(-n//2)
M1=10*(n//2)
dp1=[[float("INF")]*(M1+1)for i in range(M1+1)]
dp1[0][0]=0
for _ in range(n//2):
    a,b,c=map(int,input().split())
    for i in range(M1,a-1,-1):
        for j in range(M1,b-1,-1):
            dp1[i][j]=min(dp1[i][j],dp1[i-a][j-b]+c)
dp2=[[float("INF")]*(M2+1)for i in range(M2+1)]
dp2[0][0]=0
for _ in range(-(-n//2)):
    a,b,c=map(int,input().split())
    for i in range(M2,a-1,-1):
        for j in range(M2,b-1,-1):
            dp2[i][j]=min(dp2[i][j],dp2[i-a][j-b]+c)
ans=float("INf")
for i in range(M1+1):
    for j in range(M1+1):
        for c in range(max(1,-min(-i//p,-j//q)),M2//max(p,q)+1):
            ans=min(ans,dp1[i][j]+dp2[c*p-i][c*q-j])
print(ans if ans!= float("INF") else -1)

Measured memory_bytes: 76496
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

double gettheta(int h, int m) {
    double theta1 = m / 60.0 * 2.0 * M_PI;
    double theta2 = (h / 12.0 + m / 60.0 / 12.0) * 2.0 * M_PI;
    return fabs(theta1 - theta2);
}
int main() {
    double a, b;
    int h, m;
    cin >> a >> b >> h >> m;
    long double r = sqrt(a * a + b * b - 2 * a * b * cos(gettheta(h, m)));
    cout << fixed << setprecision(15) << r << endl;
    return 0;
}

Measured memory_bytes: 4152
import java.io.UnsupportedEncodingException;
import java.util.Scanner;

/**
 * Counting Characters
 */
public class Main {
    private static byte[] asciiCodes = new byte[26];
    private static int asc_a = 97;
    private static String alphabet;
    private static int alphabetSize = 26;

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

        setAsciiCodes();
        String str;
        int [] count = new int[26];

        while (scan.hasNext()) {
            str = scan.nextLine();
            str = str.toLowerCase();
            for (int i = 0; i < str.length(); i++) {
                for (int y = 0; y < alphabetSize; y++) {
                    if (str.substring(i, i+1).equals(alphabet.substring(y, y+1))) {
                        count[y]++;
                    }
                }
            }
        }
        for (int p = 0; p < alphabetSize; p++) {
            System.out.println(alphabet.substring(p, p+1) + " " + ":" + " " + count[p]);
        }
    }

    private static void setAsciiCodes() {
        for (int i = 0; i < alphabetSize; i++) {
            asciiCodes[i] = (byte) asc_a;
            asc_a ++;
        }
        try {
            alphabet = new String(asciiCodes, "US-ASCII");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 20788
N = int(input())
X_2 = input()
X_10 = int(X_2, 2)

y = X_2.count('1')

a = X_10%(y+1)
if y==1:
    b = 0
else:
    b = X_10%(y-1)

for i in range(N):
    if X_2[i] == '1' and y == 1:
        print(0)
        continue
    elif X_2[i] == '1':
        x = (b-pow(2, N-1-i, y-1))%(y-1)
    else:
        x = (a+pow(2, N-1-i, y+1))%(y+1)
    count = 1
    while x!=0:
        x %= bin(x)[2:].count('1')
        count += 1
    print(count)

Measured memory_bytes: 9540
struct Rin{}
impl Rin{
    fn input(&self)->String{
        let mut x=String::new();
        std::io::stdin().read_line(&mut x).ok();
        x
    }
    fn inputs(&self)->String{
        let s=self.input().trim().to_string();
        s
    }
    fn inputn(&self)->i32{
        let n:i32=self.input().trim().parse().unwrap();
        n
    }
    fn inputvs(&self)->Vec<String>{
        let vs=self.input().trim().split(' ').map(|x|x.to_string()).collect();
        vs
    }
    fn inputvn(&self)->Vec<i32>{
        let vn=self.input().trim().split(' ').map(|x|x.to_string().parse().unwrap()).collect();
        vn
    }
}

fn main(){
    let r=Rin{};
    let k=r.inputn() as usize;
    let s=r.inputs();
    if s.len()<=k{
        println!("{}",s);
    }else{
        println!("{}...",s[..k].to_string());
    }
}

Measured memory_bytes: 2080
/*
8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1
*/
#include <bits/stdc++.h>
using namespace std;
void print() { cout << '\n'; } template<class T, class ...U> void print(T x, U ...y){ cout << x << ' '; print(y...); }
typedef long long ll; const int N = 2e5 + 5, M = 1e9 + 7; typedef vector<int> vi; typedef vector<vi> vii; void Main();
int main(int argc, char **argv) {
  ios::sync_with_stdio(0), cin.tie(0); cout << setprecision(10) << fixed;
  #ifdef Zmm
  freopen((string(*(argv)).substr(2, string(*(argv)).size() - 6) + string(".cpp")).c_str(), "r", stdin); string x; cin >> x;
  #endif
  Main();
}

void Main() {
  int n, A = 1, B = 1, time = 1;
  cin >> n;
  vi a(n), b(n), c(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) c[i] = i + 1;
  do {
    int x = 0, y = 0;
    for (int i = 0; i < n; i++) if (a[i] == c[i]) x++;
    for (int i = 0; i < n; i++) if (b[i] == c[i]) y++;
    if (x == n) A = time;
    if (y == n) B = time;
    time++;
  } while(next_permutation(c.begin(), c.end()));
  cout << abs(A - B) << '\n';
}

Measured memory_bytes: 256
n, m = map(int, input().split())
red = [1] + [0] * (n - 1)
num = [1] * n
for i in range(m):
    x, y = map(int, input().split())
    if red[x - 1] == 1:
        red[y - 1] = 1
        if num[x - 1] == 1:
            red[x - 1] = 0
    num[x - 1] -= 1
    num[y - 1] += 1
    
print(sum(red))

Measured memory_bytes: 10480
#include<bits/stdc++.h>
using namespace std;
char c[15],ans[15];int zz,l,i;
int main(){
	scanf("%s",c);
	l=strlen(c);
	for(i=0;i<l;i++)
		if(c[i]=='B'){if(zz) ans[zz--]=0;}
		else ans[zz++]=c[i];
	for(i=0;i<zz;i++) printf("%c",ans[i]);
	printf("\n");
	return 0;
}

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxs = 210;

LL n;

int n_le = 0;
int le[maxs + 5];
int n_ri = 0;
int ri[maxs + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> n;
	++n;
	int first_bit = -1;
	for (int i = 40; i >= 0; --i) if (n >> i & 1) { first_bit = i; break; }
	int now = 0;
	for (int i = first_bit - 1; i >= 0; --i)
	{
		++now;
		le[n_le++] = now;
		ri[n_ri++] = now;
		if (n >> i & 1) 
		{
			++now;
			le[n_le++] = now;
			ri[n_ri++] = now;
			rotate(ri, ri + (n_ri) - 1, ri + n_ri);
		}
	}
	printf("%d\n", n_le + n_ri);
	REP(i, 0, n_le) printf("%d ", le[i]);
	REP(i, 0, n_ri) printf("%d ", ri[i]);
	return 0;
}


Measured memory_bytes: 256
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);
#define asc(A) sort(A.begin(),A.end())
#define dsc(A) sort(A.begin(),A.end(),greater<ll>())
#define input(A,N) for(ll i=0;i<N;i++) cin>>A[i];
int main()
{
    fasino
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    #endif
    ll K,A,B;
    cin>>K>>A>>B;
    ll m = B/K;
    if(m*K>=A && m*K<=B){
        cout<<"OK";
    }
    else{
        cout<<"NG";
    }
    return 0;
}

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

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

    int ans = 0;

    for (int i=1; i<A; i++){
        for (int j=1; j<31; j++){
            if (i == j) ans = ans + 1;
        }
    }
    
    for (int j=1; j<(B+1); j++){
        if (A == j) ans = ans + 1;
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
from sys import stdin

S = stdin.readline().rstrip()

count = 0
if S[0]=='R':
  if S[1] =='R':
    if S[2] =='R':
      count = 3
    else:
      count = 2
  else:
    if S[2] =='R':
      count = 1
    else:
      count = 1
else:
  if S[1] =='R':
    if S[2] =='R':
      count = 2
    else:
      count = 1
  else:
    if S[2] =='R':
      count = 1
    else:
      count = 0

print(count)


Measured memory_bytes: 61764
N = int(input())
X = list(map(int, input().split()))

mm = 0
for x in X:
    mm += x**2

for i in range(min(X), max(X) + 1):
    s = 0
    for x in X:
        s += (x - i)**2

    if s < mm:
        mm = s

print(mm)


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

int main() {
    int s;
    cin >> s;
    if((s/100)>=1 && (s/100)<=12 && (s%100)>=1 && (s%100)<=12){
        cout << "AMBIGUOUS" << endl;
    }
    else if((s/100)>=1 && (s/100)<=12 && ((s%100)>=13 || (s%100)==0)){
        cout << "MMYY" << endl;
    }
    else if(((s/100)==0 || (s/100)>=13) && (s%100)>=1 && (s%100)<=12){
        cout << "YYMM" << endl;
    }
    else{
        cout << "NA" << endl;
    }
}

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

A = map(int,input().split())
B = map(int,input().split())
C = map(int,input().split())

Z = []

for a in A:
    Z.append([a,0])
    
for b in B:
    Z.append([b,1])

for c in C:
    Z.append([c,2])
    
Z.sort()

accum_a = 0
a_buf = 0
accum_c = 0
c_buf = 0
b_buf = 0
prev_z = 0
ans = 0
for z in Z:
    if z[0]==prev_z:
        if z[1]==0:
            a_buf+=1
        elif z[1]==1:
            b_buf+=1
        else:
            c_buf+=1
    else:
        prev_z = z[0]
        accum_c+=c_buf
        ans+=b_buf*(N-accum_c)*accum_a
        accum_a+=a_buf
        a_buf=0
        b_buf=0
        c_buf=0
        if z[1]==0:
            a_buf+=1
        elif z[1]==1:
            b_buf+=1
        else:
            c_buf+=1
            
print(ans)

Measured memory_bytes: 50520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
#define fill(x, v) memset(x, v, sizeof(x))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define ios std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
/*
std::cout << std::setprecision(9) << f << '\n';//3.141590000;
map<char,int>::reverse_iterator rit;
for(rit = mp.rbegin(); rit!=mp.rend(); rit++)
*/
int n;
int32_t main()
{
    ios;

    unsigned long long k, cycles = 0;
    cin >> n;
    cin >> k;
    vector<int> arr(n + 1);
    set<int> st;
    for (int i = 1; i <= n; i++)
        cin >> arr[i];
    int par = 1;
    int nxt = 0, i = 1, start;
    st.insert(1);
    while (1)
    {
        nxt = arr[i];
        if (st.find(nxt) != st.end())
        {
            start = i;
            break;
        }
        st.insert(nxt);
        cycles++;
        i = nxt;
    }
    i = start;
    par = arr[start];
    int cy2 = 1;
    while (1)
    {
        nxt = arr[i];
        if (arr[nxt] == par)
        {
            break;
        }
        cy2++;
        i = nxt;
    }
    if (k == 0)
        cout << 1 << endl;
    else if (k < cycles)
    {
        cycles = 0;
        i = 1;
        while (cycles < k)
        {
            nxt = arr[i];
            cycles++;
            i = nxt;
        }
        cout << i << endl;
    }
    else
    {

        k -= cycles;

        k %= cy2;
        i = start;

        cycles = 0;
        while (cycles < k)
        {
            nxt = arr[i];
            cycles++;
            i = nxt;
        }
        cout << i << endl;
    }
}


Measured memory_bytes: 13928