akhauriyash/Code-Regression huggingface dataset:
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const int maxn = 1e5 + 5;

int n;
int l[maxn], r[maxn];
ll ans = 0, res = 0;

int main(){
	scanf("%d", &n);
	FOR(i, 0, n){
		scanf("%d%d", l + i, r + i);
		r[i] = - r[i];
	}
	l[n] = r[n] = 0;
	sort(l, l + n + 1);
	sort(r, r + n + 1);
	for(int i = n; i >= 0; --i){
		res += l[i] + r[i];
		ans = max(ans, res);
	}
	printf("%lld\n", ans << 1);
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;
typedef long double ld;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

void solve(){

	ll n;
	cin>>n;
	vector<pair<ld,string>> money(n);
	for(ll i=0;i<n;i++){
		string u;
		ld x;
		cin>>x>>u;
		money[i]=make_pair(x,u);
	}

	ld sum=0;
	for(ll i=0;i<n;i++){
		if(money[i].second=="JPY"){
			sum+=money[i].first;
		}
		else{
			sum+=money[i].first*380000.0;
		}
	}

	cout<<(double)sum<<endl;
}


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


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int K, A, B;
	cin>>K>>A>>B;
	for(;A<=B;A++) if(A%K==0) {
		cout<<"OK\n";
		return 0;
	}
	cout<<"NG\n";
	return 0;
}

Measured memory_bytes: 3652
N = input()

a =  list(map(int,input().split()))
b = 0
c = 0
for i in range(len(a)):
    if a[i] % 2 == 0:
        b+=1
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            c+=1
if b == c:
    print('APPROVED')
else:
    print('DENIED')

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

void solve(int N, vector<int> a, vector<int> b)
{
    vector<vector<int>> tree(N);
    for (int i = 0; i < N - 1; i++)
    {
        tree.at(a.at(i) - 1).push_back(b.at(i) - 1);
        tree.at(b.at(i) - 1).push_back(a.at(i) - 1);
    }

    int k = 0;
    map<pair<int, int>, int> color;

    vector<bool> visited(N);
    visited.at(0) = true;
    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));
    while (!q.empty())
    {
        int u = q.front().first, c_u = q.front().second;
        q.pop();
        int c_v = 1;
        for (auto v : tree.at(u))
        {
            if (visited.at(v))
                continue;
            visited.at(v) = true;
            if (c_u == c_v)
                c_v++;
            color[make_pair(min(u, v), max(u, v))] = c_v;
            q.push(make_pair(v, c_v));
            k = max(k, c_v);
            c_v++;
        }
    }

    cout << k << endl;
    for (int i = 0; i < N - 1; i++)
    {
        cout << color.at(make_pair(a.at(i) - 1, b.at(i) - 1)) << endl;
    }
}

int main()
{
    int N;
    cin >> N;
    vector<int> a(N - 1);
    vector<int> b(N - 1);
    for (int i = 0; i < N - 1; i++)
    {
        cin >> a.at(i);
        cin >> b.at(i);
    }
    solve(N, move(a), move(b));
    return 0;
}


Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (long long int i=0;i<(n);i++)
//#define int long long  
int main(){
    int N,K;
    long long int x[52],y[52];
    long long int x1,y1,x2,y2;
    int count=0;
    long long int ans=8101145141919893364;
    cin >> N >> K;
    REP(i,N){cin >> x[i] >> y[i];}
    REP(i,N){
        for(int j=i+1;j<N;j++){
            REP(k,N){
                for(int l=k+1;l<N;l++){
                    x1=min(x[i],x[j]);
                    x2=max(x[i],x[j]);
                    y1=min(y[k],y[l]);
                    y2=max(y[k],y[l]);
                    count=0;
                    REP(m,N){
                        if(x1<=x[m]&&x[m]<=x2&&y1<=y[m]&&y[m]<=y2){
                        count++;
                        }
                    }
                    if(count >=K){
                    ans=min(ans,(x2-x1)*(y2-y1));
                    //cout << ans << endl;
                    }
                }
            }
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
 
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;
#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;
 

void solve(){
    string s;
    cin >> s;
    int cpd = 0;
    
    string ans = "";
    rep(i,s.size()){
        
        if (s[i] == '?'){
            ans += 'D';
        }   
        else ans += s[i];
    }
    
    cout << ans;
    
}
void solve1(){
    string s;
    int h1,m1,h2,m2;
    int k;
    cin >> h1 >> m1 >> h2 >> m2;
    cin >> k;
    int start = h1*60+m1;
    int end = h2*60+m2;
    
    //vector<int> a();
    
    cout << max(0,end-start-k);
    
    
}
 
int main(){
    int T;
    T = 1;
    while(T--){
        solve(); 
    }
}
 

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

class Program
{
    static void Main(string[] args)
    {
        var A = sc.ReadInt();
        var B = sc.ReadInt();
        var C = sc.ReadInt();
        var D = sc.ReadInt();
        var x = A * B;
        var y = C * D;
        var ans = Math.Max(x, y);
        Console.WriteLine(ans);
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


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

int main(){
    
    // 1. 入力情報取得.
    int N, K;
    char S[22];
    scanf("%d %s %d", &N, S, &K);
    
    // 2. S の K番目の文字と異なる文字全て '*' に置き換えて出力.
    for(int i = 0; i < N; i++){
        if(S[i] != S[K - 1]) printf("%c", '*');
        else                 printf("%c", S[i]);
    }
    printf("\n");
    return 0;
    
}

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

namespace B_Time_Limit_Exceeded
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str1 = Console.ReadLine().Split(' ');
            int N = int.Parse(str1[0]);
            int T = int.Parse(str1[1]);
            int[] c = new int[N];
            int[] t = new int[N];
            for(int i = 0; i < N; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                c[i] = int.Parse(str[0]);
                t[i] = int.Parse(str[1]);                
            }

            int cmin = int.MaxValue;
            int Count = 0;
            //int answer = 0;
            for(int i = 0; i < N; i++)
            {
                if (t[i] <= T)
                {
                    Count++;
                    if (cmin > c[i])
                    {
                        cmin = c[i];
                    }
                   
                    //answer = i;
                }
            }

            if (Count != 0)
            {
                Console.Write(cmin);
            }
            else
            {
                Console.Write("TLE");
            }
           
        }
    }
}


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

int max(int a, int b)
{
	return a > b ? a : b;
}
void result(string s1, string s2)
{
	int n1 = s1.length();
	int n2 = s2.length();
	int dp[n1+1][n2+1];
	for (int i = 0; i <= n1; ++i)
	{
		for (int j = 0; j <= n2; ++j)
		{
			if(i==0 || j==0)
				dp[i][j] = 0;
			else if(s1[i-1] == s2[j-1])
				dp[i][j] = dp[i-1][j-1]+1;
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	int index = dp[n1][n2];
	char lcs[index+1];
	lcs[index] = '\0';
	int i = n1, j = n2; 
	while (i > 0 && j > 0) 
	{ 
	  if (s1[i-1] == s2[j-1]) 
	  { 
	      lcs[index-1] = s1[i-1]; 
	      i--; j--; index--;     
	  } 

	  else if (dp[i-1][j] > dp[i][j-1]) 
	     i--; 
	  else
	     j--; 
	} 
  	cout << lcs << endl;
}
int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	result(s1,s2);
	return 0;
}


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

namespace AthleteProgramming2
{
    
    class Program
    {
        static void Main()
        {
            string str;
            Stack<int> stack = new Stack<int>();
            while ((str = Console.ReadLine()) != null)
            {
                int num = int.Parse(str);
                if (num != 0)
                {
                    stack.Push(num);
                }else
                {
                    Console.WriteLine(stack.Pop());
                }
            }
        }
    }
}

Measured memory_bytes: 9996
// NOMURA2020D.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 5050, mod = 1e9 + 7;

int n, fa[MAX_N], siz[MAX_N], mem[MAX_N], f[MAX_N], m;

int find(int x) { return mem[x] == x ? x : mem[x] = find(mem[x]); }

int fpow(int bas, int tim)
{
	int ret = 1;
	while (tim)
	{
		if (tim & 1)
			ret = 1LL * ret * bas % mod;
		bas = 1LL * bas * bas % mod;
		tim >>= 1;
	}
	return ret;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &fa[i]), mem[i] = i, siz[i] = 1;
	for (int i = 1; i <= n; i++)
		if (fa[i] > 0)
		{
			int fx = find(i), fy = find(fa[i]);
			if (fx != fy)
				siz[fy] += siz[fx], mem[fx] = fy;
		}
		else
			m++;
	int ans = 1LL * n * fpow(n - 1, m) % mod;
	f[0] = 1;
	for (int i = 1; i <= n; i++)
		if (i == find(i))
			if (fa[i] == -1)
				for (int j = n; j >= 1; j--)
					f[j] = (0LL + f[j] + 1LL * f[j - 1] * siz[i] % mod) % mod;
			else
				ans = (0LL + ans + mod - fpow(n - 1, m)) % mod;
	f[1] = (0LL + f[1] + mod - m) % mod;
	int acc = 1;
	for (int i = 1; i <= m; acc = 1LL * acc * i % mod, i++)
		ans = (0LL + ans + mod - 1LL * f[i] * fpow(n - 1, m - i) % mod * acc % mod) % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

//2e5
const ll max_n = 1<<18;
const ll init_m=1e18;
ll leaf_n;
vector<ll> dat(max_n);

// 要素数決定、(1<<31)-1で初期化
void init(ll n) {
  leaf_n=1;
  while(leaf_n<n) leaf_n*=2;
  for(ll i=0;i<2*leaf_n-1;i++) dat[i]=init_m;
}

// from 0 [k]->a
void update(ll k,ll a) {
  k+=leaf_n-1;
  dat[k]=a;
  while(k>0) {
    k=(k-1)/2;
    dat[k]=min(dat[k*2+1],dat[k*2+2]);
  }
}

// (a,b,0,0,leaf_n),[a,b),[0,leaf_n)
ll find(ll a, ll b, ll k, ll l, ll r) {
  if(r<=a||b<=l) return init_m;
  if(a<=l&&r<=b) return dat[k];
  else {
    ll vl=find(a,b,k*2+1,l,(l+r)/2);
    ll vr=find(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
}

int main() {
  ll n,x;
  cin >> n >> x;
  init(n);
  for(ll i=0;i<n;i++) {
    ll a;
    cin >> a;
    update(i,a);
  }
  ll ans=1e18;
  for(ll i=0;i<n;i++) {
    ll tans=x*i;
    for(ll j=0;j<n;j++) {
      ll f=j-i;
      if(f<0) {
        f+=n;
        tans+=min(find(f,n,0,0,leaf_n),find(0,j+1,0,0,leaf_n));
      }
      else {
        tans+=find(f,j+1,0,0,leaf_n);
      }
    }
    ans=min(ans,tans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B, C;
  cin >> A >> B >> C;
  if (A == B && A == C && B == C)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
//
//AtCoder Beginner Contest 072
//D
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<int> p(n);
    REP(i, n) {
        cin >> p[i];
        p[i]--;
    }

    int ans=0;
    REP(i,n){
        if (i==p[i]){
            if (i==n-1) swap(p[i],p[i-1]);
            else swap(p[i],p[i+1]);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> L(n), R(n);
    L[0] = a[0];
    R[n-1] = a[n-1];

    for (int i = 1; i < n; i++) {
        L[i] = __gcd(a[i], L[i-1]);
    }

    for (int i = n - 2; i >= 0; i--) {
        R[i] = __gcd(R[i+1], a[i]);
    }

    int ans = L[n-1];
    for (int i = 0; i < n; i++) {
        int tmp = -1;
        if (i > 0) {
            tmp = L[i-1]; 
        }
        if (i < n - 1) {
            if (tmp == -1) tmp = R[i+1];
            else tmp = __gcd(tmp, R[i+1]);
        }
        if (tmp == -1) continue;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>

using namespace std;

int n, k;
long long a[100001];
long long sum[100001];
long long sum_plus[100001];

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

        long long s1 = 0;
        long long s2 = 0;
        for (int i = 0; i < n; i++) {
                cin >> a[i];
                s1 += a[i];
                s2 += max(0LL, a[i]);

                sum[i + 1] = s1;
                sum_plus[i + 1] = s2;
        }

        sum[0] = 0;
        sum_plus[0] = 0;

        long long ans = 0;
        for (int i = 0; i <= n - k; i++) {
                ans = max(ans,
                          sum_plus[i] + max(sum[i + k] - sum[i], 0LL) +
                              (sum_plus[n] - sum_plus[i + k]));
        }

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


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; }

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

ll n;
ll a[100010];
ll b[100010];
int main(){
    cin >> n;
    rep(i, n+1)cin >> a[i];
    rep(i, n)cin >> b[i];
    ll ans = 0;
    rep(i, n){
        if(a[i] >= b[i]){
            ans += b[i];
        }else{
            ans += a[i];
            ans += min(a[i+1], b[i]-a[i]);
            a[i+1] = max(0LL, a[i+1] - (b[i]-a[i]));
        }
    }
    cout << ans << endl;

}



Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string w;
	
	cin >> w;

	char a[26];

	memset(a, 0, sizeof(char)*26);

	for (int i = 0; i < w.size(); i++)
	{
		int index = w[i] - 'a';
		a[index] = a[index] ^ 0x01; 
	}

	bool is_be = true;
	for (int i = 0; i < 26; i++)
	{
		if (a[i] != 0)
		{
			is_be = false;
			break;
		}
	}

	if (is_be)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string ans;
    for(int i = 0; i < size(s); i++) {
        if(i & 1 ^ 1) ans += s[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3740
#入力
N,M = map(int,input().split())
K = [0] * N
A = [0] * N
for i in range(N):
    K[i], *A[i] = map(int, input().split())
#共通部分    
Ans_i = set(A[0])
for i in range(N):
  Ans_i = Ans_i & set(A[i])
print(len(list(Ans_i)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(998244353)
#define PI 3.14159265358979323846264338327950L
#define debugCont(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl
#define double long double
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

signed main(){

    fastIO
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double angle = ((double)h + (double)m/60.0)*30 - (double)m*6;
	// trace(angle);
	double rad = PI * 2 * ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0);
	angle *= (PI/180);
	trace(angle, rad)
	double ans1 = sqrtl((double)(b*b + a*a) - (double)2*b*a*cosl(angle));
	// double ans2 = sqrtl((double)(b*b + a*a) - (double)2*b*a*cosl(rad));
	// printf("ans2 = %Lf\n", ans2);
	// printf("%20.20Lf\n", ans1);
	cout << setprecision(20) << ans1 << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  map<char,ll> m;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    char c=S.at(0);
    if(m.count(c)==0){
      m[c]=1;
    }else{
      m[c]++;
    }
  }

  ll a=m['M'],b=m['A'],c=m['R'],d=m['C'],e=m['H'];
  ll ans=a*b*c+a*b*d+a*b*e+a*c*d+a*c*e+a*d*e+b*c*d+b*c*e+b*d*e+c*d*e;
  cout<<ans<<endl;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, a, b, c);
  out(max(0, c - (a - b)));
}


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

using namespace std;
typedef long long LL;

int main(){
	LL N, K;
	cin >> N >> K;
	if(N>=K) N%=K;
	cout << min(N,K-N) << endl;

	return 0;
}


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

using namespace std;

int main(void) {
	
	int n;
	cin >>n;
	
	int h[n+1]={0},i,max=0;
	for (i=0 ; i<n ; i++) {
		cin >>h[i];
		if (h[i]>max) max=h[i];
	}
	
	int oh,w=0;
	for (oh=0 ; oh<=max ; oh++) {
		for (i=0 ; i<n+1 ; i++) {
			if (h[i]<=oh && h[i-1]>oh) {
				w++;
			}
		}
	}
	
	cout <<w <<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;
int main() {
	int R[MAX], n;
	cin >> n;
	for (int i = 0; i<n; i++)cin >> R[i];

	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i<n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << maxv << endl;
	return 0;
}


Measured memory_bytes: 3872
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, q;
    cin >> n >> q;
    auto edge = initVec2<int>(n + 1, 0);
    rep(i, n - 1){
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    vector<int> ans(n + 1, 0);
    rep(i, q){
        int p, x;
        cin >> p >> x;
        ans[p] += x;
    }

    stack<P> st;
    st.emplace(1, 0);
    while(not st.empty()){
        int v = st.top().first;
        int p = st.top().second;
        st.pop();

        ans[v] += ans[p];
        for(int u : edge[v]){
            if(u == p){
                continue;
            }
            st.emplace(u, v);
        }
    }

    rep(i, n){
        cout << ans[i+1] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 19440
#include<stdio.h>
int main(){
  int str,tmp;
  int i,j,n,k,l,a[8],b[8];
  scanf("%d",&n);
  for(k=0;k<n;k++){
    scanf("%d",&str);

    for(i=0;i<8;i++){
      a[i]=str%10;
      str/=10;
    }
    for(i=0;i<=7;i++)b[i]=a[i];

  for(i=0;i<7;i++){
    for(j=7;j>i;j--){
      if(a[j]>a[j-1]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
      }
    }
  }
  for(i=0;i<7;i++){
    for(j=7;j>i;j--){
      if(b[j]<b[j-1]){
	tmp=b[j];
	b[j]=b[j-1];
	b[j-1]=tmp;
      }
    }
  }


  l=10000000,str=0,tmp=0;
  for(i=7;i>=0;i--){
    str+=l*a[i];
    tmp+=l*b[i];
    l/=10;
  }

  printf("%d\n",tmp-str);
  }
  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void) {
    

    int S, h, m, s;

    scanf("%d", &S);

    h = S / 3600;
    m = (S % 3600) / 60;
    s = ((S % 3600) % 60);

    printf("%d:%d:%d\n", h,m,s);

    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
 
using namespace std;

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

	if(s.size()<=2){
		cout << 0 << endl;
		return 0;
	}

	ll ans=0;
	ll acnt = 0;

	rep(i,0,s.size()-1){
		if(s[i]=='B' && s[i+1]=='C'){
			ans += acnt;
			i++;
		}
		else if(s[i]=='A'){
			acnt++;
		}
		else{
			acnt=0;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 720
#include <stdio.h>

int prime(int a){
  int i;
  if(a<=1)return 1;
  if(a==2)return 0;
  if(a%2==0)return 1;

  for(i=3;i*i<=a;i+=2){
    if(a%i==0)return 1;
  }

  return 0;
}

int main(void){
  int i,n,a,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(prime(a)==0)count++;
  }

  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 1800
import sys
input = sys.stdin.readline
from collections import *

"""
def dfs(x, y):
    if x<=1 and y<=1:
        return False
    
    res = False
    
    for i in range(2, x+1, 2):
        res |= not dfs(x-i, y+i//2)
    
    for i in range(2, y+1, 2):
        res |= not dfs(x+i//2, y-i)
    
    return res

for i in range(5):
    for j in range(5):
        print(dfs(i, j), end=' ')
    
    print()
"""

X, Y = map(int, input().split())

if abs(X-Y)<=1:
    print('Brown')
else:
    print('Alice')

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
	int n; cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int ans = 0;
	int active = 0;
	rep(i, n) {
		if (active >= h[i]) {
			active = h[i];
		}
		else {
			ans += h[i] - active;
			active = h[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,l,i,sum=0;
  scanf("%d %d",&n,&l);
  int j[n];
  for(i=0;i<n;i++){
    scanf("%d",&j[i]);
    sum+=j[i];
    if(sum>l){
      break;
    }
  }
  printf("%d",i+1);
  return 0;
}


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

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    String S = scanner.next();
    scanner.close();
    int[] countW = new int[N + 1];
    Arrays.fill(countW, 0);
    for (int i = 1; i < N + 1; i++) {
      if (S.charAt(i - 1) == 'W') {
        countW[i] = countW[i - 1] + 1;
      } else {
        countW[i] = countW[i - 1];
      }
    }
    int[] tmp = new int[N];
    for (int i = 0; i < N; i++) {
      tmp[i] = countW[i] + N - (i + 1) - (countW[N] - countW[i + 1]);
    }
    int ans = Integer.MAX_VALUE / 4;
    for (int i : tmp) {
      ans = Math.min(ans, i);
    }
    System.out.println(ans);
  }

}


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

long long n;
long long a[60] = {0};
long long now = 0, num = 0, p = 0, cnt = 0;
long long ans[2][120] = {0};

void solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    a[i] = x;
    if(abs(num) <= abs(x)) {
      num = x;
      p = i;
    }
  }
  solve();
  cout << cnt << endl;
  for(int i = 0; i < cnt; ++i) {
    cout << ans[0][i] + 1 << " " << ans[1][i] + 1 << endl;
  }
  return 0;
}

void solve() {
  if(num == 0) return;
  for(int i = 0; i < n; ++i) {
    if(a[i] == num) continue;
    ans[0][cnt] = p;
    ans[1][cnt] = i;
    ++cnt;
    a[i] += num;
  }
  if(num > 0) {
    now = 0;
    while(now < n - 1) {
      if(a[now] > a[now + 1]) {
        ans[0][cnt] = now;
        ans[1][cnt] = now + 1;
        ++cnt;
        a[now + 1] += a[now];
      }
      ++now;
    }
  }
  else {
    now = n - 1;
    while(now > 0) {
      if(a[now] < a[now - 1]) {
        ans[0][cnt] = now;
        ans[1][cnt] = now - 1;
        ++cnt;
        a[now - 1] += a[now];
      }
      --now;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	ll n,m; cin>>n>>m;
	vl c(m);
	rep(i,0,m)cin>>c[i];
	vvl dp(m+10,vl(n+10));
	rep(i,0,m+10){
		rep(j,0,n+10){
			dp[i][j]=MOD;
		}
	}
	dp[0][0]=0;
	rep(i,0,m){
		rep(j,0,n+1){
			chmin(dp[i+1][j],dp[i][j]);
			if(j-c[i]>=0)chmin(dp[i+1][j],dp[i+1][j-c[i]]+1);
		}
	}
	cout<<dp[m][n]<<endl;
	
	
	return 0;
}


Measured memory_bytes: 14944
#include <stdio.h>


int main() {
	int H, W, N, hasil;
	
	scanf("%d %d %d", &H, &W, &N);
	
	if(H > W) {
		hasil = (N+H-1)/H;
	} else {
		hasil = (N+W-1)/W;
	}
	
	printf("%d\n", hasil);
	
	return 0;
}

Measured memory_bytes: 1640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a;
  cin>>a;
  vector<int> b(a),c(a),d(a);
  rep(i,a)
    cin>>b[i]>>c[i]>>d[i];
  rep(i,a){
  if(b[i]%2!=(c[i]+d[i])%2||(c[i]+d[i]>b[i])){
  cout<<"No"<<endl;
    return 0;
  }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 2560
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [long(input_raw[0]), long(input_raw[1])]
    A = []
    A_str = []
    for i in range(N):
        input_raw = read_func().strip().split()
        A_str.append(input_raw)
    is_all_zero_set = set([])
    for i in range(M):
        is_all_zero = True
        for j in range(N):
            if A_str[j][i] != "0":
                is_all_zero = False
                break
        if is_all_zero == True:
            is_all_zero_set.add(i)


    for i in range(N):
        col = -1
        a = 0
        for j in range(M):
            if j in is_all_zero_set:
                continue
            col += 1
            a += int(A_str[i][j]) << col
        A.append(a)
    M_new = col + 1
##    is_set = set([])
##    is_all_zero_set = set([])
##    A_ = [0 for i in range(N)]
##    all_zero_count = 0

##    for i in range(max(M, N)):
##        is_all_zero = True
##        for j in range(N):
##            if (A[j] & (0x01 << i)) > 0 and j not in is_set:
##                A_[i] = A[j]
##                is_set.add(j)
##                break

##    for i in range(max(M, N)):
##        is_all_zero = True
##        for j in range(N):
##            if (A[j] & (0x01 << i)) > 0:
##                is_all_zero =False
##            if (A[j] & (0x01 << i)) > 0 and j not in is_set:
##                A_[i] = A[j]
##                is_set.add(j)
##                is_all_zero =False
##                break
##        if is_all_zero == True:
##            is_all_zero_set.add(i)
##            all_zero_count += 1
##            for j in range(N):
##                if j not in is_set:
##                    A_[i] = A[j]
##                    is_set.add(j)
##                    break

    for i in range(min(N, M_new)):
        if (A[i] >> i) & 0x01 == 0:
            for j in range(i + 1, N):
                if (A[j] >> i) & 0x01 > 0:
                    tmp = A[j]
                    A[j] = A[i]
                    A[i] = tmp

        for j in range(N):
            if j == i:
                continue
            if ((A[j] >> i) & 0x01) > 0:
                A[j] = A[j] ^ A[i]
    r = 0
    for i in range(N):
        if A[i] != 0:
            r += 1
    k = N - min(r, M_new)
    count1 = 1L
    for i in range(M-1):
        count1 = (count1 * 2L)%998244353
    count2 = 1L
    for i in range(N):
        count2 = (count2 * 2L)%998244353
    count3 = 1L
    for i in range(k):
        count3 = (count3 * 2L)%998244353
    count = (count1 * ((count2 - count3) %998244353))%998244353
    print count



if __name__ == '__main__':
    main()


Measured memory_bytes: 3824
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

int a, b;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> a >> b;
    if (a > 9 || b > 9) cout << "-1\n";
    else cout << a * b << '\n';
}

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

int B[1000][1000], W[1000][1000];

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

  for(; N--; ){
    int x, y; char c; scanf("%d%d %c", &x, &y, &c);
    int b = (x / K + y / K) ^ (c == 'W');

    (b & 1 ? B : W)[x % K][y % K]++;
  }

  for(int j = 1; j < K; j++){
    B[0][j] += B[0][j - 1]; W[0][j] += W[0][j - 1];
  }

  for(int i = 1; i < K; i++){
    B[i][0] += B[i - 1][0]; W[i][0] += W[i - 1][0];
  }

  for(int i = 1; i < K; i++){
    for(int j = 1; j < K; j++){
      B[i][j] += B[i - 1][j] + B[i][j - 1] - B[i - 1][j - 1];
      W[i][j] += W[i - 1][j] + W[i][j - 1] - W[i - 1][j - 1];
    }
  }

  int ans = 0;

  for(int i = 0; i < K; i++){
    for(int j = 0; j < K; j++){
      int b = 2 * B[i][j] - B[K - 1][j] - B[i][K - 1];
      int w = 2 * W[i][j] - W[K - 1][j] - W[i][K - 1];

      int bv = b - w + B[K - 1][K - 1]; if(bv > ans) ans = bv;
      int wv = w - b + W[K - 1][K - 1]; if(wv > ans) ans = wv;
    }
  }

  printf("%d\n", ans);
  return 0;
}

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

typedef long long ll;
using namespace std;

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

    int ans = INT_MAX;
    for (int i = 0; i < n; ++i) {
        int c, tt;
        cin >> c >> tt;
        if (tt <= t) {
            ans = min(ans, c);
        }
    }
    if (ans == INT_MAX) cout << "TLE";
    else cout << ans;
    return 0;
}


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

const int MOD = 998244353;
inline int add(int x, int y) { return x + y >= MOD ? x + y - MOD : x + y; }
inline int sub(int x, int y) { return x < y ? x - y + MOD : x - y; }
inline int mul(int x, int y) { return 1LL * x * y - 1LL * x * y / MOD * MOD; }
inline void Add(int &x, int y) { (x += y) >= MOD && (x -= MOD); }

int n, m, K, tot;
int a[310], S[310], dp[310][310][610], sum1[310][310][610], sum2[310][310][610];
// dp[now][sum][delta]
char s[310];

int main() {
	// freopen("in.txt", "r", stdin);
	scanf(" %s%d", s + 1, &K), n = strlen(s + 1), K = std::min(K, n), s[++n] = '0';
	for (int i = 1, cnt = 0; i <= n; ++i) {
		if (s[i] == '0') a[++m] = cnt, cnt = 0;
		else ++cnt;
	}
	for (int i = 1; i <= m; ++i) S[i] = S[i - 1] + a[i];
	tot = S[m];
	for (int i = a[1]; i <= n; ++i) dp[1][i][i - a[1]] = 1;
	for (int j = 0; j <= tot; ++j)
		for (int k = 0; k <= tot << 1; ++k) {
			if (!j || !k) sum1[1][j][k] = dp[1][j][k];
			else sum1[1][j][k] = add(sum1[1][j - 1][k - 1], dp[1][j][k]);
		}
	for (int j = tot; ~j; --j)
		for (int k = 0; k <= tot << 1; ++k) {
			if (!k) sum2[1][j][k] = dp[1][j][k];
			else sum2[1][j][k] = add(sum2[1][j + 1][k - 1], dp[1][j][k]);
		}
	// for (int i = 2; i <= m; ++i)
	// 	for (int j = S[i - 1]; j <= tot; ++j)
	// 		for (int k = 0; k <= tot << 1; ++k)
	// 			for (int l = std::max(S[i] - j, 0); l + j <= tot; ++l) if (k + abs(l - a[i]) <= (tot << 1))
	// 				Add(dp[i][l + j][k + abs(l - a[i])], dp[i - 1][j][k]);
	for (int i = 2; i <= m; ++i) {
		for (int j = S[i]; j <= tot; ++j)
			for (int k = 0; k <= tot << 1; ++k) {
				// S[i - 1] <= l <= j, now: j - l, del: |j - l - a[i]|
				// int L = std::max(j - a[i] - k, S[i - 1]), R = j - a[i] + std::min(a[i], k);
				int L = std::max(S[i - 1], j - a[i] - k), R = std::min(j, j + k - a[i]);
				// printf("Update! i: %d, j: %d, k: %d [%d, %d]\n", i, j, k, L, R);
				if (L > R) continue;
				dp[i][j][k] = add(sub(sum1[i - 1][j - a[i]][k], L && k + a[i] + L > j ? sum1[i - 1][L - 1][k - j + a[i] + L - 1] : 0),
							   	  sub(sum2[i - 1][j - a[i] + 1][k - 1], k + j > R + a[i] ? sum2[i - 1][R + 1][k - R + j - a[i] - 1] : 0)
								 );
				// if (dp[i][j][k]) printf("Update! i: %d, j: %d, k: %d [%d, %d]\n", i, j, k, L, R);
			}
		for (int j = 0; j <= tot; ++j)
			for (int k = 0; k <= tot << 1; ++k) {
				if (!j || !k) sum1[i][j][k] = dp[i][j][k];
				else sum1[i][j][k] = add(sum1[i][j - 1][k - 1], dp[i][j][k]);
			}
		for (int j = tot; ~j; --j)
			for (int k = 0; k <= tot << 1; ++k) {
				if (!k) sum2[i][j][k] = dp[i][j][k];
				else sum2[i][j][k] = add(sum2[i][j + 1][k - 1], dp[i][j][k]);
			}
	}
	// for (int i = 2; i <= m; ++i)
	// 	for (int j = 0; j <= tot; ++j)
	// 		for (int k = 0; k <= tot << 1; ++k)
	// 			if (dp[i][j][k]) printf("dp[%d][%d][%d] = %d\n", i, j, k, dp[i][j][k]);
	int ans = 0;
	for (int i = 0; i <= K; ++i) Add(ans, dp[m][tot][i << 1]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 164572
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll a, b, c;

int main(){
	cin >> a >> b >> c;
	cout << min(b/a, c) << endl;
	return 0;
}

Measured memory_bytes: 256