akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin >> n >> s;
    ll l = 0,r = 0,a = 0,b = 0;
    rep(i,n){
        if (s[i] == '('){
            l++;
        }
        else{
            r++;
            if (l > 0){
                l--;
                r--;
            }
        }
        if (s[n-i-1] == ')'){
            a++;
        }
        else{
            b++;
            if (a > 0){
                a--;
                b--;
            }
        }
    }
    rep(i,r) s = '('+s;
    rep(i,b) s += ')';
    PRINT(s);
}




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;



int main() {
	int n,sum=0,tmp=0;
	string S;
	set<char> x, y;
	cin >> n >> S;
	for (int i = 1; i < n; i++) {
		tmp = 0;
		for (auto s : S.substr(0, i)) {
			x.insert(s);
		}
		for (auto s : S.substr(i, n - i)) {
			y.insert(s);
		}
		for (auto c : x) {
			if (y.count(c))tmp++;
		}
		x.clear(); y.clear();
		sum = max(sum, tmp);
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
n *= 2
ans = []
ans2 = []
for i in range(2,32*10**6):
  if n % i == 0:
    ans.append(i)
    n //= i
    cnt = 1
    while n % i == 0:
      n //= i
      cnt += 1
    ans2.append(cnt)
if n != 1:
  ans.append(n)
  ans2.append(1)
#print(ans)
#print(ans2)
l = len(ans)
for i in range(l):
  ans[i] **= ans2[i]
#print(ans)
if len(ans) == 1:
  print(ans[0]-1)
  exit()
time = [0 for _ in range(l)]
def nex(time):
  for i in range(l):
    if time[i] == 0:
      time[i] = 1
      return time
    else:
      time[i] = 0
  else:
    return 'over'
can = []
while time != 'over':
  x = 1
  y = 1
  for i in range(l):
    if time[i] == 0:
      x *= ans[i]
    else:
      y *= ans[i]
  #print(x,y)
  X = int(x)
  Y = int(y)
  if x > y:
    rec = []
    while y != 1:
      rec.append(x//y)
      x,y = y,x%y
    #print(rec)
    if rec:
      le = len(rec)
      rec.reverse()
      now = [1,-rec[0]]
      for j in range(1,le):
        #print(now)
        now[0],now[1] = now[1],now[0]-now[1]*rec[j]
      #print(now)
      #print(min(abs(X*now[0]),abs(Y*now[1])))
      can.append(min(abs(X*now[0]),abs(Y*now[1])))
  time = nex(time)
print(min(can))

Measured memory_bytes: 68772
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod = 1e9+9;
const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    rep(i,n){
        cout << "ACL";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ln = (1+sqrt(8*n+1))/2;
    int sm = (ln * (ln+1))/2;
    for(int i=1;i<=ln;i++){
        if(sm-n != i) cout << i << endl;
    }
}


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

int main(void){
  int i;
  int A,B;
  scanf("%d %d\n",&A,&B );
  for(i = 1;i < 1101;i++){
    if((i *8/100 == A) && (i /10 == B)){
      printf("%d\n", i);
      exit(0);
    }
  }
  printf("-1\n");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main(){
    char a[20],b[20],c[20];
    cin>>a>>b>>c;
    cout<<char(a[0]-('a'-'A'))<<char(b[0]-('a'-'A'))<<char(c[0]-('a'-'A'))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[100010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	ll ans = A[0] / 2;
	A[0] %= 2;
	for (int i = 1; i < N; i++) {
		ans += min(A[i - 1], A[i]);
		A[i] -= min(A[i - 1], A[i]);
		ans += A[i] / 2;
		A[i] %= 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include "iostream"
#include "math.h"
using namespace std;

int N;
long long int ans;

int main() {
	cin >> N;
	ans = 3;
	for (int i = 1; i <= N; i++) {
		ans *= 2;
		ans++;
	}
	cout << ans-1 << "\n";
	return 0;
}

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

signed main(){
    int n,m;
    cin >> n >> m;
    int h[n];
    rep(i,n){
        int hh;
        cin >> hh;
        h[i]=hh;
    }
    vector<vector<int>> G(n);

    rep(i,m){
        int aa,bb;
        cin >> aa >> bb;
        aa--;
        bb--;
        G[aa].push_back(bb);
        G[bb].push_back(aa);
    }

    int c=0;
    rep(i,n){
        bool z=false;
        for(auto x:G[i]){
            if(h[i]<=h[x]){
                z=true;
                break;
            }
        }
        if(!z){
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 9812
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	ll K, X;
	cin >> K >> X;

	if (500 * K < X)
	{
		cout << "No" << '\n';
	}
	else
	{
		cout << "Yes" << '\n';
	}


	return 0;
}


Measured memory_bytes: 256
use std::collections::HashMap;
use std::io;

fn main() {
    let n = parse_line::<usize>();
    let mut counter: HashMap<String, usize> = HashMap::new();
    for _ in 0..n {
        let si = parse_line::<String>();
        let c = counter.entry(si).or_insert(0);
        *c += 1;
    }
    let max_count = counter.values().max().unwrap();
    //println!("{:?}", counter);
    //println!("{}", max_count);
    let mut vec = Vec::new();
    for (k, v) in counter.iter() {
        if v == max_count {
            vec.push(k);
        }
    }
    vec.sort();
    for item in vec {
        println!("{}", item);
    }
}

/// Parse line from io::stdin into T Value
fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 20408
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();
        String s[] = S.split("");
        String ans="";
        if(S.length()<=K)
        {
            System.out.println(S);
        }
        else
        {
            for(int i=0;i<K;i++)
            {
                ans += s[i];
            }
            System.out.println(ans+"...");
        }
    }
}


Measured memory_bytes: 40028
/* ex3_4
   urah  */

#include <stdio.h>

int main(void){
    int num, num_init;

    // 入力を受け取る
    scanf("%d", &num);

    // numの初期値を保持しておく
    num_init = num;

    // ループを使って解く
    for (int i=1; i <= 9; i++) {
        // 一回でも1~9で割り切れた場合
        if (num % i == 0) { 
            num = num / i;
            for (int j = 1; j <= 9; j++){
                // 商は1~9のいずれかであるか
                if (num == j) {
                    printf("Yes\n");
                    return 0;
                }
            }
            // numをiで割っているのでもとに戻す
            num = num_init;
        }
    }

    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
for i in range(input()):
    s, g = map(int, raw_input().split())
    if s < g:
        res = range(s, g+1)
    elif 0 <= s <= 5 and 0 <= g <= 5:
        res = range(s, g-1, -1)
    else:
        res = range(s, 10)
        if 0 <= g <= 5:
            res.extend(range(5, g-1, -1))
        else:
            res.extend(range(5, -1, -1))
            res.extend(range(1, g+1))
    print ' '.join(map(str, res))

Measured memory_bytes: 4228
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define ii tuple<int, int>
#define iii tuple<int, int, int>
#define M 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli a, b, c, d;
    cin>>a>>b>>c>>d;
    if(ceil((float)c/b)<=ceil((float)a/d))
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
 
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x[ohara],y,sum,pos;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll dp[100][100][50*50+100];
 
//-------------------------↓↓↓↓↓↓------------------------
 
int main(void){
        cin.tie(0);
        cout.tie(0);
    ios::sync_with_stdio(false);
 
    cin>>n>>a;
    rep(i,n)cin>>x[i];
    dp[1][1][x[0]]=1;
    dp[1][0][0]=1;
    rrep(i,2,n+1){
        rep(j,n+1){
            rep(k,50*50+1){
                if(j==0||k<x[i-1]){
                    dp[i][j][k]+=dp[i-1][j][k];
                }
                else dp[i][j][k]+=dp[i-1][j-1][k-x[i-1]]+dp[i-1][j][k];
            }
        }
    }
    rep(i,n+1){
        ans+=dp[n][i][a*i];
    }
    Cout(ans-1);
    return 0;
}

Measured memory_bytes: 104704
#include<iostream>
using namespace std;
int main()
{
  int N,K;
  cin>>N>>K;
  char S[N];
  for(int i=0;i<N;i++)
  {
    cin>>S[i];
  }
  
  S[K-1]=tolower(S[K-1]);
  
  for(int i=0;i<N;i++)
  {
    cout<<S[i];
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int dist=800;
	for(int i=0;i<s.size()-2;i++){
		int x=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
		dist=min(dist,abs(753-x));
	}
	cout<<dist;
	return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int x,y,ans,Min;
int main() {
	scanf("%3d",&x);
	Min = abs(753-x);
	while (scanf("%1d",&y) != EOF) {
		x = (x*10+y)%1000;
		if (abs(753-x) < Min) Min = abs(753-x);
	}
	printf("%d",min(Min,753));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
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(){
    ll H,W;
    cin>>H>>W;
    ll A,B;
    ll ans=H*W;
    if(H%2==0){
        A=H/2;
        B=H/2;
    }
    else{
        A=(H+1)/2;
        B=H-A;
    }
    for(int i=1;i<W;i++){
        ll S1=A*i;
        ll S2=B*i;
        ll S3=(W-i)*H;
        ll SMm=max(S1,max(S2,S3))-min(S1,min(S2,S3));
        ans=min(ans,SMm);
    }
    if(W%2==0){
        A=W/2;
        B=W/2;
    }
    else{
        A=(W+1)/2;
        B=W-A;
    }
    for(int i=1;i<H;i++){
        ll S1=A*i;
        ll S2=B*i;
        ll S3=(H-i)*W;
        ll SMm=max(S1,max(S2,S3))-min(S1,min(S2,S3));
        ans=min(ans,SMm);
    }
    if(H>=3){
        if(H%3==0){
            ans=0;
        }
        else{
            ans=min(ans,W);
        }
    }
    if(W>=3){
        if(W%3==0){
            ans=0;
        }
        else{
            ans=min(ans,H);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
dp = [dict() for i in range(2)]

big = 10 ** 9 + 7

for a in ['A', 'C', 'G', 'T']:
    for b in ['A', 'C', 'G', 'T']:
        for c in ['A', 'C', 'G', 'T']:
            seq = a + b + c
            if seq != 'AGC' and seq != 'GAC' and seq != 'ACG':
                dp[0][seq] = 1
            else:
                dp[0][seq] = 0

def sum_of_dict(d):
    ans = 0
    for a in ['A', 'C', 'G', 'T']:
        for b in ['A', 'C', 'G', 'T']:
            for c in ['A', 'C', 'G', 'T']:
                seq = a+b+c
                ans += d[seq]
    return ans

def sum_of_dict_with(d, latter):
    ans = 0
    for a in ['A', 'C', 'G', 'T']:
        seq = a+latter
        ans += d[seq]
    return ans

for i in range(3, N):
    n = i % 2
    for a in ['A', 'C', 'G', 'T']:
        for b in ['A', 'C', 'G', 'T']:
            for c in ['A', 'C', 'G', 'T']:
                seq = a + b + c
                if seq == 'AGC' or seq == 'GAC' or seq == 'ACG':
                    dp[n][seq] = 0
                elif seq == 'TGC':
                    dp[n][seq] = (sum_of_dict_with(dp[(n-1)%2], seq[:2]) - dp[(n-1)%2]['ATG']) % big
                elif seq == 'GGC':
                    dp[n][seq] = (sum_of_dict_with(dp[(n-1)%2], seq[:2]) - dp[(n-1)%2]['AGG']) % big
                elif seq == 'GTC':
                    dp[n][seq] = (sum_of_dict_with(dp[(n-1)%2], seq[:2]) - dp[(n-1)%2]['AGT']) % big
                else:
                    dp[n][seq] = (sum_of_dict_with(dp[(n-1) % 2], seq[:2])) % big

print(sum_of_dict(dp[(N-1)%2]) % big)


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

typedef long long ll;

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

    for(int i=0;;i++){
        int h,w; 
        cin >> h >> w;
        if(h==0 && w==0) break;
        for(int j=0;j<h;j++){
            for(int k=0;k<w;k++){
                if((j+k)%2==0) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();

		int r = n / 11 - 1;
		int m = n % 11 + 11;

		long ret = 0;
		if (r > 0) {
			ret += cnt(13, k) * r;
			ret += cnt(m, k);
		} else {
			ret += cnt(n, k);
		}

		pr.println(ret);
	}

	private static long cnt(int n, int k) {
		long ret = 0;

		int base = (1 + 2 + 3 + 8 + 9 + 10 + 15 + 16 + 17) % 11;
		for (int i = 0; i + 2 < n; i++) {
			for (int j = 0; j + 2 < 7; j++) {
				if ((base + j * 9) % 11 == k) {
					ret++;
				}
			}

			base += 63;
			base %= 11;
		}

		return ret;
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

const int INF = 1000000000;
const int MAXN = 100013;

int N, M;
int arr[MAXN];
vi edge[MAXN];
bitset<MAXN> vis;
int ans[2 * MAXN];
map<int, int> eid[MAXN];
bitset<MAXN> color;
vi ord;

void dfs(int u)
{
    vis[u] = true;
    for (int v : edge[u])
    {
        if (vis[v]) continue;
        if (arr[v] != arr[u]) continue;
        if (arr[v] == arr[u])
        {
            color[v] = !color[u];
            ans[eid[u][v]] = arr[v];
            // cerr << "ans" << u << ',' << v << ' ' << arr[v] << endl;
        }
        dfs(v);
    }
}
bool cmp(int i, int j)
{
    return (arr[i] < arr[j]);
}

int32_t main()
{
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(4);
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N >> M;
    FOR(i, 0, N)
    {
        cin >> arr[i];
    }
    FOR(i, 0, M)
    {
        int u, v;
        cin >> u >> v; u--; v--;
        edge[u].PB(v);
        edge[v].PB(u);
        eid[u][v] = i;
        eid[v][u] = i;
        ans[i] = INF;
    }
    FOR(i, 0, N)
    {
        int mn = INF;
        for (int x : edge[i])
        {
            ckmin(mn, arr[x]);
        }
        if (mn > arr[i])
        {
            cout << "-1\n";
            return 0;
        }
    }
    //its min neighbor is <= it.
    FOR(i, 0, N)
    {
        int mn = INF;
        for (int x : edge[i])
        {
            ckmin(mn, arr[x]);
        }
        if (mn > arr[i])
        {
            cout << "-1\n";
            return 0;
        }
        if (mn == arr[i] && !vis[i])
        {
            dfs(i);
        }
    }
    ord.resize(N);
    FOR(i, 0, N) ord[i] = i;
    sort(ALL(ord), cmp);
    for (int u : ord)
    {
        for (int v : edge[u])
        {
            if (vis[v]) continue;
            vis[v] = true;
            color[v] = color[u];
            // cerr << "ans " << u << ' ' << v << ' ' << ans[eid[u][v]] << endl;
            ans[eid[u][v]] = arr[v] - arr[u];
        }
    }
    FOR(i, 0, N)
    {
        cout << (color[i] ? 'B' : 'W');
    }
    cout << '\n';
    FOR(i, 0, M)
    {
        cout << ans[i] << '\n';
    }
    return 0;
    //if it has a neighbor w same value as it, just color em opposite colors and go.
    //otherwise, put it 1 + any friendly color.
    //otherwise,
}


Measured memory_bytes: 34560
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
                int n = Integer.parseInt(line);
                String[] s = new String[n];
                for(int i=0; i<n; i++){
                    s[i] = br.readLine();
                }
                int r = 0;
                for(int a=0; a<n; a++){
                    boolean flag = true;
                    String[] sa = new String[n];
                    for(int i=0; i<n; i++){
                        sa[i] = s[i].substring(a,n)+s[i].substring(0,a);
                    }
                    sq:for(int i=0; i<n; i++){
                        //int k = (i+a)%n;
                        for(int j=i+1; j<n; j++){
                            if(sa[i].charAt(j) != sa[j].charAt(i)){//(s[k].charAt(j) != s[j].charAt(k)){
                                flag = false;
                                break sq;
                            }
                        }
                    }
                    if(flag) r++;
                }
                System.out.println(r*n);
            }
        }
    }
}

Measured memory_bytes: 102376
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define why 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
    return (x&(-x));
}
void solve(){
    int n; cin>>n;
    double p[n];
    double dp[n+1][n+1];
   double ans=0.0;
    for(int i=0; i<n; ++i)
        cin >> p[i];
    dp[0][0]=1.0;
    for(int i=0; i<n; ++i)
        for(int j=0; j<=i; ++j) {
            dp[i+1][j+1]+=dp[i][j]*p[i];
            dp[i+1][j]+=dp[i][j]*(1-p[i]);
        }
    for(int j=(n+1)/2; j<=n; ++j)
        ans+=dp[n][j];
    cout << fixed << setprecision(16) << ans;
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
        solve();
    }
}

Measured memory_bytes: 70528
#include<stdio.h>
int selectionSort(int A[],int N){
  int i,j,t,sw=0,minj;
  for(i=0;i<N-1;i++){
    minj = i;
    for(j=i;j<N;j++){
      if(A[j] < A[minj])minj = j;
    }
    t=A[i];
    A[i]=A[minj];
    A[minj]=t;
    if(i!=minj)sw++;
  }
  return sw;
}
int main(){
  int A[100],N,i,sw;
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);
  sw = selectionSort(A,N);
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",sw);
  return 0;
}



Measured memory_bytes: 2108
S=`dd`
n=S.size
c=0
a=0
(n-1).downto(0){|i|
if S[i]=="A" then
    a+=c
elsif i>0&&S[i-1]=="B"&&S[i]=="C"
    c+=1
elsif !(S[i]=="B"&&S[i+1]=="C")
    c=0
end
}
p a

Measured memory_bytes: 2296
#include <cstdio>

long long a, b, n;

int main()
{
	scanf("%lld%lld%lld", &n, &a, &b);
	printf("%lld\n", n / (a + b) * a + (n % (a + b) > a ? a : n % (a + b)));
	return 0;
}

Measured memory_bytes: 128
N,M = map(int,input().split())
key = [0] * (N+1)
tmp_R = 10 ** 5
tmp_L = 1
for _ in range(M):
    L,R = map(int,input().split())
    if L >= tmp_L:
        tmp_L = L
    if R <= tmp_R:
        tmp_R = R
ans = tmp_R - tmp_L + 1
if ans < 0:
    print(0)
else:
    print(ans)



Measured memory_bytes: 3828
#include <iostream>
#include <string>
using namespace std;
int main(void){
	string s;
	int x[26] = {};
	while(getline(cin,s) ){
		for(int i = 0;i < s.size();i++){
			char c = s.at(i);
			c = tolower(c);
			x[c - 'a']++;
		}
	}
	
	for(int i = 0;i < 26;i++){
		cout << char(i+'a') <<" : "<< x[i] << endl;
	}
	return 0;
}


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

using namespace std;

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

typedef vector<int> vi;

int n, s;

//??????p????????¶ c???????????°??? sum????¨?
int dfs(int p, int c, int sum) {
	if (c == 10) return p == 0 && sum == s;
	
	return dfs(p - 1, c + 1, sum + c) + dfs(p, c + 1, sum);
}

int main() {
	while (true) {
		cin >> n >> s;
		if (!n && !s) break;
		
		cout << dfs(n, 0, 0) << endl;
	}
	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    double x;
    cin >> x;
    ll now = 100;
    ll ans = 0;
    while(now < x){
        now = (ll)((double)now)*1.01;
        ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3744
n,m = list(map(int,input().split()))
l_list = [list(map(int,input().split())) for i in range(m)] 
p = list(map(int,input().split()))
output = 0

for i in range(2 ** n):
  lights = []
  for j in range(n+1):
    if ((i >> j) & 1):
      lights.append(j+1)
      
  for inde, l in enumerate(l_list):
    if len(set(l[1:]) & set(lights)) % 2 != p[inde]:
      break
  else:
    output += 1
print(output)

Measured memory_bytes: 92836
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
const int N = 2005;
int n, a[N];
bool g[N][N], vis[N];
vector <int> merge(vector <vector <int> > a) {
	vector <int> ans;
	priority_queue <vector <int> > pq;
	for (int i = 0; i < a.size(); ++ i)
		pq.push(a[i]);
	while (!pq.empty()) {
		vector <int> tmp = pq.top(); pq.pop();
		ans.push_back(tmp[0]);
		tmp.erase(tmp.begin());
		if (tmp.size()) pq.push(tmp);
	}
	return ans;
}
vector <int> dfs(int u) {
	vis[u] = 1;
	vector <vector <int> > tmp;
	for (int i = 0; i < n; ++ i) if (g[u][i] && !vis[i]) tmp.push_back(dfs(i));
	vector <int> ans = merge(tmp);
	ans.insert(ans.begin(), a[u]);
	return ans;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i) scanf("%d", &a[i]);
	sort(a, a + n);
	for (int i = 0; i < n; ++ i) for (int j = i + 1; j < n; ++ j) if (__gcd(a[i], a[j]) != 1) g[i][j] = g[j][i] = 1;
	vector <vector <int> > tmp;
	for (int i = 0; i < n; ++ i) if (!vis[i]) tmp.push_back(dfs(i));
	vector <int> ans = merge(tmp);
	for (int i = 0; i < ans.size(); ++ i) printf("%d%c", ans[i], " \n"[i + 1 == ans.size()]);
	return 0;
}


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

int dp[1001];
int main() {
    int W, N; int T = 0;
    while(~scanf("%d%d", &W, &N) && W) {
        memset(dp, 0, sizeof(dp));
        rep(i, N) {
            int v, w; scanf("%d,%d", &v, &w);
            for(int j = W; j - w >= 0; --j)
              dp[j] = max(dp[j], dp[j - w] + v);
        }
        pair<int, int> ans(0, 0);
        rep(i, W + 1) ans = max(ans, make_pair(dp[i], -i));
        printf("Case %d:\n%d\n%d\n", ++T, ans.first, -ans.second);
    }
    return 0;
}

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

vector<long long> hs, ps;
long long solve(long long N, long long X) {
  long long mid = hs[N] / 2;
  cerr << N << " " << mid << " " << X << endl;
  // 全部食べ切る
  if (X == hs[N] - 1) return ps[N];
  // 一番下はB
  if (X == 0) return 0;
  // それ以外
  // ちょうど真ん中なのでN-1バーガー分とmidの位置の分
  if (X == mid) return ps[N - 1] + 1;
  else if (X <= mid) {
    // 真ん中より小さい時
    // 一番下はBなので，Xを一つ下にずらして，N-1バーガー中で解く
    return solve(N - 1, X - 1);
  } else {
    // + 真ん中より下分のバーガーに含まれるP
    return solve(N - 1, X - mid - 1) + ps[N - 1] + 1;
  }
}

// パティの数
// 1
// 3  (= 1*2 + 1)
// 7  (= 3*2 + 1)
// 15 (= 7*2 + 1)

// 高さ
// 1
// 5 (1*2 + 3)
// 13 (5*2 + 3)

int main(void) {
  long long N, X;
  cin >> N >> X;
  long long h = 1, p = 1;
  hs.push_back(h);ps.push_back(p);
  for (int i = 0; i < N; i++) {
    h = h * 2 + 3;p = p * 2 + 1;
    hs.push_back(h);ps.push_back(p);
  }
  cout << solve(N, X - 1) << endl;
  return 0;
}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  int ans = (max(4 - X, 0) + max(4 - Y, 0)) * 100000;
  if (X == 1 && Y == 1)
    ans += 400000;
  cout << ans << endl;
}

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

#define ll long long 
#define MOD 1000000007

int candies(const vector<int>& v, int k, int n) {
	ll dp[n+2][k+2];
	for (int j = 0; j <= k; ++j) {
		dp[1][j] = (j > v[1]) ? 0 : 1 ;
	}

	for (int i = 2; i <= n; ++i)
	{
		for (int j = 0; j <= k; ++j)
		{
			if(j==0) {
				dp[i][j] = dp[i-1][j];
			} else {
				dp[i][j] = ((dp[i][j-1] + dp[i-1][j])%MOD + MOD - ((j-v[i]-1>=0) ? dp[i-1][j-v[i]-1] : 0)) % MOD;
			}
		}
	}


	return dp[n][k];
}

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

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

    cout << candies(v,k,n);

    return 0;
}

Measured memory_bytes: 78720
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int,int> Pi;
const ll inf = 1e18 + 1;
const ll limit = 1e9;

int main() {
    int n,m; cin >> n >> m;
    vector<int> v(n+1,-1);
    bool ok = true;
    for (int i = 0; i < m; i++) {
        int s,c; cin >> s >> c;
        if (v[s] == -1) {
            v[s] = c;
        } else if (v[s] != -1 && v[s] != c) ok = false;
    }
    if (n != 1 && v[1] == 0) ok = false;
    if (n == 1) {
        if (v[1] == -1) v[1] = 0;
        if (ok) cout << v[1] << "\n";
        else cout << -1 << "\n";
    } else if (ok) {
        if (v[1] == -1) v[1] = 1;
        cout << v[1];
        for (int i = 2; i <= n; i++) {
            if (v[i] == -1) v[i] = 0;
            cout << v[i];
        }
        cout << "\n";
    } else cout << -1 << "\n";
}   
 

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

int main() {
    int N, four = 0, two = 0, odd = 0;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
        if (A[i] % 4 == 0 ) four++;
        else if (A[i] % 2 == 0) two++;
        else odd++;
    }

    if(N / 2 <= four) cout << "Yes" << endl;
    else if(N / 2 <= odd) cout << "No" << endl;
    else if(four + two / 2 >= N / 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int inf = 2147483647;
const int mod = 1e9 + 7;
const int N = 5e3 + 1;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I LL read() {
	LL x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

I int pow_mod(reg a, reg k) {reg ans = 1; for(; k; k >>= 1, a = (LL)a * a % mod) if(k & 1) ans = (LL)ans * a % mod; return ans;}

int f[N][N], g[N];

int main() {
	reg n = read(), m = read();
	fo(i, 1, m) f[0][i] = 1;
	fo(i, 1, n) {
		reg s = 0;
		fo(j, 1, m) f[i][j] = ((LL)f[i - 1][j] * (j + 1) + s) % mod, s = (2LL * s + (LL)f[i - 1][j] * j) % mod;
	} pr2(f[n][m] < 0 ? f[n][m] + mod : f[n][m]);
	return 0;
}



Measured memory_bytes: 101292
const main = stdin => {
  const input = stdin.trim().split('\n')
  const S = input[0]

  let ans = 99999999
  for (let i = 0; i < S.length - 2; i++) {
    ans = Math.min(Math.abs(parseInt(S.substr(i, 3)) - 753), ans)
  }

  console.log(ans)
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29492
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n;
	cin>>n;
	int arr[n];
	vector<pair<int,int>>move;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	//int c=0;
	int max=-1000006,min=1000006,maxind=0,minind=0;
	for(int i=0;i<n;i++)
	{
		if(max<arr[i])
		{
			max=arr[i];
			maxind=i;
		}
		if(min>arr[i])
		{
			min=arr[i];
			minind=i;
		}
	}
	cout<<2*n-1<<"\n";
	if(abs(max)<abs(min))
	{
		for(int i=0;i<n;i++)
			cout<<minind+1<<" "<<i+1<<"\n";
		for(int i=n-1;i>0;i--)
			cout<<i+1<<" "<<i<<"\n";
	}
	else
	{
		for(int i=0;i<n;i++)
			cout<<maxind+1<<" "<<i+1<<"\n";
		for(int i=0;i<n-1;i++)
			cout<<i+1<<" "<<i+2<<"\n";
	}
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll w,h,l,m;
 sc(w);sc(h);sc(l);sc(m);
 bool ans=false;
 double s=(double)w*(double)h/2.000000000;
 if(w==2*l&&h==m*2)ans=true;
 printf("%lf %d\n",s,ans);  
return 0;}

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

int main(){
	int a,b,c,ans;
	cin >> a;
	cin >> b;
	cin >> c;
	ans = 0;
	for(int i = a;i <= b;i++){
		if(c%i == 0){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3100
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	ll N;
	cin >> N;
	vector<ll> vec(N);
	rep(i, N) cin >> vec[i];

	ll ans = 9223372036854775807;

	rep(i, 100)
	{
		ll temp = 0;
		rep(j, N)
		{
			temp += pow(vec[j] - i, 2);
		}
		if (temp < ans) ans = temp;
	}

	cout << ans << '\n';

	return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i=0;i<n;i++){
    cin>>a.at(i);
  }
  for (int i=0;i<n;i++){
    int tmp=a.at(i);
    b.at(tmp-1)=i;
  }
  for (int i=0;i<n;i++){
    cout<<b.at(i)+1;
    if (i==n-1){
      cout<<endl;
    }else{
      cout<<' ';
    }
  }
}

Measured memory_bytes: 1664
N, K = map(int, input().split())
A = []
for _ in range(K):
    d = int(input())
    A.append(list(map(int, input().split())))
nusuke = [i+1 for i in range(N)]
N_nusuke = [0 for i in range(N)]
for a in A:
    for i in range(len(a)):
        N_nusuke[a[i]-1] += 1
print(N_nusuke.count(0))

Measured memory_bytes: 9072
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0578 : Signboard **/
int main()
{
	int N; string s;
	cin>>N>>s;
	
	int ans = 0;
	rep(z, N) {
		string t; cin>>t;
		REP(i, 1, 101) {
			bool ok=false;
			
			rep(j, t.size()) {
				int k=j;
				int idx=0;
				
				while (k<t.size()) {
					if (t[k] == s[idx]) {
						idx++;
					} else {
						break;
					}
					
					if (idx == s.size()) {
						ok = true;
						break;
					}
					
					k += i;
				}
			}
			
			if (ok) {
				ans++;
				break;
			}
		}
	}
	
	cout << ans << endl;
}

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

#define MAX_N 100000

int DP[MAX_N];

int N;

int INF = 1000000000;

int max(int a, int b) {
	if (a > b) return a;
	return b;
}
int min(int a, int b) {
	if (a < b) return a;
	return b;
}
int abs(int a) {
	if (a < 0) a *= -1;
	return a;
}

int main(void) {
	scanf("%d", &N);
	std::vector<int> H;
	for (int i = 0; i < N; ++i) {
		int h;
		scanf("%d", &h);
		H.push_back(h);
		DP[i] = INF;
	}
	DP[0] = 0;
	for (int i = 0; i < N; ++i) {
		int next = i + 1;
		int nextnext = i + 2;
		if (next < N) {
			DP[next] = min(DP[next], DP[i] + (abs(H[i] - H[next])));
		}
		if (nextnext < N) {
			DP[nextnext] = min(DP[nextnext], DP[i] + (abs(H[i] - H[nextnext])));
		}
	}
	printf("%d", DP[N - 1]);
	return 0;
}


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

int main() {
  int N, L;
  scanf("%d%d", &N, &L);

  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }

  sort(S.begin(), S.end());

  string ans;
  for (auto s : S) ans += s;
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      int A=int.Parse(str[0]);
      int B=int.Parse(str[1]);
      int C=int.Parse(str[2]);
      if((B/A)>=C){
        Console.WriteLine(C);
      }else{
        Console.WriteLine(B/A);
      }
    }
    
  }

}


Measured memory_bytes: 27500
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,n) for(ll i=0;i<n;i++)
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

int main(){
    fast;
    ll x[5],ans;
    for(ll i=0;i<5;i++){
        cin>>x[i];
        if(x[i] == 0){
            ans=i;
        }
    }
    cout<<ans+1<<endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S; cin >> S;
	int an = 0;
	for (int i = 0; i < 6; i++)
	{
		if (S[i] == '1') an++;
	}
	cout << an << endl;
}

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

signed main(void){ 
  
  int n,k; cin >> n >> k;
  
  vector<int> to(n);
  
  for(int i = 0; i < n; i++){ 
    int a; cin >> a; 
    a--; 
    to[i] = a;
  }
  
  vector<int> visited(n,-1);
  int pos = 0;
  visited[0] = 0;
  
  int lp,lt1,lt2;
  
  int time = 0;
  
  while(true){ 
    
    int npos = to[pos];
    time++;
    
    if(visited[npos] != -1){ 
      //すでに訪れたことがある
      
      lp = npos;
      lt1 = visited[npos];
      lt2 = time;
      break;
      
    }
    
    visited[npos] = time;
    
    pos = npos;
  }
  //ここまでは大丈夫なはず
  
  if(false){ 
  cout << lp << " " << lt1 << " "<< lt2 << endl;
  }

  
  if( k <= lt1 ){ 
    
    //愚直にシミュレートしていったほうが早い
    
    int now = 0;
    while(k>0){ 
      int nnow = to[now];
      k--;
      now = nnow;
    }
    cout << now+1 << endl;
  }
  //ここまで問題なし
  else{
    
    if( lt2 == lt1+1 ){ 
      cout << lp+1 << endl;
      return 0;
    } 
    
    int T = lt2-lt1;
    k = k-lt1; //残り、lpから出発して移動できる回数に等しい
    
    k %= T;
    
    //後これだけの回数をlpから動けばいい
    
    int where = lp;
    
    while(k>0){ 
      int n_where = to[where];
      k--;
      where = n_where;
    }
    
    cout << where+1 << endl;
      
    
  }
  
  
    
    
  
  return 0;
} 

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

using namespace std;

#define pb push_back
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define mem(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, int> pli;

const int mn = 3e5 + 5;
const int maxlog = 19;

const string s[]={"KIHBR","KIHBRA","KIHBAR","KIHBARA","KIHABR","KIHABRA","KIHABAR","KIHABARA",
                  "AKIHBR","AKIHBRA","AKIHBAR","AKIHBARA","AKIHABR","AKIHABRA","AKIHABAR","AKIHABARA"};

int main() {
    //cin.sync_with_stdio(0);
#ifdef trote
    freopen("../1.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#endif
    string c;
    cin>>c;
    for(auto &i:s){
        if (c==i) {
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

if A + B < 2 * C:
    print(A * X + B * Y)
else:  # ABピザを二枚ずつ増やしていく。最大は2(max(x,y))
    ans = float('inf')
    for i in range(0, max(X, Y) * 2 + 1, 2):
        ans = min(ans, max(A * (X - i // 2), 0) + max(B * (Y - i // 2), 0) + C * i)
    print(ans)


Measured memory_bytes: 3060
d=int(input())

last=[0]*26
c=list(map(int,input().split()))
s=[list(map(int, input().split())) for _ in range(d)]

t=[int(input()) for _ in range(d)]
ans=[]
score=0
for i in range(d):

    score+=s[i][t[i]-1]
    last[t[i]-1]=i+1
    for j in range(26):
        score-=(c[j]*((i+1)-last[j]))

        
    ans.append(score)


for item in ans:
    print(item)





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

const int maxn = 105;
const ld PI = atan(1)*4;
int N;
struct Point
{
    int x, y;
};
vector<Point> pts;

ld modAngle(ld angle) {
    while (angle > PI) angle -= 2*PI;    
    while (angle < -PI) angle += 2*PI;
    return angle;
}

Point add(Point a, Point b) {
    return {a.x+b.x,a.y+b.y};
}

ld mag(Point a) {
    return sqrt(1LL*a.x*a.x + 1LL*a.y*a.y);
}

bool wrap(ld start, ld stop, ld curr) {
    if (start < stop) return curr >= stop || curr < start;    
    else return stop <= curr && curr < start;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N;
    for (int i = 0; i < N; i++) {
        int xi, yi; cin >> xi >> yi;
        if (xi == 0 && yi == 0) {
            continue;
        }
        else {
            pts.push_back({xi,yi});
        }
    }
    N = pts.size();
    sort(pts.begin(),pts.end(),[](auto a, auto b) {
            return atan2(a.x,a.y) < atan2(b.x,b.y);
            });
    for (int i = 0; i < N; i++) {
        pts.push_back(pts[i]);
    }
    /*
    for (auto p: pts) {
        cout << p.x << ' ' << p.y << ' ' << atan2(p.x,p.y) << '\n';
    }
    */
    ld res = 0;
    for (int i = 0; i < N; i++) {
        auto p = pts[i];
        Point sum = {0,0};
        ld best = 0;
        for (int j = i; j < min((int)pts.size(),i+N); j++) {
            sum = add(sum,pts[j]);
            best = max(best,mag(sum));
        }
        res = max(res,best);
    }
    cout << fixed << setprecision(25) << res << '\n';
}



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

long long f(long long a, long long b) {
	if (a == 0 || b == 0) return 0;
	if (a > b) {
		return f(a % b, b) + b * (a / b) * 2;
	} else {
		return f(a, b % a) + a * (b / a) * 2;
	}
}

int main() {
	long long n, x;
	cin >> n >> x;

	long long ans = f(x, n - x) + n - __gcd(n, x);
	cout << ans << endl;
}

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

int main(){
int n,i,x,j,k;
char s;
int cards[4][13];
for(j=0;j<4;j++){
 for(i=0;i<13;i++){
  cards[j][i]=0;
 }
}
cin>>n;
for(i=0;i<n;i++){
cin>>s>>x;
if (s=='S'){
cards[0][x-1]=1;}
else if (s=='H'){
cards[1][x-1]=1;}
else if (s=='C'){
cards[2][x-1]=1;}
else if (s=='D'){
cards[3][x-1]=1;}
}

for(j=0;j<4;j++){
 for(i=0;i<13;i++){
  if(cards[j][i]==0){
    if(j==0)
     {cout<<"S"<<" "<<i+1<<endl;}
    else if(j==1)
     {cout<<"H"<<" "<<i+1<<endl;}
    else if(j==2)
     {cout<<"C"<<" "<<i+1<<endl;}
    else if(j==3)
     {cout<<"D"<<" "<<i+1<<endl;}
 }}
}

    return 0;
}

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

int gcd2(int a, int b) {
  if (a < b) {
    int tmp = b;
    b = a;
    a = tmp;
  }
  int r = a % b;
  if (r == 0) return b;
  return gcd2(r, b);
}

int gcd(int a, int b, int c) {
  int tmp;
  if (b < c) {
    tmp = c; c = b; b = tmp;
  }
  if (a < b) {
    tmp = b; b = a; a = tmp;
  }
  if (b < c) {
    tmp = c; c = b; b = tmp;
  }
  return gcd2(gcd2(a, b), gcd2(b, c));
}

int main() {
  int k;
  cin >> k;
  int result = 0;
  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        result += gcd(a, b, c);
      }
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n) for(int i=a; i<n; i++)
#define SPEED ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(0)
int main() 
{
	SPEED; 
	int x,a;
	cin>>x>>a;
	if(x<a) cout<<"0";
	else cout<<"10";
	return 0;
}

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

int main(){
  long long S, a, b, p, q;
  
  cin >> S;
  
  if( S <= 1000000000){
    cout << "0" <<" "<< "0" <<" "<< "1" <<" "<< "0" <<" "<< "0" <<" "<< S << endl;
  }else if(S < 1000000000000000000){
    a = S / 1000000000;
    b = a + 1;
    p = S % 1000000000;
    q = 1000000000 - p;
      
     cout << "0" <<" "<< "0" <<" "<< "1000000000" <<" "<< "1" <<" "<< q <<" "<< b << endl;
  }else{
     cout << "0" <<" "<< "0" <<" "<< "1000000000" <<" "<< "0" <<" "<< "0" <<" "<< "1000000000" << endl;
  }  
}

Measured memory_bytes: 256
import heapq
from collections import defaultdict

n, m = map(int, input().split())
ans = 0
jobs = defaultdict(list)
to_do = []
heapq.heapify(to_do)
for i in range(n):
    array = list(map(int, input().split()))
    array[1] *= -1
    jobs[array[0]].append(array[1])

for i in range(1, m+1):
    if len(jobs[i]) > 0:
        for j in jobs[i]:
            heapq.heappush(to_do, j)
    if len(to_do) > 0:
        ans += -1 * heapq.heappop(to_do)

print(ans)



Measured memory_bytes: 33104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int N;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    vector<P> l;
    rep(i, N) {
        int A, B; cin >> A >> B;
        l.pb(P(B, A));
    }
    sort(l.begin(), l.end());
    int now = 0;
    bool flag = true;
    
    rep(i, N) {
        int B = l[i].first, A = l[i].second;
        if (now+A>B) flag = false;
        now += A;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 6256