akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,a[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();m=read();
	if(n<=10)m+=100*(10-n);
	cout<<m;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
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; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



//——————— comre(n);　→　nCk=com(n,k) —————————————————

vector<ll> fact, fact_inv, inv;
/*  comre :二項係数のための前処理
    計算量:O(n)
*/
void comre(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}
/*  com :modでの二項係数を求める(前処理 comre が必要)
    計算量:O(1)
*/
ll com(ll n, ll k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

//—————————————————————————————————————————————————


int main() {
  ll x,y;
  cin>>x>>y;

  if((x+y)%3!=0||x>2*y||y>2*x) {
    cout << 0 << endl;
    return 0;
  }

  ll a=(x+y)/3;
  ll b=2*a-x;

  comre(a);

  cout << com(a,b) << endl;


}

Measured memory_bytes: 15872
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
char s[100005];bool d[35];
void work()
{
	scanf("%s",s);
	int l=strlen(s);
	for(int i=0;i<l;i++){
		d[s[i]-'a']=true;
	}
	for(int i=0;i<=25;i++){
		if(!d[i]){
			printf("%c\n",'a'+i);
			return ;
		}
	}
	puts("None");
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ret = 0;
		for (int i = 1; i <= n; i++) {
			if (i > k) {
				ret += y;
			} else {
				ret += x;
			}
		}
		System.out.println(ret);
	}

}


Measured memory_bytes: 21844
S = input()
MOD = 10 ** 9 + 7
N = len(S)

dp = [[0 for _ in range(13)] for _ in range(N + 1)]
dp[0][0] = 1

for i in range(N):
    for j in range(0, 10):
        if (S[i] != '?' and S[i] != str(j)):
            continue
        for k in range(0, 13):
            dp[i + 1][(k * 10 + j) % 13] += dp[i][k]

    for j in range(0, 13):
        dp[i + 1][j] %= MOD

print(dp[N][5])


Measured memory_bytes: 66780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
template <typename G>
struct StronglyConnectedComponents
{
  const G &g;
  vector<vector<ll>> ng, rg;         // normal-graphとreversed-graph
  vector<int> compo, order, used; // compo…頂点がどの成分に属しているか、order…帰りがけ順で何番目か

  StronglyConnectedComponents(G &g) : g(g), ng(g.size()), rg(g.size()), compo(g.size(), -1), used(g.size())
  {
    for (int i = 0; i < g.size(); i++)
      for (auto t : g[i])
      {
        ng[i].emplace_back((int)t);
        rg[(int)t].emplace_back(i); // 逆辺
      }
  }

  // []で聞かれたときは成分番号を返す
  int operator[](int k) { return compo[k]; }

  void dfs(int now)
  {
    if (used[now])
      return;
    used[now] = true;
    for (auto to : ng[now])
      dfs(to);
    order.emplace_back(now);
  }

  void rdfs(int now, int count)
  {
    // used代わりに結果を入れていく
    if (compo[now] != -1)
      return;
    compo[now] = count;
    for (auto to : rg[now])
      rdfs(to, count);
  }

  void build(vector<vector<ll>> &ret)
  {
    // 普通にDFS、辺の向きを変えてもう一度DFS
    for (int i = 0; i < ng.size(); i++)
      dfs(i);
    reverse(order.begin(), order.end());
    int group = 0;
    for (auto i : order)
      if (compo[i] == -1)
        rdfs(i, group), group++;

    // 縮めたグラフを構築する
    ret.resize(group);
    for (int i = 0; i < g.size(); i++)
    { // 全ての辺について
      for (auto &to : g[i])
      {
        int s = compo[i], t = compo[to];
        if (s != t)
          ret[s].emplace_back(t);
      }
    }
  }
};
int main()
{
ll n, m;
cin >> n >> m;
vector<vector<ll>> g(n);
vector<vector<ll>> gg;
rep(i, m)
{
  ll a, b;
  cin >> a >> b;
  g[a].push_back(b);
}
StronglyConnectedComponents<vector<vector<ll>>> scc(g);
scc.build(gg);

ll q ;
cin >> q ;
rep(i,q){
  ll u , v  ;
  cin >> u >> v ;
  cout << (scc[u]==scc[v]) << endl;
}

return 0;
}


Measured memory_bytes: 5048
import sys
def input():
    return sys.stdin.readline()[:-1]
N,K=map(int, input().split())
A=tuple(map(int,input().split()))
l=[0]*40
for i in A:
    b=bin(i)
    for i in range(-1,1-len(b),-1):
        if b[i]=="1":
            l[i]+=1
x=[0]*40
xi=0
for i in range(40):
    if l[i]<=N//2 and xi+2**(39-i)<=K:
        x[i]=1
        xi+=2**(39-i)
a=0
for i in range(40):
    if x[i]:
        a+=(N-l[i])*2**(39-i)
    else:
        a+=l[i]*2**(39-i)
print(a)

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

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

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    rep(i, N+1){
        rep(j, M+1){
            int ans = i*(M-j) + j*(N-i);
            if(ans == K){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
// AOJ 0590
// @kankichi573
#include <stdio.h>
#include <string.h>

char prime_flag[65536];

int prime256[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,
67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,
157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,
241,251};

make_furui()
{
        int i,j,num;
        memset(prime_flag,-1,65536);
        
        prime_flag[0]=prime_flag[1]=0;

        for(i=0;prime256[i];i++)
                for(j=2;(num=prime256[i]*j)<65536;j++)
                {
                        //printf("%d\n",num);
                        prime_flag[num]=0;
                }
}
int isprime32(unsigned int n)
{
        int i;

        for(i=2;i<65536;i++)
                if(prime_flag[i] && 0==(n % i) && (n > i))
                        return(0);
        return(1);
}

main()
{
        int N,cnt,i;
        unsigned int num;

        make_furui();

        scanf("%d",&N);

        for(i=0,cnt=0;i<N;i++)
        {
                scanf("%u",&num);
                cnt += isprime32(2*num+1);
        }
        printf("%d\n",cnt);
        return(0);
}

Measured memory_bytes: 672
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    int ans = 1e9;
    vector <int> v(n);
    for (auto &it : v)
        cin >> it;
    for (int i = 0; i <= 100; i++) {
        int c = 0;
        for (auto it : v) {
            c += (it - i) * (it - i);
        }
        ans = min(c, ans);
    }
    cout << ans;

    return 0;
}


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

int main(){
    string s;cin >> s;
	long long k;cin >> k;
	int o=0,ans=0;
	for(int i=0;i<s.size();++i){
		if(s.at(i)=='1') o++;
		else{
			ans=s.at(i)-'0';
			break;
		}
	}
	if(o>=k) cout << 1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np

# a b c キャンディーの数
a, b, c = map(int, input().split())

candy = np.array([a, b, c])

# キャンディーの数順でソート
candy.sort()

# 少ない２つと一番多いので比較
if (candy[0] + candy[1] == candy[2]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21108
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))


d = {}
for i, junretsu in enumerate(permutations(i + 1 for i in range(N))):
    d[junretsu] = i

print(abs(d[P] - d[Q]))


Measured memory_bytes: 43248
using System;

public class Program
{
	public static void Main(string[] args)
	{
		var ss = new StreamScanner();
		//---------------------------------
		//????????????int, double, string?????????????????£????????????
		while (true)
		{
			var n = ss.Next<int>();
			var x = ss.Next<int>();
			if (n == 0 && x == 0)
			{
				break;
			}

			int ans = 0;
			for (int i = 1; i <= n; i++)
			{
				for (int j = i + 1; j <= n; j++)
				{
					for (int k = j + 1; k <= n; k++)
					{
						if (i + j + k == x)
						{
							ans += 1;
						}
					}
				}

			}
			Console.WriteLine(ans);

			//int x = ss.Next<int>();
			//double d = ss.Next<double>();
			//string s = ss.Next<string>();

			//?????°???????????????????????¨?????????????????????????????????????????????????´???????
			//int[] array = ss.Next<int>(10);
			//---------------------------------
		}
	}
}
public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 9856
fruit = map(int, input().split())
price = map(int, input().split())
list1=[]
list2=[]
for i in price:
    list1.append(i)
for j in fruit:
    list2.append(j)
sot=sorted(list1)
result=0
for x in range(0,list2[1]):
    result+= sot[x]
print(result)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()



int main() {
    int h, w, ans;
    cin >> h >> w;
    ans = min(h,w);
    if(h%3==0 || w%3==0) ans = 0;
    REP(i,2){
        ans = min(ans, max((h/3)*w,(h-h/3)*(w/2+w%2))-min((h/3)*w,(h-h/3)*(w/2)));
        ans = min(ans, max((h/3+1)*w,(h-h/3-1)*(w/2+w%2))-min((h/3+1)*w,(h-h/3-1)*(w/2)));
        swap(h,w);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
program ec12;
var 
	a,j,t,s:array[1..100001] of longint;
	n,m,i,tot1,tot2,tot3:longint;
begin 
	readln(n);
	tot1:=0;
	tot2:=0;
	tot3:=0;
	for i:=1 to n do 
	begin 
		read(a[i]);	
		if a[i] mod 2=1 then 
		inc(tot1)
		else
		begin 
			if a[i] mod 4=0 then 
			inc(tot3)
			else
			inc(tot2);
		end;
	end;
	if tot3<tot1-1 then 
	begin 
		writeln('No');
		halt;
	end;
	if (tot3=tot1-1) and (tot2>0) then 
	begin 
		writeln('No');
		halt;
	end;
	writeln('Yes');
end. 

Measured memory_bytes: 512
n,a,b = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
ans = 0
for i in range(n-1):
    l = x[i]
    r = x[i+1]
    if (r-l)*a<b:
        ans +=(r-l)*a
    else:
        ans+=b
print(ans)

Measured memory_bytes: 63216
const input = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');
const meta = input[0];
const a = input[1];
const b = input[2];
const c = input[3];

const metaD = meta.trim().split(' ').map(i => parseInt(i));
const X = metaD[0];
const Y = metaD[1];
const Z = metaD[2];
const K = metaD[3];
const A = a.trim().split(' ').map(i => parseInt(i)).slice(0,X).sort((a,b)=>b-a);
const B = b.trim().split(' ').map(i => parseInt(i)).slice(0,Y).sort((a,b)=>b-a);
const C = c.trim().split(' ').map(i => parseInt(i)).slice(0,Z).sort((a,b)=>b-a);

const result = [];
const queue = [{
    p: A[0]+B[0]+C[0],
    x: 0,
    y: 0,
    z: 0
}];

const done = {};

const addToQueue = (p,x,y,z) => {
    if (!queue.find(v => v.p === p && v.x === x && v.y === y && v.z === z)
    && !done[`${x},${y},${z}`]) {
        queue.push({p,x,y,z});
    }
}

const min = (i,arr) => Math.min(i,arr.length - 1);

Array.from(Array(K)).forEach(() => {
    const largest = queue.sort((a,b)=>a.p-b.p).pop();
    result.push(largest);
    const x = largest.x;
    const y = largest.y;
    const z = largest.z;
    done[`${x},${y},${z}`] = true;
    addToQueue(A[min(x+1,A)]+B[y]+C[z],min(x+1,A),y,z);
    addToQueue(A[x]+B[min(y+1,B)]+C[z],x,min(y+1,B),z);
    addToQueue(A[x]+B[y]+C[min(z+1,C)],x,y,min(z+1,C));
});

console.log(result.map(v => v.p).join('\n'));

Measured memory_bytes: 17392
N, M, C = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
A = [[int(_) for _ in input().split()] for i in range(N)]

result = sum(
    C + sum([x * y for x, y in zip(a, B)]) > 0
    for a in A
)

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



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

  int  a[30]={0};
  for(int t=0;t<n;t++){
    string s;cin>>s;
    int b[30]={0};
    for(unsigned int i=0;i<s.size();i++){
      int temp=s[i]-'a';
      b[temp]++;
    }

    if(t==0)memcpy(a,b,sizeof(b));

    for(int t=0;t<26;t++)a[t]=min(a[t],b[t]);
  }

  for(char t='a';t<='z';t++){
    for(int i=0;i<a[t-'a'];i++){
      cout<<t;
    }
  }

  cout<<"\n";
  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())


pics = []
tmp = ["."] * (w+2)
pics.append(tmp)
for i in range(h):
  tmp = list(input())
  tmp.insert(0,".")
  tmp.append(".")
  pics.append(tmp)
  
tmp = ["."] * (w+2) 
pics.append(tmp)
ans = "Yes"  

for i in range(1,h+1):
  for j in range(1,w+1):
    if pics[i][j] == "#":
      #print(i,j)
      if pics[i-1][j] != "#" and pics[i+1][j] != "#" and pics[i][j-1] != "#" and pics[i][j+1] != "#":
        print("No")
        exit()
      
print("Yes")


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		do {

			String str = sc.nextLine();
			String[] strs = str.split(" ");

			if (strs[0].equals("0") && strs[1].equals("0")) {
				break;
			}

			int[] ints = new int[] {Integer.parseInt(strs[0]), Integer.parseInt(strs[1])};
			Arrays.sort(ints);



	        System.out.println( ints[0] + " " + ints[1] );

		}while(true);
		sc.close();

	}

}



Measured memory_bytes: 35096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

typedef pair<int, int> pii;

int n, djs[MAXN];
pii pt[MAXN];
map<int, vector<int> > x, y;

struct Plan {
    int u, v, cost;
    bool operator < (const Plan &p) {
        return cost < p.cost;
    }
};
vector<Plan> plan;

int fnd (int x) {
    return x == djs[x] ? x : djs[x] = fnd(djs[x]);
}

bool mrg (int x, int y) {
    x = fnd(x), y = fnd(y);
    if (x == y) {
        return false;
    }
    djs[x] = y;
    return true;
}
/*********************GoodLuck***********************/
int main () {
    IOS();
    cin >> n;

    REP (i, n) {
        djs[i] = i;
    }

    REP (i, n) {
        cin >> pt[i].first >> pt[i].second;
        x[pt[i].first].emplace_back(i);
        y[pt[i].second].emplace_back(i);
    }

    ll ans = 0;
    for (auto it=x.begin(); it!=x.end(); it++) {
        if (it !=x.begin()) {
            plan.push_back({*(it->second.begin()), *(prev(it)->second.begin()), it->first - prev(it)->first});
        }
        const auto &v = it->second;
        REP (i, SZ(v) - 1) {
            mrg(v[i], v[i+1]);
        }
    }

    for (auto it=y.begin(); it!=y.end(); it++) {
        if (it !=y.begin()) {
            plan.push_back({*(it->second.begin()), *(prev(it)->second.begin()), it->first - prev(it)->first});
        }
        const auto &v = it->second;
        REP (i, SZ(v) - 1) {
            mrg(v[i], v[i+1]);
        }
    }

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

    for (const auto &p : plan) {
        if (mrg(p.u, p.v)) {
            ans += p.cost;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 28020
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val w = readLine()!!.split(' ').map(String::toInt)
    val sum = w.sum()
    println(scan({ acc, i -> acc + i }, 0, w).map{ Math.abs(sum - it * 2)}.min()!!)
}

fun<T1, T2> scan (f: (T2, T1) -> T2, init: T2, list: List<T1>): List<T2> {
    var tmp = init
    return list.map {
        tmp = f(tmp, it)
        tmp
    }
}


Measured memory_bytes: 38120
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

int N, M;
vector<vector<int>> node;
vector<bool> flag;

//自分に戻るような経路が存在するか探索(頂点bgnを始点終点とするような閉路があるか)
bool dfs(int bgn, int prev, int cur, int end) {
	flag[cur] = false;
	for (int i = 0; i < node[cur].size(); i++)
	{
		int next = node[cur][i];

		//end orさっきいたところなら続ける
		if (next == prev || next == end) continue;

		//始点終点をbgnとするような閉路が存在する
		if (next == bgn) {
			return true;
		}

		//まだ行ってないところであれば探索し、閉路が存在すればtrue
		if (flag[next] && dfs(bgn,cur,next,end)) {
			return true;
		}
	}
	//頂点bgnを始点終点とするような閉路は存在しない
	return false;
}

int main() {

	cin >> N >> M;
	node.resize(N + 1, vector<int>());
	flag.resize(N + 1, true);

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		node[a].push_back(b);
		node[b].push_back(a);
	}

	//オイラーグラフか？
	stack<int> four, six;
	for (int i = 1; i <= N; i++) {

		if (node[i].size() % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
		switch (node[i].size()) {
		case 4:four.push(i); break;
		case 6:six.push(i); break;
		}
	}

	//頂点の次数で場合分け
	if (six.size() >= 1 || four.size() >= 3) {
		cout << "Yes" << endl;
	}
	else if (four.size() == 2) {
		//次数４の頂点から出て,自分に戻るような経路が存在すればYes;
		int t = four.top(); four.pop();
		int s = four.top(); four.pop();

		if (dfs(t, 0, t, s)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 7680
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int p, s;
  char gomi;
  vpii v;
  while (cin >> p >> gomi >> s, p) v.emplace_back(s, p);
  sort(rall(v));
  vi w(101);
  w[v[0].se] = 1;
  loop(i, 1, v.size()) w[v[i].se] = w[v[i - 1].se] + (v[i - 1].fi != v[i].fi);
  int q;
  while (cin >> q) cout << w[q] << endl;
}

Measured memory_bytes: 3060
n,k = map(int,input().split())
a = [int(x) for x in input().split()]
dp = [10 **100 for x in range(n)]
dp[0] = 0
for i in range(0, n):
    for j in range(1, k + 1):
        if i + j < n:
            dp[i + j] = min(dp[i + j], dp[i] + abs(a[i] - a[i + j]))
print(dp[n - 1])

Measured memory_bytes: 56544
#include <iostream>
#include <cstring>
#include <map>
#include <vector>
#include <queue>
#include <cstdio>
#include <algorithm>
typedef long long ll;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f3f;
using namespace std;
inline int read()
{
    char c = getchar(); int x = 0, f = 1;
    while(c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
    return x*f;
}
int K;
int dis[maxn];
int dij(int s)
{
   deque<int> q;
    for(int i=0;i<=K;i++)dis[i]=inf;
    dis[s] = 0;
    q.push_back(s);
    while(!q.empty())
    {
        int x = q.front();q.pop_front();
        if(dis[(x*10)%K]>dis[x])
        {
            dis[(x*10)%K] = dis[x]; q.push_front((x*10)%K);
        }
        if(dis[(x+1)%K]>dis[x]+1)
        {
            dis[(x+1)%K] = dis[x]+1;q.push_back((x+1)%K);
        }
    }
    return dis[0];
}
int main()
{
    K = read();
    cout << dij(1) + 1 << '\n';
    return 0;
}


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

int main() {
	int a, b; cin >> a >> b;
	for (int i = 1; i <= 100000; ++i) {
		if (int(i * 0.08) == a && int(i * 0.1) == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


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

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

  vector<pair<int, int>> D(N);
  rep(i,0,N-1) {
    pair<int, int> d;
    cin >> d.first >> d.second;
    D.at(i) = d;
  }

  int cnt = 0;
  rep(i,0,N-1) {
    pair<int, int> d = D.at(i);
    if (d.first == d.second) {
      ++cnt;
    } else {
      cnt = 0;
    }
    if (cnt >= 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


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

using namespace std;
int arr[100001][3];
int ans[100001][3];
int main()
{
    int n;
    cin>>n;
    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j<3;j++)
        {
            cin>>arr[i][j];
        }
    }
    ans[0][0] = arr[0][0];
    ans[0][1] = arr[0][1];
    ans[0][2] = arr[0][2];
    
    for(int i = 1;i<n;i++)
    {
        ans[i][0] = arr[i][0] + max(ans[i-1][1],ans[i-1][2]);
        ans[i][1] = arr[i][1] + max(ans[i-1][0],ans[i-1][2]);
        ans[i][2] = arr[i][2] + max(ans[i-1][1],ans[i-1][0]);        
    }
    int answer = max({ans[n-1][0],ans[n-1][1],ans[n-1][2]});
    cout<<answer<<endl;
    return 0;
}


Measured memory_bytes: 5924
#!/usr/bin/env python3

from copy import deepcopy
from fractions import Fraction

def main():
    n, a, b = map(int, input().split())
    v = list(map(int, input().split()))
    dp = [[0, 0] for i in range(n + 1)]
    dp[0] = [0, 1]
    for j in range(n):
        dppre = deepcopy(dp)
        for i in range(n):  # 配る
            vnew = dppre[i][0] + v[j]
            ways = dppre[i][1]
            if vnew > dp[i + 1][0]:
                dp[i + 1] = [vnew, ways]
            elif vnew == dp[i + 1][0]:
                dp[i + 1][1] += ways

    maxave = 0
    for i in range(a, b + 1):
        maxave = max(maxave, Fraction(dp[i][0], i))
    ways = 0
    for i in range(a, b + 1):
        if Fraction(dp[i][0], i) == maxave:
            ways += dp[i][1]
    print(float(maxave))
    print(ways)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5100
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) a = b;
  return a > b;
}
template<class T> inline bool chmax(T&a, T b) {
  if (a < b) a = b;
  return a < b;
}

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



Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    string s;
    cin>>s;
    ll b=0,r=0;
    for(ll i=0;i<s.size();i++){
        if(s[i]=='0') r++;
        else b++;
    }
    cout<<2*min(b,r)<<endl;
    return 0;
}

Measured memory_bytes: 512
import sys

N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    sys.exit(0) 

Π = 1
for _ in A:
    Π *= _
    if(Π > 1000000000000000000):
        print(-1)
        sys.exit(0)

print(Π)


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

int sumOfEachDigit(int num) {
  int sum = 0;
  while (num != 0)
  {
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

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

  int ans = sumOfEachDigit(N);
  if (ans == 1) ans *= 10;
  cout << ans << endl;

  return 0;
}


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

ll N,K;
ll INF = 1e9+7;

void comb(ll n, ll r) {
	vector<vector<ll>> v(n + 1,vector<ll>(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
			v[j][k] = v[j][k]%INF;
		}
	}


	for(int i=1;i<=K;i++)
		cout<<v[N-K+1][i]*v[K-1][i-1]%INF<<endl;
}

int main(){
	cin>>N>>K;
	comb(N,N);

}


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

is_Yes = True
for i in range(1, N):
    if Hs[i-1] == Hs[i]:
        continue
    elif Hs[i] > Hs[i-1]:
        Hs[i] -= 1
    else:
        is_Yes = False
        break

if is_Yes:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
#include<iostream>
#include<cstdio>
#include<stack>

using namespace std;

#define WALL 0
#define FLOO 1
#define HITO 2
#define HWMAX 50
#define DMAX 10

struct point{
	int x,y;
};

int main(){

	int h,w,d,n;
	int x,y,s;
	int mize[HWMAX][HWMAX];
	int cnt[HWMAX][HWMAX]={0};
	int r[DMAX+2];
	int Dx,Dy;
	char cinp;
	stack<point> Dhito;
	point xy;
	point ptmp;
	int dy[]={0,0,1,-1};
	int dx[]={1,-1,0,0};
	bool yes=false,no=false;

	cin>>h>>w>>d>>n;

	for(int i=0;i<h;i++){
		getchar();
		for(int j=0;j<w;j++){
			cinp=getchar();
			if(cinp=='#') mize[i][j]=WALL;
			if(cinp=='.') mize[i][j]=FLOO;
			if(cinp=='D') mize[i][j]=HITO,Dy=i,Dx=j;
		}
	}

	xy.x=Dx,xy.y=Dy;
	Dhito.push(xy);
	while(!Dhito.empty()){
		xy=Dhito.top();
		Dhito.pop();
		mize[xy.y][xy.x]=HITO;
		for(int i=0;i<4;i++){
			if(xy.y+dy[i]>=0&&xy.y+dy[i]<h&&xy.x+dx[i]>=0&&xy.x+dx[i]<w){
				if(mize[xy.y+dy[i]][xy.x+dx[i]]==FLOO){
					mize[xy.y+dy[i]][xy.x+dx[i]]=HITO;
					ptmp.y=xy.y+dy[i],ptmp.x=xy.x+dx[i];
					Dhito.push(ptmp);
				}
			}
		}

	}

	for(int i=1;i<=d;i++){
		cin>>r[i];
	}
	r[0]=0;
	r[d+1]=55;

	for(int i=0;i<n;i++){
		cin>>x>>y>>s;
		for(int j=-r[s];j<=r[s];j++){
			for(int k=-r[s];k<=r[s];k++){
				if(y+j>=0&&y+j<h&&x+k>=0&&x+k<w){
					cnt[y+j][x+k]--;
				}
			}
		}
		for(int j=-r[s+1];j<=r[s+1];j++){
			for(int k=-r[s+1];k<=r[s+1];k++){
				if(y+j>=0&&y+j<h&&x+k>=0&&x+k<w){
					cnt[y+j][x+k]++;
				}
			}
		}
		if(s==0) cnt[y][x]++;
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(cnt[i][j]==n){
				if(mize[i][j]==HITO) yes=true;
				else if(mize[i][j]==FLOO) no=true;
			}
		}
	}

	if(yes&&no) cout<<"Unknown"<<endl;
	else if(yes) cout<<"Yes"<<endl;
	else if(no) cout<<"No"<<endl;
	else cout<<"Broken"<<endl;

	return 0;
}

Measured memory_bytes: 1240
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main{
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		int M=sc.nextInt();
		int X=sc.nextInt();
		int[] C=new int[N];
		int[][] A=new int[N][M];
		for (int i=0;i<N;++i) {
			C[i]=sc.nextInt();
			for (int j=0;j<M;++j) {
				A[i][j]=sc.nextInt();
			}
		}
		long INF=Long.MAX_VALUE/3;
		long ans=INF;
		for (int s=0;s<1<<N;++s) {
			long[] sum=new long[M];
			long cost=0;
			for (int i=0;i<N;++i) {
				if ((s>>i)%2==0) continue;
				cost+=C[i];
				for (int j=0;j<M;++j) {
					sum[j]+=A[i][j];
				}
			}
			boolean ok=true;
			for (int i=0;i<M;++i) ok&=sum[i]>=X;
			if (ok) {
				ans=Math.min(ans, cost);
			}
		}
		System.out.println(ans==INF?-1:ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
    	return (int)nextLong();
    }
}


Measured memory_bytes: 33988
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main(){
string str,t;
int n=0,c=0;
bool f=true;

while(cin>>str){
t=str;
n=str.size();
for(int i=0;i<n;i++)
{t[i]=str[n-i-1];}
for(int i=0;i<n;i++)
if(t[i]!=str[i])f=false;

if(f==true)c++;
f=true;n=0;
}
cout<<c<<endl;

return 0;
}

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

#define FOR(a,b,c) for(int a=(b),a##_end__=(c);a<=a##_end__;a++)
#define f(x) (x-B[x]+1)
#define M 200005

int A[M],B[M],C[M];
int n,m,ans;

void Rd(int &res){
    char c;res=0;
    while(c=getchar(),c<48);
    do res=(res<<3)+(res<<1)+(c^48);
    while(c=getchar(),c>47);
}
void Wt(int x){
    static int stk[24];int p=0;
    do stk[++p]=x%10^48;
    while(x/=10);
    while(p) putchar(stk[p--]);
}

int main(){
    Rd(n);Rd(m);
    ans=n;
    FOR(i,1,n){
        Rd(A[i]);
        B[A[i]]++;
        if(f(A[i])>0){
            if(C[f(A[i])]==0) ans--;
            C[f(A[i])]++;
        }
    }
    
    while(m--){
        /*FOR(i,1,n) printf("%d ",C[i]);
        puts(""); */
        int x,y;
        Rd(x);Rd(y);
        if(f(A[x])>0){
            if(C[f(A[x])]==1) ans++;
            C[f(A[x])]--;
        }
        B[A[x]]--;
        B[y]++;
        if(f(y)>0){
            if(C[f(y)]==0) ans--;
            C[f(y)]++;
        }
        Wt(ans);
        puts("");
        A[x]=y;
    }
}

Measured memory_bytes: 3712
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, i;
	int a[200000], b[200000];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", a+i);
		b[i]=a[i];
	}
	qsort(b, n, sizeof(int), comp);
	int m1=b[n/2-1], m2=b[n/2];

	if(m1==m2){
		char buf[11];
		sprintf(buf, "%d\n", m1);
		for(i=0; i<n; i++){
			fputs(buf, stdout);
		}
	}else{
		char buf[2][11];
		sprintf(buf[0], "%d\n", m1);
		sprintf(buf[1], "%d\n", m2);
		for(i=0; i<n; i++){
			if(a[i]<=m1){
				fputs(buf[1], stdout);
			}else{
				fputs(buf[0], stdout);
			}
		}
	}
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr << #x << ": " << x << endl;

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int    inf = 100100100;
const int    MOD = (int)1e9 + 7;
const double EPS = 1e-9;


int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(loop_count, n) {
        string s[2];
        cin >> s[0] >> s[1];
        int a[2] = {};
        rep(k, 2) {
            int t = 1;
            rep(i, s[k].size()) {
                if ('2' <= s[k][i] && s[k][i] <= '9') {
                    t = s[k][i] - '0';
                } else {
                    switch (s[k][i]) {
                    case 'm':
                        a[k] += t * 1000;
                        break;
                    case 'c':
                        a[k] += t * 100;
                        break;
                    case 'x':
                        a[k] += t * 10;
                        break;
                    case 'i':
                        a[k] += t;
                        break;
                    }
                    t = 1;
                }
            }
        }
        int    ans = a[0] + a[1];
        string ans_s = "";
        int    kiridasi = 1000;
        while (true) {
            int tmp = ans / kiridasi;
            if (tmp % 10 > 1) {
                if (kiridasi == 1000)
                    cout << tmp % 10 << "m";
                else if (kiridasi == 100)
                    cout << tmp % 10 << "c";
                else if (kiridasi == 10)
                    cout << tmp % 10 << "x";
                else if (kiridasi == 1)
                    cout << tmp % 10 << "i";
            } else if (tmp % 10 == 1) {
                if (kiridasi == 1000)
                    cout << "m";
                else if (kiridasi == 100)
                    cout << "c";
                else if (kiridasi == 10)
                    cout << "x";
                else if (kiridasi == 1)
                    cout << "i";
            }
            kiridasi /= 10;
            if (kiridasi <= 0) break;
        }
        cout << endl;
    }
    return 0;
}



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


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

/* vector<int> A(N); 
    vector<pair<int, int> > tasks; ＃ソートした場合、１つ目でソート
　tie(b, a) = p.at(i); #pairを分割
    tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
　xの二乗:  pow(x, 2.0) 
    小さい順: sort(v.begin(), v.end());
    大きい順: reverse(v.begin(), v.end());
    int: -2,147,483,648 ～ 2,147,483,647
    ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807
*/
 
int main() {
  
  int A, B, C, count=0, ans=0;
  string D, E;
  cin >> A;
  B=A/2;
  if(A%2==1){
    B++;
  }
  
  cout << B << endl;
}

Measured memory_bytes: 256
import math
x=[int(i) for i in input().split()]
a=x[0]
b=x[1]
h=x[2]
m=x[3]
db=(m/60)*360
da=(h/12)*360+(m/60)*30
if(da==db):
    print(abs(a-b))
elif(da>db):
    f=a**2
    f+=(b**2)
    diff=da-db
    if(diff>180):
        diff=360-diff
    f-=(2*a*b*math.cos(math.radians(diff)))
    print(math.sqrt(f))
elif(db>da):
    f=a**2
    f+=(b**2)
    diff=db-da
    if(diff>180):
        diff=360-diff
    f-=(2*a*b*math.cos(math.radians(diff)))
    print(math.sqrt(f))

Measured memory_bytes: 62524
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int ans=1000000,i,num=1000000,flag=0,flag2=0;
    char S[100001];
    cin >> S;
    for(i=0;S[i]!='\0';i++){
    }
    for(int j=0;j<i;j++){
        if(S[j]!=S[j+1])    num = max(j+1,i-(j+1));
        ans = min(num,ans);
        if(S[j]!='0') flag = 1;//すべて、０のときflag == 0
        if(S[j]!='1') flag2 = 1;//すべて、１のときflag2 == 0
    }
    if(flag == 0)   ans = i;
    if(flag2 == 0)   ans = i;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n;
  cout << n*n*n << endl;
}

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

using namespace std;

const int N = 1000006;

int n, m, k;
vector<vector<char>> mat;
vector<vector<int>> dist;

set<int> r[N], c[N];

void bfs(int x1, int y1, int x2, int y2) {
	dist.assign(n, vector<int>(m, -1));
	dist[x1][y1] = 0;
	queue<pair<int, int>> q;
	r[x1].erase(y1);
	c[y1].erase(x1);
	q.emplace(x1, y1);
	while(!q.empty()) {
		int x, y;
		tie(x, y) = q.front();
		q.pop();
		{
			auto it = r[x].lower_bound(y);
			while(it != r[x].end() and *it - y <= k) {
				if(mat[x][*it] == '@') break;
				if(dist[x][*it] == -1) {
					dist[x][*it] = dist[x][y] + 1;
					q.emplace(x, *it);
				}
				it = r[x].erase(it);
			}
			while(it != r[x].begin()) {
				it--;
				if(y - *it > k or mat[x][*it] == '@') break;
				if(dist[x][*it] == -1) {
					dist[x][*it] = dist[x][y] + 1;
					q.emplace(x, *it);
				}
				it = r[x].erase(it);
			}
		}
		{
			auto it = c[y].lower_bound(x);
			while(it != c[y].end() and *it - x <= k) {
				if(mat[*it][y] == '@') break;
				if(dist[*it][y] == -1) {
					dist[*it][y] = dist[x][y] + 1;
					q.emplace(*it, y);
				}
				it = c[y].erase(it);
			}
			while(it != c[y].begin()) {
				it--;
				if(x - *it > k) break;
				if(mat[*it][y] == '@') break;
				if(dist[*it][y] == -1) {
					dist[*it][y] = dist[x][y] + 1;
					q.emplace(*it, y);
				}
				it = c[y].erase(it);
			}
		}
	}
}

int main() {
	scanf("%d %d %d", &n, &m, &k);
	int x1, y1, x2, y2;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	mat.assign(n, vector<char>(m));

	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++)
		scanf(" %c", &mat[i][j]);

	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) {
		r[i].insert(j);
		c[j].insert(i);
	}

	x1--, y1--, x2--, y2--;
	bfs(x1, y1, x2, y2);

	printf("%d\n", dist[x2][y2]);
}


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

const int N = 500000 + 5;

string s;
int n, t[N * 4][26];
int vis[26];

void init(int u = 1, int b = 1, int e = n) {
    if (b == e) {
        t[u][s[b] - 'a'] = 1;
        return;
    }
    int l = u << 1, r = l + 1, m = (b + e) >> 1;
    init(l, b, m);
    init(r, m + 1, e);
    for (int i = 0; i < 26; i++) {
        t[u][i] = t[l][i] | t[r][i];
    }
}

void q(int i, int j, int u = 1, int b = 1, int e = n) {
    if (j < b or e < i) return;
    if (i <= b and e <= j) {
        for (int i = 0; i < 26; i++) {
            if (t[u][i]) vis[i] = 1;
        }
        return;
    }
    int l = u << 1, r = l + 1, m = (b + e) >> 1;
    q(i, j, l, b, m);
    q(i, j, r, m + 1, e);
}

void upd(int i, char c, int u = 1, int b = 1, int e = n) {
    if (i < b or e < i) return;
    if (i <= b and e <= i) {
        t[u][s[i] - 'a'] = 0;
        s[i] = c;
        t[u][s[i] - 'a'] = 1;
        return;
    }
    int l = u << 1, r = l + 1, m = (b + e) >> 1;
    upd(i, c, l, b, m);
    upd(i, c, r, m + 1, e);
    for (int i = 0; i < 26; i++) {
        t[u][i] = t[l][i] | t[r][i];
    }
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    cin >> n >> s;
    s = '.' + s;
    init();
    int m;
    cin >> m;
    while (m--) {
        int t;
        cin >> t;
        if (t == 1) {
            int i;
            char c;
            cin >> i >> c;
            upd(i, c);
        }
        if (t == 2) {
            int l, r;
            cin >> l >> r;
            q(l, r);
            int cnt = 0;
            for (int i = 0; i < 26; i++) {
                if (vis[i]) ++cnt;
                vis[i] = 0;
            }
            cout << cnt << '\n';
        }
    }
}

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

#define SEG_LEN (1 << 18)
int seg[SEG_LEN *2];

void update(int ind, int x){
    ind += SEG_LEN;
    seg[ind] = x;

    while (true){
        ind /= 2;
        if (ind == 0)break;
        seg[ind] = min(seg[ind*2], seg[ind*2+1]);
    }
}
// 半開区間で与えられる
int find(int l, int r){
    l += SEG_LEN;
    r += SEG_LEN;
    int ret = INF;

    while (l < r ){
        if (l%2 == 1){
            chmin(ret, seg[l]);
            l++;
        }
        l /= 2;

        if (r%2 == 1){
            chmin(ret, seg[r-1]);
            r--;
        }
        r /= 2;
    }
    return ret;
}

int sum(int l, int r){
    l += SEG_LEN;
    r += SEG_LEN;
    int ret = 0;
    while (l < r){
        if (l%2 == 1){
            ret += seg[l];
            l++;
        }
        l /= 2;

        if (r%2 == 1){
            ret += seg[r-1];
            r--;
        }
        r /= 2;
    }
    return ret;
}


int main() {
    int n,q; cin >> n >> q;
    for (int i=0; i<SEG_LEN*2; i++)seg[i] = INF;
    for (int i=0; i<q; i++){
        int com; cin >> com;
        // update
        if (com == 0){
            int ind , v;
            cin >> ind >> v;
            update(ind, v);
        }
        //find 
        if (com == 1){
            int l, r; cin >> l >> r;
            // 半開区間
            cout << find(l,r+1) << endl;
        }
    }
}


Measured memory_bytes: 5176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashSet<String> dictionary = new HashSet<>();
        for (int i = 0; i < n; i++) {
            String s = in.readLine();
            if (s.contains("insert")) {
                dictionary.add(s.substring(7));
            } else if (s.contains("find")) {
                if (dictionary.contains(s.substring(5))) {
                    System.out.println("yes");
                } else {
                    System.out.println("no");
                }
            }
        }
    }
}



Measured memory_bytes: 120552
#include<iostream>
using namespace std;
int main(){
    int S;
    cin >> S;
    int h = S / 3600;
    int m = (S - h*3600) / 60;
    int s = S - (h * 3600 + m * 60);
    cout << h << ":" << m << ":" << s << endl;;
}


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

int main() {
    ll N, M, K; cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    rep(i, N){
        cin >> A[i];
    }
    rep(i, M){
        cin >> B[i];
    }

    ll ans = 0;
    ll aa = 0;
    ll total = 0;
    rep(i, N){
        if(total + A[i] <= K){
            total += A[i];
            if(i == N-1){
                ans = N;
                aa = N-1;
            }
        } else {
            ans = i;
            aa = i-1;
            break;
        }
    }

    ll now = ans;

    rep(i, M){
        if(total + B[i] <= K){
            total += B[i];
            now++;
            ans = max(now, ans);
        } else {
            while(1){
                if(aa == -1)break;
                total -= A[aa];
                aa--;
                now--;
                if(total + B[i] <= K)break;
            }
            if(total + B[i] <= K){
                total += B[i];
                now++;
                ans = max(now, ans);
            } else {
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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


int main() {
  int A, B; cin >> A >> B;
  
  rep(i, 10000000) {
    if(int(i*0.08) == A && int(i*0.1) == B) {
      cout << i << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
  
}

Measured memory_bytes: 384
a, b = map(int, input().split())
l = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]

if l.index(a) > l.index(b):
    print("Alice")
elif l.index(a) == l.index(b):
    print("Draw")
else:
    print("Bob")


Measured memory_bytes: 3060
d,a=[],0;n=gets.chomp.split.map(&:to_i);n[0].times{dd=gets.chomp.split.map(&:to_i).drop(1);d<< dd}
d.flatten!
n[1].times{|i|d.count(i+1)==n[0]? a+=1:nil}
p a

Measured memory_bytes: 1788