akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main(int argc, const char * argv[]) {
    std::string s, p;
    getline(std::cin, s);
    getline(std::cin, p);
    s += s.substr(0, p.length() - 1);
    if (s.find(p) != std::string::npos) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
    ll n;
    cin >> n;
    ll min = 1000000, max = -1000000, sum = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        sum += a;
        if (min > a) min = a;
        if (max < a) max = a;
    }
    cout << min << ' ' << max << ' ' << sum << endl; 
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,c,d,Min,lcm;
  cin >> a >> b >> c >> d;
  
  int C=c ,D=d;
  
  while(D%C!=0){
   if(C<D) swap(C,D); 
    C%=D;
  }
  
  lcm=c*d/C;
  
  long long cc,cd,clcm,ans;
  cc=b/c-(a-1)/c;
  cd=b/d-(a-1)/d;
  clcm=b/lcm-(a-1)/lcm;
  
  ans=b-a+1-cc-cd+clcm;
  
  cout <<  ans << endl;
  
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in(), a = in();
	cout << (n % 500 <= a ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  int x,a,b;
  cin >> x >> a >> b;
  if(abs(x-a)<=abs(x-b))cout << 'A' << endl;
  else cout << 'B' <<endl;
  
  return 0;     
}


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();

		if((a*b)%2==0){
			System.out.println("Even");
		}else{
			System.out.println("Odd");
		}
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int p, q, r;
    cin >> p >> q >> r;

    cout << (p + q + r - max({p, q, r})) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    sc.close();

    int count = 0;
    for (char c : s.toCharArray()) {
      if (c == 'g') {
        count += 1;
      } else {
        count -= 1;
      }
    }
    System.out.println(count / 2);
  }
}


Measured memory_bytes: 26804
#include <iostream>

using namespace std;

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

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] != i + 1) {
            cnt++;
        }
    }

    cout << (cnt == 0 || cnt == 2 ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define inf 1000000000
#define Inf 223372036854775807
#define maxn 201000
using namespace std;
typedef long long ll;
const ll mod=998244353;
const long double eps=1e-9;
const long double PI=acos(-1.0);

int n, num[maxn];

int main()
{
    cin>>n;
    for (int i=1; i<=n; i++)
        cin>>num[i];
    int f=1;
    for (int i=1; i<=n; i++)
    {
        if (num[i]&1) continue;
        if (num[i]%3==0 || num[i]%5==0) continue;
        f=0;
    }
    if (f) cout<<"APPROVED";
    else cout<<"DENIED";
    return 0;
}


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

int main(){
    int l,r;
    cin>>l>>r;
    if(r-l>=2019||l%2019>=r%2019){
        cout<<0<<endl;   
        return 0;
    }
    r++;
    int min=INT32_MAX;
    rep2(i,l,r-1){
       rep2(j,i+1,r){
            if(min>((long long)i*j)%2019)
                min=((long long)i*j)%2019;
       }
    }
    cout<<min<<endl;
    return 0;
}

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

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

    long long a[N],manag[N];

    for(int i=0;i<N;i++) manag[i] = 0;
    long long cnt = 0;

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

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



    long long x, y;
    long long res = 10000000000;
    for(int i=0;i<N-1;i++){
        x = manag[i];
        y = cnt - manag[i];
        res = min(res, abs(x - y));
    }
    cout << res << endl;
}

Measured memory_bytes: 3328
var  a,b,c,d:longint;
     s:string;
begin
  readln(s);
  a:=ord(s[1])-ord('0');
  b:=ord(s[2])-ord('0');
  c:=ord(s[3])-ord('0');
  d:=ord(s[4])-ord('0');
  if  a+b+c+d=7  then
    begin  writeln(a,'+',b,'+',c,'+',d,'=7');  exit;  end;
  if  a+b+c-d=7  then
    begin  writeln(a,'+',b,'+',c,'-',d,'=7');  exit;  end;
  if  a+b-c+d=7  then
    begin  writeln(a,'+',b,'-',c,'+',d,'=7');  exit;  end;
  if  a-b+c+d=7  then
    begin  writeln(a,'-',b,'+',c,'+',d,'=7');  exit;  end;
  if  a-b-c+d=7  then
    begin  writeln(a,'-',b,'-',c,'+',d,'=7');  exit;  end;
  if  a-b+c-d=7  then
    begin  writeln(a,'-',b,'+',c,'-',d,'=7');  exit;  end;
  if  a+b-c-d=7  then
    begin  writeln(a,'+',b,'-',c,'-',d,'=7');  exit;  end;
  if  a-b-c-d=7  then
    begin  writeln(a,'-',b,'-',c,'-',d,'=7');  exit;  end;
end.


Measured memory_bytes: 128
#include <stdio.h>

int main(void){

   int n, q, m, i, j;

   m = 0;

   scanf("%d", &n);

   int S[n];

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

   scanf("%d", &q);

   int T[q];

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

   for(i = 0; i < q; i++) {
      for(j = 0; j < n; j++) {
         if (T[i] == S[j]){
            m++;
            break;
         }
      }
   }

   printf("%d\n", m);

   return 0;
}


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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define eb emplace_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    int n;
    string s;
    cin >> n >> s;

    if(n < 3200) cout << "red\n";
    else cout << s << "\n";

    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};


#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define REP_REV(i, n) for (ll i = n-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ll(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;

vector<ll> a, b;
ll zero_cnt = 0;

ll count(ll x) {
  ll ret = 0;
  if(x == 0) {
    ret += zero_cnt * (zero_cnt - 1) / 2;
    ret += zero_cnt * (sz(a) + sz(b));
    ret += sz(a) * sz(b);
    return ret;
  }
  if(x < 0) {
    int b_idx = 0;
    REP(i, sz(a)) {
      while(b_idx < sz(b) && a[i] * b[b_idx] <= x) {
        b_idx++;
      }
      ret += b_idx;
    }
    return ret;
  }
  ret += zero_cnt * (zero_cnt - 1);
  ret += zero_cnt * (sz(a) + sz(b)) * 2;
  ret += sz(a) * sz(b) * 2ll;
  int rgt = 0;
  REP_REV(i, sz(a)) {
    while(rgt < sz(a) && a[i] * a[rgt] <= x) {
      rgt++;
    }
    ret += rgt;
    if(i < rgt) ret--;
  }
  int lft = sz(b) - 1;
  REP(i, sz(b)) {
    while(lft >= 0 && b[i] * b[lft] <= x) {
      lft--;
    }
    ret += sz(b) - 1 - lft;
    if(lft < i) ret--;
  }
  return ret / 2;
}


signed main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll n, k;
  cin >> n >> k;
  REP(i, n) {
    ll x;
    cin >> x;
    if(x == 0) {
      zero_cnt++;
    }
    else if(x > 0) {
      a.push_back(x);
    }
    else {
      b.push_back(x);
    }
  }
  sort(all(a));
  sort(all(b));
  ll lft = -inf-10;
  ll rgt = inf+10;
  while(rgt - lft > 1) {
    ll mid = (rgt + lft) / 2;
    ll tmp = count(mid);
    if(tmp < k) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  cout << lft + 1 << endl;
  return 0;
}


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

int main() {
	int n;
	double sum = 0;
	cin >> n;
	vector<double> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		sum += 1 / a.at(i);
	}
	cout << 1 / sum << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){ll c; while(b!=0){c=a%b; a=b; b=c;} return a;}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a * c%mod;} a=a * a%mod; b>>=1;} return c;}
vi calc(ll x){vi res; while(x>0){res.pb(x%10); x/=10;} reverse(all(res)); return res;}

void solve() {
  int n;
  cin>>n;
  if(n%2==0) out(n/2);
  else out((n+1)/2);
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    vector <int> test;
    test.resize(n,0);
    int i=0;
    while(i<n)
    {
        int l=i;
        while(i<n&&s[i]==s[l])
            i++;
        int x=i-1;
        int l2=i;
        while(i<n&&s[i]==s[l2])
            i++;
        int n1=x-l+1;
        int n2=i-l2;
        if(n1>=n2){
            test[x]=(n1+n2+1)/2;
            test[l2]=(n1+n2)/2;
        }
        else
        {
            test[l2]=(n1+n2+1)/2;
            test[x]=(n1+n2)/2;
        }
        if((max(n1,n2)-1)%2)
            swap(test[x],test[l2]);

    }
    for(auto i:test)
        cout<<i<<" ";
    cout<<endl;
    
    
    
    return 0;   
}


 
 


Measured memory_bytes: 1104
n=int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
s1=s2=s3=0
for i in range(n):
    if p[i]<=a:
        s1+=1
    elif p[i]<=b:
        s2+=1
    else:
        s3+=1
print(min(s1,s2,s3))





Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  int64_t H;

  cin >> H;

  int attack_layer = 0;
  int64_t attack_num = 0;
  while (true) {
    attack_layer++;
    attack_num += pow(2, attack_layer - 1);
    if (H == 1) {
      break;
    }
    else {
      H = H / 2;
    }
  }

  cout << attack_num;

  return 0;
}


Measured memory_bytes: 384
N, L = map(int, input().split())
if L < 0:
    if N <= (-L):
        print(sum([i for i in range(L, L + N - 1)]))
    else:
        print(sum([i + L for i in range(N)]))
else:
    print(sum([i for i in range(L + 1, N + L)]))


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

int main() {
  string S ;
  cin >> S ;
  int X = 0 ;
  for (int i=0 ; i< S.size()/2; i++){
    int j=S.size() - (i+1) ;
    if (!(S.at(i) == S.at(j)))
      X+=1 ;
  }
  
  cout << X <<endl;
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define rg register
#define int long long
const int MAXN = 100010;
using namespace std;
inline int read(){
	int s = 0; bool f = false; char c = getchar();
	while(c < '0' || c  > '9') f |= (c == '-'), c=getchar();
	while(c >= '0' && c <= '9') s = s * 10 + c - 48, c = getchar();
	return f ? -s : s;
}
int c[MAXN << 1];
inline int lowbit(int x) { return x & (-x); }
inline void update(int x) { for (rg int i = x; i <= MAXN << 1; i += lowbit(i)) ++c[i]; }
inline int query(int x) { int res = 0; for (rg int i = x; i > 0; i -= lowbit(i)) res += c[i]; return res; }
int n, a[MAXN], s[MAXN << 1];
inline bool check(int key){
   	int sum = 0;
	memset(c, 0, sizeof c);
	s[0] = 0;
	for (rg int i = 1; i <= n; i++) s[i] = s[i - 1] + (a[i] >= key ? 1 : -1), sum += (s[i] >= 0);
	for (rg int i = 1; i <= n; i++) sum += query(s[i] + MAXN), update(s[i] + MAXN);
	int newn = n * (n - 1) / 2 + n;
	return newn - sum < newn / 2 + 1;
}
signed main(){
	n = read();
	int l = 0, r = 0, mid;
	for (rg int i = 1; i <= n; i++) a[i] = read(), r = max(r, a[i]);
	while (l <= r){
		mid = (l + r) >> 1;
		if (check(mid))
			l = mid + 1;
		else
			r = mid - 1;
	}
	printf("%lld", r);
	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;


void solve() {
	int i,j,k,l,r,x,y; string s;
	vector<int> V;
        FOR(i, 3){
            int input;
            cin>>input;
            V.push_back(input);
        }
        int K;
        cin>>K;
        int imax;
	FOR(k,K) {
            imax=max_element(ALL(V))-V.begin();
            V[imax] *=2;
        }
	
        cout<<(V[0]+V[1]+V[2])<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
s = input()

n = len(s)

req1 = '10'*10**5
req2 = '01'*10**5

diff = sum([1 for x, y in zip(s, req1) if x != y])

diff2 = sum([1 for x, y in zip(s, req2) if x != y])

print(min(diff, diff2))

Measured memory_bytes: 4656
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            # if i != n // i:
            #     divisors.append(n//i)

    # divisors.sort()
    return divisors


N = int(input())
a = make_divisors(N)[-1]
b = N // a
print(a + b - 2)


Measured memory_bytes: 3060
#include <cstdio>

using namespace std;

long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	int t, i;
	
	scanf("%d", &t);
	
	for (i = 0; i < t; i++) {
		long long a, b, c, d;
		
		scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
		
		if (a < b || d < b) {
			puts("No");
		} else if (c >= b) {
			puts("Yes");
		} else {
			long long x;
			
			a %= b;
			
			if (d % b == 0) {
				x = a;
			} else {
				long long g = gcd(b, d);
				
				x = a % g - g + b;
			}
			
			if (c >= x) {
				puts("Yes");
			} else {
				puts("No");
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)

using namespace std;

int main() {
	ll d;
	cin >> d;
	switch(d){
	case 22:
		cout << "Christmas Eve Eve Eve" << endl;
		break;
	case 23:
		cout << "Christmas Eve Eve" << endl;
		break;
	case 24:
		cout << "Christmas Eve" << endl;
		break;
	case 25:
		cout << "Christmas"<< endl;
		break;
	}
}

Measured memory_bytes: 256
/* author   : mpily :-()
title : Competing.cpp
time :Sun Jun 14 13:11:23 2020

*/
#include<climits>
#include<random>
#include<cassert>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<utility>
#include<cstdint>
#include<queue>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdio>
//4611686018427387903
using namespace std;
void solve(int cnum){	
	int n;
	cin >> n;
	cout << (1000-n%1000)%1000 <<"\n";
	
}
int main(){
	
	//ios_base::sync_with_stdio(false);
	//cin.tie(nullptr);
	//cout.tie(nullptr);
	//initprime();
	int t;
	int count = 1;
	for(t = 1;t--; solve(count),count++);
	return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int dfs(Int number, string target, int count,bool three, bool five, bool seven){
    if(stoll(target) > number){
        return 0;
    }

    if(target == "0"){
        target = "";
    }

    int ans = 0;
    if(three && five&& seven){
        ans= 1;
    }
    ans += dfs(number, target+"3", count+1, true,five,seven);
    ans += dfs(number, target+"5", count+1,three,true,seven);
    ans += dfs(number, target+"7",count+1, three,five,true);

    return  ans;
}

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

    if(N<357){
        ans =0;
    }else{
        string start ="0";
        ans = dfs(N, start, 0, false,false,false);
    }

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

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

const int MAX = 1e5;
int n, u, v;
vector<int> to[MAX];
bool visited[MAX];
bool eble[MAX];
int dis[MAX];
int d;

void bfs() {
  queue<int> que;
  que.push(v);
  visited[v] = true;
  dis[v] = 0;
  while (!que.empty()) {
    int tmp = que.front();
    que.pop();
    for (int next : to[tmp]) {
      if (visited[next]) continue;
      visited[next] = true;
      que.push(next);
      dis[next] = dis[tmp] + 1;
    }
  }
}

void dfs(int tmp) {
  eble[tmp] = true;
  for (int next : to[tmp]) {
    if (eble[next]) continue;
    ++d;
    if (d < dis[next]) dfs(next);
    else if (d == dis[next]) eble[next] = true;
    --d;  
  }
}

int main() {
  cin >> n >> u >> v;
  --u; --v;
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  bfs();
  dfs(u);
  int ans = 0;
  rep(i, n) {
    if (eble[i]) ans = max(ans, dis[i]);
  }
  cout << ans - 1 << endl;
  return 0;
}

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

using namespace std;

int main(void)
{
	int N,A,B,C,D,Ahako,Chako;
	cin>>N>>A>>B>>C>>D;
	if(N%A==0){
		Ahako=N/A;
	}else{
		Ahako=N/A+1;
	}
	if(N%C==0){
		Chako=N/C;
	}else{
		Chako=N/C+1;
	}
	if(Ahako*B<=Chako*D){
		cout<<Ahako*B<<endl;
	}else{
		cout<<Chako*D<<endl;
	}
	return 0;
}


Measured memory_bytes: 3104
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt() * 1000;
        int a = sc.nextInt() * 1000;
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int min = -1;
        int idx = 0;
        for (int i = 0; i < n; i++) {
            int tmp = Math.abs(a - (t - h[i] * 6));
            // System.out.println(tmp);
            if (i == 0) {
                min = tmp;
                idx = 0;
            } else {
                if (min > tmp) {
                    min = tmp;
                    idx = i;
                }
            }
        }
        System.out.println((idx + 1));

    }

}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  REP(i, n) cin >> a[i];
  REP(i, n/2){
    sum ^= a[2*i]^a[2*i+1];
  }
  vector<ll> ans(n);
  REP(i, n) ans[i] = sum^a[i];
  REP(i, n) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 6348
package main

import (
	"fmt"
	"sync"
)

type graph struct {
	path []int
	height int
	// flag bool // pathに存在するもので自分より高いものがあればtrue
}
var graphs []graph
var wg sync.WaitGroup
var count int
func main() {
	var N,M int
	fmt.Scan(&N,&M)
	graphs = make([]graph,N)
	for i:= 0; i<N; i++ {
		var h int
		fmt.Scan(&h)
		graphs[i].height = h
		graphs[i].path = []int{}
		// graphs[i].flag = false
	}
	for i:= 0; i<M; i++ {
		var a,b int
		fmt.Scan(&a,&b)
		graphs[a-1].path = append(graphs[a-1].path,b-1)
		graphs[b-1].path = append(graphs[b-1].path,a-1)
	}
	count = 0
	for i:=0; i<N; i++ {
		wg.Add(1)
		go goFor(i)
	}
	wg.Wait()
	fmt.Println(count)
}

func goFor (i int) {
	paths := graphs[i].path
	height := graphs[i].height
	bestHeight := true // 一番高いのならtrue
	for _, value := range paths {
		if height <= graphs[value].height {
			bestHeight = false
			break
		}
	}
	if bestHeight {
		// fmt.Println(graphs[i],"ベスト")
		count++
	}
	defer wg.Done()
}

Measured memory_bytes: 98668
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	A := make([]int, N+1)
	B := make([]int, N)

	for i := 0; i < N+1; i++ {
		A[i], _ = strconv.Atoi(read())
	}
	for i := 0; i < N; i++ {
		B[i], _ = strconv.Atoi(read())
	}

	for i := 0; i < N; i++ {
		ans += min(cnt, A[i])
		A[i] -= min(cnt, A[i])

		if A[i] <= B[i] {
			ans += A[i]
			cnt = B[i] - A[i]
		} else {
			ans += B[i]
			cnt = 0
		}
	}
	fmt.Println(ans + min(cnt, A[N]))
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i][0] < a[j][0] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 4736
import sys
input = sys.stdin.readline
 
H, W, M = map(int, input().split())
Hsum = [0] * H
Wsum = [0] * W
hw = set()
for m in range(M):
  h, w = map(lambda x: int(x) - 1, input().split())
  Hsum[h] += 1
  Wsum[w] += 1
  hw.add((h, w))

mh = max(Hsum)
mw = max(Wsum)
hidx = [i for i, _ in enumerate(Hsum) if _ == mh]
widx = [i for i, _ in enumerate(Wsum) if _ == mw]
 
if len(hidx) * len(widx) > M:
  print(mh + mw)
else:
  fi_flg = False
  for h in hidx:
    for w in widx:
      if (h, w) not in hw:
        print(mh + mw)
        fi_flg = True
        break
    if fi_flg:
      break
  if fi_flg is False:
    print(mh + mw - 1)

Measured memory_bytes: 169176
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
#define dis(it,it1) distance(it,it1)+1
#define MAX 100005
#define INF 9223372036854775807LL
#define MOD 1000000007
#define print(cs) printf("Case %lld: ",cs)
#define Yesno(ok) if(ok)puts("YES");else puts("NO")
#define yesno(ok) if(ok)puts("Yes");else puts("No")
ll lcm(ll a,ll b){return ((a*b)/__gcd(a,b));}
vector<ll>vt;
ll sz;
string ques;
vector<ll>ans;
bool chq(string a,string b)
{
//    cout<<a<<" "<<b;endl;
    ll num1,num2;
    stringstream ss;
    ss<<a;
    ss>>num1;
    stringstream ss1;
    ss1<<b;
    ss1>>num2;
//    cout<<num1<<" "<<num2;endl;
    return (num1>=num2?true:false);
}
void rec(ll idx,string s)
{
    if(idx==sz)
    {
        if(chq(s,ques))
        {
            stringstream ss;
            ss<<s;
            ll num;
            ss>>num;
            ans.pb(num);
        }
        return ;
    }
    if(idx==sz-1&&chq(s,ques))
    {
        stringstream ss;
        ss<<s;
        ll num;
        ss>>num;
        ans.pb(num);
        return ;
    }
    for(ll i=0;i<vt.size();i++)
    {
        s.pb(vt[i]+'0');
        rec(idx+1,s);
        s.pop_back();
    }
}
int main()
{
    ll i,j,k,l,n,m,r;
    cin>>ques>>k;
    ll arr[10];
    ms(arr,0);
    for(i=0;i<k;i++)
    {
        in(m);
        arr[m]=1;
    }
    for(i=0;i<10;i++)if(!arr[i])vt.pb(i);
    sz=ques.size()+1;
    rec(0,"");
    sort(all(ans));
    cout<<ans[0];endl;
}


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

int main() {
    int n, t, a, i, temp, min = 100000000, ans;
    cin >> n >> t >> a;


    for(i = 0; i < n; ++i) {
        int h;
        cin >> h;
        temp = t * 1000 - 6 * h;
        if(abs(temp - a*1000) < min) {min = abs(temp - a*1000); ans = i;}
    }
    cout << ans + 1<< endl;



}

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

using namespace std;

void Main() {
    long long N, C;
    cin >> N >> C;

    vector<vector<long long>> D(C, vector<long long>(C, 0));
    for (long long i = 0; i < C; ++i) {
        for (long long j = 0; j < C; ++j) {
            cin >> D[i][j];
        }
    }
    map<long long, map<long long, long long>> cmap;
    cmap.emplace(0, map<long long, long long>());
    cmap.emplace(1, map<long long, long long>());
    cmap.emplace(2, map<long long, long long>());
    for (long long i = 0; i < N; ++i) {
        for (long long j = 0; j < N; ++j) {
            long long c;
            cin >> c;
            --c;
            long long g = (i + j) % 3;
            if (cmap[g].count(c) == 0) {
                cmap[g].emplace(c, 0);
            }
            cmap[g][c] += 1;
        }
    }

    long long ans = 1000000000000000000LL;
    for (long long i = 0; i < C; ++i) {
        for (long long j = 0; j < C; ++j) {
            if (i == j) {
                continue;
            }
            for (long long k = 0; k < C; ++k) {
                if (i == k || j == k) {
                    continue;
                }

                long long diff = 0;
                for (auto e : cmap[0]) {
                    if (e.first != i) {
                        diff += e.second * D[e.first][i];
                    }
                }
                for (auto e : cmap[1]) {
                    if (e.first != j) {
                        diff += e.second * D[e.first][j];
                    }
                }
                for (auto e : cmap[2]) {
                    if (e.first != k) {
                        diff += e.second * D[e.first][k];
                    }
                }
                ans = min(ans, diff);
            }
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>

using namespace std;
#define MAX 1000000000

int main(){
    double T, X;

    cin >> T >> X;

    double ans = T / X;
    cout << ans << "\n";
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include <string.h>
#include <iomanip>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
const ll mod=1e9+7;


int main(void){
    ll N;
    cin>>N;
    vector<ll> A(N),B(N);
    rep(i,N) cin>>A.at(i)>>B.at(i);
    vector<pair<ll,ll>> BA(N);
    rep(i,N) BA.at(i)=make_pair(B.at(i),A.at(i));
    sort(BA.begin(),BA.end());
    ll time=0;
    rep(i,N){
        time+=BA.at(i).second;
        if(time>BA.at(i).first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main()
{
	
	char a[20];
	int k;
	scanf("%s",a);
	k=strlen(a);
	for(int i=0; i<k; i++)
	{
		if(a[i]==',')
		{
			a[i]=' ';
		}
	}
	printf("%s\n",a);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, M, Q;
  cin >> N >> M >> Q;

  vector<vector<int>> ans(N+1, vector<int>(N+1, 0));
  REP(i, M){
    int l, r;
    cin >> l >> r;
    ans[l][r]++;
  }

  REP(i, N) REP(j, N+1) ans[i+1][j] += ans[i][j];
  REP(i, N+1) REP(j, N) ans[i][j+1] += ans[i][j];

  REP(i, Q){
    int p, q;
    cin >> p >> q;

    cout << ans[q][q]-ans[q][p-1]-ans[p-1][q]+ans[p-1][p-1] << "\n";
  }

  return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {

  int N; cin >> N;
  int M = N/100 * 111;
  if(N > M)
    cout << M + 111 << endl;
  else
    cout << M << endl;
  return 0;
}

Measured memory_bytes: 256
S=input()
res=0
cnt=0
if S[0]!='A':
    print('WA')
    exit()
for i in range(2,len(S)-1):
    if S[i]=='C' and cnt==0:
        cnt+=1
        res=1
    elif S[i]=='C' and cnt==1:
        res=0
for i in range(len(S)):
    if S[i]!='A' and S[i]!='C' and S[i].isupper() == True:
        print('WA')
        exit()
if res==0:
    print('WA')
else:
    print('AC')

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

int main(void)
{
	double a, x, h;
	scanf("%lf %lf", &x, &h);
	while(x!=0.0 & h!=0.0) {
		a=x*x+2*x*sqrt(x*x/4+h*h);
		printf("%f\n", a);
		scanf("%lf %lf", &x, &h);
	}
	return 0;
}


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

#define ll long long
#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

int n,m; 
int main(){
	scanf("%d%d",&n,&m);
	int cur=1;
	rep(i,m)cur*=2;
	printf("%d",((n-m)*100+m*1900)*cur);
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 256
N = int(input())
words = []
for a in range(0, N):
    words.append(input())

isok = True

for a in range(0, N-1):
    w1 = words[a]
    w2 = words[a+1]

    if w1[-1] != w2[0]:
        isok = False
        break

if isok and len(list(set(words))) == N:
    print('Yes')
else:
    print('No')


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;


void solve(long long N, long long K, std::vector<long long> p){
	ll ret = 0;
	sort(ALL(p));
	REP(i, K) {
		ret += p[i];
	}
	cout << ret << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}



Measured memory_bytes: 3700
#Round Robin Schedule
#queue ring buffer
from functools import wraps

def RoundRobinSchedule(process, n, q):
    elasped_time = 0
    head = 0
    tail = 0
    Q = [["a", i] for i in range(n+1)]


    def initialize():
        nonlocal head, tail, Q
        head = 0
        tail = 0


    def isEmpty():
        nonlocal head, tail, Q
        return head == tail


    def isFull():
        nonlocal head, tail, Q
        return head == (tail+1)%(n+1)


    def enqueue(x):
        nonlocal head, tail, Q
        if isFull():
            print("overflow")
            exit()
        Q[tail] = x
        if tail + 1 == n + 1:
            tail = 0
        else:
            tail += 1


    def dequeue():
        nonlocal head, tail, Q
        if isEmpty():
            print("underflow")
            exit()
        x = Q[head]
        if head + 1 == n + 1:
            head = 0
        else:
            head += 1
        return x


    for i in range(n):
        enqueue(process[i])
    while not isEmpty():
        target = dequeue()
        if target[1] <= q:
            elasped_time += target[1]
            print(target[0] + " " + str(elasped_time))
        else:
            elasped_time += q
            enqueue([target[0],target[1] - q])


n,q = [int(i) for i in input().split()]
process = []
for i in range(n):
    a,b = input().split()
    process.append([a,int(b)])
RoundRobinSchedule(process,n,q)


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

int main() {
  string S;
  cin >> S;
  string T = S;
  reverse(T.begin(), T.end());
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) ans++;
  }
  cout << ans / 2 << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const int MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	int n;
	cin >> n;
	vector<int> a(n), cnt(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	ll ans = 1;
	if (n % 2 == 1) {
		if (cnt[0] != 1) {
			cout << 0 << endl;
			return 0;
		}
		for (int i = 2; i < n; i += 2) {
			if (cnt[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
			(ans *= 2) %= MOD;
		}
	}
	else {
		for (int i = 1; i < n; i += 2) {
			if (cnt[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
			(ans *= 2) %= MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
N, M, K = map(int, input().split())


def solve(N, M, K):
    for i in range(N+1):
        for j in range(M+1):
            blackNum = i*M + j*N - 2*i*j
            if K == blackNum:
                return "Yes"
    return "No"

print(solve(N, M, K))


Measured memory_bytes: 2940