akhauriyash/Code-Regression huggingface dataset:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A = mapint()
Xs = list(mapint())
Xs.sort()
dp = [[[0]*2501 for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for i in range(1, N+1):
    x = Xs[i-1]
    dp[i][0][0] = 1
    for j in range(1, N+1):
        for n in range(2501):
            dp[i][j][n] += dp[i-1][j][n]
            if n>=x:
                dp[i][j][n] += dp[i-1][j-1][n-x]

ans = 0
for j in range(1, N+1):
    ans += dp[-1][j][j*A]
print(ans)

Measured memory_bytes: 119024
#include<cstdio>
#include<cmath>
#include<string.h>
#include<algorithm>
using namespace std;


int main()
{
	int n, x;
	bool right = true;
	scanf("%d", &n);
	while(n--){
		scanf("%d", &x);
		if(right&&x%2==0){
			if(x%3!=0&&x%5!=0){
				right = false;
			}
		}
	}
	if(right)	printf("APPROVED\n");
	else		printf("DENIED\n");
	return 0;
} 

Measured memory_bytes: 128
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.arange(1, 10)
B = A[:, None] * A[None, :]
bl = np.any(B == N)
print('Yes' if bl else 'No')


Measured memory_bytes: 12384
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using static System.Math;

class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split();
        int a = int.Parse(input[0]);
        int p = int.Parse(input[1]);
        int piece = 3 * a + p;
        Console.WriteLine(piece / 2);
    }
}

Measured memory_bytes: 13140
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    long A,B,C,K;

    private void solve() {
        A = nextLong();
        B = nextLong();
        C = nextLong();
        K = nextLong();

        long ans = 0;
        if (K % 2 == 1) {
            ans = B - A;
        } else {
            ans = A - B;
        }

        if ((long)-1e18 <= ans && ans <= (long)1e18) {
            out.println(ans);
        } else {
            out.println("Unfair");
        }
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

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

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

int main(){
	int h, w;
	int a, b;
	cin >> h >> w >> a >> b;
	float hf, wf;
	hf = h;
	wf = w;
	float ans = hf*wf/2;
	int f = 0;
  	if(h == a*2 && w == b*2) f = 1;
	cout << ans << ' ' << f << endl;
}

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

int T, n, d;
int main() {
	int i;
	cin >> T;
	while(T--) {
		scanf("%d%d", &n, &d);
		if(n % 2 == 0) d ^= 127;
		cout << 127 * (n-1) + d << endl;
	}
	return 0;
}


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

int main() {
  
  int N;
  double M;
  cin >> N >> M;
  
  vector<double> A(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  
  double total = 0, demand;
  
  for (int i = 0; i < N; i++) {
    total += A.at(i);
  }
  
  demand = total / (4 * M);
  
  if (A.at(M - 1) < demand) {
    cout << "No" << endl;
  }
  
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
/*
 _  __    _   _   _ ____ _____ 
| |/ /   / \ | | | / ___|_   _|
| ' /   / _ \| | | \___ \ | |  
| . \  / ___ \ |_| |___) || |  
|_|\_\/_/   \_\___/|____/ |_|  
*/
#include <bits/stdc++.h>
#include <fstream>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a, b) for (long long i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
using namespace std;
int main()
{
    CIN;
    int n;
    cin >> n;
    vi v(n);
    rep(i,0,n){
        cin >> v[i];
    }
    int dp[n+2];
    rep(i,0,n+2){
        dp[i] = intlimit;
    }
    dp[0] = 0;
    rep(i,0,n){
        if(i<n-1)
        dp[i+1] = min(dp[i+1],dp[i] + abs(v[i]-v[i+1]));
        if(i<n-2)
        dp[i+2] = min(dp[i+2],dp[i] + abs(v[i]-v[i+2]));
    }
    cout << dp[n-1];
}


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

using namespace std;

const int maxn=510;

typedef long long ll;

string s;
map<string,int> mp;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	ll ans=0;
	for(int i=0;i<n;i++){
		cin>>s;
		sort(s.begin(),s.end());
		ans+=mp[s];
		mp[s]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  if(n==1 && m==1) cout<<1<<endl;
  else if(n==1) cout<<m-2<<endl;
  else if(m==1) cout<<n-2<<endl;
  else cout<<(n-2)*(m-2)<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    int H[N];
    REP(i, N) cin >> H[i];

    int c = 1;
    int m = H[0];
    FOR(i, 1, N) {
        if (H[i] >= m) {
            c++;
            m = H[i];
        }
    }
    cout << c << endl;
    return 0;
}


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

int main() { 
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    int b = 0;
    for(int i = 0; i < m; i++){
        cin >> a.at(i);
        b += a.at(i);
    }
    if(n-b<0){
        cout << -1 << endl;
        return 0;
    }
    cout << n - b << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  double x, y, arg;
  ST(double x, double y, double arg):x(x),y(y),arg(arg){}
};
bool operator<(const ST& a, const ST& b){
  return a.arg < b.arg;
}


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

  vector<ST> v;
  rep(i,N){
    int a, b;
    cin >> a >> b;
    if(a == 0 && b == 0){
      v.emplace_back((double)a,(double)b,0);
    }else{
      v.emplace_back((double)a,(double)b,atan2(b,a));
    }
  }
  sort(ALLOF(v));
  //rep(i,N){
  //  cout << " " << v[i].x << " " << v[i].y << " " << v[i].arg << endl;
  //}
  
  vector<ST> w;
  rep(i,N){
    w.push_back(v[i]);
  }
  rep(i,N){
    w.push_back(v[i]);
  }
  
  double ret = 0.0;
  
  rep(i,w.size()){
    rep(j,N){
      double sumx = 0, sumy = 0;
      REP(k,i,i+1+j){
        sumx += w[k].x;
        sumy += w[k].y;
      }
      ret = max(ret, sqrt(sumx*sumx + sumy*sumy));
    }
  }
  
  printf("%.12lf\n", ret);
  
  return 0;
}



Measured memory_bytes: 512
N, L = map(int, input().split())
if L >= 0:
    print(sum([L+i-1 for i in range(2, N+1)]))
else:
    apple = [L+i-1 for i in range(1, N+1)]
    apple.pop(min(N-1, -L))
    print(sum(apple))


Measured memory_bytes: 2940
N, X = map(int, input().split())
items = []
for i in range(N):
    b, l, u = map(int, input().split())
    items.append((b, l, u, u * (X - b), - b * l))

items = sorted(items, key=lambda x: -(x[3] - x[4]))


def f(num):
    cnt = num // X
    mod = num % X
    point = 0
    for i in range(cnt):
        point += items[i][3]
    for i in range(cnt, N):
        point += items[i][4]

    if mod == 0:
        if point >= 0:
            return True
        else:
            return False
    else:
        tmp = -float("inf")
        for i in range(N):
            b, l, u, d1, d2 = items[i]
            if mod >= b:
                mul = u * (mod - b)
            else:
                mul = l * (mod - b)

            if i < cnt:
                tmp = max(tmp, point - d1 + mul + items[cnt][3] - items[cnt][4])
            else:
                tmp = max(tmp, point - d2 + mul)
        if tmp >= 0:
            return True
        else:
            return False

ok = N * X + 1
ng = - 1
while (ok - ng) > 1:
    mid = (ok + ng) // 2
    if f(mid):
        ok = mid
    else:
        ng = mid
print(ok)


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

#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
typedef long double ld;
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
const int N=1e3+5, mxN=(1<<22);
int mod=1e9+7;
int n;
ll a[N],b[N],c[N];
priority_queue<ll>qq,q;


int main()
{
    FIO
int x,y,z,k;

cin>>x>>y>>z>>k;
for(int i=0;i<x;i++)
    cin>>a[i];
sort(a,a+x,greater<int>());

for(int i=0;i<y;i++)
    cin>>b[i];


for(int i=0;i<z;i++)
    cin>>c[i];



    for(int j=0;j<y;j++)
    {

        for(int ind=0;ind<z;ind++)
        {
           q.push(b[j]+c[ind]);

        }
    }
    for(int z=0;z<3000&&q.size();z++)
    {

        for(int i=0;i<x;i++)
        {

            qq.push(q.top()+a[i]);

        }
q.pop();

    }

while(k--)
{
    cout<<qq.top();
    qq.pop();
    if(k)
        cout<<endl;

}


    return 0;

}






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

int main()
{
  int N;
  string str;
  char ch = '\0';
  int ans = 0;
  
  cin >> N;
  cin >> str;
  
  for (int i = 0; i < str.size(); i++) {
    if (ch != str.at(i)) {
      ans++;
      ch = str.at(i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
A,B,M = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
xyc = [[int(i) for i in input().split()] for j in range(M)]

a_min = min(a)
b_min = min(b)

ans = a_min+b_min

for i in range(M):
    ans = min(ans,a[xyc[i][0]-1]+b[xyc[i][1]-1]-xyc[i][2])
    
print(ans)

Measured memory_bytes: 80196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename 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);
}
int main()
{
    int N;
    cin >> N;
    vll A(N), B(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i] >> B[i];
    }
    ll sum = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        if ((A[i]+sum) % B[i] != 0)
            sum += B[i] - (A[i] + sum) % B[i];
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 1792
import sys, itertools


def solve(N: int, x: "List[int]", y: "List[int]"):
    route = list(itertools.permutations([i for i in range(N)]))
    length = 0
    itter = range(N-1)
    for i in route:
        for j in itter:
            length += ((x[i[j]]-x[i[j+1]])**2+(y[i[j]]-y[i[j+1]])**2)**0.5
    print(length/len(route))
    return
    
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int N;
vi a;

signed main() {
    cin >> N;
    a = vi(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    ll ans = accumulate(a.begin(), a.end(), 0LL);
    ans -= N;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int cost(int i, int j, vector<vector<int>> &C, const vector<int> &p) {
  int min_cost = INT_MAX;
  if (C[i][j] != 0) return C[i][j];
  if (i == j) {
    min_cost = 0;
  } else if (i + 1 == j) {
    min_cost = p[i - 1] * p[i] * p[i + 1];
  } else {
    for (int k = j - 1; i < k; k--) {
      min_cost =
          min(cost(i, k, C, p) + cost(k + 1, j, C, p) + p[i - 1] * p[k] * p[j],
              min_cost);
    }
    C[i][j] = min_cost;
  }
  return min_cost;
}
int main() {
  int tmp;
  cin >> n;
  vector<int> p(n + 1);
  vector<vector<int>> C(n + 1, vector<int>(n + 1, 0));
  cin >> p[0];
  for (size_t i = 1; i <= n; i++) {
    cin >> p[i] >> tmp;
  }

  cout << cost(1, n, C, p) << endl;
}



Measured memory_bytes: 3204
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N;
int A[SIZE];
ll K;

int main()
{
	scanf("%d%d%d",&A[0],&A[1],&A[2]);
	sort(A,A+3);
	int ans = A[2]*10 + A[0] + A[1];
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)/b;
}


int main(void){
    vector<vector<ll>>dp(1e5+10);
    ll n,a,b,c;
    cin>>n;
    vector<vector<ll>>h(n); //happy
    rep(i,n){
        cin>>a>>b>>c;
        h[i].push_back(a);
        h[i].push_back(b);
        h[i].push_back(c);
    }
    dp[0].push_back(h[0][0]);
    dp[0].push_back(h[0][1]);
    dp[0].push_back(h[0][2]);
    for(int i=1;i<n;++i){
        dp[i].push_back(max(dp[i-1][1],dp[i-1][2])+h[i][0]);
        dp[i].push_back(max(dp[i-1][0],dp[i-1][2])+h[i][1]);
        dp[i].push_back(max(dp[i-1][1],dp[i-1][0])+h[i][2]);
    }

    cout<<*(max_element(ALL(dp[n-1])));
}
/*

*/

Measured memory_bytes: 14336
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,K;
inline char nc(){
	static char buf[100000],*p1,*p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
	int ret=0;bool f=0;char ch=nc();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=nc();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc();
	return f?-ret:ret;
}
long long work(long long x,long long y){
	return !y?-x:work(y,x%y)+x/y*y*2;
}
int main(){
	scanf("%lld%lld",&n,&K);
	printf("%lld\n",n+work(K,n-K));
	return 0;
}

Measured memory_bytes: 128
import numpy as np

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for _ in range(D)])


def s11(c, s, last_date, di, i, mul):
    score = s[di - 1][i]
    score += 0.01 * mul * c[i] * (di - last_date[i])
    return score


def f12(D, c, s):
    last_date = np.zeros(26)

    t = []
    for di in range(1, D + 1):
        mul = np.mean(s[di - 1]) / np.mean(c)
        score_list = []
        for i in range(26):
            score_list.append(s11(c, s, last_date, di, i, mul))

        select_index = score_list.index(max(score_list))
        t.append(select_index)
        last_date[select_index] = di

    return t


for ti in f12(D, c, s):
    print(ti + 1)

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

using namespace std;

#define int long long

const int mod = 1e9 + 7;

int logpow(int x, int y)
{
	int res = 1;
	
	while(y)
	{
		if(y % 2 == 1)
			res = (res * x) % mod;
		
		y /= 2;
		x = (x * x) % mod;
	}
	
	return res;
}

int comb(int n, int k)
{
	int fact1 = 1;
	int fact2 = 1;
	int fact3 = 1;
	
	for(int i = 1; i <= k; i++)
		fact1 = (fact1 * i) % mod;
	
	for(int i = 1; i <= n - k; i++)
		fact2 = (fact2 * i) % mod;
		
	for(int i = 1; i <= n; i++)
		fact3 = (fact3 * i) % mod;
	
	fact2 = logpow(fact2, mod -  2);
	fact1 = logpow(fact1, mod -  2);
	
	fact3 = (fact3 * fact2) % mod; 
	fact3 = (fact3 * fact1) % mod; 
	
	return fact3;
}


main()
{ 
	
	int x, y;
	cin >> x >> y;
	
	int p = 0;
	
	if(x > y)
		swap(x, y);
		
	while(x < y)
	{
		x --;
		y -= 2;
		
		p++;
	}
	
	if(x < 0 || y < 0 || x != y)	
	{
		cout << 0;
		return 0;
	}
	
	if(x % 3 != 0)
	{
		cout << 0;
		return 0;
	}
	
	x /= 3;
	
	int t = x + x + p;
	int res = 1;
	
	cout << comb(t, x);
}


//2 3 4 1
//
//1 2 3 0
//
//1 1 1 -3

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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	bool b = true;
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n-1-i]) b = false;
	}
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n / 2 - 1 - i]) b = false;
	}
	for (int i = n / 2; i < n; i++) {
		if (s[i] != s[n - 1 - i]) b = false;
	}
	if (b) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3552
#include<iostream>
using namespace std;
int n,X,x,s;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
main(){
	cin>>n>>X;
	for(;cin>>x;)s=gcd(s,x-X);
	cout<<(s>0?s:-s)<<endl;
}


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int x,a;
    cin>>x>>a;
    if(x<a) cout<<"0";
    else cout<<"10";
    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
p = list(map(int,input().split()))

def kitaiti(n):
    return 0.5*n + 0.5

ans = 0

s=[0]*(N+1)
for i in range(N):
    s[i+1] = s[i] + p[i]

for i in range(N-K+1):
    val = s[K+i] - s[i]
    if ans<val:
        ans = val

print(kitaiti(ans)+0.5*(K-1))


Measured memory_bytes: 71792
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE MultiWayIf #-}

module Main where

import qualified Data.ByteString.Char8 as B
import Control.Applicative

main :: IO ()
main = do
  t <- B.getLine
  B.putStrLn $ if p t then "Heisei" else "TBD"

p t = let
  Just (y, t') = B.readInt t
  Just (m, t'') = B.readInt $ B.drop 1 t'
  Just (d, _) = B.readInt $ B.drop 1 t''
  in if
    | y < 2019 -> True
    | y > 2019 -> False
    | m < 4 -> True
    | m > 4 -> False
    | d <= 30 -> True
    | otherwise -> False


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

int main(void) {
    int n, h[101], max = -1, ans = 0;

    if(scanf("%d", &n) == 1);

    for(int i = 0; i < n; i++) {
        if(scanf("%d", &h[i]) == 1);
        if(h[i] >= max) {
            max = h[i];
            ans++;
        }
    }


      printf("%d", ans);

      return 0;
}

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

int main(){
	long long l,r,i,j;
	int min,a;
	scanf("%ld%ld",&l,&r);
	if(((l+r)/2)*((l+r)/2)<2019&&((l+r)/2+1)*((l+r)/2+1)<2019){printf("%d\n",l*(l+1));return 0;}
	
	for(a=1;a<1000000;a++){
		if(a*2019>r)break;
		if(a*2019>=l&&a*2019<=r){printf("0\n");return 0;}
	}

		min=2019;
		for(i=l;i<r;i++)
				for(j=i+1;j<=r;j++)
					if(i*j%2019<min)min=i*j%2019;
			printf("%d\n",min);			
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n, m, k; cin >> n >> m >> k;
  for(int i = 0; i <= n; i++) {
    for(int j = 0; j <= m; j++) {
      if(i*(m-j) + j*(n-i) == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#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 VE = vector<T>;
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 ll m = 1234567;
const long double pi = 3.141592653589793;
int main() {
	string s;
	cin >> s;
	s.erase(unique(all(s)), s.end());
	puts(s.size() == 4 ? "Good" : "Bad");
	return 0;
}

Measured memory_bytes: 3548
#include<iostream>
using namespace std;
int main()
{
	int x;
	cin>>x;
	if (x>=400&&x<600) cout<<'8';
	else if (x>=600&&x<800) cout<<'7';
	else if (x>=800&&x<1000) cout<<'6';
	else if (x>=1000&&x<1200) cout<<'5';
	else if (x>=1200&&x<1400) cout<<'4';
	else if (x>=1400&&x<1600) cout<<'3';
	else if (x>=1600&&x<1800) cout<<'2';
	else if (x>=1800&&x<2000) cout<<'1';
	return 0;
}

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

int w, h;
string grid[71][71];
string dp[71][71];

string maxstr(string a, string b){
	if (a.size() > b.size()) return a;
	if (a.size() < b.size()) return b;
	return max(a, b);
}

int main()
{
	while (scanf("%d %d", &w, &h), w){
		for (int i = 0; i < 71; i++){
			for (int j = 0; j < 71; j++){
				grid[i][j].clear();
				dp[i][j].clear();
			}
		}
		
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				char c;
				scanf(" %c", &c);
				if ('0' <= c && c <= '9'){
					grid[i][j] += c;
					dp[i][j] += c;
				}
			}
		}
		
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (grid[i][j].size() == 0) continue;
				if (dp[i][j] == "0") continue;
				if (grid[i][j + 1].size()){
					dp[i][j + 1] = maxstr(dp[i][j + 1], dp[i][j] + grid[i][j + 1]);
				}
				if (grid[i + 1][j].size()){
					dp[i + 1][j] = maxstr(dp[i + 1][j], dp[i][j] + grid[i + 1][j]);
				}
			}
		}
		
		string maxi;
		for (int i = 0; i <= h; i++){
			for (int j = 0; j <= w; j++){
				maxi = maxstr(maxi, dp[i][j]);
			}
		}
		
		cout << maxi << endl;
	}
}

Measured memory_bytes: 1532
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
ll N,X;
vll x,s;
int main(){
  cin>>N>>X;
  rep(i,N){
    ll a;
    cin>>a;
    x.pb(a);
  }
  reverse(x.begin(),x.end());
  s.pb(0);
  rep1(i,x.size()){
    s.pb(s[i-1]+x[i-1]);
  }
  ll res=INFLL;
  rep1(i,N){
    ll temp=0;
    bool f=false;
    temp+=(N+i)*X;
    temp+=s[i]*5;
    if(temp>=res) continue;
    ll j=i+i,k=2;
    while(j<=N){
      temp+=(s[j]-s[j-i])*(2*k+1); 
      if(temp>=res){
	f=true;
	break;
      }     
      k++;
      j+=i;
    }
    if(f) continue;
    temp+=(s[N]-s[j-i])*(2*k+1);
    res=min(res,temp);
  }
  prin(res);
  return 0;
}


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

#define REP(i,a,b) for(int i=a;i<b;i++)

using namespace std;
int main(){

    int total;
    cin>>total;


    string first,second;
    cin>>first>>second;
//    getline(cin,first);


//    getline(cin,second);


    string answer;




    REP(i,0,total)
     {
          answer=answer+first.at(i);
          answer=answer+second.at(i);
     }
     cout<<answer;

}


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


int main(){
	int n,m,h,t=0,p=0;
	string s;
	cin>>n>>m;
	vector<int>a(10000000);
	vector<int>b(10000000);
	for(int i=0;i<n;i++){
		a[i]=0;
		b[i]=0;
	}
	for(int i=0;i<m;i++){
		cin>>h>>s;
		if(a[h-1]==0&&s=="AC"){
			a[h-1]=1;
		}
		if(a[h-1]==0&&s=="WA"){
			b[h-1]++;
		}
	}
	for(int i=0;i<n;i++){
		t+=a[i];
		if(a[i]>0){
			p+=b[i];
		}
	}
	cout<<t<<" "<<p<<endl;
    
    return 0;
}

Measured memory_bytes: 78336
A,B,K=map(int,input().split())
cnt=0
while True:
    if A % 2 == 1:
        A -= 1
    B += A // 2
    A //= 2
    cnt += 1
    if cnt >= K:
        break
    if B % 2 == 1:
        B -= 1
    A += B // 2
    B //= 2
    cnt += 1
    if cnt >= K:
        break
print('{} {}'.format(A,B))

Measured memory_bytes: 9124
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

struct Node {
    using NP = Node*;

    int ma = -1;
    int get(int a, int b) {
        if (b <= 0 or sz <= a) return -1;
        if (a <= 0 and sz <= b) {
            return ma;
        }
        return max(l->get(a, b), r->get(a-sz/2, b-sz/2));
    }
    void set(int k, int x) {
        if (sz == 1) {
            ma = x;
            return;
        }
        if (k < sz/2) {
            l->set(k, x);
        } else {
            r->set(k-sz/2, x);
        }
        ma = max(l->ma, r->ma);
    }
    NP l, r;
    int sz;
    Node(int sz) : sz(sz) {
        if (sz == 1) return;
        l = new Node(sz/2);
        r = new Node(sz - sz/2);
    }
};


int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    int p[n], q[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", p+i); p[i]--;
    }
    for (int i = 0; i < n; i++) {
        q[p[i]] = i;
    }
/*    for (int i = 0; i < n; i++) {
        printf("%d, ", q[i]);
    }
    printf("\n");*/
    Node* rmq = new Node(n);
    int mi[n];
    vector<vector<int>> g(n);
    for (int i = 0; i < n; i++) {
        {
            int v = rmq->get(max(0, q[i]-k+1), q[i]);
            if (v != -1) {
                int qv = q[v];
//                printf("ed %d %d\n", q[i], qv);
                g[q[i]].push_back(qv);
            }
        }
        {
            int v = rmq->get(q[i], min(n, q[i]+k));
            if (v != -1) {
                int qv = q[v];
//                printf("ed %d %d\n", q[i], qv);
                g[q[i]].push_back(qv);
            }
            rmq->set(q[i], i);
        }        
        rmq->set(q[i], i);
    }
/*    Node* rrmq = new Node(n);
    for (int i = n-1; i >= 0; i--) {
        int v = n-1-rrmq->get(max(0, q[i]-k+1), min(n, q[i]+k));
        if (v != n) {
            int qv = q[v];
            printf("ed %d %d\n", qv, q[i]);
            g[qv].push_back(q[i]);
        }
        rrmq->set(q[i], n-1-i);
    }*/

    int deg[n];
    fill_n(deg, n, 0);
    for (int i = 0; i < n; i++) {
        for (int j: g[i]) {
            deg[j]++;
        }
    }
    priority_queue<int> que;
    for (int i = 0; i < n; i++) {
        if (deg[i] == 0) {
            que.push(i);
        }
    }
    vector<int> v;
    while (que.size()) {
        int p = que.top(); que.pop();
        v.push_back(p);
        for (int d: g[p]) {
            deg[d]--;
            if (deg[d] == 0) {
                que.push(d);
            }
        }
    }
    reverse(v.begin(), v.end());
    int ans[n];
    for (int i = 0; i < n; i++) {
//        printf("%d, ", v[i]);
        ans[v[i]] = i+1;
    }
//    printf("\n");
    for (int i = 0; i < n; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 87672
#include<iostream>

using namespace std;

int main(){

	int a,b,c,d,e,f;
	cin >> a>>b>>c>>d;
	e=c-a;
	f=d-b;
	cout << c-f<<" "<< d+e<< " ";
	cout << a-f<< " "<<b+e<< endl;
}

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define mod 1e9 + 7
#define INF 999999999
#define fk first
#define sv second

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

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

#define N 200010

int rN[N], me[N];

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

  int n, m;
  cin >> n >> m;

  int a, b;

  REP (i, m) {
    cin >> a >> b;
    if (a == 1) {
      me[b] = 1;
    } else if (b == n) {
      rN[a] = 1;
    }
  }

  bool f = 0;

  FOR (i, 0, n) {
    if (me[i] == rN[i] && me[i] == 1) {
      f = 1;
    }
  }

  if (f) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }

}



Measured memory_bytes: 1792
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int n,d;
    cin >> n >> d;

    vector<vector<int> > vec(n,vector<int>(d));

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

    double tmp;

    int cnt = 0;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            tmp = 0;
            for(int k=0;k<d;k++){
                if(vec[i][k]!=vec[j][k]){
                    tmp += pow(vec[i][k]-vec[j][k],2);
                }
            }
            tmp = sqrt(tmp);
            if((int)tmp == tmp){
                cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

const char O = '#';
const char F = '.';

class UnionFind {
private:
	int sz;
	vector<int> par, size_;
public:
	UnionFind() {}
	UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1) {
		iota(par.begin(), par.end(), 0);
	}
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return;
		if (size_[x] < size_[y]) swap(x, y);
		par[y] = x;
		size_[x] += size_[y];
	}
	int size(int x) {
		x = find(x);
		return size_[x];
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};


int main(void) {
	int H, W;
	cin >> H >> W;
	vec<string> MAP(H);

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

	vec<UnionFind> uW(H, UnionFind(W));
	vec<UnionFind> uH(W, UnionFind(H));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W - 1; ++j) {
			if (MAP[i][j] == F && MAP[i][j + 1] == F) {
				uW[i].unite(j, j + 1);
			}
		}
	}

	for (int j = 0; j < W; ++j) {
		for (int i = 0; i < H - 1; ++i) {
			if (MAP[i][j] == F && MAP[i + 1][j] == F) {
				uH[j].unite(i, i + 1);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (MAP[i][j] == O)continue;
			int sum = uH[j].size(i) + uW[i].size(j);
			ans = max(ans, sum);
		}
	}

	cout << ans - 1 << endl;
	return 0;

}

Measured memory_bytes: 67328
import sys
from bisect import bisect_right

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


N, D, A = MI()
monsters = list()
for i in range(N):
    x, h = MI()
    monsters.append((x, (h + A - 1) // A))
monsters.sort()

X = [x for x, h in monsters]
ub = [0] * N
for i, x in enumerate(X):
    ub[i] = bisect_right(X, x + 2 * D)

dmg = [0] * N
accum = 0
ans = 0
for i, (x, h) in enumerate(monsters):
    h = h - max(0, accum + dmg[i])
    if h > 0:
        ans += h
        dmg[i] += h
        if ub[i] < N:
            dmg[ub[i]] -= h
    accum += dmg[i]
print(ans)


Measured memory_bytes: 75356
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
const int MAX_N=5;
const int BINS=13;
int main(){ _;
  int a[MAX_N];
  int b[BINS+1];
  while(scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4])!=-1){
    REP(i,BINS+1) b[i]=0;
    REP(i,MAX_N) b[a[i]-1]++;
    b[13]=b[0];
    for(int i=0;i<BINS;i++)
      if(b[i]==4){
	cout<<"four card"<<endl;
	goto NEXT;
      }
    for(int i=0;i<BINS;i++)
      for(int j=0;j<BINS;j++)
	if(b[i]==2&&b[j]==3){
	  cout<<"full house"<<endl;
	  goto NEXT;
	}
    for(int i=0;i<10;i++)
      if(b[i]==1&&b[i+1]==1&&b[i+2]==1&&b[i+3]==1&&b[i+4]==1){
	cout<<"straight"<<endl;
	goto NEXT;
      }
    for(int i=0;i<BINS;i++)
      if(b[i]==3){
	cout<<"three card"<<endl;
	goto NEXT;
      }
    for(int i=0;i<BINS;i++)
      for(int j=0;j<BINS;j++)
	if(i!=j&&b[i]==2&&b[j]==2){
	  cout<<"two pair"<<endl;
	  goto NEXT;
	}
    for(int i=0;i<BINS;i++)
      if(b[i]==2){
	cout<<"one pair"<<endl;
	goto NEXT;
      }
    cout<<"null"<<endl;
  NEXT:;
  }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
    auto c3 = [](const P &a, const P &b, const P &c){
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b){
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c){
        return norm(a - c.pnt) <= c.rad*c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

int main(){
     srand(time(0));
     int n;
     cin >> n;
     vector<P> ps(n);
     for(int i = 0; i < n; ++i){
         ld x,y;
         cin >> x >> y;
         ps[i] = P(x,y);
     }
    printf("%.7lf\n", (double)smallest_enclosing_disc(ps).first);
 }

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

int main(int argc, const char * argv[]) {
    int H, W;
    cin >> H >> W;
    vector<string> v(H), V(H);
    string s0, s1 = "";
    for (int i = 0; i < W; i++) {
        s1 += '.';
    }
    for (int i = 0; i < H; i++) {
        cin >> s0;
        v[i] = s0;
        V[i] = s1;
    }
    /*
    for (int i = 0; i < H; i++) {
        //cout << v[i] << endl;
        cout << V[i] << endl;
    }
     */
    bool flag = true;
    int dy[4] = {-1, 0, 0, 1};
    int dx[4] = {0, -1, 1, 0};
    for (int i = 0; i < H && flag; i++) {
        for (int j = 0; j < W && flag; j++) {
            int cnt = 0, cnt1 = 0;
            if (v[i][j] == '#') {
                cnt1++;
            }
            for (int k = 0; k < 4; k++) {
                if (i+dy[k] < H && j+dx[k] < W && i+dy[k] >= 0 && j+dx[k] >= 0) {
                    if (v[i+dy[k]][j+dx[k]] == '#') {
                        cnt1++;
                    }
                }
            }
            //cout << cnt1 << endl;
            if (v[i][j] == '#') {
                if (cnt1 >= 2) {
                    if (v[i][j] == '#' && V[i][j] == '.') {
                        cnt++;
                        V[i][j] = '#';
                    }
                    for (int k = 0; k < 4 && cnt < 2; k++) {
                        if (i+dy[k] < H && j+dx[k] < W && i+dy[k] >= 0 && j+dx[k] >= 0) {
                            if (v[i+dy[k]][j+dx[k]] == '#' && V[i+dy[k]][j+dx[k]] == '.') {
                                V[i+dy[k]][j+dx[k]] = '#';
                                cnt++;
                            }
                        }
                    }
                }
            }
            
            /*
            for (int i = 0; i < H; i++) {
                //cout << v[i] << endl;
                cout << V[i] << endl;
            }
            cout << endl;
            */
        }
    }
    
    for (int i = 0; i < H && flag; i++) {
        if (v[i] != V[i]) {
            flag = false;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

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

using namespace std;
using ll = long long;

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

	bool ok = false;
	for (int i = 0; i < s.size() - 1; ++i) {
		if (s.substr(i, 2) == "AC") { ok = true; }
	}

	if (ok) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int num = 0;
		int money = 0;
		int money1 = 0;
		int money2 = 0;
		int money3 = 0;

		for (int i = 0; i < a + 1; i++) {
			money1 = i * 500;
			money = money +money1;
			for (int j = 0; j < b + 1; j++) {
				money2 = j * 100;
				money = money1 + money2;
				for (int k = 0; k < c + 1; k++) {
					money3 = k * 50;
					money = money1 + money2 + money3;
					if (money == x) {
						num++;
					}
					money = 0;
				}
			}
		}

		System.out.println(num);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
bitset<4000002> dp;
int main()
{
    int n;
    cin>>n;
   dp[0]=1;
    int a[n],s=0;
    for(int i=0;i<n;i++)
    {
      int x;
        cin>>x;
      s+=x;
        dp|=(dp<<x);
    }
    int j=0;
    for(j=(s+1)/2;j<=s;j++)
    {
        if(dp[j])
            break;
    }
    cout<<j<<"\n";
    return 0;
}


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

int main() {

    int X;
    cin >> X;

    if (X < 600) cout << 8 << endl;
    else if (X < 800) cout << 7 << endl;
    else if (X < 1000) cout << 6 << endl;
    else if (X < 1200) cout << 5 << endl;
    else if (X < 1400) cout << 4 << endl;
    else if (X < 1600) cout << 3 << endl;
    else if (X < 1800) cout << 2 << endl;
    else if (X < 2000) cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 3484
#include<iostream>
using namespace std;
//26545
int main(){
	//56256157425641241643461564
	int a,b,c,d,s1,s2;
	cin>>a>>b>>c>>d;//121210000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
	s1=a*b;
	s2=c*d;
	if(s2>s1){
		swap(s1,s2);
	}
	cout<<s1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int q,n;
  cin>>n>>q;
  string s;
  cin>>s;
  int c[n],pre[n];
  c[0]=0;
  pre[0]=0;
  rep(i,1,n){
    c[i]=0;
    if(s[i]=='C' && s[i-1]=='A'){
      c[i]=1;
    }
    pre[i]=pre[i-1]+c[i];
    // cout<<pre[i]<<" ";
  }
  // cout<<endl;
  // cout<<pre[7]<<endl;
  while(q--){
    int l,r;
    cin>>l>>r;
    l--,r--;
    int ans=pre[r];
    // cout<<pre[r]<<endl;
    // cout<<ans<<endl;
    if(l>=1) ans-=pre[l-1];
    if(c[l]==1) ans--;
    cout<<ans<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 4528