akhauriyash/Code-Regression huggingface dataset:
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<ll> a(n); rep(i, n)cin >> a[i];
	ll s = 0;
	ll MOD = 1e9 + 7;
	rep(i, n)
	{
		s += a[i];
		s %= MOD;
	}
	ll res = 0;
	rep(i, n)
	{
		s -= a[i];
		if (s < 0)s += MOD;
		res += a[i] * s;
		res %= MOD;
	}
	cout << res << endl;
}

Measured memory_bytes: 4824
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	map<int,int> mp;
	rep(i,m){
		int a, b;
		cin >> a >> b;
		mp[a]++;
		mp[b]++;
	}

	for(auto i : mp){
		if(i.second % 2 == 1){
			cout << "NO" << endl;
			return  0;
		}
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
 
 
 
 
int main(){
int a,b;
  cin>>a>>b;
  vector<int64_t>card(a);
  vector<P>score(b);
  
  for(int i=0;i<a;i++)
  {
  int64_t d;
    cin>>d;
  card.at(i)=d;
  }
  
for(int i=0;i<b;i++)
  {
  int64_t d,e;
    cin>>d>>e;
  score.at(i)=P(e,d);
  }
  sort(card.begin(),card.end());
  sort(score.begin(),score.end());
  int t=0;
  int64_t dp[b]; 
  for(int i=0;i<b;i++)
  {
   if(t==a) dp[i]=t;
   else{
     while(card.at(t)<score.at(i).first )
  {
  t=t+1;
     if (t==a) break;
  }
  dp[i]=t;
   }
   
  }
  int64_t df[b];
  int64_t p=0;
  for(int i=b-1;i>=0;i--)
  {
  df[i]=p; 
    p=p+score.at(i).second;
 
  }
  int64_t sum=0;
  int64_t y=0;
  for(int i=0;i<b;i++)
  {
  if(dp[i]-df[i]>0){
  if(score.at(i).second > dp[i]-df[i]){
    sum=sum+(dp[i]-df[i])*score.at(i).first;
    y=y+dp[i]-df[i];
  }
    else{
      sum=sum+score.at(i).second*score.at(i).first;
    y=y+score.at(i).second;
    }
     
  
  }
  
  }
  for(int i=y;i<a;i++)
  {
  sum=sum+card.at(i);

  }
  cout<<sum<<endl;

}
 

Measured memory_bytes: 4096
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

int main() {
	int n;
	scanf("%d", &n);
	ll sm = 0;
	map <ll, int> las;
	las[0] = -1;
	vector <int> to(n, -1);
	rep(i, n) {
		int a; scanf("%d", &a);
		sm += a;
		if (las.find(sm) != las.end())
			to[i] = las[sm] + 1;
		las[sm] = i;
	}
	vector <ll> f(n);
	rep(i, n) if (~to[i]) f[i] = (to[i] ? f[to[i] - 1] : 0) + 1;
	ll ans = 0;
	rep(i, n) ans += f[i];
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 15104
//! Bismillahi-Rahamanirahim.
/** ========================================**
 ** @Author: Md. Abu Farhad ( RUET, CSE'15)
 ** @Category:
/** ========================================**/

#include<bits/stdc++.h>
#include<stdio.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;


#define ll                  long long
#define scl(n)              scanf("%lld",&n)
#define scll(n, m)              scanf("%lld%lld",&n, &m)
#define scc(c)	            scanf("%c",&c)
#define fr(i,n)             for (ll i=0;i<n;i++)
#define fr1(i,n)            for(ll i=1;i<=n;i++)
#define pfl(x)              printf("%lld\n",x)
#define pb                  push_back
#define debug               cout<<"I am here"<<endl;
#define pno                 cout<<"NO"<<endl
#define pys                 cout<<"YES"<<endl
#define tcas(i,t)           for(ll i=1;i<=t;i++)
#define all(x) 	            (x).begin(), (x).end()
#define pr                  pair<ll, ll>
#define ff                  first
#define ss                  second

#define l(s)                s.size()
#define asort(a)            sort(a,a+n)
#define dsort(a)            sort(a,a+n,greater<int>())
#define vasort(v)           sort(v.begin(), v.end());
#define vdsort(v)           sort(v.begin(), v.end(),greater<int>());
#define uniquee(x)          x.erase(unique(x.begin(), x.end()),x.end())
#define pn                  printf("\n")
#define el                  cout<<endl
#define md                  1000000007
#define inf                 9e18
#define ps                  cout<<" ";
#define Pai                  acos(-1.0)
#define mem(a,i)            memset(a, i, sizeof(a))
#define pcas(i)             cout<<"Case "<<i<<": "<<endl;
#define fast 	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)


map<ll, ll>mp;
ll n;
bool ispos(ll mid)
{
    ll x=mid, cnt=0 ;
    while(mid>0)
    {
        cnt+= mid%10;
        mid/=10;
    }

    cout<<x<<" "<<cnt<<" "<<x+cnt<<endl;

    return x+cnt;
}


int main()
{
        ll m,b,c,d,i,j,k,x,y,z,l,r, p, q;
        string s1, s2, s3, s4;
        ll  ans=0;

        cin>>n>>m>>k;
        string s[n];
        fr(i, n)cin>>s[i];


        x=pow(2, n) , y=pow(2, m);

        fr(mask, x)
        {
            fr(mask1 , y)
            {
                ll cnt=0;
                fr(i, n) fr(j, m)
                if(  (mask & (1<<i ))==0 and (mask1 & (1<<j ))==0  and  s[i][j]=='#')cnt++;

                if(cnt==k)ans++;
            }
        }

        pfl(ans);


        /*
        ll cnt=0,cn=0,ans=0,sum=0 ;
        vector<ll>v;
        cin>>n;

        l=1, r=n;

        while(l<=r)
        {
           ll mid=(l+r)/2;
           if(ispos(mid) >=n  )
           {
               if(ispos(mid)==n)  v.pb(mid) ;
               r=mid+1;
           }
           else l=mid-1;
        }

        cout<<v.size()<<endl;
        fr(i, v.size())cout<<v[i]<<" ";
        */
return 0;
}

/// **************************Before submit****************************

///    ****Please check all base case output  and printing " YES or NO " ***
///    *check for integer overflow,array bounds
///    *check for n=1




Measured memory_bytes: 4124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;
#define INF 1000000007
#define MOD 1000000007

ll		nC2(ll n)
{
	return (n * (n - 1) / 2);
}

int		main(void)
{
	int n;
	cin >> n;
	map <string, int> m;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		auto it = m.find(s);
		if (it == m.end())
			m.insert(make_pair(s, 1));
		else
			it->second++;
	}
	ll ans = 0;
	for (auto it = m.begin(); it != m.end(); it++)
		ans += nC2((ll)it->second);
	cout << ans << endl;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
 
#define IOS 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sd(n)       scanf("%d", &n)
#define sdd(a,b)    scanf("%d %d", &a, &b)
#define sddd(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sld(n)      scanf("%lld", &n)
#define slld(a,b)   scanf("%lld %lld", &a, &b)
#define sllld(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define slu(n)      scanf("%llu", &n)
#define sllu(a,b)   scanf("%llu %llu", &a, &b)
#define slllu(a,b,c) scanf("%llu %llu %llu", &a, &b, &c)
#define ss(a)		scanf("%s", a)
#define inStrAftInSome cin.ignore(numeric_limits<streamsize>::max(),'\n')		//input string(with whitespace) after input something(char, int, bool, str)
#define all(a) 		a.begin(),a.end()
#define unq(x)      x.erase(unique(all(x)), x.end()
#define mp 			make_pair
#define mt 			make_tuple
#define sz(av) 		int((av).size())					//return size of vec
#define CLR(arr)    memset(arr, 0, sizeof(arr))			//assign 0 to whole arr
#define SET(vec)    memset(arr, -1, sizeof(arr))		//assign -1 to whole arr
#define CLRV(vec)	fill(vec.begin(), vec.end(), 0)		//assign 0 to whole vec
#define SETV(vec,n,a) vec.assign(n, a)	
#define vtd(rowsize,colsize,type,name) 		vector < vector <type> > name(rowsize,vector <type> (colsize)); 	//assign to first n elements value a in vec
#define SETB(a)		memset(a, true, sizeof(a))			//boolean array initialize by true value
#define CLRB(a)		memset(a, false, sizeof(a))			//boolean array initialize by false value
#define vintitr 	vector<int>::iterator
#define vlnlnitr 	vector<long long>::iterator
#define sintitr 	set<int>::iterator
#define slnlnitr 	set<long long>::iterator
#define aa			first
#define bb			second
#define mod 		1000000007
#define PI 			acos(-1.00)
#define psb 		push_back
#define ppb			pop_back
#define ppb			pop_back
#define psf			push_front
#define ppf			pop_front
#define in 			inset
#define rep(i, n) 	for(int i=0; i<n; i++)
#define repi(i,j,n) for(int i=j; i<n; i++)
#define rof(i, n)   for(int i=n-1; i>=0; i--)
#define roff(i, n, f)	for(int i = n-1; i>=f; i--)
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define __lcm(a, b)	a*b / __gcd(a, b)
#define __builtin_zerocount(a)	8*sizeof(a)-__builtin_popcount(a)-__builtin_clz(a)-__builtin_ctz(a)
#define D(t)        cerr << #t " = " <<t  << '\n'
#define DBG         cerr << "Hi!" << '\n'
 
 
typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef vector< int > 		vi;
typedef vector< vi >		vvi;
typedef pair<int, int> 		pii;
typedef tuple<int,int,int>  tiii;



int main()
{
	llu n;	cin >> n;
	llu ans;
	int d = sqrt(n+1);
	for (int i = d; i > 0; --i)
	{
		if(n % i == 0){
			ans = i + (n / i) - 2;
			break;
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,b=0,c,x=0;
  cin>>x;
  while(x>0)
  {
     if(x%10==9)
       {b=1;
       break;
       }
       x/=10;
  }
  if(b)
  {
    //cout<<max(1ll*0,x-a);
    Yes
  }
  else
  {
    No
    //cout<<"B"<<endl;
  }
  
  
  
  

}
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
const int N=2e5+5;
std::vector<int> g[N];
int ans[N],n,q;
void dfs(int u,int fa,int x) {
    ans[u]+=x;
    for(int v:g[u]) if(v!=fa) dfs(v,u,ans[u]);
}
int main() {
    scanf("%d%d",&n,&q);
    for(int i=1,x,y;i<n;i++) {
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int x,y;q--;) {
        scanf("%d%d",&x,&y);
        ans[x]+=y;
    }
    dfs(1,1,0);
    for(int i=1;i<=n;i++) printf("%d%c",ans[i]," \n"[i==n]);
    return 0;
}


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

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

int n, pos=0;
vector<int> pre, in, post;

void reconstruction(int l, int r) {
  if (l >= r) return;
  int root = pre[pos++];
  int m = distance(in.begin(), find(in.begin(), in.end(), root));
  reconstruction(l, m);
  reconstruction(m+1, r);
  post.push_back(root);
}

int main() {
  cin >> n;
  rep(i,n) {
    int t;
    cin >> t;
    pre.push_back(t);
  }
  rep(i,n) {
    int t;
    cin >> t;
    in.push_back(t);
  }
  
  reconstruction(0, n);

  rep(i,n) printf("%d%c", post[i], (i==n-1?'\n':' '));
  return 0;
}



Measured memory_bytes: 3304
import itertools


n, a, b, c = map(int, input().split())
L = [int(input())for _ in range(n)]
L_perm = list(itertools.permutations(L))
ans = 10**9
for l in L_perm:
    for i in range(1, n-1):
        A_tree = l[:i]
        synthesis_A = 10 * (i-1)
        fix_A = abs(a-sum(A_tree))
        for j in range(i+1, n):
            B_tree = l[i:j]
            synthesis_B = 10 * (j-i-1)
            fix_B = abs(b-sum(B_tree))
            for k in range(j+1, n+1):
                C_tree = l[j:k]
                synthesis_C = 10 * (k-j-1)
                fix_C = abs(c-sum(C_tree))

                total = fix_A + fix_B + fix_C + synthesis_A + synthesis_B + synthesis_C
                ans = min(ans, total)

print(ans)

Measured memory_bytes: 58972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(Math.Min(r[0] * r[1],r[2]));
        }
    }
}

Measured memory_bytes: 13396
import sys

N = int(input())

W = []
for n in range(N):
    W.append(input())

ret = "Yes"
# 重複チェック
dict = {}
for w in W:
    if w in dict:
        dict[w] += 1
        if dict[w] >= 2:
            # print("Duplicated!")
            ret = "No"
    else:
        dict[w] = 1
# print(dict)

if ret != "No":
    current = W[0]
    for i in range(1, N):
        if (current[-1] != W[i][0]):
            # print("Not Connected: " + current + "," + W[i])
            ret = "No"
            break
        current = W[i]

print(ret)


Measured memory_bytes: 3064
n,m = map(int,input().split())
k = []
s = []
for _ in range(m):
    l = list(map(int,input().split()))
    k.append(l[0])
    s.append(l[1:])
p = list(map(int,input().split()))

# bit全探索
ans = 0
for i in range(2**n):
    c = 0

    # スイッチのOn/Offの状態
#    print (i,bin(i))

    # 各ライトについて
    for j in range(m):
        sum = 0
        for x in s[j]:
            sum += i >> x-1
        if sum%2==p[j]:
            c += 1
        if c == m:
            ans += 1

print (ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cstdio>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if (a % 500 <= b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
N, D, A = map(int, input().split())

Monster = [0]*N
for i in range(N):
    Monster[i] = list(map(int, input().split()))

Monster.sort(key=lambda x:x[0])

from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort

from collections import deque

d = deque()
damage = 0
ans = 0
for i in range(N):
    while len(d)>0:
        a = d.popleft()
        if a[0]==i:
            damage -= a[1]
        else:
            d.appendleft(a)
            break
    Monster[i][1] -= damage
    count = -(-max(Monster[i][1],0)//A)
    ans += count
    right = Monster[i][0]+2*D
    ind = bisect(Monster,[right,10**9+1])
    damage += A*count
    d.append([ind,A*count])
print(ans)

Measured memory_bytes: 75992
a, b, c, d, e, k = [int(input()) for i in range(6)]

print('Yay!' if abs(a-b) <= k and abs(a-c) <= k and abs(a-d) <= k and abs(a-e) <= k and abs(b-c) <= k and abs(b-d) <= k and abs(b-e) <= k and abs(c-d) <= k and abs(c-e) <= k and abs(d-e) <= k else ':( ')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
main(){
    int n,res=0 ;
    cin>>n;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                res+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<res<<endl;
}


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

int main() {

  int a,b,i,c=0,e,f,g;
  cin>>a>>b;
  for(i=a;i<=b;i++){
    e=i%100;
    f=e%10;
    g=e/10;
  if(i/1000==(g+f*10))
    c++;
  }
  cout<<c;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,a,b;
  cin>>x>>a>>b;
  if(max(x,a)-min(x,a)<max(x,b)-min(x,b))cout<<'A'<<endl;
  else cout<<'B'<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a <= b ? f(a, b) : f(b, a));
        }
    }

    private static String f(int a, int b) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < b; i++) {
            sb.append(a);
        }
        return sb.toString();
    }
}

Measured memory_bytes: 26904
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int n,k;
int a[110];
ll dp[110][100010];

int main(){
  cin>>n>>k;
  rep(i,n) cin>>a[i];
 
  rep1(i,k) dp[0][i]=0;
  rep(i,n+1) dp[i][0]=1;
  rep1(i,n){
    rep1(j,k){
      if(j-a[i-1]-1>=0){
	dp[i][j]=((dp[i][j-1]+dp[i-1][j])%MOD-dp[i-1][j-a[i-1]-1])%MOD;
	if(dp[i][j]<0) dp[i][j]+=MOD;
      }
      else{
	dp[i][j]=(dp[i][j-1]+dp[i-1][j])%MOD;
      }
    }
  }
  
  prin(dp[n][k]);
  
  
  

  return 0;
}


Measured memory_bytes: 80128
#include<iostream>
using namespace std;
int main()
{
 int a,b,c;
 cin>>a;
 cin>>b;
 c= a+b;
 if(a%3==0)
 {
     cout<<"Possible";
 }
 else if(b%3==0)
 {
     cout<<"Possible";
 }
 else if(c%3==0)
 {
     cout<<"Possible";
 }
 else
 {
     cout<<"Impossible";
 }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int image[105][105];
int B[105][105];
bool check(int y,int x){
	for(int i=0; i<m; i++){
		for(int j=0; j<m; j++){
			if(B[i][j]!=image[i+y][j+x]) return false;
		}
	}
	return true;
}
int main(){
	cin>>n>>m;
	for(int i=0; i<n; i++){
		string s;
		cin>>s;
		for(int j=0; s[j]; j++){
			if(s[j]=='#') image[i][j] = 1;
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++) image[i][j+n] = image[i][j];
	}
	for(int i=0; i<m; i++){
		string s;
		cin>>s;
		for(int j=0; s[j]; j++){
			if(s[j]=='#') B[i][j] = 1;
		}
	}
	bool exist = false;
	for(int i=0; i<=n-m; i++){
		for(int j=0; j<n; j++){
			if(check(i,j)) exist = true;
		}
	}
	if(exist) cout<<"Yes";
	else cout<<"No";
}

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if((B <= A) && (B <= C) && (C <= A)) {
        cout << "Yes" << endl;
    } else if((B >= A) && (B >= C) && (C >= A)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    //
    // B, C, A or A, C, B
    return 0;
}

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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = static_cast<ll>(1e9 + 7);



int main() {
	int N, K;
	cin >> N >> K;
	cout << ((K == 1)? 0 : N - K) << endl;
}

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

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];

    //エラトステネスの篩
    int P_MAX = 1000005;
    vector<int> pmn(P_MAX, -1);     //smallest prime number that can divide i(pmn[i] == i -> i is prime number)
    //vector<int> plst;               //prime number list
    //plst.emplace_back(2);
    for(int i = 1; i < P_MAX; i++)
        if(i%2 == 0) pmn[i] = 2;
        else pmn[i] = i;
    for(int i = 3; i*i < P_MAX; i += 2){
        if(pmn[i] == i){
            //plst.emplace_back(i);
            for(int j = 3*i; j < P_MAX; j += 2*i)
                if(pmn[j] == j) pmn[j] = i; 
        }
    }

    int flag = 2;
    vector<int> cnt(P_MAX,0);
    rep(i,n){
        while(a[i] != 1){
            int apmn = pmn[a[i]];
            cnt[apmn]++;
            while(a[i]%apmn == 0) a[i] /= apmn;
        }
    }
    rep(i,cnt.size()){
        if(cnt[i] > 1){
            if(cnt[i] == n){
                flag = 0;
                break;
            }
            flag = 1;
        }
    }

    if(flag == 2){
        puts("pairwise coprime");
    }else if(flag == 1){
        puts("setwise coprime");
    }else{
        puts("not coprime");
    }
}


Measured memory_bytes: 14788
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main() {
  int N, K; cin >> N >> K;
  ll ans = 0;
  for (ll i = K ; i <= N + 1 ; i++) {
    ll mn = i * (i - 1) / 2 % MOD, mx = (2 * N - i + 1) * i / 2 % MOD;
    //    cout << i << " " << mn << " " << mx << endl;
    ans = (ans + (mx - mn + 1 + MOD) % MOD) % MOD;
  }
  cout << ans << endl;
}

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

#define f_io ios::sync_with_stdio(false);cin.tie(0)
#define ll long long
#define FOR(a,b,c) for(ll a=b;a<c;a++)
#define cases long t;cin>>t;while(t--)


int main(){

        int n,a=0,b=0;
        cin>>n;
        vector<int> f(n);
        vector<int> arr(n);
        vector<int> k(n+1,1);
        vector<int> l(n+1,1);
        f[n-1]=0;
        f[n-2]=1;
        int j=2;
        for(int i=n-3;i>=0;i--){
            f[i]=j*f[i+1];
            j++;
        }
        FOR(i,0,n) cin>>arr[i];
        FOR(i,0,n){
            int num =arr[i];
            a+= f[i]*(num-k[num]);
            while(num<=n){
                k[num]++;
                num++;
            }
        }

        FOR(i,0,n) cin>>arr[i];
        FOR(i,0,n){
            int num =arr[i];
            b+= f[i]*(num-l[num]);
            while(num<=n){
                l[num]++;
                num++;
            }
        }
        cout<<abs(a-b)<<endl;
        //FOR(i,0,n) cout<<f[i]<< " ";
        //cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		
		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int K = scan.nextInt();
		int X = scan.nextInt();
		int Y = scan.nextInt();
		
		if(N<=K){//NがK以下
			System.out.println(N*X);
			
		}else{//NがKより大きい
			System.out.println(K*X+(N-K)*Y);
		}
		
		
		
		
	}

}


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

#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PER(j,n,a) for (int j=n-1;j>=a;j--)
#define REP(i,a,n) for (int i=a;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define show(x) cout<<(x)<<endl
#define UM unordered_map
#define PB push_back
#define V vector
#define EPS 1e-8
typedef unsigned long ul;
typedef long long ll;
typedef string str;
/*FIN*/
int n,w,mv,r;
str s;
int main() {
	FAST;
	cin>>n;
	cin>>s;

	w=0;
	REP(i,0,n) w+=(s[i]=='W');
	if(min(w,n-w)==0) {
		show(0);
		return 0;
	}

	r = n-w;
	mv = 0;
	REP(i,0,n) {
		if(s[i]=='W')
			mv++;
		r--;
		if(r==0) break;
	}
	show(min(mv,n-w));
	return 0;
}



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

/* I'm too stupid to solve this problem */

using namespace std;
#define PI 3.14159265359
#define eps 1e-7
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
const int INF = 1<<29;
typedef unsigned long long ull;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int n,m;

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);	

    cin >> n >> m;

    cout << (n-1)*(m-1) << endl;
    
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<pair<int,int>>ab(n); for(auto&i:ab)cin>>i.first>>i.second;
	sort(ab.begin(),ab.end());
	int64_t ans=0;
	for(auto&i:ab){
		int mn=min(m,i.second);
		ans+=(int64_t)mn*i.first;
		m-=mn;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;

int n;
ll h;
ll a[100005], b[100005];
vector<ll> s, t;



int main(){
  cin >> n >> h;
  for(int i = 0; i < n; ++i){
    cin >> a[i] >> b[i];
    //cout << a[i] << b[i] << endl;
    s.push_back(a[i]);
    t.push_back(b[i]);
  }
  sort(s.begin(), s.end(), greater<ll>());
  sort(t.begin(), t.end(), greater<ll>());
  //ll mp = h;
  //ll cnt = 0;
  ll tmp = 0;
  //cout << cnt << endl;
  ll s_ini = s[0];
  ll t_ini = t[0];
  ll t_sum = 0;
  while(t_ini > s_ini && t_sum < h){
    t_sum += t[tmp];
    tmp++;
    t_ini = t[tmp];
  }
  ll s_cnt = 0;
  if(t_sum < h){
    if(((h - t_sum) % s[0]) == 0){
      s_cnt = ((h - t_sum) / s[0]);
    }else{
      s_cnt = ((h - t_sum) / s[0]) + 1;
    }
  }
  cout << tmp + s_cnt << endl;
  
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s = "";
    int ans = 0;
    cin >> s;
    rep(i, 0, s.size()){
        if(ans == 0 && s[i] == 'C') ans++;
        if(ans == 1 && s[i] == 'F') ans++;
    }
    if(ans == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define all(c)          c.begin(), c.end()
#define int             long long
#define ff              first
#define ss              second
#define nl              '\n'


int32_t main()
{
	ninja
	int x; cin>>x;
	int now=100;
	int res=0;
	while(true)
	{
		now =now+ now*0.01;
		res++;
		if(now>=x){
			cout<<res; return 0;
		}
	}	
}



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

public class Main {

	public static void main(String[] args) {
		Scanner sc = null;
		int[] triangle = new int[3];

		try {
			sc = new Scanner(System.in);

			int numQ = sc.nextInt();

			for (int i = 0; i < numQ; i++) {
				for (int j = 0; j < triangle.length; j++) {
					triangle[j] = sc.nextInt();
				}
					Arrays.sort(triangle);
					if (Math.pow(triangle[0], 2) + Math.pow(triangle[1], 2) == Math.pow(triangle[2], 2)) {
						System.out.println("YES");
					}else{
						System.out.println("NO");
					}
			}

		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				try {
					sc.close();
				} catch (Exception e) {
					// TODO: handle exception
				}
			}
		}
	}

}

Measured memory_bytes: 33248
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
const int inf=(1<<31)-1;

int n;
vi num;

int main(){
	while(cin>>n){
		if(n) num.push_back(n);
		else{
			cout<<num.back()<<endl;
			num.pop_back();
		}
	}
}

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int result = 0;
  if (A >= B){
    result += B;
  }else{
    result += A;
  }
  if (C >= D){
    result += D;
  }else{
    result += C;
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	int N, Q;
	while(cin >> N >> Q, N) {
		vi date(101, 0);
		REP(i, N) {
			int M, tmp;
			cin >> M;
			REP(j, M) {
				cin >> tmp;
				date[tmp]++;
			}
		}
		int maxn = Q-1;
		int ans = 0;
		FOR(i, 1, 100) {
			if(date[i] > maxn) {
				ans = i;
				maxn = date[i];
			}
		}
		cout << ans << endl;
		next:;
	}

	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

int main()
{
    ll a,b,i,j,n,m,k,t;
    cin>>n;
    if(n==1) cout<<"1.0000000";
    else if(n%2)
    {
        long double x,y;
        x=(n/2)+1;
        x/=n;
        cout<<setprecision(8)<<fixed<<x;
        
    }
    else cout<<"0.5000000";
}

Measured memory_bytes: 3776
N, C = map(int, input().split())
x = [0]
v = [0]
for i in range(N):
    x_i, v_i = map(int, input().split())
    x.append(x_i)
    v.append(v_i)
fw = [0] * (N+1)
bw = [0] * (N+1)
for i in range(N):
    fw[i+1] = fw[i] + v[i+1]
    bw[i+1] = bw[i] + v[N-i]

for i in range(N):
    fw[i+1] -= x[i+1]
    bw[i+1] -= C - x[N-i]
m_fw = [0] * (N+1)
m_bw = [0] * (N+1)
for i in range(N):
    m_fw[i+1] = max(m_fw[i], fw[i+1])
    m_bw[i+1] = max(m_bw[i], bw[i+1])
c = 0
for i in range(N+1):
    if i == 0:
        l = 0
    else:
        l = C - x[-i]
    c = max(c, bw[i]+m_fw[N-i]-l, fw[i]+m_bw[N-i]-x[i])
print(c)

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

int main() {
    int N, K;
    std::string S;
    std::cin >> N >> K >> S;

    std::vector<int> nums;
    nums.reserve(100000);

    int cnt = 0;
    int current = 1;
    for (size_t i = 0; i < S.size(); ++i) {
        if (S[i] == ('0' + current)) {
            ++cnt;
        } else {
            nums.push_back(cnt);
            cnt = 1;
            current = 1 - current;
        }
    }

    if (cnt != 0) {
        nums.push_back(cnt);
    }

    if (nums.size() % 2 == 0) {
        nums.push_back(0);
    }

    const int add = 2 * K + 1;
    int ans = 0;
    for (size_t i = 0; i < nums.size(); i += 2) {
        int tmp = 0;
        const int right = std::min(i + add, nums.size());
        for (int j = i; j < right; ++j) {
            tmp += nums[j];
        }

        ans = std::max(ans, tmp);
    }

    std::printf("%d\n", ans);

    return 0;
}


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

using namespace std;


int main(){
	string a, b;
	cin >> a >> b;
	if(a.length() > b.length()) cout << "GREATER";
	else if(a.length() < b.length()) cout << "LESS";
	else{
		if(a<b) cout << "LESS";
		else if(a==b) cout << "EQUAL";
		else if(a>b) cout << "GREATER";
	}
	return 0;
}



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

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

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

#define INF 1e16
#define mod 1000000007

ll n,d;
vector<vector<ll>> x;
bool issq[1000010];

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

  rep(i,300)issq[i*i]=true;

  cin>>n>>d;
  rep(i,n){
    vector<ll> tmp(d);
    rep(j,d)cin>>tmp[j];
    x.push_back(tmp);
  }

  ll res=0;
  rep(i,n)repl(j,i+1,n){
    ll sum=0;
    rep(k,d)sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
    if(issq[sum])res++;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    string s = "Christmas";

    for (int i = 0; i < 25 - d; i++) {
        s += " Eve";
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
c=Array.new()
while true do
  n,x=gets.split(' ')
  n=n.to_i
  x=x.to_i
  if n==0 and x==0 then
     break
  end
  b=Array.new()

  for i in 1..n do
     for j in i+1..n do
        k=x-(i+j)
        if k==i || k==j || i==j || k<i || k<j || k>n then
           next
        else
           a=Array[i,j,k]
           if b.find{|p| p==a}==nil then
              b.push(a)
           end
        end
     end
  end
  c.push(b.length)
end
c.each{|ans|
  printf("%d\n",ans)
}

Measured memory_bytes: 8816
#include <cstdio>

typedef long long ll;

const int MAXN = 1E3 + 10;
const int MOD = 1E9 + 7;

ll inv[MAXN], fac[MAXN], facinv[MAXN];
ll f[MAXN][MAXN];

void getInv(int n = MAXN - 1){
	inv[0] = 0, inv[1] = 1;
	fac[0] = fac[1] = 1;
	facinv[0] = facinv[1] = 1;
	for (int i = 2; i <= n; ++i){
		inv[i] = inv[MOD % i]  * (MOD - MOD / i) % MOD;
		fac[i] = fac[i - 1] * i % MOD;
		facinv[i] = facinv[i - 1] * inv[i] % MOD;
	}	
}

int main(){
	getInv();

	int n, A, B, C, D;
	scanf("%d%d%d%d%d", &n, &A, &B, &C, &D);
	f[0][0] = fac[n];
	for (int i = 1; i <= n; ++i){
		ll t0 = 1;
		for (int j = 0; j < C; ++j)
			t0 = t0 * facinv[i] % MOD;

		for (int j = 0; j <= n; ++j){
			f[i][j] = f[i - 1][j];
			if (i < A || B < i || C * i > j)
				continue;

			ll t = t0;
			for (int k = C; k <= D && k * i <= j; ++k, t = t * facinv[i] % MOD)
				f[i][j] = (f[i][j] + f[i - 1][j - k * i] * facinv[k] % MOD * t) % MOD;
		}
	}

	printf("%d\n", (int)f[n][n]);
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int a, b;

int main(){
    cin >> a >> b;

    if(a > 12){
        cout << b;
    }else if (a > 5){
        cout << b/2;
    } else{
        cout << 0;
    }

}


//g++ -std=c++14 comp.cpp; ./a.exe


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
int main()
{
	int n;cin>>n;
	if(n%2==0)
	cout<<n/2<<endl; 
	else
	cout<<n/2+1<<endl;
}

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

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

 typedef long long ll;
 //const long long INF = 1LL << 60;



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

   int minimum = 0;
   int maximum = 100005;

   for(int i = 0; i < m; i++)
   {
       int l,r;
       cin >> l >> r;
       if(l >maximum or r < minimum)
       {
           cout << 0 << endl;
           return 0;
       }

        minimum = max(minimum, l);
        maximum = min(maximum, r);
   }

   cout << maximum - minimum +1 << endl;
    

    return 0;
 }

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

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

  priority_queue<ll> que;

  int N, M;
  cin >> N >> M;
  ll tmp;
  for(int i = 0; i < N; i++){
    cin >> tmp;
    que.push(tmp);
  }

  for(int i = 0; i < M; i++){
    tmp = que.top();
    que.pop();
    que.push(tmp/2);
  }

  ll ans = 0;
  while(!que.empty()){
    ans += que.top();
    que.pop();
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1400
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.typetuple;
import std.typecons;
import std.container;

void main() {
    string s = readln.chomp;
    int k = readln.chomp.to!(int);
    auto ans = new RedBlackTree!(string, "a < b");

    for (char e = 'a'; e <= 'z'; e++) {
        for (int j = 0; j < s.length; j++) {
            if (e != s[j]) continue;
            for (int l = j + 1; l <= s.length && l - j <= k; l++) {
                ans.insert(s[j..l]);
            }
        }
        if (ans.length >= k) break;
    }

    for (int i = 0; i < k - 1; i++) {
        ans.removeFront;
    }

    writeln(ans.front);
}

Measured memory_bytes: 380
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[]args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int n=0;
		String[] arr;
		int[] array;
		int min=0;
		int max=0;
		long sum=0;
		while((str=br.readLine())!=null){
			if(n == 0){
				n=Integer.parseInt(str);
				continue;
			}
			arr=str.split(" ");
			array = new int[n];
			for(int i=0;i<n;i++){
				array[i]=Integer.parseInt(arr[i]);
				sum+=array[i];
			}
			for(int i=0;i<n;i++){
				for(int j=i+1;j<n;j++) {
					if(array[i] <= array[j]);
					else{
						int temp = array[i];
						array[i]=array[j];
						array[j]=temp;
					}
				}
			}

			min=array[0];
			max=array[n-1];
			System.out.println(min+" "+max+" "+sum);
			
		}		
		br.close();
	}
}

Measured memory_bytes: 25628
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    while(~scanf("%d %d %d",&a,&b,&c))
    {
        int sum = a+b+c;
        if(sum == 17)
        {
            printf("YES\n");
        }
        else printf("NO\n");
    }
}

Measured memory_bytes: 256
let main () =
  let s, k = Scanf.scanf "%s\n%d\n" (fun a b -> a, b) in
  let xs = ref BatSet.empty in
  for i = 0 to String.length s - 1 do
    for j = 1 to min k (String.length s - i) do
      xs := BatSet.add (String.sub s i j) !xs
    done;
  done;
  let ys = BatSet.to_array !xs in
  Array.sort String.compare ys;
  Printf.printf "%s\n" (ys.(k-1))

let _ = main ()


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

int cnt[333];

void solve(istream& cin, ostream& cout) {
    string s;
    cin >> s;
    int n = s.size();
    lint ans = 0;
    for (int i = 0; i < n; i++) {
        ans += i - cnt[s[i]];
        cnt[s[i]]++;
    }
    cout << ans + 1;
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


Measured memory_bytes: 720
/*
|| Suyash Yadav | B.Tech (3rd Year CSE) | Tier-3 (NCR,India)
|| suyashky@gmail.com | "suyashky" @linkedIn
||
||		   /\_/\
||		  ( o.o )
|| 	 	   > ^ <
|| From infinity to beyond!
*/

# include <bits/stdc++.h>
using namespace std;
# define INF (long long int)1e28
# define MOD 1000000007
# define endl "\n"
# define all(con) con.begin() , con.end()
# define MAX numeric_limits<int64>::max()
# define MIN numeric_limits<int64>::min()
# define watch1(x) cout<<#x<<": "<<x<<endl
# define watch2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
# define watch3(x,y,z) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
# define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int int64;
typedef unsigned long long int uint64;

bool mark[100005];
int dp[100005];
void dfs(int a, vector<vector<int>> &adj)
{
	mark[a] = true;
	int maxC = -1;
	for (int c : adj[a])
	{
		if (!mark[c])
			dfs(c, adj);
		maxC = max(maxC, dp[c]);
	}
	dp[a] = max(dp[a], 1 + maxC);
}

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

	memset(mark, false, sizeof(mark));
	memset(dp, 0, sizeof(dp));
	int n, m;
	cin >> n >> m;

	vector<vector<int>> adj(n + 1);
	int a, b;
	for (int i = 1 ; i <= m ; i++)
	{
		cin >> a >> b;
		adj[a].push_back(b);
	}

	for (int i = 1 ; i <= n ; i++)
	{
		if (!mark[i])
		{
			dfs(i, adj);
		}
	}

	int maxA = -1;
	for (int i = 1 ; i <= n ; i++)
	{
		if (dp[i] > maxA)
			maxA = dp[i];
	}
	cout << maxA << endl;
}

Measured memory_bytes: 8960
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] line = S.Split(' ');
            int A = int.Parse(line[0]);
            int B = int.Parse(line[1]);
            int C = int.Parse(line[2]);

            if ((A == B && A != C) || (A == C && A != B) || (B == C && B != A))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}

Measured memory_bytes: 11092
import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
xy = []
for _ in range(n):
    m = int(readline())
    tmp = [list(map(int, readline().split())) for _ in range(m)]
    xy.append(tmp)

ans = 0

for l in list(itertools.product([0, 1], repeat=n)):
    bl = True
    for i,a in enumerate(l):
        if a == 1:
            for b in xy[i]:
                if l[b[0] - 1] != b[1]:
                    bl = False
    if bl:
        ans = max(ans, sum(l))
print(ans)

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

#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define MOD 1000000007
#define INF 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y) 
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	float n,a;
	cin>>n>>a;
	cout<<ceil(float(n/a));

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

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

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
vector<int>G[10010];
vector<int>c(10010,0);
int num[10010];
bool used[10010];
int now_c=0;
int dfs(int s){
    if(used[s]){
        return 0;
    }else{
        used[s]=true;
    }

    num[s]=c[now_c];
    now_c++;

    for(int i=0; i<G[s].size(); i++){
        dfs(G[s][i]);
    }
    return 0;
}


int main() {
    int W,H; cin >> W >> H;
    int x,y; cin >> x >> y;

    cout << (double)W*H/2 << " ";

    if( ((double)x == (double)W/2) && ((double)y == (double)H/2)){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 512