akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=-mod;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//nCr
long long Comb (long long n, long long r);
//nCr (mod)
long long modC(long long n, long long r) {
    vector<long long> f(n+1),inv(n+1),invf(n+1);
    f[0]=f[1]=1;
    invf[0]=invf[1]=1;
    inv[1]=1;
    for (long long i=2;i<n+1;i++) {
        f[i]=(i*f[i-1])%mod;
        inv[i]=mod-((mod/i)*inv[mod%i])%mod;
        invf[i]=(inv[i]*invf[i-1])%mod;
    }
    long long cmb=f[n]*(invf[r]*invf[n-r]%mod)%mod;
    if (n>=r) return cmb;
    else return 0;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(N);lin(M);
  vector<bool> broken(N,false);
  rep(i,M){
    lin(a);
    broken[a]=true;
  }
  vl dp(N+1);
  dp[0]=1;
  rep(now,N){
    for(ll next=now+1;next<=min(N,now+2);next++){
      if(!broken[next]){
        dp[next]+=dp[now];
        dp[next]%=mod;
      }
    }
  }
  
  cout<<dp[N];
}
    

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;

  if (A == B) {
    if (C != A) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else if (B == C) {
    if (A != B) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else if (C == A) {
    if (B != C) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else cout << "No" << endl;
}

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

#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) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

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

ll modpow(ll b, ll e, ll mod) {
  ll ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}

ll solve(ll x) {
  ll ans = 0;
  while (__builtin_popcountll(x) != 0) {
    x %= __builtin_popcountll(x);
    ++ans;
  }
  return ans;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  string x;
  cin >> n >> x;

  int pcnt = 0;
  for (auto c: x) if (c=='1') ++pcnt;

  vi lo(n), hi(n);

  rep(i,0,n) {
    if (x[i] == '1') {
      if (pcnt-1!=0)
        lo[i] = modpow(2, n-i-1, pcnt-1);
      hi[i] = modpow(2, n-i-1, pcnt+1);
    }
  }

  ll L = accumulate(all(lo), 0ll), H = accumulate(all(hi), 0ll);

  rep(i,0,n) {
    if (x[i] == '1') {
      if (pcnt-1==0) {
        cout << 0 << '\n';
        continue;
      }
      ll rem = (L-lo[i])%(pcnt-1);
      rem += pcnt-1;
      rem %= pcnt-1;
      ll ans = 1+solve(rem);
      cout << ans << '\n';
    } else {
      ll rem = (H+modpow(2,n-i-1,pcnt+1))%(pcnt+1);
      rem += pcnt+1;
      rem %= pcnt+1;
      ll ans = 1+solve(rem);
      cout << ans << '\n';
    }
  }
}

Measured memory_bytes: 5232
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	double n;
	cin >> n;
	if (int(n) % 2 == 0) {
		cout << "0.5" << endl;
	}
	else {
		double ans = (n + 1) / 2 / n;
		cout << setprecision(16) << ans << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

int n;
ll arr[200100];
ll ps[200100];
map<ll,ll> m;

int main() {
    int i;

    scanf("%d",&n);
    for (i=1;i<=n+1;i++) {
        if (m.find(arr[i-1])==m.end()) m[arr[i-1]]=1;
        else m[arr[i-1]]++;
        if (i==n+1) break;
        scanf("%lld",&arr[i]);
        arr[i] += arr[i-1];
    }
    auto it = m.begin();
    ll ans = 0;
    while(it!=m.end()) {
        ans += (*it).second*((*it).second-1)/2;
        it++;
    }
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
const int MOD = 1e9+7;
using namespace std;


int main(){
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;

	if (s == u) a--;
	else b--;
	cout << a << " " << b << endl; 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <chrono>
#include <random>
#include <unordered_map>
#include <cassert>
#pragma GCC optimize("O3")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

int main() {
    int n;
    cin >> n;
    long ans = long(pow(3, n));
    long minus = 1;
    for (int i = 0; i < n; i++) {
        long a;
        cin >> a;
        if (a % 2 == 0) {
            minus *= 2;
        }
    }
    cout << ans - minus << endl;
}


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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    cout << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    cout << ']';
    return s;
}

ll dp[201][100001];

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, x;
    cin >> n >> x;

    vector<int> s(n);
    rep(i, n) cin >> s[i];

    sort(s.rbegin(), s.rend());
    fill_n(*dp, 201*100001, 0);
    dp[0][x] = 1;

    for(int i = 0; i < n; ++i){
        for(int x = 0; x <= 100000; ++x){
            dp[i+1][x%s[i]] += dp[i][x];
            dp[i+1][x%s[i]] %= MOD;
            dp[i+1][x] += dp[i][x]*(n-i-1);
            dp[i+1][x] %= MOD;
        }
    }

    ll ans = 0LL;
    rep(i, s[n-1]){
        ans += i*dp[n][i];
        ans %= MOD;
    }


    ppp(ans);
    return 0;
}


Measured memory_bytes: 157312
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    string s1 = "dream";
    string s2 = "dreamer";
    string s3 = "erase";
    string s4 = "eraser";
    bool continueFlg = true;
    while(continueFlg){
        continueFlg = false;
        rep(i,7){
            if(7>s.size()) break;
            if(s.at(i) != s2.at(i)) break;
            if(7<s.size() && s.at(7)=='a') break;
            if(i==6){
                continueFlg = true;
                s = s.substr(7);
            }
        }
        if(continueFlg) continue;
        rep(i,5){
            if(5>s.size()) break;
            if(s.at(i) != s1.at(i)) break;
            if(i==4){
                continueFlg = true;
                s = s.substr(5);
            }
        }
        if(continueFlg) continue;
        rep(i,6){
            if(6>s.size()) break;
            if(s.at(i) != s4.at(i)) break;
            if(i==5){
                continueFlg = true;
                s = s.substr(6);
            }
        }
        if(continueFlg) continue;
        rep(i,5){
            if(5>s.size()) break;
            if(s.at(i) != s3.at(i)) break;
            if(i==4){
                continueFlg = true;
                s = s.substr(5);
            }
        }
    }
    // cout << s << endl;
    if(s.empty()){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: str):
    summation = 0
    for n in N:
        summation += int(n)
    if summation % 9 == 0:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = next(tokens)  # type: str
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9324
n,k=map(int,input().split())
p=list(map(int,input().split()))
max=0
sum=0
for i in range(0, k):
    sum += p[i]
max=sum
for i in range(1,n-k+1):
    sum+=p[k-1+i]-p[i-1]
    if sum>max:
        max=sum
ans=(max+k)*0.5
print(ans)

Measured memory_bytes: 32064
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rep1(i, n) for(ll i = 1; i < (n); ++i)
#define rep4(i, start, end, step) for (ll i = (start); i < (end); i += (step))

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG (INF << 32)
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

signed main()
{
    cout << fixed << setprecision(9);

    ll n; cin >> n;
    vector<ll> p(n); rep(i, n) cin >> p[i];

    ll ans = 0;
    rep1(i, n - 1){
        if ((p[i - 1] < p[i]) && (p[i] < p[i + 1]))
            ++ans;
        if ((p[i - 1] > p[i]) && (p[i] > p[i + 1]))
            ++ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var A, B, C, X, Y int
	fmt.Scan(&A, &B, &C, &X, &Y)
	a := X
	b := Y
	ab := 0
	cost := A*a + B*b
	max := a
	if b > a {
		max = b
	}
	for i := 0; i <= max*2; i++ {
		n_a := a - 1
		n_b := b - 1
		n_ab := ab + 2
		if n_a < 0 {
			n_a = 0
		}
		if n_b < 0 {
			n_b = 0
		}
		n_cost := A*n_a + B*n_b + C*n_ab
		if n_cost < cost {
			cost = n_cost
			a = n_a
			b = n_b
			ab = n_ab
		} else {
			break
		}
	}
	fmt.Println(cost)
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v) {os << " [" << i++ << "]" << x; if (i % 10 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp) {os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string s;
  std::cin >> s;

  if (s.substr(0, 4) == "YAKI") print("Yes");
  else print("No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=500010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int x=read();
    int cnt=0;
    int p=x;
    while(x) cnt+=x%10, x/=10;
    if(p%cnt==0) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3616
#!/usr/bin/env python3
import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0


n=int(input())
if n%2==0:
    print(n)
else:
    print(n*2)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, t;
  cin >> s;
  cin >> t;

  int max_match_cnt = 0;
  int s_loop_max = s.size() - t.size() + 1;
  int t_loop_max = t.size();

  //cout << "s_loop_max:" << s_loop_max << endl;
  //cout << "t_loop_max:" << t_loop_max << endl;
  
  for(int i=0; i < s_loop_max; i++) {
    int pos = i;
    int cnt = 0;

    for(int j=0; j < t_loop_max; j++) {
      //cout << s.at(pos) << ":" << t.at(j) << endl;
      if(s.at(pos) == t.at(j)) {
        cnt++;
      }
      pos++;
    } // for j
    //一致した最大数を記録
    //cout << "cnt:" << cnt << endl;
    if(max_match_cnt < cnt) max_match_cnt = cnt;
  } // for i

  cout << t.size() - max_match_cnt << endl;
}



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

int mod = 1000000000+7;
long long fac[510000], finv[510000], inv[510000];
 
void factTable() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2; i<510000; i++){
        fac[i] = (fac[i-1]*i) % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}

long long combi(int n, int k){
    if(n<k) {
      return 0;
    }
    if(n<0 || k<0) {
      return 0;
    }
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main() {
  int N, M;
  cin >> N >> M;
  int M_tmp = M;
  map<int, int> primes;
  
  for(int i=2; i*2<=M; i++) {
    while(M_tmp%i==0) {
      if(primes.find(i)==primes.end()) {
        primes.insert(make_pair(i,1));
      } else {
        primes[i]++;
      }
      M_tmp/=i;
    }
  }
  
  factTable();
  
  int ans = 1;
  for(auto itr=primes.begin(); itr!=primes.end(); itr++) {
    int pow = itr->second;
    ans = (ans*combi(pow+N-1,N-1))%mod;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 12160
n, y = map(int, input().split())

for i in range(n+1):
  for j in range(n+1-i):
    if 10000*i + 5000*j + 1000*(n-i-j) == y:
      print("{} {} {}".format(i, j, n-i-j))
      exit()
print("-1 -1 -1")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
long long n;
void out(long long x,long long y,long long z){
    cout<<x<<" "<<y<<" "<<z;
    exit(0);
}
void f(){
    long long c,m;
    for(long long i=1;i<=3500;i++)
        for(long long j=1;j<=3500;j++){
            c=n*i*j;
            m=4*i*j-n*i-n*j;
            if(m>0&&c%m==0)out(i,j,c/m);
        }
}
int main(){
    cin>>n;
    if(n%2==0)out(n,n,n/2);
    if(n%3==0)out(n,n/3*2,n/3*2);
    if((n-3)%4==0)out((n+1)/4,(n+1)*(n+1)/4,(n+1)*(n+1)*n/4);
    if((n-1)%4==0)f();
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
S1 = [[0] * (w+2) for i in range(h+2)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            S1[i+1][j+1] = 1
S2 = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            S2[i][j] = S1[i][j+1] + sum(S1[i+1][j:j+3]) + S1[i+2][j+1]
for i in range(h):
    if 1 in S2[i]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3064
#include<cstdio>

int main(){
	long long L, N;
	scanf("%lld %lld", &L, &N);
	long long X[N], ruiseki[N + 1];
	ruiseki[0] = 0;
	for (int i = 1; i <= N; ++i){
		scanf("%lld", X + i);
		ruiseki[i] = ruiseki[i - 1] + X[i];
	}
	long long answer = 0;
	for (int i = 1; i <= N; ++i){
		if(i + N & 1 && answer < (ruiseki[i + N >> 1] - ruiseki[i - 1] + ruiseki[(i + N >> 1) + 1] - ruiseki[N] + L*(N - (i + N >> 1)))*2 - X[(i + N >> 1) + 1] - L) answer = (ruiseki[i + N >> 1] - ruiseki[i - 1] + ruiseki[(i + N >> 1) + 1] - ruiseki[N] + L*(N - (i + N >> 1)))*2 - X[(i + N >> 1) + 1] - L;
		if(!(i + N & 1) && answer < (ruiseki[(i + N >> 1) - 1] - ruiseki[i - 1] + ruiseki[i + N >> 1] - ruiseki[N] + L*(N - (i + N >> 1)))*2 + X[i + N >> 1]) answer = (ruiseki[(i + N >> 1) - 1] - ruiseki[i - 1] + ruiseki[i + N >> 1] - ruiseki[N] + L*(N - (i + N >> 1)))*2 + X[i + N >> 1];
	}
	for (int i = N; i >= 1; --i){
		if(i & 1 && answer < (ruiseki[i - 1 >> 1] - ruiseki[i] + ruiseki[i + 1 >> 1] + L*(i - (i + 1 >> 1)))*2 + L - X[i + 1 >> 1]) answer = (ruiseki[i - 1 >> 1] - ruiseki[i] + ruiseki[i + 1 >> 1] + L*(i - (i + 1 >> 1)))*2 + L - X[i + 1 >> 1];
		if(!(i & 1) && answer < (ruiseki[(i >> 1) - 1] + ruiseki[i >> 1] - ruiseki[i])*2 + L*i + X[i >> 1]) answer = (ruiseki[(i >> 1) - 1] + ruiseki[i >> 1] - ruiseki[i])*2 + L*i + X[i >> 1];
	}
	printf("%lld\n", answer);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c>>d>>e>>k;
  if ((e-a)>k){
    cout << ":(" <<endl;
  }
  else{
    cout<<"Yay!"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b)&&(b==c)){
        if(a%2==0){
            cout<<-1<<endl;
        }else{
            cout<<0<<endl;
        }
        return 0;
    }
    ll ans=0;
    while(1){
        if((a%2==1)||(b%2==1)||(c%2==1)){
            break;
        }
        int aa=a;
        int bb=b;
        int cc=c;
        a=bb+cc;
        b=aa+cc;
        c=aa+bb;
        if(a%2!=0){
            break;
        }else{
            a/=2;
        }
        if(b%2!=0){
            break;
        }else{
            b/=2;
        }
        if(c%2!=0){
            break;
        }else{
            c/=2;
        }
        ans++;
    }
    cout<<ans<<endl;
}   





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <stack>

using namespace std;


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

  array<int, 9> x;

  x[4] = a + b - c;
  x[6] = b + c - x[4];
  int n = a + c + x[6];
  x[5] = n - b - c;
  x[2] = n - a - x[4];
  x[3] = n - c - x[2];
  x[1] = n - c - x[4];

  cout << a << ' ' << b << ' ' << x[1] << endl;
  cout << x[2] << ' ' << c << ' ' << x[3] << endl;
  cout << x[4] << ' ' << x[5] << ' ' << x[6] << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
  	ll n;cin>>n;
    ll p[n];rep(i,0,n)cin>>p[i];
    ll ans = 0;
    rep(i,1,n-1){
        if(p[i-1] < p[i] && p[i] < p[i+1]) ans++;
        if(p[i-1] > p[i] && p[i] > p[i+1]) ans++;
    }
    cout << ans << ednl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);
 
int n;
vector<ll> h, dp;
 
ll rec(int i) {
    if (dp[i] < inf) return dp[i];
    if (i == 0) return 0;
 
    ll res = inf;
    chmin(res, rec(i - 1) + abs(h[i] - h[i - 1]));
	if (i > 1) {
		chmin(res, rec(i - 2) + abs(h[i] - h[i - 2]));
	}
 
    return dp[i] = res;
}
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/
 
	cin >> n;
	h.resize(n);
	dp.resize(n, inf);
	rep(i, n) cin >> h[i];
 
	out(rec(n - 1));
 
	return 0;
}

Measured memory_bytes: 6528
n, m = gets.split.map &:to_i
l_max, r_min = -1, 1000000
m.times do
  l, r = gets.split.map &:to_i
  l_max = [l, l_max].max
  r_min = [r, r_min].min
end

p [r_min - l_max + 1, 0].max


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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
ll n,a,b,c,d;
const ll N=1e18;
map<ll,ll> dp;
ll f(ll n)
{
    if(dp.count(n)) return dp[n];
    if(n==0) return 0;
    if(n==1) return d;
    ll ans=4e18;
    if(n<=4e9) ans=min(ans,n*d);
    for(ll i=-5;i<=5;i++)
    {
        ll nextN=n+i;
        if(nextN<0) continue;
        if(nextN%2==0 && nextN/2 <n)
        {
            ans=min(ans,abs(i)*d+f(nextN/2)+a);
        }
        if(nextN%3==0 && nextN/3<n)
        {
            ans=min(ans,abs(i)*d+f(nextN/3)+b);
        }
        if(nextN%5==0 && nextN/5<n)
        {
            ans=min(ans,abs(i)*d+f(nextN/5)+c);
        }
    }
    return dp[n]=ans;
}
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll t;
    cin>>t;
    while(t--)
    {

        cin>>n>>a>>b>>c>>d;
        // vector<ll> nums={2,3,5};
        // ll ans;
        // ans=f(n);
        dp.clear();
        dp[0]=0;
        dp[1]=d;
        ll ans=f(n);
        cout<<ans<<'\n';
    }
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


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


int Q;
long long A, B;


bool is_possible(long long x){
    bool ret = true;
    for(long long i = x/2 - 2; i <= x/2 + 2; i++){
        long long j = x - i + 1;
        long long a, b;
        if(i >= A){
            a = i + 1;
        }else{
            a = i;
        }
        if(j >= B){
            b = j + 1;
        }else{
            b = j;
        }
        if(a * b >= A * B){
            ret = false;
        }
    }
    return ret;
}


// is_possible(begin) == true, is_possible(end) == false;
long long binary_search(long long begin, long long end){
    if(end - begin <= 1){
        return begin;
    }
    long long mid = (begin + end) / 2;
    if(is_possible(mid)){
        return binary_search(mid, end);
    }else{
        return binary_search(begin, mid);
    }
}


int main(){
    cin >> Q;
    for(int q = 0; q < Q; q++){
        cin >> A >> B;
        cout << binary_search(0, 5e9) << endl;
    }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		int x;
		while (true) {
			n = sc.nextInt();
			x = sc.nextInt();
			if (n == 0 && x == 0)
				break;
			calcWays(n, x);
		}

	}

	public static void calcWays(int n, int x) {
		int ways = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				for (int k = 1; k <= n; k++) {
					if (i > j && j > k && i + j + k == x) {
						ways++;
					}
				}
			}
		}
		System.out.println(ways);
	}
}

Measured memory_bytes: 26632
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n,m,x;
  std::cin >> n >> m >> x;
  vt<int> a(m);

  int ans1 = 0 , ans2 = 0;
  rep(i,m){
    std::cin >> a[i];
    if(a[i] < x)
      ans1++;
    else
      ans2++;
  }

  std::cout << (ans1< ans2 ? ans1 : ans2) << '\n';
  return 0;
}


Measured memory_bytes: 256
h,w,d=map(int,input().split())
lst=[0 for i in range(h*w+1)]
for i in range(h):
    x=list(map(int,input().split()))
    for j in range(w):
        lst[x[j]]=(i,j)

dif=[0 for i in range(h*w+1)]
i=d+1
while i<=w*h:
    dif[i]=dif[i-d]+abs(lst[i][0]-lst[i-d][0])+abs(lst[i][1]-lst[i-d][1])
    i+=1

q=int(input())
ans=[]
for i in range(q):
    l,r=map(int,input().split())
    ans.append(dif[r]-dif[l])
for num in ans:
    print(num)


Measured memory_bytes: 18472
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) (m*n)/GCD(m,n)
# define mod 1000000007

int main()
{
    IOS;
    ll i,j,k,t,n,sum=0,prod=1,flag=0,mark=0,marker=0,m;
    cin >> n >> m;
    ll a[n];
    priority_queue<ll> q;
    for(i=0;i<n;i++)
        {
            cin >> a[i];
            q.push(a[i]);
        }
   for(i=0;i<m;i++)
   {
       ll x = q.top();
       q.pop();
       x/=2;
       q.push(x);
   }
   while(!q.empty())
   {
       sum+=q.top();
       q.pop();
   }
   cout << sum << endl;
}


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

int main(){
  int n,m,l;
  cin>>n>>m>>l;
  long long a[n][m],b[m][l],c[n][l];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++) cin>>a[i][j];
  }for(int i=0;i<m;i++){
    for(int j=0;j<l;j++) cin>>b[i][j];
  }for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      c[i][j]=0;
      for(int k=0;k<m;k++) c[i][j]+=a[i][k]*b[k][j];
    }
  }for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      if(j) cout<<" ";
      cout<<c[i][j];
    }cout<<endl;
  }return 0;
}



Measured memory_bytes: 3316
// Stable sort
#include <stdio.h>
#include <stdbool.h>

typedef struct Card{
    char c;
    int value;
}Card;

void bubbleSort(Card C[], int N)
{
    int i, j;
    Card tmp;
    for(i=0; i<N; i++){
        for(j = N-1; j>i; j--){
            if(C[j].value < C[j-1].value){
                tmp = C[j];
                C[j] = C[j-1];
                C[j-1] = tmp;
            }
        }
    }
}

void selectionSort(Card C[], int N)
{
    int i, j, minj;
    Card tmp;
    for(i=0; i<N; i++){
        minj = i;
        for(j=i; j<N; j++){
            if(C[j].value < C[minj].value){
                minj = j;
            }
        }
        tmp = C[i];
        C[i] = C[minj];
        C[minj] = tmp;
    }
}

bool isStable(Card in[], Card out[], int N)
{
    int i;
    for(i=0; i<N; i++){
        if(!(in[i].c == out[i].c && in[i].value == out[i].value)){
            return false;
        }
    }
    return true;
}

int main(void)
{
    int N, i;
    scanf("%d%*c", &N);
    Card c1[N], c2[N];
    for(i=0; i<N; i++){
        scanf("%c%d%*c", &c1[i].c, &c1[i].value);
        c2[i] = c1[i];
    }
    bubbleSort(c1, N);
    selectionSort(c2, N);

    // bubble sortした構造体Cardの配列の表示
    for(i=0; i<N; i++){
        if(i==N-1){
            printf("%c%d\n", c1[i].c, c1[i].value);
        }else{
            printf("%c%d ",c1[i].c, c1[i].value);
        }
    }
    printf("Stable\n");

    // selection sortした構造体Cardの配列の表示と安定の判断を行う
    for(i=0; i<N; i++){
        if(i==N-1){
            printf("%c%d\n", c2[i].c, c2[i].value);
        }else{
            printf("%c%d ", c2[i].c, c2[i].value);
        }
    }
    if(isStable(c1, c2, N)){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }
    
    return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
long long n,m,f[100010],w[100200],v[100200];
int main ()
{
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	cin>>n>>m;
	for(long long i=1;i<=n;i++)
	{
		cin>>v[i]>>w[i];
	}
	for(long long i=1;i<=n;i++)
	{
		for(long long j=100000;j>=w[i];j--)
		{
			f[j]=min(f[j],f[j-w[i]]+v[i]);
		}
	}	
	long long ans=0;
	for(long long i=1;i<=100000;i++)
	{
		if(f[i]<=m) ans=max(ans,i);
	}
	cout<<ans;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> k(100002);
    int ma=0;
    for(int i=0;i<n;i++){
        int a,b;cin>>a>>b;
        ma=max(ma,b);
        k[a-1]--;
        k[b]++;
    }
    int count=1;
    for(int i=ma;i>=0;i--){
        count+=k[i];
        if(count>=i){
            count=i;break;
        }
    }
    cout<<count-1<<endl;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#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 fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 10;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,d,e;
	cin >> a >> c >>b  >> d >> e;
	int t = abs(a-b);
	int v = c - d;
	if(v <= 0){
		cout << "NO";
	}
	else{
		if(ll(e)*v < t){
			cout << "NO";
		}
		else{
			cout << "YES";
		}
	}
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int i,sm=0,j;
  for(i=0;i<m;i++)
  {cin>>j;
   sm+=j;
}
  if(sm>n)
    cout<<-1;
  else
    cout<<n-sm;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;


int main(){
    int N; cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    vector<int> counter(10000000, 0);

    rep(i,N){
        if (a[i]-1 >= 0 ) counter[a[i]-1]++;
        counter[a[i]]++;
        counter[a[i]+1]++;
    }

    int ans = 0;
    rep(i,10000000){
        ans = max(ans, counter[i]);
    }

    cout << ans << endl;


}

Measured memory_bytes: 42732
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############

S = input()

def dfs(i, s):
    global ans
    if i == len(S):
        lista = list(map(int, s.split("+")))
        return sum(lista)
    else:
        return dfs(i + 1, s + S[i]) + dfs(i + 1, s + '+' + S[i])
print(dfs(1, S[0]))

Measured memory_bytes: 64620
#include<iostream>
#include<algorithm>
using namespace std;
#include<vector>
#include<functional>
#include<limits>
template<typename T>
struct segtree{
	function<T(T,T)>calcfn,updatefn;
	int n;
	T defvalue;
	vector<T>dat;
	segtree(int n_=0,T defvalue_=numeric_limits<T>::max(),
		function<T(T,T)>calcfn_=[](T a,T b){return a<b?a:b;},
		function<T(T,T)>updatefn_=[](T a,T b){return b;}
	):defvalue(defvalue_),calcfn(calcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[i*2+1],dat[i*2+2]);
	}
	void update(int i,T a)
	{
		i+=n-1;
		dat[i]=updatefn(dat[i],a);
		while(i>0)
		{
			i=(i-1)/2;
			dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
		}
	}
	T query(int a,int b,int i=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		if(r<=a||b<=l)return defvalue;
		else if(a<=l&&r<=b)return dat[i];
		else
		{
			return calcfn(
				query(a,b,i*2+1,l,(l+r)/2),
				query(a,b,i*2+2,(l+r)/2,r)
			);
		}
	}
};
int N,R,L;
int cnt[1<<17];
main()
{
	cin>>N>>R>>L;
	segtree<pair<int,int> >P(N,make_pair(0,0),[](pair<int,int>a,pair<int,int>b){return a<b?a:b;},
	[](pair<int,int>a,pair<int,int>b){return make_pair(a.first-b.first,b.second);});
	for(int i=0;i<N;i++)P.update(i,make_pair(0,i));
	int pre=0;
	for(int i=0;i<R;i++)
	{
		int d,t,x;cin>>d>>t>>x;d--;
		cnt[P.query(0,N).second]+=t-pre;
		pre=t;
		P.update(d,make_pair(x,d));
	}
	cnt[P.query(0,N).second]+=L-pre;
	int ans=0,id;
	for(int i=0;i<N;i++)if(cnt[i]>ans)ans=cnt[id=i];
	cout<<id+1<<endl;
}



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

int main() {

  int n;
  cin >> n;
  
  long long mx = 0 - 1LL<<60;
  long long mn = 1LL<<60;
  long long sum = 0;

  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    mn = min(mn, a);
    mx = max(mx, a);
    sum += a;
  }

  cout << mn << " " << mx << " " << sum << endl;

  return 0;

}


Measured memory_bytes: 3108
N,M = map(int,input().split())
ps = []
for i in range(M):
	P,S = map(str,input().split())
	ps.append((int(P),S))
#print(ps)
p_flag = [0]*N
ans_flag = [0]*N
cnt_ans = 0
cnt_p = 0
p_cnt_flag = [0]*N
for i in range(M):
	if(p_flag[ps[i][0]-1] == 0 and ps[i][1] == "WA"):
		p_cnt_flag[ps[i][0]-1]+=1
	if(ans_flag[ps[i][0]-1] == 0 and ps[i][1] == "AC"):
		cnt_ans+=1
		ans_flag[ps[i][0]-1]+=1
		p_flag[ps[i][0]-1]+=1
		cnt_p+=p_cnt_flag[ps[i][0]-1]
print(cnt_ans,cnt_p)

Measured memory_bytes: 21328
line = input()
n, m = line.split(" ")
n = int(n)
m = int(m)

if n < 2 and m < 2:
    print("0")
elif n < 2 and m >= 2:
    ans = 0
    for i in range(m):
        ans = ans + (i)
    print(ans)
elif n >= 2 and m < 2:
    ans = 0
    for i in range(n):
        ans = ans + (i)
    print(ans)
elif n >= 2 and m >= 2:
    ans = 0
    for i in range(n):
        ans = ans + (i)
    for i in range(m):
        ans = ans + (i)
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
ll a[100000+10];
ll ans[200000+100];
int lp,rp;

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    ans[100010] = a[0];
    ans[100011] = a[n-1];
    lp = 100010;
    rp = lp+1;
    ll sp=1,bp=n-2;
    ll mem1,mem2,mem3,mem4,mems,memb;
    for(int i = 2; i < n; i++){
        mem1 = abs(ans[lp]-a[sp]);
        mem2 = abs(ans[rp]-a[sp]);
        mem3 = abs(ans[lp]-a[bp]);
        mem4 = abs(ans[rp]-a[bp]);
        mems = max(mem1,mem2);
        memb = max(mem3,mem4);

        if(mems >= memb){
            if(mem1 >= mem2){
                --lp;
                ans[lp] = a[sp];
                
            }
            else{
                ++rp;
                ans[rp] = a[sp];
            }
            ++sp;
        }
        else{
            if(mem3 >= mem4){
                --lp;
                ans[lp] = a[bp];
                
            }
            else{
                ++rp;
                ans[rp] = a[bp];
            }
            --bp;
        }
    }

    ll an=0;
    for(int i = lp; i < rp; i++){
        an += abs(ans[i]-ans[i+1]);
    }
    cout << an << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl;
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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; }

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


int main()
{
    int n,l;
    cin>>n>>l;
    string s[n];
    REP(i,n) cin>>s[i];
    sort(s,s+n);
    REP(i,n) cout<<s[i];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(),a.end());

	// a[i]*a[j] <= cなる(i,j)がk個以上ある
	auto f = [&](ll c){

		ll cnt = 0;
		rep(i,n){

			if(a[i]>0){
				// a[j] <= c/a[i]
				if(c<0 && c%a[i] != 0) cnt += upper_bound(a.begin(),a.end(),c/a[i]-1)-a.begin();
				else cnt += upper_bound(a.begin(),a.end(),c/a[i])-a.begin();
			}
			else if(a[i]==0){
				if(c>=0) cnt += n;
			} 
			else{
				// a[j] >= c/a[i]
				if(c<0 && c%a[i] != 0) cnt += a.end()-lower_bound(a.begin(),a.end(),c/a[i]+1);
				else cnt += a.end()-lower_bound(a.begin(),a.end(),c/a[i]);
			}

		}

		rep(i,n) if(a[i]*a[i] <= c) cnt--;
		return cnt/2 >= k;

	};

	auto bs = [&](){
		ll ng = -1e18-1;
		ll ok = 1e18+1;
		ll mid = (ng+ok)/2;

		while(abs(ng-ok) > 1){
			if(f(mid)) ok = mid;
			else ng = mid;
			mid = (ng+ok)/2;
		}
		
		return ok;
	};

	cout << bs() << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 1792
def otoshidama():
	N, Y = map(int, input().split())
	a = b = c = -1
	for ai in range(0, N + 1):
		for bi in range(0, N + 1 - ai):
			if 10000 * ai + 5000 * bi + 1000 * (N - ai -bi) == Y:
				a = ai
				b = bi
				c = N - ai - bi
				break
		else:
			continue
		break
	print("{0} {1} {2}".format(a,b,c))

otoshidama()

Measured memory_bytes: 39408
#include<cstdio>
#include <cstring>

#include<iostream>

#include<algorithm>

#include<queue>
#define INF 1900000000

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

#define RREP(i,n) for(int i=(n)-1;i>=0;i++)

using namespace::std;

typedef pair<int,int> P;

typedef pair<P,int> PP;

int h,w,ans[200][200];
char map[200][200];


int main(){
	memset( ans, -1, sizeof( ans ) );
	scanf("%d%d",&h,&w);
	REP(i,h)scanf("%s",map[i]);
	
	REP(i,h)REP(j,w)if(map[i][j]=='c')ans[i][j]=0;
	REP(i,h){
		int f=-INF;
		REP(j,w){
			if(map[i][j]=='c')f=0;
			if(f>0&&ans[i][j]==-1)ans[i][j]=f;
			f++;
			}
	}

	REP(i,h){
		REP(j,w-1)printf("%d ",ans[i][j]);
		printf("%d\n",ans[i][w-1]);
	}
}

Measured memory_bytes: 3364
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    double r; cin >> r;
    double ans = 2 * r * M_PI;
    cout << setprecision(10) << ans << endl;
}



Measured memory_bytes: 3784
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
 
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	cout.tie(nullptr);
	char c;
	cin>>c;
	if(isupper(c))cout<<"A"<<endl;
	else cout<<"a"<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
  string s;
  cin >> s;
  int g = 0, p = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'p')p++;
    else g++;
  }
  int d = (p + g) / 2;
  cout << d - p << endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define endl '\n'
#define _USE_MATH_DEFINES
using namespace std;

int main() {
	
	ios::sync_with_stdio(false);
    cin.tie(0);
    
    int i,goal,num,ans = 0,p;
    cin>>goal>>num;
    int forbi[102] = {0};
    for(i = 0;i<num;i++){
    	cin>>p;
    	forbi[p] = 1;
	}
	int test = goal;
	while(forbi[test]){
		if(test == 0 || test == 101) break;
		else if(test == goal){
			test = test-1;
		}
		//else if(test == 0)
		else if(test<goal){
			test = goal*2-test;
		}
		else{
			test = goal*2-test-1;
		}
	}
    cout<<test;
	//cout<<ans+1;
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int n,k,val[100005],l[100005],r[100005];
vector<int> g[100005];
void die()
{
	cout<<"No"<<endl;
	exit(0);
}
void solve(int v,int p)
{
	l[v]=-1e9-1;
	r[v]=1e9+1;
	if(val[v]!=-1) l[v]=r[v]=val[v];
	for(int i=0;i<g[v].size();i++)
	{
		int to=g[v][i];
		if(to==p) continue;
		solve(to,v);
		if(l[to]<-1e8) continue;
		if(l[v]<-1e8)
		{
			l[v]=l[to]-1;
			r[v]=r[to]+1;
		}
		else
		{
			if(abs(l[v])%2==abs(l[to])%2)
				die();
			l[v]=max(l[v],l[to]-1);
			r[v]=min(r[v],r[to]+1);
		}
	}
	if(l[v]>r[v]) die();
}
void make(int v,int p)
{
	for(int i=0;i<g[v].size();i++)
	{
		int to=g[v][i];
		if(to==p) continue;
		if(val[to]==-1)
			if(l[to]<=val[v]-1&&val[v]-1<=r[to])
				val[to]=val[v]-1;
			else
				val[to]=val[v]+1;
		make(to,v);
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<=n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	memset(val,-1,sizeof(val));
	cin>>k;
	for(int i=1;i<=k;i++)
	{
		int v,p;
		cin>>v>>p;
		val[v]=p;
	}
	solve(1,-1);
	val[1]=l[1];
	make(1,-1);
	cout<<"Yes"<<endl;
	for(int i=1;i<=n;i++)
		cout<<val[i]<<endl;
	return 0;
}


Measured memory_bytes: 15360