akhauriyash/Code-Regression huggingface dataset:
N=int(input())
A=list(map(int,input().split()))
B=[]
M=0
for a in A:
    b=bin(a)
    if M<len(b[2:]):
        M=len(b[2:])
    B.append(b[2:])
ans=0
for i in range(0,M):
    z=0;o=0
    for j in range(0,N):
        if len(B[j])<i+1:
            z+=1
        else:
            index=len(B[j])-i-1
            if B[j][index]=='0':
                z+=1
            else:
                o+=1
    ans+=(2**i*(z*o))%(10**9+7)
print(ans%(10**9+7))

Measured memory_bytes: 126724
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <complex>

using namespace std;
using pii = pair<int, int>;
using ll = long long;

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

	int n;
	cin >> n;
	cout.precision(6);
	cout << fixed;
	cout << ((int)(n + 1) / 2) / (double)n;

	return 0;
}


Measured memory_bytes: 256
week = {
    'SUN': 7,
    'MON': 6,
    'TUE': 5,
    'WED': 4,
    'THU': 3,
    'FRI': 2,
    'SAT': 1,
}

s = input()
print(week[s])


"""別解
S = input()
days = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
 
print(7 - days.index(S))
"""

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main{

	private static boolean[] vis1 = new boolean[200010];
	private static boolean[] vis2 = new boolean[200010];
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int i , j , n , m;
		n = scan.nextInt();
		m = scan.nextInt();
		for (i = 0;i < m;i ++) {
			int a , b;
			a = scan.nextInt();
			b = scan.nextInt();
			if (a == 1) {
				vis1[b] = true;
			}
			if (b == n) {
				vis2[a] = true;
			}
		}
		for (i = 2;i < n;i ++) {
			if (vis1[i] && vis2[i]) {
				break;
			}
		}
		if (i == n) {
			System.out.println("IMPOSSIBLE");
		} else {
			System.out.println("POSSIBLE");
		}
		
	}
	
	
}



















Measured memory_bytes: 94208
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
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();}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

string s;
bool ans_flag = false;

string dfs(int l) {

	dump("start_dfs");

	string ret = "NO";
	if (l == s.size() && !ans_flag) {
		ans_flag = true;
	}

	if (ans_flag) {
		ret = "YES";
		dump("YES");
	}
	else {
		if (s.substr(l,5) == "dream") {
			dump(s.substr(l,5)); 
			dump("dream");
			ret = dfs(l+5);
		}
		if (s.substr(l,7) == "dreamer") {
			dump(s.substr(l,7)); 
			dump("dreamer");
			ret = dfs(l+7);
		}
		if (s.substr(l,5) == "erase") {
			dump(s.substr(l,5)); 
			dump("erase");
			ret = dfs(l+5);
		}
		if (s.substr(l,6) == "eraser") {
			dump(s.substr(l,6)); 
			dump("eraser");
			ret = dfs(l+6);
		}
	}

	dump("return");
	return ret;
}

int main() {

	cin >> s;
	int l = 0;

	cout << dfs(l);

	return 0;
}


Measured memory_bytes: 8128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
const int mod = 1e9 + 7;
using namespace std;
typedef long long ll;


int main()
{
    ll x;
    cin >> x;
    ll ans;
    int n = x % 11;
    ans = 2 * (x / 11);
    if(n >= 7){
        ans += 2;
    }else if(n >= 1){
        ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []

for i in range(n):
    syougen_num = int(input())
    ai = []
    for j in range(syougen_num):
        xi_yi = list(map(int, input().split()))
        ai.append(xi_yi)
    a.append(ai)

res = 0
for i_bin in range(1 << n):
    syougen_list = [[0, 0] for i in range(n)]
    one_counter = 0
    for keta in range(n):
        # 1を正直者にした
        if i_bin >> keta & 1 == 1:
            one_counter += 1
            for i_syougen in a[keta]:
                #yi :0は不親切 :1は正直者 
                xi, yi = i_syougen
                syougen_list[xi - 1][yi] += 1
    for i_syougen in range(n):
        if syougen_list[i_syougen][0] >= 1 and syougen_list[i_syougen][1] >= 1:
            break
        elif syougen_list[i_syougen][0] >= 1 and i_bin >> i_syougen & 1 == 1:
            break
        elif syougen_list[i_syougen][1] >= 1 and i_bin >> i_syougen & 1 == 0:
            break
    else:
        res = max(res, one_counter)
        flag = i_bin
    # print(syougen_list, i_bin, one_counter, flag)
print(res)





Measured memory_bytes: 74396
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

#define FOR(i, l, r) for (int i = (l); i <= (r); ++i)

const int mod = 1000000007;
typedef long long LL;
LL n, a, b;
LL pow(LL x, LL n) {
    LL ret = 1;
    while(n) {
        if (n & 1) {ret *= x; ret %= mod;}
        x *= x; x %= mod; n >>= 1;
    }
    return ret;
}

LL inv(LL x) {
    return pow(x, mod - 2);
}

LL C(int n, int k) {
    if (k < 0 || k > n) return 0;
    if (k == 0) return 1;
    if (k == 1) return n;
    LL ret = n;
    for (int i = 2; i <= k; ++i) {
        ret *= (n - i + 1); ret %= mod;
        ret *= inv(i); ret %= mod;
    }
    return ret;
}

void test() {
    cout << pow(2, 4) << endl;
    cout << 4 * inv(2) % mod << endl;
}

int main() {
#ifdef __APPLE__
    freopen("main.in", "r", stdin);
#endif
    //test();
    cin >> n >> a >> b;
    LL ans = pow(2, n);
    ans -= 1; ans %= mod;
    ans -= C(n, a); ans %= mod;
    ans -= C(n, b); ans %= mod;
    ans = ((ans % mod) + mod) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define SIZE 300005
#define MOD 1000000007

using namespace std;

char str[SIZE];
int dp[SIZE][4];
//0,1
//00,01,11,10

int cmb(int S)
{
	int one=0,zero=0;
	for(int i=0;i<3;i++)
	{
		if(S>>i&1) one++;
		else zero++;
	}
	return one>zero;
}
int main()
{
	scanf("%s",&str);
	int n=strlen(str);
	if(str[0]=='0'||str[0]=='?') dp[0][0]=1;
	if(str[0]=='1'||str[0]=='?') dp[0][1]=1;
	for(int i=1;i<n;i++)
	{
		int t=(i%2==1?1:2);
		for(int S=0;S<1<<t;S++)
		{
			if(t==1)
			{
				if(str[i]=='0'||str[i]=='?')
				{
					dp[i][S*2]+=dp[i-1][S];
					if(dp[i][S*2]>=MOD) dp[i][S*2]-=MOD;
				}
				if(str[i]=='1'||str[i]=='?')
				{
					dp[i][S*2+1]+=dp[i-1][S];
					if(dp[i][S*2+1]>=MOD) dp[i][S*2+1]-=MOD;
				}
			}
			else
			{
				if(str[i]=='0'||str[i]=='?')
				{
					if(S!=2)
					{
						int c=cmb(S*2);
						dp[i][c]+=dp[i-1][S];
						if(dp[i][c]>=MOD) dp[i][c]-=MOD;
					}
					else
					{
						if(i+1<n)
						{
							int v=dp[i-1][S];
							if(str[i+1]=='?') v=v*2%MOD;
							dp[i+1][2]+=v;
							if(dp[i+1][2]>=MOD) dp[i+1][2]-=MOD;
						}
						else
						{
							dp[i][0]+=dp[i-1][S];
							if(dp[i][0]>=MOD) dp[i][0]-=MOD;
						}
					}
				}
				if(str[i]=='1'||str[i]=='?')
				{
					int c=cmb(S*2+1);
					dp[i][c]+=dp[i-1][S];
					if(dp[i][c]>=MOD) dp[i][c]-=MOD;
				}
			}
		}
		if(t==1)
		{
			dp[i][3]=0;
		}
	}
	int all=1;
	for(int i=0;i<n;i++) if(str[i]=='?') all=all*2%MOD;
	printf("%d\n",(all-dp[n-1][0]+MOD)%MOD);
	return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n, a, b, t, ans=0;
	cin >> n >> a >> b;
	for(int i=0; i<n; i++){
		cin >> t;
		if(t<a || b<=t){
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import Counter

n=int(input())
s=[]
for i in range(n):
  a=input()
  s.append(a)
c=Counter(s)

mx=max(c.values())
ans=[]
for i in c:
  if c[i]==mx:
    ans.append(i)
ans.sort()
for i in ans:
  print(i)

Measured memory_bytes: 100432
#include <bits/stdc++.h>
using namespace std;
int main() {
    string st;
    cin>>st;
    int sum=0;
    for(int i=0;i<(int)st.size();i++) {
        sum+=st[i]-'0';
    }
    if(sum%9==0) cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3744
a, b= map(int, input().split())
num = abs(abs(a)-abs(b))
 
if a * b < 0:
    num += 1
elif a * b == 0 and a > b:
    num += 1
elif a * b > 0:
    if a < 0 and abs(a) < abs(b):
        num += 2
    elif a > 0 and abs(a) > abs(b):
        num += 2
print(num)

Measured memory_bytes: 9176
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    c = 0
    t = 1
    for i in range(n):
        if a[i] == t:
            c += 1
            t += 1
    print(n - c if c != 0 else -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 71024
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,m = inpm()
    a = inpl()
    cnt = 0
    for i in range(n):
        if a[i] >= sum(a)/(4*m):
            cnt += 1
    if cnt >= m:
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 63980
#include <bits/stdc++.h>
using namespace std;
#define int long long 
using ldb = long double;
using pa = pair < int, int >;
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 2e5 + 10;
const int LINF = LLONG_MAX;
int a[N];
int dp[N][4];
int vis[N][4];
int n;
int dfs(int pos,int skip){
    if(pos <= 0){
        return 0;
    }
    if(vis[pos][skip]){
        return dp[pos][skip];
    }
    vis[pos][skip] = 1;
    if(skip == 0){
        dp[pos][skip] = a[pos] + max({dfs(pos-2,0),dfs(pos-3,1),dfs(pos-4,2)});
    }
    else if(skip == 1){
        dp[pos][skip] = a[pos] + max(dfs(pos-2,1),dfs(pos-3,2));
    }
    else{
        dp[pos][skip] = a[pos] + dfs(pos-2,2);
    }
    return dp[pos][skip];
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    f(i,1,n+1){
        cin >> a[i];
    }
    if(n&1){
        cout << max({dfs(n,0),dfs(n-1,1),dfs(n-2,2)});
    }
    else
        cout << max(dfs(n,1),dfs(n-1,2));
    return 0;
}
 

Measured memory_bytes: 22308
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x,val) memset(x,val,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
    template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    bool IN(ll x,ll l,ll r){return l<=x and x<=r;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    int a[N],b[N];
    void main()
	{
        int n=qread();fo(i,1,n) a[i]=qread();fd(i,n,2) a[i]-=a[i-1];
        fo(i,1,n) b[i]=mm(b[i-1]+invm(i));
        ll ans=0;fo(i,2,n) add(ans, 1ll*a[i]*b[i-1]%MOD );
        fo(i,1,n-1) ans=ans*i%MOD;write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
using namespace std;
int dp[2000000];
signed main()
{
	int n,sum=0,i;
	scanf("%d",&n);
	dp[0]=1;
	for (i=0;i<n;++i)
	{
		int a,q;
		scanf("%d",&a);
		sum+=a;
		for (q=min(2000000-a,2000*i);q>=0;--q)
		{
			dp[q+a]|=dp[q];
		}
	}
	for (i=sum/2;i>=0;--i)
	{
		if (dp[i])
		{
			cout<<max(i,sum-i);
			return 0;
		}
	}
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int cur = 0;
    vector<int> f;
    for (int i = 1; i <= 999; i++) {
        cur += i;
        f.push_back(cur);
    }
    int a, b;
    cin >> a >> b;
    int c = b - a - 2;
    cout << f[c] - a << endl;

}



Measured memory_bytes: 256
count = 0
MAX = 0
S = list(input())
for i in range(len(S)):
  if S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C':
    count += 1
    if MAX < count:
        MAX = count
  else:
    count = 0

print(MAX)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            var wanted = cin.Read;
            string word;
            var count = 0;
            while(true) {
                word = cin.Read;
                if (word == "END_OF_TEXT") break;
                word = word.ToLower();
                if(word == wanted) 
                    count++;
            }
            Console.WriteLine(count);
        }
        
    }

    static class ExtendClass {
        public static void Swap<T>(this T[] X, int i, int j) {
            T tmp = X[i];
            X[i] = X[j];
            X[j] = tmp;
        }
        public static string Join<T>(this T[] X, string separator = " ") => string.Join(separator, X);
        public static S[] Clone<S>(this S[] src) where S : struct {
            var res = new S[src.Length];
            Array.Copy(src, res, src.Length);
            return res;
        }
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}



Measured memory_bytes: 16320
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 123456789
//0x3f3f3f3f
#define INFL 10000000000000000
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<int,pii> pdii;
long long int MOD = 1000000007;
ll ggcd(ll a,ll b){
	if(b==0)return a;
	if(a<b){
		ll temp=a;
		a=b;
		b=temp;
	}
	ll x=a%b;
	return ggcd(b,x);
}

int main(void){
	int N;
	ll K;
	vector<ll> a;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		ll x;
		cin>>x;
		a.pb(x);
	}
	sort(a.begin(),a.end());
	ll ma=a[N-1];
	bool flag=true;
	if(ma<K)flag=false;
	ll x=a[0];
	for(int i=0;i<N;i++){
		x=ggcd(x,a[i]);
	}
	//cout<<ma<<" "<<x<<endl;
	if(ma>=K&&(K%x!=0)){
		flag=false;
	}
	if(flag)cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, A, B;
    cin >> N >> A >> B;
    int a = 0;
    int k = 0;
    string s;
    cin >> s;
    rep(i, s.size()){
        if(s[i] == 'a'){
            if(a < A + B){
                a++;
                output("Yes");
            }
            else{
                output("No");
            }
        }
        else if(s[i] == 'b'){
            if(a < A + B && k < B){
                a++, k++;
                output("Yes");
            }
            else{
                output("No");
            }
        }
        else output("No");
    }
    
    
    return 0;
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
long long a,ans=1,mod=1000000007;
int main()
{
//	freopen("2469.out","w",stdout);
//	freopen("2469.in","r",stdin);
	cin>>a;
	for(int s=2;s<=a;s++)
	{
		ans=((s%mod)*ans)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

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


  ll res = 0;
  int z = min(x,y);
  if(a + b > 2 * c) {
    res += z * c * 2;
    x -= z;
    y -= z;
  }
  if(a > 2 * c) {
    res += x * c * 2;
  } else {
    res += x * a;
  }
  if(b > 2 * c) {
    res += y * c * 2;
  } else {
    res += y * b;
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9;
int main(){
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  s += '0';

  vector<int> dp(2,INF);
  dp[0] = 0;
  int n = sz(s);
  for (int i = 0; i < n; i++) {
    int d = s[i] - '0';
    vector<int> ndp(2,INF);
    ndp[0] = min(dp[0] + d, dp[1] + d + 1);
    ndp[1] = min(dp[0] + 10 - d, dp[1] + 9 - d);
    swap(dp, ndp);
  }
  cout << dp[0] << endl;
  return 0;
} 

Measured memory_bytes: 1412
n,x=gets.split(" ").map(&:to_i)
m = Array.new()
i = 0
while i < n
  m.push(gets.to_i)
  i += 1
end

mini = m[0]
sum = 0
for j in 0..n-1
  if m[j] < mini
    mini = m[j]
  end
  sum += m[j]
end

goukei = (x - sum) / mini + n
puts goukei


Measured memory_bytes: 1788
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  long long X;
  cin >> X;

  long long cur = 100;
  long long ret = 0;
  while (cur < X) {
    cur *= 1.01;
    ++ret;
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <map>
int main()
{
	std::map<std::string, int> words;	
	std::string  input, longest, frequent;
	while (std::cin >> input) {
		words[input]++; // 出現頻度++
		if (words[input] > words[frequent]) { // 最出現頻度単語更新
			frequent = input;
		}
		if (input.length() > longest.length()) {
			longest = input;
		}
	}
	std::cout << frequent << ' ' << longest << std::endl;
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    cout << fixed << setprecision(8);
    double r; cin >> r;
    cout << 2 * M_PI * r << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3804
#include <cstdio>

int main(){
  int n,key;

  while(scanf("%d" ,&n) ,n){
    int a[n];
    for(int i = 0 ; i < n ; i++){
      scanf("%d" ,a + i);
    }

    scanf("%d" ,&key);

    int lb = 0,ub = n-1,cnt = 0;
    while(ub - lb >= 0){
      int mid = (lb + ub) / 2;
      cnt++;

      if(key == a[mid]){
	break;
      }

      if(key < a[mid]){
	ub = mid - 1;
      }else{
	lb = mid + 1;
      }
    }   
    printf("%d\n" ,cnt);
  }

  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
/*
ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nPk(ll n,ll k){
	return nCk(n,k)*F[k]%mod;
}*/

const int M=10000;
int a[M+1],n;

int main(){
	for(int i=1;i<=100;i++) for(int j=1;j<=100;j++) for(int k=1;k<=100;k++){
		int t=i*i+j*j+k*k+i*j+j*k+k*i;
		if(t<=M) a[t]++;
	}
	cin>>n;
	for(int i=1;i<=n;i++) cout<<a[i]<<endl;
}

Measured memory_bytes: 3540
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int r;
    cin >> r;
    cout <<r * r<< endl;
    return 0;
}

Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

def k (x):
            if x% 10 != 0:
                        return x-x%10+10
            else:
                        return x          




def m(y):
            if y%10 !=0:
                        return  y%10
            else:
                        return 10

a,b,c,d,e=map(k,[A,B,C,D,E])
a_list = [a,b,c,d,e]
sum_a_list = sum(a_list)

a_1,b_1,c_1,d_1,e_1=map(m,[A,B,C,D,E])
sum_a_list + min(a_1,b_1,c_1,d_1,e_1)

s=sum_a_list-10+min(a_1,b_1,c_1,d_1,e_1)
print(s)





Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c;
    rep(i,0,n) cin >> a[i];
    rep(i,0,n) cin >> b[i];
    ll sum=0;
    ll num=0;
    rep(i,0,n){
        if(b[i]>a[i]) {
            sum+=b[i]-a[i];
            num++;
        }
        if(a[i]>b[i]){
            c.push_back(a[i]-b[i]);
        }
    }
    sort(c.begin(),c.end(),greater<int>());
    if(sum>0){
        for(int i=0;i<c.size();i++){
            sum-=c[i];
            num++;
            if(sum<1) break;
        }
    }
    if(sum>0) cout << -1 << endl;
    else cout << num << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<vector<long long>> a(100001,vector<long long>(1,0));
  long long ans=0;
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    a.at(x).at(0) ++;
    ans += x;
  }
  int q;
  cin >> q;
  while(q>0){
    int b,c;
    cin >> b >> c;
    long long d = a.at(b).at(0);
    a.at(c).at(0) += a.at(b).at(0);
    a.at(b).at(0) = 0;
    ans -= b*d;
    ans += c*d;
    
    cout << ans << endl;
    q--;
  }
  
}




Measured memory_bytes: 8780
H,W=map(int,input().split())
temp=[]
mod=(10**9)+7
for r in range(H):
    s=input()
    temp.append(s)
grid=[]
for i in temp:
    x=[]
    for j in i:
        if j==".":
            x.append(0)
        else:
            x.append(1)
    grid.append(x)
dp=[]
for i in range(H):
    x=[-1]*W
    for j in range(W):
        if grid[i][j]==1:
            x[j]=0
    dp.append(x)
dp[H-1][W-1]=1
for i in range(H-1,-1,-1):
    for j in range(W-1,-1,-1):
        if grid[i][j]==1 or (i==H-1 and j==W-1):
            continue
        else:
            a=0
            b=0
            if (j+1)<W:
                a=dp[i][j+1]
            if (i+1)<H:
                b=dp[i+1][j]
            dp[i][j]=a+b
print(dp[0][0]%mod)

Measured memory_bytes: 216812
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int A, B;

int main() {
  INCANT;
  cin >> A >> B;
  if (A>=13) cout << B;
  else if (A>=6) cout << B/2;
  else cout << 0;
  cout << "\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
     
    static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
     
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String s = stdIn.next();
        String p = stdIn.next();
         
        boolean ans = false;
         
        IN:for(int i = 0; i < s.length(); i++) {
            for(int j = 0; j < p.length(); j++) {
                if(s.charAt((i + j) % s.length()) != p.charAt(j)) {
                    continue IN;
                }
            }
            ans = true;
            break;
        }
         
        System.out.println((ans)?"Yes":"No");
         
    }
}


Measured memory_bytes: 26196
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pdd pair<double, double>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 1LL << 60;

vector<int> prime;
vector<int> p;
vector<bool> use;
void sieve(int n){
    prime.resize(n + 1, 1);
    use.resize(n + 1);
    for(int i = 2; i <= n; i++){
        if(prime[i] == 1){
            p.push_back(i);
            prime[i] = i;
        }
        for(int j : p){
            if((ll)i * j > n || j > prime[i]) break;
            prime[i * j] = j;
        }
    }
}

int main(){
    StarBurstStream

    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a, b);
    sieve(1000000);

    ll ans = 1;
    ll abc = 1;
    for(int i = 2; i <= min(1000000LL, g); i++){
        if(g % i != 0)continue;

        while((g / abc) % i == 0) abc *= i;

        ll t = i;
        ll t2 = i;
        while(true){
            if(t == 1) break;
            if(use[t]) goto next;
            t = t / prime[t];
        }
        while(true){
            if(t2 == 1) break;
            use[t2] = true;
            t2 = t2 / prime[t2];
        }
        ans++;
        //cerr << i << "\n";
        next:;
    }
    if(g / abc != 1) ans++;

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 4988
s = input()
test = ["01","02","03","04","05","06","07","08","09","10","11","12"]
a1 = s[:2]
a2 = s[2:]

if a1 in test and a2 in test:
    print("AMBIGUOUS")
elif a1 in test:
    print("MMYY")
elif a2 in test:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 38416
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<int> H(N);
	rep(i,N)cin>>H[i];
	int ans = 0;
	int maxH = H[0];
	rep(i,N){
		if(H[i]>=maxH)ans++;
		maxH = max(maxH,H[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
x = int(input())
maximum = 1
for i in range(2,32):
  if i*i <= x and i*i > maximum:
    maximum = i*i

for i in range(2, 11):
  if pow(i,3) <= x and pow(i,3) > maximum:
    maximum = pow(i,3)

for i in range(2, 6):
  if pow(i,4) <= x and pow(i,4) > maximum:
    maximum = pow(i,4)

for i in range(2, 4):
  if pow(i,5) <= x and pow(i,5) > maximum:
    maximum = pow(i,5)

for i in range(2, 4):
  if pow(i,6) <= x and pow(i,6) > maximum:
    maximum = pow(i,6)

for i in range(7,10):
  if pow(2,i) <= x and pow(2,i) > maximum:
    maximum = pow(2,i)

print(maximum)


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int M=stdIn.nextInt();
		int s[][]=new int[M][N];
		int k[]=new int[M];
		int p[]=new int[M];
		int ans=0;
		for(int i=0;i<M;i++){
			k[i]=stdIn.nextInt();
			for(int j=0;j<k[i];j++){
				s[i][j]=stdIn.nextInt()-1;
			}
		}
		for(int i=0;i<M;i++){
			p[i]=stdIn.nextInt();
		}
		for(int i=0;i<Math.pow(2,N);i++){
			boolean key[]=new boolean[N];
			boolean bool=true;
			for(int j=0;j<N;j++){
				if((1&i>>j)==1)
					key[j]=true;
			}
			for(int j=0;j<M;j++){
				int cout=0;
				for(int l=0;l<k[j];l++){
					if(key[s[j][l]])
						cout++;
				}
				if(cout%2!=p[j]){
					bool=false;
					break;
				}
			}
			if(bool)
				ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#include <stdio.h>

int main(){

    int n,m,l,i,k,j;
    long long a[100][100]={0},b[100][100]={0},c[100][100]={0};
    scanf("%d %d %d",&m,&n,&l);
    for (i=0; i<m; i++)
    {
        for (j=0; j<n; j++)
        {
            scanf("%lld",&a[i][j]);
        }
    }

       for (i=0; i<n; i++)
    {
        for (j=0; j<l; j++)
        {
            scanf("%lld",&b[i][j]);
        }
    }
    
    for (i=0; i<m; i++)
    {
        for (j=0; j<l; j++)
        {
            for (k=0; k<n; k++)
            {
                c[i][j]=a[i][k]*b[k][j]+c[i][j];
            }
            if (j==l-1)
            printf("%lld",c[i][j]);
            else if (j<l)
                printf("%lld ",c[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 848
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    x = int(input())
    while True:
        if all( x%i != 0 for i in range(2,x)):
            print(x)
            exit()
        x += 1

if __name__=="__main__":
    main()


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

int main(void){

    long A,B;
    cin>>A>>B;

    if((A+B) % 2 != 0){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }

    cout<<(A+B)/2<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,c500=0,c5=0;
	cin>>n;
	if(n/500>0)
		c500=n/500;
	n=n-c500*500;
	if(n/5>0)
		c5=n/5;
	cout<<c500*1000+c5*5<<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 k,a,b; cin>>k>>a>>b;
	bool yes=false;
	for(int i=k;i<=b;i+=k){
		if(i>=a&&i<=b)yes=true;
	}
	cout<<(yes?"OK"s:"NG"s)<<"\n"s;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(void) {
  int n, i, j, k, ans = 0;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    long long a, t = 4, s = 1;
    scanf("%lld", &a);
    if(t > a) {
      ans++;
      continue;
    }
    if(a % 3 == 1) continue;
    for(j = 2; t <= a; ++j) {
      t /= (j - 1);
      t *= (j + 1);
      if(t > a) break;
      if(a % (2 * j + 1) == j) {
        s = 0;
        break;
      }
    }
    if(s) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2712
#include <vector>
#include <iostream>

int main()
{
	std::vector<int> xs;
	xs.resize(3);
	for (int i = 0; i < 3; i++) {
		std::cin >> xs[i];
	}

	if (xs[0] + xs[1] == xs[2] || xs[0] + xs[2] == xs[1] || xs[0] == xs[1] + xs[2]) {
		std::cout << "Yes\n";
	}
	else {
		std::cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long long int N,D;
    cin >> N >> D;
    D = D*D;

    int cnt=0;
    long long int x,y;
    for (int i = 0; i < N; ++i) {
        cin >> x >> y;
        if ((x*x + y*y) <= D) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3620
//
//  main.cpp
//  C - Connect Cities
//
//  Created by Bryan on 26/09/20.
//  Copyright © 2020 mac. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <map>
using namespace std;
long long N,M;
long long par[100005];

long long find(long long x)
{
    if (x == par[x])
        return x;
    else
        return par[x] = find(par[x]);
}

void join(long long x,long long y)
{
    long long xx = find(x);
    long long yy = find(y);
    par[yy] = xx;
}


int main()
{
    scanf ("%lld %lld",&N,&M);
    for (long long f = 1; f<=N;f++)
        par[f] = f;
    long long a,b;
    for (long long f = 0; f<M;f++)
    {
        scanf ("%lld %lld",&a,&b);
        join(a,b);
    }
    map<long long,long long>mp;
    long long ans = 0;
    for (long long f = 1; f<=N;f++)
    {
        if (mp.count(find(f))!=1)
            ans++;
        mp[find(f)]++;
    }
    printf ("%lld\n",ans-1);
    
}


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

char s[4];

int main(){
    for(int i = 0;i < 4;i++) cin >> s[i];
    int a=s[0]-'0', b=s[1]-'0', c=s[2]-'0', d=s[3]-'0';
    if(a + b + c + d == 7) printf("%d+%d+%d+%d=7",a,b,c,d);
    else if(a + b + c - d == 7) printf("%d+%d+%d-%d=7",a,b,c,d);
    else if(a + b - c + d == 7) printf("%d+%d-%d+%d=7",a,b,c,d);
    else if(a - b + c + d == 7) printf("%d-%d+%d+%d=7",a,b,c,d);
    else if(a - b - c + d == 7) printf("%d-%d-%d+%d=7",a,b,c,d);
    else if(a - b + c - d == 7) printf("%d-%d+%d-%d=7",a,b,c,d);
    else if(a + b - c - d == 7) printf("%d+%d-%d-%d=7",a,b,c,d);
    else if(a - b - c - d == 7) printf("%d-%d-%d-%d=7",a,b,c,d);

    return 0;
}

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

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

void solve(long long K){
    long long ans = 0;
    for(int i = 1; i <= K; i ++ ){
        for(int j = 1; j <= K; j ++ ){
            for(int k = 1;k <= K; k ++){
                ans += gcd(gcd(i,j),k);
            }
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3680
anslist = []
while True:
    ans = 0
    n, m = map(int, input().split())
    if n == 0 and m == 0:
        break

    taro = []
    hanako = []
    for i in range(n):
        s = int(input())
        taro.append(s)
    for i in range(m):
        s = int(input())
        hanako.append(s)
    ans = -1
    for i in range(n):
        for j in range(m):
            if sum(taro) - taro[i] + hanako[j] == sum(hanako) - hanako[j] + taro[i]:
                ans = [taro[i], hanako[j]]
                break
        if ans != -1:
            break

    anslist.append(ans)

for i in anslist:
    if i == -1:
        print(-1)
    else:
        print(i[0], i[1])


Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <functional>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <math.h>
#include <map>

using namespace std;
using ll = long long;

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

	vector <vector <int> > adj(n + m);

	for (int i = 0; i < n; ++i)
	{
		int k;
		cin >> k;
		k;

		for (int j = 0; j < k; ++j)
		{
			int l;
			cin >> l;
			l--;
			adj[i].push_back(n + l);
			adj[n + l].push_back(i);
		}
	}

	stack<int> s;
	vector<bool>cat(n+m, false);


	s.push(0);
	cat[0] = true;

	while (!s.empty())
	{
		int oya = s.top();
		s.pop();

		for (int child : adj[oya])
		{
			if (!cat[child])
			{
				s.push(child);
				cat[child] = true;
			}
		}
	}

	bool flag = true;

	for (int i = 0; i < n; i++)
	{
		flag = flag && cat[i];
	}
	
	if (flag)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 8952
#include<stdio.h>
int main(){
 
int A,B,a[100000],b[500],C=0,k,i;
 
scanf("%d",&A);
for(k=0;k<A;k++)
scanf("%d",&a[k]);

scanf("%d",&B);
for(k=0;k<B;k++)
scanf("%d",&b[k]);

for(i=0;i<B;i++){
for(k=0;k<A;k++){
if(a[k]==b[i]){
C++;
break;
}
}
}

printf("%d\n",C);
 
}


Measured memory_bytes: 1988
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//
 
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES
 
using namespace std;
 

 
int main()
{
    long long int n;cin>>n;
    
    if(n%1000==0) cout<<0<<endl;
    else {
        long long int ans = n/1000;
        ans++;
        ans = ans*1000-n;
        cout<<ans<<endl;
    }
}





Measured memory_bytes: 3632
from collections import defaultdict as dd
from heapq import heappop, heappush

N, K = map(int, input().split())
l = [tuple(map(int, input().split())) for _ in range(N)]
l.sort(key=lambda x:-x[1])
used = set()
q1 = dd(list)
q2, q3 = [], []

score, kind = 0, 0

for t, d in l[:K]:
    score += d
    if t in used:
        heappush(q3, d)
    else:
        used.add(t)
        kind += 1

for t, d in l[K:]:
    if not t in used:
        heappush(q1[t], -d)
for t in q1.keys():
    d = heappop(q1[t])
    heappush(q2, d)

ans = score + kind*kind
while q2 and q3:
    score -= heappop(q2)+heappop(q3)
    kind += 1
    ans = max(ans, score + kind*kind)

print(ans)

Measured memory_bytes: 30100
#include<iostream>
#include<boost/multiprecision/cpp_int.hpp>
namespace mp=boost::multiprecision;
using Int=mp::cpp_int;
const Int MOD=int(1e9)+7;
const int DELAY=1e5;
int main(){
    Int m,n;    
    std::cin>>m>>n;
    Int res;
    for(int i=0;i<DELAY;i++){
        res=mp::powm(m,n,MOD);
    }
    std::cout<<res<<std::endl;
    return 0;
}


Measured memory_bytes: 3248
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Online Judge: Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF 1e9 + 1
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define EMPP emplace_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		//printf("%d ", 2);
//		aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			//printf("%d ", i);
			//aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		//printf("%d ", n);
	//	aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i<s.length(); i++) {
		string a = s.substr(0, i + 1);
		string b = s.substr(i + 1, s.length() - 1);
		int cnt = 0;
		sort(a.begin(), a.end());
		for (int j = 0; j<a.length(); j++) {
			if (j == 0 || a[j] != a[j - 1]) {
				for (int s = 0; s<b.length(); s++) {
					if (b[s] == a[j]) {
						cnt++;
						break;
					}
				}
			}
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

A, B = read_int()

ra = 0.08
rb = 0.1
def solve():
    ans = -1
    aM = int((A + 1) // ra)
    am = int(A / ra)
    bM = int((B + 1) // rb)
    bm = int(B / rb)

    lb = min(am, bm)
    ub = max(aM, bM)
    for n in range(ub, lb - 1, -1):
        # print(n, int(math.floor(n * ra)), int(math.floor(n * rb)))
        if int(math.floor(n * ra)) == A and int(math.floor(n * rb)) == B:
            ans = n
    return ans

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3896