akhauriyash/Code-Regression huggingface dataset:
// Program Name: Minimum Spanning Tree
// Written by: by_sknight
// Date: 2019/4/27
#include <bits/stdc++.h>
using namespace std;
#define MAX 105
#define INFTY INT_MAX
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, G[MAX][MAX];

int prim() {
    int d[MAX], p[MAX], color[MAX];
    int u, minv;
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while (1) {
        u = -1;
        minv = INFTY;
        for (int i = 0; i < n; i++) {
            if (color[i] != BLACK && d[i] < minv) {
                minv = d[i];
                u = i;
            }
        }
        if (u == -1) 
            break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && G[u][v] < d[v]) {
                d[v] = G[u][v];
                p[v] = u;
                color[v] = GRAY;
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != -1) {
            sum += d[i];
        }
    }
    return sum;
}

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int k;
            cin >> k;
            G[i][j] = (k == -1 ? INFTY : k);
        }
    }

    int sum = prim();

    cout << sum << endl;
}


Measured memory_bytes: 3128
import java.math.BigDecimal;
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        BigDecimal a = sc.nextBigDecimal();
        BigDecimal b = sc.nextBigDecimal();
        System.out.println(a.multiply(b).toBigInteger());
    }
}

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

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

    int x, a, b;
    cin >> x >> a >> b;
    int d1 = abs(x - a);
    int d2 = abs(x - b);

    if(d1 < d2){
        cout << 'A' << endl;
    }else{
        cout << 'B' << endl;
    }

    return 0;
}

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

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

double dp[3010][3010];

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

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }

  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      dp[i + 1][j + 1] += dp[i][j] * v[i];
      dp[i + 1][j] += dp[i][j] * (1.0 - v[i]);
    }
  }

  double ans = 0;
  for (int i = n / 2 + 1; i <= n; i++) {
    ans += dp[n][i];
  }
  printf("%.15lf\n", ans);
}


Measured memory_bytes: 71040
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define pop(v) (v).back(); (v).pop_back()
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

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

    lint c[3][3];
    rep(i,3)rep(j,3)cin>>c[i][j];
    Yes(c[1][0]-c[0][0]==c[1][1]-c[0][1]&&c[1][1]-c[0][1]==c[1][2]-c[0][2]&&c[2][0]-c[1][0]==c[2][1]-c[1][1]&&c[2][1]-c[1][1]==c[2][2]-c[1][2]&&c[0][1]-c[0][0]==c[1][1]-c[1][0]&&c[1][1]-c[1][0]==c[2][1]-c[2][0]&&c[0][2]-c[0][1]==c[1][2]-c[1][1]&&c[1][2]-c[1][1]==c[2][2]-c[2][1]);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define PII pair<int,int>
#define ll long long
int N=INT_MAX;
ll INF=1e18L+5;
map<int ,int>my;
//vector<PII>v[1000005];

int main(){
    ll n,w;
    cin>>n>>w;
    vector<ll>weight(n),value(n);
    for(int i=0;i<n;i++){
        cin>>weight[i]>>value[i];
    }
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=value[i];
    }
    vector<ll>dp(sum+1,INF);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=sum-value[i];j>=0;j--){
            dp[j+value[i]]=min(dp[j+value[i]],dp[j]+weight[i]);
        }
    }
    ll ans=0;
    for(ll i=0;i<=sum;i++){
        if(dp[i]<=w){
            ans=max(ans,i);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define taskname "A"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 5000 + 5;
const int logn = log2(maxn) + 1;
const int inf = 1e9 + 1;
int L;
vector<pair<ii,int>> E;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP" , "r")){
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    cin >> L;--L;
    E.pb(mp(mp(0,19),L));
    for(int i = 0 ; i <= 18 ; ++i){
        E.pb(mp(mp(i,i+1),0));
    }
    for(int i = 0 ; (1 << (i + 1)) <= L ; ++i){
        E.pb(mp(mp(i,i+1),(1<<i)));
    }
    int pre = 0;
    for(int i = 19 ; i >= 0 ; --i){
        if(L & (1 << i)){
            if(pre)E.pb(mp(mp(i,19),pre));
            pre |= (1 << i);
//            cout << i << endl;
        }
    }
    cout << 20 << " " << E.size() << endl;
    for(auto c : E){
        cout << c.first.first + 1 << " " << c.first.second + 1 << " " << c.second << '\n';
    }
}


Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int N,M,n,m;
const int tmp=2333;
int main()
{
	cin>>N>>M>>n>>m;
	if(N%n!=0)
	{
		puts("Yes");
		for(int i=1;i<=N;i++)
		{
			for(int j=1;j<=M;j++)
			{
				if(i%n==0)puti(-tmp*(n-1)-1);
				else puti(tmp);
			}
			puts("");
		}
		return 0;
	}
	if(M%m!=0)
	{
		puts("Yes");
		for(int i=1;i<=N;i++)
		{
			for(int j=1;j<=M;j++)
			{
				if(j%m==0)puti(-tmp*(m-1)-1);
				else puti(tmp);
			}
			puts("");
		}
		return 0;
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;
public class Main {

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

		int H = sc.nextInt();
		int W = sc.nextInt();
		
		String[] str = new String[H];
		
		for(int j = 0; j < H; j++)
			{
				str[j] = sc.next();
			}
		
		
					
		for(int i = 0; i < H; i++)
		{
			System.out.println(str[i]);
			System.out.println(str[i]);
		}
			
	}

}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 10;
const int MOD = 1e9 + 7;

bool vis[N];
vector<int> gr[N];
int n , m;
int cnt;
void dfs(int node , int par){
	// cout << node << "\n";

	vis[node] = true;
	
	// for(int i = 1 ; i <= n ; ++i){
	// 	cout << vis[i] << " ";
	// }cout << "\n";
	
	int end = 1;
	for(int i = 1 ; i <= n ; ++i){
		if(!vis[i]){
			end = 0;
			break;
		}
	}

	if(end)
		cnt++;

	for(auto i : gr[node]){
		if(i == par)
			continue;

		if(!vis[i]){
			dfs(i,node);
		}
	}

	vis[node] = false;
}
int32_t main(){
    boost;
    
    //code
    int x,y;
    cin >> n >> m;

    for(int i = 0 ; i < m ; ++i){
    	cin >> x >> y;
    	gr[x].push_back(y);
    	gr[y].push_back(x);
    }

    dfs(1,0);

    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
while True:
    try:
        n, m = map(int, input().split(' '))
        pt = -1
        p_list = [i + 1 for i in range(n)]
        f_list = [0] * n
        while p_list.count(0) != n - 1:
            for i in range(m):
                if pt == n-1:
                    pt = 0
                else:
                    pt += 1
                while p_list[pt] == 0:
                    if pt == n-1:
                        pt = 0
                    else:
                        pt += 1
            p_list[pt] = 0
        print(sum(p_list))
    except:
        break

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
#define INF (1ll<<60)
typedef pair<li, li> PI;

li w[111];
li v[111];

li dp[111][100100];

int main(void)
{
	li n, ww;
	cin >> n >> ww;
	rep(i, n) {
		cin >> w[i] >> v[i];
	}

	rep(i, n) {
		for (li j = ww; j >= 0; j--) {
			dp[i + 1][j] = dp[i][j];
			if (j >= w[i]) {
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
			}
		}
	}

	li res = 0;
	for (li j = ww; j >= 0; j--) {
		res = max(res, dp[n][j]);
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 79360
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    vector<int> Time = {A, B, C, D, E};
    vector<int> NextTime(5);
    for (int i = 0; i < 5; i++){
        if (Time[i] % 10 == 0) NextTime[i] = Time[i];
        else NextTime[i] = Time[i] - Time[i] % 10 + 10;
    }
    
    int BestTime = 99999999;
    
    for (int i = 0; i < 5; i++){
        int SumTime = 0;
        for (int j = 0; j < 5; j++){
            if (i == j){
                SumTime += Time[j]; 
            }
            else{
                SumTime += NextTime[j];
            }
        }
        BestTime = min(BestTime, SumTime);
    }
    
    cout << BestTime << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n;  cin >> n;
  vi a(n);  rep(i,n) cin >> a[i];
  sort(all(a));
  int ans = 0, diff = 0;
  rep(i,n-1){
    if(chmax(diff,min(a[i],a.back()-a[i]))) ans = a[i];
  }
  cout << a.back() << " " << ans;
  cout << "\n";
  return 0;
}


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

int a[1010],p[1010];

int main(){
	int N,M,l,max=0,r;
	cin>>N>>M;
	for(int i=0;i<N;i++) cin>>a[i];
	for(int i=0;i<M;i++){
		cin>>l;
		for(int j=0;j<N;j++){
			if(a[j]<=l){
				p[j]++;
				break;
			}
		}
	}
	for(int i=0;i<N;i++){
		if(max<p[i]){
			max=p[i];
			r=i+1;
		}
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 3072
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var S = sc.next();
        var cnt = 0;
        var lst = new List<int>();
        foreach (var c in S.ToCharArray()) {
            if (c == 'A' || c == 'T' || c == 'C' || c == 'G') {
                cnt++;
            } else {
                cnt = 0;
            }
            lst.Add(cnt);
        }
        WriteLine(lst.Max());
    }
}


class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{

    ll H, W;
    cin >> H >> W;

    ll ans = H * W / 2LL;
    if ((H * W) % 2 == 1) ans++;
    if (H == 1 || W == 1) ans = 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, L;
    cin >> N >> L;

    vector<string>S(N);
    for(int i = 0; i < N; i++){
        cin >> S.at(i);
    }
    sort(S.begin(), S.end());
    for(int j = 0; j < N; j++){
        cout << S.at(j);
    }
    cout << endl;
}

Measured memory_bytes: 256
n = int(input())
ab = []
for _ in range(n):
    ab.append(list(map(int,input().split())))

cnt = 0
for i in range(n-1,-1,-1):
    a,b = ab[i][0],ab[i][1]
    num = a + cnt
    if num % b == 0:
        continue
    else:
        amari = num % b
        cnt += b-amari
    
print(cnt)

Measured memory_bytes: 27212
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

var used []bool

func dfs(v, n int, node [][]int) {
	used[v] = true
	for _, e := range node[v] {
		if used[e] {
			continue
		}
		dfs(e, n, node)
	}
}

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

	N, M := getInt(), getInt()
	node := make([][]int, N)
	for i := 0; i < M; i++ {
		x, y, _ := getInt()-1, getInt()-1, getInt()
		node[x] = append(node[x], y)
		node[y] = append(node[y], x)
	}

	used = make([]bool, N)
	ans := 0
	for i := 0; i < N; i++ {
		if used[i] {
			continue
		}
		ans++
		// out("i", i)
		dfs(i, i, node)
	}
	out(ans)
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

// TARO = 0 JIRO = 1

const int MAX_K=10e5+5,MAX_N=105;
int n,j,k,a[MAX_N];
bool b1,b2,dp[MAX_K][2];

int main(){
  cin >> n >> k;
  for(int i=0;i<n;++i){
    cin >> a[i];
  }
  for(int i=0;i<a[0];++i){
    dp[i][0]=1;
    dp[i][1]=0;
  }
  for(int i=a[0];i<=k;++i){
    j=0;b1=1;b2=0;
    while(j<n && a[j]<=i){
        if(dp[i-a[j]][1]==0){b1=0;}
        if(dp[i-a[j]][0]==1){b2=1;}
        ++j;
    }
    dp[i][0]=b1;dp[i][1]=b2;
  }
   if(!dp[k][0]){cout << "First";}
   else{cout << "Second";}
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,ans;
int main(){
	char s[20];
	scanf("%lld%s",&n,s);
	if(n>=3200)puts(s);
	else puts("red");
}

Measured memory_bytes: 128
#include <unistd.h>
#include <algorithm>
#include <functional>

char ibuf[4000000];
char *ibufe = ibuf-1;

void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

int read_uint(){
  int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');

  return x;
}

int n;
int S[1<<18];
int Q[19];

int main(){
  readall();
  n = read_uint();
  for(int i=0;i<(1<<n);i++) S[i] = read_uint();
  std::sort(S, S+(1<<n), std::greater<int>());
  int k = 0;
  for(int i=0;i<(1<<n);){
    int j = i;
    for(i++; S[i] == S[j]; i++) ;
    S[k++] = i-j;
  }
  Q[n] = 1;
  for(int i=0;i<k;i++){
    int l;
    int a=0;
    for(l=n;l>=0 && a < S[i];l--) a += Q[l];
    if(a<S[i]){
      write(STDOUT_FILENO, "No\n", 3);
      return 0;
    }
    l++;
    for(int t=0;t<l;t++) Q[t] += S[i];
    int b = a-Q[l];
    Q[l] = a-S[i]+b;
    for(n=l+1;b;n++){
      b -= Q[n];
      Q[n] = b;
    }
    n--;
  }
  write(STDOUT_FILENO, "Yes\n", 4);
  return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int father[55],n;

void init(int k)
{
    for(int i=1;i<=k;i++)
    {
        father[i]=i;
    }
}
int find_set(int x)
{
    if(father[x]==x) return x;
    else father[x]==find_set(father[x]);
}
void unit(int x,int y)
{
    x=find_set(x);
    y=find_set(y);
    if(x==y) return ;
    father[x]=y;
}
int main()
{
    int i,n,m,j;
    int x[55],y[55];
    while(cin>>n>>m)
    {
//        for(i=1;i<=n;i++)
//            cout<<father[i]<<endl;
        for(i=0;i<m;i++)
        {
            cin>>x[i]>>y[i];
        }
        int q=0;
        for(i=0;i<m;i++)
        {
            int count=0;
            init(n);
            for(j=0;j<m;j++)
            {
                if(i==j) continue;
                unit(x[j],y[j]);
            }
            for(int p=1;p<=n;p++)
            {
                //cout<<father[p]<<endl;
                if(father[p]==p) count++;
            }
            //cout<<"ha"<<endl;
            if(count==2) q++;
        }
        cout<<q<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma warning (disable:4996)
#include <stdio.h>

int input(int *n, int *x){
	scanf("%d %d", n, x);
	if ((*n + *x) == 0)return 0;
	else return 1;
}
int check(int *n, int *x){
	unsigned short int i, j, k, cnt = 0;
	for (i = 1; i <= *n; i++){
		for (j = 1; j <= *n; j++){
			if (i == j)break;
			for (k = 1; k <= *n; k++){
				if (j == k || i == k)break;
				if (i + j + k == *x)cnt++;
			}
		}
	}
	return cnt;
}
void output(int ans){
	printf("%d\n", ans);
}
int main(void){
	int n, x;
	while (1){
		if (input(&n, &x)){
			output(check(&n, &x));
		}
		else break;
	}
	return 0;
}

Measured memory_bytes: 600
fun main(args: Array<String>) = yorukatsu14e()

fun yorukatsu14e() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val edges = Array(n - 1) {
        readLine()!!.split(' ').map { it.toInt() - 1 }.let { Edge(it[0], it[1]) }
    }

    val graph = Array(n) { Vertex(it) }
    edges.forEach {
        val (from, to) = it
        graph[from].neighbor.add(to)
        graph[to].neighbor.add(from)
    }

    val visited = mutableSetOf(0)
    val biCoef = BiCoef(100010)
    var answer = k.toLong()

    fun dfs(currIndex: Int) {
        val neighbor = graph[currIndex].neighbor
        answer *= when (currIndex) {
            0 -> biCoef.nPr(k - 1, neighbor.size)
            else -> biCoef.nPr(k - 2, neighbor.size - 1)
        }
        answer %= MOD
        neighbor.filter { visited.add(it) }.map { dfs(it) }
    }

    dfs(0)

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

private data class Edge(val from: Int, val to: Int)
private data class Vertex(val index: Int, val neighbor: MutableSet<Int> = mutableSetOf())

@Suppress("unused")
private class BiCoef(max: Int) {
    private val fact = LongArray(max + 1)
    private val fInv = LongArray(max + 1)
    private val inv = LongArray(max + 1)

    init {
        fact[0] = 1
        fact[1] = 1
        fInv[0] = 1
        fInv[1] = 1
        inv[1] = 1
        for (i in 2..max) {
            fact[i] = fact[i - 1] * i % MOD
            inv[i] = MOD - inv[(MOD % i).toInt()] * (MOD / i) % MOD
            fInv[i] = fInv[i - 1] * inv[i] % MOD
        }
    }

    fun fact(n: Int): Long = if (n < 0) 0 else fact[n]
    fun inv(n: Int): Long = if (n < 0) 0 else inv[n]
    fun fInv(n: Int): Long = if (n < 0) 0 else fInv[n]
    fun comb(n: Int, k: Int): Long = nCr(n, k)
    fun nCr(n: Int, k: Int): Long = if (n < k || n < 0 || k < 0) 0 else fact[n] * (fInv[k] * fInv[n - k] % MOD) % MOD
    fun perm(n: Int, k: Int): Long = nPr(n, k)
    fun nPr(n: Int, k: Int): Long = if (n < k || n < 0 || k < 0) 0 else fact[n] * fInv[n - k] % MOD % MOD
}

private fun modPow(n: Long, p: Long): Long {
    var x = n
    var y = p
    var result = 1L
    x %= MOD
    while (y > 0) {
        if (y % 2 == 1L)
            result = (result * x) % MOD
        y = y shr 1
        x = (x * x) % MOD
    }
    return result
}


Measured memory_bytes: 132428
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

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

	ll cnt = 0;
	while (1) {
		if (a % 2 || b % 2 || c % 2) break;

		ll ta = a / 2, tb = b / 2, tc = c / 2;
		a = tb + tc;
		b = tc + ta;
		c = ta + tb;
		cnt++;

		if (cnt >= 10000000) break;
	}

	if (cnt >= 10000000) cout << -1 << endl;
	else cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int N;
  cin >> N;
  while(N--) {
    int n;
    cin >> n;
    char ba[2][2*n+2];
    memset(ba, 'N', sizeof(ba));
    REP(i,2*n)
      cin >> ba[0][i+1];
    REP(i,2*n)
      cin >> ba[1][i+1];
    int dp[3] = {0,1,2};
    for(int i=0; i<2*n+2; i+=2) {
      int a[3];
      if ((ba[0][i]=='Y'||ba[0][i+1]=='Y') && (ba[1][i] == 'Y'||ba[1][i+1]=='Y')) {
        a[0] = min(min(dp[0]+4, dp[1]+3), dp[2]+3);
        a[1] = min(min(dp[0]+3, dp[1]+3), dp[2]+3);
        a[2] = min(min(dp[0]+3, dp[1]+3), dp[2]+4);
      } else if ((ba[0][i] == 'Y'||ba[0][i+1]=='Y') && (ba[1][i] == 'N'&&ba[1][i+1]=='N')) {
        a[0] = min(min(dp[0]+2, dp[1]+2), dp[2]+3);
        a[1] = min(min(dp[0]+2, dp[1]+2), dp[2]+3);
        a[2] = min(min(dp[0]+3, dp[1]+3), dp[2]+4);
      } else if ((ba[0][i] == 'N'&&ba[0][i+1]=='N') && (ba[1][i] == 'Y'||ba[1][i+1]=='Y')) {
        a[0] = min(min(dp[0]+4, dp[1]+3), dp[2]+3);
        a[1] = min(min(dp[0]+3, dp[1]+2), dp[2]+2);
        a[2] = min(min(dp[0]+3, dp[1]+2), dp[2]+2);
      } else if ((ba[0][i] == 'N'&&ba[0][i+1]=='N') && (ba[1][i] == 'N'&&ba[1][i+1]=='N')) {
        a[0] = min(min(dp[0]+1, dp[1]+2), dp[2]+3);
        a[1] = min(min(dp[0]+2, dp[1]+1), dp[2]+2);
        a[2] = min(min(dp[0]+3, dp[1]+2), dp[2]+1);
      }
       REP(j,3) {
         dp[j] = a[j];
      //   cout << dp[j] << " ";
       }
      // cout << endl;
    }
    cout << dp[0]-1 << endl;
  }
}

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

int main()
{
  char str[10],x[5],y[5];
  int a,b,i=0,j=0;
  
    fgets(str,sizeof(str),stdin);
    
    for(;;){
      if(str[i]==' '){
	break;
      }
      x[i]=str[i];
      i++;
    }
    
    for(;;){
      if(str[i]=='\0'){
	break;
      }
      y[j]=str[i];
      i++;
      j++;
    }

    a=atoi(x);
    b=atoi(y);

    if(a<-1000 || 1000<b){
      printf("Error!!\n");
    }else{
      if(a<b){
	printf("a < b\n");
      }else if(a>b){
	printf("a > b\n");
      }else{
	printf("a == b\n");
      }
    }
    return 0;
}

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

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n"
#define show(a,b) cout<<(#a)<<" is "<<(a)<<" "<<(#b)<<" is "<<(b)<<"\n"
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(n) for(auto i=0;i<n;i++) 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<pi,pi> ppi;

void solve()
{
    string a,b;
    getline(cin,a);
    getline(cin,b);
    int n1=a.length(),n2=b.length();
    int lcs[n1+1][n2+1];
    //show(n1,n2);
    for(int i=0;i<=n1;i++)
    for(int j=0;j<=n2;j++)
    lcs[i][j]=INT_MIN;
    
    for(int i=0;i<=n1;i++)
    {
        for(int j=0;j<=n2;j++)
        {
            if(i==0 || j==0)
            lcs[i][j]=0;
            else
            {
                if(a[i-1]==b[j-1])
                lcs[i][j]=1+lcs[i-1][j-1];
                else
                lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
            }
        }
    }
    
    int count=0,i=n1,j=n2;
    stack<char>ans;
    int len=lcs[n1][n2];
    //watch(len);
    while(count<len)
    {
        //watch(count);
        if(lcs[i][j]==lcs[i-1][j])
        {
            i--;
        }
        else if(lcs[i][j]==lcs[i][j-1])
        {
            j--;
        }
        else if(lcs[i][j]==1+lcs[i-1][j-1])
        {
            count++;
            ans.push(b[j-1]);
            i--;j--;
        }
    }
    while(!ans.empty())
    {
        cout<<ans.top();
        ans.pop();
    }
    cout<<"\n";
}

int main()
{
    fast;
    solve();
    return 0;
}

Measured memory_bytes: 35456
def resolve():
    S = input()
    T = input()
    ans = len(T)
    for i in range(len(S)- len(T) + 1):
        count = S[i:i+len(T)]
        no = 0
        for j in range(len(count)):
            if count[j] != T[j]:
                no += 1
        if ans > no:
            ans = no
    print(ans)
resolve()

Measured memory_bytes: 9116
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

print(-(-a//10*10)-(-b//10*10)-(-c//10*10)-(-d//10*10)-(-e//10*10)-max((10-a)%10,(10-b)%10,(10-c)%10,(10-d)%10,(10-e)%10))

Measured memory_bytes: 3316
import sys

sys.setrecursionlimit(10 ** 5 * 2)
N, M = map(int, input().split())
Ps = [[] for _ in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    Ps[x - 1].append(y - 1)

mem = [-1] * N


def rec(n):
    if mem[n] > -1:
        return mem[n]
    elif len(Ps[n]) == 0:
        mem[n] = 0
        return mem[n]
    else:
        mem[n] = max([rec(Ps[n][i]) for i in range(len(Ps[n]))]) + 1
        return mem[n]


for i in range(N):
    rec(i)
print(max(mem))

Measured memory_bytes: 143904
#include<algorithm>
#include<stack>
#include<ctime>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<queue>
using namespace std;
typedef int _int;
#define int long long 
inline int read(){
	int num=0,f=1;char x=getchar();
	while(x<'0'||x>'9'){if(x=='-')f=-1;x=getchar();}
	while(x>='0'&&x<='9'){num=num*10+x-'0';x=getchar();}
	return num*f;
}
const int maxn=200005;
int n,k,MAX;
int A[maxn];
bool check(int x){
	int cnt=0;
	for(int i=1;i<=n;++i){
		cnt+=ceil(1.0*A[i]/x)-1;
	}
	return cnt<=k;
}
_int main(){
	n=read();k=read();
	for(int i=1;i<=n;++i){
		A[i]=read();
		MAX=max(MAX,A[i]);
	}
	int L=1,R=1e9;
	while(L<R){
		int mid=(L+R)>>1;
		if(check(mid))R=mid;
		else L=mid+1;
	}
	printf("%lld\n",L);
	return 0;
}


Measured memory_bytes: 5260
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}


int main()
{
	ll H, W, A, B;
	//std::string S;
	cin >> H >> W >> A >> B;

	for (ll i = 0; i < B; i++) {
		for (ll j = 0; j < A; j++) {
			cout << '1';
		}
		for (ll j = A; j < W; j++) {
			cout << '0';
		}
		cout << '\n';
	}

	for (ll i = B; i < H; i++) {
		for (ll j = 0; j < A; j++) {
			cout << '0';
		}
		for (ll j = A; j < W; j++) {
			cout << '1';
		}
		cout << '\n';
	}

	return 0;
}



Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(q => long.Parse(q)).ToArray();


            string result = "safe";

            if(inputLongArray[0] <= inputLongArray[1]) {
                result = "unsafe";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28224
var std = process.stdin;
std.resume();
std.setEncoding('utf8');

std.on('data', function(chunk){
    var data = chunk.split(/\n/g);

    for (var i = 0; i < data.length; i++){
        var
            line = data[i].replace(/\n/, '').split(' ').map(Number),
            h = line[0],
            w = line[1];
        
        if(h === 0 && w === 0) {break;}
        draw(h, w);
        console.log();  //??????
    }
});

var draw = function(h, w) {
    for (var i = 0; i < h; i++) {
        var line = '';
        for (var j = 0; j < w; j++) {
            line += '#';
        }
        console.log(line);
    }  
};

Measured memory_bytes: 18148
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define vi vector < int >
#define pii pair < int, int >
 
const int K = 1e5 + 7;
const int N = 107;
const int mod = 1e9 + 7;
 
int a[N], pr[N][K + 1], ar[N][K + 1];
int n, k;
 
main (){
    fill(pr[0], pr[0] + K + 1, 1);
    scanf("%lld%lld", &n, &k);
    for (int i = 1; i <= n; i++){
        scanf("%lld", &a[i]);
        for (int j = K; j >= 0; j--){
            ar[i][j] = pr[i - 1][j];
            if (j - a[i] - 1 >= 0){
                ar[i][j] -= pr[i - 1][j - a[i] - 1];
                ar[i][j] = (ar[i][j] + mod) % mod ;
            }
        }
        pr[i][0] = ar[i][0];
        for (int j = 1; j <= K; j++){
            pr[i][j] = pr[i][j - 1] + ar[i][j];
            pr[i][j] %= mod;
        }
    }
    cout << ar[n][k];
}

Measured memory_bytes: 161280
#include <stdio.h>
int main(void) {

	int h, w;
	int i, j;

	while (1)
	{
		scanf("%d %d", &h, &w);

		if (h == 0 && w == 0)
		{
			break;
		}

		for (j = 0; j < w; j++)
		{
			printf("#");
		}

		printf("\n");
		for (i = 0; i < h-2; i++)
		{
			for (j = 0;j < w;j++)
			{
				printf("#");

				for (j = 1;j < w - 1;j++)
				{
					printf(".");
				}

				printf("#\n");
			}

		}

		for (j = 0; j<w; j++)
		{
			printf("#");
		}

		printf("\n\n");
	}

	return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int main() {
  int64_t N, K, R, S, P;
  string T;
  
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;

  vector<char> v (N);
  int64_t score = 0;
  REP(i,N){
    if(i >= K && i < N-K){
      if(T[i] == 'r'){
        if(v[i-K] == 'p'){
          if(T[i+K] == 'p' ){
            v[i] = 'r';
          }else{
            v[i] = 's';
          }
        }else{
          v[i] = 'p';
          score += P;
        }
      }else if(T[i] == 's'){
        if(v[i-K] == 'r'){
          if(T[i+K] == 'r' ){
            v[i] = 's';
          }else{
            v[i] = 'p';
          }
        }else{
          v[i] = 'r';
          score += R;
        }
      }else{
        if(v[i-K] == 's'){
          if(T[i+K] == 'r' ){
            v[i] = 'r';
          }else{
            v[i] = 'p';
          }
        }else{
          v[i] = 's';
          score += S;
        }
      }
    }else if (i < K)   
    {
      if(T[i] == 'r'){
        v[i] = 'p';
        score += P;
      }else if(T[i] == 's'){
        v[i] = 'r';
        score += R;
      }else{
         v[i] = 's';
        score += S;
      }
    }else{
      if(T[i] == 'r'){
        if(v[i-K] != 'p'){
          v[i] = 'p';
          score += P;
        }
        
      }else if(T[i] == 's'){
        if(v[i-K] != 'r'){
          v[i] = 'r';
          score += R;
        }
      }else{
        if(v[i-K] != 's'){
          v[i] = 's';
          score += S;
        }
      }
    }
    
    
  }
  cout << score << endl;



}

Measured memory_bytes: 512
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};


int main(){
  ll N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  ll P = B - A;
  bool l = 0;
  ll sa = D - C;
  for(int p = 0; p < N; p++){
    int m = N - 1 - p;
    ll res = 0;
    res += p * C;
    res -= m * D;
    if(res <= P && P <= res + sa * (N-1)) l = 1;
  }
  if(l) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

n, k = wi()
if k == 1:
    print(0)
elif n - k == 0:
    print(0)
elif n - k < 0:
    print(1)
else:
    print(n - k)

Measured memory_bytes: 6476
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MOD=1000000007;
const int nmax=3123;
int n;
ll dp[nmax],res,tmp,tmp2;
char s[nmax];
int main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    dp[1]=1;
    for(int i=2; i<=n; ++i){
        if(s[i-1]=='<'){
            tmp=0;
            for(int j=1; j<=i; ++j){
                tmp2=dp[j];
                dp[j]=(dp[j-1]+tmp)%MOD;
                tmp=tmp2;
            }
        }
        else
            for(int j=i-2; j>0; --j)dp[j]=(dp[j]+dp[j+1])%MOD;
    }
    for(int i=1; i<=n; ++i)res+=dp[i];
    res%=MOD;
    printf("%lld",res);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000000
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef long long ll;

int main() {
  int R, G;
  cin >> R >> G;
  cout << 2 * G - R << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long
using namespace std;
int main()
{
	int l,n;
	cin>>l>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n-1;i++){
		b[i]=a[i+1]-a[i];
	}
	b[n-1]=l-(a[n-1]-a[0]);
	sort(b,b+n);
	cout<<l-b[n-1];
	return 0;
}

Measured memory_bytes: 1792
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<Integer,Integer> map = new HashMap<Integer,Integer>();
		for(int i = 0;i < N; i++) {
			Integer a = sc.nextInt();
			add(map,a);
		}
		System.out.println(map.size());
	}
	static void add(Map<Integer,Integer> map, Integer want) {
		if(map.containsKey(want)) {
			map.remove(want);
		} else {
			map.put(want, 1);
		}
	}
}

Measured memory_bytes: 59940
N,A,B = [int(i) for i in input().split()]

v = [int(i) for i in input().split()]
v.sort(reverse=True)

max_average = sum(v[:A]) / A

C = [[0]*51 for i in range(51)]
for i in range(N+1):
    for j in range(i+1):
        if j == 0 or i == 0:
            C[i][j] = 1
        else:
            C[i][j] = C[i-1][j-1] + C[i-1][j]

ans = 0
cnt = 0
if v[0] == v[A-1]:
    for i in range(N):
        if v[i] == v[0]:
            cnt += 1
    for i in range(A, B+1):
        ans += C[cnt][i]
else:
    included = 0
    for i in range(N):
        if v[i] == v[A-1]:
            cnt += 1
            if i < A:
                included += 1
    ans += C[cnt][included]

print(max_average)
print(ans)

Measured memory_bytes: 3188
N=int(input())
Ai=list(map(int,input().split()))

# ans=[]
ans=[0]*N

# for i in range(1,N+1):
    # a=Ai.index(i)+1
    # ans.append(str(a))
for i in range (N):
    ans[Ai[i]-1]=str(i+1)

print(' '.join(ans))


Measured memory_bytes: 20836
#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	#define PI 				acos(-1)
	#define mp				make_pair
	#define pb				push_back
	#define all(a)			(a).begin(), (a).end()
	#define srt(a)			sort(all(a))
	#define mem(a, h)		memset(a, (h), sizeof(a))
	#define f 				first
	#define s 				second
	#define MOD				1000000007
	#define MOD1			998244353
	#define EPS				1e-9
	#define fore(i, b, e)	for(int i = b; i < e; i++)
	#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
	int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

	using namespace std;
	using namespace __gnu_pbds;

	typedef long long 		ll;
	typedef unsigned long long 		ull;
	typedef pair<int, int>  ii;
	typedef vector<int>     vi;
	typedef vector<ii>      vii;
	typedef vector<ll>      vll;
	typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
	const int tam = 100010;
	ll dp[100][200000];
	int can[100], mul[100];
	int n, nus;
	vector<int> pri, pric;
	bitset<100000> bi;
	void criba()
	{
		bi.set();
		fore(i, 2, 100000)
		{
			if(bi[i])
			{
				forg(j, i+i, 100000, i)
					bi[j] = 0;
				pri.pb(i);
				pric.pb(i * i);
			}
		}
	}
	void fac(int ax)
	{
		int i  = 0, pos = 0;
		mem(can, 0);
		while(pric[i] <= ax)
		{
			if(ax % pri[i] == 0)
			{
				while(ax % pri[i] == 0)
				{
					ax /= pri[i];
					can[pos]++;
				}
				pos++;
			}
			i++;
		}
		if(ax > 1)
		{
			can[pos]++;
			pos++;
		}
		nus = pos;
	}
	ll f(int a, int b)
	{
		if(a == 1) return b;
		if(b == 0) return 0;
		if(b % 100 == 0)
			cout<<a<<' '<<b<<'\n';
		if(dp[a][b] != -1) return dp[a][b];
		return dp[a][b] = (f(a - 1, b) + f(a, b-1))%MOD;
	}
	int main()
	{
		//ios::sync_with_stdio(0); cin.tie(0);
		//freopen("qwe.txt", "r", stdin);
		//freopen("asd.txt", "w", stdout);
		int m;
		cin>>n>>m;
		criba();
		fac(m);
		ll res = 1;
		mem(dp, -1);
		fore(i, 0, n+1)
			dp[1][i] = i;
		fore(i, 0, 100)
			dp[i][0] = 0;
		fore(i, 2, 100)
		{
			fore(j, 1, n+1)
				dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
		}
		fore(i, 0, nus)
		{
			//cout<<can[i]<<' ';cout<<f(can[i], n)<<'\n';
			res = (res * dp[can[i]][n]) % MOD;
		}
		//cout<<'\n';
		cout<<res<<'\n';
		return 0;
	}

	// read the question correctly (is y a vowel? what are the exact constraints?)
	// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 156672
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF (ll)(1e17+5)
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       string s;
       cin>>s;
       if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes\n";
       else
        cout<<"No\n"; 
   }
}

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

int main(){
  string s,t[4]={"dream","dreamer","erase","eraser"};cin>>s;
  bool f;
  
  while(s.size()){
    f=0;
    REP(i,4) if(!(s.find(t[i]))){
      string ss=s.substr(t[i].size());
      if(!ss.size()) f=1;
      else REP(k,4) if(!(ss.find(t[k]))) f=1;
      if(f){
        s=ss;
        break;
      }
    }
    if(!f) break;
  }
  
  cout<<(f?"YES":"NO");
}

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

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

if (c=='a') {
cout  << "vowel" << endl;}
else if (c=='i') {
cout  << "vowel" << endl;}
else if (c=='u') {
cout  << "vowel" << endl;}
else if (c=='e') {
cout  << "vowel" << endl;}
else if (c=='o') {
cout  << "vowel" << endl;}
else {
cout << "consonant" << endl;
}

}



Measured memory_bytes: 256