akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

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

//a+b>=v 
int64 calc(int *a,int *b,int n,int v){
  int i=0;
  int j=n-1;
  while(i<n && a[i]+b[j]<v) i++;
  int64 cnt=0;
  for(;i<n;i++){
    while(j>=0 && a[i]+b[j]>=v) j--;
    cnt+=n-1-j;
  }
  return cnt;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*n);
  int *b=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  for(i=0;i<n;i++) scanf("%d",b+i);
  int ans=0;
  int bit;
  for(bit=29;bit>=0;bit--){
    for(i=0;i<n;i++) a[i]=a[i]&((1<<(bit+1))-1);
    for(i=0;i<n;i++) b[i]=b[i]&((1<<(bit+1))-1);
    qsort(a,n,sizeof(int),cmp);
    qsort(b,n,sizeof(int),cmp);
    int64 cnt=(calc(a,b,n,1<<bit)-calc(a,b,n,2*(1<<bit))+calc(a,b,n,3*(1<<bit)));
    if(cnt%2) ans+=1<<bit;
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 2556
from collections import deque

N, M = map(int, input().split())

graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

p=[0]*N
que= deque([0])

while que:
    v=que.popleft()
    for i in graph[v]:
        if p[i]<1:
            p[i]=v+1
            que.append(i)

if 0 in p:
    print("No")
else:
    print("Yes", *p[1:], sep="\n")


Measured memory_bytes: 39080
#include<bits/stdc++.h>
using namespace std;
namespace Kitahara_Kazusa{
	int n;
	int dis[1010][1010],vis[1010][1010];
	void solve(){
		ios::sync_with_stdio(false);
		cin>>n;
		for(int i=1;i<=n;++i){
			for(int j=1;j<=n;++j){
				cin>>dis[i][j];
			}
		}
		for(int i=1;i<=n;++i){
			for(int j=1;j<=n;++j){
				for(int k=1;k<=n;++k){
					if(i!=j&&j!=k&&i!=k){
						if(dis[i][j]+dis[j][k]<dis[i][k]){
							puts("-1");
							exit(0);
						}
						else if(dis[i][j]+dis[j][k]==dis[i][k]){
							vis[i][k]=true;
						}
					}
				}
			}
		}
		long long ans=0;
		for(int i=1;i<=n;++i)
			for(int j=i+1;j<=n;++j){
				if(!vis[i][j])ans=ans+dis[i][j];
			}
		cout<<ans<<endl;
	}
}
int main(){
	Kitahara_Kazusa::solve();
	return 0;
} 

Measured memory_bytes: 5504
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b) {
    return *(int*)a-*(int*)b;
}
int main() {
    int n;
    int a[1000];
    while(scanf("%d",&n)!=EOF)
    {
        int t;
        for(t=0; t<n; t++) {
            scanf("%d",&a[t]);
        }
        qsort(a,n,sizeof(a[0]),cmp);
        printf("%d\n",a[n-1]-a[0]);
        for(t=0; t<n; t++) {
            a[t]=0;
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <bitset>
#include <algorithm>
#include<string.h>

using namespace std;

bitset<10002> mat[12];
bitset<10002> one;
int m, n;

int dfs(int i, bitset<10002> one, int ans){
    if(i == m) return ans;

    if(i >= 0){
        mat[i] = one;
        int sub_ans = 0;
            for(int s = 0; s < n; ++s){
                int up = 0;
                for(int t = 0; t < m; ++t){
                    if(mat[t][s]){
                        up++;
                    }
                }
                sub_ans += max(up, m - up);
            }
        ans = max(ans, sub_ans);
    }

    return max(dfs(i + 1, mat[i+1], ans), dfs(i + 1, mat[i+1].flip(), ans));
}

int main(){
    while(cin>>m>>n && m > 0 && n > 0){
        memset(mat, 0, sizeof(mat));
        for(int i = 0; i < m; ++i){
            for(int j = 0; j < n; ++j){
                bool tmp;
                cin>>tmp;
                mat[i][j] = tmp;
            }
        }
        cout<<dfs(-1, mat[0], 0)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3084
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;
using Graph = vector<vector<int>>;


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 myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

/*vector<bool> seen;
void dfs(const Graph& G, int v, int count) {
    seen[v] = true;
    count = 0;
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue;
        if (count > 2) continue;
        count++;
        cout << count << ":" << next_v << endl;
        dfs(G, next_v, count);
    }
}*/

const int INF = 100000000;
typedef pair<int, int> P;

/*using Maze = vector<vector<char>>;
using D = vector<vector<int>>;
int maze_solve(int N, int M, int sx, int sy, int gx, int gy) {
    queue<P> que;
    que.push(P(sx, sy));
    //配列はNとMの最大値+1くらいをとっておく
    int D[51][51];
    char Maze[51][51];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> Maze[i][j];
            D[i][j] = INF;
        }
    }
    int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
    D[sx][sy] = 0;
    Maze[sx][sy] = 0;
    //ここから処理
    while (que.size()) {
        P p = que.front();
        que.pop();
        if (p.first == gx && p.second == gy) break;
        for (int i = 0; i < 4; i++) {
            int nx, ny;
            nx = p.first + dx[i]; ny = p.second + dy[i];
            if (nx >= 0 && nx < N && ny >= 0 && ny < M && D[nx][ny] == INF && Maze[nx][ny] != '#') {
                que.push(P(nx, ny));
                D[nx][ny] = D[p.first][p.second] + 1;
            }
        }
    }
    /*for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) cout << D[i][j];
        cout << endl;
    }
    return D[gx][gy];
}*/



int main() {
    int N; cin >> N;
    int Y; cin >> Y;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y && (N-i-j) >= 0) {
                cout << i << " " << j << " " << N - i - j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}


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

int dh[]={1,0,-1,0};
int dw[]={0,1,0,-1};

using ll=long long;
int main(){
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    vector<vector<int>> used(h,vector<int>(w,-1));
    int k=0;
    auto isRange=[&](int i,int j){
        return 0<=i && i<h && 0<=j && j<w;
    };
    function<void(int,int,int)> dfs=[&](int i,int j,int c){
        if(!isRange(i,j) || used[i][j]!=-1 || (s[i][j]=='#')!=c) return;
        used[i][j]=k;
        for(int d=0;d<4;d++){
            dfs(i+dh[d],j+dw[d],!c);
        }
    }; 
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(used[i][j]==-1){
                dfs(i,j,s[i][j]=='#');
                k++;
            }
        }
    }
    vector<ll> wcnt(k);
    vector<ll> bcnt(k);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#') bcnt[used[i][j]]++;
            else wcnt[used[i][j]]++;
        }
    }
    long long res=0;
    for(int i=0;i<k;i++){
        res+=wcnt[i]*bcnt[i];
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 16128
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#pragma GCC optimize("Ofast,no-stack-protector")
#include<bits/stdc++.h>
#define LL long long
using namespace std;
signed main()
{
  int n,a[100005];
  bool vis[100005];
  while(scanf("%d",&n)!=EOF)
  {
    LL ans=0;
    memset(vis,false,sizeof(vis));
    for(int i=0; i<n; i++)
    {
      scanf("%d",&a[i]);
      if(a[i])vis[i]=true;
      ans+=a[i]/2;
      a[i]%=2;
    }
    for(int i=1; i<n; i++)
    {
      if(a[i]&&a[i-1])
      {
        a[i]=0;
        a[i-1]=0;
        ans++;
      }
      else if(a[i]==0&&a[i-1])
        if(vis[i]) a[i]++,a[i-1]--;
    }
    printf("%lld\n",ans);
  }
}


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

int main(){
  int n,m,c,i,j,s,ac;
  cin >> n >> m >> c;
  vector<int> a(m),b(m);
  for(i=0;i<m;i++){
    cin >> b.at(i);
  }
  
  ac=0;
  for(j=0;j<n;j++){
    s=0;
    for(i=0;i<m;i++){
      cin >> a.at(i);
      s += a.at(i)*b.at(i);
    }
    if(s+c>0){
      ac++;
    }
  }
  
  cout << ac << endl;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;

namespace Tenak1PBC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            double root = Math.Sqrt(1 + 8 * N);

            if ((int)root != root)
            {
                Console.WriteLine("No");
                return;
            }
            else Console.WriteLine("Yes");

            int k = ((int)root - 1) / 2;

            int[,] S = new int[k + 1, k];

            Queue<int>[] ques = new Queue<int>[k + 1];
            int count = 1;
            for (int i = 0; i < k + 1; i++)
            {
                ques[i] = new Queue<int>();
                for (int j = 0; j < k - i; j++)
                {
                    ques[i].Enqueue(count);
                    count++;
                }
            }

            for (int i = 0; i < k + 1; i++)
            {
                int[] que = new int[ques[i].Count];
                ques[i].CopyTo(que, 0);

                for (int j = 0; j < que.Length; j++)
                {
                    S[i, j] = que[j];
                }

                for (int j = que.Length; j < k; j++)
                {
                    S[i, j] = ques[j - que.Length].Dequeue();
                }
            }

            Console.WriteLine(k + 1);
            for (int i = 0; i < k + 1; i++)
            {
                Console.Write(k);
                for (int j = 0; j < k; j++)
                {
                    Console.Write(" " + S[i, j]);
                }
                Console.WriteLine();
            }

            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 17360
n,k= map(int, input().split())
a= list(map(int, input().split()))
a.sort()

if k==0:
    print(a[-1])
    exit()


# めぐる式二部探索
l=0
r=pow(10,11)
while r-l>1:
    # rは常にOK、lは常にNG。
    mid=l+(r-l)//2
    cnt=k
    flag=True
    for i in range(n):
        if a[i]>mid:
            x=-(-a[i]//mid)-1
            cnt-=x

    # なんらかの判定
    if cnt>=0:
        r = mid  # 判定がOKのとき→範囲を左に狭める
    else:
        l = mid  # 判定がNGのとき→範囲を右に狭める

print(r)


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

bool ok(vector<vector<int>> &m) {
  set<int> s;
  for (int i = 0; i < 3; i++) {
    int t = 0;
    for (int j = 0; j < 3; j++)
      t += m[i][j];
    s.insert(t);
  }
  for (int i = 0; i < 3; i++) {
    int t = 0;
    for (int j = 0; j < 3; j++)
      t += m[j][i];
    s.insert(t);
  }
  s.insert(m[0][0] + m[1][1] + m[2][2]);
  s.insert(m[2][0] + m[1][1] + m[0][2]);
  return s.size() == 1;
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<vector<int>> m(3, vector<int>(3));
  m[0][0] = a;
  m[0][1] = b;
  m[1][1] = c;
  for (int i1 = -200; i1 <= 200; i1++) {
    m[0][2] = i1;
    int sum = m[0][0] + m[0][1] + m[0][2];
    m[2][2] = sum - m[0][0] - m[1][1];
    m[1][2] = sum - m[0][2] - m[2][2];
    m[1][0] = sum - m[1][1] - m[1][2];
    m[2][0] = sum - m[0][0] - m[1][0];
    m[2][1] = sum - m[0][1] - m[1][1];
    if (ok(m)) {
      for (auto &v : m) {
        cout << v[0];
        for (int i = 1; i < 3; i++)
          cout << " " << v[i];
        cout << endl;
      }
      return 0;
    }
  }
  return 0;
}

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

int main()
{
    string s;

    cin >> s;

    int len = s.length();
    int cnt = 0;
    for(int i = 1; i < len; i++){
        if(s[i] == '1' && s[i - 1] == '1'){
            s[i] = '0';
            cnt++;
        }
        if(s[i] == '0' && s[i - 1] == '0'){
            s[i] = '1';
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;

}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(i, N - 1)
    {
        if (A[i] % 2 == 1)
        {
            ll s = std::min(1LL, A[i + 1]);
            A[i] += s;
            A[i + 1] -= s;
        }
    }
    ll sum = 0;
    REP(i, N)
    {
        sum += A[i] / 2;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;

const int maxn = 6e5 + 10; 
int a[maxn];
int m[maxn << 2];

#define mid (l + r) / 2
#define lson 2 * rt
#define rson 2 * rt + 1

int query(int rt,int ql,int qr,int l,int r){
    if(l >= ql && r <= qr){
        return m[rt];
    }
    int ans = 0;
    if(ql <= mid)ans = max(ans,query(lson,ql,qr,l,mid));
    if(qr > mid)ans = max(ans,query(rson,ql,qr,mid + 1,r));
    return ans;
}
void update(int rt,int pos,int v,int l,int r){
    if(l == r){
        m[rt] = v;
        return ;
    }
    if(pos <= mid)update(lson,pos,v,l,mid);
    else update(rson,pos,v,mid + 1,r);
    m[rt] = max(m[lson],m[rson]);
}
void solved(){
    int n,k;cin>>n>>k;
    for(int i = 1; i <= n; i++)scanf("%d",&a[i]);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int res = query(1,max(a[i] - k,0),a[i] + k,1,maxn) + 1;
        update(1,a[i],res,1,maxn);
        ans = max(ans,res);
    }
    cout<<ans<<endl;
}
int main(){
    solved();
    return 0;
}


Measured memory_bytes: 8488
#include <stdio.h>
#include <stdlib.h>
int compare(const void *p0, const void *p1)
{
    return *(long long int *)p0 - *(long long int *)p1;
}
int main(void)
{
    long long int N;
    scanf("%lli", &N);
    long long int array[N];
    for (int i = 0; i < N; i++)
    {
        scanf("%lli", &array[i]);
    }
    long long int arraycpy[N];
    for (int i = 0; i<N; i++) {
        arraycpy[i] = array[i];
    }

    qsort(array, sizeof(array) / sizeof array[0], sizeof(long long int), compare);
    int m1 = array[N / 2 - 2];
    int m0 = array[N / 2 - 1];
    int p0 = array[N / 2];
    int p1 = array[N / 2 + 1];

    for (int i = 0; i < N; i++) { 
        if (arraycpy[i] <= m0) {
            printf("%i\n", p0);
        } else if (arraycpy[i] >= p0) {
            printf("%i\n", m0);
        }
    }
}

Measured memory_bytes: 5240
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n,m;cin>>n>>m;
    vvl a(n,vl(m));
    rep(i,n)rep(j,m)cin>>a[i][j],--a[i][j];

    repe(i,1,n){
        vl idx(n);
        vvl fas(m);
        vl cnt(m);
        queue<ll> q;
        rep(j,n)q.push(j);
        while(q.size()){
            ll x=q.front();q.pop();
            while(idx[x]<m&&cnt[a[x][idx[x]]]>i)++idx[x];
            if(idx[x]==m){
                goto nxt;
            }
            fas[a[x][idx[x]]].push_back(x);
            if(++cnt[a[x][idx[x]]]>i){
                for(ll y:fas[a[x][idx[x]]])q.push(y);
            }
        }
        cout<<i<<endl;
        return;
        nxt:;
    }
}

Measured memory_bytes: 2264
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll a, b;
  cin >> a >> b;
  if(a+b>=10)cout << "error";
  else cout << a+b;
  cout << endl;
  return 0;
}


Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
int dp[N];
int a[1004];
int n;
int f(int k)
{
       //cout<<k<<endl;
       if(k==0){return 0;}
       if(k<0){return 1;}
       if(dp[k] != -1){return dp[k];}
       dp[k] = 0;
       fri(i,0,n){
              if(f(k-a[i])==0){dp[k]=1;}
       }
       return dp[k];
}
int main()
{
       int k;
       cin>>n>>k;
       arrin(a,n);
       memset(dp,0,sizeof dp);
       fri(i,1,k+1){
              fri(j,0,n){
                     if(a[j]>i){continue;}
                     if(dp[i-a[j]]==0){dp[i]=1;}
              }
       }
       if(dp[k]){
              cout<<"First"<<endl;
       }
       else{
              cout<<"Second"<<endl;
       }
}


Measured memory_bytes: 640
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let (x,a) = get!(u32,u32);
    println!("{}", if x < a {0} else {10});
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};



int main(){
  string s;
  cin >> s;
  int f = (s[0]-48)*10 + (s[1]-48);
  int b = (s[2]-48)*10 + (s[3]-48);
  if(1<=f && f <= 12){
    if(1 <= b && b <= 12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }
  else if(1<=b && b <= 12){
    cout << "YYMM" << endl;
  }
  else cout << "NA" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i=0;i<t;i++)
#define ll long long int
#define ld long double
#define umpl unordered_map<ll,ll> 
#define vl vector<ll>
#define vld vector<ld>
#define vvl vector<vl>
#define pb push_back
#define mod 998244353
#define inf 1e18
#define pcout(x,p) cout<<fixed<<setprecision(p)<<x
#define all(a) a.begin(),a.end()
#define endl "\n"

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}
inline ll ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
inline ll mo(ll a,ll b){if(b<0){b=abs(b)%mod;b=a-b;return (b<0)?b+mod:b;}else{return (a+b)%mod;}}
inline ll pow(ll a,ll b){if(b==0){return 1;}else{if(b%2==0){ll temp=pow(a,b/2);return temp*temp;}
else{return a*pow(a,b-1);}}}

struct comp { 
    template<class T1,class T2,class T3,class T4>
    bool operator()(const pair<T1,T2> &p1,const pair<T3,T4> &p2){
        return p1.first<p2.first;
    }
}; 

int main(){
	string a,b;cin>>a>>b;
	ll ans=0;
	f(a.length()){
		if(a[i]!=b[i])ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3848
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n,m) for(ll i = (n); i<(m); i++)
using ll = long long int;

int give_water(int* array, int begin, int end);

int main(void){
  int n;
  if (!scanf("%d", &n))
    return 0;
  int* array = new int[n];
  rep(i,0,n){
  if (!scanf("%d", array+i))
    return 0;
  }
  printf("%d\n", give_water(array, 0, n-1));
  return 0;
}

int give_water(int* array, int begin, int end){
  if (begin > end)
    return 0;
  int min = 101;
  rep(i, begin, end+1){
    if (min > array[i])
      min = array[i];
  }
  rep(i,begin, end+1){
    array[i] -=min;
  }
  int pos = begin;
  for(; array[pos] == 0; pos++);
  int sum = min;
  rep(i, pos, end+1){
    if(array[i] == 0 && i != begin){
      sum+=give_water(array, pos, i-1);
      pos = i;
    }
  }
  if (array[end] != 0)
  sum+=give_water(array, pos, end);
  return sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    c/=a;
    cout << c*b<<endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, M, A, sum = 0;
int main(){
  scanf("%lld%lld", &N, &M);
  for (int i = 0; i < M; i++){
    scanf("%lld", &A); sum += A;
  }
  printf("%lld\n", max(-1ll, N - sum));
  
  return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    int n[4];
    REP(i,0,4) n[i] = s[i] - '0';
    if (n[0] + n[1] + n[2] + n[3] == 7) printf("%d+%d+%d+%d=7\n", n[0], n[1], n[2], n[3]);
    else if (n[0] + n[1] + n[2] - n[3] == 7) printf("%d+%d+%d-%d=7\n", n[0], n[1], n[2], n[3]);
    else if (n[0] + n[1] - n[2] + n[3] == 7) printf("%d+%d-%d+%d=7\n", n[0], n[1], n[2], n[3]);
    else if (n[0] + n[1] - n[2] - n[3] == 7) printf("%d+%d-%d-%d=7\n", n[0], n[1], n[2], n[3]);
    else if (n[0] - n[1] + n[2] + n[3] == 7) printf("%d-%d+%d+%d=7\n", n[0], n[1], n[2], n[3]);
    else if (n[0] - n[1] + n[2] - n[3] == 7) printf("%d-%d+%d-%d=7\n", n[0], n[1], n[2], n[3]);
    else if (n[0] - n[1] - n[2] + n[3] == 7) printf("%d-%d-%d+%d=7\n", n[0], n[1], n[2], n[3]);
    else if (n[0] - n[1] - n[2] - n[3] == 7) printf("%d-%d-%d-%d=7\n", n[0], n[1], n[2], n[3]);
}

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

Measured memory_bytes: 256
import collections

N=int(input())
A=[int(v) for v in input().split()]

C = collections.Counter(A)
C2 = {}
total = 0
for v in C:
  c = C[v]
  c2 = c*(c-1)//2
  total += c2
  C2[v]=(c2-(c-1)*(c-2)//2)
  
for a in A:
  print(total-C2[a])

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll mod = 1e9+7;

ll factorial(int n) {
  if(n <= 1) return 1;
  return n*factorial(n-1)%mod;
}

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

  int n, m; cin >> n >> m;

  if(abs(n-m) >= 2) {
    cout << 0 << '\n';
    return 0;
  }

  ll ans;
  if(n == m) ans = 2*factorial(n)*factorial(m)%mod;
  else ans = factorial(n)*factorial(m)%mod;

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
n=int(input())
l=list(map(int,input().split()))
counter=[0]*(10**6+1)
l=sorted(l)
for i in l:
    counter[i]+=1
    if counter[i]<2:
        for j in range(2*i,10**6+1,i):
            counter[j]+=2
print(counter.count(1))

Measured memory_bytes: 107492
#include "bits/stdc++.h"
using namespace std;
    int main(){
    int a, b;
    cin >> a >> b;
    if(a > 12)
    cout << b << endl;
    else if(a > 5)
    cout << b / 2 << endl;
    else 
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
s = []
t = []
for i in range(n):
    ss,tt = input().split()
    s.append(ss)
    t.append(int(tt))
x = input().strip()
onn = False
sm = 0
for i in range(n):
    if onn:
        sm += t[i]
    elif s[i]==x:
        onn = True
print(sm)


Measured memory_bytes: 38256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){

    ll N,M;
    cin >> N >> M;

    Graph G(N);
    for (ll i = 0; i < M; ++i) {
        ll a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // BFS のためのデータ構造
    vector<ll> dist(N, -1); // 全頂点を「未訪問」に初期化
    //queue<ll> que;
    ll total = 0;

    // BFS 開始 (キューが空になるまで探索を行う)
    REP(i,N){
        if(dist[i] == -1){
            dist[i] = total;
            //cout << dist[i] << endl;
            total++;
            queue<ll> que;
            que.push(i); 
            while (!que.empty()) {
                ll v = que.front(); // キューから先頭頂点を取り出す
                que.pop();

                // v から辿れる頂点をすべて調べる
                for (ll nv : G[v]) {
                    if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

                    // 新たな白色頂点 nv について距離情報を更新してキューに追加する
                    dist[nv] = dist[v];
                    que.push(nv);
                }   
            }
        }
    }
    cout << total-1 << endl;

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector <int> H(N);
    int ans = 1;
    bool canSee=true;
    for (int i=0; i<N; i++) cin >> H.at(i);
    for (int i=1; i<N; i++) {
        canSee=true;
        for (int j=0; j<i; j++) {
            if (H.at(i)<H.at(j)) {
                canSee=false;
                break;
            }
        }
        if (canSee) ans++;
    }
    cout << ans;
}

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

int main(){
  int n,m; cin >> n >> m;
  vector<string> a(n), b(m); 
  for( int i = 0; i < n; i++ ) cin >> a[i];
  for( int i = 0; i < m; i++ ) cin >> b[i];
  
  bool ans = false;
  for( int i = 0; i < n-m+1; i++ ){
    for( int j = 0; j < n-m+1; j++ ){
      bool exist = true;
      for( int k = 0; k < m; k++ ){
        for( int l = 0; l < m; l++ ){
          if( a[i+k][j+l] != b[k][l] ){
            exist = false;
            break;
          }
        }
        if( !exist ) break;
      }
      if( exist ){
        ans = true;
        break;
      }
    }
    if(ans) break;
  }
  
  cout << ( ans ? "Yes":"No" ) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 55;
const int L = 18;

int n,k,s,t;
ll a[N], comb[N][N];

#define time __nico_time
int time, mod[1<<L], cnt[1<<L];

ll solve() {
    cin >> n >> k >> s >> t;
    if ((s & t) != s) return 0;
    {
        int sz = 0;
        forn(_,n) {
            ll x; cin >> x;
            if ((s & x) != s) continue;
            if ((x | t) != t) continue;
            a[sz++] = x-s;
        }
        n = sz;
    }
    ll ans = 0;
    for (int mask = t-s; ; mask = (mask-1)&(t-s)) {
        ++time;
        vi seen;
        forn(i,n) {
            int sub = mask & a[i];
            if (mod[sub] < time) {
                cnt[sub] = 0;
                mod[sub] = time;
                seen.pb(sub);
            }
            cnt[sub]++;
        }
        int sign = __builtin_popcount(mask)%2 ? -1 : 1;
        for (auto sub : seen) {
            ans += sign * comb[cnt[sub]][k];
        }
        if (mask == 0) break;
    }
    return ans;
}

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

    forn(n,N) {
        comb[n][0] = 1;
        forsn(r,1,n+1) comb[n][r] = comb[n-1][r-1] + comb[n-1][r];
    }
    forn(n,N) {
        forsn(r,2,N) comb[n][r] += comb[n][r-1];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 5744
#include <stdio.h>

int main(){

  int n,i,a[100];
  scanf("%d",&n);

  for(i=0;i<n;i++){ 
    scanf("%d",&a[i]);
  }
    for(i=n-1;i>=0;i--){
      printf("%d",a[i]);
      if(i!=0){
	printf(" ");
      }	else {
        printf("\n");
      }
    }
  return 0;
    }

Measured memory_bytes: 600
import math
a, b, x = map(int, input().split())
sq = a*a*b/2

if sq >= x:
    A1 = 2*x/(a*b)
    num = math.atan(b/A1)
else:
    B1 = 2*x/a**2 - b
    num = math.atan((b-B1)/a)

print(math.degrees(num))


Measured memory_bytes: 9312
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	int mn = 1e9;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	for (int i = 0; i < N; i++) {
		int t = abs(sum - N*A[i]);
		if (mn > t) {
			mn = t;
			res = i;
		}
	}
	cout << res << endl;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll n, k, p;
    double max_e = 0.0;
    double e[200005];
    m0(e);
    cin >> n >> k;

    for(ll i = 1; i <= n; i++) {
        cin >> p;
        e[i] = e[i - 1];
        for(ll j = 1; j <= p; j++) {
            e[i] += (double)j / p;
        }
    }

    for (ll i = k; i <= n; i++) {
        double now = e[i] - e[i - k];
        max_e = max(max_e, now);
    }

    printf("%.10f\n", max_e);
    return 0;
}

Measured memory_bytes: 5320
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n;
int k;
int u;
string s,t;
vector<int> d[27];
vector<int> e[27];
int ll[200006];
int rr[200006];
int main()
{
	cin>>s;
	cin>>t;
	n=s.size();
	rep(i,n)
	{
		k=(int)(s[i]-'a');
		u=(int)(t[i]-'a');
		d[k].push_back(i);
		e[u].push_back(i);
	}
	rep(kkk,26)rep(i,d[kkk].size())
	{
		ll[d[kkk][i]]=d[kkk][0];
	}
	rep(kkk,26)
	{
		rep(i,e[kkk].size())
		{
			rr[e[kkk][i]]=e[kkk][0];
		}
	}
	rep(i,n)
	{
		if(ll[i]!=rr[i])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 4616
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <algorithm>    // std::copy
#include <iterator>     // std::back_inserter
#include <set>
using namespace std;
 
int max(int a, int b){
    if(a > b){
        return a;
    }
    else {
        return b;
    }
}

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

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

    int count = 0;
    int m = 0;
    for(int i = 1 ; i < N ; i++){
        if(H[i-1] >= H[i] ){
            count++;
            m = max(count, m);
            // cout << "a" <<endl;
        }
        else {
            count=0;
        }
    }
    cout << m << endl;


}



Measured memory_bytes: 640
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

/*
10 10
B R G R B R G B R G
G B R B G B R G B R
R G B G B G B R G B
B R G R G R G B R G
G B R G R G B R G B
R G B R G B R B R G
B R G B R G B R G B
G B R G B R G B R G
B R G B G B R G B R
R B R G B G B R G B
0 0
 */

//Filling Game
public class Main{
	
	int h, w, N, res;
	int[][] a, id;
	int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
	Set<Integer>[] adj;
	int[] col, bfs;
	boolean[] u;
	
	boolean ok(int i, int j){
		return 0<=i&&i<h&&0<=j&&j<w;
	}
	
	void fill(int i, int j, int ID, int col){
		a[i][j] = -1;
		id[i][j] = ID;
		for(int k=0;k<4;k++){
			int ni = i+d[k][0], nj = j+d[k][1];
			if(ok(ni, nj)&&a[ni][nj]==col)fill(ni, nj, ID, col);
		}
	}
	
	@SuppressWarnings("unchecked")
	void f(int depth, int sum){
		if(sum==N){
			res = depth; return;
		}
		Arrays.fill(bfs, 1<<29);
		Queue<Integer> q = new LinkedList<Integer>();
		for(int i=0;i<N;i++)if(u[i]){
			bfs[i] = 0; q.add(i);
		}
		int max = 0;
		while(!q.isEmpty()){
			int v = q.poll();
			for(int x:adj[v]){
				if(bfs[x]==1<<29){
					bfs[x] = bfs[v]+1; q.add(x);
					max = Math.max(max, bfs[x]);
				}
			}
		}
		if(res<=depth+max)return;
		Set<Integer>[] nx = new Set[3];
		for(int i=0;i<3;i++)nx[i]=new HashSet<Integer>();
		for(int i=0;i<N;i++)if(u[i]){
			for(int x:adj[i]){
				if(!u[x])nx[col[x]].add(x);
			}
		}
		for(int c=0;c<3;c++)if(!nx[c].isEmpty()){
			for(int x:nx[c])u[x]=true;
			f(depth+1, sum+nx[c].size());
			for(int x:nx[c])u[x]=false;
		}
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		adj = new Set[150];
		for(;;){
			w = sc.nextInt(); h = sc.nextInt();
			if((w|h)==0)break;
			a = new int[h][w];
			id = new int[h][w];
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				char c = sc.next().charAt(0);
				a[i][j] = c=='R'?0:c=='G'?1:2;
			}
			N = 0;
			col = new int[h*w];
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(a[i][j]!=-1){
				col[N] = a[i][j];
				fill(i, j, N, a[i][j]);
				N++;
			}
			for(int i=0;i<N;i++)adj[i] = new HashSet<Integer>();
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				for(int k=0;k<4;k++){
					int ni = i+d[k][0], nj = j+d[k][1];
					if(ok(ni, nj)&&id[i][j]!=id[ni][nj])adj[id[i][j]].add(id[ni][nj]);
				}
			}
			res = N;
			u = new boolean[N];
			u[0] = true;
			bfs = new int[N];
			f(0, 1);
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    if(x<a){
      System.out.println(0);
    }else{
      System.out.println(10);
    }
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define each(e,v) for(auto&& e:(v))
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;

int main() {
    int N, L; cin >> N >> L;
    vstring S(N);
    rep(i, N) cin >> S[i];
    sort(S.begin(), S.end());
    rep(i, N) cout << S[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, k;
cin >> n >> k;
  vi v(n);
  	int res = 0;
  for(int& x : v){
  	cin >> x;
	res += (x >= k); 
  }
  cout << res;

	
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(ll i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,m;
  cin >> n >> m;
  
  vector<ll> dp(1<<n,-1);
  dp[0] = 0;
  rep(mi,m){
    ll a,b; ll c = 0;
    cin >> a >> b;
    rep(bi,b){
      int ci;
      cin >> ci;
      c |= 1<<(ci-1);
    }
    rep(i,1<<n){
      if(dp[i]==-1) continue;
      ll ni = i|c;
      dp[ni] = dp[ni] == -1
             ? dp[i] + a
             : min(dp[ni],dp[i] + a);
    }
  }
  cout << dp[(1<<n)-1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define sp fixed<<setprecision
#define sz sizeof
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
bool pr[1000007];
ll fpow(ll x,ll y){x=x%MOD;ll res=1;while(y){if(y&1)res=res*x;res%=MOD;y=y>>1;x=x*x;x%=MOD;}return res;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  ll n;
  cin>>n;
  ld a[n];
  for(int i=0;i<n;i++)
  cin>>a[i];
  ld prob[2*n+1];
  memset(prob,0,sizeof(prob));
  prob[n]=1.00;
  for(int i=0;i<n;i++)
  {
    ld temp[2*n+1];
    for(int j=0;j<=2*n;j++)
    {
      if(j==0)
      {
        temp[j]=prob[j+1]*(1-a[i]);
      }
      else if(j==2*n)
      {
        temp[j]=prob[j-1]*a[i];
      }
      else
      {
        temp[j]=prob[j-1]*a[i]+prob[j+1]*(1-a[i]);
      }
    }
    for(int j=0;j<=2*n;j++)
    {
      prob[j]=temp[j];
    }
  }
  ld res=0;
  for(int i=n+1;i<=2*n;i++)
  res+=prob[i];
  cout<<fixed<<setprecision(10)<<res;


}


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

int main() {
  vector<int> N(3);
  for(int i=0;i<3;i++){
    cin >>N.at(i);
  }
  sort(N.begin(),N.end());
  cout <<(N.at(0)+10*N.at(2)+N.at(1)) <<endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string, std.conv;
import std.array, std.algorithm;
import std.typecons;

void main() {
  for(int N; N = readln.chomp.to!int, N; ) {
    alias Tuple!(string, "name", int, "win", int, "lose") Team;
    auto v = new Team[N];
    foreach(i; 0 .. N) {
      auto s = readln.split;
      string name = s[0];
      int win = 0, lose = 0;
      foreach(k; s[1 .. N]) {
        int ks = k.to!int;
        if(ks == 0) win++;
        else if(ks == 1) lose++;
      }
      v[i] = tuple(name, win, lose);
    }

    bool comp(Team a, Team b) {
      if(a.win != b.win) return a.win > b.win;
      return a.lose < b.lose;
    }
    sort!(comp)(v);
    foreach(t; v)
      writeln(t.name);
  }
}

Measured memory_bytes: 1012
import sys
input=sys.stdin.readline
from collections import deque
n,q=map(int,input().split())
nt=[list(input().split()) for _ in range(n)]
t=0
l=deque(nt)
while l:
    tmp=l.popleft()
    tmp[1]=int(tmp[1])
    if tmp[1]>q:
        tmp[1]-=q
        l.append(tmp)
        t+=q
    else:
        t+=tmp[1]
        print(tmp[0],t)



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

int main() {
int N;
cin >> N;
double ans;
if (N % 2 == 0) {
    ans = 1.0 / 2.0;
}
else {
    double n = N;
    ans = (n + 1) / (2 * n);
}
cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
LL mod=1000000007;
LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};




int main(){
    int n;cin >> n;
    string s;cin >> s;
    int ans = 0;
    s+='#';
    for (int i = 1; i <= n; i++) {
        if(s[i]!=s[i-1]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512