akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
  
  int a,b,c;
  string result;

  cin >> a >> b >> c;

  if( (a+b)==c || (a+c)==b || (b+c)==a ){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


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

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

// 素数か判定
bool isPrimeNumber(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) return false;
    }
    return true;
}

// 最大公約数を求める
ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}


int main() {
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    vector<ll> divisors = divisor(g);
    ll ans = 0;
    for (ll i : divisors) if (isPrimeNumber(i)) ans++;
    cout << ans + 1 << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define MAX 100005
using namespace std;

vector<int> g[MAX];

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (auto &x : h) cin >> x;
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        bool ok = true;
        for (auto ob : g[i + 1]) {
            if (h[ob - 1] >= h[i]) {
                ok = false;
                break;
            }
        }
        cnt += ok;
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 8804
#include <iostream>
#include <algorithm>
using namespace std;
using i64 = int64_t;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
constexpr i64 INF = 1LL << 60;

int main() {
	int n; cin >> n;
	i64* a = new i64[n];
	i64* b = new i64[n];
	rep(i, 0, n) cin >> a[i] >> b[i];

	int e = 0;
	i64 ans = 0;
	i64 bmin = INF;
	rep(i, 0, n) {
		if (a[i] > b[i]) {
			bmin = min(bmin, b[i]);
		}
		ans += a[i];
		e += a[i] == b[i];
	}
	if (e == n) {
		cout << 0 << endl;
		return 0;
	}
	cout << ans - bmin << endl;

	delete[] a;
	delete[] b;
	return 0;
}

Measured memory_bytes: 3896
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a,b;
  cin >> a >> b;
  string c;
  rep(i,a){
    cin >> c;
    cout << c << endl;
    cout << c << endl;
  }
}


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

int main(){
    int n;
    cin>>n;
    int res = 0;
    while(n){
        n/=2;
        res++;
    }
    cout << pow(2,res-1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	int a[n];
	long long xr{};
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i) xr ^= a[i];
	}
	
	cout << xr << " ";
	for (int i = 1; i < n; i++) {
		xr ^= a[i];
		xr ^= a[i - 1];
		cout << xr << " ";
	}
}

Measured memory_bytes: 4388
//
//  main.cpp
//  Atcoder Beginner Contest 071 A
//
//  Created by luras on 2017/8/20.
//  Copyright © 2017年 luras. All rights reserved.
//

#define ms(x, y) memset(x, y, sizeof(x))
#define mc(x, y) memcpy(x, y, sizeof(x))
#define lson o << 1, l, mid
#define rson o << 1 | 1, mid + 1, r
#define ls o << 1
#define rs o << 1 | 1
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<map>
#include<stack>
#include<vector>
#include<list>
#include<set>
#include<string>
#include<algorithm>
#pragma comment(linker,"/STACK:102400000,102400000")
template <class T> inline void gmax(T &a, T b){if(b > a) a = b;}
template <class T> inline void gmin(T &a, T b){if(b < a) a = b;}
using namespace std;
const int N = 1e5 + 10, M = 2e6 + 10, Z = 1e9 + 7, maxint = 2147483647, ms1 = 16843009, ms31 = 522133279, ms63 = 1061109567, ms127 = 2139062143;
const double PI = acos(-1.0), eps = 1e-8;
typedef long long LL;
void fre()
{
    freopen("/Users/luras/Desktop/in.txt", "r", stdin);
    freopen("/Users/luras/Desktop/out.txt", "w", stdout);
}
const int INF = 1e9;
int casenum, casei;

int ABS(int x)
{
    return x > 0 ? x : -x;
}

int x, a, b;

int main()
{
    while(~ scanf("%d%d%d", &x, &a, &b)){
        if(ABS(x - a) < ABS(x - b)) puts("A");
        else puts("B");
    }
    return 0;
}

/*
 
 
 题意:
 
 类型:
 
 分析:
 
 优化:
 
 trick:
 
 数据:
 
 Sample Input
 
 Sample Output
 
 
 */






Measured memory_bytes: 128
#include <stdio.h>

int main(){
	int N, M,tg[100],a[101][101],sc[101] = { 0 },i, j; 
	scanf("%d", &N);
	scanf("%d", &M);

	for (i = 0; i<M; i++)
		scanf("%d", &tg[i]);

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

	for (i = 0; i<M; i++) {
		for (j = 0; j<N; j++) {
			if (a[i][j] == tg[i])
				sc[j]++;
			else
				sc[tg[i] - 1]++;
		}
	}

	for (i = 0; i<N; i++)
		printf("%d\n", sc[i]);

	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int N, K;
    cin >> N >> K;

    vector<int> x(N);
    for (int &i : x) cin >> i;

    ll ans = (ll)INF * INF;
    rep(i, N) {
        if (N < i + K) break;
        int j = i + K - 1;
        if (x[i] < 0 && 0 < x[j]) {
            ll res = min(2 * -x[i] + x[j], -x[i] + 2 * x[j]);
            chmin(ans, res);
        } else if (x[j] < 0) {
            chmin(ans, (ll)-x[i]);
        } else {
            chmin(ans, (ll)x[j]);
        }
    }

    cout << ans << endl;
}

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

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

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

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(high[i]) ans++;
    }

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

Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>

int main()
{
	int n; scanf("%d", &n);
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		int x, k; scanf("%d%d", &x, &k);
		while(x % k) x -= ((x % k) / (x / k + 1) + ((x % k) % (x / k + 1) != 0)) * (x / k + 1);
		ans ^= x / k; 
	}
	if(ans) printf("Takahashi");
	else printf("Aoki"); 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

int main()
{
    int N;
    cin >> N;
    ll ans = 0;
    vecl A(N);
    for (int i = 0; i < N;i++)
    {
        cin >> A[i];
    }
    sort(all(A));
    reverse(all(A));
    ll nokori = N - 1;
    ans += A[0];
    ll idx = 1;
    bool odd = false;
    if(N %2 == 1){
        odd = true;
    }
    if(odd == false){
        for (int i = 1; i < N/2;i++)
        {
            ans += A[i] * 2;
        }
    }
    else{
        int i = 1;
        for (i = 1; i < (N / 2); i++)
        {
            ans += A[i] * 2;
        }
        ans += A[i];
    }
    cout << ans << endl;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;

int main(){
int n;
cin >> n;
vector<int>d;
int ans = 0;

REP(i,n){
    int t;
    cin >> t;
    d.pb(t);
    }
REP(i,n){
    FOR(j,(i+1),n){
        ans += d[i] * d[j];
    }
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
# coding=utf-8


# x,a,b = map(int, input().split())
# if abs(x-a) < abs(x-b):
#     print('A')
# else :
#     print('B')

#BBBBBBBBB
# hoge = [0] * 26
# a = ord('a')
# string = input()
# for i in range(len(string)):
#     hoge[ord(string[i])-a] = 1

# for i in range(26):
#     if hoge[i] == 0:
#         print(chr(i+a))
#         break
#     if i == 25:
#         print('None')


###CCCC

n = map(int, input().split())
A = map(int, input().split())
A = sorted(A,reverse = True)
# print(A)
e1 = A[0]
e2 = 0
hoge = False
skip = 0
# print(range(1,len(A)-1))
for i in range(1,len(A)-1):
    # print('i={}'.format(i))
    if i == skip:
        # print('cont')
        continue
    else:
        if hoge == False:
            if A[i] == e1 :
                hoge = True
                e2 = A[i+1]
                skip = i+1
                # print('skip={}'.format(skip))
            else :
                e1 = A[i] 
        else:
            if A[i] == e2 :
                # print('break')
                break
            else:
                e2 = A[i]
        if i == range(1,len(A)-1)[-1]:
            e2 = 0

print(e1*e2)



Measured memory_bytes: 14244
import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as BS

getIntList :: IO [Int]
getIntList = unfoldr (BS.readInt . BS.dropWhile (== ' ')) <$> BS.getLine

f :: String -> Int
f (b:b':bs) = if b == b' then f (b':bs) else 1+(f $ b':bs)
f _ = 0

main :: IO ()
main = do
  [n,k] <- getIntList
  s <- getLine
  let b = f s
  print $ (n-1)-b+(min b $ 2*k)


Measured memory_bytes: 5116
r1,c1,r2,c2 = map(int,input().split())
mod = 10**9 + 7
def factorial(N,MOD,r=True):
    fact = [1]*(N+1)
    rfact = [1]*(N+1)
    r = 1
    for i in range(1,N+1):
        fact[i] = r = r * i % MOD
    rfact[N] = r = pow(fact[N],MOD-2,MOD)
    for i in range(N, 0, -1):
        rfact[i-1] = r = r * i % MOD
    if r:
        return fact,rfact
    else:
        return fact
fact,rfact = factorial(r2+c2+1,mod)
def perm(n,k): #上のfactorialと併用
    return fact[n]*rfact[n-k]%mod
def comb(n,k): #上のfactorialと併用
    return fact[n]*rfact[k]*rfact[n-k]%mod
ans = comb(r1+c1,r1)
#print(ans)
for i in range(r1+1,r2+1):
    ans += comb(i+c1,c1)*comb(r2-c1+c2+1-i,r2-i+1)
    ans %= mod
    #print(ans)
#print(-1)
for i in range(c1+1,c2+1):
    ans += comb(i+r1,r1)*comb(c2-r1+r2+1-i,c2-i+1)
    ans %= mod
    #print(ans)

print(ans)

Measured memory_bytes: 74716
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s.at(0)==s.at(1) && s.at(1)==s.at(2)) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }  
  return 0;
}  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool so[10000]={};

int main(){
  so[0] = 1;
  so[1] = 1;
  for(int i=2;i*i<=10000;i++)
    if(so[i] == 0)
      for(int j=2;j*i<=10000;j++)
	so[i*j] =1;
  int n;
  while(cin>>n && n){
    for(int i=n;i>=5;i--)
      if(so[i]==0 && so[i-2]==0){
	cout << i-2 <<" "<< i<<endl;
	break;
      }
  }

  return 0;
}

Measured memory_bytes: 1172
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int n,m,a[105],sum=0;
int main()
{
	rd(n);rd(m);
	F(i,1,n) sum+=rd(a[i]);
	sort(a+1,a+n+1);
	if(a[n-m+1]*4*m>=sum) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
import math
xyzk = list(map(int,input().split()))
abc = [list(map(int,input().split())) for a in range(3)]
for a in range(3):
    abc[a].sort()
    abc[a].reverse()
abc2=[]
for a in range(len(abc[0])):
    for b in range(len(abc[1])):
        if (a+1)*(b+1)>xyzk[3]:
            break
        for c in range(len(abc[2])):
            if (a+1)*(b+1)*(c+1)>xyzk[3] :
                break
            abc2.append(abc[0][a]+abc[1][b]+abc[2][c])
abc2.sort()
abc2.reverse()
for a in range(xyzk[3]):
    print(abc2[a])

Measured memory_bytes: 8708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N) A[i] -= N - i - 1;
    ll res = 0;
    map<ll, ll> m;
    rep(i, N) {
        res += m[-(A[i] + (N - i - 1) * 2)];
        m[A[i]]++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 27332
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

namespace Unolight {

bool Ok(vector<PII> &a) {
    int h=0;
    for ( auto p:a ) {
        if ( h+p.first<0 ) {
            return false;
        }
        h+=p.second;
    }
    return true;
}

void main() {
    int n;
    cin >> n;
    vector<PII> ls,rs; // (lowest height, end height) 
    int total=0;
    REP(i,n) {
        string s;
        cin >> s;
        int b=0,h=0;
        for ( char c:s ) {
            if ( c=='(' ) {
                h++;
            } else {
                h--;
            }
            b=min(b,h);
        }
        if ( h>0 ) {
            ls.emplace_back(b,h); // 從 0 開始走到最低點，再走到h
        } else {
            rs.emplace_back(b-h,-h); //  從h開始走到最低點，再走到 0
        }
        total+=h;
    }
    sort(ls.rbegin(), ls.rend()); // 最高的最低點開始
    sort(rs.rbegin(), rs.rend()); // 最高的最低點開始
    if ( Ok(ls) && Ok(rs) && total==0 ) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
}

// {{{
} int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    Unolight::main();
    return 0;
}
// }}}

Measured memory_bytes: 11204
#include <cstdio>
using namespace std;
int h[300]; 
int main () {
    int n;
    scanf ("%d",&n);
    for (int i=1;i<=n;i++) {
    	scanf ("%d",&h[i]);
	}
	for (int i=1;i<=n;i++) {
		printf ("node %d: key = %d, ",i,h[i]);
		if ((i>>1)) printf ("parent key = %d, ",h[i>>1]);
		if ((i<<1)<=n) printf ("left key = %d, ",h[i<<1]);
		if ((i<<1)+1<=n) printf ("right key = %d, ",h[(i<<1)+1]);
		printf ("\n");
	}
    return 0;
}


Measured memory_bytes: 2704
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
C = [int(a) - 1 for a in input().split()]
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

def EulerTour(n, X, i0):
    f = lambda k: k * (k + 1) // 2
    USED = [0] * n
    ORG = [0] * n
    TMP = [0] * n
    P = [-1] * n
    Q = [~i0, i0]
    ct = -1
    ET1 = [0] * n
    ET2 = [0] * n
    ANS = [f(n)] * n
    while Q:
        i = Q.pop()
        if i < 0:
            i = ~i
            ET2[i] = ct
            USED[C[i]] += 1 + TMP[i]
            if i:
                p = P[i]
                k = ET2[i] - ET1[i] + 1 - USED[C[p]] + ORG[i]
                ANS[C[p]] -= f(k)
                TMP[p] += k
            continue
        if i >= 0:
            if i: ORG[i] = USED[C[P[i]]]
            ct += 1
            if ET1[i] == 0: ET1[i] = ct
        for a in X[i][::-1]:
            if a != P[i]:
                P[a] = i
                for k in range(len(X[a])):
                    if X[a][k] == i:
                        del X[a][k]
                        break
                Q.append(~a)
                Q.append(a)
    for i in range(n):
        ANS[i] -= f(n - USED[i])
    return ANS

print(*EulerTour(N, X, 0), sep = "\n")

Measured memory_bytes: 160140
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, x; cin >> n >> x;
	vector<int> b(n), l(n), u(n), od(n);
       	vector<long long> val(n);
	long long now = 0;
	for(int i = 0; i < n; i++){
		cin >> b[i] >> l[i] >> u[i];
		now += - 1ll * l[i] * b[i];
		val[i] = 1ll * l[i] * b[i] + 1ll * (x - b[i]) * u[i];
	}
	iota(od.begin(), od.end(), 0);
	sort(od.begin(), od.end(), [&](int a, int b){
		return val[a] > val[b];
	});
	long long lo = 0, hi = 1ll * n * x - 1, ans = 1ll * n * x;
	vector<long long> pref(n + 1, 0);
	for(int i = 0; i < n; i++) pref[i + 1] = pref[i] + val[od[i]];
	while(lo <= hi){
		long long mid = (lo+hi)>>1;
		int tk = mid / x, stk = mid % x;
		auto apply = [&](int id){
			int p = min(stk, b[id]);
			return 1ll * p * l[id] + 1ll * (stk - p) * u[id];
		};
		bool good = false;
		for(int i = 0; i < n; i++){
			long long cur = pref[tk + (i < tk)];
			if(i < tk) cur -= val[od[i]];
			if(cur + apply(od[i]) + now >= 0) good = true;
		}
		if(good) ans = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3328
ints = list(map(int, input().split()))
li = list(map(int, input().split()))

number = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
dislike = set(li)
like = number - dislike
for i in range(ints[0], 100000):
    flag = 0
    price = [int(j) for j in str(i)]
    length = len(price)
    for k in range(length):
        if price[k] in like:
            flag += 1
    if flag == length:
        break
print(i)

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

int main(int argc, const char * argv[]) {

    int c1x, c1y, c1r, c2x, c2y, c2r;
    scanf("%d %d %d", &c1x, &c1y, &c1r);
    scanf("%d %d %d", &c2x, &c2y, &c2r);
    
    if(c1r<c2r){
        if(sqrt(pow(c1x-c2x,2)+pow(c1y-c2y,2)) > c1r + c2r) printf("4\n");
        else if(sqrt(pow(c1x-c2x,2)+pow(c1y-c2y,2)) == c1r + c2r) printf("3\n");
        else if((c2r-c1r<sqrt(pow(c1x-c2x,2)+pow(c1y-c2y,2))) && (sqrt(pow(c1x-c2x,2)+pow(c1y-c2y,2)) < c1r + c2r)) printf("2\n");
        else if(sqrt(pow(c1x-c2x,2)+pow(c1y-c2y,2)) == c2r-c1r) printf("1\n");
        else if(sqrt(pow(c1x-c2x,2)+pow(c1y-c2y,2)) < c2r-c1r) printf("0\n");
        
        
    }
    
    else{
        if(sqrt(pow(c1x-c2x,2)+pow(c1y-c2y,2)) > c1r + c2r) printf("4\n");
        else if(sqrt(pow(c1x-c2x,2)+pow(c1y-c2y,2)) == c1r + c2r) printf("3\n");
        else if(((c1r-c2r<sqrt(pow(c1x-c2x,2)+pow(c1y-c2y,2))) && (sqrt(pow(c1x-c2x,2)+pow(c1y-c2y,2)) < c1r + c2r))) printf("2\n");
        else if(sqrt(pow(c1x-c2x,2)+pow(c1y-c2y,2)) == c1r-c2r) printf("1\n");
        else if(sqrt(pow(c1x-c2x,2)+pow(c1y-c2y,2)) < c1r-c2r) printf("0\n");
    }
}



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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    vector<ll> a(N), sum(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        if(i == 0) sum[0] = a[0];
        else sum[i] = sum[i - 1] + a[i];
    }
    ll m = INF, snuke, arai;
    for(int i = 0; i < N - 1; i++) {
        snuke = sum[i]; arai = sum[N - 1] - sum[i];
        m = min(m, abs(snuke - arai)); 
    }
    cout << m << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using vll = vector<ll>;

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<set<char> > suf(n);
    for (int i = n - 1; i >= 0; i--) {
        if (i < n - 1) suf[i] = suf[i + 1];
        suf[i].insert(s[i]);
    }
    unordered_set<char> cur({s[0]});
    unordered_set<string> res;
    for (int i = 1; i < n - 1; i++) {
        for (char a : suf[i + 1])
            for (char b : cur) {
                const string val({a, s[i], b});
                res.emplace(val);
            }
        cur.emplace(s[i]);
    }
    cout << res.size() << '\n';
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  vector<int> w(n);
  w = v;
  sort(v.begin(),v.end());
  int ans = v[n-1];
  int ansa = v[n-2];
  v = w;
  for(int i=0;i<n;i++){
    if(v[i] == ans) cout << ansa << endl;
    else cout << ans << endl;
  }
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    char a; cin >> a;

    if(isupper(a)){
        put('A');
    }else{
        put('a');
    }
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,a[200],counter=0;
    bool hoge=true;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    while(hoge){
        
        for (int i = 0; i < n; i++) {
            if(a[i]%2==0){
                a[i]/=2;
            }else{
                hoge=false;
                break;
            };
        }
        counter++;
    }
    std::cout << counter-1 << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,now=1,cnt=26,num=26;
int main(){
	cin>>n;
	while(cnt<n){
		num*=26;cnt+=num,now++;
	}
	cnt-=num,num/=26,n-=cnt+1;
//	cout<<n<<" "<<num<<"\n";
	
	for(int i=0;i<now;i++){
		putchar(n/num+'a');
		n%=num,num/=26;
	}
}

Measured memory_bytes: 3632
'use strict'

function main(input) {
  input = input.split('')
  const n = input.length
  const ss = input.filter((v, i, self) => {
    return self.indexOf(v) == i
  })

  if (ss.length == n) {
    console.log('yes')
  } else {
    console.log('no')
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[10];
		int[] b = new int[10];
		for(int i=0;i<10;++i) {
			a[i]=sc.nextInt();
		}
		for(int i=0;i<10;++i) {
			b[i]=sc.nextInt();
		}
		Arrays.sort(a);
		Arrays.sort(b);
//		int i=1,end=10;     // 初期位置と終了位置を調べる
//		while(i<end){                 // 終了位置未満の間
//			if(a[i-1]>a[i]){  // 昇順(>)、降順(<） 
//				swap(a, i);  // swap
//				i--;                  // ソートした場合は左で1つずれる
//				if(i==0) i+=2;        // 地点0になった場合は位置を2加算
//			} else {                  // ソートの必要が無い場合は右へ1つずれる
//				i++;
//			}
//		}
//		i=1;
//		while(i<end){                 // 終了位置未満の間
//			if(b[i-1]>b[i]){  // 昇順(>)、降順(<） 
//				swap(b, i);  // swap
//				i--;                  // ソートした場合は左で1つずれる
//				if(i==0) i+=2;        // 地点0になった場合は位置を2加算
//			} else {                  // ソートの必要が無い場合は右へ1つずれる
//				i++;
//			}
//		}
		System.out.println(Integer.toString(a[7]+a[8]+a[9])+' '+Integer.toString(b[7]+b[8]+b[9]));
	}

	public final static void swap(int[] array, int i) {
		int n=array[i-1]; array[i-1]=array[i]; array[i]=n;
	}
	
	public final static void swap2(int[] array, int i, int j) {
		int n=array[j]; array[j]=array[i]; array[i]=n;
	}
	
	public final static void swap_heap(int[] array, int i){
		int n=array[i]; array[i]=array[0]; array[0]=n;
	}
	
}


Measured memory_bytes: 26160
# -*- coding:utf8 -*-
import collections

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = collections.Counter(s)
t = [range(i) for i in list(c.values()) if i != 1]
a = [sum(i) for i in t]
print(sum(a))

Measured memory_bytes: 20332
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
int K, S;

int main() {
   cin >> K >> S;

   int ans = 0;
   for (int x = 0; x <= K; x++) {
      for (int y = 0; y <= K; y++) {
         if (S - x - y >= 0 && S - x - y <= K) ans++;
      }
   }
   cout << ans << endl;
   return 0;
}


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

// main
int main(){
    int N, K; cin >> N >> K;
    vector<int> l(N); rep(i, N) cin >> l[i];

    sort(l.begin(), l.end(), greater<int>());
    cout << accumulate(l.begin(), l.begin()+K, 0) << "\n";

    return 0;
}

Measured memory_bytes: 256
using System;
class ITP1_7_A
{
    static void Main()
    {
        while (true)
        {
            string[] input = Console.ReadLine().Split(' ');
            int m = int.Parse(input[0]);
            int f = int.Parse(input[1]);
            int r = int.Parse(input[2]);
            int sum = m + f;
            if (m == -1 && f == -1 && r == -1) break;
            else if (m == -1 || f == -1) Console.WriteLine('F');
            else if (sum >= 80) Console.WriteLine('A');
            else if (sum >= 65) Console.WriteLine('B');
            else if (sum >= 50) Console.WriteLine('C');
            else if (sum >= 30)
            {
                if (r >= 50) Console.WriteLine('C');
                else Console.WriteLine('D');
            }
            else Console.WriteLine('F');

        }
        return;
    }
}

Measured memory_bytes: 5292
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
int main() {

	char a;
	int H, W;
	char A[100][100] = { 0 };
	cin >> H >> W;

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> a;
			A[i][j] = a;
		}

	}

	

	for (int i = 0; i < H; i++)
	{
		int count = 0;

		for (int j = 0; j < W; j++)
		{
			if (A[i][j] == '.' || A[i][j] == '*' )
			{
				count++;
			}

		}

		if (W == count)
		{
			for (int j = 0; j < W; j++)
			{
				if (A[i][j] == '.')
				{
					A[i][j] = '*';
				}
			}

		}
	}

	for (int j = 0; j < W; j++)
	
	{
		int count = 0;

		for (int i = 0; i < H; i++)
		{
			if (A[i][j] == '.' || A[i][j] == '*')
			{
				count++;
			}

		}

		if (H == count)
		{
			for (int i = 0; i < H; i++)
			{
				if (A[i][j] == '.')
				{
					A[i][j] = '*';
				}
			}

		}
	}
	
	for (int i = 0; i < H; i++)
	{
		bool f = false;
		for (int j = 0; j < W; j++)
		{
			if ( A[i][j] != '*')
			{
				cout << A[i][j];
				f = true;
			}
		}
		if( f )
			cout << endl;
	}

	
}

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

int N, L;
string S[100];

int main(){
    cin >> N >> L;
    for(int i=0;i<N;i++)    cin >> S[i];

    sort(S, S+N);

    for(int i=0;i<N;i++)    cout << S[i];
    cout << endl;
}

Measured memory_bytes: 256
from itertools import product
n,m = map(int,(input().split()))
sw =[list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for bit in product([0, 1], repeat=n):
    ele = True #全部点灯ならtrue
    for i in range(m): #電球1～mに対するループ
        cnt = 0
        for j in sw[i][1:]: #switch1～nに対するループ
            #print(j)
            cnt += bit[j-1]
        if cnt % 2 != p[i]:
            ele = False
            break
    if ele:
        ans += 1        
print(ans)

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


int main(){
    int cnt=0;
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=min(a,b);;i--){
        if(a%i==0&&b%i==0){
            cnt++;
        }
        if(cnt==c){
            cout<<i;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int dp[5005][5005];
Int dpxsum[5005][5005];
Int dpysum[5005][5005];
Int pow2[5005];
Int ans;
int main() {
    Int n, a, b;
    cin >> n >> a >> b;
    if (a < b)
        swap(a, b);

    pow2[0] = 1;
    for (int i = 1; i <= n; i++)
        pow2[i] = pow2[i - 1] * 2 % MOD;
    if (a == 1 && b == 1) {
        cout << pow2[n] << endl;
        return 0;
    }
    ans = 1;
    for (int i = 1; i <= n; i++) {
        if (i - 1 < b)
            dp[i][i] = 1;
        else
            dp[i][i] = 0;
        for (Int jlen = 1; jlen < b; jlen++) {
            if (i - jlen - 1 < 1)
                continue;
            Int oklen_max = min(i - jlen, a);
            dp[i][i] += dpxsum[i - jlen - 1][i - jlen - 1] -
                        dpxsum[i - jlen - oklen_max][i - jlen - 1];
            dp[i][i] %= MOD;
            /*            for (Int oklen = 1; oklen < min(i - jlen, a); oklen++)
               { dp[i][i] += dp[i - jlen - oklen][i - jlen - 1];
                            }*/
        }

        (dpxsum[i][i] = dpxsum[i - 1][i] + dp[i][i]) %= MOD;
        (dpysum[i][i] = dpysum[i][i - 1] + dp[i][i]) %= MOD;
        for (int j = i + 1; j <= n; j++) {
            if (i == 1 && j - i >= b)
                dp[i][j]++;
            dp[i][j] += dp[i][j - 1];
            Int jlen_min = b, jlen_max = j - i;
            if (jlen_min < jlen_max)
                dp[i][j] +=
                    dpysum[i][j - jlen_min - 1] - dpysum[i][j - jlen_max - 1];
            /*            for (int jlen = b; j - jlen - 1 >= i; jlen++) {
                            dp[i][j] += dp[i][j - jlen - 1];
                            }*/
            dp[i][j] %= MOD;
            if (j - i + 1 >= a) {
                ans += dp[i][j] * pow2[n - j];
                ans %= MOD;
                //                cout << i << " " << j << " " << dp[i][j] <<
                //                endl;
                dp[i][j] = 0;
            }
            (dpxsum[i][j] = dpxsum[i - 1][j] + dp[i][j]) %= MOD;
            (dpysum[i][j] = dpysum[i][j - 1] + dp[i][j]) %= MOD;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (n - i + 1 >= a && n - j >= b) {
                (ans += dp[i][j]) %= MOD;
                //                cout << i << " " << j << " " << dp[i][j] <<
                //                endl;
            }
            //            cout << dp[i][j] << " ";
        }
        //        cout << endl;
    }
    if (ans < 0)
        ans += MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 353084
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	static Scanner stdIn = new Scanner(System.in);
	public static void main(String args[]) {
		while (true) {
			HashMap<String, Integer> map = new HashMap<String, Integer>();
			int n = stdIn.nextInt();
			if(n==0)break;
			String[] ite = new String[n];
			int[] pri = new int[n];
			for (int i = 0; i < n; i++) {
				String s = stdIn.next();
				int a = stdIn.nextInt();
				ite[i] = s;
				pri[i] = a;
				map.put(s, a);
			}
			int m = stdIn.nextInt();
			for (int i = 0; i < m; i++) {
				String s = stdIn.next();
				int a = stdIn.nextInt();
				int d = 0;
				for (int j = 0; j < a; j++) {
					String s2 = stdIn.next();
					d += map.get(s2);
				}
				if (d < map.get(s)) {
					map.put(s, d);
				}
			}
			String s = stdIn.next();
			System.out.println(map.get(s));
		}
	}
}

Measured memory_bytes: 33612
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
long long lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
int main(){
  long long N; cin>>N;
  long long ans=0;
  for(int i=0;i<N;i++){
    long long a;cin>>a;
    if(i==0)ans=a;
    ans=lcm(ans,a);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
n = int(input())
L = input().split()
L.sort()
count = 0
if n<=2:
    print(0)
    exit()
    
for i in range(n):
  for j in range(i + 1,n):
    for k in range(j + 1 ,n):
        if ((int(L[k]) < int(L[i]) + int(L[j])) & (L[k] != L[i])& (L[k] != L[j])& (L[j] != L[i]) & (abs(int(L[i]) - int(L[j])) < int(L[k]))):
            count += 1
        
print(count)

Measured memory_bytes: 9212
S = input()
n = len(S)
ans = 0
for i in range(n):
    for j in range(n):
        begin = i
        end = n-j
        if begin >=end:continue
        s = S[begin:end]
        ok = True
        for x in s:
            if x!='A' and x !='G' and x!='C' and x != 'T':
                ok = False
                break
        if ok:ans = max(ans,len(s))
print(ans)
            

Measured memory_bytes: 3064
//#include <math.h>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<stdio.h>
#include <iostream>
#include <vector>
//#include <string.h>
using namespace std;

int main(){
    int n,m;
    cin >>n>>m;
    vector<int>d(n,-1);

    bool flg = true;
    rep(i,m){
        int s,c;
        cin >> s>>c;
        if(d[n-s]==-1)
            d[n-s] = c;
        else{
            if(d[n-s] == c)
                continue;
            else{
                flg = false;
                break;
            }
        }
        
    }
    
    if(n>1 && d[n-1] == 0)
        flg =false;
    
    int ans=0;
    if(flg){
        if(n==1 && d[0]==-1){
            d[0]=0;
        }
        else if(n>1 && d[n-1]==-1){
            d[n-1]=1;
        }
           
        rep(i,n-1){
            if(d[i]==-1)
                d[i] = 0;
        }
        
        for(int i=n-1;i>=0;i--){
            ans += d[i];
            ans *=10;
        }
        
        ans/=10;
    }
    
    
    if(flg)
      cout << ans <<endl;
    else
        cout <<-1<<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 Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  ll n,m;cin>>n>>m;
  ll l=1,h=m,ml=m+1,mh=2*m+1;
  while(l<h){
    cout<<l<<" "<<h<<endl;
    l++;
    h--;
  }
  while(ml<mh){
    cout<<ml<<" "<<mh<<endl;
    ml++;
    mh--;
  }
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define pa pair<int,int>
const int N=1e6+10;
const int mod=998244353;
using namespace std;

struct point{ int x,y,id; }p[N],s[N];
inline bool cmp(point a,point b) {return a.x==b.x?a.y<b.y:a.x<b.x;}
inline ll cross(point a,point b,point c){return 1LL*(b.x-a.x)*(c.y-a.y)-1LL*(b.y-a.y)*(c.x-a.x); }
int main()
{     
     int n; scanf("%d",&n);
     for(int i=1;i<=n;i++)  scanf("%d%d",&p[i].x,&p[i].y);
     sort(p+1,p+1+n,cmp);
     s[0]=p[1];s[1]=p[2]; int t=2;
     for(int i=3;i<=n;i++)
     {
       while(t>1&&cross(s[t-2],p[i],s[t-1])>0) t--;
       s[t++]=p[i];
     }
     int tt=t-1; s[t++]=p[n-1];
     for(int i=n-2;i>=1;i--)
     {
       while(t>tt&&cross(s[t-2],p[i],s[t-1])>0) t--;
       s[t++]=p[i];
     }
     --t;
     printf("%d\n",t);
     int num=0;
     for(int i=0;i<t;i++) if(s[i].y<s[num].y) num=i;
     for(int i=num;i<t;i++) printf("%d %d\n",s[i].x,s[i].y); 
     for(int i=0;i<num;i++) printf("%d %d\n",s[i].x,s[i].y); 
return 0;   
}
/*
*/


Measured memory_bytes: 5176
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	int D[N][2];
	for (int i=0; i<N; i++)
		for (int j=0; j<2; j++)
			cin>>D[i][j];
	for (int i=0; i<N-2; i++) {
		if(D[i][0]==D[i][1] && D[i+1][0]==D[i+1][1] && D[i+2][0]==D[i+2][1]) {
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())
 
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
 
template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}
 
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
 
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
 
constexpr ll INF = TEN(18);
const int MX = 3010;
 
ll dp[MX][MX][4];
ll v[MX][MX];
 
int main() {
    int R, C, K;
    cin >> R >> C >> K;
    rep(i, K) {
        int r, c, val;
        cin >> r >> c >> val;
        --r, --c;
        v[r][c] = val;
    }
 
    rep(i, MX) rep(j, MX) rep(k, 4) dp[i][j][k] = -INF;
    dp[0][0][0] = 0;
 
    rep(i, R) {
        rep(j, C) {
            for (int k = 2; k >= 0; --k) {
                if (dp[i][j][k] >= 0) {
                    chmax(dp[i][j][k + 1], dp[i][j][k] + v[i][j]);
                }
            }
            rep(k, 4) {
                if (dp[i][j][k] >= 0) {
                    if (i + 1 < R) {
                        chmax(dp[i + 1][j][0], dp[i][j][k]);
                    }
                    if (j + 1 < C) {
                        chmax(dp[i][j + 1][k], dp[i][j][k]);
                    }
                }
            }
        }
    }
 
    ll ans = -INF;
    rep(k, 4) chmax(ans, dp[R - 1][C - 1][k]);
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 357120
# -*- coding: utf-8 -*-
"""
Created on Mon Jun  1 13:02:30 2020

@author: NEC-PCuser
"""

SX, SY, TX, TY = map(int, input().split())

ans = ""

if TX - SX > 0 and TY - SY > 0:
    first = "R"
    second = "U"
    third = "L"
    forth = "D"
elif TX - SX < 0 and TY - SY > 0:
    first = "L"
    second = "U"
    third = "R"
    forth = "D"
elif TX - SX < 0 and TY - SY < 0:
    first = "L"
    second = "D"
    third = "R"
    forth = "U"
elif TX - SX > 0 and TY - SY < 0:
    first = "R"
    second = "D"
    third = "L"
    forth = "U"

for i in range (TX - SX):
    ans += first
for i in range (TY - SY):
    ans += second
for i in range (TX - SX):
    ans += third
for i in range (TY - SY):
    ans += forth
ans += forth
for i in range (TX - SX + 1):
    ans += first
for i in range (TY - SY + 1):
    ans += second
ans += third
ans += second
for i in range (TX - SX + 1):
    ans += third
for i in range (TY - SY + 1):
    ans += forth
ans += first

print(ans)

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

int main() {
	int N; cin >> N;
	vector<string> S(N);
	vector<int> P(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i] >> P[i];
	}

	vector<pair<string, int>> SP(N);

	for (int i = 0; i < N; i++) {
		SP[i] = make_pair(S[i],-P[i]);
	}

	sort(SP.begin(), SP.end());

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (S[j] == SP[i].first && (-1*P[j]) == SP[i].second) {
				cout << j + 1 << endl;
			}
		}
	}
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a)
        print(k);
    else if (k <= a + b)
        print(a);
    else
        print(a - (k - a - b));

    return 0;
}


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



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

    if(n*500>=m){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>
typedef long long ll;

using namespace std;

signed main(){
  string s;
  cin >> s;
  if(s == "ABC")cout << "ARC" << endl;
  else if(s == "ARC") cout << "ABC" << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	vector<string> s(2);
	rep(i, 2) {
		cin >> s[i];
	}
	ll ans = 1;
	ll prev = 3;
	for (int i = 0; i < n;) {
		if (s[0][i] == s[1][i]) {
			ans *= prev;
			ans %= MOD;
			prev = 2;
			i++;
		}
		else {
			if (prev == 1) {
				ans *= 3;
				ans %= MOD;
				prev = 1;
				i += 2;
			}
			else {
				ans *= prev;
				ans *= (prev - 1);
				ans %= MOD;
				prev = 1;
				i += 2;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define INS(x) string (s); cin >> s
#define INL(x) ll (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  IN(x);
  IN(a);
  cout<<(x<a?0:10);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
int n;
string s,a;
int main()
{
	cin>>n>>s;
	a=s[0];
	int tot=0;
	for(int i=1;i<n;i++)
	{
		if(s[i]==a[tot])
		continue;
		a=a+s[i];
		tot++;
	}
	cout<<tot+1<<endl;
}

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

using namespace std;

int sum(int x) {
	return x < 10? x: sum(x / 10) + (x % 10);
}

int n, ans;

int main(){
	ans = 1e7;
	cin >> n;
	for (int i = 1; i * 2 <= n; ++i)
		ans = min(ans, sum(i) + sum(n - i));
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256