akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
const ll mod = 1e9+7;
#define INFL 0x3f3f3f3f3f3f3f3fLL
 
//-------------------------<MATH>-------------------------------------------------------//
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;
ll c = (a * b)%mod;
//cout << a << " " << b << endl;
return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(5e5 + 5)] , inv_fac[(int)(5e5 + 5)];
void precomp_factorial(int M){fac[0] = 1;for(int i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(int i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int lo[(int)(1e3 + 6)];
void sieve(int M){for(int i = 2 ; i < M ; i++){ if(lo[i]) continue; for(int j = i ; j < M ; j += i)lo[j] = i;}}
int max_expo_prime_n_fac(ll N , int prime){int ress = 0;while(N){ress += (N/prime);N /= prime;}return ress;}
//-------------------------</MATH>-------------------------------------------------------//
 
//-------------------------<STRING>-------------------------------------------------------//
string get_prefix(string x , int MAX){return x.substr(0 , min((int)x.size() , MAX));}
string get_suffix(string x,int MAX){int dn=1;for(int i=x.size()-1;i>=0;i--){if(dn==MAX)return x.substr(i);dn++;}return x;}
string convert_to_binary(int x,int len) {string ans=""; while(x){if(x&1){ans='1'+ans;}
    else{ans ='0'+ans;}x/=2;}int k = ans.size();while(k < len){ans = '0' + ans;k++;}return ans;}
//-------------------------</STRING>-------------------------------------------------------//
 
ull llrand() {ull r = 0;for(int i = 0; i < 5; ++i){r = (r << 15)|(rand() & 0x7FFF);}return r & 0xFFFFFFFFFFFFFFFFULL;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
 
 
int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll val1 = min(k,x/d);
    x -= val1*d;
    k -= val1;
    if(k%2) x = d-x;
    cout << x;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  bool t = true;
  while(1) {
    if (t) {
      c-=b;
    } else {
      a-=d;
    }
    if (a <= 0 || c <= 0) break;
    t = !t;
  }
  COUT(t ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#define ll long long
using namespace std;
int main(){
    string s;
    ll n;
    string ac="AC";
    ll cac=0;
    string wa="WA";
    ll cwa=0;
    string tle="TLE";
    ll ctle=0;
    string re="RE";
    ll cre=0;
    cin>>n;
    for (ll i = 0; i <n ; ++i) {
        cin>>s;
        if(s==ac){
            cac++;
        }
        else if(s==wa){
            cwa++;
        }
        else if(s==tle){
            ctle++;
        }
        else if (s==re){
            cre++;
        }
    }
    cout<<ac<<" x "<<cac<<endl;
    cout<<wa<<" x "<<cwa<<endl;
    cout<<tle<<" x "<<ctle<<endl;
    cout<<re<<" x "<<cre<<endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("YES");
	else say("NO");
}

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	yn(a.back() == b.front() && b.back() == c.front());
}

Measured memory_bytes: 256
import sys

infty = 10**10

def merge(A,left,mid,right):

	n1 = mid -left
	n2 = right - mid

	L = [0] * n1
	R = [0] * n2

	for i in range(n1):
		L[i] = A[left+i]
	for i in range(n2):
		R[i] = A[mid+i]

	L.append(infty)
	R.append(infty)

	i = 0
	j = 0
	cnt = 0

	for k in range(left,right):


		if L[i] <= R[j]:
			A[k] = L[i]
			i = i + 1
		else:
			cnt += len(L) - 1 - i
			A[k] = R[j]
			j = j + 1
		

	return cnt

def mergeSort(A,left,right):

	cnt = 0

	if left+1 < right:

		mid = (left + right) // 2
		cnt += mergeSort(A,left,mid)
		cnt += mergeSort(A,mid,right)
		cnt += merge(A,left,mid,right)

	return cnt

def test():

	n = int(sys.stdin.readline())
	S = list(map(int,sys.stdin.readline().split()))

	result = mergeSort(S,0,n)
	
	print(result)


if __name__ == "__main__":
	test()


Measured memory_bytes: 28120
#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

int main() 
{
	vector<int> nums;
	int n;

	cin >> n;

	nums.resize(n);

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

	int numMax = 0;
	int cons = 0;

	for (int i = 0; i<n-1;)
	{
		int j = i;
		for (; j<n-1; ++j)
		{
			if (nums[j] >= nums[j + 1])
			{
				cons++;
			}
			else 
			{ 
				break;
			}
		}

		if (cons > numMax)
		{
			numMax = cons;
		}
		cons = 0;

		i = j + 1;
	}

	cout << numMax << endl;

	return 0;
}


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

int main() {
 
  char a, b, c, d;
  cin >> a >> b >> c >> d;
    
  if ((a == b)&&(b == c) ){
   cout << "Yes" << endl; 
  }
  else if ((c == b)&&(b == d) ){
   cout << "Yes" << endl; 
  }
  else {
    cout << "No" << endl; 
  }
  // ここにプログラムを追記
}


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

int main() {
  while (true) {
    int n, m;
    cin >> n;
    if (n == 0) {
      break;
    }
    vector<char> before(n), after(n);
    for (int i = 0; i < n; ++i) {
      cin >> before[i] >> after[i];
    }
    cin >> m;
    vector<char> data(m);
    for (int j = 0; j < m; ++j) {
      cin >> data[j];
    }

    for (int j = 0; j < m; ++j) {
      for (int i = 0; i < n; ++i) {
        if (data[j] == before[i]) {
          data[j] = after[i];
          break;
        }
      }
    }

    for (int j = 0; j < m; ++j) {
      cout << data[j];
    }
    cout << endl;
  }
}


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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        string s;
        cin >> s;

        if (s == "ABC") puts("ARC");
        else if (s == "ARC") puts("ABC");
    }
}


Measured memory_bytes: 3572
N,K=map(int,input().split())
A=list(map(int,input().split()))
A=[i-1 for i in A]
c=A[A[0]]
 
s=set()
s.add(0)
s.add(A[0])
I=[]#訪れた島を記憶
I.append(0)
I.append(A[0])

while True:
  if c in s:
    break
  s.add(c)
  I.append(c)
  c=A[c]

a=I.index(c)
if K>=a:
  K-=a
else:
  ans=0
  for i in range(K):
    ans=A[ans]
  print(ans+1)
  exit()

ans=0
for i in range(a):
  ans=A[ans]
#ansが今いる島
mod=len(s)-a
K%=mod

if K==0:
  print(ans+1)
  exit()
#ans=A[0]
#for i in range(a):
#  ans=A[ans]

for i in range(K):
  ans=A[ans]
print(ans+1)

Measured memory_bytes: 32304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

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

  	int a, b, c;cin>>a>>b>>c;
  	cout<<c<<" "<<a<<" "<<b<<endl;
	return 0;
}



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

using namespace std;

typedef long long  ll;

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

    int n;
    string op;

    // (ld,rd) = 0, (lu,rd) = 1, (lu,ru) = 2, (ld,ru) = 3
    while (cin >> n, n) {
        int cnt = 0, state = 0;
        bool isDown = true;

        for (int i = 0; i < n; ++i) {
            cin >> op;
            if (op == "lu") {
                if (state == 0)
                    state = 1;
                else if (state == 3) {
                    state = 2;
                    if (isDown) {
                        ++cnt;
                        isDown = false;
                    }
                }
            }
            else if (op == "ld") {
                if (state == 1) {
                    state = 0;
                    if (!isDown) {
                        ++cnt;
                        isDown = true;
                    }
                }
                else if (state == 2)
                    state = 3;
            }
            else if (op == "ru") {
                if (state == 0)
                    state = 3;
                else if (state == 1) {
                    state = 2;
                    if (isDown) {
                        ++cnt;
                        isDown = false;
                    }
                }
            }
            else if (op == "rd") {
                if (state == 2)
                    state = 1; 
                else if (state == 3) {
                    state = 0;
                    if (!isDown) {
                        ++cnt;
                        isDown = true;
                    }
                }
            }
        }
        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    int ans = N;
    for (int i = 1; i < sqrt(N) + 100 && i < N; i++) {
        if (N % i == 0) {
            ans = min(ans, (i - 1) + ((N / i) - 1));
        }
    }
    cout << ans << endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>
using namespace std;

set<string> S;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    string tmp;
    for(int i = 0; i < N; i++){
        cin >> tmp;
        S.insert(tmp);
    }
    cout << S.size() << endl;
}


Measured memory_bytes: 19256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> job(m);
    priority_queue<int> q;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        if(a > m) continue;
        job[m-a].push_back(b); //何日目までにやる必要？
    }

    ll ans = 0;
    for(int i = m-1; i >= 0; i--){
        for(int b : job[i]){
            q.push(b);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5632
import sys

s = input()

for i in range(len(s)):
    if i % 2 == 1 and  s[i] == 'R':
        print("No")
        sys.exit()
    elif i % 2 == 0 and s[i] == 'L':
        print("No")
        sys.exit()
    

print("Yes")

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

typedef long long ll;
typedef pair<int, int> P;
const int dx[3] = {0, 1, 2};
const int dy[3] = {0, 1, 2};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int h, w, n;
    cin >> h >> w >> n;
    map<P, ll> m;
    for(int i = 0; i < n; ++i){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        
        for(int j = 0; j < 3; ++j){
            for(int k = 0; k < 3; ++k){
                int x = a - dx[j], y = b - dy[k];
                if(x < 0 || x >= h - 2 || y < 0 || y >= w - 2)      continue;
                
                ++m[P(x, y)];
            }
        }
    }
    
    vector<ll> ans(10, 0);
    ll sub = 0;
    for(auto it = m.begin(); it != m.end(); ++it){
        ++ans[it->second];
        ++sub;
    }
    ans[0] = (ll)(h - 2) * (w - 2) - sub;
    
    for(int i = 0; i < 10; ++i){
        cout << ans[i] << "\n";
    }
}

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

public class Program
{
    public static void Main()
    {
        var s = Console.ReadLine();

        var minimum = int.MaxValue;
        for (char c = 'a'; c <= 'z'; ++c)
        {
            var indices = s
                .Select((x, i) => new { x, i })
                .Where(x => x.x == c)
                .Select(x => x.i)
                .ToArray();
            var interval = indices.Concat(new[] { s.Length })
                .Zip(new[] { -1 }.Concat(indices), (x, y) => x - y)
                .Concat(new[] { 0 })
                .Max();
            minimum = Math.Min(minimum, interval);
        }
        Console.WriteLine(minimum - 1);
    }
}


Measured memory_bytes: 13524
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main(){
	string s;
	while(!(s=readln).length==0){
		s=chomp(s);
		for(int i=cast(int)s.length-1; i>=0; i--)	write(s[i]);
		writeln();
	}
}

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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];

    sort(ALL(a));

    rep(i, n-1){
        if(a[i] == a[i+1]){
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


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

int main() {
    int N, K; cin >> N >> K;
    int r = min(N, K);
    vector<int> V(N);
    for (int i = 0; i < N; i++) {
        cin >> V[i];
        V[i] *= -1;
    }

    int out = 0;
    for (int i = 0; i <= r; i++) {
        vector<int> W;
        for (int j = 0; j < i; j++) {
            W.push_back(V[j]);
        }
        for (int j = 0; j <= r - i; j++) {
            vector<int> X = W;
            for (int k = 0; k < j; k++) X.push_back(V[N - 1 - k]);
            sort(X.begin(), X.end());

            for (int k = 0; k < K - i - j; k++) {
                if (X.empty() || X[X.size() - 1] <= 0) break;
                X.pop_back();
            }

            out = max(out, -accumulate(X.begin(), X.end(), 0));
        }
    }

    cout << out << endl;

    return 0;
}

// #include <vector>
// #include <iostream>
// #include <string>
// #include <algorithm>
// #include <functional>
// #include <cmath>

// #define rep(i, n) for (int i = 0; i < (n); i++)
// using namespace std;
// typedef long long ll;
// const int INF = 1e9;

// int main(){

//     int n,k;
//     vector<int> v(n);
//     cin >> n >> k;
//     for (int i = 0; i < n; i++)
//     {
//         cin >> v[i];
//     }
//     int R = min(n,k);

//     int ans = 0;
//     for (int i = R; i >= 0; i--)
//     {
//         vector<int> s(n);
//         for (int j = 0; j <= R; j++)
//         {
//             for (int k =0; k<n;k++){
//                 s[k] = 0;
//             }
//             int sum =0;
//             int l= j;
//             int r = i - j;
//             int d = R - i;

//             for(int k = 0; k<l;k++){
//                 // s.push_back(v[k]);
//                 s[k] = v[k]
//             }
//             for (int k = 0; k < r; k++)
//             {
//                 // cout << v[n-k-1] << ' ';
//                 s.push_back(v[n-k-1]);
//             }
//             sort(s.begin(), s.begin()+(l+r));
//             for (int k = d; k < l+r; k++)
//             {
//                 if(s[k]!=0){
//                     sum += s[k];
//             }
//             // cout << "l=" << l << " r=" << r << " d=" << d << sendl;
//             if (ans < sum){
//                 ans = sum;
//             }
//         }
//     }
//     std::cout << ans << endl;
//     return 0;
// }

Measured memory_bytes: 256
n = gets.to_i
a = gets.to_i
t = gets.split.map(&:to_i)
ans = 0
for num in 0..n-1 do
  if t[num] <= a/2
    ans += t[num] * 2
  else
    ans += (a-t[num]) * 2
  end
end
p ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int N, A[10101];
//---------------------------------------------------------------------------------------------------
void _main() {
	while (cin >> N) {
		if (N == 0) return;
		rep(i, 0, N) cin >> A[i];

		int sm = 0;
		rep(i, 0, N) sm += A[i];

		int ans = 0;
		rep(i, 0, N) if (A[i] * N <= sm) ans++;
		printf("%d\n", ans);
	}
}




Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int a, b;
    cin >> a >> b;
    if(a > 9 || b > 9){
        cout << -1;
    }
    else {
        cout << a*b;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')

    @cc.export('is_ok', '(u8[:],u8[:],u8,u8)')
    def is_ok(A, F, x, k):
        tmp = 0
        for a, f in zip(A, F):
            y = a * f
            if y > x:
                tmp += a - x // f
        return tmp <= k

    cc.compile()
    exit(0)

from my_module import is_ok
n, k = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))

A = np.sort(A)
F = np.sort(F)[::-1]

ok = 10 ** 12
ng = -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_ok(A, F, mid, k):
        ok = mid
    else:
        ng = mid

print(ok)


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

int ans_MP=2147483647;
vector<int>l;
int A,B,C;
int N;

void calc(vector<int>v){
  int MP=0;
  int At=0;
  int Bt=0;
  int Ct=0;
  int A_check=0;
  int B_check=0;
  int C_check=0;
  int connect=0;
  for(int i=0;i<N;i++){
    if(v[i]==0){
      At=At+l[i];
      if(A_check!=0)connect += 1;
      A_check = A_check +1;
    }
    else if(v[i]==1){
      Bt=Bt+l[i];
      if(B_check!=0)connect += 1;
      B_check = B_check +1;
    }
    else if(v[i]==2){
      Ct=Ct+l[i];
      if(C_check!=0)connect += 1;
      C_check = C_check +1;
    }
    else{}
  }
  if(A_check==0 || B_check == 0 || C_check == 0)return;
  MP = abs(A-At)+abs(B-Bt)+abs(C-Ct)+connect*10;
  if(MP<ans_MP)ans_MP=MP;
  return;
  // for(int i=0;i<N;i++){
  //   cout << v[i] << l[i] << endl;
  // }
  // cout << A << At<< connect << endl;
  // cout << MP << endl;
}

void dfs(int depth,vector<int>v){
  if(depth==N){
    calc(v);
    return;
  }
  for(int i=0;i<4;i++){
    //v.push_back(-1);
    v[depth]=i;
    dfs(depth+1,v);
  }
  return;
}

int main(){
  cin >> N >> A >> B >> C;
  for(int i=0;i<N;i++){
    l.push_back(-1);
    cin >> l[i];
  }
  vector<int>v;
  for(int i=0;i<N;i++){
    v.push_back(-1);
  }
  dfs(0,v);
  cout << ans_MP << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int a, b;
	char op;
	cin >> a >> op >> b;
	if(op == '+') cout << a + b ;
	else cout << a - b;
}


Measured memory_bytes: 256
L,N=gets.split.map &:to_i
X=$<.map &:to_i
f=->x{r=0;(0...N).map{|i|r+=x[N-1-i]-(x[N-1-i/2]-x[N-1-i])+(L-x[N-(i+1)/2])}}
p (f[X+[L]]+f[X.reverse.map{|e|L-e}+[L]]).max

Measured memory_bytes: 15996
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
#include <random>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(a) cerr<<(a)<<endl;
#define dump(a) cerr<<#a <<' '<< a <<endl;
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
typedef pair<int,int>PI; typedef vector<int> VI;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,e,t;
    cin >> n >> e >> t;
    VLL dp(n+1,LINF),x(n+1);
    REP(i,n) cin >> x[i+1];
    dp[0]=0;
    dp[1]=t;
    int l=0;
    FOR(i,2,n+1){
        for(int j= l; j<i ; ++j){
            if(dp[i]>dp[j]+max((LL)t,(x[i]-x[j+1])*2)){
                dp[i]=min(dp[i],dp[j]+max((LL)t,(x[i]-x[j+1])*2));
                l=j;
            }
            if(t>(x[i]-x[j+1])*2)break;
        }
    }
    cout << dp[n]+e<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N; cin >> N;
    string S,T; cin >> S >> T;
    int ans=0;

    REP(i,N+1) {
        bool ok = true;
        REP(j,N-i) {
            if (S[i+j] != T[j]) {
                ok = false;
                break;
            }
        }
        //cerr << i << endl;
        if (ok) {
            ans = N+i;
            break;
        }
    }

    cout << ans << '\n';

    return 0;
}

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

long long ans = 0;
long long x;

long long patties[60];
long long total[60];
long long buns[60];

void solve(int n) {
	if( x == 0) return;
	
	if (n == 0) {
		ans++;
		x--;
	} else {
		
		if (x >= total[n]) {
			x -= total[n];
			ans += patties[n];
			return;
		}
		
		x--; // me como un pan
		
		if (x > 0) solve(n-1);
		
		if (x > 0) {
			x--;
			ans++;
		}
		
		if (x > 0) solve(n-1);
		
		if (x > 0) x--; // me como el otro pan
	}
}
int main() {
	// your code goes here
	int n; cin >> n >> x;
	
	total[0] = 1;
	patties[0] = 1;
	
	for(int i = 1; i <= n; i++) {
		buns[i] = 2*buns[i-1] + 2;
		patties[i] = 2*patties[i-1] + 1;
		total[i] = buns[i] + patties[i];
	}

	solve(n);
	cout << ans << endl;
	return 0;
}

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

int main() {
    int N, K;
    while (cin >> N >> K) {
        string S; cin >> S;
        vector<int> n_segment(N);
        bool in_segment = (S[0] == '0');
        n_segment[0] = (S[0] == '0');
        for (int i = 1; i < N; ++i) {
            if (S[i] == '0') {
                n_segment[i] = n_segment[i-1] + (in_segment ? 0 : 1);
                in_segment = true;
            } else {
                n_segment[i] = n_segment[i-1];
                in_segment = false;
            }
        }
        int answer = 0;
        for (int i = 0; i < N; ++i) {
            int limit = K + n_segment[i] + (S[i] == '0' ? -1 : 0);
            auto it = upper_bound(n_segment.begin() + i, n_segment.end(), limit);
            int len = it - (n_segment.begin() + i);
            answer = max(answer, len);
        }
        cout << answer << endl;
    }
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define modd 998244353
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
lld n,m;
lld arr[300000];
lld brr[300000];
ar<lld,2> lim[300000];
lld pref[300000];
map<lld,lld> ma;
map<lld,lld> mb;
int main()
{
     ios;
     lld TESTS,q,a,s,b,l,r,c,k,p,h,w,d,x,y,z,xs,ys,t;
     TESTS=1;
     //cin>>TESTS;
     while(TESTS--)
     {
         cin>>x;
         cin>>k;
         lld prev=0;
         lld sum=0;
         rep(i,0,k-1){cin>>arr[i];brr[i]=arr[i]-prev;prev=arr[i];if (i%2==0)brr[i]*=-1;}
         ar<lld,2> maxi={(lld)1e15,0};
         ar<lld,2> mini={(lld)-1e15,0};
         /*pref[0]=brr[0];
         rep(i,0,k-1){
            if (i>0)pref[i]=pref[i-1]+brr[i];
            if (i%2){
                lld cur=x-pref[i];
                if (cur<=maxi){
                    maxi=cur;
                    lim[i][0]=cur;
                    lim[i][1]=x;
                    ma[maxi]=pref[i];
                }
                else {
                    lim[i][0]=maxi;
                    lim[i][1]=pref[i]-ma[maxi];
                }
            }
            else {
                ;
            }
         } */
         cin>>q;
         lld cur=0;
         lld val=0;prev=0;
         while(q--){
            cin>>t>>a;
            lld ind=upper_bound(arr,arr+k,t)-arr;
            ind--;
            prev=max(prev,mini[0]);
            prev=min(prev,maxi[0]);
            if (a<=maxi[0]&&a>=mini[0]){
                val+=a-prev;
                prev=a;
            }
            else {
                if (a>maxi[0]&&prev<=maxi[0]) {val+=maxi[0]-prev;prev=maxi[0];}
                else if (a<mini[0]&&prev>=mini[0]) {val+=mini[0]-prev;prev=mini[0];}
            }
                if (val<=0)mini=max(mini,{a-val,0});
                if (val>=x)maxi=min(maxi,{a-val+x,0});
                val=max(val,0ll);
                val=min(val,x);
                rep(i,cur,ind){
                    sum+=brr[i];
                    val+=brr[i];
                    if (val<=0)mini=max(mini,{a-val,0});
                    if (val>=x)maxi=min(maxi,{a-val+x,0});
                    mini[0]=max(mini[0],-sum);
                    maxi[0]=min(maxi[0],x-sum);
                    val=max(val,0ll);
                    val=min(val,x);
                }
                lld vall=val;
                if (ind%2==0){
                    vall+=t-arr[ind];
                }
                else vall+=arr[ind]-t;
                //if (vall<=0)mini=max(mini,{a-vall,0});
                //if (vall>=x)maxi=min(maxi,{a-vall+x,0});
                vall=max(vall,0ll);
                vall=min(vall,x);
                cur=ind+1;
                cout<<vall<<"\n";
         }
     }
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X = 0;
  cin >> X;
  if ((400 <= X) && (X < 600)){
    cout << "8" << endl;
  }
  if (600 <= X && X < 800){
    cout << "7" << endl;
  }
  if (800 <= X && X < 1000){
    cout << "6" << endl;
  }
  if (1000 <= X && X < 1200){
    cout << "5" << endl;
  }
  if (1200 <= X && X < 1400){
    cout << "4" << endl;
  }
  if (1400 <= X && X < 1600){
    cout << "3" << endl;
  }
  if (1600 <= X && X < 1800){
    cout << "2" << endl;
  }
  if (1800 <= X && X < 2000){
    cout << "1" << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

struct P {
  int v;
  int d;
  int s;
  bool operator<(const P& rhs) const {
    return d > rhs.d;
  }
};

vector<int> g[100000];
int dist[100000][3];

int main() {
  int n, m;
  while(input(n,m)) {
    REP(i,n) g[i].clear();
    REP(i,m) {
      int a,b;
      input(a,b);
      a--;b--;
      g[a].push_back(b);
    }
    int s, t;
    input(s,t);
    s--;t--;
    memset(dist,0x3f,sizeof(dist));
    priority_queue<P> Q;
    Q.push(P{s,0,0});
    dist[s][0] = 0;
    while(!Q.empty()) {
      auto p = Q.top(); Q.pop();
      auto d = dist[p.v][p.s];
      if (d > p.d) continue;
      int v = p.v;
      int nxtS = (p.s + 1) % 3;
      FOR(it, g[v]) {
        int u = *it;
        int dd = d + (nxtS == 0);
        if (dist[u][nxtS] > dd) {
          Q.push(P{u,dd,nxtS});
          dist[u][nxtS] = dd;
        }
      }
      // cout << p.v << " " << d  << endl;
    }
    if (dist[t][0] == INF) {
      cout << -1 << endl;
    } else {
      cout << dist[t][0] << endl;
    }
  }
}


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

int main() {
    long long l, r;
    long long minv = 1e9;
    cin >> l >> r;
    long long i = l, j = r;
    
    for (i = l; i < j; i++)
    {
        for (j = r; j > i; j--)
        {
            minv = min(minv, (i*j) % 2019);
            if (minv == 0) {
                cout << minv << endl;
                return 0;
            }
        }
        j = r;
    }
    
    cout << minv << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

    	int h = sc.nextInt();
    	int w = sc.nextInt();
    	sc.nextLine();

    	char[][] grid = new char[h][w];
    	for(int i = 0; i < h; i++) {
    		String tmp = sc.nextLine();
    		for(int j = 0; j < w; j++) {
    			grid[i][j] = tmp.charAt(j);
    		}
    	}
    	// System.out.println(Arrays.deepToString(grid));

    	int[] imove = {0, -1};
    	int[] jmove = {-1, 0};

    	int MOD = 1_000_000_007;
    	int[][] dp = new int[h][w];
    	dp[0][0] = 1;
    	for(int i = 0; i < h; i++) {
    		for(int j = 0; j < w; j++) {
    			if(grid[i][j] == '#')
    				continue;
    			for(int k = 0; k < 2; k++) {
    				int new_i = i + imove[k];
    				int new_j = j + jmove[k];
    				if(new_i >= 0 && new_j >= 0 && new_i < h && new_j < w) {
    					dp[i][j] += dp[new_i][new_j] % MOD;
    				}
    			}
    			dp[i][j] %= MOD;
    		}
    	}
    	// System.out.println(Arrays.deepToString(dp));

    	System.out.println(dp[h-1][w-1]);
    }
}

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

int main(){
  int n, ans = 0;
  char s[100];
  
  cin >> n;
  
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  
  if(n % 2 != 0){
    cout << "No" << endl;
  }
  else{
    for(int i = 0; i < n/2; i++){
      if(s[i] == s[n/2 +i]){
        continue;
      }
      else{
        ans++;
      }
    }
    if(ans>0){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
import re

for line in stdin:
    stack = []
    for s in line.split():
        if re.match('[-+]?\d+', s):
            stack.append(float(s))
        elif s == '+':
            n = stack.pop()
            stack[-1] += n
        elif s == '-':
            n = stack.pop()
            stack[-1] -= n
        elif s == '*':
            n = stack.pop()
            stack[-1] *= n
        elif s == '/':
            n = stack.pop()
            stack[-1] /= n
    print('{:.6f}'.format(stack[-1]))

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

using namespace std;

int solve(vector<int> h) {
  h.push_back(0);
  int n = h.size(), ans = 0, pos;
  stack<int> s;
  for (int i = 0; i < n; i++) {
    pos = i;
    while (s.size() && h[s.top()] > h[i]) { 
      pos = s.top(); s.pop();
      ans = max(ans, h[pos] * (i - pos + 1));
      h[pos] = h[i];
    }
    s.push(pos);
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  vector<string> grid(n);
  for (int i = 0; i < n; i++) {
    cin >> grid[i];
  }

  auto check = [&](int i, int j) {
    int cnt = 0;
    cnt += (grid[i][j] == '#');
    cnt += (grid[i][j + 1] == '#');
    cnt += (grid[i + 1][j] == '#');
    cnt += (grid[i + 1][j + 1] == '#');
    return cnt % 2 == 0;
  };

  vector<vector<int>> mat(n, vector<int>(m - 1, 1));
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      if (check(i, j)) {
        mat[i + 1][j] = mat[i][j] + 1;
      }
    }
  }

  int ans = max(n, m);
  for (int i = 1; i < n; i++) {
    ans = max(ans, solve(mat[i]));
  }
  cout << ans << '\n';
  
  return 0;
}


Measured memory_bytes: 23324
N, M = map(int, input().split())
AB = []
for i in range(N):
    AB.append([int(i) for i in input().split()])
AB.sort()
ans = 0
for ab in AB:
    if ab[1] >= M:
        ans += ab[0] * M
        print(ans)
        exit()
    else:
        ans += ab[0] * ab[1]
        M -= ab[1]


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

long long com(int n, int r) {
    if(n==1 || n==0)
    return 0;
    if(r > n - r) r = n - r; 
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}


int main(){
   int n,m;
   cin>>n>>m;
   int com1,com2;
  
   com1=com(n,2);
   com2=com(m,2);
   
  cout<<com1+com2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
	vi a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K; cin >> K;
	cout << a.at(K - 1) << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String out = "";
    while (scanner.hasNext()) {
      String line = scanner.nextLine();
      String[] works = line.split(",");
      double w = Double.parseDouble(works[1]);
      double h = Double.parseDouble(works[2]);
      double bmi = w / (h * h);
      if (bmi >= 25) {
        out += works[0] + "\n";
      }
    }
    System.out.print(out);
  }
}

Measured memory_bytes: 17128
#include <iostream>
using namespace std;
int main() {
    int a,b,c,s;
    cin >> a >> b >> c;
    s = 3;
    if (a == b ){
        s--;
    }
    if (b == c){
        s--;
    }
    if (a == c){
        s--;
    }
    if (s == 0){
        s++;
    }
    cout << s << endl;
    return 0;
}

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

const int nIMPOS = -1;
struct StDist
{
  int m_nDist;
  int m_nDmy;

  StDist(int nDist) : m_nDist(nDist), m_nDmy(0)
  { }
};

void fnInput(vector<vector<int>>& rvvnAdjcy, vector<StDist>& rvoDist)
{
  int nxSiz;
  cin >> nxSiz;

  rvvnAdjcy.resize(nxSiz + 1, vector<int>(nxSiz + 1, 0));
  for (int i = 0; i < nxSiz; ++i)
  {
    int nx, nySiz;
    cin >> nx >> nySiz;
    for (int j = 0; j < nySiz; ++j)
    {
      int ny;
      cin >> ny;
      rvvnAdjcy[nx][ny] = 1;
    }
  }
  StDist oDist(nIMPOS);
  rvoDist.resize(nxSiz + 1, oDist);
}

void fnBreadthFirstSearch(const vector<vector<int>>& cnrvvnAdjcy, 
                          queue<int>& rqnBFSrch, vector<StDist>& rvoDist)
{
  while (rqnBFSrch.size())
  {
    int nx = rqnBFSrch.front(); rqnBFSrch.pop();
    for (int ny = 1; ny < cnrvvnAdjcy[nx].size(); ++ny)
    {
      if (!cnrvvnAdjcy[nx][ny])          continue;
      if (rvoDist[ny].m_nDist != nIMPOS) continue; 

      int nDist = rvoDist[nx].m_nDist + 1;
      rvoDist[ny].m_nDist = nDist;
      rqnBFSrch.push(ny);
    }
  }
}

void fnResult(const vector<StDist>& cnrvoDist)
{
  for (int i = 1; i < cnrvoDist.size(); ++i)
    cout << i <<  " " << cnrvoDist[i].m_nDist << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> vvnAdjcy;
  queue<int> qnBFSrch;
  vector<StDist> voDist;

  fnInput(vvnAdjcy, voDist);

  voDist[1].m_nDist = 0;
  qnBFSrch.push(1);
  fnBreadthFirstSearch(vvnAdjcy, qnBFSrch, voDist);
  fnResult(voDist);

  return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


int main(){
  for (int i = 0; i < 3; i++){
    string S; cin >> S;
    char ans = S[0] - 'a' + 'A';
    cout << ans;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
min sec
"""
# とりあえず愚直に書いてみる。→TLEした。
# Bは0、Wは1にする。→必要ない。
# ひっくり返す順番は関係なさそうなので考えない。
"""
BWのn個の連続（長さ2n）は、n+(n-1)+(n-2)+...+1 = n(n+1)//2回の操作で、
n個のBとn個のWの連続に置き換えられる。
"""
"""
ようするにバブルソートをしている。
k番目のWが文字列Sのi文字目ならば、
その移動距離は、(i-k)回になる。
これを足せばよい。
"""

def main():
    S = input()
    N = len(S)
    counter = 0
    k = 0
    for i in range(N):
        if S[i] == "W":
            counter += (i-k)
            k += 1
    print(counter)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3500
/**
 * @author yuichirw
 *
 */
import java.util.*;
import static java.util.Arrays.*;
public class Main {
	static int 		n;
	static char[] 	num;
	static Scanner 	sc = new Scanner(System.in);
	
	static boolean read() {
		num = sc.nextLine().toCharArray();
		return true;
	}
	
	static String solve() {
		sort(num);
		String max, min;
		max = ""; min = "";
		for(int i = 0; i < num.length; i++) {
			min += num[i];
			max += num[num.length - 1 - i];
		}
		return new Long(Long.parseLong(max) - Long.parseLong(min)).toString();		
	}
	
	public static void main(String[] args) {
		n = sc.nextInt(); sc.nextLine();
		while(n-- > 0 && read()) {
			System.out.println(solve());
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    char a, b;
    cin >> a >> b;
    if (a > b) cout << ">";
    else if (a < b) cout << "<";
    else cout << "="; 
}


Measured memory_bytes: 3652
// Shift-JIS（シフトジス）

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N, X;
    cin >> N >> X;
    int count = 0;
    int D = 0, L;
    while (true)
    {
        if (D <= X && count < N + 1)
        {
            count++;
            cin >> L;
            D += L;
        }
        else
        {
            break;
        }
        
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main{

	class UnionFind {
		final int[] tree;
		int num;
		public UnionFind(int n) {
			this.tree = new int[n];
			Arrays.fill(tree, -1);
			num=n;
		}
		void union(int x, int y) {
			x = root(x);
			y = root(y);
			if(x != y) {
				if(tree[x] < tree[y]) {
					x ^= y; y ^= x; x^= y;
				}
				tree[x] += tree[y];
				tree[y] = x;
				num--;
			}
		}
		boolean find(int x, int y) {
			return root(x) == root(y);
		}
		int root(int x) {
			return tree[x] < 0 ? x : (tree[x] = root(tree[x]));
		}
		int size(int x) {
			return -tree[root(x)];
		}
		int getNum() {
			return num;
		}
	}
	
	void run(){
		int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt(), h = sc.nextInt();
		char[][] m = new char[h][];
		int ti = -1, tj = -1;
		for(int i=0;i<h;i++){
			m[i]=sc.next().toCharArray();
			for(int j=0;j<w;j++)if(m[i][j]=='t'){
				ti = i; tj = j; m[i][j]='.';
			}
		}
		int ID = 0;
		int[][] id = new int[h][w];
		for(int[]a:id)Arrays.fill(a, -1);
		for(int i=0;i<h;i++)for(int j=0;j<w;j++){
			if(id[i][j]==-1&&m[i][j]=='.'){
				Queue<int[]> q = new LinkedList<int[]>();
				id[i][j] = ID;
				q.add(new int[]{i, j});
				while(!q.isEmpty()){
					int[] a = q.poll();
					for(int k=0;k<4;k++){
						int ni = a[0]+d[k][0], nj = a[1]+d[k][1];
						if(0<=ni&&ni<h&&0<=nj&&nj<w&&m[ni][nj]=='.'&&id[ni][nj]==-1){
							id[ni][nj] = ID;
							q.add(new int[]{ni, nj});
						}
					}
				}
				ID++;
			}
		}
		int t = id[ti][tj];
		if(t==0){
			System.out.println(0); return;
		}
		UnionFind uf = new UnionFind(w*h);
		int res = -1, n = sc.nextInt();
		for(int i=1;i<=n;i++){
			int xj = sc.nextInt(), xi = sc.nextInt();
			m[xi][xj] = '.'; id[xi][xj] = ID;
			for(int k=0;k<4;k++){
				int ni = xi+d[k][0], nj = xj+d[k][1];
				if(0<=ni&&ni<h&&0<=nj&&nj<w&&id[ni][nj]!=-1)uf.union(ID, id[ni][nj]);
			}
			ID++;
			if(uf.find(0, t)){
				res = i; break;
			}
		}
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 22000
w,h,n=map(int,input().split())
min_x,max_x=0,w
min_y,max_y=0,h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        min_x=max(min_x,x)
    elif a==2:
        max_x=min(max_x,x)
    elif a==3:
        min_y=max(min_y,y)
    elif a==4:
        max_y=min(max_y,y)
if max_x-min_x<=0 or max_y-min_y<=0:
    print(0) 
else:
    ans=(max_x-min_x)*(max_y-min_y)
    print(max(ans,0))

Measured memory_bytes: 3064
#include <cstdio>
const int mo = 1e9 + 7;
using namespace std;
int x, y;
int pow(int x, int t){
	int res = 1; x %= mo;
	while (t > 0){
		if (t & 1) res = 1ll * res * x % mo;
		x = 1ll * x * x % mo;
		t >>= 1;
	}
	return res;
}
int main(){
	scanf("%d%d", &x, &y);
	if ((x + y) % 3 != 0 || (2 * y - x) % 3 != 0 || (2 * x - y) % 3 != 0 || x > 2 * y || y > 2 * x){
		puts("0");
		return 0;
	} 
	int a = (2 * y - x) / 3, b = (2 * x - y) / 3;
	int ans = 1;
	for (int i = 1; i <= (a + b); i++) ans = 1ll * ans * i % mo;
	for (int i = 1; i <= a; i++) ans = 1ll * ans * pow(i, mo - 2) % mo;
	for (int i = 1; i <= b; i++) ans = 1ll * ans * pow(i, mo - 2) % mo;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
using System;

namespace atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int l = int.Parse(input[0]);
            int r = int.Parse(input[1]);
            int d = int.Parse(input[2]);
            int count = 0;

            for (int i = l; i <= r; i++)
            {
                if (i % d == 0) count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 17864
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

ll N;
vector<ll> h;

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

	cin >> N;
	h.resize(N);

	for (ll i = 0; i < N; ++i) cin >> h[i];

	vector<ll> dp(N, std::numeric_limits<ll>::max());
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);

	for (ll i = 2; i < N; ++i)
	{
		chmin(dp[i], dp[i - 1] + abs(h[i - 1] - h[i]));
		chmin(dp[i], dp[i - 2] + abs(h[i - 2] - h[i]));
	}

	cout << dp[N - 1] << endl;

	//system("pause");
}


Measured memory_bytes: 1792