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

int main(){
  int N,M;
  cin >> N;
  vector<string> s(N);
  for (int i=0;i<N;i++){
    cin >> s.at(i);
  }
  cin >> M;
  vector<string> t(M);
  for (int i=0;i<M;i++){
    cin >> t.at(i);
  }
  int count = 0;
  for(int i=0;i<N;i++){
    int tempCount = 0;
    string temp = s.at(i);
    for(int j=0;j<N;j++){
      if(s.at(j) == temp) tempCount++;
    }
    for(int j=0;j<M;j++){
      if(t.at(j) == temp) tempCount--;
    }
    if(count < tempCount) count = tempCount;
  }
  if (count > 0){
    cout << count;
  }else{
    cout << 0;
  }
}

Measured memory_bytes: 3640
def test():
    n,y = map(int,input().split())
    for i in range(n+1):
        for j in range(n-i+1):
                if 10000*i + 5000*j + 1000*(n-i-j) == y:
                    print(i,j,n-i-j)
                    return
    print("-1 -1 -1")


if __name__ == "__main__":
    test()


Measured memory_bytes: 2940
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}

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

    int n=0, w=0, s=0, e=0;
    for(int i = 0; i < move.size(); i++){
        if(move[i] == 'N') n=1;
        if(move[i] == 'W') w=1;
        if(move[i] == 'S') s=1;
        if(move[i] == 'E') e=1;
    }

    if(n==s && w==e) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#define Would
#define you
using namespace std;
int main() {
	int n;
	Would you cin >> n;
	vector<string>v(n);
	bool shiritori = true;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		if (i >= 1) {
			if (v[i][0] != v[i - 1][v[i - 1].length() - 1]) shiritori = false;
		}
	}

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i != j && v[i] == v[j]) shiritori = false;
		}
	}
	if (shiritori) Would you cout << "Yes" << endl;
	else Would you cout << "No" << endl;
}

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

using namespace std;

const int MOD = 1e9 + 7;

const int N = 1e6 + 5;
vector<int> pf[N];
void sieve() {
    for (int i = 2 ;i < N ;i++)
        if (!pf[i].size())
            for (int j = i ;j < N ;j += i)
                pf[j].push_back(i);
}

int add (int a , int b) {
    a += b;
    while (a >= MOD) a -= MOD;
    while (a < 0) a += MOD;
    return a;
}

long long mul(long long a , long long b) {
    return a * b % MOD;
}

long long power(long long a , long long b) {
    if (!b) return 1;
    long long r = power(a , b / 2);
    r = mul(r , r);
    if (b&1) return mul(r , a);
    return r;
}

long long mod_inv(long long x) {
    return power(x , MOD - 2);
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    sieve();

    int n;
    cin >> n;

    map<int , int> mx;

    vector<int> a(n);
    for (int i = 0 ;i < n ;i++) {
        cin >> a[i];
        auto &v = pf[a[i]];
        for (int x : v) {
            int org = a[i] , cnt = 0;
            while (org % x == 0)
                org /= x , cnt++;

            mx[x] = max(mx[x] , cnt);
        }
    }

    int lcm = 1;
    for (auto &p : mx)
        lcm = mul(lcm , power(p.first , p.second));

    int ans = 0;
    for (int i = 0 ;i < n ;i++) {
        auto &v = pf[a[i]];
        int m = 1;
        for (int x : v) {
            int org = a[i] , cnt = 0;
            while (org % x == 0)
                org /= x , cnt++;
            m = mul(m , power(x , cnt));
        }
        ans = add(ans , mul(lcm , mod_inv(m)));
    }

    cout << ans;
}

Measured memory_bytes: 59488
mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]
mask += [[mask[1][i] for i in mask[1]]]

def set_top(dice, top):
    return [dice[i] for i in mask[top]]

def twist(dice):
    return [dice[i] for i in (0, 3, 1, 4, 2, 5)]

def equal(dice1, dice2):
    if sorted(dice1) != sorted(dice2):
        return False
    
    for i in range(6):
        tmp_dice = set_top(dice2, i)
        for _ in range(4):
            if dice1 == tmp_dice:
                return True
            tmp_dice = twist(tmp_dice)
    return False

def diff_check_all(dices, n):
    for i in range(n -1):
        for j in range(i + 1, n):
            if equal(dices[i], dices[j]):
                return False
    return True
            

n = int(input())
dices = [input().split() for _ in range(n)]

print('Yes' if diff_check_all(dices, n) else 'No')

Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

int main(){
    int n,m;cin>>n>>m;
    vin l(m),r(m);
    rep(i,m)cin>>l[i]>>r[i];
    sort(all(l),greater<int>());
    sort(all(r));
    cout<<(r[0]-l[0]>=0?r[0]-l[0]+1:0)<<endl;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
bool R(){return true;}
template<typename T, typename ... Args>
bool R(T & x, Args & ... args){return cin >> x && R(args...);}
void init_io(){ios::sync_with_stdio(false);cin.tie(0);}

#define PB push_back
#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define ALL(vec) (vec).begin(), (vec).end()
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF   1000000007
#define INFLL 4000000000000000007LL

int n, a[200014];
vector<int> res;

void solve ()
{
  R(n);
  FOR(i, 0, n) R(a[i]);
  int txor = 0;
  FOR(i, 0, n) txor ^= a[i];
  FORDE(i, n - 1, 0)
  {
    txor ^= a[i];
    res.PB(txor);
    txor ^= a[i];
  }
  reverse(ALL(res));
  FOR(i, 0, n) printf("%d%c", res[i], " \n"[i == n - 1]);
}

int main ()
{
  init_io();
  int T = 1;
  //R(T);
  while (T--) solve();
  return 0;
}


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

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d\n", &N);
  int a,b;//00~99,01~12
  a = N/100;
  b = N%100;
  if(a > 0 && a < 13){
    if(b > 0 && b < 13){
      printf("AMBIGUOUS");
    } else {
      printf("MMYY");
    }
  } else {
    if(b > 0 && b < 13){
      printf("YYMM");
    } else {
      printf("NA");
    }
  }
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

typedef long long int ll;

//ll num[50];
//ll num2[50];
ll num[]={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
};
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;
//deque<char> deq;

int main(void)
{
    //double ans=0.0,d,d1,d2;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1=0,a2=0,a3=0;
    string s;
    char c,c1;
    a=a1=a2=a3=0;
    cin>>n;
    cout<<num[n-1];
    return 0;
}





Measured memory_bytes: 256
<?php

// define('DEBUG', true);
define('DEBUG', false);

// define('MOD', 1000000007);

fscanf(STDIN, "%d", $M);
$a = explode(" ", trim(fgets(STDIN)));
fscanf(STDIN, "%d", $N);
$b = explode(" ", trim(fgets(STDIN)));

foreach ($a as $v) {
    $arr[$v]++;
}

foreach ($b as $v) {
    if (!isset($arr[$v])) {
        echo "NO\n";
        exit;
    }
    $arr[$v]--;
    if ($arr[$v] < 0) {
        echo "NO\n";
        exit;
    }
}
echo "YES\n";


Measured memory_bytes: 48108
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {


		String s = nextString();
		int[] o = {0,0};
		int[] e = {0,0};

		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='0'){
				if(i%2==0){
					e[0]++;
				}else{
					o[0]++;
				}
			}else{
				if(i%2==0){
					e[1]++;
				}else{
					o[1]++;
				}
			}
		}
		int ans =0;
		if(o[0]>=o[1]){
			if(o[0]>=e[0]){
				ans=e[0]+o[1];
			}else{
				ans=o[0]+e[1];
			}
		}else{
			if(o[1]>=e[1]){
				ans=e[1]+o[0];
			}else{
				ans=o[1]+e[0];
			}
		}
		System.out.println(ans);

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 25300
N = int(input())
A = list(map(int, input().split()))
X = [0, 0, 0]
for a in A:
  if a % 2 == 1:
    X[0] += 1
  elif a % 4 == 2:
    X[1] += 1
  else:
    X[2] += 1
if X[1] == 0:
  if X[2] >= X[0] - 1:
    print("Yes")
  else:
    print("No")
else:
  if X[2] >= X[0]:
    print("Yes")
  else:
    print("No")

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

int main(void){
    int N, M, S, T;
    int ubuf, vbuf;

    cin >> N >> M;
    vector<vector<int>> G(3*N, vector<int>());
    for(int i=0; i<M; i++){
        cin >> ubuf >> vbuf;
        ubuf--;
        vbuf--;
        G[ubuf].push_back(vbuf+N);
        G[ubuf+N].push_back(vbuf+2*N);
        G[ubuf+2*N].push_back(vbuf);
    }
    cin >> S >> T;
    S--;
    T--;

    vector<int> Distance(3*N, -3);
    
    queue<int> que;
    Distance[S] = 0;
    que.push(S);

    while((!que.empty())&&(Distance[T]==-3)){
        int v = que.front();
        que.pop();
        for(int child: G[v]){
            if(Distance[child]!=-3)continue;
            Distance[child] = Distance[v]+1;
            que.push(child);
        }
    }

    cout << Distance[T]/3 << endl;

    return 0;
}

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

void change(int *a,int *b,int *c){
  int tmp;
  if(*a<*b){
    tmp = *b;
    *b = *a;
    *a = tmp;
  }
  if(*b<*c){
    tmp = *c;
    *c = *b;
    *b = tmp;
  }
  if(*a<*b){
    tmp = *b;
    *b = *a;
    *a = tmp;
  }
}
    

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

  change(&a,&b,&c);

  for(int i=0;i<k;i++){
    a=2*a;
  }

  cout <<(a+b+c);
  return 0;
}


Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
adj = [[] for _ in range(N)] #隣接している街のリストを作る
for i in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    adj[a].append(b)
    adj[b].append(a)

def DFS(now, visited):
    global ans
    if len(visited) == N:
        ans += 1 #到着したら1回増やす
    else:
        for u in adj[now]:
            if u not in visited: #向かう道の中で訪れていない場所を攻める
                DFS(u, visited+[u])
                #もしappendにすると、visitedが他のルートを選んだ時
                #まえのvisitedを引きずってしまう
        return



ans = 0
visited = [0] #到達したところを記憶していく
DFS(0, visited)
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define exp pow(10,-9)
#define F first
#define S second
#define PB push_back 
#define MP make_pair
#define daman ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lowercase(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define uppercase(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
main(){
	daman;
	lli n;
	cin>>n;
	lli arr[n],sum = 0;
	map<lli,lli>m;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		sum += arr[i];
		m[arr[i]]++;
	}

	lli q,b,c;
	cin>>q;
	
	for(int i=0;i<q;i++)
	{
		cin>>b>>c;
		sum += m[b]*(c - b);
		m[c] += m[b];
		m[b] = 0;
		cout<<sum<<"\n";
	}
}

Measured memory_bytes: 10284
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)

bool has_key_using_count(map<char, char> &m, char n){
    if (m.count(n) == 0){
        return false;
    }
    else{
        return true;
    }
}
void secToMin(int orgSec, int *sec, int *min) {
	*sec = orgSec % 60;
	*min = orgSec / 60;
}

int main()
{	
	//ifstream cin("sample.txt");

	int n = 0, t = 0, min = 0, sec = 0, sumSec = 0;
	
	// テァツァツ津ヲツ閉ーテ」ツつ津・ツ?ィテ」ツ?ヲティツカツウテ」ツ??
	while(cin >> t) {
		sumSec += t;
	}

	// テ・ツ按?」ツδサテァツァツ津・ツスツ「テ・ツシツ湘」ツ?ォテァツ崢エテ」ツ?療」ツ?ヲテ・ツ?コテ・ツ環?
	secToMin(sumSec, &sec, &min);
	cout << min << endl;
	cout << sec << endl;

	return 0;
}

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int x, y; scanf("%d%d", &x, &y);
	for(int i = (y - x + 1); i <= (y + x - 1); i++) {
		if(i >= -1e6 && i <= 1e6)
			printf("%d ", i);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int w=0,e=0,ss=0,n=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='W')w=1;
        else if(s[i]=='E')e=1;
        else if(s[i]=='S')ss=1;
        else if(s[i]=='N')n=1;
    }
    if(w==e&&n==ss)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#define N 1000
#define MOD 1000000007
using namespace std;
typedef long long LL;
LL mod_pow(LL base, LL exp)
{
	if(exp==0) return 1;
	if(exp&1) return (base*mod_pow(base,exp-1))%MOD;
	else return mod_pow((base*base)%MOD,exp/2);
}
LL inv(LL n){ return mod_pow(n,MOD-2); }
LL fac[N+1];
LL fac_inv[N+1];
LL C(LL n, LL k)
{
	if(k < 0 || k > n) return 0;
	LL num = fac[n];
	LL den = (fac_inv[k]*fac_inv[n-k])%MOD;
	return (num*den)%MOD;
}
LL cost[N+1][N+1];
LL memo[N+1][N+1];
LL A, B, C2, D;
LL dp(LL n, LL sz)
{
	if(n==0) return 1;
	if(n < 0 || sz > B) return 0;
	if(memo[n][sz]!=-1) return memo[n][sz];

	LL ans = dp(n,sz+1); //count = 0
	for(LL count = C2; count <= D && sz*count <= n; count++)
	{
		LL x1 = C(n,sz*count)*cost[count][sz]%MOD;
		   x1 = (x1*dp(n-sz*count,sz+1))%MOD;
		ans = (ans+x1)%MOD;
	}
	return memo[n][sz] = ans;
}
int main()
{
	fac[0] = 1;
	for(LL n = 1; n <= N; n++)
		fac[n] = (fac[n-1]*n)%MOD;
	fac_inv[N] = inv(fac[N]);
	for(LL n = N-1; n >= 0; n--)
		fac_inv[n] = (fac_inv[n+1]*(n+1))%MOD;

	for(LL count = 1; count <= N; count++)
		for(LL sz = 1; sz <= N; sz++)
			if(count*sz <= N)
			{
				LL x1 = (fac[sz*count]*fac_inv[count])%MOD;
				cost[count][sz] = (x1*mod_pow(fac_inv[sz],count))%MOD;
			}

	int n; cin >> n;
	cin >> A >> B >> C2 >> D;

	memset(memo,-1,sizeof memo);
	cout<<dp(n,A)<<endl;

	return 0;
}

Measured memory_bytes: 15360
import collections
N = int(input())
A = list(map(int, input().split()))
t = collections.defaultdict(int)
for x in A:
    t[x] += 1
ans = 0
for x in t:
    ans += t[x]*(t[x]-1) // 2
for x in A:
    tmp = ans
    tmp -= (t[x]*(t[x] - 1)) // 2
    print(tmp + ((t[x]-1)*(t[x]-2))//2)


Measured memory_bytes: 26780
#include <bits/stdc++.h>
#include <stdio.h>
#include <ios>     
#include <iomanip> 

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
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; }

int main()
{
  //input
  int A, P; cin >> A >> P; 

  //main
  
  
  // output
  cout << (3*A+P)/2 << endl;
  
  return 0;
}

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

string s,t;
ll n;
bool ans;


int main(){
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    bool ans=true;   
    for(ll i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            ans=false;
            break;
        }else{
            continue;
        }
    }
    if(ans)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
	string n;
	while(cin >> n){
		if(n=="0"){break;}
		int ans=0;
		for(int i=0; i<n.length(); i++){
			ans+=n[i]-'0';	
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3140
n, k = map(int, input().split())
li = list(map(int, input().split()))

check = [0] * (n+10)
res = []
next = 0

for i in range(k):
    if check[next] == 0:
        check[next] = 1
        next = li[next]-1
    elif check[next] == 1:
        check[next] += 1
        res.append(next+1)
        next = li[next]-1
    else:
        cnt = len(res)
        k -= check.count(1)
        amari = k%cnt
        print(res[amari])
        break
else:
    print(next+1)

Measured memory_bytes: 32376
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main() {
    int n, N[100000];
    int q, Q[50000];
    int count = 0;

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

    cin >> q;
    for (int j = 0; j< q; j++) {
        cin >> Q[j];
    }

    for (int j = 0; j < q; j++) {
        int left = 0;
        int right = n;
        int key = Q[j];
        while(left < right) {
            int mid = (left + right) / 2;
            if (N[mid] == key) {
                count++;
                break;
            } //A little bit different.
            else if (key < N[mid]) right = mid;
            else left = mid + 1;
        }
    }
//    binarySearch(); ??¢??°??¢?????????????????????????????°???

    cout << count << endl;
}

Measured memory_bytes: 3636
n, k, c = map(int, input().split())
s = input()

s2 = s[::-1]

dp1 = [0] * (n + 2)
dp2 = [0] * (n + 2)

for (dp, ss) in zip([dp1, dp2], [s, s2]):
    for i in range(n):
        if ss[i] == 'x':
            dp[i+1] = dp[i]
        elif i <= c:
            dp[i+1] = min(1, dp[i] + 1)
        else:
            dp[i+1] = max(dp[i-c] + 1, dp[i])

dp2 = dp2[::-1]

for i in range(1, n+1):
    if s[i-1] == 'o' and dp1[i-1] + dp2[i+1] < k:
        print(i)


Measured memory_bytes: 74864
#include <stdio.h>

int main(){
	int x,y;
	for(;; x=1,y=1){
		scanf("%d %d",&x,&y);
		if((x == 0)&&(y == 0)) break;
		if(x<y){
			printf("%d %d\n",x,y);
		}else if(y<x){
			printf("%d %d\n",y,x);
		}else{
			printf("%d %d\n",x,y);
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d%d", &a, &b)
#define sc3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define scl2(a, b) scanf("%lld%lld", &a, &b)
#define ss(a) scanf("%s", a)
#define mem(a, b) memset(a, b, sizeof(a))
#define PII pair<int, int>
using namespace std;
const int N = 5e5+5;
int a[N],rt[N];
int lc[N*40],rc[N*40],tot;
LL sum[N*40];
map<int,int>vis;
void update(int &u,int x,int y,int p,LL v){
    sum[tot]=sum[u]+v;
    lc[tot]=lc[u];
    rc[tot]=rc[u];
    u=tot++;
    if(x==y)return;
    int m=x+y>>1;
    if(p<=m)update(lc[u],x,m,p,v);
    else update(rc[u],m+1,y,p,v);
}
LL query(int u, int x, int y, int ql, int qr)
{
    if(ql <= x && y <= qr) return sum[u];
    int m = (x+y)>>1;
    LL ans = 0;
    if(ql <= m) ans += query(lc[u],x,m,ql,qr);
    if(qr > m) ans += query(rc[u],m+1,y,ql,qr);
    return ans;
}
int main(){
	int n,q;
	tot++;
    vis.clear();
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++){
		rt[i]=rt[i-1];
		if(vis.find(a[i])!=vis.end())
		{
			int tmp=rt[i-1];
			update(tmp,1,n,vis[a[i]],-1);
			rt[i]=tmp;
			update(rt[i],1,n,i,1);
		}
		else 
		{
			rt[i] = rt[i-1];
            update(rt[i],1,n,i,1);
        }
        vis[a[i]]=i;
	}
	while(q--){
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%lld\n",query(rt[r],1,n,l,r));
	}
    system("pause");
	return 0;
	
}


Measured memory_bytes: 319648
module ABC134

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_A
  private :: calculate_area

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_A

    ! variables for this <subroutine>
    integer(INT32) :: radius

    ! STEP.01
    ! read out the given data
    read(unit=INPUT_UNIT, fmt=*) radius

    ! STEP.02
    ! calculate & output the answer of this task
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') calculate_area (radius)

    ! STEP.END
    return

  end subroutine task_A

  pure function calculate_area (radius) result(area)

    ! arguments for this <function>
    integer(INT32), intent(in) :: radius

    ! return value of this <function>
    integer(INT32) :: area

    area = 3_INT32 * radius * radius
    return

  end function calculate_area

end module ABC134


program main

  ! <module>s to import
  use, non_intrinsic :: ABC134

  ! require all variables to be explicitly declared
  implicit none

  call task_A

end program main

Measured memory_bytes: 256
#include <iostream>
#include <cstring> // memset()
#include <cstdlib> //abs(int x)
using namespace std;


int N, W;

long long solve(int* w, long long* v){
  long long DP[N+10][W+10];
  // ok
  for (int i=0; i<N+10; i++){
    for (int j=0; j<W+10; j++){
      DP[i][j] = 0;
    }
  }

  for (int i=1; i<N+1; i++){
    for (int j=1; j<W+1; j++){
      if (w[i-1] <= j) {
        DP[i][j] = max(DP[i-1][j-w[i-1]]+v[i-1], DP[i-1][j]);
      } else {
        DP[i][j] = DP[i-1][j];
      }
    }
  }
  return DP[N][W];
}


int main(){
  cin >> N >> W;
  int w[N];
  long long v[N];
  // initialization
  for (int i=0; i<N; i++){
    cin >> w[i] >> v[i];
  }
  cout << solve(w, v) << endl;
}


Measured memory_bytes: 86144
#include <bits/stdc++.h>
#define N 110
using namespace std;

int n, a[N][3];

inline int read(){
	int s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

int main(){
	n = read();
	for (int i = 1; i <= n; ++i) a[i][1] = read(), a[i][2] = read();
	for (int i = 1; i < n - 1; ++i)
		if (a[i][1] == a[i][2] && a[i + 1][1] == a[i + 1][2] && a[i + 2][1] == a[i + 2][2]){
			puts("Yes");
			exit(0);
		}
	puts("No");
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,n3,n5,n7,ans=0;
  cin>>n;
  for(i=357;i<=min(n,77777753);i++){
    n3=0;n5=0;n7=0;
    j=i;
    while(j>0){
      if(j%10==3) n3++;
      else if(j%10==5) n5++;
      else if(j%10==7) n7++;
      else break;
      j/=10;
    }
    if(j==0&&n3>0&&n5>0&&n7>0) ans++;
  }
  for(i=333333357;i<=min(n,777777753);i++){
    n3=0;n5=0;n7=0;
    j=i;
    while(j>0){
      if(j%10==3) n3++;
      else if(j%10==5) n5++;
      else if(j%10==7) n7++;
      else break;
      j/=10;
    }
    if(j==0&&n3>0&&n5>0&&n7>0) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main() {
	int H, W; cin >> H >> W;
	char map[55][55];

	int dh[4] = { -1,0,0,1 };
	int dw[4] = { 0,-1,1,0 };
	rep(h,H) rep(w,W) cin >> map[h][w];
	rep(h, H) {
		rep(w, W) {
			if (map[h][w] == '.') continue;
			int cnt = 0;
			rep(i, 4) {
				int nh = h + dh[i];
				int nw = w + dw[i];
				if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
				if (map[nh][nw] == '.') cnt++;
			}
			if (cnt == 4) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

#define MAX_N 100
#define MAX_M (MAX_N * MAX_N)

typedef struct EDGE {
	int to;
	struct EDGE *next;
} edge;

int size;
edge buff[MAX_M];
edge *adj[MAX_N];

void add_edge(int u, int v) {
	edge *e = buff + size++;
	e->to = v;
	e->next = adj[u];
	adj[u] = e;
}

typedef int data_t;
data_t queue[MAX_N];
int head, tail;

void enqueue(data_t data) {
	queue[tail++] = data;
}

data_t dequeue() {
	return queue[head++];
}

bool empty() {
	return head == tail;
}

int dist[MAX_N];

void bfs(int s) {
	edge *e;

	memset(dist, -1, sizeof(dist));
	dist[s] = 0;
	enqueue(s);

	while(!empty()) {
		const int u = dequeue();
		for(e = adj[u]; e != NULL; e = e->next) {
			if(dist[e->to] == -1) {
				dist[e->to] = dist[u] + 1;
				enqueue(e->to);
			}
		}
	}
}

int main() {
	int n;
	int u, k;
	int i, j;
	int v;

	scanf("%d", &n);
	for(i = 0; i < n; ++i) {
		scanf("%d %d", &u, &k);
		for(j = 0; j < k; ++j) {
			scanf("%d", &v);
			add_edge(u - 1, v - 1);
		}
	}

	bfs(0);
	for(u = 0; u < n; ++u) {
		printf("%d %d\n", u + 1, dist[u]);
	}

	return EXIT_SUCCESS;
}



Measured memory_bytes: 2048
nmax = 2*10**6
mod = 10**9+7
fac = [1]*nmax
finv = [1]*nmax
inv = [1]*nmax
def ncr_pre():
    for i in range(2,nmax):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) %mod
        finv[i] = finv[i-1] * inv[i] %mod

def ncr(n,r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fac[n]* (finv[r] * finv[n-r] %mod) %mod
ncr_pre()

x,y = map(int,input().split())
a = (2*x-y)/3
b = (2*y-x)/3
if a.is_integer() and b.is_integer():
    a = int(a)
    b = int(b)
    print(ncr(a+b,b))
else:
    print(0)


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

int main() {
	string S, R;
	cin >> S;
	int n = S.size();
	for(int i = 0; i < n; i++) {
		if(S[i] == 'B') {
			if(R.size() > 0) R.pop_back();
		} else {
			R.push_back(S[i]);
		}
	}
	cout << R << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    ll n;
    cin >> n;
    string ans = "No";
    for (int i = 0; i < 3; i++)
    {
        if (n % 10 == 7)
        {
            ans = "Yes";
            break;
        }
        n /= 10;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <iostream>
#include <algorithm> 
using namespace std;
int main(){
	int i,j,k,l,m,n,ans=1000000;
	scanf("%d",&n);
	for(i=0;i<=n;i++){
	j=i;
	k=n-i;
	l=0;
	while(j){
	l+=j%6;
	j/=6;
	}
		while(k){
	l+=k%9;
	k/=9;
	}
	if(l<ans)ans=l;
	}
	printf("%d",ans);
	return 0;
	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=200005;
const int inf=0x3f3f3f3f;
int n,m,l,r;
vector<int> v[maxn];
struct node {
    int l,r,lz,mmax;
    inline void update(int v) {
        lz+=v;
        mmax+=v;
    }
} seg[maxn<<2];
inline void pushup(int x) {
    seg[x].mmax=max(seg[x<<1].mmax,seg[x<<1|1].mmax);
}
inline void pushdown(int x) {
    int lz=seg[x].lz;
    if (lz) {
        seg[x<<1].update(lz);
        seg[x<<1|1].update(lz);
        seg[x].lz=0;
    }
}
void build(int x,int l,int r) {
    seg[x].l=l,seg[x].r=r;
    if (l==r) {
        seg[x].mmax=l;
        return;
    }
    int m=(l+r)>>1;
    build(x<<1,l,m);
    build(x<<1|1,m+1,r);
    pushup(x);
}
void update(int x,int l,int r,int v) {
    int L=seg[x].l,R=seg[x].r;
    if (l<=L&&r>=R) {
        seg[x].update(v);
        return;
    }
    pushdown(x);
    int m=(L+R)>>1;
    if (m>=l)
        update(x<<1,l,r,v);
    if (m<r)
        update(x<<1|1,l,r,v);
    pushup(x);
}
int query(int x,int l,int r) {
    int L=seg[x].l,R=seg[x].r;
    if (l<=L&&r>=R)
        return seg[x].mmax;
    pushdown(x);
    int ret=-inf,m=(L+R)>>1;
    if (m>=l)
        ret=max(ret,query(x<<1,l,r));
    if (m<r)
        ret=max(ret,query(x<<1|1,l,r));
    pushup(x);
    return ret;
}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=0;i<n;++i) {
        scanf("%d%d",&l,&r);
        v[l].push_back(r);
    }
    build(1,0,m+1);
    int res=max(0,n-m);
    for (int i=0;i<=m+1;++i) {
        for (auto x:v[i])
            update(1,0,x,1);
        res=max(res,query(1,i+1,m+1)-m-i-1);
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 19072
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var s = ReadLine().Where((c, i) => i % 2 == 0).ToArray();
            WriteLine(string.Join("", s));
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28156
import java.util.*;

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

		long answer = 0;
		for (int i = 0; i < (1 << (l - 1)); i++) {
			String ss = s;
			for (int j = l - 1; j >= 0; j--) {
				if ((1 & (i >> j)) == 1) {
					ss = ss.substring(0, j+1) + "-" + ss.substring(j+1);
				}
			}
			String[] nums = ss.split("-");
			long sum = 0;
			for (int j = 0; j < nums.length; j++) {
				sum += Long.parseLong(nums[j]);
			}

			answer += sum;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 21588
#include <iostream> 
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    vector<int> x(5);
    for (int i = 0; i < 5; i++) {
        cin >> x[i];
        if (x[i] == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int a = 1; a <= n; ++a) {
    ans += (n-1)/a;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n,m;
  double total = 0;;
  vector<double> a(n);
  cin >> n >> m;
  rep(i,n) {
    cin >> a.at(i);
    total += a.at(i);
  }
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  if(a.at(m-1) < total/(4*m)) cout << "No" << endl;
  else cout << "Yes" << endl;  
}

Measured memory_bytes: 33024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = (int)1e9 + 7;
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mult(int x, int y) {
	return ((ll)x * y) % MOD;
}

const int N = 100100;
vector<int> pos[3];
int bal[N];
int dp[N];
char s[N];
int nxt[N];
int n;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%s", s);
	n = strlen(s);
	bal[0] = 0;
	for (int i = 0; i < n; i++) {
		bal[i + 1] = bal[i];
		if (s[i] == 'a')
			bal[i + 1] += 1;
		else
			bal[i + 1] += 2;
		bal[i + 1] %= 3;
	}
	for (int i = 0; i <= n; i++)
		pos[bal[i]].push_back(i);
	nxt[n] = nxt[n - 1] = n + 1;
	for (int i = n - 2; i >= 0; i--) {
		nxt[i] = nxt[i + 1];
		if (s[i] == s[i + 1])
			nxt[i] = i + 2;
	}
	int ans = 0;
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		dp[i + 1] = add(dp[i + 1], dp[i]);
		if (nxt[i + 1] == n + 1) {
			if (i < n - 1 && s[i] == s[i + 1])
				ans = add(ans, mult(dp[i], (n - i) / 2 - 1));
		}
		int want = bal[i];
		if (s[i] == 'a')
			want += 2;
		else
			want += 1;
		want %= 3;
		if (i == n - 1 || (bal[i] != bal[n] && nxt[i] <= n))
			ans = add(ans, dp[i]);
		int pp = lower_bound(pos[want].begin(), pos[want].end(), nxt[i]) - pos[want].begin();
		if (pp == (int)pos[want].size()) continue;
		int q = pos[want][pp];
		dp[q] = add(dp[q], dp[i]);
		if (q < n && nxt[q] == n + 1)
			ans = add(ans, mult(dp[i], (n - q - 1) / 2));
	}
/*
	for (int i = 0; i <= n; i++)
		printf("%d ", dp[i]);
	printf("\n");
*/
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 2172
# A,weather Prediction
# 高橋くんの住む街の天気は、一日ごとに晴れ（'Sunny'）くもり（'Cloudy'）、雨（'Rainy'）、くもり、雨と周期的に変化します。
# 今日の天気を表す文字列Sが与えられるので、明日の天気の予想をしてください。

# Sは、'Sunny','Cloudy','Rainy'のいずれかである

S = str(input())

# 明日の天気と同じ形式で出力せよ。

if S == 'Sunny':
    print('Cloudy')
elif S == 'Rainy':
    print('Sunny')
elif S == 'Cloudy':
    print('Rainy')

Measured memory_bytes: 8852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N; cin >> N;
  ll m = 100000; ll M = 0;
  ll a[N];
  for (ll i = 0; i < N; i++) {
    cin >> a[i];
    m = min(m,a[i]);
    M = max(M,a[i]);
  }
  if (M > m+1) {cout << "No" << endl; return 0;}
  if (M == m) {
    if (m == N-1 || (m <= N/2 && m >= 1)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  }
  ll n = 0;
  for (ll i = 0; i < N; i++) {
    if (a[i] == m) n++;
  }
  if (n > N-2) {cout << "No" << endl; return 0;}
  if (n+1 <= M && M <= n + (N-n)/2) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}

Measured memory_bytes: 1024
#pragma region include
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <map>
    #include <string>
    #include <queue>
    #include <stack>
    #include <cmath>
    #include <set>
    #include <cstdio>
    #define ALL(obj) (obj).begin(),(obj).end()
    #define RALL(obj) (obj).rbegin(),(obj).rend()
    #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 MOD 1000000007
    #define INF 1000000000
    #define LLINF 4000000000000000000
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef vector<int> VI;
    typedef vector<VI> VVI;
    #pragma endregion
     
    //#define __DEBUG__
    #ifdef  __DEBUG__
    #define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
    // vector出力
    template<typename T>
    ostream& operator << (ostream& os, vector<T>& v) {
        os << "{";
        REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
        os << "}";
        return os;
    }
    // pair出力
    template<typename T, typename U>
    ostream& operator << (ostream& os, pair<T, U>& p) {
        return os << "(" << p.first << ", " << p.second << ")";
    }
    // map出力
    template<typename T, typename U>
    ostream& operator << (ostream& os, map<T, U>& map_var) {
        os << "{";
        for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
            os << "(" << itr->first << ", " << itr->second << ")";
            itr++;
            if (itr != map_var.end()) os << ", ";
            itr--;
        }
        os << "}";
        return os;
    }
    // set 出力
    template<typename T>
    ostream& operator << (ostream& os, set<T>& set_var) {
        os << "{";
        for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
            os << *itr;
            ++itr;
            if (itr != set_var.end()) os << ", ";
            itr--;
        }
        os << "}";
        return os;
    }
    #endif
     
    //pow
    template<typename T>
    T pow(T k, T n) {
        T x = 1;
        while (n > 0) {
            if (n & 1) {
                x *= k;
            }
            k *= k;
            n >>= 1;
        }
        return x;
    }
     
    int main() {
        cin.tie(0); ios::sync_with_stdio(false);
        int N, K; cin >> N >> K;
        double ans = 0;
        int m = 0;
        for (int i = N; i >= 1; i--) {
            while (pow(0.5, (double)m) > (double)i / K) {
                m++;
            }
            ans += pow(0.5, (double)m) / N;
        }
        printf("%.12f\n", ans);
        getchar(); getchar();
    }

Measured memory_bytes: 256
import sys

n = int(input())
minv = int(input())
v = int(input())
maxv = v-minv
if v < minv: minv = v

for r in map(int,sys.stdin.readlines()):
  m = r-minv
  if maxv < m < 0:
    maxv = m
    minv = r
  elif maxv < m:
    maxv = m
  elif m < 0:
    minv = r

print(maxv)

Measured memory_bytes: 21852
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()



def main():
    R,C,N = LI()
    a = []
    def ff(x,y):
        if x == 0:
            return (0,y)
        if x == R:
            return (R,-y)
        if y == 0:
            return (R+1, -x)
        return (1, x)

    for _ in range(N):
        x1,y1,x2,y2 = LI()
        if (0 < x1 < R and 0 < y1 < C) or (0 < x2 < R and 0 < y2 < C):
            continue
        a.append((ff(x1,y1),_))
        a.append((ff(x2,y2),_))
    a.sort()
    b = [a[i][1] for i in range(len(a))]
    s = [None] * (len(b))
    si = -1
    for c in b:
        if si < -1:
            si += 1
            s[0] = c
            continue
        if s[si] == c:
            si -= 1
        else:
            si += 1
            s[si] = c

    if si > 1:
        return 'NO'
    return 'YES'

print(main())








Measured memory_bytes: 48000
#include<iostream>
using namespace std;
int main(){
  char a[50][50];
  char b[50][50];
  int n,m;
  cin >> n >> m;
  int i,j;
  for(i = 0;i<n;i++){
    for(j = 0;j<n;j++){
    	cin >> a[i][j];
    }
  }

  for(i = 0;i<m;i++){
    for(j = 0;j<m;j++){
    	cin >> b[i][j];
    }
  }
  int flag = 0, k, l;
  for(i = 0;i<=n-m;i++){
    for(j = 0;j<=n-m;j++){
      flag = 0;
      for(k = i;k<i + m;k++){
        for(l = j;l<j + m;l++){
        	if(a[k][l] != b[k - i][l - j]){
              flag = 1;
            }
        }
      }
      if(flag == 0){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
    
  cout << "No" << endl;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl;
#define CNO cout<<"No"<<endl;

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n,t,l,b;
    cin >> n >> t >> l >> b;
    if(n==0) return 0;
    vector<int> f(n+1,0);
    int x;
    rep(i,l){
      cin >> x;
      f[x]=1;
    }
    rep(i,b){
      cin >> x;
      f[x]=2;
    }
    vector<double> p(n+1,0),q(n+1,0),r(n+1,0);
    q[0]=1;
    rep(tt,t){
      rep(i,n){
        if(f[i]==0){
          rep(j,6){
            int idx = (i+j+1>=n?2*n-(i+j+1):i+j+1);
            if(f[idx]==2){
              r[0]+=q[i]/6;
            }else{
              r[idx]+=q[i]/6;
            }
          }
        }else if(f[i]==1){
          rep(j,6){
            int idx = (i+j+1>=n?2*n-(i+j+1):i+j+1);
            if(f[idx]==2){
              r[0]+=p[i]/6;
            }else{
              r[idx]+=p[i]/6;
            }
          }
        }
      }
      r[n]+=q[n];
      p=q;
      q=r;
      r=vector<double>(n+1,0);
    }
    cout << fixed << setprecision(10) << q[n] << endl;
  }
  return 0;
}



Measured memory_bytes: 3112
mi = lambda: map(int, input().split())
n, k = mi()
sushis = [list(mi()) for _ in range(n)]
types = set()
sushis.sort(key = lambda x: x[1], reverse = True)
bp = tp = sp = 0
exts = []
for t, d in sushis[:k]:
    bp += d
    if t in types:
        exts += d,
    else:
        types.add(t)
        tp += 1
sp = bp+tp**2
for t, d in sushis[k:]:
    if not exts: break
    if t not in types:
        types.add(t)
        bp += d-exts.pop()
        tp += 1
        sp = max(sp, bp+tp**2)
print(sp)

Measured memory_bytes: 69592
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
long long nn[301][301] = {0};
int main()
{
	int n;
	scanf("%d",&n);
	int t,t1,t2;
	for(t=1;t<=n;t++)
		for(t1=1;t1<=n;t1++)
			scanf("%d",&nn[t][t1]);
	for(t=1;t<=n;t++)
		for(t1=t+1;t1<=n;t1++)
			for(t2=t1+1;t2<=n;t2++)
			{
				if(nn[t][t1]+nn[t][t2] == nn[t1][t2])
					nn[t2][t1] = 0;
				else if(nn[t][t1]+nn[t1][t2] == nn[t][t2])
					nn[t2][t] = 0;
				else if(nn[t][t2]+nn[t1][t2] == nn[t][t1])
					nn[t1][t] = 0;
				if(nn[t][t1]+nn[t][t2]<nn[t1][t2] || nn[t][t1]+nn[t1][t2]<nn[t][t2] || nn[t][t2]+nn[t1][t2]<nn[t][t1])
				{
					printf("-1\n");
					return 0;
				}
			}
	long long sum=0;
	for(t=1;t<=n;t++)
		for(t1=1;t1<t;t1++)
			sum += nn[t][t1];
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
ll INF = 10010001010;

ll lcm(ll a,ll b)
{
    return a * b / __gcd(a, b);
}

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

int main(){
    int A, P;
    cin >> A >> P;
    cout << ((A * 3) + P) / 2 << endl;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	double r;
	cin >> r;
	double ans = PI * 2 * r;
	printf("%.6f\n", ans);
}


Measured memory_bytes: 3800
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int n;
int ar[N];
map < int , int > cnt;

int main(){
    scanf("%d" , &n);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &ar[i]);
        cnt[ar[i]]++;
    }
    sort(ar + 1 , ar + n + 1);
    reverse(ar + 1 , ar + n + 1);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int x = ar[i];
        if(!cnt[x])
            continue;
        cnt[x]--;
        bool done = 0;
        for(int j = 30; j >= 0; j--){
            int pw = (1 << j) - x;
            if(pw > 0 && cnt[pw]){
                cnt[pw]--;
                ans++;
                done = 1;
                break;
            }
        }
        if(!done)
            cnt[x]++;
    }
    printf("%d\n" , ans);
}

Measured memory_bytes: 29824
#include <stdio.h>
int main(void) {
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a<b){a^=b;b^=a;a^=b;}
  if(b<c){b^=c;c^=b;b^=c;}
  if(a<b){a^=b;b^=a;a^=b;}
  printf("%d\n",a*10+b+c);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<stdlib.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)

int main(){
    int N;
    int ans = 0;;
    scanf("%d",&N);
    char S[N+1];
    scanf("%s",S);
  for(int i=0;i<N;i++){
    if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
      ans += 1;
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128