akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod ll(1e9+7)
void solve(){
	ll a,b;
	char op;
	cin>>a>>op>>b;
	if(op=='-'){
		cout<<a-b<<endl;
	}
	else{
		cout<<a+b<<endl;
	}
}


int main(){
	solve();
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int, input().split()))
B=sorted(A)
for i in range(n+1):
  if B[i]!=i+1:
    a=i
    break
d=[i for i, x in enumerate(A) if x==a]
x=d[0]
y=d[1]

def cmb(n,r,mod):
    if (r<0 or r>n):
      return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod

mod=10**9+7 #出力の制限
N=10**5+10
g1=[1,1] # 元テーブル
g2=[1,1] #逆元テーブル
inverse=[0,1] #逆元テーブル計算用テーブル

for i in range(2,N+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

for i in range(1,n+2):
  ans=cmb(n+1,i,mod)-cmb(x+(n-y),i-1,mod)
  if ans<0:
    print(mod+ans)
  else:
    print(ans)


Measured memory_bytes: 22944
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
char str[1100][5];
long long mod=1000000007;
vector<int>g[1100];
long long dp[1100];
long long calc(int a){
	for(int i=0;i<g[a].size();i++)calc(g[a][i]);
	if(str[a][0]=='E'){
		long long ret=1;
		for(int i=0;i<g[a].size();i++)ret=ret*dp[g[a][i]]%mod;
		if(str[a][1]=='?')ret=(ret+1)%mod;
		return dp[a]=ret;
	}
	if(str[a][0]=='R'){
		long long ret=1;
		for(int i=0;i<g[a].size();i++)ret=ret*(dp[g[a][i]]+1)%mod;
		if(str[a][1]!='?')ret=(ret+mod-1)%mod;
		return dp[a]=ret;
	}
	long long ret=0;
	for(int i=0;i<g[a].size();i++)ret=(ret+dp[g[a][i]])%mod;
	if(str[a][1]=='?')ret=(ret+1)%mod;
	return dp[a]=ret;
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%s",str[i]);
	}
	for(int i=0;i<a-1;i++){
		int s,t;scanf("%d%d",&s,&t);s--;t--;
		g[s].push_back(t);
	}
	printf("%lld\n",calc(0));
	//for(int i=0;i<a;i++)printf("%lld\n",dp[i]);
}

Measured memory_bytes: 1120
#include<iostream>
using namespace std;
int main()
{
	float n,a=1,b,ba=0;
	cin>>n;
	for(int t=0;t<n;t++)
	{
		cin>>b;
		a=1/b;
		ba=ba+a;
	}
	cout<<1/ba;
	return 0;
} 

Measured memory_bytes: 256
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()

lr = 0
rl = 0
cnt = 0
for i in range(N):
    if i >= 1:
        if S[i] == S[i - 1] == 'L':
            cnt += 1
        if S[i] == 'R' and S[i - 1] == 'L':
            lr += 1
        if S[i] == 'L' and S[i - 1] == 'R':
            rl += 1
    if i <= N - 2:
        if S[i] == S[i + 1] == 'R':
            cnt += 1

op = min(lr, rl, K)
print(cnt + op * 2 + min(max(lr, rl) - op, (K - op)))

Measured memory_bytes: 41584
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;


int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (b - a > x ) cout << "dangerous" << endl;
	else if (b - a > 0)cout << "safe" << endl;
	else cout << "delicious" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctype.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    Int n, h, w;
    cin >> n >> h >> w;
    dump((n-h+1)*(n-w+1));
    return 0;  
}


Measured memory_bytes: 256
N, M = map(int,input().split())
KA = [list(map(int,input().split())) for i in range(N)]

dic = {}

for i in range(N):
  for j in range(len(KA[i])-1):
    if KA[i][1+j] not in dic.keys():
      dic[KA[i][1+j]] = 1
    else:
      dic[KA[i][1+j]] += 1
      
ans = 0

for i in dic:
  if dic[i] == N:
    ans += 1
    
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

struct LIST{
	int next_value,pre_value;
};
LIST info[NUM]; //★★インデックスではなく値基準★★

int main(){

	int N,num_query;
	scanf("%d %d",&N,&num_query);

	if(N == 1){
		printf("1\n");
		return 0;
	}

	int head,tail;
	int pre,tmp;

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

		scanf("%d",&tmp);
		//連結リストではなく、片方向リストにする

		if(i == 0){

			head = tmp;
			info[tmp].pre_value = -1;

		}else if(i == N-1){

			tail = tmp;
			info[tmp].pre_value = pre;
			info[pre].next_value = tmp;
			info[tmp].next_value = -1;

		}else{

			info[tmp].pre_value = pre;
			info[pre].next_value = tmp;
		}
		pre = tmp;
	}

	int mid_value,next_head,next_tail;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d",&mid_value); //中央の★値★を取得

		if(mid_value == head){

			info[tail].next_value = mid_value;
			info[mid_value].pre_value = tail;
			head = info[mid_value].next_value;
			tail = mid_value;

		}else if(mid_value == tail){

			info[mid_value].next_value = head;
			info[head].pre_value = mid_value;
			tail = info[mid_value].pre_value;
			head = mid_value;

		}else{

			next_head = info[mid_value].next_value;
			next_tail = info[mid_value].pre_value;

			info[mid_value].next_value = head;
			info[head].pre_value = mid_value;
			info[mid_value].pre_value = tail;
			info[tail].next_value = mid_value;

			head = next_head;
			tail = next_tail;
		}

		info[head].pre_value = -1;
		info[tail].next_value = -1;
	}

	printf("%d",head);
	pre = head;
	int count = 1,next;

	while(count < N){
		next = info[pre].next_value;
		printf(" %d",next);
		count++;
		pre = next;
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 4016
# abc109d
import copy

H,W = map(int,input().split())
a = []
for i in range(H):
    a.append(list(map(int,input().split())))

a_cp = copy.deepcopy(a)

itr = 0
for i in range(H):
    for j in range(W-1):
        if a_cp[i][j]%2==1:
            itr+=1
            a_cp[i][j]-=1
            a_cp[i][j+1]+=1

for i in range(H-1):
    j = W-1
    if a_cp[i][j]%2==1:
        itr+=1
        a_cp[i][j]-=1
        a_cp[i+1][j]+=1

print(itr)
for i in range(H):
    for j in range(W-1):
        if a[i][j]%2==1:
            print(i+1,j+1,i+1,j+2)
            a[i][j]-=1
            a[i][j+1]+=1

for i in range(H-1):
    j = W-1
    if a[i][j]%2==1:
        print(i+1,j+1,i+2,j+1)
        a[i][j]-=1
        a[i+1][j]+=1       

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

    int w,a,b,t;
    scanf("%d%d%d",&w,&a,&b);
    if(a>b)
    {
        t=a;
        a=b;
        b=t;
    }
    a=a+w;
    if(a>b)
        printf("0");
    else
        printf("%d",b-a);
    return 0;
}


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

using ll = long long;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b(n);
    rep(i, n) b[a[i] - 1] = i + 1;
    rep(i, n) cout << b[i] << endl;
    return 0;
}

Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
const ll MOD = 1000000007;
const int MAX = 1000100;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  COMinit();
  ll x,y;cin >>x >> y;
  if((x+y)%3!=0){
    cout<<0 << endl;
    return 0;
  }
  ll num = (x+y)/3;
  x -= num;
  y -= num;
  cout << COM(x+y,x) << endl;


}

Measured memory_bytes: 23680
package main

import(
    "bufio"
    "fmt"
    "os"
)

var r = bufio.NewReader(os.Stdin)

func main(){
    
    var S int
    fmt.Fscan(r, &S)
    
    s := S%60
    M := S/60
    m := M%60
    h := M/60
    
    fmt.Printf("%v:%v:%v\n",h,m,s)
}



Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int64_t func(int64_t x,int64_t y){
  return y-y/x;
}
int main() {
  int64_t A,B,C,D;
  cin>>A>>B>>C>>D;
  int64_t l=C*D/__gcd(C,D);
  cout<<func(C,B)-func(C,A-1)+func(D,B)-func(D,A-1)-(func(l,B)-func(l,A-1))<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>

int main(){
  int *A;
  int i,n,v,j,k;


  scanf("%d",&n);
  
  A  = (int *)malloc(n * sizeof(int));
  
  
  for(i=0;i<n; i++) scanf("%d",&A[i]);
  
  
  for(i=0; i<n; i++){
  
    v = A[i];
    j = i-1;
    while(j >=0 && A[j] > v){
      A[j+1] = A[j];
	j--;
    }
   A[j+1] =v;

	
   for(k=0;k<n; k++){
	  printf("%d",A[k]);
	  if(k<n-1)printf(" ");
	    }
   printf("\n");
  
	
    }

    free(A);
    return 0;
  }

    



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a) (a).begin(), (a).end()

const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T &r, T &l)
{
    T tmp = r;
    r = l;
    l = tmp;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
    return is;
}


// 1 2 3 3 2

int main()
{
    ll n;
    cin >> n;
    vector<ll> h(n);
    cin >> h;


    bool ans = true;

    for (ll i = n-1; i > 0; i--){
        cerr << h[i] <<endl;
        if (h[i] >= h[i-1]){

        }else if (h[i] >= h[i-1]-1){
            h[i-1]--;
        }else{
            // cerr << i << "  " << h[i] <<"  :" << h[i-1]<<endl;
            ans = false;
        }

    }

    cout << ((ans==true)?"Yes":"No");
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//配列,座標
/*array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
array<int, 4>dir_x2 = { 0,0,1,-1 };
array<int, 4>dir_y2 = { 1,-1,0,0 };
char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };*/

//Union Find
/*class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};*/

//最大公約数,最小公倍数
/*LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}*/

//組み合わせ
long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}

//素数判定
/*bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}*/

//桁数
/*LLI GetDigit(LLI num) {
	LLI digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}*/

//サンプル
/*const int n_max = 8;
array<array<bool, n_max>, n_max>graph;
int dfs(int v,int N,array<bool,n_max>visited) {
	int ret = 0;
	bool all_visited = true;
	for (int i = 0; i < N;i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (int i = 0; i < N;i++) {
		if (graph[v][i] == false) {
			continue;
		}
		if (visited[i] == true) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i,N,visited);
		visited[i] = false;
	}
	return ret;
}*/

//サンプル
/*vector<vector<int>>sub;
int dfs(int id) {
	if (sub[id].size() == 0) {
		return 1;
	}
	int minP = (int)1e9;
	int maxP = 0;
	for (int i : sub[id]) {
		int P = dfs(i);
		minP = min(minP, P);
		maxP = max(maxP, P);
	}
	return minP + maxP + 1;
}*/

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl
//cout << "Yes" << endl;
//cout << "No" << endl;



int main(void) {
	LLI N, M,res = 0;
	cin >> N >> M;
	res += nCr(N,2);
	res += nCr(M,2);
	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define loop(vals,times) for(vals=0;vals<times;vals++)
#define reg(time) for(int val=0;val<time;val++)
#define space <<" "<<
using namespace std;

int main()
{
    int q,c,x;
    string key;
    map<string,int> M;
    
    cin>>q;
    reg(q){
    cin>>c>>key;
        if(c==0){
            cin>>x;
            M[key]=x;
        }
        if(c==1)cout<<M[key]<<endl;
        if(c==2)M.erase(key);
    }
}



Measured memory_bytes: 27828
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		double[] X = new double[N];
		double[] Y = new double[N];
		int count = 0;

		for(int i = 0; i < N; i ++){
			X[i] = sc.nextInt();
			Y[i] = sc.nextInt();
			if(Math.sqrt(X[i] * X[i] + Y[i] * Y[i]) <= D){
				count ++;
			}
		}
		System.out.println(count);

	}
}

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

int main (void) {
  int X, A, B, C, ans = 0;
  cin >> A >> B >> C >> X;
  for(int i = 0; i <= A; i++) {
    for(int j = 0; j <= B; j++) {
      for(int k = 0; k <= C; k++) {
        if (500*i + 100*j + 50*k == X) {
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool flag = true;
    if (a > b) std::swap(a, b);
    if (a > c) std::swap(a, c);
    if (b > c) std::swap(b, c);
    if ((a == b && b != c) || (a != b && b == c)) flag = false;
    if (flag) puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 256
def G(x,y):
    if(x<y):
        x,y=y,x
    if(y==0):
        return x
    return G(y,x%y)


a,b,c,d=map(int,input().split())
ans=0
# print(a,b,c,d,b//c,a//c)
ans+=(b//c-a//c+(a%c==0))
# print(ans)
ans+=(b//d-a//d+(a%d==0))
# print(ans)
lcm=c*d//G(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)

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

int main(void)
{
    int M,N;
    int money;

    cin >> M;
    vector<string> s(M);
    for(int i=0;i<M;i++){
        cin >> s.at(i);
    }
    cin >> N;
    vector<string> t(N);
    for(int i=0;i<N;i++){
        cin >> t.at(i);
    }

    vector<string> b = {s.at(M-1)};
    vector<int>    b_count = {1};
    s.pop_back();
    bool flag;
    for(int i=M-2;i>=0;i--)
    {

        flag = true;
        for(int l=0;l<b.size();l++)
        {
            if(b.at(l) == s.at(i))
            {
                b_count[l]++;
                s.pop_back(); 
                flag = false;
                break;
            }
        }
        if(flag)
        {
            b.push_back(s.at(i)); 
            b_count.push_back(1);
            s.pop_back();
        }
    }

    for(int i=0;i<N;i++)
    {
        for(int l=0;l<b.size();l++)
        {
            if(b.at(l) == t.at(i))
            {
                b_count[l]--;
            }
        }
    }

    int max = 0;
    for(int i=0;i<b_count.size();i++)
    {
        if(max < b_count.at(i)) max = b_count.at(i);
    }
    cout << max;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split()))
mod = 998244353
mN = max(D)
count = [0] * (mN + 1)
for i in range(N):
    count[D[i]] += 1
if count[0] != 1 or D[0] != 0:
    print(0)
elif mN == 0:
    print(1)
else:
    ans = 1
    for i in range(1, len(count)):
        if count[i]:
            ans = (ans * (count[i - 1] ** count[i])) % mod
        else:
            print(0)
            exit()
    print(ans)


Measured memory_bytes: 13908
#import<stdio.h>
int main()
{
	long long n,h=0;
	scanf("%lld",&n);

       int a;
       a=n/500;
       h=a*1000;
       n=n%500;
       a=n/5;
       h=h+a*5;
       printf("%lld",h);
       
       }



Measured memory_bytes: 128
import java.util.*;

public class Main {
    static long mod = 1000000007;

    static class Hand {
        int b, c;
        public Hand(int b, int c) {
            this.b = b;
            this.c = c;
        }
        public String toString() {
            return String.format("(%d, %d)", b, c);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Integer[] lis = new Integer[n];
        Hand[] hands = new Hand[m];

        for (int i = 0; i < n; ++i) {
            lis[i] = sc.nextInt();
        }
        for (int i = 0; i < m; ++i) {
            int b = sc.nextInt();
            int c = sc.nextInt();
            hands[i] = new Hand(b, c);
        }

        Arrays.sort(lis, new Comparator<Integer>() {
            public int compare(Integer a, Integer b) {
                return a - b;
            }
        });
        Arrays.sort(hands, new Comparator<Hand>() {
            public int compare(Hand a, Hand b) {
                return b.c - a.c;
            }
        });

        long sum = 0;
        int i = 0;
        int j = 0;
        while (i < n) {
            if (j < m) {
                if (lis[i] >= hands[j].c) {
//                    System.out.println(String.format("add: lis[%d], %d => %d", i, lis[i], sum + lis[i]));
                    sum += lis[i++];
                } else {
                    for (int k = 0; k < hands[j].b && i < n; ++k) {
                        if (lis[i] >= hands[j].c) {
                            break;
                        }

                        sum += hands[j].c;
                        i += 1;
                    }
                    j++;
//                     long x = Math.min(n - i, hands[j].b);
// //                    System.out.println(String.format("add: lis[%d]: %d, hand[%d]:%s => %d", i, lis[i], j, hands[j].toString(), sum + hands[j].c * x));
//                     sum += hands[j].c * x;
//                     i += x;
//                     j++;
                }
            } else {
//                System.out.println(String.format("add: lis[%d], %d => %d", i, lis[i], sum + lis[i]));
                sum += lis[i++];
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 98436
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
	int m,n;
	scanf("%d%d",&m,&n);
	
	if(m*10000<n){
		printf("-1 -1 -1");
		return 0;
	}
	if(m*1000>n){
		printf("-1 -1 -1");
		return 0;
	}
	if(n%1000!=0){
		printf("-1 -1 -1");
		return 0;
	}
	for(int i=0;i<=m;i++)
	 for(int j=0;j<=m;j++)
	  for(int k=0;k<=m,i+j+k<=m;k++)
	   {
	   		if(i+j+k==m && i*1000+j*5000+k*10000==n)
	   		{
	   			printf("%d %d %d",k,j,i);
				return 0;	
			}
	   }
	printf("-1 -1 -1");
	return 0;
}

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

int main() {
  int W, H, x, y ,r;
  cin >> W >> H >> x >> y >> r;

  if (x >= r && x <= (W - r) && y >= r && y <= (H - r)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3104
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words1, words2;
        int wordl,result,score1=0,score2=0;
        int n=scan.nextInt();
        
        for(int i=0; i<n; i++){
            result=0;
            words1=scan.next();
            words2=scan.next();
            
            wordl=Math.min(words1.length(), words2.length());
            for(int j=0; j<wordl; j++){
                if(words1.substring(j,j+1).compareTo(words2.substring(j,j+1))!=0){
                    result=words1.substring(j,j+1).compareTo(words2.substring(j,j+1));
                    break;
                }
            }
            if(result>0)score1+=3;
            else if(result==0){
                if(words1.length()>words2.length())score1+=3;
                else if(words1.length()<words2.length())score2+=3;
                else{
                    score1++;
                    score2++;
                }
            }else score2+=3;
        }
        System.out.println(score1+" "+score2);
    }
}


Measured memory_bytes: 29696
#include<cstdio>
int main()
{
	int m,n;
	scanf("%d%d",&m,&n);
	int a[205];
	a[0]=0;
	a[1]=0;
	a[2]=1;
	for(int i=3;i<205;i++)
	a[i]=a[i-1]+i-1;
	printf("%d\n",a[m]+a[n]);
}

Measured memory_bytes: 128
import math
n,m = map(int,input().split())	
r = m
k = 0
a = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]
for i in range(len(a)):
    if m%a[i] == 0 and m >= a[i]:
        r = m//a[i]
        break
if r == m and m >= 199:
    r = m//199
if n > r:
    k = 1

while n <= r :
    if m % n == 0:
        break
    n += 1
if n == r + 1 or k == 1:
    print(1)
else:
    print(m//n)

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

int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;
	int ans = 2 * n;
	for (int i = 1;i <= n;i++) {
		if (s.substr(n - i, i) == t.substr(0, i)) {
			ans = 2 * n - i;
		}
	}
	cout << ans << endl;
}

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

namespace ConsoleApplication11 {
    class Program {
        static void Main(string[] args) {
            new Program().solve();
        }

        void solve() {
            while (true) {
                int length_Series = int.Parse(Console.ReadLine());
                if (length_Series == 0) return;
                string input = Console.ReadLine();
                int[] int_Input = new int[length_Series];
                for (int i = 0; i < length_Series; i++) {
                    int_Input[i] = int.Parse(input.Split(' ')[i]);
                }
                List<string> course = playGame(int_Input);
                for (int i = 0; i < course.Count; i++) {
                    Console.WriteLine(course[i]);
                }
            }
        }

        List<string> playGame(int[] series) {
            List<string> course = new List<string>();
            int stone_Rest = 32;
            int turn = 0;

            while (stone_Rest > 0) {
                stone_Rest -= (stone_Rest - 1) % 5;
                course.Add(stone_Rest.ToString());
                if (stone_Rest == 0) {
                    break;
                }
                int i = 0;
                while (true) {
                    if (turn % series.Length == i) {
                        if (stone_Rest < series[i]) {
                            stone_Rest = 0;
                        } else stone_Rest -= series[i];
                        course.Add(stone_Rest.ToString());
                        break;
                    }
                    i++;
                }
                turn++;
            }
            return course;
        }

    }
}

Measured memory_bytes: 9124
i = [int(i) for i in input().split()]
N = i[0]
Y = i[1]

# 10000*N - Y = 5000*y + 9000*z
# 10*N - Y/1000 = 5*y + 9*z
sum = 10*N - Y/1000
for y in range(N+1):
    for z in range(N-y+1):
        if sum == 5*y + 9*z:
            print(str(N-y-z) + " " + str(y) + " " + str(z))
            exit()
print("-1 -1 -1")

Measured memory_bytes: 65164
h,w=map(int,input().split())
for i in zip(*[i for i in zip(*[i for i in [input() for i in range(h)] if '#' in i]) if '#' in i]):
    print(''.join(i))

#1 1番内側の処理 [input() for i in range(h)] で1行ごとに文字列としてリストに格納
#2 [i for i in [#1] if '#' in i] で内側のリストに格納した要素で"#"を含むものを i に格納する (ここはリストの展開)
#3 [i for i in zip(#2) if "#" in i] #2で作成したリストを要素の先頭、2番目...のように
#縦で構成された要素を集めたリストに作り替える、この際"#"を含まないものは除かれる(ifの部分)
#4 [i for i in zip(#3)] を行うことによって縦横の入れ替わったリストをもう一度入れ替える(元に戻す)


Measured memory_bytes: 9172
#include<iostream>
#include<string>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#include<iomanip>

using namespace std;


int main() {
	int i,n,a,b;
	int box[6] = {};
	string str1,str2;
	for (i = 0; i < 6; i++) {
		cin >> box[i];
	}
	cin >> n;

	for (i = 0;i<n;i++) {
		cin >> a >> b;
		if ((a == box[0] && b == box[1]) || (a == box[1] && b == box[5]) || 
			(a == box[5] && b == box[4])|| (a == box[4] && b == box[0])) { std::cout << box[2] << endl; }
		else if ((a == box[1] && b == box[0])|| (a == box[5] && b == box[1])||
			(a == box[4] && b == box[5])|| (a == box[0] && b == box[4])) { std::cout << box[3] << endl; }
		else if ((a == box[2] && b == box[1])|| (a == box[1] && b == box[3])||
			(a == box[3] && b == box[4])|| (a == box[4] && b == box[2])) { std::cout << box[5] << endl; }
		else if ((a == box[1] && b == box[2])|| (a == box[2] && b == box[4])||
			(a == box[4] && b == box[3])|| (a == box[3] && b == box[1])) { std::cout << box[0] << endl; }
		else if ((a == box[0] && b == box[2]) || (a == box[2] && b == box[5]) ||
			(a == box[5] && b == box[3]) || (a == box[3] && b == box[0])) {
			std::cout << box[4] << endl;
		}
		else if ((a == box[0] && b == box[3]) || (a == box[3] && b == box[5]) ||
			(a == box[5] && b == box[2]) || (a == box[2] && b == box[0])) {
			std::cout << box[1] << endl;
		}
	}

	return 0;
}



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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int a, b; cin >> a >> b;
	int ret = 0;
	int c = 1;
	while(!(c>=b)) {
		c += a - 1;
		ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
//#define ACL
#ifdef ACL
#include <atcoder/all>
using namespace atcoder;
#endif
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
using LD = long double;
using VI = vector<int>;
using VVI = vector<vector<int> >;
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T> >;
template <typename T> using VVV = vector<vector<vector<T> > >;
void print() {cout << endl;}
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <typename T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <typename T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> void SORT (T &v) {sort(v.begin(), v.end());}
template <typename T> void SORTR (T &v) {sort(v.begin(), v.end(), greater<>());}
template <typename T> T GCD(T x,T y) {return __gcd(x,y);}
template <typename T> T LCM(T x,T y) {return x/__gcd(x,y)*y;}
template <typename T> int SZ(T v) {return v.size();}
template <typename T> T PCNT(T x) {return __builtin_popcountll(x);}
template <typename T> T BIT(T x) {return 1LL<<(x);}
int INF = 2000000000;
long double PI = acosl(-1);
int MOD = 1000000007;


int32_t main() {
    chrono::system_clock::time_point start_time, end_time;
    start_time = chrono::system_clock::now();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0, res = 0;
    
    string S;
    cin >> S;
    if (S[S.length()-1] == 's') S += "es";
    else S += 's';
    cout << S << endl;

    
    



    end_time = chrono::system_clock::now();
    assert(chrono::duration_cast<chrono::milliseconds>(end_time-start_time).count() < 2500);
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc179/abc179_a && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc179/abc179_a && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc179/abc179_a && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3648
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim X As Integer = NextInt()

        Dim min_m As Integer = Integer.MaxValue
        Dim ans As Integer

        For i As Integer = 0 To N - 1
            Dim m As Integer = NextInt()
            X -= m
            min_m = Math.Min(min_m, m)
            ans += 1
        Next

        ans += X \ min_m
        WriteLine(ans)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 19920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b;
	cin>>a>>b;
	ll l=a*a-b*b;
	ll r=2*a-2*b;
	if(l%r==0){
		cout << l/r;
	}
	else{
		cout << "IMPOSSIBLE";
	}
	// your code goes here
	return 0;
}

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


int main(void){
  int N, A, B;
  cin >> N;
  A = N / 4 + 1;
  B = N / 7 + 1;
  int count = 0;
  for(int i = 0; i < A; i++){
    for(int j = 0; j < B; j++){
      if(4 * i + 7 * j == N){
        cout << "Yes";
        return 0;
      }
    }
  }
    cout << "No";
 return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a, b;
	bool flag = 0;
	a = n / 1.08;
	rep(i, 0, 10) {
		int x = (a + i) * 1.08;
		if (n == x) {
			cout << a + i << endl;
			flag = true;
			break;
		}
	}
	if(!flag)cout << ":(" << endl;

}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int a[200005];
int main()
{
	ll n;cin>>n;
	ll sum=0;
	for (int i = 0; i < n; i++)
	{
		cin>>a[i],sum^=a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cout<<(sum^a[i])<<" ";
	}
	return 0;
}



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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n, k, q;
  cin >> n >> k >> q;
  vll point(n, 0);
  REP(i, q) {
    ll p;
    cin >> p;
    point[p - 1]++;
  }
  REP(i, n) {
    if (point[i] + k - q < 1) {
      COUT("No");
    }
    else {
      COUT("Yes");
    }
  }
}


int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*
6 3 4
3
1
3
2
*/


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
int a,b,c;
cin>>a>>b>>c;
int x=c;
for(int z=0;z<10;z++){
    x=(a*x)-b;
    cout<<x<<endl;
}


    return 0;
}


Measured memory_bytes: 256
n = int(input())
if n%2 == 0:
  print(n,n,n//2)
else:
  for h in range(max(2, n//4),3501):
    for l in range(max(2, n//4),3501):
      m = n*h*l
      c = 4*h*l - n*(h+l)
      if c > 0 and m%c == 0:
        w = m//c
        print(h,l,w)
        exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i;
    cin>>n;

    long long sum=0;
    for(int i=0; i<=n; i++)
    {
        if(i%3!=0 && i%5!=0)
            sum=sum+i;
    }

    cout<<sum<<endl;

}


Measured memory_bytes: 3596
/* #                          */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/

void sol() {

}

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);

    string s; cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) cout << "No\n";
    else cout << "Yes\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,k;
    cin >> n >> k;
    ll a[n],c=1;
    for (ll i=0;i<n;i++){
        cin >> a[i];
    }
    for (ll i=k;i<n;i++){
        if (a[i]>a[i-k]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


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

int main()
{

	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << a[1] - a[0] + a[2] - a[1] << "\n";
	 
	return 0;
}

Measured memory_bytes: 3640
import sys
def S(): return sys.stdin.readline().rstrip()

N,M = map(int,S().split())
AB = []
C = []
for _ in range(M):
    AB.append(tuple(int(i) for i in S().split()))
    C.append(sum(1<<(int(i)-1) for i in S().split()))

dp = [10**8+1]*(1<<N)
dp[0] = 0

for i in range(1<<N):
    for j in range(M):
        a,b = AB[j]
        c = C[j]
        dp[i|c] = min(dp[i|c],dp[i]+a)

if dp[-1] == 10**8+1:
    print(-1)
else:
    print(dp[-1])

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<string> blue(n);
  for (int i = 0; i < n; i++) {
    cin >> blue[i];
  }
  int m;
  cin >> m;
  vector<string> red(m);
  for (int i = 0; i < m; i++) {
    cin >> red[i];
  }
  int max_ans = 0;
  for (int i = 0; i < n; i++) {
    string str = blue[i];
    int ans = 0;
    for (int j = 0; j < n; j++) {
      if (str == blue[j]) ans++;
    }
    for (int j = 0; j < m; j++) {
      if (str == red[j]) ans--;
    }
    max_ans = max(max_ans, ans);
  }
  cout << max_ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
int main() {
	string s;
	cin >> s;
	set<char> a;
	for (auto c : s) {
		a.insert(c);
	}
	cout << (a.size() == 2 ? "Yes" : "No") << endl;
}

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

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

int main(){
  double a,b;
  cin>>a>>b;
  double pi = 4*atan(1.0);
  double ans = 4.0/3.0*pi*b*b*b;
  printf("%.9f\n",ans);
  return 0;
}



Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
// #define int long long
using namespace std;
typedef pair<int, int> P;

const int mod = 100000;

signed main(){
    int w, h;
    while(1){
        cin >> w >> h;
        if(w + h == 0) break;
        int dp[110][110][4] = {0};
        dp[0][1][2] = 1;
        dp[1][0][0] = 1;
        rep(i, 0, h){
            rep(j, 0, w){
                if(i == 0 && j == 0) continue;
                if(i != h - 1){
                    dp[i + 1][j][0] = (dp[i + 1][j][0] + dp[i][j][0] + dp[i][j][1]) % mod;
                    dp[i + 1][j][1] = (dp[i + 1][j][1] + dp[i][j][2]) % mod;
                }
                if(j != w - 1){
                    dp[i][j + 1][2] = (dp[i][j + 1][2] + dp[i][j][2] + dp[i][j][3]) % mod;
                    dp[i][j + 1][3] = (dp[i][j + 1][3] + dp[i][j][0]) % mod;
                }
            }
        }
        int ans = 0;
        rep(k, 0, 4){
            ans += dp[h - 1][w - 1][k];
        }
        cout << ans % mod << endl;
    }
}

Measured memory_bytes: 1356
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

#define pi 3.141592653589793

int solve(int n, int maxw, int v[], int w[])
{
	int result[101][10001];
	for(int i = 0; i < n + 1; i++){
		for(int j = 0; j < maxw + 1; j++){
			result[i][j] = 0;
		}
	}
	for(int i = 1; i < n + 1; i++){
		for(int j = 1; j < maxw + 1; j++){
			if(w[i] <= j){
				result[i][j] = max(result[i - 1][j], result[i - 1][j - w[i]] + v[i]);
			} else result[i][j] = result[i - 1][j];
		}
	}
	return result[n][maxw];
}

int main()
{
	int n, maxw;
	int v[101], w[101];
	cin >> n >> maxw;
	for(int i = 1; i < n + 1; i++){
		cin >> v[i] >> w[i];
	} 
	cout << solve(n, maxw, v, w) << endl;
	return 0;
}

Measured memory_bytes: 5104
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	int sum = 0;
	sort(L.begin(), L.end());
	for (int i = 0; i < N - 2; i++) {
		for (int j = N - 1; j > i + 1; j--) {
			for (int k = i + 1; k < j; k++) {
				if (L[j] - L[i] < L[k]) {
					sum = sum + j - k;
					break;
				}
			}
		}
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;


void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int z = -1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] < 0) z = i;
    }
    int mi = 1e9;
    if (z-k+1 >= 0) mi = min(mi, -a[z-k+1]);
    if (z+k < n) mi = min(mi, a[z+k]);
    for (int i = 1; i < k; i++) {
        int l = z+i-k+1, r = z+i;
        if (0 <= l && r < n) {
            mi = min(mi, a[r]*2 - a[l]);
            mi = min(mi, a[r] - 2*a[l]);
        }
    }
    cout << mi;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 640
import std.stdio;

// [debug]
void dump(int[][] route, int height, int width) {
  for(int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      writef("%d%s", route[j][height - i - 1], (j == width - 1) ? "\n" : " ");
    }
  }
}

void main() {
  int width, height;
  while(readf("%d %d\n", &width, &height), (width + height) != 0) {
    int[][] route = new int[][](width, height);
    bool[][] zones = new bool[][](width, height);
    int number;
    readf("%d\n", &number);
    for(int i, j, n = 0; n < number; n++) {
      readf("%d %d\n", &i, &j);
      zones[i - 1][j - 1] = true;
    }
    
    route[0][0] = 1;

    for(int i = 1; i < width; i++)
      if (!zones[i][0])
        route[i][0] = route[i - 1][0];
    for(int j = 1; j < height; j++)
      if (!zones[0][j])
        route[0][j] = route[0][j - 1];
  
    for(int i = 1; i < width; i++) {
      for(int j = 1; j < height; j++) {
        if (zones[i][j]) continue;        
        if (zones[i - 1][j] && zones[i][j - 1]) route[i][j] = 0;
        else if (zones[i - 1][j]) route[i][j] = route[i][j - 1];
        else if (zones[i][j - 1]) route[i][j] = route[i - 1][j];
        else {
          route[i][j] = route[i - 1][j] + route[i][j - 1];
        }
      }
    }
    // dump(route, height, width);
    writeln(route[width - 1][height - 1]);
  }
}

Measured memory_bytes: 1088
#include<iostream>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
using namespace std;
int P(int a)
{
	int flag=1;
	for (int i=2;i<=sqrt(a);i++)
	{
		if (a%i==0)
		{
			flag=0;
		}
	}
	if (a<2)
	{
		return 0;
	}
	if (flag==1||a==2)
	{
		return 1;
	}
	if (flag==0)
	{
		return 0;
	}
	return 0;
}
int main()
{
	double a,b,c;
	cin>>a>>b>>c;
	cout<<(a+b)*c/2;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
ans=1
a=0
X=[int(i) for i in input().split()]
for i in range(1,N):
    check=True 
    for j in range(0,i):
        if(X[i]<X[j]):
            check=False
            continue
    if(check):
        ans+=1
print(ans)

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

int main(){
  int n, t;
  cin >> n >> t;
  vector<vector<int>> menu(n, vector<int>(2, 0));
  for(int i = 0; i < n; i++){
    cin >> menu[i][0] >> menu[i][1];
  }
  sort(menu.begin(), menu.end());

  int ans = menu[0][1];
  int key;
  vector<int> dp(t, 0);
  for (int i = 0; i < n-1; i++){
    for (int j = t-1; j >= 0; j--){
      if ((j == 0) || (dp[j] != 0)){
        if (j+menu[i][0] <= t-1){
          dp[j+menu[i][0]] = max(dp[j+menu[i][0]], dp[j]+menu[i][1]);
        }
      }
    }
    key = dp[0];
    for (int j = 1; j < t; j++){
      if (key < dp[j]){
        key = dp[j];
      }
    }
    for (int j = i+1; j < n; j++){
      if (ans < key+menu[j][1]){
        ans = key+menu[j][1];
      }
    }
  }

  cout << ans << endl;
}




Measured memory_bytes: 384
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string str = ReadLine();
        int x = 0;
        do{
            x = str.IndexOf("B");
            if(x>0){
                str = str.Remove(x-1,2);
            }else if(x == 0){
                str = str.Remove(0,1);
            }
        }while(x>=0);
        WriteLine(str);
    }
}


Measured memory_bytes: 11484
#include <iostream>
#include<cmath>
using namespace std;
int main(){
int n,c,y=0,x=0;

string s;

cin>>s;

n=s.size();

if(s[0]!='A' || s[s.size()-1]=='C' || s[1]=='C'){
	cout<<"WA";
	return 0;

}

for(int i=2;i<n-1;i++){
	if(s[i]=='C')
	x+=1;
	c=i;
}
for(int j=1;j<n;j++){
	if(islower(s[j])){
		continue;	
	}
	else {
		if(s[j]=='C'){
			continue;
			
		}
		else{
			cout<<"WA";
			return 0;
		}
	}	
}
if(x==1)
	cout<<"AC";
else
	cout<<"WA";	

}


Measured memory_bytes: 760