akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
int calDigit(int);
int main() {
	int a, b;
	while(scanf("%d %d", &a, &b)!=EOF) {
		printf("%d\n", calDigit(a+b));
	}
	return 0;
}

int calDigit(int num) {
	int count = 0;
	if(num == 0) count = 1;
	while(num > 0) {
		num /= 10;
		count++;
	}
	return count;
}


Measured memory_bytes: 1896
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define ll long long int
#define ld long double
#define vec vector
#define forn(a) for(ll a=0; a<n; a++)
#define fore(a, v, n) for(ll a=v; a<n; a++)
#define all(x) x.begin(), x.end()
#define presicion(x) cout<<fixed<<setprecision(x)
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define PI 3.14159265358979323
#define sen(ang) sin((ang)*PI/180)
//cout<<flush;

using namespace std;

ll n;
map<ll, ll> cants;
ll ns[400000];

int main() {
	IOS;
	cin >> n;
	forn (i) {
		cin >> ns[i];
		cants[ns[i]]++;
	}
	ll count = 0;
	for (auto v = cants.rbegin(); v != cants.rend(); v++) {
		if (!v->second)
			continue;
		fore (e, 1, 31) {
			ll sum = 1 << e;
			auto pair = cants.find(sum - v->first);
			if (pair != cants.end() && pair->second) {
				ll matches = min(pair->second, v->second);
				if (pair->first == v->first)
					matches /= 2;
				pair->second -= matches;
				v->second -= matches;
				count += matches;
				break;
			}
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 14336
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
				
		if(a%2 != b%2) {
			System.out.println("IMPOSSIBLE");
		}else {
			System.out.println((a+b)/2);
		}
		
		
	}

}


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

using namespace std;

int main(){
    string s;
    cin>>s;
    if(s.find("RRR")!=string::npos)cout<<3<<endl;
    else if(s.find("RR")!=string::npos)cout<<2<<endl;
    else if(s.find("R")!=string::npos)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

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

using namespace std;

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

    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    int mx = 1, cur = 1;
    for (int i = 1; i < N; ++i) {
        if (H[i] <= H[i - 1]) {
            ++cur;
            mx = max(mx, cur);
        } else {
            cur = 1;
        }
    }
    cout << mx - 1 << "\n";

    return 0;
}

Measured memory_bytes: 640
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

const ll MAX_N = 1e5;
ll N,M;
ll a[MAX_N+1] = {0};
ll dp[MAX_N+1]; // メモ化テーブル
ll n_div = 1e9+7;
 
// i番目以降の品物から重さの総和がj以下になるように選ぶ
void rec(ll i){
	if (i==0) dp[i] = 1;
	else if (a[i]==1) dp[i] = 0;
	else if (a[i]==0 & i==1) dp[i] = 1;
	else dp[i] = dp[i-2] + dp[i-1];
	dp[i] %= n_div;
	return;
}
 
 
int main() {
	// 入力
	cin >> N>>M;
	for (ll i = 0; i < M; ++i){
		ll tmp;cin>>tmp;a[tmp] = 1;
	}
 
	// 解法
	// DP
	memset(dp, -1, sizeof(dp));
	REP(i,N+1) rec(i);
	
	//出力
	// REP(i,N+1)printf("%lld\n", dp[i]);
	cout << dp[N] << endl;
}


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int a,b;
signed main() {
    cin>>a>>b;
    if(a==0)cout<<"Zero"<<endl;
    else if(a>0)cout<<"Positive"<<endl;
    else if(b>=0)cout<<"Zero"<<endl;
    else if((a-b)&1)cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int x[100][4001], n;
int main() {
	x[0][0] = 1;
	for (int i = 1; i < 10; i++) {
		for (int j = 0; j < 4000; j++) {
			for (int k = 0; k <= 1000; k++) {
				x[i][j + k] += x[i - 1][j];
			}
		}
	}
	int n;
	while (cin >> n) {
		cout << x[4][n] << endl;
	}
}

Measured memory_bytes: 1316
#include <iostream>
#include <vector>

using namespace std;

#define loop(i,a,b) for(int i=a; i<b; i++)
#define rep(i,b) loop(i,0,b)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main(){
    int w,h;
    while(cin>>w>>h, w||h){
        int G[100][100]={};
        int dp[100][100]={};

        rep(i,h)rep(j,w) cin>> G[i][j];
        rep(i,w) dp[0][i] = G[0][i]==0;

        rep(i,h-1) rep(j,w){
            if( G[i][j]==1){
                dp[i][j]=0;
            } else if(G[i][j]==2){
                if(G[i+2][j]!=1){
                    dp[i+2][j]+=dp[i][j];
                }
            } else {
                if(G[i+1][j]==2) dp[i+1][j]+=dp[i][j];
                loop(k,-1,2){
                    if(0<=j+k && j+k<w && G[i+1][j+k]==0){
                        dp[i+1][j+k]+=dp[i][j];
                    }
                }
            }
        }

        ull res=0;
        for(int i: {h-1,h}) rep(j,w){
            res+=dp[i][j];
        }

        cout<<res<<endl;
    }
}

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

int main ()
{
    string S;
    std::cin >> S;
    
    int count = 0;
    bool flag_capital = false;
    int length = S.size();
    if ( S[0] == 'A' )
    {
        for (int i = 1; i < length ; i++) 
        {
            if (i >= 2 and i <= length - 2)
            {
                if (S[i] == 'C')
                {
                    count++;
                }
                else if ( S[i] >= 'A' and S[i] <= 'Z')
                {
                    flag_capital = true;
                }
            }
            else if ( S[i] >= 'A' and S[i] <= 'Z')
            {
                flag_capital = true;
            }
        }
        
        if (count == 1 and flag_capital == false)
        {
            std::cout << "AC" << std::endl;
        }
        else 
        {
            std::cout << "WA" << std::endl;
        }
        
    }
    else
    {
    std::cout << "WA" << std::endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int a;
ld b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b;
	print1((int)(a*b));
	return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)(x).size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

const int mod = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;
    if (k >= n) k = n - 1;

    vector<ll> iv(k + 1);
    iv[1] = 1;
    for (int i = 2; i <= k; i++) {
        iv[i] = (mod - mod / i * iv[mod % i] % mod) % mod;
    }

    ll ans = 1, c1 = 1, c2 = 1;
    for (int i = 1; i <= k; i++) {
        c1 = c1 * (n - i + 1) % mod * iv[i] % mod;
        c2 = c2 * (n - i) % mod * iv[i] % mod;
        ans = (ans + c1 * c2) % mod;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 4752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<ll> pos[26];
ll t[200005]={0};
ll ch[200005]={0},zk[200005]={0};
ll nxt(ll i,ll c){
  ll ps=upper_bound(pos[c].begin(),pos[c].end(),i)-pos[c].begin();
  if(ps==pos[c].size()) return 200004;
  else return pos[c][ps];
}
int main(){
  string s=".",ks;
  cin>>ks;
  s+=ks;
  ll n=ks.length();
  for(int i=1;i<=n;i++){
    int j=s[i]-'a';
    pos[j].push_back(i);
  }
  for(int i=n;i>=0;i--){
    t[i]=174417441744;
    for(int j=0;j<26;j++){
      ll ni=nxt(i,j);
      if(t[i]>t[ni]+1){
        t[i]=t[ni]+1;
        ch[i]=ni;
        zk[i]=j;
      }
    }
  }
  string ans;
  ll ps=0;
  for(int i=0;i<t[0];i++) {
    ans.push_back((char)(zk[ps]+'a'));
    ps=ch[ps];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 7300
s = input()
n = len(s)

ans = 0

for bit in range(1 << (n - 1)):
    f = s[0]

    for i in range(n - 1):
        # ここのif文の判定基準が理解できていません。
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]

    ans += sum(map(int, f.split("+")))

print(ans)

Measured memory_bytes: 42220
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    const double btc = 380000.0;
    ll N; cin >> N;
    double ret = 0.0;
    REP(i, N){
        double x; string u;
        cin >> x >> u;
        ret += (u == "JPY") ? x : x * btc;
    }
    cout << ret << endstr;
    return 0;
}


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

int calc(int start, string s) {
    char p = s[0];
    bool d = start == 2;
    int ans = 1;
    for (int i = start; i < s.size(); i++) {
        if (d || p != s[i]) {
            p = s[i];
            d = false;
        } else {
            d = true;
            i++;
        }
        if (i >= s.size())
            return ans;
        ans++;
    }
    return ans;
}

int main() {
    string s;
    cin >> s;
    cout << max(calc(1, s), calc(2, s)) << endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<long> x(n);
  for(int i = 0; i < n; i++){
    cin >> x.at(i);
  }

  sort(x.begin(), x.end());
  string ans = "YES";
  for(int i = 0; i < n-1; i++){
    if(x[i] == x[i+1]){
      ans = "NO";
      break;
    }   
  }
  cout << ans << endl;

}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
N = int(input())
B_list = list(map(int, input().split()))

ans = 0
ans += B_list[0]
ans += B_list[-1]
for i in range(1, N - 1):
    ans += min(B_list[i - 1], B_list[i])
print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  
  rep(i, N) cin >> A[i];
  rep(i, N) A[i]--;
  rep(i, N) cin >> B[i];
  rep(i, N-1) cin >> C[i];
  int ans=0;
  int prev=-1;
  
  rep(i, N){
  	ans += B[A[i]];
    if(i>0 && prev>=0 && A[i] == A[prev] + 1) ans += C[A[prev]];
    prev = i;
  }
  
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	static int ShiftOnly(int[] a, int k){
		int[] numa = new int[k];
		for(int i=0; i<k; i++){
			while(a[i]%2==0){
				numa[i]++;
				a[i] /= 2;
			}
		}
		Arrays.sort(numa);
		return numa[0];
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++){
			A[i] = sc.nextInt();
		}
		System.out.println(ShiftOnly(A, N));
	}
}

Measured memory_bytes: 21972
#include<stdio.h>
int main(){
  int N,K,i;
  int j=0;
  scanf("%d%d",&N,&K);
  int d[110],A[110],cnt[110]={0};

  for(i=0;i<K;i++){
    scanf("%d",&d[i]);
    //printf("%d\n",d[i]);
    for(j=0;j<d[i];j++){
      scanf("%d",&A[j]);
      cnt[A[j]]++;
      //printf("%d\n",A[j]);
    }
  }
  int num=0;
  for(i=1;i<=N;i++){
    //printf("%d\n",cnt[i]);
    if(cnt[i]==0){
     // printf("%d\n",i);
      num++;
    }
  }
  printf("%d\n",num);
  return 0;
}



Measured memory_bytes: 1732
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int ans = INF;
	int n;
	cin >> n;
	while (n--)
	{
		int x;
		cin >> x;
		int cnt = 0;
		while (x % 2 == 0) x /= 2, cnt++;
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    console.log(input[0].slice(0, input[0].length - 'FESTIVAL'.length));

    return 0;
}


Measured memory_bytes: 22332
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
  
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].r != NIL) calcDepth(T[u].r,p);
  if(T[u].l != NIL) calcDepth(T[u].l,p+1);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  
  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 6400
#include<iostream> 
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath> 
#include<algorithm>
#define ll long long 
using namespace std;
const int maxn=500010, inf=1e9+233;
int n;
char s[233], t[233];

template<typename T>
inline void read(T &k)
{
    int f=1; k=0; char c=getchar();
    while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
    while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
    k*=f;
}

int main()
{
    scanf("%s", s+1);
    int n=strlen(s+1);
    t[1]='k'; t[2]='e'; t[3]='y'; t[4]='e'; t[5]='n'; t[6]='c'; t[7]='e';
    if(n==7)
    {
        bool flag=1;
        for(int i=1;i<=n;i++) flag&=(t[i]==s[i]);
            if(flag) return puts("YES"), 0;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j++)
        {
            int len=i-1+n-j;
            if(len!=7) continue;
            int now=1, flag=1;
            for(int k=1;k<i;k++) flag&=(t[now]==s[k]), now++;

            for(int k=j+1;k<=n;k++) flag&=(t[now]==s[k]), now++;

            if(flag) return puts("YES"), 0;
        }
    }
    puts("NO");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void func(int nn,int mm);
int n,s;
int box[10];
int sum,cnt;
int main(void){
	int i;
	
	for(i=0;i<=9;i++)	box[i]=i;
	while(1){
		cin>>n>>s;
		if(n==0&&s==0)	break;
		sum=0;
		cnt=0;
		func(0,0);
		cout<<cnt<<endl;
	}
	return 0;
}
void func(int nn,int mm){
	int i;
	if(mm==n){
		if(sum==s)	cnt++;
	}
	else{
		if(nn<=9){
			sum+=box[nn];
			func(nn+1,mm+1);
			sum-=box[nn];
			func(nn+1,mm);
		}
	}
}
	


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std ;
int main ()
{
  int K  , a;
  cin >> K ;
  a=K/2;
  if(K%2 !=0 )
  {
      cout << a*a+a;
  }
  else
    cout << a*a;


        return 0 ;
    }

Measured memory_bytes: 256
#include <stdio.h>

int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while (A[i] != key) i++;
    return i != n;
}

int main() {
    int i, n, A[10000+1], q, key, sum = 0;

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

    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &key);
        if (search(A, n, key)) sum++;
    }
    printf("%d\n", sum);

    return 0;
}



Measured memory_bytes: 2708
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
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));}
const ll mod = 1e9+7;
const ll INF = 1e10;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    if(n%1000==0){
        cout << 0 << endl;
    }
    else{
        cout << 1000 - n%1000 << endl;
    }
}

Measured memory_bytes: 3632
n = int(input())
import numpy as np
x=0
y=0
rad=0
k=1
while(1):
  y+=np.cos(rad*np.pi/180)
  x+=np.sin(rad*np.pi/180)
  if x<0.0001 and y<0.0001:
    print(k)
    break
  else:
    k+=1
    rad+=n

Measured memory_bytes: 27200
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

#line 2 "abc161_c.cpp"

int main() {
  ll n, k;
  cin >> n >> k;
  cout << min(n % k, k - n % k) << endl;
}


Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 102
#define rep(i,j,k) for(i=j;i<=k;++i)
struct node{
	short a,b,c,d;
}t,nt;
short temp,ans,n,m,i,j,k,p,A,B,C,D,vt,ex,ey;
short sum[N][N],mp[N][N];
short f[N][N][N][N];
queue<node> q;
short getsum(short x_1,short x_2,short y_1,short y_2){
	if(x_1>x_2) return 0;
	if(y_1>y_2) return 0;
	return sum[x_2][y_2]+sum[x_1-1][y_1-1]-sum[x_1-1][y_2]-sum[x_2][y_1-1];
}
void chkmax(short &a,short b){
	if(a==-1) q.push(nt);
	if(a<b) a=b;
}
void work(){
	rep(i,1,n){
	 	temp=0;
		rep(j,1,m){
			temp+=mp[i][j];
			sum[i][j]=sum[i-1][j]+temp;
		}
	}
	rep(i,1,n)
	 rep(j,i,n)
	  rep(k,1,m)
	   rep(p,k,m)
	    f[i][j][k][p]=-1;
	f[ex][ex][ey][ey]=0;
	t=(node){ex,ex,ey,ey};
	q.push(t);
	while(!q.empty()){
		t=q.front(); q.pop(); vt=f[t.a][t.b][t.c][t.d];
		A=t.b-ex+1; B=n-(ex-t.a); C=t.d-ey+1; D=m-(ey-t.c);
		nt=t;
		if(t.b+1<=B){
			nt.b++; 
			chkmax(f[nt.a][nt.b][nt.c][nt.d],vt+getsum(nt.b,nt.b,max(nt.c,C),min(nt.d,D)));
			nt.b--; 
		}
		if(t.d+1<=D){
			nt.d++;
			chkmax(f[nt.a][nt.b][nt.c][nt.d],vt+getsum(max(nt.a,A),min(nt.b,B),nt.d,nt.d));
			nt.d--;
		}
		if(t.a-1>=A){
			nt.a--;
			chkmax(f[nt.a][nt.b][nt.c][nt.d],vt+getsum(nt.a,nt.a,max(nt.c,C),min(nt.d,D)));
			nt.a++;
		}
		if(t.c-1>=C){
			nt.c--;
			chkmax(f[nt.a][nt.b][nt.c][nt.d],vt+getsum(max(nt.a,A),min(nt.b,B),nt.c,nt.c));
			nt.c++;
		}
		chkmax(ans,vt);
	}
}
void read(short &p){
	p=0; char x=getchar();
	while(x<'0' || x>'9') x=getchar();
	while(x>='0'&&x<='9'){
		p=p*10+x-'0';
		x=getchar();
	}
}
int main(){
	read(n); read(m);
	rep(i,1,n){
		j=0;
		char x=getchar();
	   while((x!='.')&&(x!='E')&&(x!='o')) x=getchar();
	   while((x=='.')||(x=='E')||(x=='o')){
		   j++;
		   if(x=='E') ex=i,ey=j;
		   else if(x=='o') mp[i][j]=1;
		   x=getchar();
	   }
	}
	work();
	printf("%d\n",(int)ans);
	return 0;
}

Measured memory_bytes: 209536
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1e9
#define EPS 10e-8

int main(){
  ll N,t; cin>>N>>t;
  ll a[100007]; 
  rep(i,N) {
    cin>>a[i];
  }
  ll sa=0,mi=a[0],cnt=1;
  for(int i=1;i<=N-1;i++){
    mi = min(mi, a[i]);
    if(sa==a[i]-mi) cnt++;
    if(sa<a[i]-mi) sa = a[i]-mi, cnt = 1;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  long n, T;
  cin >> n >> T;
  long t[n];
  for(int i = 0; i < n; i++) cin >> t[i];

  long sum_water = T;
  for(int i = 1; i < n; i++) {
    sum_water += min((t[i]-t[i-1]), T);
  }
  cout << sum_water << endl;
  return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  cout << (a - 1) * (b - 1) << '\n';
}

Measured memory_bytes: 892
n = int(input())
m = list(map(int,input().split()))

c = 0

for i in range(n):
  if i == 0:
    continue
  if m[i-1]>m[i]:
    res = m[i-1] - m[i]
    c += res
    m[i] = res+m[i]
  
print(c)



Measured memory_bytes: 32176
H,W,D = list(map(int,input().split()))
grid = [list(map(int,input().split())) for i in range(H)]

num_point = {}
for i in range(H):
    for j in range(W):
        num_point[grid[i][j]] = (i+1,j+1)

Q = int(input())
lst = [0]*(H*W+1)
LR = []
for _ in range(Q):
    LR.append(list(map(int,input().split())))
    lst[LR[-1][0]] += 1
    lst[LR[-1][1]] -= 1

ans_lst = [0]*(H*W+1)

for i in range(1,D+1):
    for j in range(i+D,H*W+1,D):
        sx,sy = num_point[j-D]
        tx,ty = num_point[j]
        ans_lst[j] += ans_lst[j-D]+(abs(tx-sx)+abs(ty-sy))
for L,R in LR:
    print(ans_lst[R]-ans_lst[L])

Measured memory_bytes: 48920
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(a, b, c) for(ll c=a;c<b;c++)
#define re(b, c) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, a, b;std::cin >> n >> a >> b;
  vll x(n), dp(n, 0);
  re(n, i) std::cin >> x[i];
  rep(1, n, i) dp[i] = dp[i-1] + min(b, a*(x[i]-x[i-1]));
  std::cout << dp[n-1] << '\n';
  return 0;
}


Measured memory_bytes: 1792
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline

H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

answer = []
for i in range(H):
    for j in range(W):
        if A[i][j] % 2:
            if j < W - 1:
                answer.append((i + 1, j + 1, i + 1, j + 2))
                A[i][j] -= 1
                A[i][j + 1] += 1
            else:
                if i < H - 1:
                    answer.append((i + 1, j + 1, i + 2, j + 1))
                    A[i][j] -= 1
                    A[i + 1][j] += 1

print(len(answer))
for a in answer:
    print(*a)

Measured memory_bytes: 75228
/*
  AUTHOR:SOURABH
  CREATED:07:03:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll t,n,i;
    string s;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>s;
        n=s.length();
        if(n%2)
        {cout<<"No\n";return 0;}
        for(i=0;i<n;i+=2)
        {
            if(s[i]!='h' || s[i+1]!='i')
                {cout<<"No\n";return 0;}
        }
        cout<<"Yes";
    }
    return 0;
}
















Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)

	NewReader(n)
	a := ReadInts(" ")

	current := 0
	breakCount := 0

	for _, v := range a {
		if v != current+1 {
			breakCount++
			continue
		}
		current++
	}

	if current == 0 {
		fmt.Println("-1")
		return
	}
	fmt.Println(breakCount)
}

type Reader struct {
	rdr  *bufio.Reader
	size int
}

var reader *Reader

func NewReader(size int) {
	reader = &Reader{
		bufio.NewReaderSize(os.Stdin, size),
		size,
	}
}

func ReadLine() string {
	buf := make([]byte, 0, reader.size)
	for {
		line, isPrefix, err := reader.rdr.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func ReadStrs(sep string) []string {
	return strings.Split(ReadLine(), sep)
}

func ReadInts(sep string) []int {
	a := ReadStrs(sep)
	n := make([]int, 0)
	for _, v := range a {
		if i, e := strconv.Atoi(v); e == nil {
			n = append(n, i)
		}
	}
	return n
}


Measured memory_bytes: 13568
#include <iostream>

using namespace std;

int main()
{
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    int i;
    for( i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK";
            break;
        }
    }
    if(i==b+1){
        cout<<"NG";
    }
    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::unordered_set<std::string> set;
  std::copy_n(std::istream_iterator<std::string>(std::cin), N, std::inserter(set, set.end()));
  std::cout << set.size() << std::endl;
  return 0;
}

Measured memory_bytes: 17692
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()	
	{
		string[] args = Console.ReadLine().Split(' ');
		int H = Int32.Parse(args[0]);
		int W = Int32.Parse(args[1]);

		string[] S = new string[H];
		for(int i = 0; i < H; i++)
			S[i] = Console.ReadLine();

		int[,] ans = new int[H,W];
		for(int i = 0; i < H; i++)
		{
			for(int j = 0; j < W; j++)
			{
				if(S[i][j] == '.')
					continue;

				for(int dy = -1; dy <= 1; dy++)
				{
					int ny = i + dy;
					if(ny < 0 || ny >= H)
						continue;

					for(int dx = -1; dx <= 1; dx++)
					{
						int nx = j + dx;
						if(nx < 0 || nx >= W)
							continue;

						ans[ny,nx]++;
					}
				}
			}
		}

		for(int i = 0; i < H; i++)
		{
			for(int j = 0; j < W; j++)
			{
				Console.Write(S[i][j] == '.' ? ans[i,j].ToString() : "#");
			}
			Console.WriteLine();
		}
	}
}





Measured memory_bytes: 11200
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#include <climits>
#include <deque>
#include <random>
#include <functional>
#include <unordered_map>
#define rep(i,n) for(int i=0;i < (int)(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
    string s;
    cin >> s;
    if((s[0] == s[1] and s[1]== s[2]) or(s[1] == s[2] and s[2] == s[3])){
        puts("Yes");
    }else{
        puts("No");
    }
    
}

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

int n, m, q;
const int MAX = 51;
vector<int> a(MAX), b(MAX), c(MAX), d(MAX);
int ans = 0;

int f(int x, int y, vector<int> &v)
{
    return v[y] - v[x];
}

void rec(vector<int> &v)
{
    if (v.size() == n)
    {
        int score = 0;
        rep(i, q)
        {
            if (c[i] == f(a[i], b[i], v))
                score += d[i];
        }
        ans = max(ans, score);
        return;
    }
    for (int i = 1; i <= m; i++)
    {
        if (v.size() > 0 && v[v.size() - 1] > i)
            continue;
        v.push_back(i);
        rec(v);
        v.pop_back();
    }
}

int main()
{
    cin >> n >> m >> q;
    rep(i, q)
    {
        int aa, bb;
        cin >> aa >> bb;
        aa--;
        bb--;
        a[i] = aa;
        b[i] = bb;
        cin >> c[i] >> d[i];
    }
    vector<int> v;
    rec(v);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, X = map(int, readline().split())
data = np.int32(read().rstrip().split()).reshape(N, M + 1)
C = data[:, 0]
A = data[:, 1:]

ans = 10**8
for choses in itertools.product([0, 1], repeat=N):
    row_mask = np.int32(choses) > 0
    if np.all(A[row_mask].sum(axis=0) >= X):
        ans = min(ans, C[row_mask].sum().item())

print(-1 if ans == 10**8 else ans)

Measured memory_bytes: 27388
'use strict';
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    const s = input[0];
    if(s[0] != "A"){
        console.log("WA");
        return 0;
    }
    let numC = 0;
    for(let i = 1; i < s.length; i++){
        if(i >= 2 && i <= s.length - 2 && s[i] == "C"){
            numC++;
            if(numC > 1){
                console.log("WA");
                return 0;
            }
        }else if(s[i].search(/[a-z]/) == -1){
            console.log("WA");
            return 0;
        }
    }
    if(numC != 1){
        console.log("WA");
    }else{
        console.log("AC");
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
#include<bits/stdc++.h>
using namespace std;
const double eps = 0.0000000001;

bool eq(double a,double b){
  return ( fabs(a-b) < eps );
}

struct Point{
  double x,y,z;
  
  Point operator + (Point p){
    return (Point){x+p.x,y+p.y,z+p.z};
  }

  Point operator - (Point p){
    return (Point){x-p.x,y-p.y,z-p.z};
  }
  
  Point operator * (double k){
    return (Point){x*k,y*k,z*k};
  }
};
typedef Point Vector;

struct Segment{
  Point p, v;
};
typedef Segment Line;


void pr(Point p){
  printf("%.5f %.5f %.5f\n",p.x,p.y,p.z);
}


double abs(Point p){
  return sqrt( p.x*p.x + p.y*p.y + p.z*p.z );
}
double norm(Point p){
  return  p.x*p.x + p.y*p.y + p.z*p.z;
}

double dot(Point a,Point b){
  return a.x*b.x+a.y*b.y+a.z*b.z;
}

Point cross(Point a,Point b){
  double nx=a.y*b.z-b.y*a.z;
  double ny=a.z*b.x-b.z*a.x;
  double nz=a.x*b.y-b.x*a.y;
  return (Point){nx,ny,nz};
}

bool eq(Point a,Point b){
  return ( eq(a.x,b.x) && eq(a.y,b.y) && eq(a.z,b.z) );
}


double getDistanceLP(Line a,Point p){
  Point k=p-a.p;
  double c=abs( cross(a.v,k) );
  return c/abs(a.v);
}

double getDistanceSP(Segment a,Point p){
  Point k=p-a.p;
  if( dot(a.v,k) < 0 )return abs(a.p-p);
  k=p-(a.p+a.v);
  if( dot(a.v*-1.0,k) < 0 )return abs(a.p+a.v-p);
  return getDistanceLP(a,p);
}


bool getCrossCS(Point c,double r,Segment s){
  double A=getDistanceSP(s,c);
  double B=abs(c-s.p);
  double C=abs(c-(s.p+s.v));
  
  if(r+eps < A)return false;
  if(B+eps < r && C+eps < r)return false;
  return true;
}

int N,M,R;
Point S[2005];
double Sr[2005];
Point E;
Point T[20];
double Tb[20];

vector<int> G[20];

void init(){
  for(int i=0;i<M;i++)G[i].clear();
}

int main(){
  while(1){
    cin>>N>>M>>R;
    if(N==0&&M==0&&R==0)break;
    init();
    
    for(int i=0;i<N;i++)
      scanf("%lf %lf %lf %lf",&S[i].x,&S[i].y,&S[i].z,&Sr[i]);
    
    for(int i=0;i<M;i++)
      scanf("%lf %lf %lf %lf",&T[i].x,&T[i].y,&T[i].z,&Tb[i]);

    scanf("%lf %lf %lf",&E.x,&E.y,&E.z);

    for(int i=0;i<M;i++){
      Tb[i]/=norm(T[i]-E);
      for(int j=0;j<N;j++){
        if(getCrossCS(S[j],Sr[j],(Segment){T[i],E-T[i]}))
          G[i].push_back(j);
      }
    }
    
    double ans=0;

    for(int i=0;i<(1<<M);i++){
      bool flg[2005]={};    
      int cnt=0;
      double sum=0;
      for(int j=0;j<M;j++){
        if(i>>j&1)continue;
        sum+=Tb[j];
        for(int k=0;k<(int)G[j].size();k++){
          if(flg[G[j][k]])continue;
          cnt++;
          flg[G[j][k]]=true;
        }
      }
      if(cnt>R)continue;
      ans=max(ans,sum);
    }
    printf("%.8f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1440
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int n, a[200000];
ll sum[200000];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n ;
    cin>>a[0];
    sum[0]=a[0];
    for(int i=1;i<n;i++){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    ll ans=10000000000000;
    int l=0;
    int r=2;
    for(int i=1;i<n-1;i++){
        while(true){

            if(abs(sum[i]-sum[l]-sum[l])<=abs(sum[i]-sum[l+1]-sum[l+1])||l+1>=i)
            break;
            l++;
        }
        while(true){
            if(i==r){}
            else if(abs(-sum[n-1]+sum[r]+sum[r]-sum[i])<=abs(-sum[n-1]+sum[r+1]+sum[r+1]-sum[i])||r+1==n-1)
            break;
            r++;
        }
        ans=min(ans,abs(max(sum[l],max(sum[i]-sum[l],max(sum[r]-sum[i],sum[n-1]-sum[r])))-min(sum[l],min(sum[i]-sum[l],min(sum[r]-sum[i],sum[n-1]-sum[r])))));
    }
    cout << ans << "\n";
}

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

typedef long double     ld;
typedef long long       ll;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;

const int inf = 0x3f3f3f3f;
const ll  INF = 0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e)    for(int i=b; i<=e; i++)
#define FORD(i, b, e)   for(int i=b; i>=e; i--)
#define SIZE(x)         ((int)(x).size())
#define pb              push_back
#define st              first
#define nd              second
#define all(a)          begin(a), end(a)
#define watch(x)        cerr << (#x) << " is " << (x) << '\n';

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

    ll n;
    ll t[110];
    cin>>n;
    ld x=0;

    FOR(i,1,n){
        cin>>t[i];
        x+=1.0/t[i];
    }


    cout<<fixed<<setprecision(9)<<(ld)1/x;



    return 0;
}


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

int main() {
    ll n, m, r;
    cin >> n >> m >> r;
    vector<ll> s(r);
    rep(i, 0, r) cin >> s[i];
    rep(i, 0, r) s[i]--;
    const ll inf = 1e12;
    vector< vector<ll> > d(n, vector<ll>(n, inf));
    rep(i, 0, n) d[i][i] = 0;
    rep(i, 0, m) {
        ll u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        if(d[u][v] <= w) continue;
        d[u][v] = w;
        d[v][u] = w;
    }
    rep(i, 0, n){
        rep(j, 0, n){
            rep(k, 0, n){
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
    ll ans = inf;
    vector<ll> array(r);
    rep(i, 0, r) array[i] = i;
    do {
        ll tmp = 0;
        rep(i, 0, r-1) {
            ll from = array[i], to = array[i+1];
            tmp += d[s[from]][s[to]]; 
        }
        ans = min(ans, tmp);
    } while (next_permutation(array.begin(), array.end()));
    if(ans >= inf) cout << "-1\n";
    else cout << ans << "\n";
    return 0;
}

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

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

  if (((a + b) % 2) > 0) {
    cout << ((a + b) / 2) + 1 << endl;
  } else {
    cout << (a + b) / 2 << endl;
  }
}


Measured memory_bytes: 256
a=[]
a=list(input().split())
    
stack=[]



for i in a:
    if i.isdigit() == True:
       stack.append(i)
       
    else:
        y=stack.pop()
        x=stack.pop()
        if i=="+":
            stack.append(int(x)+int(y))
        elif i=="-":
            stack.append(int(x)-int(y))
        elif i=="*":
            stack.append(int(x)*int(y))

        


print(stack[0])



Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  ll a[n+1];
  ll tmp=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    for(int j=1;a[i]%2==0;j++){
      a[i]/=2;
      tmp++;
    }
  }
  cout<<tmp<<endl;
  return 0;
}


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

int N, Z, W;
vector<int> C;

int cost(int l, int r) {return abs(l-r);}

int memo[2][2001];
int dfs(int turn, int n) {
  if(memo[turn][n]) return memo[turn][n];
  auto res = cost(C[0],C[n]);
  for(auto i=1; i<n; ++i) {
    if(turn) res = min(res, dfs(!turn, i));
    else     res = max(res, dfs(!turn, i));
  }
  return memo[turn][n] = res;
}

int main() {
  cin >> N >> Z >> W;
  C.resize(N);
  for(auto& i: C) cin >> i;
  reverse(begin(C), end(C));
  C.emplace_back(W);
  cout << dfs(0, N) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        for (int i = 1; i < 2000; i++) {
            int tmp1 = (int) (i * 0.08);
            int tmp2 = (int) (i * 0.1);
            if(tmp1 == a && tmp2 == b) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }
}


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

using namespace std;

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    long long x,k,d;
    cin >> x >> k >> d;
    if(x>0){
        long long steps = abs(x)/d;
        long long mind = x - (x/d)*d;
        if(abs(mind - d) < mind){
            mind = abs(mind-d);
            steps += 1;
        }
        if(k<steps){
            cout << abs(x - k*d);
        } 
        else{
            if((k-steps)%2) cout << min(abs(mind+d), abs(mind-d));
            else cout << mind;
        }
    }
    else{
        long long steps = abs(x)/d;
        long long mind = abs(x - (x/d)*d);
        if(abs(mind+d)<mind){
            mind = abs(mind+d);
            steps += 1;
        }
        if(k<steps) cout << abs(x+k*d);
        else{
            if((k-steps)%2) cout << min(abs(mind+d), abs(mind-d));
            else cout << mind;
        }
    }
    return 0;
}

Measured memory_bytes: 3552
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
	ll A,B,i;
    cin >> A >> B;
    for(i=1;i<=1000;i++){
        if(i*8/100==A && i*10/100==B){cout << i;return 0;}
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char a[1000];
	scanf("%s",a);
	int m=0;
	for(int b=0;a[b]!='\0';b++)
	{
		if(a[b]=='C')
		{
			for(int i=b+1;a[i]!='\0';i++)
			{
				if(a[i]=='F')
				{
					m++;
					printf("Yes\n");
					break;
				}
			}
		}
		if(m==1)
			break;
	}
	if(m==0)
		printf("No\n");
	return 0;
}
		

Measured memory_bytes: 128
n = int(input())
sl = [input() for _ in range(n)]
sb,la,cnt,both = 0,0,0,0
for s in sl:
  cnt += s.count("AB")
  if s[0] + s[-1] == "BA":
    both += 1
  elif s[0] == "B":
    sb += 1
  elif s[-1] == "A":
    la += 1
if both:
  cnt += both-1
  if la:
    cnt += 1
    la -= 1
  if sb:
    cnt += 1
    sb -= 1
print(cnt + min(la,sb))

Measured memory_bytes: 3700