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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int D;
vll C, T;
vvll S;
ll score[366] = {};
vvll last = makeVector(366, 26, 0ll);

void calcScore(vll &T, ll pos) {
	for (int i = pos; i <= D; i++) {
		score[i] = score[i-1] + S[i][T[i]];

		for (int j = 0; j < 26; j++) last[i][j] = last[i-1][j];
		last[i][T[i]] = i;
		
		for (int j = 0; j < 26; j++) {
			score[i] -= (i-last[i][j])*C[j];
		}
	}
}

void Main() {
	cin >> D;
	C = makeVector(26, 0ll); cin >> C;
	S = makeVector(D+1, 26, 0ll);
	for (int i = 1; i <= D; i++) cin >> S[i];
	T = makeVector(D+1, 0ll);
	
	calcScore(T, 1);

	ll maxv = -LLINF;
	int M = 100000;
	for (int i = 0; i < M; i++) {
		int d = rand()%D; d++;
		int q = rand()%26; 

		ll tmp = T[d];
		T[d] = q;
		calcScore(T, d);
		if (score[D] <= maxv) T[d] = tmp;
		else maxv = score[D];
	}

	for (int i = 0; i < D; i++) {
		cout << T[i]+1 << el;
	}
	//cout << maxv << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
int a[10];
struct node
{
    int x,y;
}p[10];
double cal(node a,node b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i].x>>p[i].y;
    }
    int tot=0;
    for(int i=1;i<=n;i++)
        a[i]=i;
    double ans=0;
    do
    {
        ++tot;
        for(int i=2;i<=n;i++)
        {
            ans+=cal(p[a[i]],p[a[i-1]]);
        }
    }while(next_permutation(a+1,a+1+n));
    ans/=tot;
    printf("%.10f\n",ans);
}


Measured memory_bytes: 256
x = list(map(int, input().split()))

x.sort()

a = x[0]
b = x[1]
c = x[2]

import math
tmp = []

def inc(i, j):
    if i % 2 == j % 2:
        return int((j - i) / 2)
    else:
        return int(math.ceil((j - i) / 2) + 1)

# target: a
tmp.append(c - a + b - a)

# target: b
tmp.append(inc(a, b) + c - b)

# target: c
tmp.append(inc(a, c) + inc(b, c))

print(min(tmp))


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

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

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

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


signed main() {
  int H, W;
  cin >> H >> W;

  int sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;

  vector<string> s(H);
  REP(i, H) cin >> s[i];


  sx--; sy--;
  gx--; gy--;


  using P = pair<int, pair<int, int>>;
  priority_queue<P, vector<P>, greater<P>> q;
  q.push({0, {sx, sy}});

  vector<vector<int>> dist(H, vector<int>(W, INF));
  dist[sx][sy] = 0;

  while(!q.empty()){
    int x = q.top().second.first;
    int y = q.top().second.second; q.pop();
    REP(i, 5) REP(j, 5){
      if(i == 2 && j == 2) continue;
      int nx = x+i-2;
      int ny = y+j-2;
      if(OUT(0, nx, H) || OUT(0, ny, W)) continue;
      if(s[nx][ny] == '#') continue;

      int d = 1;
      if(abs(i-2)+abs(j-2) <= 1) d = 0;
      if(chmin(dist[nx][ny], dist[x][y]+d)){
        q.push({dist[x][y]+d, {nx, ny}});
      }
    }
  }

  if(dist[gx][gy] == INF) dist[gx][gy] = -1;
  cout << dist[gx][gy] << "\n";

  return 0;
}


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

typedef long long ll;
ll ans, a[15];
string t;
void f(ll p, ll q, ll w) {
	if (p == t.size()) {
		q += w;
		ans += q;
		return;
	}
	f(p + 1, q + w, a[p]);
	f(p + 1, q, w * 10 + a[p]);
}

int main()
{
	int i;
	cin >> t;
	for (i = 0; i < t.size(); i++) {
		a[i] = t[i] - '0';
	}
	f(1, 0, a[0]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N, M, X = map(int, input().split())
A = list(map(int, input().split()))

cos = [0]*(N+1)
for a in A:
    cos[a] += 1

toz = sum(cos[:X])
ton = sum(cos[X:])
print(min(toz, ton))

Measured memory_bytes: 38256
N, X, *A = map(int, open(0).read().split())

ans = sum(A)
b = A[:]
for k in range(1, N):
    for i in range(N):
        b[i] = min(b[i], A[i - k])
    ans = min(ans, k * X + sum(b))
print(ans)


Measured memory_bytes: 42860
#include<iostream>
#include<vector>
#include<algorithm>
#define INF -(1<<29)
#define F first
#define S second
#define T P
using namespace std;
typedef pair<int,int> P;
const int MAX_N = 1000010;

 bool cmp(const P& a,const P& b)
  {
    if(a.first == b.first)
      return a.second > b.second;
    return a.first < b.first;
  }



  int n;
  T dat[3*MAX_N-1];
 
  void init(int n_){
    n = 1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;i++)dat[i] = P(INF,INF);
  }

// k番めの値(0-indexed)をaに変更
  void update(int k,T a){
    k += n-1;
    dat[k] = a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = max(dat[k*2+1],dat[k*2+2],cmp);
    }
  }
 
// [a,b)の最大値を求める
  T query(int a,int b,int k,int l,int r){
    if(r<=a || b<=l)return P(INF,INF);
    else if(a<=l && r<=b)return dat[k];
     
      T vl = query(a,b,k*2+1,l,(l+r)/2);
      T vr = query(a,b,k*2+2,(l+r)/2,r);
      return max(vl,vr,cmp);
  }

//nの範囲でミスしないように極力こっちを利用 
  T _query(int a,int b){
    return query(a,b,0,0,n);
  }


int main()
{
  int n,q;
  cin >> n >> q;
  
  init(n);
  P total[n+1];
  for(int i=0;i<=n;i++)
    total[i] = P(INF,INF);
  vector<P> vec;
  for(int i=0;i<q;i++)
    {
      int a,v;
      cin >> a >> v;
      if(total[a] == P(INF,INF))
	{
	  vec.push_back(P(a,v));
	  int index = vec.size()-1;
	  total[a] = P(v,index);
	  update(index,P(v,a));
	}
      else
	{
	  total[a].first += v;
	  update(total[a].second,P(total[a].first,a));
	}
     
      P p = _query(0,vec.size());
      cout << p.second << " " << p.first << endl;    
    }

  return 0;
}

Measured memory_bytes: 33352
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    for (int i = 0; i < n;i++){
        int sum = 0;
        cin >> a[i];
        int tmp = a[i];
        while(tmp>0){
            if(tmp%2==0){
                sum++;
                tmp /= 2;
            }
            else
                break;
        }
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

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

signed main(){

    int N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;

    int x, y;
    int g = extgcd(N, M, x, y);
    int ans = N * M / g;
    int n = N / g;
    int m = M / g;

    bool f = true;
    REP(i, g){
        if(S[i * n] != T[i * m]) f = false;
    }
    if(f) cout << ans;
    else cout << -1;

    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

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

  vector<int> X = {a, b, c, d, e};

  for (int i = 0; i < 5; i++) {
    if (X.at(i) == 0) cout << i + 1 << endl;
  }
}

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

int main() {
  int k, s;
  cin>>k>>s;
  long long count=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      int z=s-i-j;
      if(i+j+z==s && z<=k && z>=0)count++;         
    }
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<sstream>
#include<stack>
#include<map>
using namespace std;
#define pd pair<double,double>

	int main(){
	int d;
	while(cin>>d){
	int ans=0;
		for(int i=1;i<600/d;i++){
			ans=ans+d*pow(d*i,2);
		}
		cout<<ans<<endl;
	}
    return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main{
    static int H;
    static int[] A;
    static Scanner sc = new Scanner(System.in);
    static StringBuilder sb = new StringBuilder();

    public static void main(String[] args){
        H = sc.nextInt();
        A = new int[H+1];
        for(int i=1; i<=H; i++){
            A[i] = sc.nextInt();
        }
        buildMaxHeap();
        for(int i=1; i<=H; i++){
            sb.append(" " + A[i]);
        }
        System.out.println(sb.toString());
    }
    public static void maxHeapify(int i){
        int l = 2*i;
        int r = 2*i+1;
        int largest;
        int B;

        if(l <= H && A[l] > A[i]){
            largest = l;
        }else{
            largest = i;
        }
        if(r <= H && A[r] > A[largest]){
            largest = r;
        }
        if(largest != i){
            B = A[i] + A[largest];
            A[largest] = B - A[largest];
            A[i] = B - A[i];
            maxHeapify(largest);
        }
    }

    public static void buildMaxHeap(){
        for(int i=H/2; i>=1; i--){
            maxHeapify(i);
        }
    }
}


Measured memory_bytes: 171724
from itertools import*
s,k=open(0)
k=int(k)
g=[len(list(v))for _,v in groupby(s)]
print(sum(c//2for c in g)*k-(g[0]%2*g[-2]%2*s[0]==s[-2])*(-k//2**(len(s)-1==g[0])+1))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>

using namespace std;
using pii=pair<int, int>;
using mii=map<int, int>;

int main() {
    int N, T;
    cin >> N >> T;
    T = T - 1;
    vector<pii> meal(N + 1);
    for (auto i = 1; i <= N; i++) {
        int a, b;
        cin >> a >> b;
        meal.at(i) = pii(a, b);
    }

    std::sort(meal.begin(), meal.end());
    vector<vector<int>> table(N + 1, vector<int>(T + 1));
    int ans = 0;
    for (auto i = 1; i <= N; i++) {
        for (auto j = 0; j <= T; j++) {
            ans = max(ans, table.at(i - 1).at(j) + meal.at(i).second);
            if (j - meal.at(i).first >= 0) {
                table.at(i).at(j) = max(table.at(i - 1).at(j),
                                        table.at(i - 1).at(j - meal.at(i).first) + meal.at(i).second);
            } else {
                table.at(i).at(j) = table.at(i - 1).at(j);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35584
(defparameter tbl (make-hash-table :test 'equal))

(defun main ()
  (let* ((n (read)) (mx 0) (sol '()))
    (loop for i from 1 to n do
         (setq mx (max mx (incf (gethash (read-line) tbl 0)))))
    (loop for k being the hash-key using (hash-value v) of tbl do
         (when (= v mx) (push k sol)))
    (loop for s in (sort sol 'string-lessp) do
         (write-line s))))

(main)


Measured memory_bytes: 84940
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


p, q, r = li()
print(min(p+q, q+r, r+p))

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int cnt[200005];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		cnt[a]++;
	}
	sort(cnt+1,cnt+n+1);
	int f=1;
	while(!cnt[f])f++;
	int ans=0;
	while(f<=n-k)
	{
		ans=ans+cnt[f];
		f++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
def solve():
    cnt = [0] * int(2 * 1e5 + 10)
    li = []
    n, q = map(int, input().split())
    for _ in range(n - 1):
        a, b = map(int, input().split())
        li.append((a, b))
    for _ in range(q):
        p, x = map(int, input().split())
        cnt[p] += x
    for a, b in sorted(li):
        cnt[b] += cnt[a]
    print(*cnt[1 : n + 1])
solve()


Measured memory_bytes: 46232
s_list = str(input())
A, B, C, D = [int(s) for s in s_list ]
for x in range(2):
    if x==0:
        X = A + B
        px = '+'
    else:
        X = A - B
        px = '-'
    for y in range(2):
        if y==0:
            Y = X + C
            py = '+'
        else:
            Y = X - C
            py = '-'
        for z in range(2):
            if z==0:
                Z = Y + D
                pz = '+'
            else:
                Z = Y - D
                pz = '-'
                
            if Z==7:
                print(A, px, B, py, C, pz, D, '=7', sep='')
                exit()

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

int main()
{
    int t,c=0, b, ans=123456789;
    cin >> t;
    int arr[t+1];
    for(int i=0; i<t; i++)
    {
        cin >> b;
        if(b%2 == 1)return cout<<"0"<<endl, 0;
        while(b%2 == 0)c++, b/=2;
        ans=min(c, ans);
        c=0;
    }

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

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

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

    int turn = 0;
    while(1) {
        if(turn == 0) {
            c -= b;
            if(c <= 0) {
                break;
            }
        } else {
            a -= d;
            if(a <= 0) {
                break;
            }
        }
        turn = (turn + 1) % 2;
    }

    string ret = "No";
    if(turn == 0) ret = "Yes";
    cout << ret << endl;
    return 0;
}

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

int main()
{
 

    int X,A,B,C;
    cin>>A>>B>>C>>X;

    long cnt=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 && i+j+k>=1)
            cnt++;
        }
      }
    }
  
	cout<<cnt<<endl;
  
  
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

void solve();

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string inp;
  	cin >> inp;
  	if(inp=="ABC") cout << "ARC";
  	else cout << "ABC";
	return 0;
}


Measured memory_bytes: 3540
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        System.out.println(Math.max(a * b, c * d));
    }
}

Measured memory_bytes: 35808
require 'pp'

def puts_answer(ans)
    o = 1
    ans.each do |t|
        o = (o * t) % MOD
    end

    o
end

MOD = 10 ** 9 + 7
n, k = gets.split.map(&:to_i)
a_n = gets.split.map(&:to_i)

# 全選択するしかない
if a_n.length == k
    ans = a_n
    puts puts_answer(ans)
    exit 0
end

# 0 を除く
len = a_n.length
a_n.delete_if {|a| a == 0}
is_zero = (len != a_n.length) 
# pp is_zero
# 0を答えに含むしかないので答えは0
if a_n.length < k
    puts 0
    exit 0
end

minus = []
plus = []

a_n.each do |a|
    if a > 0
        plus << a
    else
        minus << a
    end
end

plus.sort!.reverse!
minus.sort!

ans = []

if k % 2 != 0
    # 選択する個数が奇数

    # 最初の一つは必ず正の一番でかい数をとる
    # ただし正の数をとれない場合は負数しかないので，答えは負なので絶対値が一番小さくなるようにする
    x = plus.shift
    if x == nil
        if is_zero
            puts 0
            exit 0
        else
            ans = minus.reverse![0, k]
            puts puts_answer(ans)
            exit 0
        end
    end

    ans << x
    k = k - 1
end

# これで残りはkが偶数
#pp plus
#pp minus
z = false
while k != 0
    x, b = 
        if plus.length == 1 && minus.length == 1
            [minus[0] * plus[0], :xxx]
        elsif plus[0] == nil || plus[1] == nil
            [minus[0] * minus[1], :minus]
        elsif minus[0] == nil || minus[1] == nil
            [plus[0] * plus[1], :plus]
        else
            p1 = plus[0] * plus[1]
            m1 = minus[0] * minus[1]
            if p1 >= m1
                [p1, :plus]
            else
                [m1, :minus]
            end
        end

    if b == :plus
        ans << plus.shift
        ans << plus.shift
    elsif b == :minus
        ans << minus.shift
        ans << minus.shift
    else
        ans << minus.shift
        ans << plus.shift
        z = true
    end

    k -= 2
end

if z && is_zero
    puts 0
else
    puts puts_answer(ans)
end


Measured memory_bytes: 36380
import sys
import math
input  = sys.stdin.readline
 
N = int(input())
chk = math.floor(math.sqrt(N))
for i in range(chk, 0, -1):
  a = i
  if N%a != 0:
    continue
  b = N/a
  print(int(a+b-2))
  break


Measured memory_bytes: 2940
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int s, ans;
    int tmp,j=1;
    int ar[100000];
    bool flag= true;

    cin >> s;
    tmp = s;
    ar[1] = tmp;
    while(flag){
        j++;
        if(tmp % 2 == 0){
            tmp = tmp / 2;
        }else{
            tmp = tmp * 3 + 1;
        }
        for(int i = 1 ; i < j ; i++){
            if(ar[i] == tmp){
                ans = j;
                flag = false;
                break;
            }
        }
        ar[j] = tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc;
	int N;
	int[][] stmt;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		stmt = new int[N][2];
		
		for (int i = 0; i < N; i++) {
			int A = sc.nextInt();
			for (int j = 0; j < A; j++) {
				int x = 1 << (sc.nextInt()-1);
				int y = sc.nextInt();
				stmt[i][y] |= x;
			}
		}
		
		for (int i = 0; i < N; i++) {
			stmt[i] = saturate(0, 1<<i, i);
			if (stmt[i] != null) stmt[i][1] |= 1<<i;
		}
		int max = 0;
		int n = 1 << N;
		for (int b = 0; b < n; b++) {
			int stat0 = 0;
			int stat1 = 0;
			int i;
			for (i = 0; i < N; i++) {
				if ( (b&1<<i)==0 ) continue;
				if (stmt[i]==null) break;
				int[] s = saturate(stat0, stat1, i);
				if (s == null) break;
				stat0 |= s[0];
				stat1 |= s[1];
			}
			if (i == N) max = Math.max(max, Integer.bitCount(b));
		}
		System.out.println(max);
	}
	
	private int[] saturate(int stat0, int stat1, int i) {
		if (stmt[i] == null) return null;
		if ((stat0 & stmt[i][1]) > 0) return null;
		if ((stat1 & stmt[i][0]) > 0) return null;
		int s1 = stat1;
		stat0 |= stmt[i][0];
		stat1 |= stmt[i][1];
		int dif = s1^stat1;
		if (dif == 0) return new int[] {stat0, stat1};
		for (int j = 0; j < N; j++) {
			if ( ((1<<j)&dif) == 0) continue;
			if (saturate(stat0, stat1, j) == null) return null;
		}
		return new int[] {stat0, stat1};
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}

Measured memory_bytes: 30616
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
using namespace std;

int main()
{
	#ifdef DEBUG
	freopen("text.in", "r", stdin);
	#endif
	int n, ans = 0;
	LL d, x, y;
	cin >> n >> d; d = d * d;
	for (int i = 1; i <= n; ++i) {
		cin >> x >> y;
		ans += x * x + y * y <= d;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3732
/*
 *  C - Attack Survival
 * author: roy4801
 * (C++)
 */
#include <bits/stdc++.h>

using namespace std;

#define PROB "C"
#define TESTC ""

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PPB pop_back
#define PF push_front
#define PPF pop_front
#define N 100000
int n, k, q;
int t;
int sc[N+5];
int main()
{
	#ifdef DBG
	freopen("./testdata/" PROB TESTC ".in", "r", stdin);
	freopen("./testdata/" PROB ".out", "w", stdout);
	#endif
	while(cin >> n >> k >> q)
	{
		fill(sc+1, sc+1+n, q);
		for(int i = 0; i < q && cin >> t; i++)
			sc[t]--;
		for(int i = 1; i <= n; i++)
			if(k-sc[i] <= 0)
				printf("No\n");
			else
				printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 1024
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for i in range(N)]

# dp[damage] := モンスターに damage を与えるために必要な最小コスト

# damage = 0,1,2,...,H
dp = [10**9] * (H + 1)
dp[0] = 0
for h in range(H):
    for damage, cost in magic:
        next_index = min(h + damage, H)
        dp[next_index] = min(dp[next_index], dp[h] + cost)

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


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

#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define si set<int>
#define ii pair<int,int>
#define f first
#define s second
#define pb push_back
#define endl '\n'
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define sz(c) (int) (c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define db(x) cout << #x << ": " << x << endl
#define _db(c) for (auto x : c) cout << x << " "; cout << endl
#define forc(i,c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define tc int t; cin >> t; while (t--)
#define bs(c,x) binary_search(all(c),x)

ll MOD = 1000000007;
ll ans = 0;
ll a, b, i, j, m, n, x, y;

int main() { 
	io;
	
	cin >> x >> n;

	if (n == 0) {
		cout << x; return 0;
	}

	vl v(n);
	for (ll i = 0 ; i < n ; ++i) cin >> v[i];

	// sort (all(v));
	// _db(v); _db(diff);

	for (int i = 0 ; i < 105 ; ++i) {
		a = x-i;
		b = x+i;

		if (find(all(v),a) == v.end()) {
			cout << a; return 0;
		}
		else if (find(all(v),b) == v.end()) {
			cout <<b; return 0;
		}
	}
	
	
}

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

#define all(x)  x.begin(), x.end()

static const int INF = 1 << 30;
static const double PI = acos(-1);

int dp[202020];

int main() {
        int sx, sy, gx, gy;
        scanf("%d%d%d%d", &sx, &sy, &gx, &gy);
        int n;
        scanf("%d", &n);
        vector<pair<int, int>> p(n), q;
        for (int i = 0; i < n; i ++) scanf("%d%d", &p[i].first, &p[i].second);
        for (int i = 0; i < n; i ++) {
                if (min(sx, gx) <= p[i].first && p[i].first <= max(sx, gx) && min(sy, gy) <= p[i].second && p[i].second <= max(sy, gy)) {
                        q.push_back(p[i]);
                }
        }
        if (sy > gy) for (int i = 0; i < q.size(); i ++) q[i].second *= -1;
        sort(all(q));
        if (sx > gx) reverse(all(q));
        for (int i = 0; i < 202020; i ++) dp[i] = INF;
        for (int i = 0; i < q.size(); i ++) {
                *lower_bound(dp, dp + 202020, q[i].second) = q[i].second; 
        }
        int len = lower_bound(dp, dp + 202020, INF) - dp;
        double ans = (long long) (abs(gy - sy) + abs(gx - sx)) * 100;
        if (len < min(abs(gy - sy), abs(gx - sx)) + 1) {
                ans -= (20.0 - 5.0 * PI) * len;
        } else {
                ans -= (20.0 - 5.0 * PI) * (len - 1);
                ans += 10.0 * PI - 20;
        }
        printf("%.15lf\n", ans);
        return 0;
}



Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  int ans;
  
  if(s.at(0) == 'R' && s.at(1) == 'R' && s.at(2) == 'R') {
    ans = 3;
  } else if(s.at(0) == 'R' && s.at(1) == 'R') {
    ans = 2;
  } else if(s.at(1) == 'R' && s.at(2) == 'R') {
    ans = 2;
  } else if(s.at(0) == 'R') {
    ans = 1;
  } else if(s.at(1) == 'R') {
    ans = 1;
  } else if(s.at(2) == 'R') {
    ans = 1;
  }
  cout << ans << endl;
 
  // ここにプログラムを追記
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int sum(int a) {
	int res = 0;
	while (a > 0) {
		res += a % 10;
		a /= 10;
	}
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int res = (int)1 << 60;
	for (int i = 1; i < N; i++) {
		res = min(res, sum(i) + sum(N - i));
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
    #define LF '\n'
    #define ALL(x) x.begin(), x.end()
    #define iostreamBooster() do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
    using namespace std;
    typedef int64_t i64;
    typedef pair<int,int> pii;
    template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
    template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
    constexpr int INF = 0x3f3f3f3f;
    constexpr i64 LINF = 0x3f3f3f3f'3f3f3f3fLL;
     
    i64 a[1000100];
     
    i64 f(i64 n) {
    if (n & 1) {
    return 3*n + 1;
    } else {
    return n/2;
    }
    }
     
    signed main()
    {
    set<i64> U;
     
    int ans = 0;
    cin >> a[1];
    U.insert(a[1]);
     
    for (int i = 2; i <= 1000005; ++i) {
    a[i] = f(a[i-1]);
     
    if (U.count(a[i])) {
    ans = i;
    break;
    } else {
    U.insert(a[i]);
    }
    }
     
    cout << ans << endl;
     
    return 0;
    }
     

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

bool is_prime(int n)
{
    if (n == 0 || n == 1)
        return (false);
    if (n % 2 == 0 && n != 2)
        return (false);
    for (int i = 3; i * i < n + 1; i += 2)
    {
        if (n % i == 0)
        {
            return (false);
        }
    }
    return (true);
}

int main()
{
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<int> cum(n + 1, 0), l(q), r(q);
    for (int i = 0; i < q; i++)
    {
        cin >> l[i] >> r[i];
    }

    for (int i = 0; i < n - 1; i++)
    {
        if (s.substr(i, 2) == "AC" && i < n - 1)
        {
            cum[i + 2] = cum[i + 1] + 1;
        }
        else
        {
            cum[i + 2] = cum[i + 1];
        }
    }

    for (int i = 0; i < q; i++)
    {
        cout << cum[r[i]] - cum[l[i]] << '\n';
    }

    return 0;
}


Measured memory_bytes: 4580
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 500'000;
const int LOGN = 19;

int n, m, k;

void solve(int test) {
  cin >> n;
  vector<int> a(n);
  int64 s = 0;
  for (int& x : a) {
    cin >> x;
    s += x;
  }
  int64 ans = 0;
  for (int x : a) {
    ans += (s - x) % mod * x % mod;
    ans %= mod;
  }
  ans *= 500'000'004;
  ans %= mod;
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 3988
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;

ll n;
ll a[505][505];
void solve(vector<ll> v, ll lvl)
{
        if(v.size() <= 1) return;
        vector<ll> A;
        vector<ll> B;
        for(ll i=0;i<v.size();i++){
                if(i%2 == 0) A.pb(v[i]);
                else B.pb(v[i]);
        }
        solve(A,lvl+1);
        solve(B,lvl+1);
        for(auto &i : A) {
                for(auto &j : B) {
                        a[i][j] = lvl;
                        a[j][i] = lvl;
                }
        }
}
int main()
{
        cin >> n;
        vector< ll > v;
        for(ll i=1;i<=n;i++) {
                v.pb(i);
        }
        solve(v, 1);
        for(ll i=1;i<=n;i++) {
                for(ll j=i+1;j<=n;j++) {
                        cout << a[i][j] << " ";
                }
                cout << "\n";
        }
        return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

unsigned long long int a = 0, b = 0, c = 1, x = 0, y = 0, z = 0, maxy = -1, mini = 9999, counter = 0,startp=0,endp=0,checker=0;
std::vector<unsigned long long int> vec{}, vecsec{};
int iremono[100001];
std::vector<long long int>kinds{}, ans{}, kaku{};
char moji,moji2;
bool okada = false,okada2=false;
std::string output, output2, input, one, two;
unsigned long long int wanwan[200];
int kakunou2[50][50] = {};
unsigned long long int M, A, R, C, H;

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{

	cin >>a>>b;
	rep(i, a) {
		cin >> c;
		rep(j, c) {
			cin >> x;
			wanwan[x]++;
		}
				
	}
	c = 0;
	rep(i, b+1) {

		if (a == wanwan[i]) {
			c++;
		}
	}
	cout << c << endl;
}

	
	





Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

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

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

    int H;
    int N;

    cin >> H >> N;

    int total = 0;
    for (int i=1; i < N+1; i++) {
        int skill;
        cin >> skill;
        total += skill;
    }

    if (total >= H) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


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

using ll = long long;

int main() {
	ll h, w; scanf("%lld %lld", &h, &w);
	if (h == 1 || w == 1) {
		printf("1\n");
		return 0;
	}
	ll ans = h * w;
	printf("%lld\n", ans / 2 + ans % 2);
	return 0;
}


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

using namespace std;

int N;
long long int M;
long long int MOD = 1000000007;

long long int POW(long long int a, int p) {
	if (p == 0) { return 1; }
	if (p % 2 == 0) {
		long long int tmp=POW(a, p / 2);
		return tmp*tmp%MOD;
	}
	else {
		return a*POW(a, p - 1) % MOD;
	}
}

/*long long int INV(long long int k) {

	return POW(k, MOD - 2);
}*/

long long int INV(long long int m, long long int p) {
	vector<int> bit; // 2^0, 2^1, 2^2, 2^3, 
	long long int u = p - 2;
	while (u > 0) {
		bit.push_back(u % 2); u /= 2;
	}

	vector<long long int> W;
	long long int TMP = m;
	for (int i = 0; i < (int)bit.size(); i++) {
		TMP %= p;
		W.push_back(TMP);
		TMP *= TMP;
	}

	long long int ret = 1;

	for (int i = 0; i<(int)bit.size(); i++) {
		if (bit[i] == 1) { ret *= W[i];  ret %= p; }
	}

	return ret;
};

long long int C(int n, int m) {

	long long int U=1, D=1;

	for (int i = 0; i < m; i++) {
		U *= (n - i); U %= MOD;
		D *= (m - i); D %= MOD;
	}
	return U*INV(D,MOD) % MOD;
}

int main(void) {

	cin >> N >> M;

	long long int ans = 1;
	long long int tmp = M;
	for (int i = 2; i*i <= M; i++) {
		int cnt = 0;
		while (tmp%i == 0) { tmp /= i; cnt++; }
		//cout << "cnt= " << cnt << endl;
		ans *= C(N + cnt - 1, cnt);
		ans %= MOD;
      }

	if (tmp > 1) { ans *= N;  ans %= MOD; }

	/*for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= i; j++) {
			cout << "C[" << i << "][" << j << "]= " << C(i,j) << endl;
		}
	}*/

	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int solve(int,int);

int n,A[1000];
int main(){
  int i,s,m;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  //intput
  scanf("%d",&s);
  for(i=0;i<s;i++){
    scanf("%d",&m);
    if(solve(0,m)==0)printf("no\n");
    else printf("yes\n");
  }
  
  return 0;
}
int solve(int i,int m){
  int res;
  if(m==0)return 1;
  if(i>=n)return 0;
  res=(solve(i+1,m)||solve(i+1,m-A[i]))?1:0;
  return res;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;

int main()
{
	IO;
	int k,a,b;
	cin>>k>>a>>b;
	if(a%k==0||b%k==0){
		cout<<"OK"<<endl;
	}else if(a/k!=b/k){
		cout<<"OK"<<endl;
	}else{
		cout<<"NG"<<endl;
	}
 	return 0;
}







Measured memory_bytes: 3652
dice = gets.split.map(&:to_i)
order = gets(chomp: true)

order.each_char do |str|
  case str
  when "N"
    dice[0], dice[1], dice[4], dice[5] = dice[1], dice[5], dice[0], dice[4]
  when "S"
    dice[0], dice[1], dice[4], dice[5] = dice[4], dice[0], dice[5], dice[1]
  when "W"
    dice[0], dice[2], dice[3], dice[5] = dice[2], dice[5], dice[0], dice[3]
  when "E"
    dice[0], dice[2], dice[3], dice[5] = dice[3], dice[0], dice[5], dice[2]
  end
end
puts dice[0]


Measured memory_bytes: 6880
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	for(int n,k,t,u,v,l;cin>>n>>k>>t>>u>>v>>l;){
		vector<int> ds(n+2); ds[n+1]=l;
		for(int i=1;i<=n;i++) cin>>ds[i];
		
		double res=0,pos=0,rest=0;
		for(int carrot=0;pos<l;){
			int i=upper_bound(begin(ds),end(ds),pos)-ds.begin();
			double dist=ds[i]-pos;
			if(rest>=dist/v){
				res+=dist/v;
				pos=ds[i];
				rest-=dist/v;
				carrot++;
				if(carrot>k){
					carrot--;
					rest=t;
				}
				continue;
			}
			else if(rest>0){
				res+=rest;
				pos+=v*rest;
				rest=0;
			}
			else if(carrot>0){
				carrot--;
				rest=t;
			}
			else{
				res+=dist/u;
				pos=ds[i];
				carrot++;
			}
		}
		printf("%.10f\n",res);
	}
}

Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 1 << 19;
int n, a[maxn], max1[maxn], max2[maxn];

bool cmp(int x, int y) {
	return a[x] > a[y];
}

int main()
{
	cin>>n;
	int cnt = 1 << n;
	for(int i=0; i<cnt; i++) cin>>a[i], max1[i] = i, max2[i] = cnt;
	a[cnt] = -1;
	for(int mask=1; mask<cnt; mask++) {
		for(int i=0; i<n; i++) {
			if(mask & (1 << i)) {
				int b[4];
				b[0] = max1[mask], b[1] = max2[mask], b[2] = max2[mask ^ (1 << i)], b[3] = max1[mask ^ (1 << i)];
				sort(b, b+4, cmp);
				max1[mask] = b[0];
				if(b[0] == b[1]) max2[mask] = b[2];
					else max2[mask] = b[1];
			}
		}
	}
	int ans = 0;
	for(int i=1; i<cnt; i++) {
		ans = max(ans, a[max1[i]] + a[max2[i]]);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 8192
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;


int main(){
    
    int n;
    int c=0;
    while(1){
        cin>>n;
        if(n==0)break;
        c=0;
        rep(i,n/4){
            int a;
            cin>>a;
            c+=a;
        }
        cout<<c<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
X = int(input())

# If a is positive: n ** 5 - (n - 1) ** 5 exceeds 10 ** 9 when i = 120
# If a is non-positive: n ** 5 - (n - 1) ** 5 exceeds 10 ** 9 when i = -119
# So, the valid range of A is from -118 to 119
for a in range(-118, 119 + 1):
    tgt = a ** 5 - X
    for b in range(-119, 119):
        if tgt == b ** 5:
            print(a, b)
            exit()


Measured memory_bytes: 63448
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='C')
		{
			for(int j=i;j<s.length();j++)
			{
				if(s[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
			}
			break;
		}
	}
	cout<<"No";
	return 0;
}


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

int main() {
    int a, b, s;
    char op;

    while (1) {
        cin >> a >> op >> b;

        if ( op == '?' ) break;
        if ( op == '+' ) {
            s = a + b;    
            cout << s << endl;
        } else if ( op == '-' ) {
            s = a - b;
            cout << s << endl;
        } else if ( op == '*') {
            s = a * b;
            cout << s << endl;
        } else {
            s = a / b;
            cout << (int)s << endl;
        }
    }

    return 0;
}


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

bool IsPrime(int num)//素数だけ数えればいいから
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
    int x;
    cin >> x;
    for(int i=x;;i++){
        if(IsPrime(i)){
            cout << i;
            break;
        }
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns, OverloadedStrings #-}

import Control.Monad
import Data.Array.Unboxed
import Data.Bits
import Data.Bool
import Data.Char
import Data.Coerce
import Data.Function
import Data.Int 
import Data.IORef
import Data.List
import Data.Maybe
import qualified Data.Map.Strict as M
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  getLine
  ns <- getIntList
  print $ fst $ foldl' step (0, 0) ns
  where
    step (a, b) c = (a + max 0 (b - c), max b c)


-- Input

getInt :: IO Int
getInt = readLn
second :: (b -> c) -> (a, b) -> (a, c)
second f (a, b) = (a, f b)

readInt :: BS.ByteString -> Maybe (Int, BS.ByteString)
readInt = fmap (second BS.tail) . BS.readInt

getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n readInt <$> BS.getLine
 
getIntList :: IO [Int]
getIntList = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

getIntegerList :: IO [Integer]
getIntegerList = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

getIntPair :: IO (Int, Int)
getIntPair = do
  v <- getIntVec 2
  return (v V.! 0, v V.! 1)

-- Search

bisearch :: (Int -> Bool) -> (Int, Int) -> (Int, Int)
bisearch check = bis
  where
    bis (l, r)
      | l + 1 == r = (l, r)
      | check mid  = bis (mid, r)
      | otherwise  = bis (l, mid)
      where
        mid = l + (r - l) `div` 2

-- Modular Arithmetic
--
 
modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined
---
 
exEuclid :: (Eq a, Integral a) => a -> a -> (a, a, a)
exEuclid !f !g = loop 1 0 0 1 f g
  where loop !u0 !u1 !v0 !v1 !f 0 = (f, u0, v0)
        loop !u0 !u1 !v0 !v1 !f g =
          case divMod f g of
            (q,r) -> loop u1 (u0 - q * u1) v1 (v0 - q * v1) g r
 
recipM :: Int64 -> Int64
recipM !x = case exEuclid x modulo of
             (1,a,_) -> a `mod` modulo
             (-1,a,_) -> (-a) `mod` modulo
divM :: Int64 -> Int64 -> Int64
divM !x !y = x `mulMod` recipM y
 
instance Fractional N where
  (/) = coerce divM
  recip = coerce recipM
  fromRational = undefined

-- 組み合わせ
powerset :: [a] -> [[a]]  
powerset xs = filterM (\x -> [True, False]) xs


Measured memory_bytes: 58220
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  S=pin()[:-1]
  K=int(pin())
  t=S[K-1]
  for i in range(N):
    if t==S[i]:
      pout(t)
    else:
      pout("*")
  print()
  return 
main()

Measured memory_bytes: 9080
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
#define PF(a) pop_front(a)
 
#define MP(a,b) make_pair(a,b)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
 
//------show vector---------
template <typename T>
void showV(vector < T > a){
  EACH(i,a){
    cerr << *i << ',';
  }  
  cerr << endl;
}
 
//------show matrix---------
template <typename T>
void showVV(vector < vector < T > > a){
  EACH(i,a){
    showV(*i);
  }  
}
//grobal var
//------------------------------------------
LL dp[2000][2000];
vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  return (ret);
}

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  int N;
  while(cin >> N){
    LL ans = 0;
    vector<str> S(N);
    REP(i, N){
      cin >> S[i];
    }
    REP(i, N){
      SORT(S[i]);
    }
    SORT(S);
    REP(i, N){
      LL cnt = 1;
      FOR(j, i+1, N){
        if(S[i] != S[j]){
          ans += (cnt*(cnt-1)) / 2;
          i = j-1;
          cnt = 1;
          break;
        }
        if(S[i] == S[j]){
          cnt++;
          if(j==N-1){
            ans += (cnt*(cnt-1)) / 2;
            i = j-1;
            cnt = 1;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll inf = 1e18;
ll mod = 1e9+7;

ll n,k;

int main(){
    cin >> n >> k;
    ll sum = 0;
    for (ll i = k; i <= n + 1; i++) {
        sum += (n - i + 1) * i + 1;
        sum %= mod;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h> 
using namespace std; 
typedef   long long int ll;
int main () 
{
   ll n,m,k,w;cin>>n>>m;
   k=(n*(n-1))/2;
   w=(m*(m-1))/2;
   if (k<0) k=0;
   if (w<0) w=0;
   cout<<k+w<<endl;



}

Measured memory_bytes: 256