akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

char created_num[5], ans[8];
int stack_top = 0, stack_array[4];

void push(int value)
{
	stack_array[stack_top] = value;
	stack_top++;
}

int pop(void)
{
	stack_top--;
	return(stack_array[stack_top]);
}

int solve(void)
{
	int c, var1, var2;
	
	stack_top = c = 0;
	while (ans[c] != '\0'){
		if (ans[c] >= '0' && ans[c] <= '9'){
			push(ans[c] - '0');
		}
		else {
			var1 = pop();
			var2 = pop();
			switch (ans[c]){
				case '+':
				var2 += var1;
				break;
				
				case '-':
				var2 -= var1;
				break;
				
				case '*':
				var2 *= var1;
			}
			push(var2);
		}
		c++;
	}
	
	if (pop() == 10){
		return (1);
	}
	return (0);
}

int make_rpn(int num, int exp)
{
	static int isused[4] = {0, 0, 0, 0};
	int i;
	
	if (num + exp == 7){
		ans[7] = '\0';
		if (solve()){
			return (1);
		}
		return (0);
	}
	else {
		if (num - exp >= 2){
			ans[num + exp] = '+';
			if (make_rpn(num, exp + 1)){
				return (1);
			}
			
			ans[num + exp] = '-';
			if (make_rpn(num, exp + 1)){
				return (1);
			}
			
			ans[num + exp] = '*';
			if (make_rpn(num, exp + 1)){
				return (1);
			}
		}
	}
	if (num <= 3){
		for (i = 0; i < 4; i++){
			if (isused[i] == 0){
				isused[i] = 1;
				ans[num + exp] = created_num[i];
				if (make_rpn(num + 1, exp)){
					isused[i] = 0;
					return (1);
				}
				isused[i] = 0;
			}
		}
	}
	return (0);
}

int main(void)
{
	int i;
	while (1){
		for (i = 0; i < 4; i++){
			scanf("%d", &created_num[i]);
			created_num[i] += '0';
		}
		if (created_num[0] + created_num[1] + created_num[2] + created_num[3] == 4 * '0'){
			break;
		}
		created_num[4] = '\0';
		if (make_rpn(0, 0)){
			if ((ans[2] == '+' || ans[2] == '*' || ans[2] == '-') && (ans[4] == '+' || ans[4] == '*' || ans[4] == '-') && (ans[6] == '+' || ans[6] == '*' || ans[6] == '-')){
				printf("(((%c %c %c) %c %c) %c %c)", ans[0], ans[2], ans[1], ans[4], ans[3], ans[6], ans[5]);
			}
			else if ((ans[2] == '+' || ans[2] == '*' || ans[2] == '-') && (ans[5] == '+' || ans[5] == '*' || ans[5] == '-') && (ans[6] == '+' || ans[6] == '*' || ans[6] == '-')){
				printf("((%c %c %c) %c (%c %c %c))", ans[0], ans[2], ans[1], ans[6], ans[3], ans[5], ans[4]);
			}
			else if ((ans[3] == '+' || ans[3] == '*' || ans[3] == '-') && (ans[5] == '+' || ans[5] == '*' || ans[5] == '-') && (ans[6] == '+' || ans[6] == '*' || ans[6] == '-')){
				printf("(%c %c ((%c %c %c) %c %c))", ans[0], ans[6], ans[1], ans[3], ans[2], ans[5], ans[4]);
			}
			else if ((ans[2] == '+' || ans[2] == '*' || ans[2] == '-') && (ans[4] == '+' || ans[4] == '*' || ans[4] == '-') && (ans[6] == '+' || ans[6] == '*' || ans[6] == '-')){
				printf("(%c %c (%c %c %c)) %c %c))", ans[0], ans[4], ans[1], ans[3], ans[2], ans[6], ans[5]);
			}
			else{
				printf("(%c %c (%c %c (%c %c %c)))", ans[0], ans[6], ans[1], ans[5], ans[2], ans[4], ans[3]);
			}
		}
		else {
			printf("0");
		}
		printf("\n");
	}
	return (0);
}

Measured memory_bytes: 0
using System;
class Practice
{
    public static void Main()
    {
        while (true)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]), b = int.Parse(str[1]);
            if (a == 0 && b == 0) break;
            Console.WriteLine("{0} {1}", Math.Min(a, b), Math.Max(a, b));
        }
    }
}


Measured memory_bytes: 15944
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        System.out.println(S.length()<6 ? "No" : S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5) ? "Yes" : "No") ;
    }
}

Measured memory_bytes: 22868
#include <stdio.h>

int main() {
  int f, m, r;
  
  while (1){
    scanf("%d%d%d", &m, &f, &r);

    if ( m==-1 && f==-1 && r==-1) break;
    
    if ( f==-1 || m==-1 ) printf("F\n");
    else if ( f+m >= 80 ) printf("A\n");
    else if ( f+m >= 65 ) printf("B\n");
    else if ( f+m >= 50 ) printf("C\n");
    else if ( f+m >= 30 ) {
      if ( r >= 50 ) printf("C\n");
      else printf("D\n");
    }
    else printf("F\n");
  }
  
  return 0;
}


Measured memory_bytes: 2128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1<<30;
const ll MOD = 1e9 + 7;
const ll MAX_N = 1e5 + 10;
struct edge
{
    ll to, cost;
    edge(ll to, ll cost) { this->to = to, this->cost = cost; };
};
ll n;
vector<edge> G[MAX_N];
void solve()
{
    vector<ll> color(n, 0);
    vector<ll> used(n, 0);
    queue<P> que;
    que.push(P(0, 0));
    while(que.size())
    {
        P p = que.front(); que.pop();
        int v = p.first;
        used[v] = 1;
        for(ll u = 0; u < G[v].size(); u++)
        {
            edge e = G[v][u];
            if(used[e.to]) continue;
            if(e.cost % 2 == 0) color[e.to] = p.second;
            else color[e.to] = (p.second == 0 ? 1 : 0);
            que.push(P(e.to, color[e.to]));
        }
    }
    for(int i = 0; i < n; i++) cout << color[i] << endl;
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n - 1; i++)
    {
        ll u, v, w; cin >> u >> v >> w;
        u--, v--;
        G[u].push_back(edge(v, w));
        G[v].push_back(edge(u, w));
    }
    solve();
    return 0;
}

Measured memory_bytes: 9472
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

int main()
{
	string s,si;
	int d[26];
	for (int i =0; i < 26; i++) {
		d[i] = 0;
	}
	s = "";
	while (getline(cin,s)) {
		for (int i = 0; i < s.size(); i++){
			if (s[i] >= 'A' && s[i] <= 'Z') {
				d[s[i] - 'A']++;
			}else if (s[i] >= 'a' && s[i] <= 'z') {
				d[s[i] - 'a']++;
			}
		}
	}

	char c = 'a';
	for (int i = 0; i < 26; i++){
		printf("%c : %d\n", c + i, d[i]);
	}
	
	return 0;
}


Measured memory_bytes: 3284
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<map>
#include<deque>
#include<stack>
#include<algorithm>
using namespace std;
const int INF=0x7fffffff;
const double Pi=acos(-1);
int main()
{
	int A[5];
	scanf("%d%d%d",&A[1],&A[2],&A[3]);
	sort(A+1,A+4);
	if(A[1]==5&&A[2]==5&&A[3]==7)printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
ans_count=0
number_count=1

for i in range(len(A)):
    if A[i]==number_count:
        number_count+=1
    else:
        ans_count+=1
        
if number_count!=1:print(ans_count)
else:print("-1")

Measured memory_bytes: 24744
from collections import Counter

if __name__=="__main__":
    n = int(input())
    s=[]
    for i in range(n):
        s.append(input())
        
    s_most = Counter(s).most_common()

    ans_list = [s_most[0][0]]
    for i in range(1,len(s_most)):
        if s_most[i][1]==s_most[0][1]:
            ans_list.append(s_most[i][0])
        else:
            break

    ans_list.sort()

    for i in range(len(ans_list)):
        print(ans_list[i])

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

int main(){
    unsigned long long ans=0;
    int n,i;
    char token[300]={};
    fgets(token, sizeof(token), stdin);n=atoi(token);
    for (i=1; i<=n; i++) {
        if (i%3!=0&&i%5!=0) ans+=i;
    }
    printf("%lld",ans);
    return 0;
}



Measured memory_bytes: 1708
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    string a, b;
    cin >> a >> b;
    string s = a + b;
    int n = stoi(s);
    imfor(i, 1000) {
        if (i * i == n) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#define MAX_INT 2100000000
using namespace std;
typedef long long int ll;
//#include "Header.h"
int first[110], n, i, j, mn = 0,last=0,length;
vector<int> ans;
int main()
{
	bool now = false;
	int i, m=0,ans=0;
	string s;
	cin >> s;
	for (i = 0; i < s.length(); i++)
	{
		//printf("i=%d,m=%d,s=%c", i, m, s[i]);
		//cout << m << endl;
		if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C')
		{
			if (now == false) {
				now = true;
			}
			m++;
		}else if (now){
			now = false;
			ans = max(ans, m);
			
			m = 0;
		}
	}
	ans = max(ans, m);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 0x3f3f3f;
int main(){
    int a[3][3];
    int vis[3][3]={0};
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int n,x;
    cin>>n;
    for(int k=1;k<=n;k++){
        scanf("%d",&x);
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(x==a[i][j]) {
                    vis[i][j]=1;
                    break;
                }
            }
        }
    }
    int fg=0;
    if(vis[0][0]==1&&vis[0][1]==1&&vis[0][2]==1) fg=1;
    if(vis[1][0]==1&&vis[1][1]==1&&vis[1][2]==1) fg=1;
    if(vis[2][0]==1&&vis[2][1]==1&&vis[2][2]==1) fg=1;
    if(vis[0][0]==1&&vis[1][1]==1&&vis[2][2]==1) fg=1;
    if(vis[0][2]==1&&vis[1][1]==1&&vis[2][0]==1) fg=1;
    if(vis[0][0]==1&&vis[1][0]==1&&vis[2][0]==1) fg=1;
    if(vis[0][1]==1&&vis[1][1]==1&&vis[2][1]==1) fg=1;
    if(vis[0][2]==1&&vis[1][2]==1&&vis[2][2]==1) fg=1;
    if(fg==1) cout<<"Yes";
    else cout<<"No";
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		
		int black = h * b + w * a - w * h;
		
		System.out.println(a * b - black);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i, n) cin >> v[i];

  vector<ll> sl(n + 1);
  rep(i, n) sl[i + 1] = sl[i] + v[i];

  reverse(all(v));
  vector<int> rv(n);
  rep(i, n) rv[i] = v[i];
  reverse(all(v));

  vector<ll> sr(n + 1);
  rep(i, n) sr[i + 1] = sr[i] + rv[i];

  ll ans = 0;
  rep(l, n + 1) rep(r, n + 1) {
    if(l + r > n) continue;
    int ret = k - l - r;
    if(ret < 0) continue;
    vector<int> hand;
    rep(i, l) hand.push_back(v[i]);
    rep(i, r) hand.push_back(rv[i]);
    sort(all(hand));
    ll now = sl[l] + sr[r];
    rep(i, ret) {
      if(i >= hand.size()) break;
      if(hand[i] > 0) break;
      now -= hand[i];
    }
    ans = max(ans, now);
  }
  cout << ans << endl;

  return 0;
}

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

long gcd(long, long);

int main()
{
	long a,b;

	while(cin>>a>>b){
		long lcm=a*b/gcd(a,b);
		cout<<gcd(a,b)<<" "<<lcm<<endl;
	}

	return 0;

}

long gcd(long a, long b) //a>=b
{
	if(b==0){
		return a;
	} else {
		return gcd(b, a%b);
	}
}

Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

int main(){
	char b;
	cin >> b;
	if(b == 'A')cout << "T" << endl;
	if(b == 'T')cout << "A" << endl;
	if(b == 'G')cout << "C" << endl;
	if(b == 'C')cout << "G" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[105],b[105];
signed main()
{
	int n,i;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	for(i=3;i<=n;i++)
		if(a[i]==b[i]&&a[i-1]==b[i-1]&&a[i-2]==b[i-2])
		{
			cout<<"Yes";
			return 0;
		}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

int main(void){
    int kuku[] = {1,2,3,4,5,6,7,8,9,10,12,14,16,18,15,21,24,27,20,28,32,36,25,30,35,40,45,36,42,48,54,49,56,63,64,72,81};
    int n;
    int *iter;
    int kukuSize = sizeof(kuku)/sizeof(kuku[0]);
    scanf("%d",&n);
    for(iter = kuku; iter != &kuku[kukuSize];iter++){
        if(n == *iter){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    Int x = n % 10;
    if (x == 2 or x == 4 or x == 5 or x == 7 or x == 9) {
        print("hon");
    } else if (x == 0 or x == 1 or x == 6 or x == 8) {
        print("pon");
    } else {
        print("bon");
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
    int h,w; cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }
    ll ans = round((double)h * (double)w/2.0);
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

const double EPS = 1e-8;
bool used[305][305][305];
double dp[305][305][305];
ll n, cnt[4];

double dfs(ll x, ll y, ll z) {
  if(!x && !y && !z) return 0;
  if(used[x][y][z]) return dp[x][y][z];
  double ret = (double)n/(x+y+z);
  if(x) ret += dfs(x-1, y, z) * (double)x / (x+y+z);
  if(y) ret += dfs(x+1, y-1, z) * (double)y / (x+y+z);
  if(z) ret += dfs(x, y+1, z-1) * (double)z / (x+y+z);
  used[x][y][z] = true;
  // cerr << x << " " << y << " " << z << " " << ret << endl;
  return dp[x][y][z] = ret;
}

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

  cin >> n;
  REP(i, n) {
    ll a;
    cin >> a;
    cnt[a]++;
  }

  cout << fixed << setprecision(15) << dfs(cnt[1], cnt[2], cnt[3]) << endl;

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int A,B,C,X,Y; 
    cin >> A >> B >> C >> X >> Y;
    ll ans = 10000000000;
    for(int i = 0; i <= 100000; i++){
        ll res = i*2*C + max(0,X-i)*A + max(0,Y-i)*B;
        ans = min(ans,res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

ll bin_exp_mod(ll a, ll b,ll m)
{
	a%=m;
	ll ans=1;
	if(a==0) ans=0;

	while(b>0)
	{
		if(b&1) ans=(ans*a)%m;
		a=(a*a)%m;
		b>>=1;
	}
	return ans;
}

int main()
{ 
	

fast;

ll n;
cin>>n;

vector<ll> dp(n+5,1);

for(ll i=0;i<3;i++)dp[i]=0;

for(ll i=4;i<n+5;i++)
{
	for(ll j=3;i-j>2;j++)
		dp[i]=(dp[i]+dp[i-j])%mod;
}

cout<<dp[n];

}


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

using namespace std;
int max(int a , int b)
{
    if(a>=b)
    {
    	//cout<<b<<"\t" ;
        return(a);
    }
    return(b);
}
int main()
{
    int a,b,c,i,j,n,k ;
    cin>>n ;
    int arr[n+1][3],arr1[n+1][3] ;
    i = 0 ;
    arr1[i][0]=0 ;
	arr1[i][1]=0 ;
	arr1[i][2]=0 ;
	arr[i][0]=0 ;
	arr[i][1]=0 ;
	arr[i][2]=0 ;
    for(i=1 ; i<=n ; i=i+1)
    {
    	cin>>a>>b>>c ;
    	arr[i][0] = a ;
    	arr[i][1] = b ;
    	arr[i][2] = c ;
    	arr1[i][0]=0 ;
    	arr1[i][1]=0 ;
    	arr1[i][2]=0 ;
	}
	for(i=1 ; i<=n ; i=i+1)
	{
		arr1[i][0] = arr[i][0] + max(arr1[i-1][1],arr1[i-1][2]) ;
		arr1[i][1] = arr[i][1] + max(arr1[i-1][0],arr1[i-1][2]) ;
		arr1[i][2] = arr[i][2] + max(arr1[i-1][0],arr1[i-1][1]) ;
		
	}
	c = max(arr1[n][0],arr1[n][1]);
	c = max(c,arr1[n][2]) ;
	cout<<c ;
	
}

Measured memory_bytes: 2560
import bisect

N = int(input())
lst =list(map(int, input().split()))
lst.sort()
ret = 0
for i in range(N):
    for j in range(i + 1, N):
        n = lst[i] + lst[j]
        idx = bisect.bisect_left(lst, n)
        ret += max(0, idx - j - 1)
print(ret)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <limits>
#define ll long long int
using namespace std;
#define fr(i,n) for(ll i=0;i<n;i++)
#define pii pair <ll ,ll>
#define ppi pair < pii , int > 

#include <bits/stdc++.h> 


int main()
{
    ll nm = std::numeric_limits<long long>::max();
    ll n;cin>>n;
    ll a[n];fr(i,n)cin>>a[i];
    ll dp[n][n];
    fr(i,n)fr(j,n)dp[i][j]=-1;
    fr(i,n)dp[i][i]=0;
    fr(i,n-1)dp[i+1][i]=dp[i][i+1]=a[i+1] + a[i];
    for(int l=2;l<n;l++)
    {
        fr(k,n-l)
        {
            int i = k;
            int j = k + l;
            
            ll sum = 0;
            for(int h=i;h<=j;h++)sum+=a[h];
            dp[i][j]=nm;
            for(int x=i;x<j;x++)
            dp[i][j] = min(dp[i][j],dp[i][x] + dp[x+1][j] + sum);
            dp[j][i]=dp[i][j];
        }
    }
    // cout<<endl;
    // fr(i,n){fr(j,n)cout<<dp[i][j]<<" ";cout<<endl;}
    cout<<dp[0][n-1]<<endl;
    return 0 ;
}

Measured memory_bytes: 1536
#!/bin/bash
':' /*
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro node:5.2-slim \
  /bin/bash -c "node /vo/$(basename $0) < /vo/g.inp"; exit $?
exit 0
*/

"use strict";

const main = (input) => {
  let n = Number.parseInt(input[0]);
  let st = input[1].split(" ");
  let ans = "";
  for(let i=0; i<n; i++){
    ans += st[0].charAt(i);
    ans += st[1].charAt(i);
  }
  return ans;
};
console.log(main(require("fs").readFileSync("/dev/stdin", "utf-8")
  .trim().split("\n")));


Measured memory_bytes: 21064
n = int(input())
*a, = map(int, input().split())
c = [0]*(10**5+1)
for i in range(n):
    c[a[i]+0] += 1
    c[a[i]+1] += 1
    if a[i] > 0:
        c[a[i]-1] += 1
print(max(c))


Measured memory_bytes: 87268
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main() {
    int i = 0;
    int N;
    cin >> N;
    string s1, s2;
    cin >> s1 >> s2;
    long long int ans = 1;
    bool isVertical;

    if (s1[0] == s2[0]) {
        ans = 3;
        i = 1;
        isVertical = true;
    } else {
        ans = 6;
        i = 2;
        isVertical = false;
    }

    for (i; i < N; i++) {
        if (isVertical) {
            ans = (ans * 2) % 1000000007;
            if (s1[i] != s2[i]) {
                isVertical = false;
                i++;
            }
        } else {
            if (s1[i] == s2[i]) {
                isVertical = true;
            } else {
                ans = (ans * 3) % 1000000007;
                isVertical = false;
                i++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

typedef long long int ll;
int N;
ll h[100010];

/*int dp(int i) {
	if (i == N - 1) return 0;
	if (i + 2 > N - 1)
		return dp(i + 1) + abs(h[i] - h[i + 1]);
	return min(dp(i + 1) + abs(h[i] - h[i + 1]), dp(i + 2) + abs(h[i] - h[i + 2]));
}*/

int main() {
	optimizar_io
	ll dp[100010];

	cin >> N;
	for (int i = 0; i < N; i++) cin >> h[i];
	dp[0] = 0;
	for (int i = 1; i < N; i++) {
		if (i - 2 >= 0)
			dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
		else
			dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
	}
	cout << dp[N - 1] << "\n";
	return 0;
}

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

int main()
{
  int n, ans = 0;
  cin >> n;
  vector<int> A(n);
  if (n % 2 == 1)
    cout << n / 2 + 1 << endl;
  else
    cout << n / 2 << endl;
}

Measured memory_bytes: 256
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var alist = new List<string>();
        alist.Add("000");
        for (int i = 1; i <= 9; i++)
            alist.Add((111 * i).ToString());
        var s = Console.ReadLine().Trim();
        foreach (var x in alist)
            if (s.Contains(x)) { Console.WriteLine("Yes");goto end; }
        Console.WriteLine("No");
        end:;
    }
}


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

int main() {
  int H, W; cin >> H >> W;
  vector<vector<bool>> game(H, vector<bool>(W));
  rep(i, H) rep(j, W) {
    char c; cin >> c;
    game[i][j] = (c == '.' ? true : false);
  }
  
  vector<vector<int>> num(H, vector<int>(W, -1));
  queue<pair<int,int>> q;
  
  int ans = 0;
  num[0][0] = 0;
  q.push(make_pair(0,0));

  while(true) {
    if(!q.empty()) {
      auto p = q.front();
      int h=p.first, w=p.second;
      if(h>0 && game[h-1][w] && num[h-1][w]<0) {
        num[h-1][w] = num[h][w]+1;
        q.push(make_pair(h-1,w));
      }
      if(w>0 && game[h][w-1] && num[h][w-1]<0) {
        num[h][w-1] = num[h][w]+1;
        q.push(make_pair(h,w-1));
      }
      if(h<H-1 && game[h+1][w] && num[h+1][w]<0) {
        num[h+1][w] = num[h][w]+1;
        q.push(make_pair(h+1,w));
      }
      if(w<W-1 && game[h][w+1] && num[h][w+1]<0) {
        num[h][w+1] = num[h][w]+1;
        q.push(make_pair(h,w+1));
      }
      q.pop();
    } else break;
  }
  
  rep(i, H) rep(j, W) if(game[i][j]) ans++;

  if(num[H-1][W-1] > 0) cout << ans-num[H-1][W-1]-1 << 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 < (n); ++i)
typedef long long ll;

int main(){
  int X,Y;
  cin>>X>>Y;
  int third = 100000;
  int second = 200000;
  int first = 300000;
  int ans = 0;
  if(X==1 && Y==1){
    ans += 400000;
  }
  if(X==1){
    ans += first;
  }
  else if(X==2){
    ans += second;
  }
  else if(X==3){
    ans += third;
  }

  if(Y==1){
    ans += first;
  }
  else if(Y==2){
    ans += second;
  }
  else if(Y==3){
    ans += third;
  }
 
 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;
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());

  combination c(n + 5);

  mint ans = 0;
  rep(ri, 2) {
    rep(i, n) {
      mint now = c(i, k - 1);
      if (ri == 1) now = -now;
      ans += now * a[i];
    }
    reverse(a.begin(), a.end());
  }

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


Measured memory_bytes: 2176
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  int64_t x;
  cin>>x;

  map<int64_t, int64_t> have;
  for (int64_t i = -200; i<=200; i++) {
    int64_t temp = 1;
    for (int j=0; j<5; j++) temp *= i;
    have[temp] = i;
  }

  for (auto p : have) {
    int64_t left = p.first + x;
    if (have.find(left) != have.end()) {
      cout<<have[left]<<" "<<p.second<<endl;
      break;
    }
  }
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB"){cout << "No";}else{cout << "Yes";}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
// vector<int> fac; //precompute fac array
// fac.resize(n+1);
// fac[0] = 1; 
// for (int i=1; i<=n; i++)   fac[i] = m(m(fac[i-1])*m(i));
// int modInverse(int n){ 
// return p(n, MOD-2); 
// }  
// int nCrModPFermat(int n, int r){   
//     if(r == 0)  return 1; 
//     return m(m(m(fac[n])*m(modInverse(fac[r])))*m(modInverse(fac[n-r]))); 
// } 
signed main(){
    fast();
    int x, y;
    cin >> x >> y;
    for(int i=0; i<=100; i++){
        for(int j=0; j<=100; j++){
            if((2*i+4*j == y) && (i+j == x)){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> vote(n);
    int total = 0;
    for (int i = 0; i < n; i++) {
        int num;
        cin >> num;
        total += num;
        vote.at(i) = num;
    }
    sort(vote.begin(), vote.end(), greater<int>());
    double x = (double)total / 4 / m;
    if (vote.at(m - 1) >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect

A, B, Q = map(int, input().split())
s = [-10**15] + [int(input()) for i in range(A)] + [10**15]
t = [-10**15] + [int(input()) for i in range(B)] + [10**15]
# s = [-10**15]
# t = [-10**15]
# for _ in range(A):
#     s.append(int(input()))
# s.append(10**15)
# for _ in range(B):
#     t.append(int(input()))
# t.append(10**15)
x = list(map(int, (input() for _ in range(Q))))
for y in x:
    i = bisect(s, y)
    j = bisect(t, y)
    ans = min(
        max(abs(s[i] - y), abs(t[j] - y)),
        max(abs(s[i - 1] - y), abs(t[j - 1] - y)),
        2 * min(abs(s[i] - y), abs(t[j - 1] - y)) + max(abs(s[i] - y), abs(t[j - 1] - y)),
        2 * min(abs(s[i - 1] - y), abs(t[j] - y)) + max(abs(s[i - 1] - y), abs(t[j] - y))
    )
    print(ans)

Measured memory_bytes: 18092
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)


int main() {

	int A, B;
	cin >> A >> B;

	for (int i = 1; i < 1001; i++) {
		if ( int(double(i) * 0.08) == A && (int)((double)i * 0.1) == B) {
			cout << i << endl;
			return 0;
		}
	}

	cout << "-1" << 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;
using ll = long long;
using P = pair<int, int>;

int ctoi(char c) {
  switch (c) {
    case '0':
      return 0;
    case '1':
      return 1;
    case '2':
      return 2;
    case '3':
      return 3;
    case '4':
      return 4;
    case '5':
      return 5;
    case '6':
      return 6;
    case '7':
      return 7;
    case '8':
      return 8;
    case '9':
      return 9;
    default:
      return 0;
  }
}

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

  int length = S.size();
  int power = length - 1;
  ll sum = 0;

  for (int i = 0; i < (1 << power); i++) {
    bitset<10> b_plus(i);
    b_plus.set(power, 1);  // add finally
    ll tmp = 0;
    rep(j, length) {
      tmp = (tmp * 10) + ctoi(S.at(j));
      if (b_plus.test(j)) {
        sum += tmp;
        tmp = 0;
      }
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

struct v{
    bool isA;
    int x;
    int y;
};

int main() {
    int N;
    cin >> N;
    vector<v> A(2 * N);
    REP(i, N){
        A[i].isA = true;
        cin >> A[i].x >> A[i].y;
    }
    REP(i, N){
        A[i+N].isA = false;
        cin >> A[i+N].x >> A[i+N].y;
    }
    sort(A.begin(), A.end(), [](v& a, v& b){return a.x > b.x;});

    set<int> s;
    int ans = 0;
    REP(i, 2*N){
        if (!A[i].isA) s.insert(A[i].y);
        else{
            auto iter = s.lower_bound(A[i].y);
            if (iter != s.end()){
                s.erase(iter);
                //cout << A[i].y << " " << *iter << endl;
                ans++;
            }
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define max(a,b)(((a)>(b))?(a):(b))
int w, n, value[1001], weight[1001];
int weight_s,dp[1001][1001];

void search() {
  int i,j;
	for (i = 0; i < n; i++) {
		for (j = 0; j <= w; j++) {
			if (j < weight[i]) {
				dp[i + 1][j] = dp[i][j];
			}else{
				dp[i + 1][j] = max(dp[i][j],dp[i][j-weight[i]]+value[i]);
			}
		}
	}
	for (j = 0; j <= w; j++) {
		if (dp[n][j] == dp[n][w]) {
			weight_s = j;
			break;
		}
	}
}
int main(void) {
	int i,j,k=0;

	while (1) {
		scanf("%d", &w);
		if (w == 0)break;
		scanf("%d", &n);
		k++;
		for (i = 0; i < 1001; i++) {
			for (j = 0; j < 1001; j++) {
				dp[i][j] = 0;
 			}
		}
		for (i = 0; i < n; i++)
			scanf("%d,%d", &value[i], &weight[i]);

		search();
		printf("Case %d:\n",k);
		printf("%d\n", dp[n][w]);
		printf("%d\n",weight_s);
	}
	return 0;
}

Measured memory_bytes: 4520
n=int(input())
s=input()

R=s.count("R")
G=s.count("G")
B=s.count("B")
ans=R*G*B

for i in range(n-2):
    for j in range(i+1,n-1):
        k=2*j-i
        if k<n:
            if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:
                ans-=1

print(ans)

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  int a, b, m; cin >> a >> b >> m;

  vi va(a), vb(b);

  int mia = INF, mib = INF;
  for(int i=0;i<a;++i) {
    cin >> va[i];
    mia = min(mia, va[i]);
  }
  for(int i=0;i<b;++i) {
    cin >> vb[i];
    mib = min(mib, vb[i]);
  }

  int ans = mia + mib;
  for(int i=0;i<m;++i) {
    int x, y, c; cin >> x >> y >> c;
    x--;
    y--;
    ans = min(ans, va[x] + vb[y] - c);
  }
  cout << ans << endl;



}


Measured memory_bytes: 1024
S = input()

def fact(n):
    if n == 0:
        return 1
    return n * fact (n-1)
def comb(n,r):
    return fact(n) // (fact(r) * fact(n-r))
def calc(s,n):
    if n == 0:
        return int(s)
    ans = 0
    for i in range(len(s)-n):
        ln = len(s[i+1:])
        ans += int(s[:i+1])*comb(ln-1, n-1)+calc(s[i+1:],n-1)
    return ans
ans = 0
for i in range(len(S)):
    ans += calc(S, i)
print(ans)

Measured memory_bytes: 3064
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)


int n;
int main() {
	cin >> n;
	if (n == 3) {
		cout << "2 5 63" << endl;
	}
	else if (n == 4) {
		cout << "2 5 20 63" << endl;
	}
	else {
		cout << "2 3 4 9 ";
		n -= 4;
		if (n >= 19995) {
			n -= 2;
			cout << "29991 29997 ";
		}
		int pos = 6;
		int num = 15;
		while (num + 12 <= 30000 && n >= 2) {
			n -= 2;
			cout << num << " " << num + 6;
			if (num > 0) {
				cout << " ";
			}
			num += 12;
		}
		while (n > 3) {
			n -= 3;
			cout << pos << " " << pos + 2 << " " << pos + 4 << " ";
			pos += 6;
		}
		if (n == 0) {
			cout << endl;
		}
		else if (n == 1) {
			cout << pos << endl;
		}
		else if (n == 2) {
			cout << pos + 2 << " " << pos + 4 << endl;
		}
		else if (n == 3) {
			cout << pos << " " << pos + 2 << " " << pos + 4 << endl;
		}
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli unsigned long long int
#define MOD 1000000007
#define DEBUG 0
#define REP(i,n) for(int i=0;i<n;i++)

int main(){

	lli x,y;
	cin>>x>>y;

	lli ans = max(x,y) - min(x,y);

	if(ans <= 1)cout<<"Brown"<<endl;
	else cout<<"Alice"<<endl;

	return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<string>
#include<algorithm>

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, s, a) for (int i = s; i < a; i++)
#define llint long long int
using namespace std;

const int N_MAX = 505;
const int INF = 9999999;

int main()
{
    int n, t, min = INF;
    cin >> n >> t;

    rep(i, n) {
        int co, ti;
        cin >> co >> ti;
        if (ti <= t && co < min) min = co;       
    }

    if (min == INF) cout << "TLE";
    else cout << min;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>


using namespace std;

int dfs(int m,int rem, vector<int> &st, vector<vector<int> > &switchs, vector<int> &tento)
{
    if(rem == 0){
        vector<int> sum(m, 0);
        for(int i = 0; i < switchs.size(); i++){
            if(st[i] == 0){
                continue;
            }
            for(int j = 0; j < switchs[i].size(); j++){
                sum[switchs[i][j]]++;
            }
        }
        bool all = true;
        for(int i = 0; i < m; i++){
            if(sum[i] % 2 != tento[i]){
                all = false;
                break;
            }
        }
        if(all){
            return 1;
        }else{
            return 0;
        }
    }

    int ans = 0;

    st.push_back(1);
    ans += dfs(m, rem -1, st, switchs, tento);
    st.pop_back();
    st.push_back(0);
    ans += dfs(m, rem -1, st, switchs, tento);
    st.pop_back();

    return ans;
}

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

    vector<int> tento;
    vector<vector<int> > switchs(n, vector<int>());
    for(int i = 0; i < m; i++){
        int k;
        cin >>k;

        for(int j = 0; j < k; j++){
            int s;
            cin >>s;
            switchs[s-1].push_back(i);
        }
    }
    for(int i = 0; i < m; i++){
        int p;
        cin >>p;
        tento.push_back(p);
    }
    vector<int> vt;
    int ans = dfs(m, n, vt, switchs, tento);
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y,z;
	cin >> x>> y>> z;
    string ans;
    if(x-y==y-z)ans="YES";
    else ans = "NO";
      cout << ans << endl;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

long long A,B;

bool ok(long long key,long long index){
    string S = to_string(index);
    long long nagasa = S.size();
    if(index*A+nagasa*B > key) return true;
    else if(index*A+nagasa*B <= key) return false;
}

long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int N,K;cin >> N >> K;
    vector<int> retu(N);
    for(int i = 0;i<N;i++)cin >> retu.at(i);
    sort(retu.begin(),retu.end());
    reverse(retu.begin(),retu.end());
    int ans = 1000000000;
    for(int i = 0;i<N-K+1;i++){
        ans = min(ans,retu.at(i)-retu.at(i+K-1));
    }

    cout << ans << endl;
    // PLEASE GIVE ME THE "ACCEPTED" !
}

Measured memory_bytes: 640
q= int(input())
import math
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

X = []
for n in range(1, 10**5+1):
    if n%2 == 0:
        continue
    if is_prime(n) and is_prime((n+1)//2):
        X.append(n)

#print(X[0:15])
import bisect
for i in range(q):
    l, r = map(int, input().split())
    il = bisect.bisect_left(X, l)
    ir = bisect.bisect_right(X, r)
    print(ir-il)


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

int main() {
    int H, W;
    string s;
    cin >> H >> W;
    rep(i, W+2) cout << '#';
    cout << '\n';
    rep(i, H) {
        cout << '#';
        cin >> s;
        cout << s << '#' <<'\n';
    }
    rep(i, W+2) cout << '#';
    cout << '\n';
}

Measured memory_bytes: 256
using System;
class aoj{
	static void Main(){
		string[]a=Console.ReadLine().Split(' ');
		double  []b=new double[2];
		for(int i=0;i<2;i++){
			b[i]=double.Parse(a[i]);
		}
		int d=(int)b[0]/(int)b[1];
		double r=b[0]%b[1];
		double f=b[0]/b[1];
		Console.WriteLine("{0} {1} {2:0.0000000}",d,r,f);
	}
}

Measured memory_bytes: 9364
# coding: utf-8
from itertools import combinations


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


def find_result(primes, cond, total):
    combi = {}
    for i in range(len(primes)):
        for c in combinations(primes, i+1):
            s = reduce(lambda x, y: x * y, c)
            if s <= cond - 2 and total / s < 3500:
                combi[tuple(c)] = s

    keys = sorted(combi.keys())
    for h in keys:
        for n in keys:
            for w in keys:
                s = combi[h] + combi[n] + combi[w]
                if s == cond:
                    return combi[h], combi[n], combi[w]
    return None


N = int(raw_input())
primes = [
    1,
] + prime_decomposition(N)

i = 2
while True:
    cond = i * 4
    all_primes = primes + prime_decomposition(i)
    total = reduce(lambda x, y: x * y, all_primes)
    candi_primes = [p for p in all_primes if p <= cond - 2]

    r = find_result(candi_primes, cond, total)
    if r is not None:
        h, n, w = r
        print '{} {} {}'.format(int(total/h), int(total/n), int(total/w))
        break
    i += 1

Measured memory_bytes: 2788
fn main() {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  let mut s1: Vec<char> = buf.trim().chars().collect();

  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  let mut s2: Vec<char> = buf.trim().chars().collect();

  s2.reverse();

  if s1 == s2 {println!("YES")} else {println!("NO")};

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
 
using namespace std;
 
typedef long long ll;
struct edge{
	int u, v, cost;
};
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int l;
	cin >> l;
	l--;
 
	int r = 0;
	while((1 << (r + 1)) - 1 <= l) r++;
 
	vector<edge> v;
	int m = 0;
	rep(i, r){
		v.push_back({i+1, i+2, 1 << i});
		v.push_back({i+1, i+2, 0});
		m += 2;
	}
 
	int val = (1 << r) - 1;
	for(int i = r-1; i >= 0; i--){
		if(l >= val + (1 << i)){
			v.push_back({i+1, r+1, val + 1});
			m++;
			val += (1 << i);
		}
	}
 
	cout << r + 1 << " " << m << endl;
	rep(i, m){
		cout << v[i].u << " " << v[i].v << " " << v[i].cost << endl;
	}
 
}

Measured memory_bytes: 256