akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb push_back;
#define sp " ";
void vout(vector<int> v){
    for(unsigned int i=1;i<v.size();i++)
    cout<<v.at(i)+1<<endl;
}
int main(){
    int n,m;
    cin>>n>>m;
    vvi edge(n);
    vi ans(n,-1);
    rep(i,m){
        int s,t;
        cin>>s>>t;
        s--;
        t--;
        edge.at(s).push_back(t);
        edge.at(t).push_back(s);
    }
    queue<int> q;
    q.push(0);
    while(!q.empty()){
       int k=q.front();
       q.pop();
       for(int j:edge.at(k)){
           if(ans.at(j)==-1){
               ans.at(j)=k;
               q.push(j);
           }
       }
    }
  cout<<"Yes"<<endl;
    vout(ans);
}

Measured memory_bytes: 13616
#include <algorithm>
#include <iostream>

using namespace std;

constexpr static int MAXN = 1e6;
constexpr static int MOD = 1e9 + 7;

int main() {
    int n, p;
    cin >> n >> p;
    int c0 = 0, c1 = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 0)
            c0++;
        else
            c1++;
    }

    int64_t r = 1;
    if (p == 0) {
        // 2^c0
        r *= (1LL << c0);
        // 2^{c1-1}
        if (c1 > 0)
            r *= (1LL << (c1 - 1));
    }
    else {
        if (c1 == 0) {
            r = 0;
        }
        else {
            r *= (1LL << c0);
            r *= (1LL << (c1 - 1));
        }
    }
    cout << r << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N; cin>>N;
  vector<ll> A(N,0), O(N+1,0), DP(N+1,-1e15);
  for(int i=0; i<N; i++){
    ll a; cin>>a; A[i]=a;
    if(i%2==0) O[i+1]=a;
    if(i<=2) DP[i+1]=max(DP[i],a);
    //DP[4]、2個とる。DP[2]+aかO[1]+O[3]
    //DP[5]、2個とる。DP[4]かDP[3]+a
    //DP[6]、3個とる。DP[4]+aかO[1]+O[3]+O[5](aを使わないとなると奇数番目をとるだけ）
    //DP[7]、3個とる。DP[6]かDP[5]+a
  }
  //奇数累積和
  for(int i=1; i<=N; i++) O[i]=O[i-1]+O[i];
  //DPつくる
  for(int i=4; i<=N; i++){
    if(i%2==0) DP[i]=max(DP[i-2]+A[i-1], O[i-1]);
    else DP[i]=max(DP[i-1],DP[i-2]+A[i-1]);
  }
  cout<<DP[N]<<endl;
}


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

int main(){
  string s;
  cin >> s;
  bool flagym=true;
  bool flagmy=true;
  if(stoi(s.substr(0,2))>12){
    flagmy=false;
  }
  if(stoi(s.substr(2,2))>12){
    flagym=false;
  }
  if(s.substr(0,2)=="00"){
    flagmy=false;
  }
  if(s.substr(2,2)=="00"){
    flagym=false;
  }
  if(flagmy&&flagym){
    cout << "AMBIGUOUS" << endl;
  }else if(flagmy){
    cout << "MMYY" << endl;
  }else if(flagym){
    cout << "YYMM" << endl;
  }else{
    cout << "NA" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

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

    vector<ll> dp(n+1,0);
    dp[0] = 1;
    if(a[1]==1){
        dp[1]=0;
    }else{
        dp[1]=1;
    }
    for(int i = 2; i <= n; i++){
        if(a[i] == 1){
            dp[i] = 0;
        }else{
            dp[i] = dp[i-1] + dp[i-2];
            dp[i]%=MOD;
        }
    }

    cout << dp[n]%MOD << endl;

    return 0;
}


Measured memory_bytes: 1792
// C - String Transformation
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S, T; cin>>S>>T;
	vector<int> st(26, -1), ts(26, -1);//st:S->T, ts:T->S
	int i;
	for(i=0; i<S.size(); ++i){
		int s = S[i]-'a', t = T[i]-'a';
		if(st[s] != ts[t]) break;
		st[s] = ts[t] = s;//s as common code
	}
	puts(i==S.size()? "Yes":"No");
}

Measured memory_bytes: 776
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    vector<double> dp(1, 1.0);
    for(int i=0; i<n; ++i){
        double p;
        cin >> p;
        vector<double> nextDp(2+i, 0.0);
        for(int j=0; j<=i; ++j){
            nextDp[j+1] += dp[j] * p;
            nextDp[j] += dp[j] * (1.0 - p);
        }
        dp = move(nextDp);
    }

    double ans = accumulate(dp.begin() + (n + 1) / 2, dp.end(), 0.0);
    printf("%.10f\n", ans);

    return 0;
}


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

#define tetra(N) N*(N+1)*(N+2)/6
#define isEven(N) N%2==0
#define N_MAX 1000000

int main(int argc, char* argv[]){
	int *min=malloc((N_MAX+1)*sizeof(int)), *minOdd=malloc((N_MAX+1)*sizeof(int)), i, n;
	
	/* initialize */
	for(i=1; i<=N_MAX; i++) min[i]=-1, minOdd[i]=-1;
	
	/* problem 1 */
	for(i=1; tetra(i)<=N_MAX; i++) min[tetra(i)]=1;
	for(i=1; i<=N_MAX; i++){
		int j, minLocal=N_MAX;
		if(min[i]!=-1) continue;
		for(j=1; i-tetra(j)>0; j++)
			if(min[i-tetra(j)]!=-1 && min[i-tetra(j)]+1<minLocal) minLocal=min[i-tetra(j)]+1;
		if(minLocal!=N_MAX) min[i]=minLocal;
	}
	
	/* problem 2 */
	for(i=1; tetra(i)<=N_MAX; i++){
		if(isEven(tetra(i))) continue;
		minOdd[tetra(i)]=1;
	}
	for(i=1; i<=N_MAX; i++){
		int j, minLocal=N_MAX;
		if(minOdd[i]!=-1) continue;
		for(j=1; i-tetra(j)>0; j++){
			if(isEven(tetra(j))) continue;
			if(minOdd[i-tetra(j)]!=-1 && minOdd[i-tetra(j)]+1<minLocal) minLocal=minOdd[i-tetra(j)]+1;
		}
		if(minLocal!=N_MAX) minOdd[i]=minLocal;
	}
	
	while(scanf("%d",&n), n!=0) printf("%d %d\n",min[n],minOdd[n]);
	
	free(min), free(minOdd);
}
	
	

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

int main(){
   char x,y;cin>>x>>y;
   if(x>y){
      cout << ">";
   }else if(x<y){
      cout << "<";
   }else{
      cout << "=";
   }
   return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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;}

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

    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll> >vp;
    rep(i, 0, N) {
        ll a, b;
        cin >> a >> b;
        vp.push_back(make_pair(a, b));
    }
    vsort(vp);

    ll rsl = 0;
    rep(i, 0, N) {
        ll a = vp[i].first, b = vp[i].second;
        rsl += a * min(M, b);
        if(M <= b) break;
        M -= b;
    }
    cout << rsl << endl;
}


Measured memory_bytes: 2420
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_CHAR_MAX		200005									// 最大文字数

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Str[D_CHAR_MAX];									// 文字列
static int siSLen;												// 文字列長
static int si2DCnt[D_CHAR_MAX][2];								// 分割数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 改行カット
// 戻り値：文字数
int
fCutCrLf(
	char *pcpStr				// <I> 文字列
)
{
	int i;

	for (i = 0; pcpStr[i] != '\0'; i++) {
		if (pcpStr[i] == '\n') {
			pcpStr[i] = '\0';
			break;
		}
	}

	return i;
}

// 最大値 - 取得
int
fGetMax(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	if (piVal1 > piVal2) {
		return piVal1;
	}
	else {
		return piVal2;
	}
}

// 実行メイン
int
fMain(
)
{
	int i;

	// 文字列 - 取得
	fgets(sc1Str, sizeof(sc1Str), szpFpI);
	siSLen = fCutCrLf(sc1Str);

	// 分割数 - セット
	for (i = 0; i < siSLen; i++) {

		// １文字＋１文字
		if (i == 0) {
			si2DCnt[i][0] = 1;
		}
		else if (sc1Str[i] != sc1Str[i - 1]) {
			si2DCnt[i][0] = fGetMax(si2DCnt[i][0], si2DCnt[i - 1][0] + 1);
		}

		// １文字＋２文字
		if (i < siSLen - 1) {
			if (i == 0) {
				si2DCnt[i + 1][1] = 1;
			}
			else {
				si2DCnt[i + 1][1] = fGetMax(si2DCnt[i + 1][1], si2DCnt[i - 1][0] + 1);
			}
		}

		// ２文字＋１文字
		if (i > 1) {
			si2DCnt[i][0] = fGetMax(si2DCnt[i][0], si2DCnt[i - 1][1] + 1);
		}
	}

	// 最大値 - 取得
	if (si2DCnt[siSLen - 1][0] > si2DCnt[siSLen - 1][1]) {
		return si2DCnt[siSLen - 1][0];
	}
	else {
		return si2DCnt[siSLen - 1][1];
	}
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si2DCnt, 0, sizeof(si2DCnt));						// 分割数

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOut(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			if(n == 0)break;
			int a[] = new int [10];
			for(int i = 0;i < n;i++){
				int num = in.nextInt();
				a[num]++;
			}
			for(int i = 0;i < 10;i++){
				if(a[i] == 0){
					System.out.println("-");
				}else{
					for(int j = 0;j < a[i];j++){
						System.out.print("*");
					}
					System.out.println();
				}
			}
		}
	}
}

Measured memory_bytes: 54012
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <stack>
#include <vector>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <set>
#include <limits>
#include <numeric>
#include <array>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int wMax;
	cin >> wMax;
	vector<vector<long long>> dp(n + 1, vector<long long>(wMax + 1, 0));
	vector<int> weights(n);
	vector<int> values(n);
	long long res = 0;

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

	for (int i = 1; i < dp.size(); ++i)
	{
		for (int j = 0; j < dp.front().size(); ++j)
		{
			dp[i][j] = dp[i - 1][j];
			if (j - weights[i - 1] >= 0)
			{
				dp[i][j] = max(dp[i][j], values[i - 1] + dp[i - 1][j - weights[i - 1]]);
			}
			res = max(res, dp[i][j]);
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 80256
n,t= map(int, input().split())
a= list(map(int, input().split()))

# dp[i][0]:０からiまでの区間に置けるMIN
# dp[i][1]:その区間での左から右への差の最大値
# dp[i][2]:最大値をとるものがいくつあるか
dp=[[float('inf'),0,0] for i in range(n)]

for i in range(n):
    if i==0:
        dp[i][0]=a[i]
    else:
        dp[i][0]=min(dp[i-1][0],a[i])
        if dp[i-1][1]<a[i]-dp[i-1][0]:
            dp[i][1]=a[i]-dp[i-1][0]
            dp[i][2]=1
        elif dp[i-1][1]==a[i]-dp[i-1][0]:
            dp[i][1]=dp[i-1][1]
            dp[i][2]=dp[i-1][2]+1
        else:
            dp[i][1]=dp[i-1][1]
            dp[i][2]=dp[i-1][2]


print(dp[-1][2])

Measured memory_bytes: 72084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<(x)<<endl
const int maxn=(int)1e6+5;
typedef long long ll;
const ll mod=(ll)1e9+7;
ll a[maxn];
bool b[maxn];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;

    rep(i,1,n)cin>>a[i];
    int t=60;
    ll b=1;
    ll ans=0;

    while(t--){
        ll zero=0,one=0;
        rep(i,1,n){
            if(a[i]&1)one++;else zero++;
            a[i]>>=1;
        }
        ans+=one*zero%mod*(b%mod)%mod;
        ans%=mod;
        b<<=1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
import numpy as np

W, H, N = map(int, input().split())
xlist = np.zeros(N,dtype=int)
ylist = np.zeros(N,dtype=int)
alist = np.zeros(N,dtype=int)
for i in range(N):
    xlist[i], ylist[i], alist[i] = map(int, input().split())
rectangular = np.zeros((H, W))
for i in range(N):
    if alist[i] == 1:
        rectangular[:,:xlist[i]] = 1
    if alist[i] == 2:
        rectangular[:,xlist[i]:] = 1
    if alist[i] == 3:
        rectangular[:ylist[i],:] = 1
    if alist[i] == 4:
        rectangular[ylist[i]:,:] = 1
print(sum(sum(rectangular < 1)))


Measured memory_bytes: 12508
N = int(input())
A = []
B = []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
A = list(reversed(A))
B = list(reversed(B))

ans = 0
for i in range(N):
  d, m = divmod(A[i] + ans, B[i])
  if m > 0:
    add = B[i] - m
    ans += add

print(ans)

Measured memory_bytes: 11840
#include <bits/stdc++.h>
using namespace std;
int a[111];
int n;

int main(int argc, char const *argv[])
{
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool last = false;
	int ans = 0;
	for(int i = 1; i < n; i++) {
		if(last) {
			last = false;
		} else {
			if(a[i - 1] == a[i]) {
				++ans;
				last = true;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

int n;
int a[200010],idx[200010];

int main(){
  cin>>n;
  rep(i,n){
    cin>>a[i];
    idx[a[i]-1]=i;
  }
  idx[n]=n;

  int pre=INF,sub=0,sum=0;
  rep(i,n){
    if(pre<idx[i])sum++;
    else sum=1;
    pre=idx[i];
    maxch(sub,sum);
  }

  cout<<n-sub<<endl;
  return 0;
}


Measured memory_bytes: 1792
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()

print(s.replace(',', ' '))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int i,c,a[7];
	int b[7];
	for(i=1;i<=7;i++){
		scanf("%d",&a[i]);
		scanf("%d",&b[i]);
	}
	for(i=1;i<=7;i++){
		printf("%d\n",a[i]-b[i]);
	}
	return 0;
}


Measured memory_bytes: 2760
#include <stdio.h>

int main(void) {
	int i, num;
	int a[50];

	scanf("%d", &num);
	a[0] = 1;
	a[1] = 1;

	for (i = 2; i <= num; i++) {
		a[i] = a[i - 1] + a[i - 2];
	}

	printf("%d\n", a[num]);	 

	return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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



void Main(){
    int n;
    cin >> n;
    VI av(n);
    VI bv(n);
    REP(i, n) cin >> av[i] >> bv[i];
    SORT(av); SORT(bv);
    int min_a, min_b, ans;
    if (n % 2 == 1) {
        min_a = av[n/2];
        min_b = bv[n/2];
        ans = min_b - min_a + 1;
    } else {
        min_a = av[n/2-1] + av[n/2];
        min_b = bv[n/2-1] + bv[n/2];
        ans = min_b - min_a + 1;
    }
    cout << ans << en; 
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 4768
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var prices = new int[3];
        for(var i = 0; i < 3; i++)
        {
            prices[i]= Convert.ToInt32(input[i]);
        }
        
        var max = Math.Max(prices[0], prices[1]);
        max = Math.Max(max, prices[2]);
        var result = 0;
        var isSame = false;
        for (var i = 0; i < 3; i++)
        {
            if (prices[i] == max && !isSame)
            {
                isSame = true; continue;
            }
            result+=prices[i];
        }
        Console.WriteLine(result);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()

bool checker(vector<vector<int>> t, int x, int y){
  x++;
  y++;
  if(t.at(x+1).at(y) == 1 || t.at(x-1).at(y) == 1 || t.at(x).at(y+1) == 1 || t.at(x).at(y-1) == 1){
    return true;
  }
  return false;
}

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  vector<vector<int>> t(H+2, vector<int>(W+2, 0));
  for(int i = 0; i < H; i++){
    cin >> s.at(i);
  }
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(s.at(i).at(j) == '#') t.at(i+1).at(j+1) = 1;
    }
  }
  bool flag = true;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(s.at(i).at(j) == '#' && !checker(t, i, j)) flag = false;
    }
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;



}

Measured memory_bytes: 256
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

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

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

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...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  int n,k,q; cin >> n >> k >> q;
  vi v(q); 
  input(v);
  vi win(n,0);
  for(auto x : v) win[x-1] += 1;
  forall(i,0,n){
    if( k-q+win[i] <= 0 ){
      cout << "No\n";
    }else{
      cout << "Yes\n";
    }
  }
  return 0;
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

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

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll a, b, c, d; cin >> a >> b >> c >> d;

    cout << max(max(max(a*c, a*d), b*c), b*d) << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int n,count=2;

int fibonacch(int f1, int f2){
    int f=f1+f2;
    if(count++==n) return f;
    else return fibonacch(f2, f);
}

int main(){
    scanf("%d",&n);
    if(!n || n==1) printf("1\n");
    else printf("%d\n",fibonacch(1, 1));
    return 0;
}




Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define FIO "agc31C"
#define ll long long

const int N=1<<17;

int n,A,B;

#define poly std::vector<int>

inline void out(const poly &a){
  for(int i=0,n=a.size();i<n;i++)printf("%d%c",a[i],i^n-1?' ':'\n');
}

inline poly get(int n,int A,int B){
  poly ret(1<<n);
  //printf("Geting %d %d %d\n",n,A,B);
  if(n==1){
    ret[0]=A;ret[1]=B;
    return ret;
  }
  int pos=0;
  for(;!((A^B)>>pos&1);pos++);
  int tA=A>>(pos+1)<<pos|(A&((1<<pos)-1));
  int tB=B>>(pos+1)<<pos|(B&((1<<pos)-1));
  int C=tA^1;

  //printf("pos=%d\n",pos); printf("tA=%d C=%d tB=%d\n",tA,C,tB);

  poly l=get(n-1,tA,C),r=get(n-1,C,tB);

  for(int i=0;i<1<<n-1;i++){
    ret[i]=(l[i]>>pos)<<(pos+1)|(((A>>pos)&1)<<pos)|(l[i]&((1<<pos)-1));
    ret[i+(1<<n-1)]=(r[i]>>pos)<<(pos+1)|(((B>>pos)&1)<<pos)|(r[i]&((1<<pos)-1));
  }
  return ret;
}

int main(){
  scanf("%d%d%d",&n,&A,&B);
  if(!__builtin_parity(A^B)){
    puts("NO");
  }else{
    puts("YES");
    out(get(n,A,B));
  }
  return 0;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

int main()
{
	vector<int> v = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	int K;
	cin >> K;

	cout << v[K - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let a: usize = sc.get();
    let b: usize = sc.get();
    let x: usize = sc.get();
    let ans;
    if a > 0 {
        ans = b / x - (a-1) / x;
    } else {
        ans = b / x + 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4476
s = list(input())

if s[0] != "A":
    print("WA")
    exit()

if s[2:-1].count("C") != 1:
    print("WA")
    exit()

s.remove("A")
s.remove("C")
s_in = "".join(s)

if not s_in.islower():
    print("WA")
    exit()

print("AC")


Measured memory_bytes: 38384
//                               //
    // author : samars_diary //
    // 17-09-2020 │ 08:08:58 //
//                               //

#include <iostream>
#include <string>
using namespace std;

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

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif

    int t = 1;
    cin >> t;
    long long int AC(0),TLE(0),WA(0),RE(0);
    string temp;
    while(t--){
        cin>>temp;
        if(temp=="AC"){
            AC+=1;
        }else if(temp=="TLE"){
            TLE+=1;
        }else if(temp=="WA"){
            WA+=1;
        }else{
            RE+=1;
        }
    }
    cout<<"AC x "<<AC<<'\n';
    cout<<"WA x "<<WA<<'\n';
    cout<<"TLE x "<<TLE<<'\n';
    cout<<"RE x "<<RE<<'\n';
    return 0;
}

Measured memory_bytes: 3648
import java.util.Comparator;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<String,Map<Integer,Integer>> map = new TreeMap<>();
		int N=sc.nextInt();

		for(int i=0;i<N;i++) {
			String S=sc.next();
			int P=sc.nextInt();
			if(!map.containsKey(S)) {
				map.put(S,new TreeMap<Integer,Integer>(Comparator.reverseOrder()));
			}
			map.get(S).put(P,i+1);
		}

		for(Map.Entry<String,Map<Integer,Integer>> E: map.entrySet()) {
			for(Map.Entry<Integer,Integer> e: E.getValue().entrySet()) {
				System.out.println(e.getValue());
			}
		}

	}
}

Measured memory_bytes: 21716
import sys
from collections import defaultdict
from queue import Queue


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    g = defaultdict(list)
    for i in range(n):
        line = list(map(int, input().split()))
        if line[1] > 0:
            g[line[0]] = line[2:]
    q = Queue()
    q.put(1)
    dist = [-1] * (n + 1)
    dist[1] = 0
    while not q.empty():
        p = q.get()
        for nxt in g[p]:
            if dist[nxt] == -1:
                dist[nxt] = dist[p] + 1
                q.put(nxt)
    for i in range(1, n + 1):
        print(i, dist[i])


if __name__ == "__main__":
    main()



Measured memory_bytes: 6996
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string s = Console.ReadLine();
        int[] c = new int[26];
        long count = 1;
        for(int i=0;i<s.Length;i++){
            count += i - c[s[i]-'a'];
            c[s[i]-'a']++;
        }
        sb.Append(count+"\n");
    }
}

Measured memory_bytes: 11616
import qualified Data.ByteString.Char8 as BC
import qualified Data.Vector.Unboxed as VU
import Data.Char
import Data.List

main = do
  [k,n] <- map read . words <$> getLine :: IO [Int]
  xs <- VU.unfoldrN n (BC.readInt . BC.dropWhile isSpace) <$> BC.getLine
  let ys = xs VU.++ VU.map (+k) xs
  print $ minimum  $ map (\i -> ys VU.! (i+n-1) - (ys VU.! i)) [0..n-1]

Measured memory_bytes: 10620
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut n: i32 = s.trim().parse().unwrap();
    let mut f = false;
    while n > 0 {
        if n % 10 == 7 {
            f = true;
            break;
        } else {
            n /= 10;
        }
    }

    println!("{}", if f { "Yes" } else { "No" });
}


Measured memory_bytes: 2128
N = int(input())
card = [int(i) for i in input().split()]

Alice = 0
Bob = 0
flag = True

card.sort(reverse = True)
for i in card:
  if flag == True:
    Alice += i
    flag = False
  else:
    Bob += i
    flag = True
  
print(Alice - Bob)  

Measured memory_bytes: 3060
import math
t = int(input())
C = [list(map(int, input().split())) for i in range(t)]
di = [2, 3, 5]

nmax = 10**18

def a1(x, co):
    global D
    # print(x,D)
    if x in D:
        # print("rt")
        return D[x]
    else:
        ans = float("inf")
        for j in range(3):
            ans = min(ans, a1(x//di[j], co) + d*(x%di[j]) + co[j])
            if x > x//di[j] + 1:
                ans = min(ans, a1(x//di[j] + 1, co) + d*(di[j] - (x%di[j])) + co[j])
        ans = min(ans, d*x)
        D[x] = ans
        # print("wr")
        return ans

for ii in range(t):
    n,a,b,c,d = C[ii]
    co = [a,b,c]
    D = {0:0, 1:d}
    print(a1(n, co))

Measured memory_bytes: 101488
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int d = a*b;
        System.out.println(Math.min(c,d));


    }
}


Measured memory_bytes: 35760
#include <iostream>
#include <vector>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace  std;

const double cos60 = cos(M_PI / 3);
const double sin60 = sin(M_PI / 3);

struct StPnt
{
  double m_nx;
  double m_ny;

  StPnt() :
    m_nx(0), m_ny(0)
  { }
  StPnt(double nx, double ny) :
    m_nx(nx), m_ny(ny)
  { }

  ~StPnt() { }
};

void fnInput(int &rnRcSiz)
{
  cin >> rnRcSiz;
}

void fnKochCrv( const StPnt &cnroPnt1, const StPnt &cnroPnt2, vector<StPnt> &rvoRtnPnt)
{
  rvoRtnPnt[0] = cnroPnt1;
  rvoRtnPnt[1].m_nx = (2 * cnroPnt1.m_nx + cnroPnt2.m_nx) / 3;
  rvoRtnPnt[1].m_ny = (2 * cnroPnt1.m_ny + cnroPnt2.m_ny) / 3;
  rvoRtnPnt[3].m_nx = (cnroPnt1.m_nx + 2 * cnroPnt2.m_nx) / 3;
  rvoRtnPnt[3].m_ny = (cnroPnt1.m_ny + 2 * cnroPnt2.m_ny) / 3;

  rvoRtnPnt[2].m_nx =  (rvoRtnPnt[3].m_nx - rvoRtnPnt[1].m_nx) * cos60 
                     - (rvoRtnPnt[3].m_ny - rvoRtnPnt[1].m_ny) * sin60;
  rvoRtnPnt[2].m_nx += rvoRtnPnt[1].m_nx;
  rvoRtnPnt[2].m_ny =  (rvoRtnPnt[3].m_nx - rvoRtnPnt[1].m_nx) * sin60
                     + (rvoRtnPnt[3].m_ny - rvoRtnPnt[1].m_ny) * cos60;
  rvoRtnPnt[2].m_ny += rvoRtnPnt[1].m_ny;

  rvoRtnPnt[4] = cnroPnt2;
}

void fnKochCtl(int nRcSiz, vector<vector<StPnt>> &rvvoPnt)
{
  StPnt oPntB(0.0, 0.0);
  StPnt oPntE(100.0, 0.0);

  rvvoPnt.resize(7);
  rvvoPnt[0].clear();
  rvvoPnt[0].push_back(oPntB);
  rvvoPnt[0].push_back(oPntE);

  for (int nRc = 0; nRc < nRcSiz; nRc++)
  {
    rvvoPnt[nRc + 1].clear();
    rvvoPnt[nRc + 1].push_back(oPntB);
    for (int i = 0; i < rvvoPnt[nRc].size() - 1; i++)
    {
      StPnt oPnt1 = rvvoPnt[nRc][i];
      StPnt oPnt2 = rvvoPnt[nRc][i + 1];
      vector<StPnt> voRtnPnt(5);

      fnKochCrv(oPnt1, oPnt2, voRtnPnt);
      for (int j = 1; j < 5; j++)
        rvvoPnt[nRc + 1].push_back(voRtnPnt[j]);
    }
  }
}

void fnResult(int nRcSiz, const vector<vector<StPnt>> &cnrvvoPnt)
{
  for (int i = 0; i < cnrvvoPnt[nRcSiz].size(); i++)
    cout << cnrvvoPnt[nRcSiz][i].m_nx << " " << cnrvvoPnt[nRcSiz][i].m_ny << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(8);

  int nRcSiz;
  vector<vector<StPnt>> vvoPnt;

  fnInput(nRcSiz);
  fnKochCtl(nRcSiz, vvoPnt);

  fnResult(nRcSiz, vvoPnt);

  return 0;
}

Measured memory_bytes: 1392
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    //int a[200005];
    bool flag=false;
    int x,a,ans=0;
    //char s[105],t[105],u;
   
   cin >> x;
    //for(int i=0;i<n;i++) cin >> s[i];
    //for(int i=0;i<n;i++) cin >> t[i];
    if(x!=2 && x!=3){
    while(1){
        for(int i=2;i<pow(x,0.5)+1;i++){
            if(x%i == 0){
                flag = true;
                break;
            }
        }

        if(flag){
            x++;
            flag = false;
        }else break;
    }
    }
    ans = x;
    
    //cout << (!flag ? "Yes" : "No");
    cout << ans;
    //cout << s;
    //printf("%.10f",ans_d);
    cout << endl;
}


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

	int a[26];
int main()
{
	string s;
	cin>>s;
	int f=0;
	for(int i=0;i<s.length();i++)
	{
		if(a[s[i]-'a'])
			f=1;
		a[s[i]-'a']=1;
	}
	if(!f)
		cout<<"yes\n";
	else
		cout<<"no\n";
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
A = [*0..N]
$<.each{|ln|
	x, y, = ln.split.map(&:to_i)
	a, b = [x, y].map{|i| i = A[i] until i == A[i]; i }
	A[x] = A[y] = A[a] = A[b] = [a, b].min
}
p A.each_with_index.count{|a,i| a == i }-1


Measured memory_bytes: 3452
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int ans = 0;
        int kijun = 0;
        while (ans < 10000000) {
            ans++;
            kijun=kijun*10+7;
            kijun = kijun%k;
            if (kijun == 0) {
                System.out.println(ans);
                return;
            }
        }
        System.out.println("-1");
    }
}


Measured memory_bytes: 35800
#include <bits/stdc++.h>
#define int long long int
#define mod 1e9 +7
using namespace std;
int DP[101][100001] = {0};
signed main() {
    int n,k1;
    cin>>n>>k1;
    int cap[n+1];
    for(int i=1;i<=n;i++)
    cin>>cap[i];

    int cum[n+1] = {0};
    cum[1] = cap[1];
    for(int i=2;i<=n;i++ )
    cum[i]+=(cap[i] + cum[i-1]);
    //cout<<cum[1]<<cum[2]<<cum[3]<<endl;
    DP[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int k=0;k<=k1;k++)
        {
            if(i==0 && k==0)
            continue;
            if(k==0)
            {
                DP[i][k]=1;
                continue;
            }
            if(i==0)
            continue;

            if(cap[i]>=k)
            {
                DP[i][k] = DP[i][k-1] + DP[i-1][k];
                
                DP[i][k] = DP[i][k]%1000000007;
            }
            else
            {
                DP[i][k] = DP[i][k-1] + DP[i-1][k] +mod - DP[i-1][k-cap[i]-1];
                DP[i][k] = DP[i][k]%1000000007;
            }

        }
    }

    cout<<DP[n][k1]<<endl;

//    for(int i=0;i<=n;i++)
  //  {
//
//
  //      for(int k=0;k<=k1;k++)
    //    {
      //      cout<<DP[i][k]<<" ";
        //}
        //cout<<endl;
    //}

    //cout<<DP[3][3]<<DP[2][4]<<DP[2][0]%1000000007;
    return 0;
}


Measured memory_bytes: 78336
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[20010];
int n;
struct pr{
	ll l,r;
	pr(ll l=0,ll r=0):l(l),r(r){}
}p[30],q[30];
bool operator<(pr a,pr b){return a.l==b.l?a.r<b.r:a.l<b.l;}
int M;
bool gao(){
	int i,C;
	ll l,r;
	for(i=1;i<=M;i++){
		if(!p[i].l||p[i].l>p[i].r)return 1;
	}
	sort(p+1,p+M+1);
	C=0;
	l=p[1].l;
	r=p[1].r;
	for(i=2;i<=M;i++){
		if(r<p[i].l-1){
			q[++C]=pr(l,r);
			l=p[i].l;
			r=p[i].r;
		}else
			r=max(r,p[i].r);
	}
	q[++C]=pr(l,r);
	for(i=1;i<=C;i++)p[i]=q[i];
	M=C;
	return 0;
}
bool check(ll pw,int t){//S%(10*pw) in [t*pw,(t+1)*pw)
	int i,j;
	p[M=1]=pr(t*pw,(t+1)*pw-1);
	pw*=10;
	for(i=1;i<=n;i++){
		for(j=1;j<=M;j++)p[M+j]=pr((p[j].l-a[i]%pw+pw)%pw,(p[j].r-a[i]%pw+pw)%pw);
		M*=2;
		if(gao())return 1;
	}
	return 0;
}
int main(){
	int i,j,s;
	ll pw;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%lld",a+i);
	pw=1;
	s=0;
	for(i=0;i<17;i++,pw*=10){
		for(j=9;j>0;j--){
			if(check(pw,j)){
				s+=j;
				break;
			}
		}
	}
	printf("%d",s);
}

Measured memory_bytes: 256
array = input().split()
W = int(array[0])
H = int(array[1])
x = int(array[2])
y = int(array[3])
r = int(array[4])

if x >= r:
    if x <= W-r:
        if y >= r:
            if y <= H-r:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 7724
S = list(input())
l = len(S)

if l == 1:
    print(int(S[0]))
    exit()

A = []
for i in range(2**(l-1)):
    B = []
    for j in range(l-1):
        if (i>>j) & 1:
            B.append(1)
        else:
            B.append(0)
    A.append(B)

ans = 0

for i in range(2**(l-1)):
    C = []
    a = S[0]
    for j in range(l-1):
        if j != l-2:
            if A[i][j] == 0:
                a += S[j+1]
            else:
                C.append(a)
                a = S[j+1]
        else:
            if A[i][j] == 0:
                a += S[j+1]
                C.append(a)
            else:
                C.append(a)
                C.append(S[j+1])
    for j in C:
        ans += int(j)

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>

using namespace std;

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

    while (true)
    {
        cin >> x >> y;
        if (x == 0 && y == 0)
        {
            break;
        }

        if (x > y)
        {
            int tmp = x;
            x = y;
            y = tmp;
        }
        printf("%d %d\n", x, y);
    }

    return 0;
}


Measured memory_bytes: 3056
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void run(){
		String str = sc.next();
		int n  = sc.nextInt();
		int ans = 0;
		for(int i =0 ; i < n ;i++){
			String buffer= sc.next();
			buffer = buffer+buffer;
			if(buffer.contains(str)){
				ans++;
			}
		}
		System.out.println(ans);
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define ll long long
#define fr(i,x) for( int i=0;i<(x);i++)
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int main() 
{ 
    int n;
    int m,s=0,temp=0;
    cin>>n>>m;
    int a[n];
    float j=4*m;
    float p=1/j;
    // cout<<p<<endl;
    for (int i = 0; i < n; i++) 
    {
       cin>>a[i];
       s=s+a[i];
    }
   // cout<<s<<endl;
    //cout<<p*s<<endl;
    for (int i = 0; i < n; i++) 
    {
       if(a[i]>=(p*s))
       {
           temp++;
       }
    }
    if(temp>=m)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
	return 0; 
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define mod 1000000007
#define qmod 998244353
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mk make_pair 
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll LINF = LLONG_MAX;
const int MAX_V = 201;

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0&&c>0){
		if(c>0){
			c = c-b;
		}
		if(c<=0){
			cout<<"Yes\n";
			return 0;
		}
		if(a>0){
			a = a-d;
		}
		if(a<=0){
			cout<<"No\n";
			return 0;
		}
	}
	

	
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

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

	int ans = b+min(c,a+b+1);



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

}


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

int main(){
    int x,y;
    bool f=false;
    cin>>x>>y;
    for(int i=0;i<=x;++i){
        for(int j=0;i+j<=x;++j){
            if(2*i+4*j==y)
                if(i+j==x){
                    f=true;
                    break;
                }
        }
        if(f)
            break;
    }
    cout<<((f)?"Yes":"No")<<endl;
    
}

Measured memory_bytes: 3620
n = 0
c = []
ans = 0
"""
def changePosition(int stone1,int stone2):
    r = c[stone1]
    c[stone1] = c[stone2]
    c[stone2] = r
    ans += 1

def changeColor(int stone):
    if c[stone]=="R":
        c[stone]="W"
    else:
        c[stone]="R"
    ans += 1
"""

def main():
    n = int(input())
    c = input()

    red=c.count("R")
    num=c[0:red].count("R")
    print(red-num)


main()

Measured memory_bytes: 9464
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iterator>

using namespace std;


bool is_bingo(vector <vector <int>> sheet) {
	if (sheet[0][0] == -1 && sheet[0][1] == -1 && sheet[0][2] == -1)
		return true;
	if (sheet[1][0] == -1 && sheet[1][1] == -1 && sheet[1][2] == -1)
		return true;
	if (sheet[2][0] == -1 && sheet[2][1] == -1 && sheet[2][2] == -1)
		return true;
	if (sheet[0][0] == -1 && sheet[1][0] == -1 && sheet[2][0] == -1)
		return true;
	if (sheet[0][1] == -1 && sheet[1][1] == -1 && sheet[2][1] == -1)
		return true;
	if (sheet[0][2] == -1 && sheet[1][2] == -1 && sheet[2][2] == -1)
		return true;
	if (sheet[0][0] == -1 && sheet[1][1] == -1 && sheet[2][2] == -1)
		return true;
	if (sheet[0][2] == -1 && sheet[1][1] == -1 && sheet[2][0] == -1)
		return true;
	return false;
}

int main()
{
	ios_base::sync_with_stdio(false);
	vector < vector <int> > sheet(3, vector <int>(3));
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j)
			cin >> sheet[i][j];
	}
	int n;
	cin >> n;
	bool ok = true;
	for (int i = 0; i < n; ++i) {
		int b;
		cin >> b;
		bool found = false;
		for (int x = 0; x < 3; ++x) {
			for (int y = 0; y < 3; ++y) {
				if (sheet[x][y] == b) {
					sheet[x][y] = -1;
					found = true;
					break;
				}
			}
			if (found)
				break;
		}
	}
	if (is_bingo(sheet))
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		InputStreamReader is = new InputStreamReader(System.in);
                BufferedReader br = new BufferedReader(is);
		int su = Integer.parseInt(br.readLine());//秒入力
		int h = su / 3600;
		int m = (su % 3600) / 60;
		int s = su - (3600 * h + m * 60);
		System.out.println(h+":"+m+":"+s);
	}
}


Measured memory_bytes: 24448
import math as mt
import collections as cc
I=lambda:list(map(int,input().split()))
a,b,c,d=I()
x=(a//d)+(1 if a%d else 0)
y=(c//b)+(1 if c%b else 0)
if x==y:
    print('Yes')
elif x<y:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 65364