akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;

const int N = (int)1e3 + 7;
const int inf = (int)1e9 + 7;

int a[N];
ll dp[N];
int pr[N];

main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    dp[i] = a[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i - 2; j >= 1; j -= 2) {
      if (dp[j] + a[i] > dp[i]) {
        dp[i] = dp[j] + a[i];
        pr[i] = j;
      }
    }
  }
  ll ans = -inf;
  int ind = -1;
  for (int i = 1; i <= n; i++) {
    if (dp[i] > ans) {
      ans = dp[i];
      ind = i;
    }
  }
  printf("%lld\n", ans);
  vector < int > vec;
  for (int i = n; i > ind; i--) {
    vec.pb(i);
  }
  n = ind;
  while (pr[ind]) {
    int mid = (ind + pr[ind]) >> 1;
    int c = ind - mid;
    while (c--) {
      vec.pb(mid);
      mid--;
    }
    ind = pr[ind];
  }
  for (int i = 1; i < ind; i++) {
    vec.pb(1);
  }
  printf("%d\n", sz(vec));
  for (int to : vec) {
    printf("%d\n", to);
  }
}


Measured memory_bytes: 256
var n,re,t,i:longint;
    a:array[1..100000] of longint;


procedure sort(l,r:longint);
var x,tmp,i,j:longint;
begin
	i:=l; j:=r;
	x:=a[(l + r) shr 1];
	repeat
	  while a[i] < x do inc(i);
	  while a[j] > x do dec(j);
	  if i <= j then
	    begin
	      tmp:=a[i];
	      a[i]:=a[j];
	      a[j]:=tmp;
	      inc(i);
	      dec(j);
	    end;
	until i > j;
	if l < j then sort(l,j);
	if i < r then sort(i,r);
end;

begin
	readln(n);
	for i:=1 to n do read(a[i]);
	sort(1,n);
    t:= n shr 1;
    if a[t] = a[t + 1] then re:=0
    else re:=a[t + 1] - a[t];
    write(re);
end.

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
b=sum(b)

for i in range(n-1):
  if a[i+1]-a[i]==1:
    b+=c[a[i]-1]
    
print(b)

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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    bool ok = false;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            ok = true;
            break;
        }
    }

    string ans;
    if (ok)
        ans = "OK";
    else
        ans = "NG";

    cout << ans << endl;
}

Measured memory_bytes: 3612
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static int mod = 998244353;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();

        if(S.length() > K){
            System.out.println(S.substring(0,K) + "...");
        } else {
            System.out.println(S);
        }

    }

}









Measured memory_bytes: 38548
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep2(i,st,ed) for(int i = st; i < ed; ++i)
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
const ll mod = 1e5+3;
const ll N = 1e2 + 200;
const ll INF = 9999999999999;
const double eps = 1e-7;

int main(){
    int n;
    int g[4][4];
    int vis[4][4] = {0};
    rep(i,3){
        rep(j,3){
            cin>>g[i][j];
        }
    } 
    cin>>n;
    int x;
    rep(i,n){
        cin>>x;
        rep(j,3){
            rep(k,3){
                if(g[j][k] == x){
                    vis[j][k] = 1;
                }
            }
        }
    } 
    int flag = 0;
    int a[4] = {0};
    rep(i,3){
        a[0] = 0;
        a[1] = 0;
        rep(j,3){
            if(vis[i][j] == 1){
                a[0]++;
            }
            if(vis[j][i] == 1){
                a[1]++;
            }
        }
        if(a[0] == 3 || a[1] == 3) flag = 1;
    }
    rep(i,3){
        if(vis[i][i] == 1){
            a[3]++;
        }
        if(vis[2-i][i] == 1){
            a[2]++;
        }
    }
    if(a[3] == 3 || a[2] == 3){
        flag = 1;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define name(x) #x
using namespace std;


const int INF = INT_MAX-100;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

int main() {
    // if double is required
    
    string s;
    cin>>s;
    
    int out = 0;
    
    for(auto i = 0;i<(s.size()+1)/2;i++){
        out -= (s[i]=='p');
    }
    
    for(auto i = (s.size()+1)/2;i<s.size();i++){
        out += (s[i]=='g');
    }
    
    cout << out << endl;
    return 0;
}




Measured memory_bytes: 512
# saikyouA
M,D = map(int,input().split())
cnt = 0
for i in range(M+1):
    for j in range(D+1):
        d1 = j-(j//10)*10
        d10 = j//10
        
        if d1 >= 2 and d10 >= 2 and d1*d10 == i:
            cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(int i = int(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)

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; }
template<typename T> inline void remove(std::vector<T>& vector, unsigned int index) { vector.erase(vector.begin() + index); }

const long long INF = 1LL << 60;

// ここから開始だよ！
ll N, mark;
vector<ll> B, ans;

int main() {
	// 呪文エリア
	cin.tie(0);
	ios::sync_with_stdio(false);
	// 詠唱完了

	cin >> N;
	rep(i, N) {
		ll tmp;
		cin >> tmp;
		B.push_back(tmp);
	}

	while (!B.empty()) {
		mark = -1;
		rep(i, B.size()) {
			if (B[i] == i + 1 && mark < i + 1) {
				mark = i + 1;
			}
		}
		if (mark == -1) {
			cout << -1 << endl;
			return 0;
		}
		else {
			remove(B, mark-1);
			ans.push_back(mark);
		}
	}

	rerep(i, ans.size()) {
		cout << ans[i] << endl;
	}

	return 0;
}


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

int main()
{
    long long t,n,m,i,j,k,x=0,y=0,z;
    cin>>n>>m>>k;

    if(n==m)
    {
        for(i=0; i<n; i++)
        {
            cout<<k<<" ";
        }
        cout<<endl;
        return 0;
    }
    for(i=0; i<m; i++)
    {
        cout<<k<<" ";
    }
    if(k>1)
    {
        for(i=m; i<n; i++)
        {
            cout<<k-1<<" ";
        }
    }
    else
    {
        for(i=m; i<n; i++)
        {
            cout<<k+2<<" ";
        }
    }
    cout<<endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vec h(n);
  for(ll i=0;i<n;i++) cin >> h[i];
  ll ans=0;
  ll tmp=h[0];
  for(ll i=0;i<n;i++) {
    ans+=tmp<=h[i];
    tmp=max(tmp,h[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] v = new int[n];
    int[] c = new int[n];
    int[] sub = new int[n];
    int num = 0;
    for(int i=0; i<n;i++){
      v[i] = sc.nextInt();
    }
    for(int i=0; i<n;i++){
      c[i] = sc.nextInt();
    }
    for(int i=0; i<n;i++){
      sub[i] = v[i] -c[i];
    }
    for(int i=0; i<n;i++){
      if(sub[i]>0){
        num += sub[i];
      }
    }
    System.out.println(num);
  }
}

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

int main(){
    long long n;
    cin >> n;
    vector<long long> a(3*n);
    for(int i = 0;i < 3*n;i++){
        cin >> a[i];
    }
    /**/
    sort(a.begin(), a.end());

    long long ans = 0;
    for(int i = n*3 - 2;i >= n*3 - n*2;i -= 2){
        ans += a[i];
        //cout << a[i] << endl;
    }

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

Measured memory_bytes: 5108
N,A,B,C = map(int, input().split())

bms = [int(input()) for _ in range(N)]

def dfs(cur,a,b,c):
    if cur == N:
        s = abs(A-a)+abs(B-b)+abs(C-c)-30 if min(a,b,c) > 0 else 10**9
        return s
    s_0 = dfs(cur+1,a,b,c)
    s_a = dfs(cur+1,a+bms[cur],b,c) + 10
    s_b = dfs(cur+1,a,b+bms[cur],c) + 10
    s_c = dfs(cur+1,a,b,c+bms[cur]) + 10
    return min(s_0,s_a,s_b,s_c)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vi ans(n);

    int cnt = 0;
    //R
    rep(i, n) {
       if(s[i] == 'R') cnt++;
        else {
            ans[i] += cnt / 2;
            ans[i - 1] += (cnt+1) / 2;
            cnt = 0;
        }
    }

    //L
    cnt = 0;
    for(int i = n - 1; i >= 0; i--) {
        if(s[i] == 'L') cnt++;
        else {
            ans[i] += cnt / 2;
            ans[i + 1] += (cnt+1) / 2;
            cnt = 0;
        }
    }

    rep(i, n) {
        cout << ans[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll mod=1e9+7 ;
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 n;
ll a[100000+5];
ll b[100000+5];

int main(){
	scanf("%d", &n);
	FOR(i,1,n+1){
		scanf("%lld", a+i);
	}
	FOR(i,1,n) scanf("%lld", b+i);
	ll ans = 0;
	FOR(i,1,n+1){
		if(i>=2) {ll cur = min(b[i-1],a[i]); a[i] -= cur; b[i-1] -= cur; ans += cur; }
		if(i<=n) {ll cur = min(b[i],a[i]); a[i] -= cur; b[i] -= cur; ans += cur;}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
#define MOD 1000000007
#define MAX_N 100000
#define MAX_P 200005
Int fact[MAX_P],inv[MAX_P];
Int extgcd(Int a,Int b,Int& x,Int& y){
  Int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
Int mod_inverse(Int a,Int mod){
  Int x,y;
  extgcd(a,mod,x,y);
  return (mod+x%mod)%mod;
}
Int euler_phi(Int n){
  Int res=n;
  for(Int i=2;i*i<=n;i++){
    if(n%i==0){
      res=res/i*(i-1);
      for(;n%i==0;n/=i);
    }
  }
  if(n!=1) res=res/n*(n-1);
  return res;
}

Int euler[MAX_N];

void euler_phi2(){
  for(Int i=0;i<MAX_N;i++) euler[i]=i;
  for(Int i=2;i<MAX_N;i++){
    if(euler[i]==i){
      for(Int j=i;j<MAX_N;j+=i) euler[j]=euler[j]/i*(i-1);
    }
  }
}

Int mod_pow(Int x,Int n,Int mod){
  Int res=1;
  while(n>0){
    if(n&1) (res*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return res;
}

Int mod_inverse2(Int a,Int mod){
  return mod_pow(a,mod-2,mod);
}

void init(Int mod){
  fact[0]=1;
  for(Int i=1;i<MAX_P;i++)
    fact[i]=(fact[i-1]*i)%mod;

  inv[1]=1;
  for(Int i=2;i<MAX_P;i++)
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
}

Int mod_fact(Int n,Int mod,Int& e){
  e=0;
  if(n==0) return 1;
  Int res=mod_fact(n/mod,mod,e);
  e+=n/mod;
  if(n/mod%2!=0)return res*(mod-fact[n%mod]) %mod;
  return res*fact[n%mod]%mod;
}

Int mod_comb(Int n,Int k,Int mod){
  if(n==k||k==0) return 1;
  Int e1,e2,e3;
  Int a1=mod_fact(n,mod,e1),a2=mod_fact(k,mod,e2),a3=mod_fact(n-k,mod,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inverse(a2*a3%mod,mod)%mod;
}

Int mod_comb2(Int n,Int k,Int mod){
  Int res=1;
  for(Int i=0;i<k;i++){
    res*=(n-i)%mod;
    res%=mod;
    res*=mod_inverse(i+1,mod);
    res%=mod;
  }
  return res;
}

Int montmort(Int n,Int mod){
  Int res=0,inv=1;
  for(Int k=2;k<=n;k++){
    (inv*=mod_inverse(k,mod))%=mod;
    if(k%2) (res+=mod-inv)%=mod;
    else (res+=inv)%=mod;
  }
  for(Int i=1;i<=n;i++)
    (res*=i)%=mod;
  return res;
}
//END CUT HERE

//mod_pow
signed AOJ_NTL1B(){
  Int n,m;
  cin>>m>>n;
  cout<<mod_pow(m,n,MOD)<<endl;
  return 0;
}
/*
  verified on 2017/12/31
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_B&lang=jp
*/


//euler_phi:
signed AOJ_NTL1D(){
  Int n;
  cin>>n;
  cout<<euler_phi(n)<<endl;
  return 0;
}
/*
  verified on 2017/12/31
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_D&lang=jp
*/

//extgcd
signed AOJ_NTL1E(){
  Int a,b;
  cin>>a>>b;
  Int x,y;
  extgcd(a,b,x,y);
  cout<<x<<" "<<y<<endl;
  return 0;
}
/*
  verified on 2017/12/31
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_E&lang=jp
*/

//montmort
signed ARC009_C(){
  Int n,k;
  cin>>n>>k;
  const Int MMOD=1777777777;
  Int a=montmort(k,MMOD);
  a=a*mod_comb2(n,k,MMOD)%MMOD;
  cout<<a<<endl;
  return 0;
}
/*
  verified on 2017/12/31
  https://arc009.contest.atcoder.jp/tasks/arc009_3
*/


signed main(){
  //AOJ_NTL1B();
  //AOJ_NTL1D();
  AOJ_NTL1E();
  
  //ARC009_C();
  return 0;
}

Measured memory_bytes: 3124
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
import itertools #list(accumulate(A))

S = sys.stdin.readline().rstrip()
S_int = list(map(int, list(S)))
N = len(S)
cnt = 0

if N==1:
    print(S)
    exit()

for l in list(itertools.product([0, 1], repeat=N-1)):
    if l[0] == 0:
        tmp = S_int[0]
    else:
        tmp = 0
        cnt += S_int[0]

    for i, kigo in enumerate(l):
        if kigo == 1:
            cnt += tmp
            tmp = S_int[i+1]
        else:
            tmp = tmp * 10 + S_int[i+1]
    cnt += tmp

print(cnt)

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int gcd(ll a, ll b){
  if(b == 0){
    return a;
  }else{
    return gcd(b,a%b);
  }
}

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

  int n;
  cin >> n;
  int a[n];
  REP(i,n) cin >> a[i];

  // dp[i][j] := a[i]からa[j]まで残った状態から始まった時の得点
  vector<vector<ll>> dp(n,vector<ll>(n));

  REP(i,n){
    if((n-1)%2==0){
      dp[i][i] = a[i];
    }else{
      dp[i][i] = -a[i];
    }
  }

  FOR(dif,1,n){
    REP(j,n){
      if(j+dif >= n)break;

      //とった数が偶数なら先手の番
      if((n-dif-1)%2==0){
        dp[j][j+dif] = max(dp[j+1][j+dif] + a[j] , dp[j][j+dif-1] + a[j+dif]);
      }else{
        dp[j][j+dif] = min(dp[j+1][j+dif] - a[j] , dp[j][j+dif-1] - a[j+dif]);
      }
    }
  
  }

  cout << dp[0][n-1] << endl;
  return 0;
}


Measured memory_bytes: 73652
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=2e5+7;
int tree[maxn];
void add(int x)
{
    while(x<maxn)
    {
        tree[x]++;
        x+=x&-x;
    }
}
int query(int x)
{
    int ret=0;
    while(x)
    {
        ret+=tree[x];
        x-=x&-x;
    }
    return ret;
}
vc<ll> all;
inline int getid(ll x)
{
    return lower_bound(all.begin(),all.end(),x)-all.begin()+1;
}
int main()
{
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    vi a(n+1);
    ll pre=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        pre+=a[i];
        ll val=pre-i*k;
        all.push_back(val);
    }
    all.push_back(0);
    mkuni(all);
    pre=0;
    add(getid(0));
    for(int i=1;i<=n;i++)
    {
        pre+=a[i];
        ll val=pre-i*k;
        //dbg(i,val);
        ans+=query(getid(val));
        add(getid(val));
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 3440
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int X, Y; cin >> X >> Y;


    bool ok = false;
    for (int t = 0; t <= 100; t++) {
        for (int k = 0; t + k <= X || 2 * t + 4 * k <= Y; k++) {
            if (t + k == X && 2 * t + 4 * k == Y) {
                ok = true;
                break;
            }
        }
        if (ok) break;
    }    

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

signed main(){
    ll n,q,l,r;
    cin>>n>>q>>l>>r;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll p[q],x[q],s[q],t[q];
    for(int i=0;i<q;i++){
        cin>>p[i]>>x[i]>>s[i]>>t[i];
    }
    sort(a,a+n);
    ll low = 0,up = n;
    while(up-low>0){
        ll mid = (low+up)/2;
        ll now = a[mid];
        for(int i=0;i<q;i++){
            if(p[i]==1){
                if(x[i]>now) continue;
                now = t[i] * (now+s[i]);
            }
            else {
                if(x[i]<now) continue;
                now = (now - s[i])/t[i];
            }
        }
        if(now<l){
            low = mid+1;
        }
        else up = mid;
    }
    ll L=low;
    low = 0, up = n;
    while(up-low>0){
        ll mid = (low+up)/2;
        ll now = a[mid];
        for(int i=0;i<q;i++){
            if(p[i]==1){
                if(x[i]>now) continue;
                now = t[i] * (now+s[i]);
            }
            else {
                if(x[i]<now) continue;
                now = (now - s[i])/t[i];
            }
        }
        if(now<=r){
            low = mid+1;
        }
        else up = mid;
    }
    ll R = low;
    //cout << L << " " << R << endl;
    ll ans = max(0LL,R-L);
    cout << ans << endl;
}


Measured memory_bytes: 10776
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <cmath>
#include <array>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI;
typedef pair<int,int> pii;
const int mod = (int)1e9+7;


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll a, b;
	cin >> a >>b;
	
	ll n = b-a;
	if(a<=0 && b>=0) puts("Zero");
	else if(a>0 ) puts("Positive");
	else{
		if(n%2==0)  puts("Negative");
		else puts("Positive");
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());
            int Y = int.Parse(Console.ReadLine());

            if (N <= K)
            {
                Console.WriteLine(N*X);
            }
            else
            {
                Console.WriteLine(
                    X*K+Y*(N-K) 
                    );
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        while(a % 2 == 0){
            a /= 2;
            ++ans;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    double ans;
    if(N % 2 == 0){
        ans = 0.5;
    } else {
        ans = (double)(N + 1) / (2 * N);
    }
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
# define int long long

using namespace std;

const int N = 500;

int32_t main() {
    int n, k, ans = 1e18;
    cin >> n >> k;
    n %= k;

    map < int, int > used;
    ans = min( ans, n );

    while ( !used[n] ) {
        used[n] = 1;
        n = abs( n - k );
        ans = min( ans, n ); 
    }
    cout << ans;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long 
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd long long
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
using namespace std;
ll pri[1000005];
ll a[1000005];
int main(){
	boost;
	ll gc=0;
	ll n;
	cin>>n;
	map<ll,ll> help;
	
	pri[1]=pri[0]=1;
	
	for(ll i=2;i<=1000000;i++){
		if(pri[i]==0){	
			for(ll j=i;j<=1000000;j+=i){
				if(pri[j]==0)pri[j]=i;
			}
		}
	}
	ll f=1;
	
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		ll j=a[i];
		map<ll,ll> tmp;
		while(j>1){
			tmp[pri[j]]++;
			if(tmp[pri[j]]==1){
				help[pri[j]]++;
				if(help[pri[j]]>1)f=0;
			}
          j/=pri[j];

			
		}
		
		
		
		gc=__gcd(gc,a[i]);
    }
    
    if(f)cout<<"pairwise coprime";
    else if(gc==1)cout<<"setwise coprime";
    else cout<<"not coprime";
    
	
	
}
  
  
  
   


    

Measured memory_bytes: 24168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vpll = vector<pll>;

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define RREP(i, n) for(ll i = n-1; i >= 0; i--)
#define FOR(i, a, b) for(ll i = a; i <= (ll)(b); i++)
#define RFOR(i, a, b) for(ll i = a; i >= (ll)(b); i--)

#define SIZE(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));

#define PB push_back
#define MP make_pair
#define F first
#define S second

#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ld A, B; ll H, M; cin >> A >> B >> H >> M;
    ld deg = abs(H * 30 - M * 5.5); deg = min(deg, 360 - deg);
    ld rad = deg * (PI / 180.0);
    ld distance = sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(rad));
    cout << fixed << setprecision(15) << distance << endl;
}

Measured memory_bytes: 4188
N = int(input())
S = [input()[0] for i in range(N)]
m = S.count("M")
a = S.count("A")
r = S.count("R")
c = S.count("C")
h = S.count("H")
print(m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h)

Measured memory_bytes: 9656
#include <stdio.h>

main(){
  int b[100][100];
  int n, k;
  int s[100];
  int i, j, p, sum;

  while(1){
    scanf("%d %d", &n, &k);
    if(n==0 && k==0) break;

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

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

    p=0;

    for(i=0;i<k;i++){
      sum=0;
      for(j=0;j<n;j++){
	sum+=b[j][i];
      }
      if(s[i]<sum) p=1;
    }
    if(p==1) printf("No\n");
    else printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 420
n,k = map(int,input().split())
oppo = list(input().split())
for i in range(len(oppo)):
    oppo[i] = int(oppo[i])

oppo = sorted(oppo)
attack = 0

if  k >= n:
    print(0)
else:
    for i in range(0,len(oppo)-k):
        attack = attack + oppo[i]
    print(attack)


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

int main()
{
    int n,m;
    cin >> n >> m;

    vector<vector <int> > A(n, vector<int>(m));
    vector<int> b(m);
    vector<int> c(n);
    for (int i = 0; i < n; i++)
    {
        c[i] = 0;
    }

    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 ++)
    {
        cin >> b[i];
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            c[i] += A[i][j] * b[j];
        }
        cout << c[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3192
S = input()
s = [i for i in S]
if s.count('R') == 3:
    print(3)
elif s.count('R') == 1:
    print(1)
elif s.count('R') == 0:
    print(0)
else:
    if S == 'RSR':
        print(1)
    else:
        print(2)

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

ll pow(ll a, ll b) {
    if (b == 0) return 1;
    if (b % 2) return a * pow(a, b - 1);
    return pow(a * a, b / 2);
}

//a^(-1)≡a^(p-2) (mod p) (but p is prime)
ll powMod(ll a, ll b, ll p) {
    if (b == 0) return 1;
    if (b % 2) return (a * powMod(a, b - 1, p)) % p;
    return powMod(a * a % p, b / 2, p);
}

ll dp[100001];

int main() {
    ll n, k;
    ll ans = 0;
    cin >> n >> k;
    for (ll i = k; i >= 1; --i) {
        ll cnt = powMod(k / i, n, MOD);
        for(ll j = 2 * i; j <= k; j += i) {
            (cnt = cnt - dp[j] + MOD) %= MOD;
        }
        dp[i] = cnt % MOD;
        (ans += (cnt * i) % MOD) %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4412
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    N = int(input())
    print(N*(N-1)//2-N//2)
    for i in range(1, N):
        for j in range(i+1, N+1):
            if j == N - N % 2 - (i - 1):
                continue
            print(i, j)

if __name__ == '__main__':
    main()


'''
4:
 1 [ , 2, 3,  ] = 9
 2 [1,  ,  , 4] = 8
 3 [1,  ,  , 4] = 7
 4 [ , 2, 3,  ] = 6
5:
 1 [ , 2, 3,  , 5] = 10
 2 [1,  ,  , 4, 5] = 10
 3 [1,  ,  , 4, 5] = 10
 4 [ , 2, 3,  , 5] = 10
 5 [1, 2, 3, 4, ] = 10
6:
 1 [   2, 3, 4, 5,  ] = 14
 2 [1,    3, 4,  , 6] = 14
 3 [1, 2,    4, 5, 6] = 18
 4 [1, 2, 3,    5, 6] = 17
 5 [1,  , 3, 4,    6] = 14
 6 [ , 2, 3, 4, 5,  ] = 14
'''

Measured memory_bytes: 9288
N = $stdin.gets.chomp.to_i
S = $stdin.gets.chomp

def t(s)
  $stderr.puts s
  balance = 0
  cnt = 0
  s.split("").each{ |a| 
    case a
    when '('; balance += 1
    when ')'; 
      balance -= 1
    end
    if balance < 0
      cnt += 1
      balance = 0
    end
    $stderr.puts "#{a},#{balance},#{cnt}"
  }
  cnt
end

open = t(S)
close = t(S.reverse.tr("()",")("))
puts "#{'('*open}#{S}#{')'*close}"


Measured memory_bytes: 1788
#include<iostream>
#include<string>

using namespace std;

int main(void){
	string l, r;
	cin >> l >> r;
	if(l.size() > r.size()){
		cout << "GREATER" << endl;
	}else if(l.size() < r.size()){
		cout << "LESS" << endl;
	}else{
		if(l == r){
			cout << "EQUAL" << endl;
		}else for(int i = 0; i < l.size(); i++){
			if(l[i] > r[i]){
				cout << "GREATER" << endl;
				break;
			}else if(l[i] < r[i]){
				cout << "LESS" << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long a, std::string s){
    if(a < 3200){
        cout << "red" << endl;
    }else{
        cout << s << endl;
    }
}

int main(){
    long long a;
    scanf("%lld",&a);
    std::string s;
    std::cin >> s;
    solve(a, s);
    return 0;
}


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

int  main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i]; // h[i]はi-1番目の高さ
    vector<int> dp(n,INF);  //dp[i]はi-1番目に着くまでにかかる最小コスト
    dp[0] = 0; 
    for(int i =1;i<n;i++){
        if(i==1){
          dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        }else{
          dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
        }
    }
    cout << dp[n-1] << endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
int main()
{
    int N, M, C;
    std::cin >> N >> M >> C;

    std::vector<int> B(M);
    for (int i = 0; i < M; i++) {
        std::cin >> B[i];
    }

    std::vector<std::vector<int>> A(N, std::vector<int>(M));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            std::cin >> A[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int a = 0;
        for (int j = 0; j < M; j++) {
            a += B[j] * A[i][j];
        }
        if (a > -C) ans++;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include "bits/stdc++.h"
 
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main() {
  char a, b;
  cin >> a >> b;
  
  if(a < b) printf("<\n");
  else if(a == b) printf("=\n");
  else printf(">\n");
 
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

N, W = map(int, input().split())
w, v = [], []
# dp = [[0] * (W+1) for _ in range(N+1)]
dp = [[0] * (W+1) for _ in range(N)]

for i in range(N):
    t1, t2 = map(int, input().split())
    w.append(t1)
    v.append(t2)

# Initialize dp[0]
for weight in range(W+1):
    if w[0] <= weight:
        dp[0][weight] = v[0]
    else:
        dp[0][weight] = 0

# print('dp[0]:', dp[0])

for idx in range(1, N):
    for weight in range(1, W+1):
        # Cannot select
        if weight - w[idx] < 0:
        # if weight - w[idx - 1] < 0:
            dp[idx][weight] = dp[idx - 1][weight]
            continue

        # Select
        v1 = dp[idx - 1][weight - w[idx]] + v[idx]
        # v1 = dp[idx - 1][weight - w[idx - 1]] + v[idx - 1]

        # Not Select
        v2 = dp[idx - 1][weight]

        dp[idx][weight] = max(v1, v2)

# for i in range(N):
#     print(dp[i])

# print(dp[N][W])
print(dp[N-1][W])

Measured memory_bytes: 151716
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N;
    cin>>N;
    string S; cin>>S;
    ll ctr=0;
    ll ctg=0;
    ll ctb=0;
    rep(i,N){
        if(S[i]=='R') ++ctr;
        if(S[i]=='G') ++ctg;
        if(S[i]=='B') ++ctb;
    }
    ll ans=ctr*ctg*ctb;
    rep(i,N){
        reps(j,i+1,N){
            ll k=j-i+j;
            if(k>=N) continue;
            if(S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]) --ans;
        }
    }
    cout<< ans <<"\n";



}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

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

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

	return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
int a[N];

int main()

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

    int n, a;

    cin >> n >> a;

    cout << n*n-a;

    return 0;
}


Measured memory_bytes: 256
int parentNode(int i);
int leftChild(int i);
int rightChild(int i);
void maxHeapify(int i);
void buildMaxHeap(void);
 
int A[500001];
int n;
 
main(){
 
    int i;
 
    scanf("%d", &n);
 
    for(i=1; i<=n; i++){
        scanf("%d", &A[i]);
    }
     
    buildMaxHeap();
     
    for(i=1; i<=n; i++){
        printf(" %d", A[i]);
    }
     
    printf("\n");
     
    return 0;
     
}
 
int parentNode(int i){
    return (int)i/2;
}
 
int leftChild(int i){
    return 2*i;
}
 
int rightChild(int i){
    return 2*i+1;
}
 
void maxHeapify(int i){
    int l = leftChild(i);
    int r = rightChild(i);
    int largest, tmp;
     
    if(l <= n && A[l] > A[i]){
        largest = l;    
    }else{
        largest = i;
    }
    if(r <= n && A[r] > A[largest]){
        largest = r;    
    }
    if(largest != i){
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        maxHeapify(largest);
    }
}
 
void buildMaxHeap(void){
    int i;
    for(i=(int)n/2; i>0; i--)
        maxHeapify(i);
}

Measured memory_bytes: 2552
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc072.contest.atcoder.jp/tasks/arc072_b>
問題文============================================================
 AliceとBrownはゲームをするのが好きです。今日は以下のゲームを思いつきました。
 
 2つの山があり、はじめにX,Y個の石が置かれています。
 AliceとBrownは毎ターン以下の操作を交互に行い、操作を行えなくなったプレイヤーは負けとなります。
 
 片方の山から 2i 個の石を取り、そのうち i 個の石を捨て、残りの i 個の石をもう片方の山に置く。
 ここで、整数 i(1≦i) の値は山に十分な個数の石がある範囲で自由に選ぶことができる。
 Aliceが先手で、二人とも最適にプレイすると仮定したとき、
 与えられた X,Y に対しどちらのプレイヤーが勝つか求めてください。
 

=================================================================

解説=============================================================

 解説を見た
 参考：
 https://atcoder.jp/img/arc072/editorial.pdf
 http://ronly.hatenablog.com/entry/2017/10/12/182048
 
 (x,y) = (0,0),(1,0),(0,1),(1,1) ならば必ず自分が負ける
 この状態から逆に遷移させて考える
 
 負け:L 勝ち:W
 
    0 1 2 3 4 5 6
  0 L L W W W W W
  1 L L L W W W W
  2 W L L L W W W
  3 W W L L L W W
  4 W W W L L L W
  5 W W W W L L L
  6 W W W W W L L
 
 => |x - y| <= 1 then Win Brown
    |x - y| >= 2 then Win Alice
================================================================
*/
void solve(){
    ll X,Y; cin >> X >> Y;
    if(abs(X-Y)<= 1){
        cout << "Brown" << endl;
    }else{
        cout << "Alice" << endl;
    }
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}


Measured memory_bytes: 256
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>?5*8},'ruby',$0);def f(i,c)(h=(H[i].map{|e|f e,i}.max||0)+1)>=K&&c!=1&&(h=0;$r+=1);h end;N,K,Q,*A=`dd`.split.map &:to_i;H=Hash.new{|h,k|h[k]=[]};2.upto(N){|i|H[A[i-$r=2]]<<i};f(1,1);p$r--~Q/Q

Measured memory_bytes: 231904
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

#define ll long long
#define MOD 1000000007

using namespace std;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> p(M);
  vector<string> S(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i] >> S[i];
  }

  ll AC = 0, WA = 0;
  vector<bool> check(N + 1, false);
  vector<ll> WAcount(N + 1, 0);
  for (int i = 0; i < M; i++) {
    if (check[p[i]] == false) {
      if (S[i] == "AC") {
        AC++;
        check[p[i]] = true;
      } else {
        WAcount[p[i]]++;
      }
    }
  }
  for (int i = 0; i <= N; i++) {
    if (check[i] == true) {
      WA += WAcount[i];
    }
  }
  cout << AC << " " << WA << endl;
}


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

typedef long long ll;
const int N = 100010;
const int inf = 0x3f3f3f3f;

int n, ans = inf;
int a[N], b[N];
int A, B;

int main() {
	scanf("%d%d%d", &A, &B, &n);
	int x = inf;
	for(int i = 1; i <= A; ++i) scanf("%d", &a[i]), x = min(a[i], x);
	int y = inf;
	for(int i = 1; i <= B; ++i) scanf("%d", &b[i]), y = min(b[i], y);
	ans = x + y;
	for(int i = 1; i <= n; ++i) {
		int c = 0;
		scanf("%d%d%d", &x, &y, &c);
		ans = min(ans, a[x] + b[y] - c);
	}
	printf("%d\n", ans);
} 

Measured memory_bytes: 1024
def caesar(s, n):
    ns = []
    for ch in s:
        # A - Z
        if ('A' <= ch and ch <= 'Z'):
            ns.append(chr((ord(ch) - ord('A') + n) % 26 + ord('A')))
        # a - z
        elif ('a' <= ch and ch <= 'z'):
            ns.append(chr((ord(ch) - ord('a') + n) % 26 + ord('a')))
        # 0 - 9
        elif ('0' <= ch and ch <= '9'):
            ns.append(chr((ord(ch) - ord('0') + n) % 10 + ord('0')))
        # no change for other characters
        else:
            ns.append(ch)
    return "".join(ns)
x = int(input())
y = str(input())
result = caesar(y, x)
print(result)

Measured memory_bytes: 3188
<?php
fscanf(STDIN, '%s', $input);
$input = str_split($input);
$patterns = array_values(array_count_values($input));
if (count($patterns) === 2 && $patterns[0] === 2 && $patterns[1] === 2) {
    echo "Yes\n";
} else {
    echo "No\n";
}

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

int main() {
    vector<int> result; // 結果を出力するための配列
    bool tf = true; // ループを抜けるためのフラグ
    while (tf) {
        int n,x;
        scanf("%d%d", &n,&x);
        if (n == 0 && x == 0) {
            tf = false;
            continue;
        }
        int count = 0; // カウンター
        for (int a = 1; a <= n-2; a++) {
            for (int b = a+1; b <= n-1; b++) {
                for (int c = b+1; c <= n; c++) {
                    if (a + b + c == x) {
                        count++;
                    }
                }
            }
        }
        result.push_back(count);
    } 
    for (int i = 0; i < result.size(); i++) {
        printf("%d\n", result.at(i));
    }
}


Measured memory_bytes: 3228
#include<iostream>
using namespace std;
int main(){
  int A, B, C, X;
  cin >> A >> B >> C >>X;
  int counter = 0;
  for(int i=0; i<=A; i++){
    for(int j=0; j<=B; j++){
      for(int k=0; k<=C; k++){
        if(500*i+100*j+50*k == X){
          counter++;
        }
      }
    }
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

const int MOD = 1e9 + 7;
int N;
vector<map<string, ll>> cnt;
string S[4] = {"A", "C", "G", "T"};

bool is_valid(string s) {
    REP(i, 4) {
        string t = s;
        if (i > 0) {
            swap(t[i - 1], t[i]);
        }
        if (t.find("AGC") != string::npos) {
            return false;
        }
    }
    return true;
}

ll dfs(int i, string s) {
    if (cnt[i].count(s) > 0) {
        return cnt[i][s];
    }
    if (i == N) {
        return 1;
    }
    ll res = 0;
    REP(j, 4) {
        string t = s + S[j];
        if (is_valid(t)) {
            res = (res + dfs(i + 1, t.substr(1))) % MOD;
        }
    }
    cnt[i][s] = res;
    return res;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    cnt = vector<map<string, ll>>(N + 1);
    cout << dfs(0, "TTT") << endl;
    return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <queue>
#define MAX 1000001
using namespace std;
typedef pair<int, int> PAIR;

int main(){
	int n, q, a, v, array[MAX];
	fill(array, array + 1000001, 0);
	
	priority_queue<PAIR> que;
	
	scanf("%d %d", &n, &q);
	for(int i = 0; i < q; i++){
		scanf("%d %d", &a, &v);
		array[a] += v;
		que.push(PAIR(array[a], -a));
		
		while(true){
			PAIR pai = que.top();
			if(pai.first <= array[-pai.second]) {
				printf("%d %d\n", -pai.second, pai.first);
				break;
			}
			que.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 5840