akhauriyash/Code-Regression huggingface dataset:
require 'benchmark'

n = gets.to_i
S = gets.split.map(&:to_i)
q = gets.to_i
T = gets.split.map(&:to_i)

Benchmark.measure do
  cnt = 0
  S.sort!
  T.each do |x|
    l = 0
    r = n
    while l < r
      m = (l + r) / 2
      if S[m] == x
        cnt += 1
        break
      elsif x < S[m]
        r = m
      else
        l = m + 1
      end
    end
  end
  puts cnt
end



Measured memory_bytes: 16252
def solve(a_list):
    if len(list(filter(lambda x: x >= 0, a_list))) == 0:
        return max(a_list)

    dp = [0] * len(a_list)
    dp[0] = max(0, a_list[0])
    for i in range(1, len(dp)):
        dp[i] = max(0, a_list[i] + dp[i - 1])

    return max(dp)


def main():
    while True:
        n = int(input())
        if n == 0:
            break
        a_list = [int(input()) for _ in range(n)]
        print(solve(a_list))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7832
#include <iostream>

using namespace std;

int main() {
	int n, s, m, h;
	cin >> n;
	s = n % 60;
	h = (n-s) / 60;
	m = h % 60;
	h = (h-m) / 60;
	cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

void shuffle(int array[], int size) {
	std::random_device rnd;
	for (int i = 0; i < size; i++) {
		int j = rnd() % size;
		int t = array[i];
		array[i] = array[j];
		array[j] = t;
	}
}

int n, c[30], s[400][30];
int d[30];
int ans[400], ans2[400], ans3[400];
int x[400];

int score(int *l) {
	int res = 0;
	int dd[30];
	fill(dd, dd + 30, 0);
	for (int i = 1; i <= n; i++) {
		res += s[i][l[i]];
		dd[l[i]] = i;
		for (int j = 1; j <= 26; j++)res -= c[j] * (i - dd[j]);
	}
	return res;
}

signed main() {
	std::random_device rnd;
	cin >> n;
	for (int i = 1; i <= 26; i++)cin >> c[i];
	for (int i = 1; i <= n; i++)for (int j = 1; j <= 26; j++)cin >> s[i][j];
	for (int i = 1; i <= n; i++) {
		int ma = -1000000000, p = 0;
		for (int j = 1; j <= 26; j++) {
			int cnt = 0;
			for (int k = 1; k <= 26; k++)if (j != k)cnt -= c[k] * (i - d[k]);
			cnt += s[i][j];
			if (ma < cnt) {
				ma = cnt;
				p = j;
			}
		}
		ans[i] = p;
		d[p] = i;
	}
	int t = 2000;
	int ma = 0;
	while (t) {
		int q = 50;
		for (int i = 1; i <= n; i++)ans3[i] = ans2[i];
		for (int i = 1; i <= n; i++)ans2[i] = ans[i];
		while (q) {
			int x = rnd() % 365 + 1, y = rnd() % 26 + 1;
			int g = ans2[x];
			int f = score(ans2);
			ans2[x] = y;
			if (score(ans2) < f) ans2[x] = g;
			q--;
		}
		if (score(ans2) <= ma) {
			for (int i = 1; i <= n; i++)ans2[i] = ans3[i];
		}
        t--;
	}
	for (int i = 1; i <= n; i++)ans[i] = ans2[i];
	int q = 5;
	while (q) {
		for (int i = 1; i <= n; i++) {
			int ma = -1000000000, p = 0;
			for (int j = 1; j <= 26; j++) {
				ans[i] = j;
				if (ma < score(ans)) {
					ma = score(ans);
					p = j;
				}
			}
			ans[i] = p;
		}
		q--;
	}
	for (int i = 1; i <= n; i++)cout << ans[i] << endl;
	//cout << score(ans) << endl;
}

Measured memory_bytes: 3632
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=1e9+7;

#define getcode(i,j) (((i)>>(j))&1)
int n,m,dp[1<<15],con[15],bits[1<<15];
int main()
{
	for(int i=0;i<(1<<15);i++)bits[i]=__builtin_popcount(i);
	get2(n,m);
	for(int i=0,u,v;i<m;i++)
	{
		get2(u,v);u--;v--;
		con[u]|=1<<v;
	}
	
	dp[0]=1;
	for(int i=0;i<(1<<n);i++)
	{
		int all=(1<<n)-1^i;
		for(int nxt=all;nxt;nxt=nxt-1&all)
		{
			if(getcode(nxt,0)&&getcode(nxt,1))continue;
			int coef=1,rest=all^nxt;
			for(int j=0;j<n&&coef;j++)
			{
				if(getcode(nxt,j))coef=((LL)coef<<bits[con[j]&rest])%mod;
				else if(getcode(rest,j))coef=(((LL)coef<<bits[con[j]&nxt])-coef+mod)%mod;
			}
			dp[i|nxt]=(dp[i|nxt]+(LL)dp[i]*coef)%mod;
		}
	}
	printendl(dp[(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (int)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
vector<string> s;
vector<map<char, int>> mp;
/**********************************************/

int main(){
    cin >> n;
    s.resize(n+5);
    mp.resize(n+5);
    REP(i, n) cin >> s[i];

    REP(i, n){
        REP(j, s[i].size()){
            mp[i][s[i][j]]++;
        }
    }

    for(int i = 0; 'a'+ i != 'z' + 1; i++){
        int num = INF;
        REP(j, n){
            num = min(mp[j][(char)('a'+i)], num);
        }
        REP(j, num){
            cout << (char)('a'+i);
        }
    }
    cout << endl;
}


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

typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int main(){
    int used[1000000]={};
    int data[1000000]={};
    string s;
    while(getline(cin,s)){
        if(s=="")break;
        int m=0;
        rep(i,s.size()){
            if(s[i]==','){
                m=i;
                break;
            }
        }
        int a=stoi( s.substr(0,m) );
        int b=stoi( s.substr(m+1,s.size()-m) );
        data[a]++;
        used[a]=1;
    }
    while(getline(cin,s)){
        int m;
        rep(i,s.size()){
            if(s[i]==','){
                m=i;
                break;
            }
        }
        int a=stoi( s.substr(0,m) );
        int b=stoi( s.substr(m+1,s.size()-m) );
        data[a]++;
        if(used[a])used[a]=10;
    }
    rep(i,1000000){
        if(used[i]==10)cout<<i<<" "<<data[i]<<endl;
    }
}

Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

class BipartiteMatching {
    int n, n0;
    int mode;
    vvi adj;
    vi mc;
    vi used;

    bool dfs(int v) {
        used[v] = true;
        for (int i = 0; i < adj[v].size(); i++) {
            int u = adj[v][i];
            int w = mc[u];
            if (w < 0 || (!used[w] && dfs(w))) {
                mc[v] = u;
                mc[u] = v;
                return true;
            }
        }
        return false;
    }
public:
    BipartiteMatching(int n) : n(n), adj(n), mc(n, -1) {
        mode = 0;
    }
    BipartiteMatching(int n, int m) : n(n + m), n0(n), adj(n + m), mc(n + m, -1) {
        mode = 1;
    }

    void addEdge(int u, int v) {
        if (mode == 0) {
            adj[u].push_back(v);
            adj[v].push_back(u);
        } else {
            adj[u].push_back(n0 + v);
            adj[n0 + v].push_back(u);
        }
    }

    int match() {
        int ret = 0;
        for (int v = 0; v < n; v++) {
            if (mc[v] < 0) {
                used = vi(n);
                if (dfs(v)) {
                    ret++;
                }
            }
        }
        return ret;
    }

    int operator[](int k) {
        return mc[k];
    }
};

int main() {
    int x, y, e;
    cin >> x >> y >> e;
    BipartiteMatching match(x, y);
    for (int i = 0; i < e; i++) {
        int a, b;
        cin >> a >> b;
        match.addEdge(a, b);
    }

    cout << match.match() << endl;
}


Measured memory_bytes: 3300
#include <iostream>
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
using ll = long long int;
const int AL = 26 + 1;
const int MAXN = 100'000;
struct trienode{
    vector<trienode*> nodes;
    int count = 0;
    trienode(){
        nodes.resize(AL, NULL);
    }
    trienode*& operator[](int ch){
        return nodes[ch];
    }
};
int dp[MAXN][AL][AL];
struct trie{
    trienode begin;
    void get(const string &s, int idx){
        trienode* currnode = &begin;
        for(int i=0;i<s.size();i++){
            int ch = s[i] - 'a' + 1;
            if((*currnode)[ch] == NULL){
                (*currnode)[ch] = new trienode();
            }
            for(int i=0;i<AL;i++){
                if((*currnode)[i] == NULL) continue;
                dp[idx][ch][i]+=(*currnode)[i]->count;
            }
            currnode = (*currnode)[ch];
        }
    }
    void add(const string &s){
        trienode* currnode = &begin;
        ++currnode->count;
        for(int i=0;i<s.size();i++){
            int ch = s[i] - 'a' + 1;
            if((*currnode)[ch] == NULL){
                (*currnode)[ch] = new trienode();
            }
            currnode = (*currnode)[ch];
            ++currnode->count;
        }
    }
};
void solve(){
    int n;
    cin>>n;
    trie solver;
    vector<string> seq(n);
    for(int i=0;i<n;i++){
        cin>>seq[i];
        seq[i].pb('a' - 1);
        solver.add(seq[i]);
    }
    for(int i=0;i<n;i++){
        solver.get(seq[i], i);
    }
    int q;
    cin>>q;
    while(q--){
        int k;
        string order;
        vector<int> idx(AL);
        cin>>k>>order;
        int ans = 0;
        for(int i=0;i<AL-1;i++){
            idx[order[i] - 'a' + 1] = i + 1;
        }
        for(int i=0;i<AL;i++){
            for(int j=0;j<AL;j++){
                if(idx[i]<=idx[j]){
                    continue;
                }
                ans+=dp[k-1][i][j];
            }
        }
        cout<<ans+1<<"\n";
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

Measured memory_bytes: 348840
/// Containers Start
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <set>
#include <unordered_set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Extra Start
#define nn '\n'
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl
/// Debug End

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

int main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(n,a,b);
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(),p.end());
    int count1=0,count2=0,count3=0;
    rep(i,n){
        if(p[i]<=a){
            count1++;
        }else if(p[i]<=b){
            count2++;
        }else{
            count3++;
        }
    }
    cout << min(count1,min(count2,count3)) << nn;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;
    ll l,r;cin>>l>>r;
    if((r-l)>=2020){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 2019ll;
    for(ll i = l;i<r;i++){
        for(ll j = i+1;j<=r;j++){
            chmin(ans, i*j%2019ll);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd, sqrt
from operator import mul
from functools import reduce
from operator import mul
from pprint import pprint



sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = int(input())
a = list(map(int, input().split()))

t = 0
flg = 0

for ai in a[2:]:
    t = t ^ ai

b1 = a[0] + a[1] - t
if b1 < 0 or b1 % 2:
    flg = 1

b1 //= 2
a1 = b1

if a1 > a[0]:
    flg = 1

for i in reversed(range((a[0] + a[1]).bit_length())):
    if t & (1 << i):
        if b1 & (1 << i):
            flg = 1
        if a1 + 2 ** i <= a[0]:
            a1 += 2 ** i

if a1 == 0:
    flg = 1

print(a[0] - a1 if flg == 0 else -1)











Measured memory_bytes: 81356
import java.util.Scanner;
public class Main{
	static int n;
	static long[] s;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		s=new long[n+1];
		long ans=0;
		for(int i=2; i<=n; i++){
			int t=i;
			for(int j=2; j<=t; j++){
				while(t%j==0){
					s[j]++;
					t/=j;
				}
			}
		}
		ans+=count(74);
		ans+=count(24)*(count(2)-1);
		ans+=count(14)*(count(4)-1);
		ans+=count(4)*(count(4)-1)*(count(2)-2)/2;
		System.out.println(ans);
	}
	static long count(int u){
		long res=0;
		for(int i = 2; i<=n; i++){
			if(s[i]>=u){
				res++;
			}
		}
		return res;
	}
}

Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ_problem_01
{
    class Program
    {
        static long Check(long p, int k, long[] data, int n)
        {
            int j = 0;
            for(int i = 0; i < k; i++)
            {
                long s = 0;
                while(s + data[j] <= p)
                {
                    s += data[j];
                    j++;
                    if(j == n)
                    {
                        return n;
                    }
                }           
            }
            return j;
        }


        static long Maxp(long[] data, int k, int n)
        {
            long right = int.MaxValue;
            long mid = 0;
            long left = 0;

            while (right - left > 1)
            {
                mid = (right + left) / 2;
                long v = Check(mid, k, data, n);
                if(v >= n)
                {
                    right = mid;
                }
                else
                {
                    left = mid;
                }
            }
            return right;
        }



        static void Main(string[] args)
        {
            
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int k = int.Parse(str[1]);
            long[] data = new long[n];

            for (int i = 0; i < n; i++)
            {
                data[i] = int.Parse(Console.ReadLine());
            }

            long p = Maxp(data, k, n);

            Console.WriteLine(p);
        }

    }

}




Measured memory_bytes: 19980
def c_sequence():
    N = int(input())
    A = [int(i) for i in input().split()]

    def solver(sign):
        ret, total = 0, 0
        for a in A:
            total += a
            if sign * total <= 0:
                ret += abs(sign - total)  # 総和がsignになるまでaを変化させる
                total = sign
            sign *= -1
        return ret
    # 1: 奇数番目を正、偶数番目を負にする場合。 -1: その逆
    return min(solver(1), solver(-1))

print(c_sequence())

Measured memory_bytes: 14332
n=int(input())
l,r=0,n
print(0,flush=True)
s=input()
sl,sr=s,s
while True:
  m=(l+r)//2
  print(m,flush=True)
  sm=input()
  if sm==sl and (m-l)%2==0:
    l=m
    sl=sm
  elif sm!=sl and (m-l)%2!=0:
    l=m
    sl=sm
  else:
    r=m
    sr=sm

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

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

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

    vector<int> good(n, 1);
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        if(h[a] >= h[b]) good[b] = 0;
        if(h[a] <= h[b]) good[a] = 0;
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        ans += good[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4068
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;

const int MAXN = 510;

int R, S, r, s;
int sol[MAXN][MAXN];

int main(void) {
  scanf("%d%d%d%d", &R, &S, &r, &s);

  if (r == 1 && s == 1) {
    printf("No\n");
    return 0;
  }

  for (int i = 0; i < R; ++i)
    for (int j = 0; j < S; ++j)
      sol[i][j] = 1;

  for (int i = r - 1; i < R; i += r)
    for (int j = s - 1; j < S; j += s)
      sol[i][j] = -r*s;

  int shift = 0;
  llint x = sol[r - 1][s - 1];

  while (abs(x) < (llint) 1e9) {
    x *= (llint) 2;
    ++x;
    ++shift;
  }

  --shift;
  --x; x /= 2;

  for (int i = 0; i < R; ++i)
    for (int j = 0; j < S; ++j)
      sol[i][j] <<= shift;

  for (int i = r - 1; i < R; i += r)
    for (int j = s - 1; j < S; j += s)
      sol[i][j] = x;

  llint _sum = 0;
  for (int i = 0; i < R; ++i)
    for (int j = 0; j < S; ++j)
      _sum += (llint) sol[i][j];

  if (_sum > 0) {
    printf("Yes\n");
    for (int i = 0; i < R; ++i) {
      for (int j = 0; j < S; ++j)
        printf("%d ", sol[i][j]);
      printf("\n");
    }
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 3840
import java.util.Scanner; 

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

        int N = sc.nextInt();
        int a = 0, b = 0, c = 0, d = 0;

        for(int i = 0; i<N ;i++){
            String e = sc.next();
            if(e.equals("AC")) a++;
            if(e.equals("WA")) b++;
            if(e.equals("TLE")) c++;
            if(e.equals("RE")) d++;
        }

        System.out.println("AC x "+a);
        System.out.println("WA x "+b);
        System.out.println("TLE x "+c);
        System.out.println("RE x "+d);       

    }
}

Measured memory_bytes: 58728
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 100000;

inline int gcd(int a, int b)
{
	while (b > 0)
	{
		a %= b;
		swap(a, b);
	}
	return a;
}

int n;
int a[MaxN];

int main()
{
	cin >> n;
	for (int i = 0; i < n; ++i)
		a[i] = getint();

	bool cur = false;
	while (true)
	{
		int o = 0, e = 0, k = 0;
		for (int i = 0; i < n; ++i)
			a[i] & 1 ? (++o, k = i) : ++e;

		if ((~e & 1) && o == 1)
		{
			if (a[k] == 1)
				break;

			int d = --a[k];
			for (int i = 0; i < n; ++i)
				d = gcd(d, a[i]);
			for (int i = 0; i < n; ++i)
				a[i] /= d;

			cur = !cur;
		}
		else
		{
			if (e & 1)
				cur = !cur;

			break;
		}
	}

	puts(cur ? "First" : "Second");

	return 0;
}

Measured memory_bytes: 640
A,B,C = map(int, input().split())
o1 = min(A,B,C)
o3 = max(A,B,C)
o2 = A + B + C - o1 - o3
#print (str(o1) +  " " + str(o2) +  " "  + str(o3))
count = 0 
count += o3 - o2
o2 += count 
o1 += count
#print (count)
#print (str(o1) +  " " + str(o2) +  " "  + str(o3))
count += (o2 - o1)//2
o1 += ((o2 - o1)//2)*2
#print (str(o1) +  " " + str(o2) +  " "  + str(o3))
if (o1 == o2) :
	print (count)
else :
	print (count + 2)

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

vector<int> sieveOfEratosthenes(int n) {
  vector<int> primes(n, 0);
  for (int i = 2; i < n; ++i) primes[i] = i;
  for (int i = 2; i * i < n; ++i) {
    if (primes[i]) {
      for (int j = i * i; j < n; j += i) primes[j] = 0;
    }
  }
  // primes.erase(remove(begin(primes), end(primes), 0), end(primes));
  return primes;
}

int main() {
  int n;
  auto prime = sieveOfEratosthenes(123457 * 2);
  while (cin >> n, n) {
    int ans = 0;
    for (int i = n + 1; i <= 2 * n; i++) {
      ans += (prime[i] > 0);
    }
    cout << ans << endl;
  }
}



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

int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 13) {
		b = b;
	}
	else if (a >= 6) {
		b /= 2;
	}
	else {
		b = 0;
	}
	cout << b;
	return 0;
}



Measured memory_bytes: 3624
#include<iostream>
#define INT_MAX 1000000010
using namespace std;
int abs(int a){
	return a<0?-1*a:a;
}
int n,k,h[(int)1e5+1],dp[100001];
int solve(int st){
	if(st==n) return 0;
	int &ret=dp[st];
	if(ret!=INT_MAX) return ret;
	for(int i=1;i<=k&&st+i<=n;i++)
		ret=min(ret,abs(h[st]-h[st+i])+solve(st+i));
	return ret;
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){ 
		scanf("%d",h+i);
		dp[i]=INT_MAX;
	}
	cout<<solve(1);
	return 0;
}


Measured memory_bytes: 5760
// https://atcoder.jp/contests/abc155/tasks/abc155_d
// 2つの要素の積 二分探索　
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
#define outl(x) cout<<x<<endl
#define outsp(x) cout<<x<<" "
typedef long long ll;
typedef pair<int,int> P;

#define MAX_N 200005
ll n,k,nm=0,nz=0,np=0;
ll am[MAX_N];
ll ap[MAX_N];

ll search_minus(ll t){
	// t以上の数
	ll cnt = 0;
	if(nm<np){
		rep(i,nm){
			ll t2 = (t+am[i]-1)/am[i]; // t <= am[i]*ap[index]とするため
			ll index = lower_bound(ap,ap+np,t2)-ap;//ap[i-1]<k/am[i]<=ap[i]
			cnt += np-index;
		}
	}else{
		rep(i,np){
			ll t2 = (t+ap[i]-1)/ap[i]; 
			ll index = lower_bound(am,am+nm,t2)-am;
			cnt += nm-index;
		}
	}
	// outsp(t);outl(cnt);
	return cnt;
}
ll search_plus(ll t,ll x[],ll xn){
	// t以上の数
	ll cnt=0;
	rep(i,xn){
		ll t2 = (t+x[i]-1)/x[i];
		ll index = lower_bound(x+i+1,x+xn,t2)-x;
		cnt += xn-index;
	}
	// outsp(t);outl(cnt);
	return cnt;
}

int main() {
	cin>>n>>k;
	rep(i,n){
		ll a;
		cin >> a;
		if(a>0){ap[np]=a; np++;}
		else if(a<0){am[nm]=-a; nm++;}
		else nz++;
	}
	ll kall = n*(n-1)/2;
	ll km = np*nm;
	ll kz = nz*(nm+np) + nz*(nz-1)/2;
	ll kp = np*(np-1)/2 + nm*(nm-1)/2;
	sort(ap,ap+np);
	sort(am,am+nm);
	ll ans;
	if(k<=km){
		ll l=0,r=1e18+1;
		while(l<r){
			ll t=(l+r)/2;
			if(search_minus(t)>=k){
				if(t==l)break;
				l=t;
			}else r=t;
		}

		ans = -l;
	}else if(k<=km+kz){
		ans = 0;
	}else{
		ll l=0,r=1e18+1;
		while(l<r){
			ll t=(l+r)/2;
			if(search_plus(t,am,nm)+search_plus(t,ap,np)>=kall-k+1){
				if(t==l)break;
				l=t;
			}else r=t;

		}
		ans = l;
	}
	outl(ans);
    return 0;
}



Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long LL;

char s[11];

int main() {
    scanf("%s",s);
    for(int i = 0; s[i]; ++i) {
        if(s[i]=='9') s[i]='1';
        else if(s[i]=='1') s[i]='9';
    }
    printf("%s",s);

}


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

int main(){
  int tmp, n;
  unsigned long long int sum = 0;
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> tmp;
    sum += tmp - 1;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C=0;
  cin >> A;
  vector<int>P(A),G(A);
  for(int i=0;i<A;i++){
    cin >> P[i];
    G[i]=P[i];
  }
  sort(G.begin(),G.end());
  for(int i=0;i<A;i++){
    if(G[i]!=P[i])C++;
  }
  if(C>2)cout << "NO" <<endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=(c-a);
	int y=(d-b);	
	cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<stack>
#include<queue>
#include<sstream>
#include<bitset>
#include<cstdio>
using namespace std;
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
int main()
{
	//in_out_txt();
	fast();
	int a,b;
	cin>>a>>b;
	bool ok=true;
	string str;
	cin>>str;
	if(str[a]!='-')
		ok=false;
	for(int i=0;i<str.size();i++)
	{
		if(i==a)
			continue;
		if(str[i]<'0' || str[i]>'9')
			ok=false;
	}
	if(ok)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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


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

    int H[N], i, j,  ans = 0, lf;

    for (i=0; i<N; i++){
        scanf("%d", &H[i]);
    }

    for (i=0; i<N; i++){
        lf =1;
        for (j=0; j<N; j++){
            if (j >= i) break;
            if (H[j] > H[i]){
                lf = 0;
                break;
            }
        }
        if (lf == 1) ans++;
    }

    printf("%d",  ans);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<ctype.h>

int main(){
int i;
char moji;		
	
while(1){
	scanf("%c",&moji);
	
	if(moji=='\n') break;
	
	if(islower(moji)!=0){
		printf("%c",toupper(moji));
	}
	else if(isupper(moji)!=0){
		printf("%c",tolower(moji));
	}
	else{printf("%c",moji);}
}
printf("\n");


	


return 0;

}

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

int main() {
    int n;
  	cin >> n;
    double ans = 0;
    
    for(int i=0; i<n; i++)
    {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") {
        ans+= x;
        } else {
            ans +=  x * 380000;
        } 
    }
    cout  << ans << endl;
 }


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

ans = 0

# A内での転置数
# N*N通り調べてもいいが、以下ではjはiによって絞られることを考慮した
x = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        if a[i] > a[j]:
            x += 1

# y=Aの各要素について、それより小さい要素がA内にいくつ存在するか
# ex. [3,5,1]なら、3>1, 5>3, 5>1の3つ
y = 0
for a1 in a:
    for a2 in a:
        if a1 > a2:
            y += 1

# A内で発生する転倒数 * AはK個存在する
ans += x * k

# ...[3,5,1]...[3,5,1]...と2つのAを選ぶ時を考える
# このとき2つのA間での転倒は3つ、つまりyに等しくなる
# 2つのAの選び方はK_C_2
ans += y * k * (k - 1) // 2

ans %= 10**9 + 7
print(ans)


Measured memory_bytes: 9364
import java.util.*

fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val grid = (1..h).map { readLine()!! }
    val numOfWhite = grid.map { it.filter { it == '.' }.count() }.sum()

    data class Point(val y: Int, val x: Int, var dist: Int)

    val queue = ArrayDeque<Point>()
    val visited = Array(h) { Array(w) {false}}

    val start = Point(0, 0, 0)
    queue.offerLast(start)
    visited[start.y][start.x] = true

    val d = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)

    while (queue.isNotEmpty()) {
        val now = queue.pollFirst()

        val children = mutableListOf<Point>()
        for ((dy, dx) in d) {
            val nextY = now.y + dy
            val nextX = now.x + dx
            if (!(nextY in 0 until h && nextX in 0 until w)) {
                continue
            }
            if (grid[nextY][nextX] == '#') {
                continue
            }
            if (visited[nextY][nextX]) {
                continue
            }

            val child = Point(nextY, nextX, now.dist + 1)
            children.add(child)
        }

        for (child in children) {
            if (child.y == (h - 1) && child.x == (w - 1)) {
                val masu = child.dist + 1
                println(numOfWhite - masu)
                return
            }

            visited[child.y][child.x] = true
            queue.offerLast(child)
        }
    }

    println(-1)
}

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

using namespace std;

const int maxn = 110;
const int maxm = 1e5+10;

typedef long long ll;

int w[maxn], v[maxn];

ll dp[maxm];

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

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

	for (int i = 1; i <= n; i++)
		for (int j = m; j >= w[i]; j--)
			dp[j] = max(dp[j], dp[j-w[i]]+1LL*v[i]);

	ll ans = 0LL;
	for (int i = 1; i <= m; i++)
		ans = max(ans, dp[i]);

	cout << ans << "\n";
}

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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const int mod=1e9+7;
const int sze=1e5+2;
signed main(){
  int n;
  sl(n);
  int cnt[10][10];
  ms(cnt,0);
  for(int i=1;i<=n;i++){
	string str=to_string(i);
	int len1=str.length();
	 cnt[str[0]-'0'][str[len1-1]-'0']++; 
  }
  int ans=0;
   for(int i=1;i<=n;i++){
	 string str=to_string(i);
	 int len1=str.length();
	 ans+=cnt[str[len1-1]-'0'][str[0]-'0']; 
  }
  cout<<ans<<endl;
  
  
  return 0;
}


Measured memory_bytes: 384
#include<set>
#include<vector>
#include<list>
#include<deque>
#include<map>
#include <stack>
#include<algorithm>
#include<iterator>
#include<iostream>
#include<string>

using namespace std;

int main() {
    stack<int> v[1005];
    int n,q;
    cin>>n>>q;
    int a,b,c;
    while(q--){
        cin>>a;
        if(a==0){
            cin>>b>>c;
            v[b].push(c);
        }
        else if(a==1){
            cin>>b;
            if(!v[b].empty()) cout<<v[b].top()<<endl;
        }
        else{
            cin>>b;
            if(!v[b].empty()) v[b].pop();
        }
    }
    return 0;
}




Measured memory_bytes: 4396
s, t = [input() for _ in range(2)]
max_count = 0
for i in range(len(s) - len(t) + 1):
    m_count = 0
    for j in range(len(t)):
        if s[i+j] == t[j]:
            m_count += 1
    if max_count < m_count:
        max_count = m_count

print(len(t)-max_count)


Measured memory_bytes: 9120
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int l[N], r[N], ans[N];
 
signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    string s;
    cin >> s;
    int mx = 0;
    for(int i = 0; i < (int)s.length(); i++){
        if(s[i] == 'R')
            mx = i;
        else
            l[i] = mx;
    }
    mx = s.length();
    for(int i = s.length(); i >= 0; i--){
        if(s[i] == 'L')
            mx = i;
        else
            r[i] = mx;
    }
    for(int i = 0; i < (int)s.length(); i++){
        if(s[i] == 'R'){
            if((r[i]-i)&1)
                ans[r[i]-1]++;
            else
                ans[r[i]]++;
        }
        else{
            if((i-l[i])&1)
                ans[l[i]+1]++;
            else
                ans[l[i]]++;
        }

    }
    for(int i = 0; i < (int)s.length(); i++)
        cout << ans[i] << " ";
    return 0;
}

Measured memory_bytes: 1872
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
using namespace std;

int sx, sy, tx, ty;

int main() {
   cin >> sx >> sy >> tx >> ty;
   int dx = tx-sx;
   int dy = ty-sy;

   for (int i = 0; i < dy; i++) cout << 'U';
   for (int i = 0; i < dx; i++) cout << 'R';
   for (int i = 0; i < dy; i++) cout << 'D';
   for (int i = 0; i < dx+1; i++) cout << 'L';
   for (int i = 0; i < dy+1; i++) cout << 'U';
   for (int i = 0; i < dx+1; i++) cout << 'R';
   cout << 'D'; cout << 'R';
   for (int i = 0; i < dy+1; i++) cout << 'D';
   for (int i = 0; i < dx+1; i++) cout << 'L';
   cout << 'U';
   cout << endl;
}



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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

ll memo[100033][32];

ll nCr(int n, int r)
{
	if (memo[n][r]) return memo[n][r];
	if (r == 0 || n == r) return memo[n][r] = 1;
	if (r == 1) return memo[n][r] = n;
	ll res = nCr(n-1, r-1) + nCr(n-1, r);
	return memo[n][r] = res % MOD;
}

int N, M;
vector<int> v;

void init()
{
	cin >> N >> M;
	int t = 2;
	while (M != 1) {
		v.PB(0);
		while (M % t) {
			if (M < t * t) {
				t = M;
				break;
			}
			t++;
		}
		while (M % t == 0) {
			v.back()++;
			M /= t;
		}
	}
}

void solve()
{
	ll res = 1;
	rep(i, v.size()) {
		res *= nCr(N-1+v[i], v[i]);
		res %= MOD;
	}
	cout << res << endl;
}


Measured memory_bytes: 29952
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n,flag = 0,a[201],min = 1000000000;
	cin >> n ;
	string s[101];
	for (int i = 0; i < n; i++) {
		flag = 0;
		cin >> a[i];
		for (; a[i] % 2 == 0;) {
			flag++;
			a[i] = a[i] / 2;
		}
		if (min > flag) min = flag;
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	int x=n%10;
	if(x==3)
		cout<<"bon\n";
	else if(x==0||x==1||x==6||x==8)
		cout<<"pon\n";
	else
		cout<<"hon\n";
	return 0;
}




Measured memory_bytes: 3624
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define VI vector<int>
#define VD vector<double>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVC vector<VC>
#define VVS vector<VS>
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define mp make_pair
#define fi first
#define se second
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define range(vec,x,y) vec.begin()+x,vec.begin()+y
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
#define eraseif(vec,condition_x) vec.erase(remove_if(all(vec),[](auto x){return condition_x;}),vec.end())
#define countif(vec,condition_x) count_if(all(vec),[](auto x){return condition_x;})
#define replaceif(vec,condition_x,n) replace_if(all(vec),[](auto x){return condition_x;},n)
#define optvalue(vec,condition_x,relation_x_opt) *min_element(all(vec),[](int x,int opt){return condition_x ? (opt==0)||!(relation_x_opt):false;})
#define erase_unique(vec) vec.erase(unique(all(vec)),vec.end())
#define calcvec(vec,calc_x) for_each(all(vec),[](int&x){x= calc_x;})
#define calc2vec(vec1,op,vec2) {rep(1){int s=min(si(vec1),si(vec2));fou(i,0,s)vec1[i]=vec1[i] op vec2[i];}}
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__);
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(Head head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(Head head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
template<class C>void outvec(vector<C> vec){int vecsize=si(vec);fou(i,0,vecsize-1)cout<<vec[i]<<" ";out(vec[vecsize-1]);}
template<class C> C gcd(C a,C b){if(a&&b)return gcd(min(a,b),max(a,b)%min(a,b));else return a;}
template<class C> C lcm(C a,C b){return a/gcd(a,b)*b;}




#define int int64_t
// #define double long double


// 無名関数template
// map,makepair

signed main(){
  IOS;

  in(int,x,y)
  string ans;
  ans= (abs(x-y)<=1) ? "Brown" : "Alice";
  out(ans);


}

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

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

using namespace std;

int main(){
  int n;cin>>n;
  rep(i,50000){
    if((int)floor(i*1.08)==n){
      cout<<i;
      return 0;
    }
  }

  cout<<":(";

  return 0;
}

Measured memory_bytes: 384
function Main(input) {
 
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
  
    let N = parseInt(input[0].split(" ")[0]);
    let K = parseInt(input[0].split(" ")[1]);
    
    let d = input[1].split(" ").map(v => parseInt(v));
    
    for (let i = 1; i <= K; i++) {
        
        let flag = true;
        let tmp = make_d(d);
        
        for (let j = 0; j < d.length; j++) if (d[j] != tmp[j]) flag = false; 
        
        if (flag) break;
        
        d = tmp;
        
    }
    
    
    console.log(d.join(" "));
}

function make_d(d){
    
    let b_i = (new Array(d.length)).fill(0);
        
    d.forEach((value, index) => {
        
        let d_min = index - value >= 0 ? index - value : 0;
        let d_max = index + value + 1;
        
        b_i[d_min] += 1;
        if (d_max < b_i.length) b_i[d_max] -= 1;
        
    });
    
    for(let i = 0; i < b_i.length; i++) if(0 < i) b_i[i] += b_i[i - 1];
    
    return b_i;
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 70532
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,c[50],v[50],ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    for(int i=0;i<n;i++){
        if(v[i]>c[i]){
            ans+=v[i]-c[i];
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
 
class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws IOException {
        int a = ReadInt();
        int b = ReadInt();
        String str = String.format("%.6f", (double)a / b);
        System.out.println(a / b + " " + a % b + " " + str);
    }
    static int ReadInt() throws IOException {
        return Integer.parseInt(sc.next());
    }
}


Measured memory_bytes: 26500
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    char S[11];

    //input
    cin >> S;

    for(ll i = 0; i < strlen(S); i += 2){
        if(S[i] != 'h' || S[i + 1] != 'i'){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int MAX(int a,int b){
	return a>b?a:b;
}
void LCS(string s1,string s2){
	int x=s1.length();
	int y=s2.length();
	int m[x+1][y+1];
	for(int i=0;i<=x;i++){
		for(int j=0;j<=y;j++){
			if(i==0||j==0)
			m[i][j]=0;
			else if(s1[i-1]==s2[j-1])
			m[i][j]=m[i-1][j-1]+1;
			else 
			m[i][j]=MAX(m[i][j-1],m[i-1][j]);
		}
	}
	int i=x,j=y,count=m[x][y];
	char a[m[x][y]+1];
	a[m[x][y]]='\0';
	while(i>0&&j>0){
			if(s1[i-1]==s2[j-1]){
				a[--count]=s1[i-1];
				j--;
				i--;
			}
			else if(m[i-1][j]>m[i][j-1])
			i--;
			else
			j--;
		}
	
	cout<<a;
}
int main(){
  ios_base::sync_with_stdio(false);
cin.tie(NULL);
string str1,str2;
cin>>str1>>str2;
LCS(str1,str2);
return 0;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  int r,g,b;
  cin >> r >> g >> b;
  if((r * 100 + g * 10 + b ) % 4 == 0) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a); i >= (b); --i)
#define sz(a) int((a).size())
#define pconent(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef long double ld;
const ll MOD =  1e9 + 7;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define pos(v) ((v) << 1)
#define neg(v) (pos(v) ^ 1)
#define db(v) (cout<<v<<" ** "<<endl)
template <class T> inline void dbv(T a) { for(auto x : a){ cout<<x<<" ** " ;} cout<<endl;}
vector<vector<ll> > g;
vector<ll> vis;
vector<ll> comp;
void dfs(ll u)
{
    vis[u] = 1;
    comp.pb(u);
    for(ll c : g[u])
    {
        if(!vis[c])
        {
            vis[c]=1;
            dfs(c);
        }
    }
}
void output()
{
    ll n,m;
    cin>>n>>m;
    g.resize(n);
    vis.resize(n);
    vector<ll> p(n);
    FOR(i,0,n)
    {
        cin>>p[i];
        p[i]--;
    }
    FOR(i,0,m)
    {
        ll u,v;
        cin>>u>>v;
        u--;
        v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    ll ans=0;
    FOR(i,0,n)
    {
        if(!vis[i])
        {
            dfs(i);
            // dbv(comp);
            set<ll> ind,vals;
            for(auto x : comp)
            {
                ind.insert(x);
            }
            for(auto x : comp)
            {
                vals.insert(p[x]);
            }
            comp.resize(0);
            for(auto x : ind)
            {
                if(pconent(vals,x))
                {
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1  ;
    // cin>>t ;
    FOR(i,0,t)
    {
        output() ;
    }
    return 0 ;
}

Measured memory_bytes: 20468