akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b,c = li()

if a+b >= c:
    print(b+c)
else:
    print(a+2*b+1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

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

int main(){
  int m = 1000000007;
  int n, k;
  cin >> n >> k;
  vector<vector<int> > a(n);
  REP(i, n - 1){
    int p, q;
    cin >> p >> q;
    --p, --q;
    a[p].push_back(q);
    a[q].push_back(p);
  }
  uint64_t r = k;
  vector<bool> visited(n);
  visited[0] = true;
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int v = q.front();
    q.pop();
    int s = 0;
    for(int b: a[v]){
      if(visited[b]) continue;
      ++s;
      q.push(b);
      visited[b] = true;
    }
    int b = k - 1;
    if(v == 0){
      b = k;
    }
    if(b <= s){
      cout << 0 << endl;
      return 0;
    }
    for(int g = b - s; g < b; ++g){
      r *= g;
      r %= m;
    }
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 6520
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array



void solve(){
	string s;
	cin >> s;
	int n = s.size();
	if(s[n-1]=='s') s+="es";
	else s+='s';
	cout << s << "\n";
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int TC = 1;
    while(TC--)
        solve();

    return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int m, n; cin >> m >> n;
	vector<ll> w(m + 1), t(m + 1);
	rep(i, m){
		int x, y; cin >> x >> y;
		w[i + 1] = w[i] + x;
		t[i + 1] = t[i] + y;
	}
	vector<ll> c(n), b(n);
	rep(i, n) cin >> c[i] >> b[i];
	
	vi dp(1 << n, -1);
	dp[0] = 0;
	
	rep(i, 1 << n) if(dp[i] >= 0) rep(j, n) if(!(i & 1 << j)){
		ll nw = w[dp[i]] + c[j];
		ll nt = t[dp[i]] + b[j];
		nw = upper_bound(all(w), nw) - w.begin();
		nt = upper_bound(all(t), nt) - t.begin();
		dp[i | 1 << j] = max(dp[i | 1 << j], (int)min(nw, nt) - 1);
	}
	cout << dp[(1 << n) - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 6180
n = int(input())
p_l = []
for _ in range(n):
    p_l.append(int(input()))
    
# print(p_l)
# print(sum(p_l))

p_l_s = sorted(p_l, reverse=True)
# print(p_l_s)
p_l_s[0] = int(p_l_s[0] / 2)
# print(p_l_s)

print(sum(p_l_s))

Measured memory_bytes: 9004
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<int,int> P;

int H,W;

int main(){
  cin >> H >>  W;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      string s;
      cin >> s;
      if(s == "snuke"){
        char c = 'A' + j-1;
        cout << c << i << endl;
      }
    }
  }
}

Measured memory_bytes: 384
while True:
    n,x = map(int,input().split())
    if n == x == 0:
        exit()
    ans = 0
    for i in range(1,n-1):
        for j in range(i+1,n+1):
            c = x-i-j
            if j < c <= n:
                ans += 1
    print(ans)


Measured memory_bytes: 5592
#include <vector>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

bool isValid(vi xs, vi ys, vi hs, int x, int y, int H)
{
    ll count = xs.size();
    for(int i = 0; i < count; i++)
    {
        if(max(H - abs(xs[i] - x) - abs(ys[i] - y), 0) != hs[i])
            return false;
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    vi xs(N), ys(N), hs(N);
    int x, y, h, idx = 0;
    while (cin >> x >> y >> h) {
        xs[idx] = x;
        ys[idx] = y;
        hs[idx] = h;
        idx++;
    }
    
    int h_min = 0, h_max = 0;
    h_min = *std::min_element(hs.begin(), hs.end());
    h_max = *std::max_element(hs.begin(), hs.end());
    
    vi h_c(h_max - h_min + 1000);
    for(int i = 0; i < h_c.size(); i++)
        h_c[i] = h_min + i;
    
    for (int x = 0; x <= 100; x++) {
        for (int y = 0; y <= 100; y++) {
//            auto p =  partition_point(h_c.begin(), h_c.end(), [&, x, y](int H){return isValid(xs, ys, hs, x, y, H);});
//            if (p != h_c.begin() && p != h_c.end()) {
//                cout << x << " " << y << " " << *p - 1 << endl;
//                break;
//            }
            for(auto& h : h_c){
                if(isValid(xs, ys, hs, x, y, h)){
                    cout << x << " " << y << " " << h << endl;
                    break;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)

















int main(){
    ll n;
    cin >> n;
    vector<string> s(n);
    vector<vector<ll>> w(n, vector<ll>(n, INF));
    REP(i, n){
        cin >> s[i];
        REP(j, n){
            if(s[i][j] == '1') w[i][j] = 1;
            if(i == j) w[i][j] = 0;
        }
    }
    
    vector<ll> col(n);
    [dfs = [&](auto &dfs, ll now, ll c) -> void {
        col[now] = c;
        REP(i, n){
            if(s[now][i] == '0') continue;
            if(col[i] == 0){
                dfs(dfs, i, c == 1? 2 : 1);
            }
            else{
                if(c == col[i]){
                    cout << -1 << endl;
                    exit(0);
                }
            }
        }
    }](){ dfs(dfs, 0, 1); }();
    
    REP(k, n){
        REP(i, n){
            REP(j, n){
                w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
            }
        }
    }
    cout << [n, w](){
        ll mx = 0;
        REP(i, n){
            REP(j, n){
                mx = max(mx, w[i][j]);
            }
        }
        return mx + 1;
    }() << endl;
}

Measured memory_bytes: 896
a,b,c = input().split()

tmp = []
ans = []
tmp.append(a)
tmp.append(b)
tmp = ''.join(tmp)
ans.append(int(tmp)+int(c))

tmp = []
tmp.append(b)
tmp.append(c)
tmp = ''.join(tmp)
ans.append(int(tmp)+int(a))

tmp = []
tmp.append(a)
tmp.append(c)
tmp = ''.join(tmp)
ans.append(int(tmp)+int(b))

tmp = []
tmp.append(c)
tmp.append(a)
tmp = ''.join(tmp)
ans.append(int(tmp)+int(b))

tmp = []
tmp.append(b)
tmp.append(a)
tmp = ''.join(tmp)
ans.append(int(tmp)+int(c))


tmp = []
tmp.append(c)
tmp.append(b)
tmp = ''.join(tmp)
ans.append(int(tmp)+int(a))

print(max(ans))


Measured memory_bytes: 38416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e9+7;
#define ALL(x) (x).begin(),(x).end()

int main() {
	int N, K;
	cin >> N >> K;
	vector<ll> X(N), Y(N), xs(N), ys(N);
	for(int i=0;i<N;i++) {
		cin >> X[i] >> Y[i];
		xs[i] = X[i];
		ys[i] = Y[i];
	}
	xs.push_back(-2*INF);
	ys.push_back(-2*INF);
	sort(ALL(xs));
	sort(ALL(ys));
	xs.erase(unique(ALL(xs)), xs.end());
	ys.erase(unique(ALL(ys)), ys.end());

	vector<int> cx(N), cy(N);
	vector<vector<int>> sum(N+1, vector<int>(N+1,0));
	map<int,ll> tox, toy;
	for(int i=0;i<N;i++) {
		cx[i] = lower_bound(ALL(xs), X[i]) - xs.begin();
		cy[i] = lower_bound(ALL(ys), Y[i]) - ys.begin();
		tox[cx[i]] = X[i];
		toy[cy[i]] = Y[i];
		sum[cy[i]][cx[i]]++;
	}
	for(int i=1;i<=N;i++) {
		for(int j=1;j<=N;j++) {
			sum[i][j] = sum[i][j] + sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
		}
	}
	ll ans = LLONG_MAX;
	// [yl, yr], [xl,xr]の範囲を求める
	for(int yl=1;yl<=N;yl++) {
		for(int yr=yl;yr<=N;yr++) {
			for(int xl=1;xl<=N;xl++) {
				for(int xr=xl;xr<=N;xr++) {
					int tsum = sum[yr][xr] - sum[yr][xl-1] - sum[yl-1][xr] + sum[yl-1][xl-1];
					if(tsum == K) {
						ans = min(ans, (toy[yr] - toy[yl]) * (tox[xr] - tox[xl]));
					}
				}
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

void subsets(vector<int> U, int n, int m) 
{
    long nSub = 1 << n;
    
    for(long i = 0; i < nSub; i++)
    {
        long d = 0;
        
        for(int k = 0; k < n; k++)
        {
            if((1 << k) & i)
            {
                d += (1 << U[k]);
            } 
        }
        
        vector<int> v;
        
        for(int k = 0; k < n; k++)
            if((1 << k) & i)
                v.emplace_back(U[k]);
        
        if((int)v.size() == m)
        {
            printf("%ld:", d);
            for(int k = 0; k < m; k++)
                printf(" %d", v[k]);
            printf("\n");
        }
    }
}

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

    vector<int> U;
    
    for(int i = 0; i < n; i++)
        U.emplace_back(i);
    
    subsets(U, n, k);
    
    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const int mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x,ll n,int md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}

int main(){
    fastio;
    //clock_t tm = clock();
    double r;
    cin>>r;
    double ans=2*PI*r;
    cout<<setprecision(8)<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,x;
	cin >> n >> x;
	ll ans = -1;
	FOR(i,0,n){
		ll k;
		cin >> k;
		k = abs(x-k);
		if(ans==-1)ans = k;
		ans = gcd(k,ans);
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
require 'prime'

A, B, K = gets.chomp.split.map(&:to_i)

a_div = A.prime_division
b_div = B.prime_division
a_div_h = Hash[*a_div.flatten]
b_div_h = Hash[*b_div.flatten]
primes = a_div.map{|t| t[0]} & b_div.map{|t| t[0]} # 積集合
c_div = primes.map{|p| [p, [a_div_h[p], b_div_h[p]].min]}
c_div_h = Hash[*c_div.flatten]

cds = [1]
for prime in primes do
  cds = cds.map{|e| (0..c_div_h[prime]).map{|power| prime**power}.map{|ee| ee*e}}.flatten
end

ans = cds.sort.reverse[K-1]
print("#{ans}\n")

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

using namespace std;

int main()
{
  int n, r;
  double xa, ya, ra, xb, yb, rb, d;

  while(cin>>n && n)
    while(n--){
      cin >> xa >> ya >> ra >> xb >> yb >> rb;
      d = sqrt(pow(xa-xb, 2.0)+pow(ya-yb, 2.0));
      if(fabs(ra-rb) > d){
	if(ra > rb) r = 2;
	else if(ra < rb) r = -2;
	else r = 1;
      } else if(d <= ra+rb && fabs(ra-rb) <= d){
	r = 1;
      } else {
	r = 0;
      }
      cout << r << endl;
    }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

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

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

    int n,l;
    cin>>n>>l;
    int answer=n*l+(n-1)*n/2;
    if(l<=0 && l+n-1>=0) cout<<answer;
    else if(l>0) cout<<answer-l;
    else cout<<answer-(l+n-1);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{   int i,l,j;
    char s[101],t[101],tmp[1];
    scanf("%s",s);
    scanf("%s",t);
    l=strlen(s);
    for(i=0;i<l;i++){
        if(strcmp(s,t)==0){
            printf("Yes");
            return 0;
        }else{
            tmp[0]=s[0];
            for(j=0;j<l-1;j++){
                s[j]=s[j+1];
            }
            s[l-1]=tmp[0];
        }
    }
    
printf("No");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


int main()
{
    ll N,M;
    cin >> N >> M;
    vector<pair<ll,ll>> AB(N);
    for(int i = 0; i < N; i++)
    {
        cin >> AB[i].first >> AB[i].second;
    }
    sort(AB.begin(),AB.end());

    ll cost = 0;

    for(int i = 0; i < AB.size(); i++)
    {
        if(M == 0)break;
        if(M > AB[i].second)
        {
            M -= AB[i].second;
            cost += AB[i].first * AB[i].second;
        }
        else
        {
            cost += AB[i].first * M;
            M = 0;
        }
    }

    cout << cost << endl;
}

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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const ll llinf = LLONG_MAX;
const ull ullinf = ULLONG_MAX;

int n, c;
int cost[50][50];
int color[510][510];
vector<int> v0, v1, v2;
vector<int> cost0, cost1, cost2;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;:w
#endif
  cin >> n >> c;
  for (int i = 0; i < c; i++) {
    for (int j = 0; j < c; j++) {
      cin >> cost[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> color[i - 1][j - 1];
      color[i - 1][j - 1]--;
      if ((i + j) % 3 == 0) v0.push_back(color[i - 1][j - 1]);
      else if ((i + j) % 3 == 1) v1.push_back(color[i - 1][j - 1]);
      else v2.push_back(color[i - 1][j - 1]);
    }
  }
  /*  for (int k = 0; k < c; k++) {
    for (int i = 0; i < c; i++) {
      for (int j = 0; j < c; j++) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
    }*/
  for (int i = 0; i < c; i++) {
    int res = 0;
    for (int j = 0; j < (int)v0.size(); j++) {
      res += cost[v0[j]][i];
    }
    cost0.push_back(res);
  }
  for (int i = 0; i < c; i++) {
    int res = 0;
    for (int j = 0; j < (int)v1.size(); j++) {
      res += cost[v1[j]][i];
    }
    cost1.push_back(res);
  }
  for (int i = 0; i < c; i++) {
    int res = 0;
    for (int j = 0; j < (int)v2.size(); j++) {
      res += cost[v2[j]][i];
    }
    cost2.push_back(res);
  }
  ll ans = 100000000000;
  for (int i = 0; i < c; i++) {
    for (int j = 0; j < c; j++) {
      if (i == j) continue;
      for (int k = 0; k < c; k++) {
        if (k == i || k == j) continue;
        ll res = cost0[i] + cost1[j] + cost2[k];
        //cout << "i:" << i << "j:" << j << "k:" << k << "=" << res<<endl;
        ans = min(ans, res);
      }
    }
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}



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

int main() {
  ll A;
  long double B;
  cin >> A >> B;
  ll ans = ll(A * B * 100);
  
  cout << ans / 100 << endl;
  return 0;
}


Measured memory_bytes: 3720
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int H, W, d;
int c(int y, int x) {
	return y * H + x;
}
bool isRanged(int y, int x) {
	return y >= 0 && y < H && x >= 0 && x < W;
}
int main() {
	H = in();
	W = in();
	d = in();
	
	if (d % 2 == 1) {
		rep(y, H) {
			rep(x, W) {
				cout << ((y + x) % 2 ? "R" : "B");
			}
			cout << endl;
		}
		return 0;
	}
	
	vector<vint> area(H, vint(W, 0));
	int N = max(H, W) + 3;
	rep(s, N) {
		repr(t, -N, N) {
			int y = s * d / 2 - t * (d / 2 - 1);
			int x = s * d / 2 + t * (d / 2 + 1);
			if (y + d / 2 <= 0) break;
			if (x >= W) break;
			if (x + d < 0) continue;
			repr(k, - d / 2 + 1, d / 2 - 1) repr(i, abs(k), d - abs(k)) {
				if (! isRanged(y + k, x + i)) continue;
				area[y + k][x + i] = (s & 1) * 2 + (t & 1);
			}
		}
	}
	
	rep(y, H) {
		rep(x, W) cout << ("RGBY"[area[y][x]]);
		cout << endl;
	}
	
	return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	double R;
	cin >> R;
	cout << 2*R*3.14159265 << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3780
#include<iostream>
using namespace std;
bool is(int p) {
	int k=2,sum=0;
	while(p!=1) {
		int s=0;
		while(p%k==0) {
			p/=k;
			s++;
		}
		k++;
		if(s!=0){
			if(s==1)
				return false;
			if(sum==0) {
				sum=s;
				continue;
			}
			else {
				if(sum!=s)
					return false;
			}
		}
	}
	return true;
}
int main() {
	int n;
	cin>>n;
	for(int i=n; i>=1; i--)
		if(is(i)) {
			cout<<i;
			return 0;
		}
}

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

  int a[4],b[2],s=0,blank,i,j;

  for(i = 0; i < 4; i++){

    scanf("%d",&a[i]);

  }

  for(j = 0; j < 3; j++){

    for(i = 0; i < 3; i++){

      if(a[i] < a[i+1]){

        blank=a[i];
        a[i]=a[i+1];
        a[i+1]=blank;

      }

    }

  }

  s += a[0]+a[1]+a[2];

  scanf("%d %d",&b[0],&b[1]);

  if(b[0] < b[1]){

    s += b[1];

  } else {

    s += b[0];

  }

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

  return 0;

}

Measured memory_bytes: 600
#include<bits/stdc++.h>                                                         
using namespace std;
int main()
{
  string S;
  cin >> S;
  int count=0;
  for(int i=0; i<S.size(); i++){
    for(int j=0; j<S.size(); j++){
      if(i!=j){
        if(S.at(i)==S.at(j)){
          count++;
        }
      }
    }
  }
  if(count==0)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}

Measured memory_bytes: 256
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int x, y;
    cin >> x;
    int z = 0;
    ll stool = 0;
    vector<int> thelist;
    for (int i = 0; i < x; i++) {
        cin >> y;
        thelist.push_back(y);
    }
    for (auto it = thelist.begin(); it != thelist.end(); it++) {
        if (*it >= z) {
            z = *it;
        }
        else {
            stool += z - *it;
        }
    }
    cout << stool;
}

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

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

    long long int sq = sqrt(n);

    long long int cnt = 1000000000000;
    for(int i = 1; i <= sq; ++i)
    {
        if(n % i == 0)
        {
            long long int j = n / i;
            if(j-1+i-1 < cnt)
            {
                cnt = j+i-2;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import itertools,math,bisect,pprint,sys
l = 10**9+7
n = input()
table = []
table2 = []
def prime_decomposition(n):
  i = 2
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
prime_decomposition(math.factorial(n))
pn = 0
while pn < len(table):
    t = table.count(table[pn])
    table2.append(t+1)
    pn += t
res = 1
for i in table2:
    res *= i
print res%l

Measured memory_bytes: 2816
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int d = sc.nextInt();
			if((n|d) == 0) break;
			ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
			int [] sum = new int[n];
			for(int i = 0 ; i< n; i++){
				int m = sc.nextInt();
				list.add(new ArrayList<Integer>());
				for(int j = 0; j < m; j++){
					int temp = sc.nextInt();
					sum[i] += temp;
					list.get(i).add(temp);
				}
			}
			
			while(true){
				int max = sum[0];
				int min = sum[0];
				int maxind = 0;
				for(int i = 1; i < n; i++){
					min = Math.min(min, sum[i]);
					if(max < sum[i]){
						max = sum[i];
						maxind = i;
					}
					else if(max == sum[i]) maxind = -1;
				}
				int secondmax = get2max(sum, max);
				
				boolean isremove = false;
				for(int i = 0; i < n; i++){
					if(list.get(i).size() == 0) continue;
					int now = sum[i] - list.get(i).get(list.get(i).size() - 1);
					int diff;
					if(i == maxind){
						diff = Math.max(now, secondmax) - Math.min(min, now);
					}
					else{
						diff = Math.max(now, max) - Math.min(min, now);
					}
					if(diff > d) continue;
					sum[i] = now;
					list.get(i).remove(list.get(i).size() - 1);
					isremove = true;
					break;
				}
				if(! isremove) break;
			}
			
			boolean ansflg = true;
			for(int i = 0; i < n; i++){
				if(list.get(i).size() != 0) ansflg = false;
			}
			System.out.println(ansflg ? "Yes" : "No");
		}
	}

	private int get2max(int[] sum, int max) {
		int res = 0;
		boolean flg = false;
		for(int i = 0; i < sum.length; i++){
			if(max == sum[i]){
				if(! flg){
					flg = true;
				}
				else{
					res = sum[i];
				}
			}
			else{
				res = Math.max(res, sum[i]);
			}
		}
		return res;
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
   IOS;
   int d,t,s;
   cin >> d >> t >> s;
   int can = t * s;
   if(can >= d)puts("Yes");
   else puts("No");
}


Measured memory_bytes: 3652
import itertools
while True:
    N, K = map(int, input().split())
    if N==K==0:
        break
    S = [int(input()) for _ in range(N)]
    
    Scum = [0] + list(itertools.accumulate(S))
    reg = -10**9
    for i in range(N-K+1):
        partial_sum = Scum[i+K] - Scum[i]
        reg = max(reg, partial_sum)
    print(reg)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = (int)(n)-1; i >=0; i--)
#define INF 1000000000000
using ll = long long;


int main(){
  int x;
  cin >> x;
  int y = 1;
  while(y*y<=x){
    y++;
  }
  if(x==2){
      cout<<2<<endl;
      return 0;
  }
  while(1){
    int flag = 0;
    for(int i = 2; i <= y; i++){
      if(x%i==0){
        flag = 1;
        x++;
        break;
      }
    }
    if(flag)continue;
    else{
      cout<<x<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <limits>
using ll = long long;
using ld = long double;
int MOD = 1e9 + 7;
using namespace std;
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main(){
    ll n;cin>>n;
    ll sum=0;
    ll reg_1=0;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }
    for(int i=0;i<n;i++){
        if(i%2==0){
            sum+=vec[i];
            if(sum<=0){
                reg_1+=(1-sum);
                sum=1;
            }
        }else{
            sum+=vec[i];
            if(sum>=0){
                reg_1+=(sum+1);
                sum=-1;
            }
        }
    }
    sum=0;
    ll reg_2=0;
    for(int i=0;i<n;i++){
        if(i%2==1){
            sum+=vec[i];
            if(sum<=0){
                reg_2+=(1-sum);
                sum=1;
            }
        }else{
            sum+=vec[i];
            if(sum>=0){
                reg_2+=(sum+1);
                sum=-1;
            }
        }
    }
    cout<<min(reg_1,reg_2)<<endl;
}

Measured memory_bytes: 640
import numpy as np

W, H, N = input().split()
commands = []
for i in range(int(N)):
  commands.append(input().split())
pic = np.zeros((int(W),int(H)))
for com in commands:
  x = int(com[0])
  y = int(com[1])
  a = int(com[2])
  if a==1:
    pic[:x,:] = 1
  if a==2:
    pic[x:,:] = 1
  if a==3:
    pic[:,:y] = 1
  if a==4:
    pic[:,y:] = 1

area = 0

for w in range(int(W)):
  for h in range(int(H)):
    if pic[w,h]==0:
      area += 1
      
print(area)

Measured memory_bytes: 26964
x = int(input())
lim = int(x**(1/5))+1

for a in range(10**6):
    mul = 1
    if a**5 < x:
        mul = -1
    
    b = ((a**5 - x)*mul)**(1/5)
    b*=mul
    b = int(b)
    if a**5 - b**5 == x:
        print(a, b)
        exit()

Measured memory_bytes: 9452
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator,
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display,
{
    for (i, e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

struct ContestPrinter {
    s: String,
}

impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter { s: String::new() }
    }

    fn print<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}", x).as_str());
    }

    fn println<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}

impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}

fn main() {
    let mut printer = ContestPrinter::new();
    let n = readl!(i32);
    let a = readl!(i32);
    if n%500 <= a {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vf80 xs(n), ys(n);
  rep(i, n) cin >> xs[i] >> ys[i];
  auto rad = [&](f80 x, f80 y) {
    f80 ret = 0;
    rep(i, n) {
      amax(ret, sqrt(pow(x - xs[i], 2) + pow(y - ys[i], 2)));
    }
    return ret;
  };
  auto ysearch = [&](f80 x) {
    f80 yl = -10000, yr = 10000;
    while (abs(yl - yr) >= 0.00000001) {
      auto yl_ = yl + (yr - yl) / 3 * 1;
      auto yr_ = yl + (yr - yl) / 3 * 2;
      if (rad(x, yl_) <= rad(x, yr_)) {
        yr = yr_;
      } else {
        yl = yl_;
      }
    }
    return yl;
  };
  f80 xl = -10000, xr = 10000;
  while (abs(xl - xr) >= 0.00000001) {
    auto xl_ = xl + (xr - xl) / 3 * 1;
    auto xr_ = xl + (xr - xl) / 3 * 2;
    if (rad(xl_, ysearch(xl_)) <= rad(xr_, ysearch(xr_))) {
      xr = xr_;
    } else {
      xl = xl_;
    }
  }
  cout << rad(xl, ysearch(xl)) << endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000ll;
int n,m;
string s[510];
void sol(int x, int y)
{
	for(int i = 1; i <= n; i++, cout << "\n")
		for(int j = 0; j < m; j++)
		{
			if(j == m - 1 - x) cout << ".";
			else if(i % 2 == y) cout << "#";
			else if(j == x) cout << "#";
			else if(s[i][j] == '#') cout << "#";
			else cout << ".";
		}
}
int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> s[i];
	sol(m - 1, 0);
	cout << "\n";
	sol(0, 1);
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  COMinit();
  ll n;
  cin>>n;
  ll cnt,cnt2;
  ll ja;
  v(ll) a(n+1);
  map<int,int> mp;
  rep(i,n+1){
    cin>>a[i];
    mp[a[i]]++;
    if(mp[a[i]]==2){
      ja=a[i];
      cnt2=i;
      break;
    }
  }
  rep(i,n+1){
    if(a[i]==ja){
      cnt=i;
      break;
    }
  }
  for(ll i=1;i<=n+1;i++){
    ll ans=COM(n+1,i)-COM(cnt+n-cnt2,i-1);
    if(ans<0) ans+=MOD;
    cout<<ans<<endl;
  }
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 20100, MAXK = 35;
const ll MOD = 1e9+7;
const ll INF = 1e17;
const ld PI = asin(1) * 2;

int n;
vi l;

int main()
{
    FAST_IO;

    cin >> n;
    FOR(i, 1, n) {int a; cin >> a; l.pb(a);}
    sort(l.begin(), l.end());

    ll ans = 0;
    FOR(i, 0, n-2) FOR(j, i+1, n-1) {
        int cMax = l[i]+l[j];
        auto it = lower_bound(l.begin(), l.end(), cMax);
        if (it == l.end()) ans += n-1-j;
        else ans += (it-l.begin()-1)-j;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string.h>
#include<set>
#define inf 0x3f3f3f3f
using namespace std;
char pre[110];
char str[110];
int main()
{
    scanf("%s",str);
    int cnt=0;
    for(int i=0;i<strlen(str);i++)
    {
        if(str[i]=='B')
            cnt--;
            else
                pre[cnt++]=str[i];
        if(cnt<0)
            cnt=0;
    }
    for(int i=0;i<cnt;i++)
        printf("%c",pre[i]);
    puts("");
}


Measured memory_bytes: 256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int S = int.Parse(strs[0]);
            int W = int.Parse(strs[1]);
            if (S>W)
            {

                Console.WriteLine("safe");
            }
            else
            {
                Console.WriteLine("unsafe");
            }
        }
    }
}


Measured memory_bytes: 27504
import java.util.Scanner;

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

        if (((a*b) % 2) == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 21716
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < s.length(); i++){
            int next = (alp.indexOf(String.valueOf(s.charAt(i))) + n) % alp.length();
            sb.append(String.valueOf(alp.charAt(next)));
        }
        System.out.println(sb.toString());
    }
}



Measured memory_bytes: 24276
#include<bits/stdc++.h>
#define ll long long int
#define fl(i,x,y) for( int i=x;i<y;i++)
#define w(t) while(t--)
#define vi vector<ll>
#define vvi vector< vi >
#define si set<ll>
#define msi multiset<ll>
#define si_d set<ll, greater<ll> >
#define mii map<ll,ll>
#define pb push_back
#define msi_it  multiset<ll> :: iterator
#define si_it set<ll> :: iterator
#define sort1(v) sort(v.begin(),v.end());
#define F first
#define S second
using namespace std;
#define N 1000000007
#define mod 15000000000031
int main()
{
	string s;cin>>s;
	if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=110;
int n,k;
char c[MAXN],c1[MAXN];
ll ans;
ll calc (char* c,int len) {
	ll res=0,cnt=1;
	for (int i=2;i<=len;i++) {
		if (c[i]!=c[i-1]) {
			res+=cnt/2;
			cnt=0;
		}
		cnt++;
	}
	res+=cnt/2;
	return res;
}
int main () {
	scanf("%s%d",c+1,&k);
	n=strlen(c+1);
	if (c[1]!=c[n]) {
		printf("%lld\n",1ll*calc(c,n)*k);
		return 0;
	}
	int flag=0;
	for (int i=2;i<=n;i++) {if (c[i]!=c[i-1]) {flag=i;break;}}
	if (!flag) {
		printf("%lld\n",1ll*n*k/2);
		return 0;
	} else {
		for (int i=flag;i<=n;i++) {
			c1[i-flag+1]=c[i];
		}
		for (int i=1;i<=flag-1;i++) {
			c1[i+n-flag+1]=c[i];
		}
		printf("%lld\n",1ll*(k-1)*calc(c1,n)+(flag-1)/2+calc(c1,n-flag+1));
	}
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::string S){
    if(S.substr(0, N/2) == S.substr(N/2, N)){
        cout<<YES<<endl;
    }else{
        cout<<NO<<endl;
    }
}

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


Measured memory_bytes: 256
//D
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };
//残りn枚での各プレイヤーの最善スコアを格納
ll xBest[2010] = { 0 }, yBest[2010] = {0};
ll n, z, w;
ll a[2010];
signed main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	cin >> n >> z >> w;
	ll kari;
	REP(i, n) {
		cin >> a[i+1];
	}

	//xBestは小さな値で初期化、ybestは巨大な値で初期化しておく
	//ybestを巨大な値で初期化
	REP(i, 2010) {
		yBest[i] = LINF;
	}

	//n=1の時だけ特別扱い
	if (n == 1) {
		cout << abs(a[1] - w)<<endl;
		return 0;
	}

	//初手で全部取る型破りなケースを計算しておく（コーナーケース）
	xBest[n] = abs(a[n] - w);

	//残り1枚での最善手
	xBest[1] = abs(a[n - 1] - a[n]);
	yBest[1] = abs(a[n - 1] - a[n]);


	//残り2枚での最善手から、段々に残りN枚での最善手まで求める
	//残りi枚での最善手
	for (int i = 2; i <= n; i++) {

		//残りi-1枚でのyの最善手と i-2と... ... 残り1枚でのyの最善手のもっとも大きいもの
		for (int j = i - 1; j > 0; j--) {
			xBest[i] = max(yBest[j], xBest[i]);
		}
		//最後に全部とって、yの手番が回らないケースを考える。
		//xは最後のn枚目で、yはi-1枚目のカードを持つ。
		xBest[i] = max(abs(a[n]-a[i-1]), xBest[i]);

		//続いてyの最善手を計算

		//残りi-1枚でのxの最善手と i-2と... ... 残り1枚でのxの最善手のもっとも小さいもの
		for (int j = i - 1; j > 0; j--) {
			yBest[i] = min(xBest[j], yBest[i]);
		}
		//最後に全部とって、xの手番が回らないケースを考える。
		//yは最後のn枚目で、xはi-1枚目のカードを持つ。
		yBest[i] = min(abs(a[n] - a[i - 1]), yBest[i]);
	}

	//最後にxが残りn枚のときの最大スコアを出力
	cout << xBest[n] << endl;


	return 0;
}

Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N, M, X;
    scan(N, M, X);
    auto CA = new long[][](N);
    foreach (i; 0 .. N)
        CA[i] = aryread();
    long ans = long.max;
    foreach (s; 1 .. (1 << N))
    {
        long cost;
        auto m = new long[](M);
        foreach (i; 0 .. N)
            if (s & (1 << i))
            {
                cost += CA[i][0];
                m[] += CA[i][1 .. $][];
            }
        if (m.all!(x => X <= x))
            ans = ans.min(cost);
    }
    writeln(ans == long.max ? -1 : ans);
}


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

int a[10];

int main(){
  int n, k; cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int c; cin >> c;
    a[c]++;
  }
  for (int i = n; i < n*100; i++) {
    int c = i;
    while (true) {
      if (a[c%10] != 0) break;
      else c /= 10;
      if (c == 0) {
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256