akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define int long long
#define swap(x,y) (x^=y^=x^=y)

#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

using namespace std;

// long long modexpo(long long x, long long p){
//     int res = 1;x = x%mod;
//     while(p){
//         if(p%2)res = res * x;
//         p >>= 1;
//         x = x*x % mod;
//         res %= mod;
//     }
//     return res;
// }

// int max(int a,int b){return (a>b?a:b);} 
// int min(int a,int b){return (a<b?a:b);}


struct compare{
    bool operator() (const pair<int,int> a, const pair<int,int> b) const{
        return a.first < b.first;
    }
};

void yes(){
    cout << "Yes" << endl;
}

int32_t main(){
    IOS
    string s;
    cin >> s;
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            if(i == j){
                continue;
            }
            for(int k = 0; k < 4; k++){
                if(k == i || k == j){
                    continue;
                }
                for(int l = 0; l < 4; l++){
                    if(l == i || l== j || l == k){
                        continue;
                    }
                    if(s[i] == s[j] && s[k] == s[l] && s[i] != s[k]){
                        cout << "Yes" << endl;
                        exit(0);
                    }
                }
            }
        }
    }
    cout << "No" << endl;
} 

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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; }
int main(){
    cout << fixed << setprecision(10);
    ll n;
    string s;
    cin >> n >> s;
    map<char,ll> mcl;
    rep(i, s.size()){
        mcl[s[i]]++;
    }
    ll ans = 1;
    for(auto u : mcl){
        ans *= u.second + 1;
        ans %= mod;
    }
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 3728
object Main extends App {
	var cnt = 0
	for(line <- io.Source.stdin.getLines()) {
		cnt = cnt + 1
		var num = line.toInt
	    val n = num match {
	    	case 0 => ""
	    	case x => x
	    }
	    if(n != "") {
	    	println("Case " + cnt + ": " + n)
	    }
	}
}


Measured memory_bytes: 51524
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int main(){
    int d,t,s; cin >> d >> t >> s;
    if(s*t >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    char[][] board = new char[h][w];
    for(int i = 0; i < h; i++) {
      String s = sc.next();
      for(int j = 0; j < w; j++) {
        board[i][j] = s.charAt(j); 
      }
    }
    for(int i = 0; i < h; i++) {
      String ans = "";
      for(int j = 0; j < w; j++) {
        if(board[i][j] == '#') {
          ans += "#";
        } else {
          int ba = 0;
          for(int s = -1; s <= 1; s++) { 
            for(int t = -1; t <= 1; t++) {
              if((s != 0) || (t != 0)) {
                if(((i + s) >= 0) && ((i + s) < h) && ((j + t) >= 0) && ((j + t) < w)) {
                  if(board[i + s][j + t] == '#') ba++;
                }
              }
            }
          }
          ans += (String.valueOf(ba));
        }
      }
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  map<string,int> mp;
  int MAX = 0;
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    if(mp.count(S)){
      mp[S]++;
    }
    else{
      mp[S] = 1;
    }
    MAX = max(MAX,mp[S]);
  }
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    if(itr->second == MAX){
      cout << itr->first << endl;
    }
  }   
}

Measured memory_bytes: 25216
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int R,G,B,N,ans=0,k1,k2,i,j,x1,x2;

  scanf("%d %d %d %d",&R,&G,&B,&N);
  k1 = N / R;
  for (i = k1; i >= 0; i--) {
    x1 = N - R*i;
    k2 = x1 / G;
      for (j = k2; j >= 0; j--) {
        x2 = x1 - G*j;
          if (x2 % B == 0) {
            ans++;
          }
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;

#define reg(i, x) for (int (i)=head[x];(i);i=e[i].next)
#define clr(a) memset(a,0,sizeof(a))
#define Sort(a, len) sort(a + 1, a + len + 1)
#define Sort2(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))

#define ull unsigned long long
#define ll long long
#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define Pii pair<int, int>

const int iinf = INT_MAX/2 ;
const ll linf = LLONG_MAX/2 ;
const int MOD = 1e9+7 ;

inline int read(){
    int X = 0,w = 0 ;
	char ch = 0;
    while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
    while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
    return w ? -X : X;
}

void write(int x){
     if(x < 0) putchar('-'),x = -x;
     if(x > 9) write(x / 10);
     putchar(x%10 + '0');
}

void print(int x) {
	cout << x << endl ;
	exit(0) ;
}

void douout(double x){
	 printf("%lf\n", x + 0.0000000001) ;
}

#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
#define MAX 100010
ll N,Q,L;
ll x[MAX],a,b;
 
int nex[MAX][80];
 
void compute() {
  rep(i,N) {
    nex[i][0] = ( upper_bound(x,x+N,x[i]+L) - x ) - 1;
    assert( nex[i][0] != 0 );
  }
 
  rep(j,70) rep(i,N) nex[i][j+1] = nex[nex[i][j]][j];
  cin >> Q;
  rep(_,Q) {
    cin >> a >> b;
    --a, --b;
    if( !( a < b ) ) swap(a,b);
    ll cost = 0;
    for(int i=69;i>=0;--i) {
      if( nex[a][i] < b ) {
	cost += (1LL<<i);
	a = nex[a][i];
      }
    }
    cout << cost+1 << endl;
  }
}
 
int main() {
  cin >> N;
  rep(i,N) cin >> x[i];
  cin >> L;
  compute();
  return 0;
}
/*
写代码时请注意：
	1.是否要开Long Long？数组边界处理好了么？
	2.特殊情况处理好了么？
	3.做一些总比不做好。
	4.最大值和最小值问题可不可以用二分答案？
	5.有没有贪心策略？否则能不能dp？
	6.实数精度有没有处理？
*/


Measured memory_bytes: 32896
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
a = LIST()
m = a[0] ^ a[1]
for i in range(2, n):
    m = m ^ a[i]
ans = []
for i in range(n):
    ans.append(str(m ^ a[i]))
#print(m)
print(' '.join(ans))

Measured memory_bytes: 116120
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);


void solve(int T){
    int  n;
    cin>>n;
    vector<int>a(n+1);
    int ans=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]!=i)ans++;
    }
    if(ans>2){
        cout<<"NO\n";
    }
    else cout<<"YES\n";

}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}





Measured memory_bytes: 3620
#include <iostream>
#include <string>
int main(){
  int h,w;
  std::string s;
  std::cin>>h>>w;
  for(int i=0;i!=h+2;++i){
    std::cout<<'#';
    if(i==0||i==h+1)for(int j=0;j!=w;++j)std::cout<<'#';
    else{
      std::cin>>s;
      std::cout<<s;
    }
    std::cout<<"#\n";
  }
}
  

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = list(map(int, input().split()))
count = 0
point = 0 


for i in range(N):
    if A[i]==0:
        count = 1
        break
    elif A[i] < 0:
        point += 1

if count==1 or point%2==0:
    print(sum(np.abs(A)))

else:
    A1 = np.abs(A)
    A2 = min(A1)
    print(sum(A1)-2*A2)


Measured memory_bytes: 23292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    int a, b; cin >> a >> b;
    int ans =0;
    if(a>=13){
        ans = b;
    }else if(a>=6){
        ans = b/2;
    }else {
        ans = 0;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF pow(10, 9) + 7
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define chmax(x, y) x = max(x, y)
#define print(x) cout << x << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

void solve(){

	ll N, K, cnt, tmp;
	cin >> N >> K;
	vl v(N);
	rep(i, N) cin >> v[i];
	ll ans = 0;
	
	rep(i, N + 1){
		rep2(j, i + 1, N + 2){
			
			tmp = 0;
			cnt = 0;
			priority_queue<ll> q;
			
			rep(k, i){
				tmp += v[k];
				q.push(-v[k]);
				cnt += 1;
			}
			rep2(k, j, N){
				tmp += v[k];
				q.push(-v[k]);
				cnt += 1;
			}
			
			if(cnt <= K){
				rep(k, K - cnt){
					if(q.empty() or q.top() <= 0) break;
					tmp += q.top();
					q.pop();
				}
				chmax(ans, tmp);
			}
			
		}
	}
	
	print(ans);
			
}	

int main(){
    
    fastio;
	solve();
    
	return 0;
	
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
#define true 1
#define false 0


int solve(int i, int m);

int n;
int q;
int A[2000];

int main()
{
  int i;
  int m[2000];
  int S[2000];
  
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&m[i]);
  }

  for(i=0; i<q; i++){
    S[i] = solve(0,m[i]);
    if(S[i] == 1){
      printf("yes\n");
    } else printf("no\n");
  }


  return 0;
}

int solve(int i,int m){
  int res;
  if(m == 0)
    return true;
  if( i >= n )
    return false;
  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}



Measured memory_bytes: 2700
N,M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))
    
def fibonacci(n):
    listf = [0]+[1]*n
    a, b = 1, 0
    for i in range(n-1):
        a, b = (a+b)%1000000007 , a
        listf[i+2] = a
    return listf 

fib = fibonacci(N+1)
if a:
    ans = [a[0]]
    
    for i in range(M-1):
        ans.append(a[i+1]-a[i]-1)
            

    result = 1
    for j in range(len(ans)):
        result = result * fib[ans[j]] % 1000000007
    
    result = result * fib[(N - a[-1])] % 1000000007
    
    print(result)
else:
    ans = fib[-1]
    print(ans)


Measured memory_bytes: 11660
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,popcnt")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<17, mod = 1e9 + 7, i2 = (mod+1)/2;
ll solve(vector<int> a) {
	ll sm = 0, t;
	sort(all(a));
	for(int i = 0; i < a.size(); i++) {
		if(a[i] < 0) a[i] = (mod + a[i]%mod)%mod;
		sm = (sm + (a.size()-i)*1ll*a[i] + (i+1)*1ll*(mod-a[i]))%mod;
	}
	return sm;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(m);
	for(auto &i : a) cin >> i;
	for(auto &i : b) cin >> i;
	cout << solve(a)*solve(b)%mod;
	return 0;
}


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

int main(void) {
	char s[5];
	cin >> s;
	int res = 0;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '+') {
			res++;
		}
		else {
			res--;
		}
	}
	cout << res << endl;
}

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


int main()
{
	string s;
	cin >> s;
	bool a = false;
	bool b = false;
	bool c = false;
	for (int i = 0; i < 3; ++i)
	{
		if (s[i] == 'a')
		{
			a = true;
		} else if (s[i] == 'b')
		{
			b = true;
		} else if (s[i] == 'c')
		{
			c = true;
		}

	}
	if (a && b && c)
	{
		cout << "Yes";
	} else
	{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void 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;
		}
	}
	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)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}


int main() {
	int a, b;
	cin >> a >> b;

	cout << ((a * b) %2 == 0 ? "Even" : "Odd" ) << endl;
}



Measured memory_bytes: 256
from fractions import gcd
a, b, c, d = map(int, input().split())

print(b - b//c - b//d + b//((c*d)//gcd(c, d)) - (a-1 - (a-1)//c - (a-1)//d + (a-1)//((c*d)//gcd(c, d))))

Measured memory_bytes: 64748
#include <stdio.h>

int main(){
	int S,h,m,s;

	scanf("%d",&S);

	h = S/3600;
	m = (S%3600)/60;
	s = S - (h*3600+m*60);
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>
using namespace std;

int main() {
    unsigned long long s;
    cin >> s;
    unsigned long long  a,b,c,d,e,f;
    a = 0;
    b = 0;
    c = sqrt(s);
    f = s/c;
    if (c != 1000000000) {
        c++;
    }
    // cout << c * f - s << endl;
    e = c * f - s;
    d = 1;
    // unsigned long long binary = log10(s);
    // cout << binary << endl;
    // unsigned long long xbinary = binary/2;
    // c = s / powl(10,binary) * powl(10,xbinary);
    // cout << c << endl;
    // f = s / (c+powl(10,xbinary));
    // cout << f << endl;
    // e = c*f - s;
    // d = 1;
    // cout << c*f << endl;
    cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl;
    // cout << c * f - d * e << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin>>c;
  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
   cout<<"vowel"<<endl; 
  }else{
   cout<<"consonant"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    if(a==0): return b
    if a<b: a,b=b,a
    while b: a,b=b,a%b
    return a

n, *a = map(int, open(0).read().split())
g = 0
for i in a: g = gcd(g, i)
print(g)

Measured memory_bytes: 14052
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


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

  //map<char,vi> C;
  vvi C(26);
  rep(i,s.size()) C[s[i]-'a'].pb(i);

  // rep(j,26) {
  //   rep(i,C[j].size()) cout << j << " " << C[j][i] << endl;
  // }

  rep(i,T.size()) {
    if(C[T[i]-'a'].empty()){
      cout << -1 << endl;
      return 0;
    }
  }

  ll ans = 0;
  ll cnt = 0;
  int j = -1;
  rep(i,T.size()){
    int c = T[i]-'a';
    int n = C[T[i]-'a'].size();
    int k = upper_bound(all(C[T[i]-'a']),j) - C[T[i]-'a'].begin();
    if(k == n){
      k = 0;
      cnt++;
    }
    j = C[T[i]-'a'][k];
  }
  ans = cnt * s.size() + j+1;
  cout << ans << endl;
}

Measured memory_bytes: 1216
A,B,M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a)+min(b)

for _ in range(M):
    x,y,c = map(int, input().split())
    x -= 1
    y -= 1
    ans = min(a[x]+b[y]-c,ans)
print(ans)

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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if (A + B >= C){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N ()
#define ll long long
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define CM cerr<<(&MOP2-&MOP1)/1024.0/1024.0<<endl
using namespace std;
template <class T> inline T Min(T x, T y){
    return x<y?x:y;
}
template <class T> inline T Max(T x, T y){
    return x>y?x:y;
}
bool MOP1;

bool MOP2;
int main(){
	int n;
	string s;
	cin>>n>>s;
	if(n>=3200)cout<<s;
	else cout<<"red";
}






Measured memory_bytes: 256
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import collections
import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    N, Q = read_int_array()
    add, delete = [], []
    for i in range(N):
        S, T, X = read_int_array()
        add.append((S - X, X))
        delete.append((T - X, X))

    active = []
    to_delete = collections.defaultdict(int)
    import heapq
    heapq.heapify(add)
    heapq.heapify(delete)
    for _ in range(Q):
        x = read_int()
        while add and add[0][0] <= x:
            coord, val = heapq.heappop(add)
            heapq.heappush(active, val)

        while delete and delete[0][0] <= x:
            coord, val = heapq.heappop(delete)
            to_delete[val] += 1

        while active and to_delete[active[0]] > 0:
            to_delete[active[0]] -= 1
            heapq.heappop(active)

        print(active[0] if active else -1)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = "x" in file.mode or "r" not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion


def read():
    return input()


def read_array(sep=None, maxsplit=-1):
    return read().split(sep, maxsplit)


def read_int():
    return int(read())


def read_int_array(sep=None, maxsplit=-1):
    return [int(a) for a in read_array(sep, maxsplit)]


if __name__ == "__main__":
    main()


Measured memory_bytes: 134728
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{

    static void Main()
    {
        string s = Console.ReadLine();
        switch (s)
        {
            case "a":
            case "i":
            case "u":
            case "e":
            case "o":
                Console.WriteLine("vowel");
                break;
            default:
                Console.WriteLine("consonant");
                break;
        }
    }
}


Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	long double a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n-1;i++)
	{
		a[i+1]=(a[i+1]+a[i])/2;
	}
	cout<<fixed<<setprecision(6)<<a[n-1];
}

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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

// fact(n)
TLong fact(TLong n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1) % TBMod);
}

int main(int argc, char const *argv[])
{
	TLong n,m;
	scanf("%lld%lld",&n,&m);
	switch(abs(n - m)){
		case 0:
			printf("%lld\n", (2 * fact(n) * fact(m)) % TBMod);
			break;
		case 1:
			printf("%lld\n", (fact(n) * fact(m)) % TBMod);
			break;
		default:
			puts("0");
			break;
	}
	return 0;
}


Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
#define MAXN 1001
#define ll long long
int n, m, cnt, last1, last2, first2;
int main()
{
	scanf("%d%d",&n,&m);
	if(m%2 == 1) last1 = m, last2 = m-1;
	else last1 = m-1, last2 = m;
	first2 = 2 + last1;
	for(int i=1;last1 >= 1 && i >= 1;i++)
	{
		printf("%d %d\n",i,i+last1);
		last1 -= 2;
	}
	for(int i=first2;i>=1 && last2>=1;i++)
	{
		printf("%d %d\n",i,i+last2);
		last2 -= 2;
	}
	
	return 0;
}

Measured memory_bytes: 3828
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[1<<60]*(n)
dp[0]=0
for i in range(1,n):
    for j in range(1,min(k+1,i+1)):
        dp[i]=min(abs(h[i-j]-h[i])+dp[i-j],dp[i])
print(dp[-1])

Measured memory_bytes: 52592
s=str(input())
cnt=0
for i in range(len(s)):
    tmp=0
    for j in range(len(s)-i):
        
        if(s[i+j]=="A"or s[i+j]=="C"or s[i+j]=="G" or s[i+j]=="T"):
            tmp+=1
        else:
            break
    cnt = max(cnt,tmp)

print(cnt)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;
typedef long long ll;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

int main()
{
    ll n;cin>>n;
    vector<pair<ll,ll>>ba(n);
    REP(i,n) cin>>ba[i].second>>ba[i].first;
    sort(ba.begin(),ba.end());
    ll time=0;
    REP(i,n)
    {
        time+=ba[i].second;
        if(time>ba[i].first){cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main(void)
{
  int A,B,C,D;

  scanf("%d%d%d",&A,&B,&C);
  D = B / A;
  if (D > C){
    printf("%d",C);
  }
  else {
    printf("%d",D);
  }
  return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s == "abc") {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#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() {
  string S;
  cin >> S;
  if (S[1] == 'B') cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}

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

#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 ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

const int MAX = 510000;
const int MOD = 1000000007;

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() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  map<ll, ll> cnt;
  REP(i, n) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  sort(ALL(a));
  COMinit();

  ll ans = 0;
  ll i = 0;
  while (i <= n - 1) {
    if (i + cnt[a[i]] >= k) {
      ll tmp = a[i] * (COM(i + cnt[a[i]], k) - COM(i, k));
      tmp %= MOD;
      if (tmp < 0) tmp += MOD;
      ans += tmp;
      ans %= MOD;
      if (ans < 0) ans += MOD;
    }

    if (n - i >= k) {
      ll tmp = a[i] * (COM(n - i, k) - COM(n - i - cnt[a[i]], k));
      tmp %= MOD;
      if (tmp < 0) tmp += MOD;
      ans -= tmp;
      ans %= MOD;
      if (ans < 0) ans += MOD;
    }

    i += cnt[a[i]];
  }

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

Measured memory_bytes: 18688
N = int(input())
S = input()

Sold = S
while True:
    Snew = Sold.replace('()', '')
    if len(Snew) == len(Sold):
        break
    Sold = Snew

num = Snew.count(')')
print('(' * num + S + ')' * (len(Snew) - num))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
using namespace std;
typedef long long LL;
const int N = 100500;
int a[N], n;
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	LL ans = 0, bns = 0, sum;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
	sum = 0;
	for (int i = 0; i < n; ++i) {
		// cout << sum << " " << ans << " " << u << endl;
		if (sum < 0) {
			sum += a[i];
			if (sum <= 0) {
				ans += 1 - sum;
				sum = 1;
			}
		} else {
			sum += a[i];
			if (sum >= 0) {
				ans += sum + 1;
				sum = -1;
			}
		}
	}
	sum = 0;
	for (int i = 0; i < n; ++i) {
		// cout << sum << " " << ans << " " << u << endl;
		if (sum <= 0) {
			sum += a[i];
			if (sum <= 0) {
				bns += 1 - sum;
				sum = 1;
			}
		} else {
			sum += a[i];
			if (sum >= 0) {
				bns += sum + 1;
				sum = -1;
			}
		}
	}
	cout << min(ans, bns) << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main()
{
    int number[9];
	int color[9];
	int cards[3][9];
	int i,j,k,n;
	int zero=0;
	char ch;
	
    scanf("%d",&n);
    
    for(k=0;k<n;k++){
        
        //初期化
        for(i=0;i<3;i++){
		    for(j=0;j<9;j++){
			    cards[i][j]=0;
		    	number[j]=0;
			    color[j]=0;
	    	}
    	}

	//カードを読み込む
	    for(i=0;i<9;i++){
		    scanf("%d ",&number[i]);
		     color[i]=0;
    	}
	    for(i=0;i<9;i++){
	    	scanf("%c ",&ch);
		    if(ch=='R'){
		    	color[i]=0;
		    }
		    else if(ch=='G'){
		    	color[i]=1;
	    	}
		    else if(ch=='B'){
			    color[i]=2;
	    	}
    	}
	
    	for(i=0;i<9;i++){
		    if(color[i]==0){
		    //	cards[0][i]=number[i];
	            cards[0][number[i]-1]++;
	    	}
		    if(color[i]==1){
	//		    cards[1][i]=number[i];
	             cards[1][number[i]-1]++;
	    	}
	    	if(color[i]==2){
	//	    	cards[2][i]=number[i];
	            cards[2][number[i]-1]++;
	    	}
    	}

        
        //所持している枚数
        /*    	
    	for(i=0;i<3;i++){
	    	for(j=0;j<9;j++){
	    		printf("%d",cards[i][j]);
	    	}
		printf("\n");
    	}*/
    	
	//同じ色で三枚とも同じセットがあるとき
    	for(i=0;i<3;i++){
	      for(j=0;j<9;j++){
	        if(cards[i][j]>=3){
	            cards[i][j] -= 3;
	        }
	     }
    	}
	
    	for(i=0;i<3;i++){
            for(j=0;j<8;j++){
                //2セットの連番があるとき
                if(cards[i][j] >= 2 && cards[i][j+1] >=2 && cards[i][j+2] >= 2){
                    cards[i][j] -= 2;
	                cards[i][j+1] -= 2;
	                cards[i][j+2] -=2;
                }
                //1セットの連番があるとき
                else if(cards[i][j] >= 1 && cards[i][j+1] >= 1 && cards[i][j+2] >= 1){
	                cards[i][j]--;
	                cards[i][j+1]--;
	                cards[i][j+2]--;
	        }
	    }
	}
	
	//セット作った後のカード所持数
	/*
	    for(i=0;i<3;i++){
		    for(j=0;j<9;j++){
		    	printf("%d",cards[i][j]);
	    	}
	    	printf("\n");
	}
*/
	//所持しているカードはないか確認
    	for(i=0;i<3;i++){
	    	for(j=0;j<9;j++){
    		if(cards[i][j]==0) zero++;
		}
	}
	//手札が無いなら１、残ったなら０である
	if(zero==27){
	    printf("1\n");
	}else{
	    printf("0\n");
	}
	zero=0;
    }
	return 0;
}


Measured memory_bytes: 1960
n, k = map(int, input().split())

mod = 998244353

m_list = []

for _ in range(k):
    m_list.append(list(map(int, input().split())))

dp = [0]*n
dp[0] = 1

dp_sum = [0]*n
dp_sum[0] = 1

for i in range(1, n):
    for j in range(k):
        l, r = m_list[j]
        il = i-l
        ir = i-r-1
        if il < 0:
            continue
        else:
            if ir < 0 :
                dp[i] += dp_sum[il]
            else:
                dp[i] += dp_sum[il] - dp_sum[ir]
            dp[i] %= mod
    dp_sum[i] = dp_sum[i-1] + dp[i]
    dp_sum[i] %= mod

print(dp[n-1] % mod)

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

int main()
{
	int N;
	cin >> N;
	int A[N];
	int B[N];
	int C[N-1];

	for (int i = 0; i < N; i++)
		cin >> A[i];
	for (int i = 0; i < N; i++)
		cin >> B[i];
	for (int i = 0; i < N-1; i++)
		cin >> C[i];

	int s = 0;
	for (int i = 0; i < N; i++) {
		s += B[i];
		if (A[i] + 1 == A[i+1])
			s += C[A[i]-1];
	}

	cout << s << '\n';
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

auto kadane(vector<int> ary)
{
    int max_global = ary[0], max_current = ary[0];
    for (int i = 1; i < ary.size(); i++)
    {
        max_current = max(ary[i], max_current + ary[i]);
        max_global = max(max_global, max_current);
    }
    return max_global;
}

vector<int> a[100];

int main()
{
    int n;
    cin >> n;
    rep(i, n) rep(j, n)
    {
        int m;
        cin >> m;
        a[i].push_back(m);
    }
    int maxv = INT_MIN;

    rep(i, n)
    {
        vector<int> st(n, 0);

        for (int j = i; j < n; j++)
        {
            rep(k, n) st[k] += a[j][k];
            maxv = max(maxv, kadane(st));
        }
    }

    OP(maxv);

    return 0;
}


Measured memory_bytes: 3228
class String
  def to_ia
    self.split(/\s/).map {|s| s.to_i}
  end
end

def create_memo(ary)
  memo = [Array.new(2001)] + ary.map {|i| Array.new(2001)}
  ary.each_with_index do |val, i|
    i += 1
    (1..2000).each do |j|
      res = false
      if val == j
        res = true
      elsif memo[i-1][j]
        res = true
      elsif j-val > 0 and memo[i-1][j-val]
        res = true
      end
      memo[i][j] = res
    end
  end
  memo
end

def solve(ary, dest)
  @memo ||= create_memo(ary)
  @memo.each do |row|
    return true if row[dest]
  end
  false
end

lines = STDIN.read.split(/\n/)
ary = lines[1].to_ia
lines[3].to_ia.each do |i|
  puts solve(ary, i) ? "yes" : "no"
end

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

using namespace std;
typedef long long ll;

void solve()
{
   char ch;
   cin>>ch;
   if(ch>='A' && ch<='Z')
   {
       cout<<"A"<<endl;
   }
   else
    cout<<"a"<<endl;

}
int main()
{

    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }



}





Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <numeric>

using namespace std;

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

    cout << 3.141592 * 2 * R << endl;
    return 0;
}


Measured memory_bytes: 3788
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class COrdinaryBeauty {
public:
	void solve(std::istream& in, std::ostream& out) {
        double n, m, d;
        in >> n >> m >> d;

        double res = 1 / pow(n, 2) * (m-1) * (n-d);

        if(d != 0) res *= 2.0;

        out << fixed << setprecision(10) << res << endl;
	}
};


int main() {
	COrdinaryBeauty solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
def main():
    from collections import deque
    n = int(input())
    s = input()

    r_list = deque([])
    for i,j in enumerate(s):
        if j == 'R':
            r_list.append(i)

    c = 0
    for i,j in enumerate(s):
        if r_list: 
            if j == 'W':
                r_list.pop()
                c += 1
            else:
                r_list.popleft()
        else:
            break
    print(c)
        
main()

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL)
    x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key)
    return u;
  if(k<u->key)
    return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)
    return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL)
    y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL)
    x=y->left;
  else x=y->right;

  if(x!=NIL)
    x->parent=y->parent;

  if(y->parent==NIL)
    root=x;
  else if(y==y->parent->left)
    y->parent->left=x;
  else y->parent->right=x;

  if(y!=z)
    z->key=y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x=x->left;
    else x=x->right;
  }
  z->parent=y;

  if(y==NIL)root=z;
  else if(z->key<y->key)
    y->left=z;
  else y->right=z;
}

void inorder(Node u){
  if(u==NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20476
n,k = map(int,input().split())
a = list(map(int,input().split()))
a2 = a + a
def tentou (l):
    count = [0]*len(l)
    for i in range(len(l)-1):
        for j in range(i+1,len(l)):
            if l[i] > l[j]:
                count[i] += 1
    return count
if n == 1:
    print(0)
else:
    a_v = tentou(a)
    a2_v = tentou(a2)
    mergin = [x-y-y for (x,y) in zip(a2_v,a_v)]
    if k == 1:
        S = sum(a_v)
        result = S % ((10**9) + 7)
    else:
        for i in range(len(a_v)):
            a_v[i] = a_v[i]*(k*(k+1))//2 + mergin[i]*(k*(k-1))//2
        S = sum(a_v)
        result = S % ((10**9) + 7)
        print(result)

Measured memory_bytes: 3336
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
for l in range(K+1):
    for r in range(K-l+1):
        if l + r > N:
            continue

        score = 0
        S = []

        for i in range(l):
            score += V[i]
            S.append(V[i])

        for i in range(r):
            score += V[-(i+1)]
            S.append(V[-(i+1)])

        d = K - l - r
        S.sort()
        for i in range(d):
            if i > len(S)-1:
                break
            if S[i] > 0:
                break
            score -= S[i]

        ans = max(ans, score)

print(ans)


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

int main(){
	int N;
	cin >> N;
	vector<int> L(N);
	for(auto &i:L)cin >> i;
	sort(L.begin(),L.end());
	int ans=0;
	for(int i=0;i<N-2;i++)for(int j=i+1;j<N-1;j++){
		int ab=L[i]+L[j];
		auto it=lower_bound(L.begin(),L.end(),ab);
		ans+=max(0,(int)(it-L.begin())-(j+1));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   cout<<(a+b)*c/2<<endl;
   return 0;
}


Measured memory_bytes: 256
# Your code here!
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

answer_count = 0

def check(x, answer_count)
    if X == x then
        answer_count += 1
    end
    return answer_count
end

A.downto(0){ |a_num|
    x_tmp = 500 * a_num
    B.downto(0){ |b_num|
        x_tmp = 500 * a_num + 100 * b_num
        C.downto(0){ |c_num|
            x_tmp = 500 * a_num + 100 * b_num + 50 * c_num
            answer_count = check(x_tmp, answer_count)
        }
    }
}

print(answer_count)





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

using namespace std;

const int MAXN = 2E5;
pair<long long, int> a[MAXN + 1];
int orig[MAXN + 1];
int pos[MAXN + 1];
int bit[MAXN + 1];

void inc(int pos, int amt)
{
    while (pos <= MAXN)
    {
        bit[pos] += amt;
        pos += pos & (-pos);
    }
}

int query(int pos)
{
    int ans = 0;
    while (pos > 0)
    {
        ans += bit[pos];
        pos -= pos & (-pos);
    }
    return ans;
}

int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        x -= k;
        orig[i] = x;
        if (i > 1)
            a[i] = {a[i - 1].first + x, i};
        else
            a[i] = {x, i};
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++)
        pos[a[i].second] = i;
    long long offset = 0;
    long long ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int ind = 0;
        for (int jump = n / 2 + 1; jump > 0; jump /= 2)
        {
            while (ind + jump <= n && a[ind + jump].first < offset)
                ind += jump;
        }
        ans += n - ind - ((i - 1) - query(ind));
        inc(pos[i], 1);
        offset += orig[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int a, b;
  cin >> a >> b;
  if(a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout << ":(" << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		StringTokenizer st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(st.nextToken());
		}
		int q = Integer.parseInt(reader.readLine());
		st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < q; i++) {
			if (subsetSum(Integer.parseInt(st.nextToken()), a)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
		reader.close();
	}

	private boolean subsetSum(int s, int[] a) {
		int n = a.length;
		boolean[][] dp = new boolean[n+1][s+1];
		for (int i = 0; i < n; i++) {
			int v = a[i];
			for (int j = 0; j <= s; j++) {
				if (v == j) {
					dp[i+1][j] = true;
				} else if (v > j) {
					dp[i+1][j] = dp[i][j];
				} else {
					dp[i+1][j] = dp[i][j] || dp[i][j-v];
				}
			}
		}
		return dp[n][s];
	}
}



Measured memory_bytes: 29624