akhauriyash/Code-Regression huggingface dataset:
from sys import stdin

def main():
    N, Q = map(int, input().split())
    S = input()
    LR = [tuple(map(int, input().split())) for _ in [0] * Q]

    cnt = [0] * N
    prev = ''
    for i, s in enumerate(S):
        if prev + s == 'AC':
            cnt[i] = cnt[i-1] + 1
        else:
            cnt[i] = cnt[i-1]
        prev = s

    for l, r in LR:
        n = cnt[r-1] - cnt[l-1]
        print(n)

input = lambda: stdin.readline().rstrip()
main()


Measured memory_bytes: 19816
#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 100000000
#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;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m; cin>>n>>m;
    vector<int > a(m,0);
    REP(i,m) cin>>a[i];

    llong mod=1000000007;

    pair<llong, bool> dp[n+1];
    REP(i,n+1)
    {
        dp[i].first=0;
        dp[i].second=false;
    }
  
  	REP(j,m)
    {
    dp[a[j]].second=true;
    }
  
    dp[0].first=1; 
    if(dp[1].second==false) dp[1].first=1;
  
    for(int i=1; i<n; i++)
    {
        if(dp[i+1].second==false) dp[i+1].first=(dp[i].first+dp[i-1].first)%mod;
        else dp[i+1].first=0;
    }
    llong ans=dp[n].first%mod;

    cout<<ans<<endl;

    return  0;
}


Measured memory_bytes: 2176
#include<cstdio>
#define ll long long
using namespace std;
ll sum=0;
ll n;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		if(i%3==0||i%5==0)
		{
			continue;
		}
		sum+=i;
	}
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define print printf("==================\n")
#define ll long long
#define pi acos(-1.0)
#define eps 1e-16
#define max3(a,b,c) max(a,max(b,c))
const ll INF = 1 << 30;
#define mod 1000000007
typedef pair<double, double  > payar;
typedef struct
{
    ll  x, y;
} point;
priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending
vector< pair<double,payar  > > vpp;
vector < payar >  vp;
char ara[1006][1006];
ll dp[1006][1005];
int n, m ;
ll cal(int i, int j )
{
    if(i>n or j>m )
        return 0;
    if(i==n and j==m)
        return 1;
    if(ara[i][j]=='#')
        return 0 ;
    if(dp[i][j]!=-1)
        return dp[i][j]%mod;
    return dp[i][j]= (cal(i+1,j)%mod+cal(i,j+1)%mod)%mod;


}
int main()
{


    cin>>n>>m;
    memset(dp,-1,sizeof dp);
    for(int i = 1 ; i<=n ; i++)
    {
        for(int j = 1 ; j<=m ; j++)
        {
            cin>>ara[i][j];
        }
    }
    cout<<cal(1,1);

    return  0 ;
}


Measured memory_bytes: 9216
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long ll;
ll N, X;

int main() {
	scanf("%lld%lld", &N, &X);
	printf("%lld\n", 3ll * (N - __gcd(N, X)));
	return 0;
}

Measured memory_bytes: 128
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "c.cpp"

int main() {
  ll n;
  cin >> n;

  vl ans(n);
  
  rep3(i, 1, n+1) {
    rep3(j, i, n+1) {
      rep3(k, j, n+1) {
        ll sum = i*i+j*j+k*k+i*j+j*k+k*i;
        if (sum > n) break;
        if (i == k) {
          ans[sum-1]++;
        } else if (i == j or j == k) {
          ans[sum-1] += 3;
        } else {
          ans[sum-1] += 6;
        }
      }
    }
  }

  for (auto&& i : ans) {
    cout << i << el;
  }
}


Measured memory_bytes: 3604
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        pw.println(Math.max(c,Math.max(a,b))*9+a+b+c);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25456
function main(input) {
  var N = Number(input.split("\n")[0]);
  var Narr = input.split("\n")[1];
  var arr = Narr.split(" ");

  var max = 0;
  var ans = 0;
  for(var i=0; i<N; i++){
    if(arr[i] >= max){
      max = Number(arr[i]);
      ans++;
    }
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <iostream>

int main() {
	int n, b, f, r, vc, v[4][3][10];
	for (b = 0; b < 4; ++b) {
		for (f = 0; f < 3; ++f) {
			for (r = 0; r < 10; ++r) {
				v[b][f][r] = 0;
			}
		}
	}
	std::cin >> n;
	for (int i = 1; i <= n; ++i) {
		std::cin >> b >> f >> r;
		std::cin >> vc;
		v[b - 1][f - 1][r - 1] += vc;
	}
	for (b = 0; b < 4; ++b) {
		if (0 < b && b < 4) { std::cout << "####################" << std::endl; }
		for (f = 0; f < 3; ++f) {
			for (r = 0; r < 10; ++r) {
				std::cout << " " << v[b][f][r];
			}
			std::cout << std::endl;
		}
	}
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); } } initCpp;

signed main() {
  i32 x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<i64> A(x), B(y), C(z);
  cin >> A >> B >> C;
  sort(ALL(A), greater<i64>());
  sort(ALL(B), greater<i64>());
  sort(ALL(C), greater<i64>());
  auto solve = [&](i32 P) {
    i32 cnt = 0;
    REP(u, x) {
      REP(v, y) {
        REP(w, z) {
          if (A[u] + B[v] + C[w] < P) break;
          cnt++;
          if (cnt >= k) return true;
        }
      }
    }
    return false;
  };
  i64 l = 0;
  i64 r = A[0] + B[0] + C[0];
  while (l < r) {
    i64 m = (l + r + 1) / 2;
    if (solve(m)) {
      l = m;
    } else {
      r = m - 1;
    }
  }
  vector<i64> ans;
  REP(u, x) {
    REP(v, y) {
      REP(w, z) {
        i64 p = A[u] + B[v] + C[w];
        if (p < l) break;
        if (p >= l) ans.push_back(p);
      }
    }
  }
  sort(ALL(ans), greater<i64>());
  REP(i, k) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 133216
a,b,c=map(int,input().split())
k=int(input())
lis=[]
for i in range(0,k+1):
  for j in range(0,k-i+1):
      atai=a*(2**i)+b*(2**j)+c*(2**(k-i-j))
      if not atai in lis:
        lis.append(atai)
lis.sort()
print(lis[-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
const int INF =100100100;
const int MOD = (int)1e9+7;
const double EPS = 1e-9;
typedef long long ll;
typedef long li;
#define pb push_back 
#define mp make_pair

signed main (){	
	ll NN,xx;
	cin >> NN >>xx;
	ll temp;
	vector <ll> a;
	rep(i,NN){
		cin >>temp;
		a.pb(temp);
	}
	sort(a.begin(),a.end());
	ll ans = 0;
	ll sum = 0;
	rep(i,NN){
		sum += a[i];
		if(xx >= sum) ans ++;
		else break;
	}
	if(ans == NN && sum != xx) ans --;

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


Measured memory_bytes: 256
isPrime = [True] * 1000000
prime = [0, 0]
def calcPrime():
    isPrime[0] = isPrime[1] = False
    count = 0
    for i in range(2, len(isPrime)):
        if(isPrime[i]):
            count += 1
            prime.append(count)
            for j in range(2 * i, len(isPrime), i):
                isPrime[j] = False
        else:
            prime.append(count)

calcPrime()
while(True):
    try:
        n = input()
        print(prime[n])
    except Exception:
        break

Measured memory_bytes: 69008
import sys

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    a_sorted = sorted(a)
    distance = sys.maxsize
    r = -1
    for i in a:
        if abs(i - a_sorted[n-1]/2) <= distance:
            distance = abs(i - a_sorted[n-1]/2)
            r = i
    print(str(a_sorted[n-1]) + ' ' + str(r))



Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using ll = long long;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  REP(i, n) { cin >> a[i]; }
  FOR(i, k, n) {
    if (a[i] > a[i - k]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4004
A = input()
B = input()
C = input()

from collections import deque

dic = {'a':deque(A),'b':deque(B),'c':deque(C)}

d = dic['a']
turn = 'a'
while len(d)>0:
    card = d.popleft()
    turn = card
    d = dic[turn]
print(turn.upper())

Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long;

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;

int H, W, S, U[35][35];
int sum[35][35][35][35];
pair<int, int> dp[35][35][35][35];
//dp[y1][x1][y2][x2]: [(y1,x1),(y2,x2)]??? ????????¢??? <?????§??°???????????°, ?????????>
//dp[0][0][H-1][W-1]??????????????????

pair<int, int> dfs(int y1, int x1, int y2, int x2){
  if(dp[y1][x1][y2][x2].F != -INF){
     return dp[y1][x1][y2][x2];
  }

  //first: ?????????????????¨????????????????????°??????????????¨??????????????°??????????????????????????¨??????????????????1?????\??????
  //second: ????????????????????°??????????????£?????´??????????????????????????\????????????
  pair<int, int> ret = make_pair(1, S-(sum[0][0][H-1][W-1]-sum[y1][x1][y2][x2]));

  //?????´??????
  for(int cutx=x1; cutx<x2; cutx++){
    int suml = sum[y1][x1][y2][cutx];
    int sumr = sum[y1][cutx+1][y2][x2];
    if(sum[0][0][H-1][W-1]-suml > S || sum[0][0][H-1][W-1]-sumr > S) continue;
    pair<int, int>  l = dfs(y1,x1,y2,cutx);
    pair<int, int>  r = dfs(y1,cutx+1,y2,x2);
    pair<int, int> tmp = make_pair(l.F+r.F, min(l.S,r.S));  //???????????????????????§?¨?????????????
    ret = max(ret, tmp);  //F->S????????§????????????????????§????????§OK
  }

  //?°´?????????
  for(int cuty=y1; cuty<y2; cuty++){
    int suml = sum[y1][x1][cuty][x2];
    int sumr = sum[cuty+1][x1][y2][x2];
    if(sum[0][0][H-1][W-1]-suml > S || sum[0][0][H-1][W-1]-sumr > S) continue;
    pair<int, int>  l = dfs(y1,x1,cuty,x2);
    pair<int, int>  r = dfs(cuty+1,x1,y2,x2);
    pair<int, int> tmp = make_pair(l.F+r.F, min(l.S,r.S));  //???????????????????????§?¨?????????????
    ret = max(ret, tmp);  //F->S????????§????????????????????§????????§OK
  }

  //???????????§??\???????????§?????????????????????????????????????????????????±???????????????§???
  //????????§dp?????\??????????????????????????????????????????????????????????????????????????????????????¢?´¢?????????dp?????????????????§?????????
  return dp[y1][x1][y2][x2] = ret;
}


int main() {
  while(1){
    cin>>H>>W>>S;
    if(H==0&&W==0&&S==0) break;
    REP(i,0,H){
      REP(j,0,W){
        cin>>U[i][j];
      }
    }
    //????????????????¨?????????????????????????
    REP(i,0,H){
      REP(j,0,W){
        REP(ranH,0,H-i)REP(ranW,0,W-j){
          int tmp = 0;
          REP(k,i,i+ranH+1){
            REP(l,j,j+ranW+1){
              tmp += U[k][l];
            }
          }
          sum[i][j][i+ranH][j+ranW] = tmp;
        }
      }
    }
    //?????????
    REP(i,0,H){
      REP(j,0,W){
        REP(k,0,H){
          REP(l,0,W){
            dp[i][j][k][l] = make_pair(-INF,-INF);
          }
        }
      }
    }

    pair<int, int> ans = dfs(0,0,H-1,W-1);
    cout<<ans.F<<" "<<ans.S<<endl;
  }

  return 0;
}

Measured memory_bytes: 19652
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int x,y;
	int a,b,c;
	cin>>x>>y>>a>>b>>c;
	
	vector<llong> p(a),q(b),r(c);
	REP(i,a) cin>>p[i];
	REP(i,b) cin>>q[i];
	REP(i,c) cin>>r[i];
	sort(ALL(p),greater<llong>());
	sort(ALL(q),greater<llong>());
	sort(ALL(r),greater<llong>());
	
	priority_queue<llong,vector<llong>,greater<llong>> eat;
	REP(i,x) eat.push(p[i]);
	REP(i,y) eat.push(q[i]);
	REP(i,c){
		if(r[i]<=eat.top()) break;
		eat.pop();
		eat.push(r[i]);
	}
	
	llong ans=0;
	while(!eat.empty()){
		ans+=eat.top();
		eat.pop();
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 4724
#include <iostream>
#include <math.h>
using namespace std;

int main(void) {

  int N, D = 0;
  int X[10][10] = {0};
  
  cin >> N >> D;
  int i, j = 0;
  for(j=0; j < N; j++) {
	for(i=0; i < D; i++) {
    	cin >> X[j][i];
    }
  } 
  int cnt = 0;
  int k = 0;
  for(k = 0; k < N - 1; k++) {
     for(j = k + 1; j < N; j++) {
       int sum = 0;
       for(i = 0; i < D; i++) {
           sum += ((X[k][i] - X[j][i]) * (X[k][i] - X[j][i]));
       }
       double sq = sqrt(sum);
       int sq_ = int(sq);
       if((sq_ * sq_) == sum) {
         cnt++;
       } 
     }
  }
  cout << cnt << endl;
  return 0; 
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    ll ans = 0;
    ll s = 0;
    for (int i = 0; i < n; ++i) {
        s += a[i];
    }
    for (int i = 0; i < n; ++i) {
        if (a[i] > b[i]) {
            ans = max(ans, s - b[i]);
        }
    }
    cout << ans;
    return 0;
}

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

#define For(i,a,b) for(int i = a;i <= b; i++)
#define reset(f, x) memset(f, x, sizeof(f))

const int N = 2000+10,inf = 1e9;
int a[2*N],c[2*N],n,res,pos[2][N],f[N][N],t[2][2*N];

int update(int k, int i) {
    for(i; i <= 2*n; i += i & (-i)) t[k][i]++;
}

int get(int k, int i) {
    int res = 0;
    for(i; i; i -= i & (-i)) res += t[k][i];
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    For(i, 1, 2*n) {
        char ch;
        cin >> ch >> a[i];
        c[i] = (ch == 'B');
        pos[c[i]][a[i]] = i;
    }
    For(i, 0, n) For(j, 0, n) f[i][j] = inf;
    f[0][0] = 0;
    For(u, 0, n) {
        reset(t[1], 0);
        For(v, 0, n) {
            int i = u+v+1;
            if (u < n) {
                int p = pos[0][u+1];
                p += get(0, 2*n) - get(0, pos[0][u+1]);
                p += get(1, 2*n) - get(1, pos[0][u+1]);
                f[u+1][v] = min(f[u+1][v], f[u][v] + p - i);
            }
            if (v < n) {
                int p = pos[1][v+1];
                p += get(0, 2*n) - get(0, pos[1][v+1]);
                p += get(1, 2*n) - get(1, pos[1][v+1]);
                f[u][v+1] = min(f[u][v+1], f[u][v] + p - i);
            }
            if (v < n) update(1, pos[1][v+1]);
        }
        if (u < n) update(0, pos[0][u+1]);
    }
    cout << f[n][n];
	return 0;
}

Measured memory_bytes: 16000
var
	A,B,C,K:Longint;
begin
	read(A,B,C,K);
	while A>=B do begin
		dec(K);
		B:=B*2;
	end;
	while B>=C do begin
		dec(K);
		C:=C*2;
	end;
	if K<0 then writeln('No')else writeln('Yes');
end.

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

int main(){
  string S;
  cin>>S;
  int ss=S.size();
  string D="dream",Dr="dreamer",E="erase",Er="eraser",X="";
  int it=-1;
  bool ans=true;
  for(int i=ss-1;i>=0;i--){
    if(X!=""){
      if(X[it]==S[i]){
        if(it) it--;
        else{
          X="";ans=true;
        }
      }
      else{
        ans=false;
        break;
      }
      continue;
    }
    ans=false;
    if(S[i]=='m'){
      X=D;
      it=3;
    }
    if(S[i]=='e'){
      X=E;
      it=3;
    }
    if(S[i]=='r'){
      if(i<5) break;
      if(S[i-2]=='m'){
        X=Dr;
        it=5;
      }
      if(S[i-2]=='s'){
        X=Er;
        it=4;
      }
    }
  }
  if(ans)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

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

int func(int A, int B, int C) {
    if (A%2 == 1 || B%2 == 1 || C%2 == 1) {
        return 0;
    }
    if (A == B && A == C) {
        return -1;
    }
    
    return func((B+C)/2, (C+A)/2, (A+B)/2) + 1;
}

int main() {
    // input
    int A, B, C;
    cin >> A >> B >> C;
    
    int ans = func(A, B, C);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3604
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)]

from collections import defaultdict, deque
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
# sys.setrecursionlimit(1000000)
# list(map(int, input().split()))
mod = 10 ** 9 + 7

N = getN()
A = getList()
alta = []
cntminus = 0
for i in A:
    if i < 0:
        cntminus += 1
    alta.append(abs(i))
if cntminus % 2 == 0:
    print(sum(alta))
else:
    print(sum(alta) - 2 * min(alta))


Measured memory_bytes: 69976
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ret = 0;
  for (int i = 0; i + 3 <= n; ++i) {
    if (s.substr(i, 3) == "ABC") ++ret;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
//hms.cpp
#include <iostream>
using namespace std;
int main (){
  int x, h, m, s;
  cin >> x;
  h = x / 3600;
  m = (x % 3600) / 60;
  s = ((x % 3600) % 60);
  cout << h << ":" << m << ":" << s << endl;
}




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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine().Split()
                .Select(int.Parse)
                .ToArray();

            for (int i = 0; i < 5; i++)
            {
                if(x[i] == 0)
                {
                    Console.WriteLine(i+1);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 27920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod=1e9+7;

int main(){
  int n;cin>>n;
  double p[n];rep(i,n)cin>>p[i];
  double dp[n][n+1];
  rep(i,n) rep(j,n+1) dp[i][j]=(double)0;
  dp[0][0]=(double)1-p[0];
  dp[0][1]=p[0];

  rep(i,n-1){
    rep(j,n){
      dp[i+1][j]+=dp[i][j]*((double)1-p[i+1]);
      dp[i+1][j+1]+=dp[i][j]*p[i+1];
    }
  }
  double sum=0;
  rep(i,n/2+1,n+1)sum+=dp[n-1][i];
  cout<<setprecision(14)<<sum<<endl;
}

Measured memory_bytes: 70528
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define mod        1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        2e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}


int p[100001],q[100001],r[100001];
void solve()
{
 
int x,y,a,b,c;
cin >> x >> y >> a >> b >> c;

forf(i,0,a) cin >> p[i];
forf(i,0,b) cin >> q[i];
forf(i,0,c) cin >> r[i];

sort(p,p+a,greater<int>());
sort(q,q+b,greater<int>());
sort(r,r+c,greater<int>());

int i=x-1,j=y-1,k=0;

int sw=0;


for(int l=0;l<x+y;l++)
{
    if(i<0)
    {
        if(k<c && q[j] < r[k])
        {
            swap(q[j],r[k]);
            k++;
           
        }
        j--;
    }
    else if(j<0)
    {
        if(k<c && p[i] < r[k])
        {
            swap(p[i] , r[k]);
            k++;
        }
        i--;
    }
    else
    {
        if(p[i] < q[j])
        {
            if(k<c && p[i] < r[k])
        {
            swap(p[i] , r[k]);
            k++;
        }
        i--;
          
        }else
        {
        if(k<c && q[j] < r[k])
        {
            swap(q[j],r[k]);
            k++;
           
        }
        j--;

        }
    }
}


forf(i,0,x) sw+=p[i];
forf(i,0,y) sw+=q[i];


cout<<sw<<endl;

}

int32_t main()
{
  //pr_init();
  //fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

 }


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

int main(){
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for(int j = 0; j < M; ++j) cin >> B[j];
  int ans = 0;
  for(int i = 0; i < N; ++i){
    int t = C;
    for(int j = 0; j < M; ++j){
      int a;
      cin >> a;
      t += a*B[j];
    }
    if(t > 0) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if (l[i] != l[j])  and (l[i] != l[k]) and (l[j] != l[k]):
      	if (l[i] < (l[j] + l[k])) and (l[j] < (l[i] + l[k])) and (l[k] < (l[i] + l[j])):
        	ans += 1
print(ans)
  

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

int main() {
  int x, y;
  
  cin >> x >> y;
  int total = 0;
  std::string isok = "No";
  for (int i=0; i<x; i++){
  	total = 2 * (x- i) + 4 * (i);
    if(total == y){
      isok = "Yes";
      break;
    }
  }
  for (int i=0; i<x; i++){
  	total = 2 * (i) + 4 * (x - i);
    if(total == y){
      isok = "Yes";
      break;
    }
  }
  std::cout << isok << std::endl;
}
  
  


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

class Insert{
private:
	int *p;
	int size;
public:
	Insert();
	Insert(const Insert&);
	void input();
	void narabekae();
	Insert& operator=(const Insert&);
	~Insert();
	int get_size()const{ return size; }
};

Insert::Insert(){
	int comp;
	cin>>comp;
	size = comp;
	p = new int[comp];
}

Insert::~Insert(){
	delete [] p;
}

Insert::Insert(const Insert& x){
	p = new int[x.get_size()];
}

Insert&::Insert::operator=(const Insert& x){
	if(this==&x) return *this;
	delete p;
	p = new int[x.get_size()];
	return *this;
}

void Insert::input(){
	for(int i=0;i<size;i++)
		cin>>p[i];
}

void Insert::narabekae(){
	for(int i=0;i<size;i++){
		if(i!=size-1){
			cout<<p[i]<<" ";
		}else{
			cout<<p[i]<<endl;
		}
	}
	for(int i=1;i<size;i++){
		int v = p[i];
		int j= i-1;
		while(j>=0&&v<p[j]){
			p[j+1] = p[j];
			j--;
		}
		p[j+1] = v;
		for(int k=0;k<size;k++){
			if(k!=size-1){
				cout<<p[k]<<" ";
			}else{
				cout<<p[k]<<endl;
			}
		}
	}
}


int main(){
	
	Insert test;
	test.input();
	test.narabekae();

	cin.get();
	cin.get();
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
    
#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
    
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
    
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
    
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

bool check(LL n, LL k) {
    while(n % k == 0) n /= k;
    return (n % k) == 1;
}

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

    if(N == 2) {
        cout << 1 << endl;
        return 0;
    }

    LL ans = 2;
    for(LL i=2; i*i<=(N-1); i++) {
        if((N-1) % i == 0) {
            ans += (i*i == (N-1) ? 1 : 2);
        }
    }

    for(LL i=2; i*i<=N; i++) {
        if(N % i == 0) {
            ans += check(N, i);
            if(i*i != N) {
                ans += check(N, N/i);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3592
#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=5e15;

ll n,m,R;
vec r(10);
mat d(210,vec(210,inf));


int main() {
  cin >> n >> m >> R;
  for(ll i=0;i<R;i++) {
    cin >> r[i];
    r[i]--;
  }
  for(ll i=0;i<n;i++) d[i][i]=0;
  for(ll i=0;i<m;i++) {
    ll a,b,c;
    cin >> a >> b >> c;
    a--,b--;
    d[a][b]=d[b][a]=c;
  }
  for(ll k=0;k<n;k++) {
    for(ll i=0;i<n;i++) {
      for(ll j=0;j<n;j++) {
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  vec p(R);
  for(ll i=0;i<R;i++) {
    p[i]=i;
  }
  ll ans=inf;
  while(1) {
    ll tmp=0;
    for(ll i=0;i<R-1;i++) {
      tmp+=d[r[p[i]]][r[p[i+1]]];
    }
    ans=min(ans,tmp);
    if(!next_permutation(p.begin(),p.end())) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
h_1, m_1, h_2, m_2, k = map(int, input().split())
time_m = h_2*60 + m_2 - (h_1*60 + m_1) - k
if time_m >= 0:
    print(time_m)
else:
    time_m = 24*60 - (h_2*60 + m_2) + h_1*60 + m_1 - k
    print(time_m)

Measured memory_bytes: 9172
# N
# A1 A2 ... An

_n = gets.chomp
as = gets.chomp.split(" ").map(&:to_i)

result = as.map do |i|
  r = 0
  i.to_s(2).chars.reverse_each do |c|
    break if c == "1"
    r += 1
  end
  r
end

puts result.min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef pair < int , int > Pi;
const long long LLINF = 1LL << 62;
int main()
{
    int N, K;
    Pi data[55];
    int yi[55];
    long long minv = LLINF;

    cin >> N >> K;
    for(int i = 0; i < N; i++) {
        cin >> data[i].first >> data[i].second;
        yi[i] = data[i].second;
    }

    sort(data, data + N);
    sort(yi, yi + N);

    //yindex
    for(int i = 0; i < N; i++) {
        for(int j = i; j < N; j++) {
            //xindex
            for(int k = 0; k < N; k++) {
                int cnt = 0;
                int l = k;
                while(l < N) {
                    int val = data[l].first;
                    while(l < N && val == data[l].first) {
                        if(yi[i] <= data[l].second && data[l].second <= yi[j]) cnt++;
                        l++;
                    }
                    if(cnt >= K) {
                        minv = min(minv, (long long)(yi[j] - yi[i]) * (data[l - 1].first - data[k].first));
                        break;
                    }
                }
            }
        }
    }

    cout << minv << endl;
    return (0);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

bool memo[2<<14][35];
bool visited[2<<14][35];
vector<int> m;

bool dfs(int s, int t){
  if(visited[s][t]) return memo[s][t];
  visited[s][t]=true;
  if(s==0) return memo[s][t]=true;
  if(s==1) return memo[s][t]=false;
  int nt = (t+1)%m.size();
  repl(i,1,m[t]+1){
    if(dfs(s-i,nt)==false) return memo[s][t]=true;
  }
  return memo[s][t]=false;
}

int main(){
  int n;
  while(cin>>n, n){
    int s;
    cin>>s;
    m.resize(2*n);
    rep(i,2*n) cin>>m[i];

    fill(visited[0], visited[2<<14], false);
    if(dfs(s,0)) cout<<1<<endl;
    else cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int n;
long long ans, sum, x;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x;
        ans = (ans + sum * x) % MOD;
        sum = (sum + x) % MOD;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3636
N,A,B=map(x->parse(Int,x),split(readline()))
K=T=0
for c=chomp(readline())
  flag=0
  if c=='a'
    if K<A+B
      flag=1
    end
  elseif c=='b'
    if K<A+B&&T<B
      T+=1
      flag=1
    end
  end
  K+=flag
  println(flag==1 ? "Yes" : "No")
end

Measured memory_bytes: 120236
#include <bits/stdc++.h>
using namespace std;
struct node{
  long long num;
  long long id;
};
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long a;
  cin >> a;
  node MAX;
  MAX.num = 0;
  MAX.id = 0;
  node k[a];
  long long ans = 0;
  long long maxv = 0;
  for(int i = 0;i < a;i++){
    cin >> k[i].num;
    if(k[i].num > maxv){
      maxv = k[i].num;
    }
    else if(k[i].num < maxv){
      ans += maxv - k[i].num;
      k[i].num = maxv;
    }
  }
  cout << ans;
  return 0;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N; cin >> N;
    string s; cin >> s;
    int alp[26] = {};
    rep(i, N) alp[s[i] - 'a']++;
    ll ans = 1;
    rep(i, 26) ans = (ans * (alp[i]+1)) % mod;
    cout << ans-1 << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int a[10],i,j,n;
	for(i=0;i<10;i++){
		cin>>a[i];
	}
	for(i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){
				n=a[i];
				a[i]=a[j];
				a[j]=n;
			}
		}
	}
	cout<<a[0]<<endl<<a[1]<<endl<<a[2]<<endl;
return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
using namespace std;

int main()
{
    int n, l;
    int i;
    
    cin >> n >> l;
    
    vector<string> s(n, "");
    
    for(i = 0; i < n; i++) {
        cin >> s[i];
    }
    
    sort(s.begin(), s.end());
    
    for(i = 0; i < n; i++) {
        cout << s[i];
    }
    
    cout << endl;
    
    return 0;
}

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

typedef long long ll;

int main()
{
	int n, m;
	std::cin >> n >> m;
	std::map<ll, int> mp;
	std::vector<ll> a(n);
	std::cin >> a[0];
	a[0] %= m;
	mp[a[0]]++;
	for (int i = 1; i < n; ++i)
	{
		std::cin >> a[i];
		a[i] = (a[i] + a[i - 1]) % m;
		mp[a[i]]++;
	}
	ll count = mp[0];
	for (int i = 0; i < n; ++i)
	{
		if (mp[a[i]] > 0)
		{
			mp[a[i]]--;
		}
		count += mp[a[i]];
	}
	std::cout << count << '\n';
	return 0;
}

Measured memory_bytes: 7920
#include<iostream>
#include<cmath>

using namespace std;
int main(void){
    int a,b,c,d,e,f,g;
    cin>>a>>b>>c;
    d=abs(a-b);
    e=abs(a-c);
    f=abs(b-c);
    g=min(d+e,min(e+f,f+d));
    cout<<g<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
#include <algorithm>
#include<set>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
int main(void){
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i,n){
    cin >> b[i];
    b[i]--;
  }
  rep(i,n){
    if(b[i]>i){
      cout<<-1<<endl;
      return 0;
    }
  }
  vector<int> result(n);
  rep(i,n){
    rep(j,n-i){
      /*rep(k,b.size()){
        cout<<b[k]<<" ";
      }
      cout<<"test"<<endl;
      cout <<b[n-1-i-j]<<" "<< n-1-i-j << endl;*/
      if(b[n-1-i-j]==n-1-i-j){
        b.erase(b.begin()+n-i-j-1);
        result[n-1-i]=n-i-j-1;
        //cout<<"erase"<<endl;
        break;
      }else{
        continue;
      }
      cout<<-1<<endl;
      return 0;
    }
  }
  rep(i,n){
    cout<<result[i]+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//using namespace std;
int main(void){
    int N;
    int ans = 0;
    std::cin >> N;
    std::vector<int> vec(N, 0);
    for(int i = 0;i < N;i++){
        //L_iを代入
        std::cin >> vec[i];
    }
    //i<j<kとなるようにforループを回す
    for(int i = 0;i < N;i++){
        for(int j = i + 1; j < N;j++){
            for(int k = j + 1;k < N;k++){
                int a = vec[i];
                int b = vec[j];
                int c = vec[k];
                //三角形の成立条件を満たし、かつどの二辺も同じ長さでない
                if(a + b > c && a + c > b && b + c > a && a != b && b != c && a != c){
                    ans++;
                }
                //std::cout << i << j << k << std::endl;//デバッグ
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3612
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(a * b % 2 == 0) {
        System.out.println("No");
        return;
      }
      System.out.println("Yes");
  }
}

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

const int N = 5000;

int n, len;
int g[N], f[N][N], pre[N][N];
int vis[N];

void init() {
  g[0] = 0;
  for (int i = 1;; i++) {
    g[i] = g[i - 1] + i;
    if (g[i - 1] + i > (int)1e7) {
      len = i;
      break;
    }
  }
}

int main() {
  init();
  cin >> n;
  int v = lower_bound(g + 1, g + 1 + len, n) - g;
  int val = g[v] - n;
  f[0][0] = 1;
  for (int i = 1; i <= v; i++) {
    for (int j = 0; j <= val; j++) {
      if (j - i >= 0 && f[i - 1][j - i] == 1) f[i][j] = 1, pre[i][j] = j - i;
      if (f[i - 1][j] == 1) f[i][j] = 1, pre[i][j] = j;
    }
  }
  int pt = v;
  while (pt >= 1) {
    int key = pre[pt][val];
    vis[val - key] = 1;
    pt--, val = key;
  }
  for (int i = 1; i <= v; i++) {
    if (vis[i]) continue;
    printf("%d\n", i);
  }
  return 0;
}




Measured memory_bytes: 177664
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	can := false
	var total int

	if n < 3 {
		fmt.Println("No")
		return
	}

L:
	for i := 0; i <= 100/7; i++ {
		for j := 0; j <= 100/4; j++ {
			total = i*4 + j*7

			if total == n {
				// fmt.Printf("%d = %d*4 + %d*7\n", total, i, j)
				can = true
				break L
			}
		}
	}

	if can {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
S = list(input().strip())
flag = False

if S[0] == "A" and "C" in S[2:-1]:
    count = 0
    for s in S:
        if s < "a":
            count += 1
    if count == 2:
        flag = True
if flag:
    print("AC")
else:
    print("WA")

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

int main(){
  int ans=1, N,a,b;
  string s="";
  cin>>N>>a;
  for(int i=1;i<N;i++){
    cin>>b;
    if(a<b)s.push_back('<');
    if(a>b)s.push_back('>');
    a=b;
  }
  int cnt=0;
  for(int i=0;i<(int)s.size();i++){
    if(i>0&&s[i-1]==s[i]){
      cnt++;
    }else{
      cnt=1;
    }
    ans=max(ans,cnt+1);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3340
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
priority_queue<ll, vector<ll>, greater<ll> > q;
int n, m, x, y, k;
pair<ll, ll> p[100005];
bool comp(pair<ll, ll> a, pair<ll, ll> b) {
	return a.second>b.second;
}
int main() {
	cin>>n>>m;
	for(int i=1; i<=n; i++) {
		scanf("%d", &k);
		q.push(k);
	}
	for(int i=1; i<=m; i++) {
		scanf("%lld%lld", &p[i].first, &p[i].second);
	}
	sort(p+1, p+m+1, comp);
	for(int i=1; i<=m; i++) {
		x=p[i].first, y=p[i].second;
		while(q.size()&&q.top()<y&&x) {
			q.pop();
			q.push(y);
			x--;
		}
	}
	ll ans=0;
	while(q.size()) {
		ans+=q.top();
		q.pop();
	}
	cout<<ans;
}

Measured memory_bytes: 2676
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  vector<int> C(101);
  for (int i = 0; i < 3; i++) {
    int c;
    cin >> c;
    C[c]++;
  }
  int ans = 0;
  for (int i = 0; i < 101; i++) {
    if (C[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
using namespace std;
typedef pair<int,int>P;
int n,m,s,t,low[N],used[N],depth[N];
vector<int> G[N];
set<P>ans;
void dfs(int x,int d,int prev){
  depth[x]=d;
  for(int i=0;i<G[x].size();i++){
    int nx=G[x][i];
    if(nx==prev)continue;
    if(!used[nx]){
      used[nx]=true;
      dfs(nx,d+1,x);
      if(!low[nx])
      ans.insert(P(min(x,nx),max(x,nx)));
      low[x]+=low[nx];
    }
    else if(d>depth[nx])low[nx]--,low[x]++;
  }
}
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>s>>t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  used[0]=1;
  dfs(0,0,0);
  set<P>::iterator it=ans.begin();
  while(it!=ans.end()){
    cout<<(*it).first<<' '<<(*it).second<<endl;
    it++;
  }
  return 0;
}


Measured memory_bytes: 7152
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 200005
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, a[maxN], b[maxN];

int count(int b[], int l, int r) {
    return upper_bound(b+1, b+n+1, r)-upper_bound(b+1, b+n+1, l-1);
}

int main () {
    scanf("%d", &n);
    fto(i, 1, n) scanf("%d", &a[i]);
    fto(i, 1, n) scanf("%d", &b[i]);

    int ans = 0;
    fdto(bit, 29, 0) {
        fto(i, 1, n) {
            a[i] &= (1<<(bit+1))-1;
            b[i] &= (1<<(bit+1))-1;
        }
//        if (bit == 2) {
//            fto(i, 1, n) printf("%d ", a[i]);
//            puts("");
//            fto(i, 1, n) printf("%d ", b[i]);
//            puts("");
//
//        }
        sort(b+1, b+n+1);

        int lo = (1<<bit), hi = (1<<(bit+1))-1;
        ll cnt = 0;
        fto(i, 1, n) {
            cnt += count(b, lo-a[i], hi-a[i]);
            cnt += count(b, lo+(1<<(bit+1))-a[i], hi+(1<<(bit+1))-a[i]);
        }
        if (cnt&1) ans |= (1<<bit);
    }

    printf("%d", ans);

    return 0;
}


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

typedef long long ll;


int main(){
  stack<int> S;
  int a, b, x;
  string s;
  while(cin >> s){
    if(s[0] == '+'){
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a + b);
    }
    else if(s[0] =='-'){
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(b - a);
    }
    else if(s[0] =='*'){
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a * b);
    }
    else{
      S.push(atoi(s.c_str()));
    }
  }
  cout << S.top() << endl;
}



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

#define rep(i,a) for(int i=0;i<(a);i++)
using namespace std;

int n,k,result;
set<int> s;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  rep(i,n) {
    cin >> k;
    if(s.find(k) == s.end()) {
      s.insert(k);
      result++;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 256