akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <int>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
const ll mod=1e9+7;
bool is_prime(int n)
{
    if(n==2)
        return true;
    if(n%2==0||n<2)
        return false;
    for(int i=3; i<=sqrt(n); i+=2)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
long long power(ll n, ll k){
    if(k==0) return 1;
    ll sq=(power(n,k/2))%mod;
    sq=(sq*sq)%mod;
    if(k%2==1)
        sq=(sq*n)%mod;
    return sq%mod;
}
long long gcd(long long a,long long b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
// lcm = (a*b)/gcd(a,b)
//freopen("input.txt" ,"r",stdin );
//freopen("output.txt","w",stdout);
int n,W;
vector<int>w,v;
ll memo[105][100005];
ll fun(int idx,int rest)
{
	if (idx ==n)
		return 0;
    if(rest<=0)return -1e9;
	ll &ret = memo[idx][rest];
	if (~ret)
		return ret;
    if(w[idx]<=rest)ret=max(ret,fun(idx+1,rest-w[idx])+v[idx]);
    return ret=max(ret,fun(idx+1,rest));
}
void fast();
int main()
{
    fast();
    cin>>n>>W;
    w.resize(n);
    v.resize(n);
    memset(memo,-1,sizeof memo);
    loop(n)cin>>w[i]>>v[i];
    cout<<fun(0,W);
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/


Measured memory_bytes: 82304
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define fill(x,v) memset(x, v, sizeof(x))
#define PI (ld)acos(-1)
#define endl '\n'
#define dbg(x) cout<<#x<<"="<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl; 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define IO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
const ld eps=(ld)1e-9;
const ll inf=(ll)1e18;
const ll mod=(ll)1e9+7;
int n;
ld p[3001], d[3001][3001] ;
void f(){
	fill(d,0);
	d[0][0]=1;
	for (int i = 1; i <=n; ++i)
	{
		for (int j = 0; j <=i; ++j)
		{
			d[i][j]=d[i-1][j]*(1-p[i])+(j>0?d[i-1][j-1]*p[i]:0);
		}
	}
	ld ans=0;
	for (int j = (n+1)/2; j <=n; ++j)
	{
		ans+=d[n][j];
	}
	cout<<setprecision(11)<<ans;
}

void solve(){
	cin>>n;
	for (int i = 1; i < n+1; ++i)
	{
		cin>>p[i];
	}
	f();
}

int main(){fio;
int test=1;
// cin>>test;
while(test--){
	solve();
	cout<<endl;
}
return 0;
}

Measured memory_bytes: 141056
#include<stdio.h>
#include<stdlib.h>
int main()
{
 int A=0,B=0,C=0;
  scanf("%d %d\n",&A,&B);
   if((A<(2*B))||(B>A))
   {
       printf("0");
   }
   else
      {
         C=A-(2*B);
        printf("%d",C);
      }
      return 0;
      }

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

using namespace std;
                                                                          	
#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define file ""     
#define F first                       
#define S second 
#define pb push_back   

typedef long long ll; 
typedef pair <ll, ll> PII;
typedef double ld;
                                                                                          
const int N = 2e6 + 1; 
const int INF = 1e9 + 9;
const int B = 1e9 + 7;

string s;
               
int main () {
#ifdef machine42
	freopen (file"in", "r", stdin);
	freopen (file"out", "w", stdout);
#endif		
	ios_base :: sync_with_stdio (0);
	cin.tie(0);

	cin >> s;
	int ans = 0;
	int cnt = 0;
	for (auto c : s) { 
		if (c == 'S') ++cnt;
		else
		if (cnt == 0) ++ans;
		else --cnt;
	}
	ans += cnt;
	cout << ans << "\n";

	return 0;         	
}


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

int main(){
  int i,j,cnt;
  int n;
  cin>>n;
  double a[n];
  for(i=0;i<n;i++)cin>>a[i];
  double sum=0;
  for(i=0;i<n;i++)sum+=1/a[i];
  printf("%.7lf",1/sum);
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> c(N);
  int a;
  
  for (int i=0; i<2*M; i++) {
    cin >> a;
    c.at(a-1) += 1;
  }
  
  for (int i=0; i<N; i++)
    cout << c.at(i) << endl;
}



Measured memory_bytes: 256
s = input()
t = input()

cur = 0
count_min = 1000
while cur + len(t) -1 < len(s):
    count = 0
    for i in range(len(t)):
        if t[i] != s[i + cur]:
            count += 1
    if count < count_min:
        count_min = count
    cur += 1
print(count_min)


Measured memory_bytes: 67572
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def check(vec, init_pos, target_pos):
    dp = {init_pos}

    for nv in vec:
        dp_next = set()
        for v in dp:
            dp_next.add(v - nv)
            dp_next.add(v + nv)
        dp = dp_next

    return target_pos in dp


def main():
    S = readline().strip()
    x, y = map(int, readline().split())

    L = [len(commands) for commands in S.split('T')]

    init_x = L[0]
    x_commands = L[2::2]
    y_commands = L[1::2]

    ok = check(x_commands, init_x, x) and check(y_commands, 0, y)

    if ok:
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 81020
#include <stdio.h>

int main(void) {
  int N;
  scanf("%d", &N);

  int Max = 0;
  int Sum = 0;
  for(int i = 0; i < N; i++) {
    int P;
    scanf("%d", &P);

    if(Max < P) Max = P;
    Sum += P;
  }

  printf("%d\n", Sum - Max / 2);

  return 0;
}


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

   int main(){
       int a,b;
       cin >> a >> b;
       if(a * b % 2 == 0){
           cout << "Even" << endl;
       }
       else{
           cout << "Odd" << endl;
       }
      
}


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

using namespace std;

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

  int N;
  cin >> N;
  vector<int> a(N);

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

  int p = 1;
  for (int i = 1; i <= N; i++) {
    if (a[p - 1] == 2) {
      cout << i << '\n';
      return 0;
    }
    p = a[p - 1];
  }
  cout << -1 << '\n';

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

int dp[405][405];

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

	int n;
	cin >> n;
	int a[n + 1], sum[n + 1] = {0};
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
	}
	memset(dp, 63, sizeof(dp));
	for(int len = 1; len <= n; len++) {
		for(int i = 1; i + len - 1 <= n; i++) {
			if(len == 1) {
				dp[i][i] = 0;
			}
			else {
				for(int j = i; j < i + len - 1; j++) {
					dp[i][i + len - 1] = min(dp[i][i + len - 1], sum[i + len - 1] - sum[i - 1] + dp[i][j] + dp[j + 1][i + len - 1]);
				}
			}
		}
	}
	cout << dp[1][n];

	return 0;
}

Measured memory_bytes: 4900
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i <= s.size() - 3; ++i){
		if (s.substr(i, 3) == "ABC")
			ans++;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define show(ans)  cout << ans << endl;


int main() {long N;
cin >> N;
vector<long> dp(N+1, 100001);
dp[0] = 0;
erep(i, N){
    long power = 1;
    while(power <= i){//????
        dp[i] = min(dp[i], dp[i-power]+1);
        power *= 6;
    }
    power = 1;
    while(power <= i){//????
        dp[i] = min(dp[i], dp[i-power]+1);
        power *= 9;
    }
}


show(dp[N]);
  return 0;
 
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <string>
#include <stack>
 
using namespace std;
 
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int>>
#define ss second
#define ff first
#define ll long long
#define lld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define pqll priority_queue< ll >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define INF 1000000000
#define NINF -1000000000
 
ll maxll(ll a , ll b ){
    return a > b ? a : b;
}
 
ll minll(ll a , ll b){
    return a > b ? b : a;
}

// bool check(ll z){
//     ll temp = k;
//     // cout << z << endl;
//     f(i , 0 , n){
//         ll sub = (ll)z * a[i];
//         if (sub > b[i])
//         temp -= (sub -b[i]);
//         if (temp < 0){
//             return 0;
//         }
//     }
//         // cout << z << endl;
//     sol = z;
//         return 1;
// }


// To count Number of ones in a binary number
// int count_one(int x){
//     x = (x & (0x55555555)) + ((x >> 1) & (0x55555555));
//     x = (x & (0x33333333)) + ((x >> 2) & (0x33333333));
//     x = (x & (0x0f0f0f0f)) + ((x >> 4) & (0x0f0f0f0f));
//     x = (x & (0x00ff00ff)) + ((x >> 8) & (0x00ff00ff));
//     x = (x & (0x0000ffff)) + ((x >> 16) & (0x0000ffff));
//     // cout << x << endl;
//     return x;
// }

// int gcd (int a , int b){
//     return __gcd(a,b);
// }

// void print_vi(vi a){
//     for (int i: a){
//         cout << i << " " ;
//     }
//     cout << endl;
// }

// Best algo to find maximum sum subarray (contiguous)
// ll kadane (vl a){
//     ll curr = 0 , maxi = 0;
//     f(i , 0 , a.size()){
//         curr = max(a[i] , curr + a[i]);
//         maxi = max(maxi , curr);
//     }
//     return maxi;
// }

typedef struct books{
    int time;
    int a;
    int b;
}book;

book boo[200001];
bool compare(book a , book b){
    return a.time > b.time;
}

void solve(){
    
    string a , b;
    cin >> a >> b;
    int count = 0;
    for ( int i = 0 ; i < a.size() ; i++){
        if (a[i] != b[i])
        count++;
    }
    cout << count << endl;
}

 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
 
 
    
    int t = 1;
    // cin >> t;
    
    while(t--){
        
        solve();
    }
}

Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#define ll long long 
using namespace std;

int main() {
	int ans = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.length() - 1; i++) {
		if (s[i] != s[i + 1]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n, time;
        cin >> n >> time;
        vector<ll> t(n);
        for(i = 0; i < n; i++){
            cin >> t[i];
        }
        ll ans = 0;
        ll last = 0;
        t.pb(INF);
        for(i = 0; i <= n; i++){
            if(last <= t[i]){
                ans += time;
                last = t[i] + time;
            }
            else{
                last = t[i] + time;
                ans += t[i] - t[i - 1];
            }
        }
        cout << ans - time;
    }
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N,M;
  cin>>N>>M;
  vector<vector<int>>A(N,vector<int>(M));
  for(int i=0;i<N;i++)for(int j=0;j<M;j++)cin>>A[i][j];
  for(int i=0;i<N;i++)for(int j=0;j<M;j++)A[i][j]--;
  vector<bool>ng(M,false);
  ll ans=N;
  for(int i=0;i<M-1;i++){
    ll res=0;
    map<int,int>m;
    for(int j=0;j<N;j++){
      for(int k=0;k<M;k++){
        if(!ng[A[j][k]]){
          m[A[j][k]]++;
          break;
        }
      }
    }
    vector<pair<ll,ll>>a;
    for(auto it:m)a.push_back({it.second,it.first});
    ans=min(ans,(*max_element(rng(a))).first);
    ng[(*max_element(rng(a))).second]=true;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli f(lli x) {
  if (x % 4 == 3 || x <= 0) return 0;
  return x ^ f(x - 1);
}

lli a, b;
int main() {
  cin >> a >> b;
  if (a==b) {cout << a << endl; return 0; }
  cout << (f(b) ^ f(a-1)) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n, l;

    cin >> n >> l;
    vector < string > arr(n);

    for (int i = 0; i < n; ++i)
        cin >> arr[i];

    for (int i = 0; i < n-1; ++i)
        for (int j = n-1; j > i; --j) {
            if (arr[j] < arr[j-1]) {
                string temp;
                temp = arr[j];
                arr[j] = arr[j-1];
                arr[j-1] = temp;
            }
        }

    for (int i = 0; i < n ; ++i)
        cout << arr[i];
    return 0;
}


Measured memory_bytes: 3136
from collections import defaultdict
from math import gcd

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    all = 0
    for a in A:
        all = gcd(all, a)
    if all != 1:
        return "not coprime"

    M = 10 ** 6
    B = defaultdict(int)
    for a in A:
        B[a] += 1

    for i in range(2, M + 1):
        cnt = 0
        for j in range(i, M, i):
            cnt += B[j]
        if cnt > 1:
            return "setwise coprime"

    return "pairwise coprime"

print(solve())


Measured memory_bytes: 264880
s = int(input())
count = 1
a = s
ans = {s}
while count<1000001:
  if a%2==0:
    a/=2
  else:
    a = 3*a+1
  if a in ans:
    print(count+1)
    break
  else:
    count+= 1
    ans.add(a)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n, k;
    cin >> n >> k;
    ll h[n];
    rep(i,n)cin >> h[i];
    sort(h,h+n,greater<ll>());

    if(k >= n)k = n;

    ll ans = 0;

    rep(i,n){
        if(i < k)continue;
        ans += h[i];
    }

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


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

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  var count = 0;
  var r = Number(lines[0].split(" ")[0]);
  var g = Number(lines[0].split(" ")[1]);
  var b = Number(lines[0].split(" ")[2]);
  var limit = Number(lines[0].split(" ")[3]);
  for (i = 0; i * r <= limit; i++) {
    for (j = 0; j * g <= limit; j++) {
      if ( ( limit - r*i - g*j ) % b == 0 && limit >= r*i + g*j) {
        count++;
        // console.log(r + ", " + g + ", " + (limit - r*i - g*j)/b );
      } else if ( limit < r*i + g*j ) {
        break
      }
    }
  }
  console.log(count);
});

Measured memory_bytes: 21320
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int a,b,c;
	
	cin>>a>>b>>c;
	
	cout<<(int)floor((double)b/c)-(int)ceil((double)a/c)+1<<endl;
}


Measured memory_bytes: 3648
n,m = [int(x) for x in input().split()]
li = []
for _ in range(m):
    li.append([int(x) for x in input().split()])
z = sorted(li,key=lambda x:x[1])
ans = 0
res = 0
for i in z:
    if res < i[0]:
        ans += 1
        res = i[1]-0.5
print(ans)

Measured memory_bytes: 23580
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
#include <iterator>
#include <complex>
#include <assert.h>
 
using namespace std;
 
typedef long long ll;
typedef pair <double,double> P;
typedef pair <int,P > PP;
 
int tx[] = {+0,+1,+0,-1};//URDL
int ty[] = {-1,+0,+1,+0};
 
static const double EPS = 1e-8;

bool dp[5500][1<<12];

int main(){
  int num_of_element_strings;
  int num_of_lines;
  while(~scanf("%d %d",&num_of_element_strings,&num_of_lines)){
    if(num_of_element_strings == 0 && num_of_lines == 0) break;

    vector<string> elements;
    for(int i = 0; i < num_of_element_strings; i++){
      string tmp;
      cin >> tmp;
      elements.push_back(tmp);
    }

    string text= "";
    for(int i = 0; i < num_of_lines; i++){
      string tmp;
      cin >> tmp;
      text += tmp;
    }

    memset(dp,false,sizeof(dp));
    for(int i = 0; i < elements.size(); i++){
      int next = 0;
      while(true){
        int current = text.find(elements[i],next);
        if(current == string::npos) break;
        dp[current + elements[i].size()][1<<i] = true;
        next = current + 1;
      }
    }

    for(int text_i = 0; text_i < text.size(); text_i++){
      for(int S = 0; S < (1<<elements.size()); S++){
        if(!dp[text_i][S]) continue;
        for(int to = 0; to < elements.size(); to++){
          if((S & (1<<to))) continue;
          dp[text_i + elements[to].size()][S | (1<<to)] 
            |= dp[text_i + elements[to].size()][(1<<to)];
            }
      }
    }
    int res = 0;
    for(int text_i = 0; text_i <= text.size(); text_i++){
      if(dp[text_i][(1<<elements.size()) - 1]) res++;
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 23280
while line = gets
  a = line.split(" ")
  a[0] = a[0].to_i
  a[1] = a[1].to_i
  a[2] = a[2].to_i
  if a[0]==-1 && a[1] == -1 && a[2] == -1
    break
  end
  if a[0] == -1 || a[1] == -1
    puts "F"
  else
    if a[0] + a[1] >= 80
      puts "A"
    else
      if a[0] + a[1] >= 65
        puts "B" 
      else
        if a[0] + a[1] >= 50 
          puts "C"
        else
          if a[0] + a[1] >= 30
            if a[2] >= 50
              puts "C"
            else
              puts "D"
            end
          else
            puts "F"
          end
        end
      end
    end
  end
end

Measured memory_bytes: 8684
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <math.h>


using namespace std;

int main() {
    int a, b;
    char op;
    cin >> a >> op >> b;
    if (op == '+') {
        cout << a + b << endl;
    } else {
        cout << a - b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N,W,H;
vector<P> t;

bool check(P p,int a){
  if(p.first<p.second){
    return (p.first<=a&&a<=p.second);
  }else{
    return (p.first<=a||a<=p.second);
  }
}

int calcArg(int x,int y){
  if(x==0)return y;
  if(y==H)return H+x;
  if(x==W)return H+W+H-y;
  return H+W+H+W-x;
}

int calcLU(int x,int y){
  int d=min(x,H-y);
  return calcArg(x-d,y+d);
}

int calcRU(int x,int y){
  int d=min(W-x,H-y);
  return calcArg(x+d,y+d);
}

int calcRD(int x,int y){
  int d=min(W-x,y);
  return calcArg(x+d,y-d);
}

int calcLD(int x,int y){
  int d=min(x,y);
  return calcArg(x-d,y-d);
}

int solve(int si){
  int res=1,last=t[si].second;
  for(int i=si;i<si+N;i++){
    if(check(t[i],last))continue;
    res++;
    last=t[i].second;
  }
  return res;
}

int main(){
  cin>>N>>W>>H;
  for(int i=0;i<N;i++){
    int x,y;
    char ch;
    P p;
    cin>>x>>y>>ch;
    if(ch=='N'){
      p.first=calcLU(x,y);
      p.second=calcRU(x,y);
    }else if(ch=='E'){
      p.first=calcRU(x,y);
      p.second=calcRD(x,y);
    }else if(ch=='S'){
      p.first=calcRD(x,y);
      p.second=calcLD(x,y);
    }else if(ch=='W'){
      p.first=calcLD(x,y);
      p.second=calcLU(x,y);
    }
    t.push_back(p);
  }

  for(int i=0;i<N;i++)swap(t[i].first,t[i].second);
  sort(t.begin(),t.end());
  for(int i=0;i<N;i++)t.push_back(t[i]);
  for(int i=0;i<N+N;i++)swap(t[i].first,t[i].second);
  int ans=1e9;
  for(int i=0;i<N;i++)ans=min(ans,solve(i));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
int main(void){
  int a,b,c;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  
  int d=0;
  
  if(a==b&&b!=c) d=1;
  if(b==c&&c!=a) d=1;
  if(c==a&&a!=b) d=1;
  
  if(d){
    printf("Yes");
  }
  else{
    printf("No");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

string s;
int n;
int main(){
  cin>>s;
  n=s.size();
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      bool ok=1;
      for(int k=i;k<=j;k++)if(s[k]!='A'&&s[k]!='C'&&s[k]!='G'&&s[k]!='T')ok=0;
      if(ok)ans=max(ans,j-i+1);
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll a, b, c, x, y, i, j, k;
  cin >> a >> b >> c >> x >> y;
  
  if(x >= y) {
    i = 2*c*y +a*(x-y);
    j = 2*c*x;
  }
  else {
    i = 2*c*x +b*(y-x);
    j = 2*c*y;
  }
  k = a*x + b*y;
  
  cout << min({i, j, k}) << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
	double X;
	cin >> X;
	double K = 360 / X;
	for (int i = 1; i < 360; i++) {
		if (ceil(K) == floor(K))
			break;
		else
			K = 360 / X * i;
	}
	cout << K << endl;
	return 0;
}

Measured memory_bytes: 3788
#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 a[N];
int b[N];
vector<int> v1[2], v2[2];
void refrain(vector<int> v[2], int a[], int n, int m)
{
	int mask = (1 << m) - 1;
	v[0].clear();
	v[1].clear();
	for (int i = 1; i <= n; i++)
	{
		v[a[i] >> m & 1].push_back(a[i] & mask);
	}
	sort(v[0].begin(), v[0].end());
	sort(v[1].begin(), v[1].end());
}
LL solve(vector<int>& v1, vector<int>& v2, int maxv)
{
	int ptr = v2.size() - 1;
	LL sum = 0;
	for (int i = 0; i < v1.size(); i++)
	{
		while (ptr >= 0 && v2[ptr] + v1[i] >= maxv) ptr--;
		sum += ptr + 1;
	}
	return sum;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	scanf("%d", &n);
	int mask = (1 << 14) - 1;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &b[i]);
	}
	int ans = 0;
	for (int o = 28; o >= 0; o--)
	{
		refrain(v1, a, n, o);
		refrain(v2, b, n, o);
		for (int i = 0; i < 2; i++)
		{
			for (int j = 0; j < 2; j++)
			{
				LL low = solve(v1[i], v2[j], 1 << o);
				LL up = 1LL * v1[i].size() * v2[j].size() - low;
				int t = (low & (i + j)) ^ (up & (i + j + 1));
				t &= 1;
				ans ^= t << o;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4724
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main(){
	int a[25],c=0;
	char b;
	for(int i=0;i<25;i++)a[i]=0;
	while(cin>>b){
		a[b-'a']++;
	}
	for(int i=0;i<25;i++)if(a[i]%2==1)c++;
	if(c>0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
	return 0;
}


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

int main()
{
    vector<int> a(3);
    cin >> a[0];
    while (cin >> a[0] >> a[1] >> a[2])
    {
        sort(a.begin(), a.end());
        if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
}


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

int main() {
  while (true) {
    string x;
    cin >> x;
    if (x == "0") break;
    int sum = 0;
    for (int i = 0; i < x.size(); i++) sum += (int)x.at(i) - '0';
    cout << sum << endl;
  }
}


Measured memory_bytes: 3216
#include<iostream>
main(){int f,i,j,m,b[100001]={0};for(i=b[1]=1;i*i<100001;)for(j=++i+i;!b[i]&j<100001;j+=i)b[j]=1;for(double A,B;std::cin>>m>>A>>B,m;printf("%d %d\n",j-1,i+1)){f=1;for(i=m;f&i>2;i--)for(j=1;f&j*j++<i;)i%j|b[j]|b[i/j]|A/B>(double)j*j/i||(f=0)|(i/=j);}}

Measured memory_bytes: 1352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	while(true) {
    		int d = sc.nextInt();
    		double e = sc.nextDouble();
    		if(d==0 && e==0) break;
    		double min = 150.0;
    		for(int i=0;i<=d;i++) {
    			double l = Math.sqrt((double)(i*i + (d-i)*(d-i)));
    			double b = Math.abs(e-l);
    			if(b<min) min = b;
    		}
    		System.out.printf("%.10f", min);
    		System.out.println();
    	}
    }
}



Measured memory_bytes: 28836
#include <iostream>

int main(){
    int n;
    std::cin >> n;
    bool flag = true;
    for(int i = 0; i < n; i++){
        int a;
        std::cin >> a;
        if(!(a%2)){
            if((a%3)*(a%5)){
                flag = false;
            }
        }
    }
    std::cout << (flag ? "APPROVED" : "DENIED") << std::endl;
}


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

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<vector<int>> g(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> ans(n,-1);
	queue<int> que;
	que.push(0);
	while(!que.empty()){
		int v=que.front();
		que.pop();
		for(auto to:g[v]){
			if(ans[to]!=-1)continue;
			ans[to]=v+1;
			que.push(to);
		}
	}
	cout<<"Yes"<<endl;
	FOR(i,1,n){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 10348
a = list(map(int,input().split()))
a.sort()

def solve():
    if a[0] == a[1] and a[0] != a[2]:
        return True
    if a[0] != a[1] and a[1] == a[2]:
        return True
    return False

if solve():
    print("Yes")
else:
    print("No")



Measured memory_bytes: 2940
import copy
from collections import deque
H,W=map(int, input().split())
Abase=[[None]*W for _ in range(H)]
starts=deque()
for h in range(H):
  s=input()
  for w in range(W):
    if s[w]=='.':
      starts.append((h,w))
    else:
      Abase[h][w]=-1
 
DIF=[(1,0),(0,1),(-1,0),(0,-1)]
answers=[]
while starts:
  A=copy.deepcopy(Abase)
  st=starts.popleft()
  A[st[0]][st[1]]=0
  d=deque()
  d.append(st)
  while d:
    point=d.popleft()
    for dif in DIF:
      x=point[0]+dif[0]
      y=point[1]+dif[1]
      if 0<=x<H and 0<=y<W and A[x][y]==None:
        d.append((x,y))
        A[x][y]=A[point[0]][point[1]]+1
  ans=0    
  for h in range(H):
    Amax=max(A[h])
    ans=max(ans,Amax)
  answers.append(ans)
print(max(answers))

Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int a,b,c;
void in(){
cin>>a >> b >> c;
}

void solve(){

    int mx = max({a, b, c});
    int sum = a + b + c;
    if(a == b && b == c && c == a){
        print("Yes");
    }else{
        print("No");
    }
}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
//#define TEST
 
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;
 
class Program
{
    static int N;
    static int[] h;
 
    static void Main()
    {
        N = int.Parse(Console.ReadLine());
        h = Console.ReadLine().Split().Select(int.Parse).ToArray();
 
        long[] dp = new long[N];
        for (int i = 1; i < N; i++)
        {
            dp[i] = dp[i - 1] + Abs(h[i] - h[i - 1]);
            try
            {
                dp[i] = Min(dp[i], dp[i - 2] + Abs(h[i - 2] - h[i]));
            }
            catch { continue; }
        }
#if TEST
        foreach (var c in dp)
            Console.Write("{0} ", c);
        Console.WriteLine();
#endif
        Console.WriteLine(dp[N-1]);

    }
}

Measured memory_bytes: 20576
using System;
using System.Linq;

public class AtCoder
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var Arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        if (Arr.Contains(1))
        {
            int next = 1;
            int count = 0;
            foreach(int i in Arr)
            {
                if (i == next)
                {
                    next += 1;
                }
                else
                {
                    count += 1;
                }
            }
            Console.WriteLine(count);
        }
        else
        {
            Console.WriteLine("-1");
        }
    }
}


Measured memory_bytes: 35676
parseint(x) = parse(Int, x)

function main()
    n = readline() |> parseint
    a = map(x->1/parseint(x), readline() |> split)
    ans = 0.
    for i = 1:n
        ans += a[i]
    end
    ans \= 1
    println(ans)
end

main()

Measured memory_bytes: 113052
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    int k,t;
    cin >> k >> t;
    int a[t];
    int m = 0;
    for(int i = 0; i < t; i++){
        cin >> a[i];
        m = max(m,a[i]);
    }
    cout << max(0,m-(k-m)-1) << endl;
}

Measured memory_bytes: 256
n=int(input())
s=int(n**(1/2))+1
l=[]
for i in range(1,s+1):
  if n%i==0:
    l.append([i,n//i])
def digit(a,b):
  return max(len(str(a)),len(str(b)))
ans=11
for i in range(len(l)):
  if ans>=digit(l[i][0],l[i][1]):
    ans=digit(l[i][0],l[i][1])
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30

using namespace std;
typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        int ans = INF;
        rep(i,101) {
            if(i*i*i > n) break;

            rep(j,1001) {
                if(i*i*i + j*j > n) break;
                ans = min(ans,i+j+(n - i*i*i - j*j));
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;

int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll n,k;cin>>n>>k;ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i];
        ll l=1,r=10000000000,mid,sum=0,mi=inf;
        while(l<=r){
            mid=(l+r)/2;
            // cout<<l<<" "<<r<<endl;
            if(l==mid){
                for(ll i=0;i<n;i++)
                sum=sum+arr[i]/l+!!(arr[i]%l);
                if(sum<=k)
                mi=min(mi,l);
                sum=0;
                for(ll i=0;i<n;i++)
                sum=sum+arr[i]/r+!!(arr[i]%r);
                if(sum<=k)
                mi=min(mi,r);break;
            }
            sum=0;
            for(ll i=0;i<n;i++)
            sum=sum+arr[i]/mid+!!(arr[i]%mid)-1;
            // if(mid==4)cout<<sum<<" ";
            if(sum<=k)
            mi=min(mi,mid),r=mid;
            else
            l=mid;
        }
        cout<<mi;

}


Measured memory_bytes: 5144
#include <stdio.h>
int main(){
  int h,w,i,j;
  char a[101][101];
  
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++){
    scanf("%s",a[i]);
  }
  
  for(i=0;i<h+2;i++){
    for(j=0;j<w+2;j++){
      if(i==0 || j==0 || i==(h+1) || j==(w+1)){
        printf("#");
      } else {
        printf("%c",a[i-1][j-1]);
      }
    }
    printf("\n");
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
int main()
{
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		int n;
		cin>>n;
		set<int> st;
		bool pos = true;
		int curr;
		REP(i,n)
		{
			cin>>curr;
			if(st.count(curr))
				pos = false;
			else
				st.insert(curr);
		}
		if(pos)
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const ll MOD = 1e9+7;

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("in.txt", "r", stdin);
    int n;
    string s;
    cin >> n >> s;
    int m = 2*n;
    vi v(m);
    rep(i,0,m) {
        int a = 0;
        if(s[i] == 'B') a++;
        a += m-1-i;
        if(a%2) {
            v[i] = -1;
        } else {
            v[i] = 1;
        }
    }
    bool flag = true;
    int d = 0;
    rep(i,0,m) {
        d += v[i];
        if(d < 0) {
            flag = false;
            break;
        }
    }
    if(d != 0) flag = false;
    if(!flag) {
        cout << 0 << '\n';
        return 0;
    }
    ll ret = 1;
    ll cnt = 0;
    per(i,0,m) {
        if(v[i] == 1) {
            ret *= cnt;
            ret %= MOD;
            cnt--;
        } else {
            cnt++;
        }
    }
    rep(i,1,n+1) {
        ret = ret * i % MOD;
    }
    cout << ret << '\n';
	return 0;
}


Measured memory_bytes: 1360
from collections import defaultdict, deque
from heapq import heappop, heappush
from string import ascii_lowercase as abc

class BIT:
    def __init__(self, N):
        # Nは入れたい要素の個数
        self.size = 2 ** (int.bit_length(N+1))
        self.tree = [0]*(self.size + 1)
 
    def sum(self, i):
        res = 0
        while i:
            res += self.tree[i]
            i -= (i & -(i))
        return res
 
    def add(self, i, x):
        if i == 0:
            return
        while i <= self.size:
            self.tree[i] += x
            i += (i & -(i))


D = [deque() for _ in range(26)]
S = input()
N = len(S)

for i in range(len(S)):
    D[ord(S[i])-97].append(i)

M = [len(D[i])%2 for i in range(26)]
if sum(M) >= 2:
    print(-1)
    exit()

odd = sum(M)

Q = []
for c in range(26):
    if len(D[c]) >= 2:
        l = D[c].popleft()
        r = D[c].pop()
        a = l * 1
        b = N - 1 - r
        if b < a:
            a, b = b, a
        heappush(Q, (a, b, l, r, c))

T = [0]*(N//2)
for i in range(N//2):
    _, _, l, r, c = heappop(Q)
    T[i] = c

    if len(D[c]) >= 2:
        l = D[c].popleft()
        r = D[c].pop()
        a = l * 1
        b = N - 1 - r
        if b < a:
            a, b = b, a
        heappush(Q, (a, b, l, r, c))

L = [[] for i in range(26)]

for i in range(N//2):
    L[T[i]].append(N-1-i)

if odd:
    L[M.index(1)].append(N//2)

for i in range(N//2-1, -1, -1):
    L[T[i]].append(i)

bit = BIT(N)
ans = 0
for i in range(N):
    j = L[ord(S[i]) - 97].pop()
    ans += i - bit.sum(j+1)
    bit.add(j+1, 1)
print(ans)

Measured memory_bytes: 71500
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
constexpr ll MOD = 1000000007;

int main()
{
  string s;
  cin>>s;
  int n = s.size();
  vector<vector<ll>> dp(n+1, vector<ll>(13, 0));
  dp[0][0] = 1;
  REP(i,n) {
    REP(j,13) {
      if (s[i] == '?') {
        REP(k,10) {
          dp[i+1][(10*j+k)%13] += dp[i][j];
          dp[i+1][(10*j+k)%13] %= MOD;
        }
      } else {
        int a = s[i] - '0';
        dp[i+1][(10*j+a)%13] += dp[i][j];
        dp[i+1][(10*j+a)%13] %= MOD;
      }
    }
  }
  cout<<dp[n][5]<<endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    char S[N];
    for(int i=0;i<N;++i){
        cin >> S[i];
    }
    int res=0;
    int slime_num=0;
    int ini_num=N;
    for(int i=0;i<N-1;++i){
        if(S[i]==S[i+1]){
            ++res;
        }
    }
    cout << N-res;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

struct edge{
	int to, cap, rev;
	edge(int t, int c, int r):to(t),cap(c),rev(r){}
	edge(){}
};

int dfs(int v, int g, int flow, vector<vector<edge> >& adj, vector<bool>& used){
	if(used[v]) return -1;
	used[v] = true;
	if(v == g) return flow;
	
	for(int i=0; i<(int)adj[v].size(); i++){
		edge& next = adj[v][i];
		if(next.cap > 0){
			int ret = dfs(next.to, g, min(flow, next.cap), adj, used);
			if(ret > 0){
				next.cap -= ret;
				adj[next.to][next.rev].cap += ret;
				return ret;
			}
		}
	}
	return -1;
}

int maxflow(int s, int g, vector<vector<edge> > &graph){
	int res = 0;
	while(1){
		vector<bool> used((graph.size()+1)*2, false);
		int ret = dfs(s, g, inf, graph, used);
		if(ret==-1) break;
		res += ret;
	}
	return res;
}

int main(){
	while(1){
		int n,m,l;
		cin >> n >> m >> l;
		if(n==0) break;
		
		vector<vector<int> > adj(n, vector<int>(n, inf));
		for(int i=0; i<n; i++) adj[i][i] = 0;
		for(int i=0; i<m; i++){
			int u,v,d;
			cin >> u >> v >> d;
			adj[u][v] = adj[v][u] = d;
		}
		
		for(int k=0; k<n; k++){
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);
				}
			}
		}
		
		vector<int> p(l), t(l);
		for(int i=0; i<l; i++){
			cin >> p[i] >> t[i];
		}
		
		vector<vector<edge> > bg((l+1)*2);
		for(int i=0; i<l; i++){
			for(int j=0; j<l; j++){
				if(i==j) continue;
				if(t[i] +adj[p[i]][p[j]] <= t[j]){
					bg[i].push_back(edge(l+j, 1, bg[l+j].size()));
					bg[l+j].push_back(edge(i, 0, bg[i].size()-1));
				}
			}
		}
		for(int i=0; i<l; i++){
			bg[2*l].push_back(edge(i, 1, bg[i].size()));
			bg[i].push_back(edge(2*l, 0, bg[2*l].size()-1));
			bg[l+i].push_back(edge(2*l+1, 1, bg[2*l+1].size()));
			bg[2*l+1].push_back(edge(l+1, 0, bg[l+1].size()-1));
		}
		cout << l -maxflow(2*l, 2*l+1, bg) << endl;
	}
	return 0;
}


Measured memory_bytes: 18552
// ABC165B - 

#include <bits/stdc++.h>
using namespace std;

int main() {
	long long int X;
	cin >> X;

	long long int ans = 1;
	long long int money = 100;
	double t;
	while (1) {
		t = money * 101.0 / 100.0;
		money = (long long int)t;
		if (money >= X) {
			break;
		}
		++ans;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636