akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
using namespace std;

#define PI 3.14159265359
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfstr(v) scanf("%s", v);
#define sz(v) (int)v.size()
#define ndl puts("")
#define SS stringstream
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

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

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int a[10][10];
int x[300][300];
int n, m;

int solve(int num) {
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> qu;
	qu.push({ 0, num });
	vector<int> cost(10, INT_MAX);
	cost[num] = 0;
	while (sz(qu)) {
		int curnum = qu.top().second;
		int curcost = qu.top().first;
		qu.pop();
		for (int i = 0; i < 10; i++) {
			if (cost[i] > curcost + a[curnum][i]) {
				cost[i] = curcost + a[curnum][i];
				qu.push({ cost[i], i });
			}
		}
	}
	return cost[1];
}


int main() {
	//PLAY();
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	

	cin >> n >> m;

	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			cin >> a[i][j];

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> x[i][j];

	ll res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (x[i][j] == -1) continue;
			res += solve(x[i][j]);
		}
	}
	cout << res << endl;

	return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

typedef long long ll;

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

int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  map<int, int> cnt;
  for(int i = 0; i < N; i++){
    cin >> D[i];
    cnt[D[i] - 1]++;
  }
  int M;
  cin >> M;
  vector<int> T(M);
  bool flag = true;
  for(int i = 0; i < M; i++){
    cin >> T[i];
    if(cnt[T[i] - 1]){
      cnt[T[i] - 1]--;
    }else{
      flag = false;
    }
  }
  if(flag)cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)
int sigma(int n) {
	return n*(n + 1) / 2;
}


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

	long long cnt = 0;
	FOR(b, 1, n) {
		int q = n / b;
		int r = n%b;
		cnt += q*max(0, b - k) + max(0, r - k + 1);
	}
	if (k == 0) {
		cnt -= n;
	}

	ANS(cnt);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define fd(i,k,n,d) for(int i = k; i<n; i+=d)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define W(x)        cout<<x<<endl
#define WW(x,y)     cout<<x<<' '<<y<<endl;
#define in(x)       cin>>x
#define v(x)        vector<x>
#define int         long long
#define ar(x,y)       array<x,y>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//****************************************************************************************************************************************//

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

//*****************************************************************************************************************************************//

template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}

template<class T>
T power(T a,T b,T m){
    T res = (T)1;
    a%=m;
    while(b>0){
        if(b&1)res = (res*a)%m;
        b>>=1;
        a = (a*a)%m;
    }
    return res;
}

//*****************************************************************************************************************************************//

struct dsu{
  map<int,int> pr,sz;
  dsu(){
    (this->pr).clear();
    (this->sz).clear();
  }
  void make(int x){
    pr[x] = x;
    sz[x] = 1;
  }
  int getpar(int x){
    if(pr[x] == x)return x;
    return pr[x] = getpar(pr[x]);
  }
  void merge(int x,int y){
    x = getpar(x);
    y = getpar(y);
    if(sz[x]<sz[y])swap(x,y);
    pr[y] = x;
    sz[x]+=sz[y];
    sz[y] = 0;
  }
};

//******************************************************************************************************************************************//


void solve(){
    int n;
    cin>>n;
    int odd = 0;
    odd+=n/2;
    if(n&1)odd++;
    cout<<fixed<<setprecision(12)<<(odd/(1.0*n))<<"\n";
}

signed main(){
    fastio();
    int cs = 1;
    //cin>>cs;
    while(cs--){
        solve();
    }
}


Measured memory_bytes: 3800
import sys
def input():
	return sys.stdin.readline()[:-1]

BASE, MOD = 1999849216943526259, (1<<61)-1

d = dict()
ans = 0
ss = [str(input())[::-1] for _ in range(int(input()))]
zero = [0 for _ in range(26)]
ss.sort(key=lambda x: -len(x))
for s in ss:
	n = len(s)
	if n == 1:
		ans += zero[ord(s[n-1])-97]
	else:
		hashes = [0 for _ in range(n-1)]
		hashes[0] = ord(s[0])
		for i in range(1, n-1):
			hashes[i] = (hashes[i-1] * BASE + ord(s[i])) % MOD
		if hashes[n-2] in d:
			ans += d[hashes[n-2]][ord(s[n-1])-97]
		alph = [0 for _ in range(26)]
		alph[ord(s[n-1])-97] = 1
		for i in range(n-2, 0, -1):
			alph[ord(s[i])-97] = 1
			if hashes[i-1] not in d:
				d[hashes[i-1]] = [0 for _ in range(26)]
			for j, a in enumerate(alph):
				d[hashes[i-1]][j] += a
		alph[ord(s[0])-97] = 1
		for j, a in enumerate(alph):
			zero[j] += a
print(ans)

Measured memory_bytes: 597876
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
int main(){
    int A,B;
    
    cin >> A >> B;
    cout << max(A+B,max(A-B,A*B)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forp(x,a,b) for(int x=a; x<b; x++)
#define forn(x,a,b) for(int x=a; x>b; x--)
#define SZ(a) ((int)(a).size())
#define pb push_back
#define vec(x) vector<x>
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define umpii unordered_map<int,int>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define ff first
#define ss second
#define print(x) for(auto it:x) cout<<it<<" ";
using namespace std;
typedef long long ll;

int pot(int x,int y){if(y==0){return 1;}
else{return x*pot(x,y-1);}
}

int bin(int x,int y){if((x==0 && y!=0)||(y==0 && x!=0)){return 1;}
else{return bin(x,y-1)+bin(x-1,y);}
}

void strlwr(string& s){for(int i=0;(unsigned)i<s.size();i++){if(s[i]>='A' && s[i]<='Z'){s[i]+=32;}}
}



int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
     
     int r,v,a,k, t=0;
     cin>>r>>v>>a>>k;
     while(!(v>r)){t++;v*=2;}
     while(!(a>v)){t++;a*=2;}
     t>k?cout<<"No":cout<<"Yes";
     
     
    
    
    return 0;}

Measured memory_bytes: 3648
while  True:
    table = input().split()
    a = int(table[0])
    op = table[1]
    b = int(table[2])

    if op == "+":
        print(a + b)
    elif op == "*":
        print(a * b)
    elif op == "-":
        print(a - b)
    elif op == "/":
        print(a // b)
    else:
        break



Measured memory_bytes: 5592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  int N,a,b;
  cin >> N;
  a=N/111;
  b=N%111;
  if(b==0)  cout << N << endl;
  else if(b!=0)  cout << (a+1)*111 << endl;

  return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def main():
    N, M = map(int, input().split())

    A = list(set(map(int, input().split(" "))))
    G = A.copy()

    while not any(x % 2 for x in G):
        G = [i // 2 for i in G]

    if not all(x % 2 for x in G):
        print(0)
        exit(0)

    total = 1

    for x in A:
        total = lcm(total, x // 2)

    print((M // total + 1) // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11508
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
int main(){
    int N;
    cin >> N;
    bool flg = false;
    for(int i=0; i<N; i++){
        string S;
        cin >> S;
        if(S[0] == 'Y') flg = true;
    }
    if(flg == false) cout << "Three" << endl;
    else cout << "Four" << endl;
    
    return 0;
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
 
const ll MAX = 2e5;
const ll inf = 1e18;
const ll mod = 1e9 + 7;


 
int main(){
	fastio;
	ll a,b,c;
	cin >> a >> b >> c;
	if( b*c >= a ) cout <<"Yes\n";
	else cout <<"No\n";
	return 0;
}

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

int main(){
    int q,x;
    string command;

    list<int> v;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> command;
        if(command == "insert"){
            cin >> x;
            v.push_front(x);
        }else if(command == "deleteFirst"){
            v.pop_front();
        }else if(command == "deleteLast"){
            v.pop_back();
        }else if(command == "delete"){
            cin >> x;
            for (auto itr = v.begin(); itr != v.end() ; itr++) {
                if(*itr == x){
                    v.erase(itr);
                    break;
                }
            }
        }
    }
    int i = 0;
    for(auto itr = v.begin(); itr != v.end(); ++itr) {
        if ( i ++) cout << " ";
        cout << *itr;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 34420
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
struct BIT{
    int n,beki=1;
    vector<int>bit;
    BIT(int x){
        bit.resize(x+1,0);
        n=x;
        while(beki*2<=n)beki*=2;
    }
    int sum(int i){
        int res=0;
        while(i>0){
            res+=bit[i];
            i-=i&-i;
        }
        return res;
    }
    void add(int i,int x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }
    int lowerbound(int w){
        if(w<=0)return 0;
        int x=0;
        for(int k=beki;k>0;k>>=1){
            if(x+k<=n&&bit[x+k]<w){
                w-=bit[x+k];
                x+=k;
            }
        }
        return x+1;
    }
};
void solve(){
    int n,a[200010],ans=0,odd=0;
    string s;
    vector<int>v[26];
    vector<P>vec;
    cin>>s;
    n=s.size();
    rep(i,n)v[s[i]-'a'].pb(i);
    rep(i,26)odd+=(v[i].size()%2);
    if(odd>=2){
        puts("-1");
        return;
    }
    rep(i,26){
        int siz=v[i].size();
        if(siz%2)a[n/2]=v[i][siz/2];
        rep(j,siz/2)vec.pb({v[i][j],v[i][siz-1-j]});
    }
    sort(all(vec));
    rep(i,vec.size()){
        a[i]=vec[i].fi;
        a[n-i-1]=vec[i].se;
    }
    BIT bit(n+1);
    rep(i,n)a[i]++;
    rep(i,n){
        ans+=i-bit.sum(a[i]);
        bit.add(a[i],1);
    }
    cout<<ans<<endl;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


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

#define st first
#define nd second
typedef long long LL;
typedef long double LLD;
typedef pair <int, int> PII;
typedef pair <LL, LL> PLL;

bool Check (int n)
{
    while (n >= 0)
    {
        if (n % 4 == 0)
            return true;
        n -= 7;
    }
    return false;
}

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

    if (Check(n))
        printf("Yes");
    else
        printf("No");
       
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int K = sc.nextInt();

		if(N%K==0) {

			System.out.println(0);

		}else {

			System.out.println(1);
		}

	}

}


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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
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>
inline T upper(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	ll x;
	cin >> x;

	if (x <= 6) cout << 1 << endl;
	else if(x <= 10) cout << 2 << endl;
	else {
		ll tmp = x / 11 * 2;
		if (x % 11) {
			if (x % 11 <= 6) tmp += 1;
			else tmp += 2;
		}
		cout << tmp << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

template <typename T>
struct cvector {
  vector<T> vec;
  cvector() : vec(26) {
  }
  cvector(T init) : vec(26, init) {
  }
  T& operator[](char c) {
    return vec[c - 'a'];
  }
};

template <typename T>
ostream& operator<<(ostream& s, const cvector<T>& cvector) {
  s << cvector.vec;
  return s;
}

signed main() {
  int H, W;
  cin >> H >> W;
  cvector<int> cnt;
  vector<vector<char>> a(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> a[i][j];
      cnt[a[i][j]]++;
    }
  }

  for (char c = 'a'; c <= 'z'; c++) {
    cnt[c] %= 4;
  }

  int h = H % 2, w = W % 2;

  bool ok = true;
  if (h + w == 0) {
    for (char c = 'a'; c <= 'z'; c++) {
      if (cnt[c] != 0)
        ok = false;
    }
  } else if (h + w == 1) {
    int can2 = (h ? W : H) / 2;
    for (char c = 'a'; c <= 'z'; c++) {
      if (cnt[c] == 0)
        continue;
      if (cnt[c] == 2 && can2 > 0) {
        can2--;
        continue;
      }
      ok = false;
    }
  } else {
    int can2 = H / 2 + W / 2;
    int can1 = 1;
    for (char c = 'a'; c <= 'z'; c++) {
      if (cnt[c] == 0)
        continue;
      if (cnt[c] == 2 && can2 > 0) {
        can2--;
        continue;
      }
      if (cnt[c] == 1 && can1 > 0) {
        can1--;
        continue;
      }
      ok = false;
    }
  }

  if (ok)
    cout << "Yes\n";
  else
    cout << "No\n";
}

Measured memory_bytes: 256
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define INF 1e16
#define N (1000000000+7)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;



int main(void){
    int h1,w1,h2,w2,k;
    cin>>h1>>w1>>h2>>w2>>k;
    int hour = k/60;
    int mi = hour*60-k;
    int total = 60*(h2-h1-1)+w2-w1+60;
    cout<<total-k<<endl;
    return 0;
}

Measured memory_bytes: 3636
N,M,C = map (int, input ().split ())
ans = 0
B = [int (x) for x in input().split()]
for i in range (N):
  K = 0
  A = [int (x) for x in input().split()]
  for j in range (M):
    K += (A[j])*(B[j])
  if K+C > 0:
    ans += 1
print (ans)

Measured memory_bytes: 9188
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	string res = "UNRESTORABLE";

	string S, T; cin >> S >> T;
	long slen = S.length();
	long tlen = T.length();

	for (int i = slen - tlen; i >= 0; i--) { //S内のどこを始点にするか
		string isT; isT = S.substr(i, tlen); //候補となる部分文字列

		for (int j = 0; j < tlen; j++) if (isT[j] != '?' && isT[j] != T[j]) goto isnot; 
        //候補が見つかったとき
		for (int j = 0; j < tlen; j++) S[j + i] = T[j];
		for (int k = 0; k < slen; k++) if (S[k] == '?') S[k] = 'a';

		cout << S << endl; return 0;

	isnot:;
	}

	cout << res << endl;

}

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

constexpr long long int MOD = 1e9 + 7;
int main(){
    int n, m;
    cin >> n >> m;
    vector<long long int> a(m), b(n+1);
    for(auto& e : a) cin >> e;
    a.push_back(1e9);
    b[0] = 1;
    b[1] = !(a[0] == 1);
    for(int i = 1, l = (a[0] == 1);i + 1 < n + 1;i++){
        if(i + 1 != a[l]){
            b[i+1] = b[i] + b[i-1];
            b[i+1] %= MOD;
        }else{
            if(i + 2 != a[l+1]){
                b[i+1] = 0;
            }else{
                b[0] = 0;
            }
            l = min(l+1, m-1);
        }
    }
    cout << b[0] * b[n] << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int a[1100];

int main(){
	int i, j, n, k;
	
	scanf("%d%d", &n, &k);

	int ans = 1;
	for (i = 0; i < n; i++) {
		if (ans < k) ans = ans*2;
		else ans += k;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <climits>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;

using Pair = pair<int, int>;
using lint = long long;

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

// const int mod = 1e9 + 7;
// const int mod = 998244353;

template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main(){
  int n,q;
  cin>>n>>q;
  dsu d(n);
  rep(i,q){
    int t,u,v;
    cin>>t>>u>>v;
    if(t==0)d.merge(u,v);
    else cout<<(int)d.same(u,v)<<endl;
  }
}


Measured memory_bytes: 3928
_ = gets.to_i
arr = gets.chop.split.map(&:to_i)
res = true
for i in arr
  next if (i%2) > 0 || ((i%3 == 0) || (i%5 == 0))
  res = false
  break
end
puts res ? 'APPROVED' : 'DENIED'


Measured memory_bytes: 1788
//#define _GLIBCXX_DEBUG
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef map<int, int> mii;
    typedef map<char,int> mci;
    typedef vector<int> vi;
    typedef vector<vi> vvi;
    typedef vector<ll> vll;
    typedef vector<pair<int,int>> vii;
    typedef vector<char> vc;
    typedef vector<vc> vcc;
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()
    #define pb push_back
    #define mp make_pair
    #define F first
    #define S second
    #define in insert
    #define sz(v) v.size()
    #define mina(a,b) (a)=min((a),(b));
    #define maxa(a,b) (a)=max((a),(b));
    const int INF = 1e9 + 5;
    
    void solve(){
        int a,b,t;
        cin>>a>>b>>t;
        int i=1;
        t=t/a;
        cout<<t*b;
    }
    int main(){
        int T=1;
        //cin>>T;
        for(int i = 0; i < T; i++) solve(); 
    }

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();

            out.println(Math.max(a + b, Math.max(a - b, a * b)));
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define pb push_back
//////////////////

int const INF = 1e9 + 41;
int const N = 2e5 + 41;
int n, b[N], qu, l[N], r[N], ans;

void remin(int &a, int b){
	a = min(a, b);
}

namespace tree{
	int t[(1 << 19)], l, r, val, p;
	
	void build(int v, int tl, int tr){
		if(tl == tr){
			t[v] = INF;
		}else{
			int tm = (tl+tr)/2;
			build(v*2+1, tl, tm);
			build(v*2+2, tm+1, tr);
			t[v] = min(t[v*2+1], t[v*2+2]);
		}
	}

	void build(){
		build(0, 0, n-1);
	}

	void upd(int v, int tl, int tr){
		if(tl == tr){
			remin(t[v], val);
		}else{
			int tm = (tl+tr)/2;
			if(p <= tm) upd(v*2+1, tl, tm);
			else upd(v*2+2, tm+1, tr);
			t[v] = min(t[v*2+1], t[v*2+2]);
		}
	}

	void upd(int p, int val){
		tree::p = p;
		tree::val = val;
		upd(0, 0, n-1);
	}
	
	int ask(int v, int tl, int tr){
		if(l > tr || tl > r) return INF;
		if(l <= tl && tr <= r) return t[v];
		int tm = (tl+tr)/2;
		return min(ask(v*2+1, tl, tm), ask(v*2+2, tm+1, tr));
	}

	int ask(int l, int r){
		tree::l = l;
		tree::r = r;
		return ask(0, 0, n-1);
	}
};

vector<int> e[N];

void solve(){
	tree::build();
	fi(0, qu) e[l[i]].pb(r[i]);
	int v0 = 0;
	fi(0, n){
		fj(0, sz(e[i])){
			int r = e[i][j];
			int v1 = tree::ask(i, r-1);
			int v = min(v1, v0);
			tree::upd(r, v);
		}
		v0 += (b[i] == 1 ? 1 : -1);
		v0 = min(v0, tree::ask(i, i));
	}
	ans = v0;
	fi(0, n) if(b[i] == 0) ++ans;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%d",&n);
	fi(0, n) scanf("%d",&b[i]);
	scanf("%d",&qu);
	fi(0, qu){
		scanf("%d %d",&l[i],&r[i]);
		--l[i];
		--r[i];
	}

	solve();

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

	return 0;
}

Measured memory_bytes: 13312
def caesar(s, n):
    ns = []
    for ch in s:
        # A - Z
        if ('A' <= ch and ch <= 'Z'):
            ns.append(chr((ord(ch) - ord('A') - n) % 26 + ord('A')))
        # a - z
        elif ('a' <= ch and ch <= 'z'):
            ns.append(chr((ord(ch) - ord('a') - n) % 26 + ord('a')))
        # 0 - 9
        elif ('0' <= ch and ch <= '9'):
            ns.append(chr((ord(ch) - ord('0') - n) % 10 + ord('0')))
        # no change for other characters
        else:
            ns.append(ch)
    return "".join(ns)

N = int(input())
i =input()

result = caesar(i, -N)
print(result)



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

int h, w, a[100][100], res, ans = 1000000009;

signed main()
{
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            res = 0;
            for(int k = 0; k < h; k++){
                for(int r = 0; r < w; r++){
                    res += a[k][r] * min(abs(i - k), abs(j - r));
                }
            }
            //printf("%lld %lld %lld\n", i, j, res);
            ans = min(ans, res);
        }
    }
    cout << ans << endl;


    return 0;
}



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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, tmp = 0;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	sort(begin(a), end(a));
	for(int i = 0; i < n - 1; ++i){
		if(a[i] == a[i + 1]) tmp += 1;
	}
	int ans = n - (tmp / 2 + tmp % 2) * 2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N;
	string S;
	cin >> N >> S;
	
	vector<int> E(N+1), W(N+1);
	for(int i=0;i<N;i++){
		E[i+1] = E[i] + (S[i] == 'E' ? 1 : 0);
		W[i+1] = W[i] + (S[i] == 'W' ? 1 : 0);
	}
	
	int mi = (int) 1e9;
	for(int i=0;i<N;i++){
		int lw = W[i];
		int re = E[N] - E[i+1];
		mi = min(mi, lw + re);
	}
	
	cout << mi << endl;
	
	
    return 0;
}

Measured memory_bytes: 3076
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    ans = 0
    ruiseki = [0]
    d = defaultdict(int)
    d[0] = 1
    for i in range(n):
        ruiseki.append(ruiseki[i] + a[i])
        ans += d[ruiseki[i+1]]
        d[ruiseki[i + 1]] += 1
    print(ans)

if __name__ == '__main__':
    main()


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

vector<int> A;
int n;

bool solve(int i, int m) {
  if (m == 0) return true;
  if (i >= n) return false;

  return solve(i + 1, m - A[i]) || solve(i + 1, m);
}

int main() {
  cin >> n;
  A.reserve(n);
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int m;
    cin >> m;
    if (solve(0, m)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}



Measured memory_bytes: 3096
import itertools

n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

ans = 0
for A in itertools.combinations_with_replacement(range(1, m+1), n):
    tmp = 0
    for i in range(q):#i番目の得点を計算
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            tmp += d[i]
    ans = max(ans, tmp)#最大化
    
print(ans)


Measured memory_bytes: 68160
# AOJ 0164 Ohajiki Game
# Python3 2018.6.18 bal4u

while True:
	n = int(input())
	if n == 0: break
	a = list(map(int, input().split()))
	print(31)
	i, k = 0, 31
	while k > 1:
		k -= a[i]
		print(k)
		k = k - (k-1) % 5;
		print(k)
		i += 1
		if i >= n: i = 0
	print(0)


Measured memory_bytes: 5596
import java.util.Scanner
import scala.collection.Searching._

import scala.annotation.tailrec

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def replace1(input: String): String = {
    if (input == "") ("") else {
      (input(0) match {
        case '0' => "1"
        case '1' => "2"
        case '2' => "3"
        case '3' => "4"
        case '4' => "5"
        case '5' => "6"
        case '6' => "7"
        case '7' => "8"
        case '8' => "9"
        case '9' => "0"
        case x => x
      }) + replace1(input.substring(1))
    }
  }

  def replace2(input: String): String = {
    if (input == "") ("") else {
      (input(0) match {
        case '0' => "9"
        case '1' => "0"
        case '2' => "1"
        case '3' => "2"
        case '4' => "3"
        case '5' => "4"
        case '6' => "5"
        case '7' => "6"
        case '8' => "7"
        case '9' => "8"
        case x => x
      }) + replace2(input.substring(1))
    }
  }

  def solve2(order: String, message: String): String = {
    if (order == "") (message) else {
      solve2(order.substring(1),
        order(0) match {
          case 'J' => message.charAt(message.length - 1) + message.substring(0, message.length - 1)
          case 'C' => message.substring(1) + message.charAt(0)
          case 'E' => message.substring((message.length + 1) / 2) + (if (message.length % 2 == 0) ("") else (message(message.length / 2))) + message.substring(0, message.length / 2)
          case 'A' => message.reverse
          case 'P' => replace2(message)
          case 'M' => replace1(message)
        })
    }
  }

  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    for (_ <- 0 until N) {
      println(solve2(sc.next.reverse, sc.next))
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

Measured memory_bytes: 44908
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
				
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0){
				break;
			}
			int start = Integer.parseInt(br.readLine());
			int goal = Integer.parseInt(br.readLine());
			int d = Integer.parseInt(br.readLine());

			boolean bridge[][] = new boolean[d + 1][n];
			for(int i = 1; i <= d; i++){
				String str = br.readLine();

				for(int j = 1; j < n; j++){
					if(str.charAt(j - 1) == '1'){
						bridge[i][j] = true;
					}
				}
			}

			solve(bridge, start, goal);
		}

	}
	static void solve(boolean bridge[][], int start, int goal){
		int d = bridge.length - 1;
		int n = bridge[0].length;
		
		//まずは普通にあみだくじをプレイ
		int result = playLots(bridge, start);

		if(result == goal){
			System.out.println(0);
			return;
		}
		//総当り
		for(int i = 1; i <= d; i++){
			for(int j = 1; j < n; j++){
				//置きたいところに既に橋がある
				//or そこに置くと繋がっていまう場合は除外
				if(bridge[i][j] || bridge[i][j - 1] || (j != n - 1 && bridge[i][j + 1])){
					continue;
				}

				bridge[i][j] = true;

				result = playLots(bridge, start);

				if(result == goal){
					System.out.println(i+" "+j);
					return;
				}

				//一時的に置いた橋は元に戻す
				bridge[i][j] = false;
			}
		}

		System.out.println(1);

	}
	//あみだくじをプレイ（1オリジン）
	static int playLots(boolean bridge[][], int start){
		int d = bridge.length - 1;
		int n = bridge[0].length;
		
		int current = start;
		
		for(int i = 1; i <= d; i++){
			if(bridge[i][current - 1]){
				current--;
			}
			else if(current != n && bridge[i][current]){
				current++;
			}
			
		}
		
		return current;
	}

}



Measured memory_bytes: 24464
#include<iostream>
using namespace std;
int main()
{
  	string s;
  	cin>>s;
  	if(s[0]=='S' && s[1]== 'S' && s[2]=='S')
  		cout<<"0\n";
	else if(s[0]=='R' && s[1]=='R' && s[2]=='R')
		cout<<"3\n";
	else if((s[0]=='R' && s[1]== 'S' && s[2]=='S') || (s[0]=='S' && s[1]== 'R' && s[2]=='S') || (s[0]=='S' && s[1]== 'S' && s[2]=='R') || (s[0]=='R' && s[1]== 'S' && s[2]=='R'))
  		cout<<"1\n";
  	else
  		cout<<"2\n";
  return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(void){

  int a , b , c , d , p ;
  int ma1 , ma2 ;

  scanf ("%d",&a);
  scanf ("%d",&b);
  scanf ("%d",&c);
  scanf ("%d",&d);
  scanf ("%d",&p);

  if (p > c){
    ma1 = b + (p-c) * d;
  }else{
    ma1 = b ;
  }
  ma2 = a * p;

  if (ma1 < ma2){
    printf ("%d\n",ma1);
  }else{
    printf ("%d\n",ma2);
  }

  return 0 ;

}

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

int main(){
    long long int q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;

    long long int per1 = min(q*4, min(h*2, s));
    cout << min(n * per1, (((n-(n%2))/2) * d + (n%2) * per1));

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<cstdlib>
#include<unordered_set>
#include<algorithm>
#include<chrono>
 
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
//~ #define ii pair	<long long ,long 	long >
#define i64ii pair< long long, pair<int,int> >
#define i64i pair<long long , int >
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define ii pair<int, int > 
#define iii pair<int, ii >	
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;

typedef long long ll;	
typedef vector< int> vi;
typedef long double ld;

typedef unsigned long long ull;
		
typedef  pair <ii, ii > iiii;
typedef vector < ii > vii;

const int MAX = 2100;
const int maxn = 1e6 + 100;



int n ;
int main(){
 //~ in
 
 
 
 cin >> n;
 
 int thousand = n / 500;
 int five =  (n % 500 ) / 5;
 
 cout << thousand * 1000 + five *5  << '\n';

 
 return 0;
}


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

string S;

int main(){
  cin >> S;
  if (S[1] == 'B') cout << "ARC" << endl;
  else cout << "ABC" << endl;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
int main() {
	// #ifndef ONLINE_JUDGE
	// 	// for getting input from input.txt
	// 	freopen("input.txt", "r", stdin);
	// 	// for writing output to output.txt
	// 	freopen("output.txt", "w", stdout);
	// #endif

		double n;
		cin>>n;
		for(int i=0;i<50000;i++){
			int x = i*1.08;
			if(n == x){
				cout<<i<<"\n";
				return 0;
			}
		}

		 cout << ":(" << endl;
		return 0;
	}	

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

typedef long long ll;

int main()
{
   int n;
   cin>>n;
   vector<string>s(n);
   vector<char>c(n);
   rep(i,n){
     cin>>s[i];
     c[i]=s[i].at(0);
     }
   
   vector<ll>a(5);//m,a,r,c,h
   rep(i,n){
     switch(c[i]){
     case 'M':
       a[0]++;
       break;
     case 'A':
       a[1]++;
       break;
     case 'R':
       a[2]++;
       break;
     case 'C':
       a[3]++;
       break;
     case 'H':
       a[4]++;
       break;
       }
   }
   ll ans;
   ans+=a[0]*(a[1]*(a[2]+a[3]+a[4])+a[2]*(a[3]+a[4])+a[3]*a[4]);
   ans+=a[1]*(a[2]*(a[3]+a[4])+a[3]*a[4]);
   ans+=a[2]*a[3]*a[4];
   cout<<ans<<endl;
   
     
}


Measured memory_bytes: 6272
#include<stdio.h>
#include<math.h>

int main(void) {
  int N, result = 0, highest = 0;
  scanf("%d", &N);

  for(int i=0;i<N;i++){
    int h;
    scanf("%d", &h);
    if(h >= highest) {
      highest = h;
      result ++;
    }
  }

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

  return 0;
}


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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=1e5+50;
int n,sze[N],mx_son[N],mx; LL ans;
vector <pii> edge[N];
inline void dfs(int x,int f) {
	sze[x]=1; 
	for(auto v:edge[x])
		if(v.first^f) {
			dfs(v.first,x); sze[x]+=sze[v.first];
			ans+=(LL)v.second*min(sze[v.first],n-sze[v.first])*2;
			mx_son[x]=max(mx_son[x],sze[v.first]);
		}
	mx_son[x]=max(mx_son[x],n-sze[x]);
	mx=min(mx,mx_son[x]);
}
int main() {
	n=rd(); mx=n;
	for(int i=1;i<n;i++) {
		int x=rd(), y=rd(), v=rd();
		edge[x].push_back(pii(y,v));
		edge[y].push_back(pii(x,v));
	} 
	dfs(1,0); 
	int mn=2e9;
	if((!(n&1)) && mx==n/2) {
		for(int i=1;i<=n;i++) if(mx_son[i]==n/2)
			for(auto v:edge[i]) if(mx_son[v.first]==n/2) mn=min(mn,v.second);
	} else {
		for(int i=1;i<=n;i++) if(mx_son[i]==mx)
			for(auto v:edge[i]) mn=min(mn,v.second);
	}
	ans-=mn;
	cout<<ans<<'\n';
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> board(h, vector<char>(w));
    rep(y, h) rep(x, w) cin >> board[y][x];

    vector<vector<int>> horizontal(h, vector<int>(w, 0));
    vector<vector<int>> vertical(h, vector<int>(w, 0));

    for (int y = 0; y < h; y++) {
        horizontal[y][0] = board[y][0] == '.' ? 1 : 0;
        for (int x = 1; x < w; x++) {
            if (board[y][x] == '.') {
                horizontal[y][x] = horizontal[y][x - 1] + 1;
            } else {
                horizontal[y][x] = 0;
            }
        }
    }

    for (int y = 0; y < h; y++) {
        for (int x = w - 2; x >= 0; x--) {
            if (horizontal[y][x] == 0) continue;
            horizontal[y][x] = max(horizontal[y][x + 1], horizontal[y][x]);
        }
    }

    for (int x = 0; x < w; x++) {
        vertical[0][x] = board[0][x] == '.' ? 1 : 0;
        for (int y = 1; y < h; y++) {
            if (board[y][x] == '.') {
                vertical[y][x] = vertical[y - 1][x] + 1;
            } else {
                vertical[y][x] = 0;
            }
        }
    }


    for (int x = 0; x < w; x++) {
        for (int y = h - 2; y >= 0; y--) {
            if (vertical[y][x] == 0) continue;
            vertical[y][x] = max(vertical[y + 1][x], vertical[y][x]);
        }
    }

    int ans = 0;
    rep(y, h) rep(x, w) {
            if (board[y][x] == '#') continue;
            int now = horizontal[y][x] + vertical[y][x] - 1;
            cmax(ans, now);
        }

    cout << ans << endl;
}

Measured memory_bytes: 37632
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < (ll)(r); i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = 1000000007;

int main() {
    int T; cin >> T;
    queue<ll> ans;
    while(T--) {
        int N; cin >> N;
        vector<P> lKD, rKD;
        ll mx = 0;  
        int K,L,R;
        rep(i,N) {
            cin >> K >> L >> R;

            //Lの方が高いラクダとRの方が高いラクダに分ける
            if(L-R >= 0) lKD.emplace_back(P(K, L-R));
            else rKD.emplace_back(P(N-K, R-L));
            mx += max(L,R);
        }
        //K（左端，右端からK番目以内に置きたい），LとRの差（希望通りでないときの減少量の小さい順）でソート
        sort(lKD.begin(), lKD.end());
        sort(rKD.begin(), rKD.end());

        //すでに並んでいるラクダの集合(LとRの差の小さい順)
        priority_queue<int, vector<int>, greater<int>> llaw;
        priority_queue<int, vector<int>, greater<int>> rlaw;
        int lidx = 0, ridx = 0;
        //左に並べたいラクダを順に並べていく
        rep(j,lKD.size()) {
            while(lidx < lKD.size() && j+1 == lKD[lidx].first) {
                llaw.push(lKD[lidx].second);
                lidx++;
            }
            //並んでいるラクダの内，LとRの差が小さいラクダを追い出す
            while(llaw.size() > j+1) {
                mx -= llaw.top();
                llaw.pop();
            }
        }
        //右に並べたいラクダを順に並べていく
        //N=Kのとき，右には並べられないことに注意
        rep(j,rKD.size()+1) {
            while(ridx < rKD.size() && j == rKD[ridx].first) {
                rlaw.push(rKD[ridx].second);
                ridx++;
            }
            while(rlaw.size() > j) {
                mx -= rlaw.top();
                rlaw.pop();
            }
        }
        ans.push(mx);
    }

    while(!ans.empty()) {
        cout << ans.front() << "\n";
        ans.pop();
    }
    return 0;
}


Measured memory_bytes: 5644