akhauriyash/Code-Regression huggingface dataset:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i_a in range(a+1):
    sum_a = 500 * i_a
    for i_b in range(b+1):
        sum_b = 100 * i_b
        for i_c in range(c+1):
            sum_c = 50 * i_c
            if x == (sum_a + sum_b + sum_c):
                count += 1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(ll, n, p);
  Cins(ll, n, a);

  bool all_even = true;
  for (auto e : a)
    if (e % 2ll == 1ll) all_even = false;

  if (all_even) {
    cout << (p == 0ll ? 1ll << n : 0ll) << endl;
    return;
  }

  cout << (1ll << (n - 1ll)) << endl;
}

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

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		for(;sc.hasNext();){
			String s = sc.next();
			String t = sc.next();
			SuffixArray sa = new SuffixArray(s);
			int left=-1,right=t.length()+1;
			while(left<right-1){
				int len= (left+right)/2;
				
//				System.out.println(left+" "+right+" "+len);
				boolean f = false;
				for(int i=0;i<t.length();i++){
					if(i+len>t.length())break;
					String sub = t.substring(i,i+len);
					if(sa.contain(sub)){
						f=true;
						break;
					}
				}
				if(f){
					left=len;
				}
				else{
					right=len;
				}
					
			}
			System.out.println(left);			
		}

	}



	static class SuffixArray {

		/**
		 * @param args
		 */
		int n,k=1;
		Integer[] sa,rank,tmp;
		String s;

		SuffixArray(String _s) {
			s=_s;
			n = s.length();
			String[] S = new String[n+1];
			S[n]="";
			for(int i=n-1;i>=0;i--){
				S[i] = s.charAt(i)+S[i+1];
			}
			rank=new Integer[n+1];
			sa=new Integer[n+1];
			tmp=new Integer[n+1];
			for(int i=0;i<n;i++){
				sa[i]=i;
				rank[i]=(int) s.charAt(i);
			}
			sa[n]=n;
			rank[n]=-1;

			for(k=1;k<=n;k<<=1){
				Arrays.sort(sa,new Comparator<Integer>(){
					@Override
					public int compare(Integer o1, Integer o2) {
						int r1=rank[o1];
						int r2=rank[o2];
						if(r1!=r2)return -(r1-r2);
						int r11=o1+k <= n ? rank[o1+k] : -1;
						int r22=o2+k <= n ? rank[o2+k] : -1;

						return -(r11-r22);
					}
				});
				tmp[sa[0]]=0;
				for(int i=1;i<=n;i++){
					tmp[sa[i]]=tmp[sa[i-1]]+ (compare(sa[i-1],sa[i])>0?1:0);
				}
				for(int i=0;i<=n;i++){
					rank[i]=tmp[i];
				}
			}
		}
		boolean contain(String t){
			return contain(s,sa,t);
		}
		private boolean contain(String s,Integer[] sa,String t){
			int a=0,b=s.length();
			while(b-a>1){
				int c = (a+b)/2;
				String sub = s.substring(sa[c], Math.min(sa[c]+t.length(), s.length()));
				//			System.out.println(sub);
				//			System.out.println(a+" "+c+" "+b);
				if(sub.compareTo(t)<0){
					a=c;
				}
				else{
					b=c;
				}
			}
			return s.substring(sa[b], Math.min(sa[b]+t.length(), s.length())).compareTo(t)==0;
		}

		/*
		 * s.substring(i1,i2).compare(t)と同じ。メモリ節約
		 */
		private int compare(String s,int i1,int i2,String t){
			for(int i=i1;i<i2;i++){
				if(i-i1>=t.length()){
					return 1;
				}
				if(s.charAt(i)!=t.charAt(i-i1)){
					return s.charAt(i)-t.charAt(i-i1);
				}
			}
			return (i2-i1)-t.length();
		}

		/*
		 * s.substring(i1,i2).compare(t.substring(j1,j2)と同じ。メモリ節約
		 */
		private int compare(String s,int i1,int i2,String t,int j1,int j2){
			int slen=i2-i1;
			int tlen=j2-j1;
			for(int i=0;i<slen;i++){
				if(i>=tlen){
					return 1;
				}
				if(s.charAt(i+i1)!=t.charAt(i+j1)){
					return s.charAt(i+i1)-t.charAt(i+j1);
				}
			}
			return slen-tlen;
		}

		private int compare(Integer o1, Integer o2) {
			int r1=rank[o1];
			int r2=rank[o2];
			if(r1!=r2)return (r1-r2);
			int r11=o1+k <= n ? rank[o1+k] : -1;
			int r22=o2+k <= n ? rank[o2+k] : -1;

			return (r11-r22);
		}

	}

}

Measured memory_bytes: 190316
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
lld A[lim];

int main(){
    lld n = sc();
    rep(x,1,100) rep(y,1,100) rep(z,1,100) A[x * x + y * y + z * z + x * y + y * z + z * x]++;
    rep(i,1,n) prL(A[i]);
    return 0;
}


Measured memory_bytes: 4192
// In the name of Allah. Ya ali!
#include<bits/stdc++.h>
#define double long double
typedef long long ll;
const ll MAX_N = 5000+10;
const ll MOD = 1e9+7;
using namespace std;

int a[MAX_N];
int pos[MAX_N];
ll dp[MAX_N][MAX_N];
int d[MAX_N][MAX_N];
int cnt[MAX_N][MAX_N];
ll n,l,r;

int main()
{
    cin >> n >> r >> l;
    for(int i = 1;i<=n;++i)
        cin >> a[i],pos[a[i]] = i;
    for(int i = n;i>=1;--i)
        for(int j = pos[i];j<=n;++j)
            d[j][i] = pos[i];
    for(int i = 1;i<=n;++i)
    {
        for(int j = 1;j<=n;++j)
        {
            cnt[i][j] = cnt[i-1][j] + (a[i]<=j);
        }
    }
    for(int i = 1;i<=n;++i)
    {
        for(int j = 1;j<=n;++j)
        {
            if (!d[i][j])
            {
                dp[i][j] = dp[i][j-1];
                continue;
            }
            if (d[i][j]==i)
            {
                dp[i][j] = dp[i-1][j];
                continue;
            }
            int t = cnt[i][j]-cnt[d[i][j]][j];
            dp[i][j] = min(dp[i][j-1]+r,dp[d[i][j]][j-1]+l*t);
        }
    }
    cout << dp[n][n];
    return 0;
}


Measured memory_bytes: 392064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, x1, x2, x3, x4, x5, k=0;
  cin >> A >> B;
  for (int i = A; i < B + 1; i++) {
    x1 = i/10000;
    x2 = i/1000 - 10*x1;
    x3 = i/100 - 10*x2 - 100*x1;
    x4 = i/10 - 10*x3 - 100*x2 - 1000*x1;
    x5 = i%10;
     if ((x1 == x5) && (x2 == x4)) {
       k++;
     }
  }
  
  cout << k << endl;
}

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

map<long, int> fac(long n) {
  map<long, int> M;
  for (long i = 2; i <= n; i++) {
    if (n == 1) break;
    if (i * i > n) {
      M[n] = 1; break;
    }
    if (n % i == 0) {
      M[i] = 0;
      while (n % i == 0) { n /= i; M[i]++; }
    }
  }
  return M;
}

int main() {
  long N; cin >> N;
  map<long, int> M = fac(N);
  int c = 0;
  for (auto it = M.begin(); it != M.end(); it++) {
    c += (int)((-1.0 + sqrt(1.1 + 8.0 * it->second)) / 2.0);
  }
  cout << c << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a=s.length();
    if(s[0]=='R' && s[1]=='R' && s[2]=='R')
    {
        cout<<"3"<<endl;
    }
    else if(s[0]=='R' && s[1]=='R' || s[1]=='R' && s[2]=='R')
    {
        cout<<"2"<<endl;
    }
    else if(s[0]=='S' && s[1]=='S' && s[2]=='S')
    {
        cout<<"0"<<endl;
    }
    else
    {
        cout<<"1"<<endl;
    }
}

Measured memory_bytes: 3620
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        s: chars,
    }
    println!("{}", if s.iter().all(|&c| c == s[0]) { "No" } else { "Yes" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define fr         first
#define se         second
#define sc(x)      scanf("%d",&x)
#define pr(x)      printf("%d ",x)
#define scl(x)     scanf("%lld",&x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x);
#define bb(x)      cerr<< x <<endl;
#define ii         pair<int,int>
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M   = 1e7+9 ;
const ll inf = 1e19  ;
const int si = 1e5+9 ;
//////////////////////    Hi    ^_^  hack me if you can :P
int a[200200];
int t;
int main()
{
    string s;
    cin>>s;
    int cs=0,ct=0,ans=0;
    lop(i,sz(s)){
        if(s[i]=='S')
            cs++;
        if(s[i]=='T'){
            if(cs){
                cs--;
                ++ans;
            }
        }
    }
    cout<<sz(s)-2*ans;
    r0;
}



/*

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

*/
/*
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
int mx[]= {0,0,1,1,1,-1,-1,-1};
int my[]= {1,-1,0,1,-1,0,1,-1};
bool inside (int i,int j) {return (i>=0 && i<n && j>=0 && j<m);}
*/


Measured memory_bytes: 640
Q = int(input())
lr = [list(map(int, input().split())) for _ in range(Q)]
n=10**5 + 1
prime = [True] * (n)
prime[0] = prime[1] = False
for i in range(2, int((n)**0.5) + 1):
    if prime[i]:
        for j in range(i*2, n, i):
            prime[j] = False
counter = 0
work = [0] * (n)
for i in range(2, n):
    if prime[i] and prime[(i+1)//2]:
        counter += 1
    work[i] = counter
for l, r in lr:
    print(work[r] - work[l-1])

Measured memory_bytes: 29856
N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
cnt = 0
for i_1 in range(N):
    for i_2 in range(i_1+1, N):
        for i_3 in range(i_2 + 1, N):
            if (L[i_1] != L[i_2] != L[i_3]) and (abs(L[i_1] - L[i_2]) < L[i_3] < L[i_1]+L[i_2]):
                cnt += 1
print(cnt)

Measured memory_bytes: 9208
#include <iostream>

using namespace std;
int main () {

    int a[5];
    int o[5];
    int sub[5];
    for(int i = 0; i < 5; ++i) {
        cin >> a[i];
        o[i] = 0;
        int n = (a[i]/10+1);
        sub[i] = (a[i]%10==0) ? 0 : n * 10 - a[i];
        // cout << i << " " << sub[i] << endl;
    }

    int time = 0;
    for (int i = 0; i < 5; ++i) {
        int idx = 0;
        int max = 10;
        for (int j = 0; j < 5; ++j) {
//            cout << sub[j] << endl;
            if (max > sub[j] && o[j] == 0) {
                max = sub[j];
                idx = j;
            }
        }

        o[idx] = 1;
        time += (i==4) ? a[idx] : (a[idx]%10==0) ? a[idx] : (a[idx]/10+1)*10;
        // cout << i << " " << idx << " " <<time << endl;
    }
    cout << time << endl;
    return 0;
}

Measured memory_bytes: 256
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>

// type alias
using lint = long long;
using ldouble = long double;
template <class T>
using greater_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T>>;


/* ----- class ----- */

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;


/* ----- debug ----- */

#if __has_include("../setting/source/debug.hpp")
#include "../setting/source/debug.hpp"
#endif


/* ----- short functions ----- */

template <class T>
inline T sq(T a) { return a * a; }

template <class T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <class T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        std::swap(a, b);
    }
    return a;
}

template <class T, class U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

// 0-indexed
template <class T, class U>
inline T kthbit(T a, U k) { return (a >> k) & 1; }

template <class T, class U>
inline T mask(T a, U k) { return a & ((1 << k) - 1); }

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < v.size(); ++i) rev[v[i]] = i;
    return rev;
}

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}


/* ----- constants ----- */

// const int INF = std::numeric_limits<int>::max() / 3;
// const lint INF = std::numeric_limits<lint>::max() / 3;
// const ldouble PI = acos(-1);
// const ldouble EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));


using namespace std;

int main() {
    int P, Q, R;
    cin >> P >> Q >> R;

    cout << P + Q + R - max({P, Q, R}) << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    A1s = list(map(int, input().split()))
    A2s = list(map(int, input().split()))
    A3s = list(map(int, input().split()))
    As = []
    As.append(A1s)
    As.append(A2s)
    As.append(A3s)
    N = int(input())
    bingo = [[False for _ in range(3)] for __ in range(3)]

    for _ in range(N):
        b = int(input())

        for i in range(3):
            for j in range(3):
                if b == As[i][j]:
                    bingo[i][j] = True

    # 判定
    for i in range(3):
        if bingo[i][0] and bingo[i][1] and bingo[i][2]:
            print("Yes")
            return
        if bingo[0][i] and bingo[1][i] and bingo[2][i]:
            print("Yes")
            return
    if (bingo[0][0] and bingo[1][1] and bingo[2][2] or
        bingo[0][2] and bingo[1][1] and bingo[2][0]):
        print("Yes")
        return
    print("No")



if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MOD 998244353
long long mi(long long a, long long m) {
    long long m0 = m;
    long long y = 0, x = 1;
    if (m == 1) {
        return 0;
    }
    while (a > 1) {
        long long q = a / m;
        long long t = m;

        m = a % m;
        a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0) {
        x += m0;
    }
    return x;
}
long long ncr(long long n, long long r, vector<long long>& fact) {
    return ((fact[n] * mi(fact[r], MOD) % MOD) * mi(fact[n - r], MOD)) % MOD;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long a, b, n, k;
    cin >> n >> a >> b >> k;
    vector<long long> fact(n + 1);
    fact[0] = 1;
    for (int i = 1; i <= n; i++) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    long long ans = 0;
    for (int i = 0; i <= n; i++) {
        if (k < i * a || (k - i * a) % b != 0 || (k - i * a) / b > n) {
            continue;
        }
        long long red = i, blue = (k - i * a) / b;
        ans += ncr(n, red, fact) * ncr(n, blue, fact) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  dsu d(n);
  int i;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a,--b;
    d.merge(a, b);
  }
  cout << d.groups().size() - 1 << endl;
}

Measured memory_bytes: 8872
#include<stdio.h>

void scan(int*[],int);
int search(int*[],int*[],int,int);

int main(){

  int i,j,n=0,q=0,c=0;
  int* s[10000];
  int* t[500];

  scanf("%d",&n);
  scan(s,n);
 
  scanf("%d",&q);
  scan(t,q);

  c=search(s,t,n,q);
 
  printf("%d\n",c);

  return 0;
}

void scan(int* a[], int m){

  int i;
  for(i=0;i<m;i++){
    scanf("%d",&a[i]);
  }
}

int search(int* s[],int* t[],int n,int q){

  int i,j,c = 0;

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(t[i]==s[j]){
	c++;
	break;
      }
    }
  }

  return c;

}

Measured memory_bytes: 680
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    OUT(n*n / 1);

    return 0;
}

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

int main()
{
    int a, b, ans = 0;

    cin >> a >> b;

    for(int i = 0;i < 2;i++){
        if(a < b){
            ans += b;
            b--;
        }
        else{
            ans += a;
            a--;
        }
    }

    cout << ans;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> X(N);
  for (int i=0; i<N; i++) {
    cin >> X[i];
  }
  int ans = 0;
  for (int x : X) {
    if (2*x < K) ans +=  2*x;
    else ans += 2*(K-x);
  }
  
  cout << ans << endl;
      
  
}

Measured memory_bytes: 256
#include<stdio.h>
 
int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while (A[i] != key)i++;
    return i != n;
}
 
int main() {
    int i, n, A[10000 + 1], q, key, sum = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++)scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &key);
        if (search(A, n, key))sum++;
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <iostream>
#include <cmath>
using namespace std;

int h[1000000];
int dp[1000000];
int k,n;


int cost(int x){

      if(x==n-1)
        return 0;
      if(dp[x]!=-1)
        return dp[x];
      int c=abs(h[x+1]-h[x])+cost(x+1);
      for(int i=2;i<=k;i++){
      if(x+i>=n)
        break;

        c= min(c,abs(h[x+i]-h[x])+cost(x+i));
      }
        return  dp[x]=c;

    }


  int main(){


      cin>>n;
      cin>>k;


      for(int i=0;i<n;i++)
        cin>>h[i];


    memset(dp,-1,sizeof(dp));
    cout<<cost(0)<<endl;










  }














Measured memory_bytes: 15680
#include <stdio.h>

int main(){
    int i,j,k,n;
    scanf("%d",&n);
    int a[n];
    for (int i = 0; i <n ; ++i) {
        scanf("%d",&a[i]);
    }
    int count,temp,check;
    count=0;
    check=1;
    for (int j = 0; j < n; j++) {
        if(check==0) break;
        check=0;

        for (int k = (n-1); j < k;k--) {
          
            if (a[k]<a[k-1]){
                temp=a[k-1];
                a[k-1]=a[k];
                a[k]=temp;
                count++;
                check=1;

            }
        }
    }
    for(i=0;i<n;i++){

        if(i==(n-1))printf("%d",a[i]);
        else {printf("%d",a[i]);printf(" ");}
    }

    printf("\n");
    printf("%d",count);
    printf("\n");
    return 0;

}


Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    double r, g;
    cin>>r>>g;
    cout<<-r+2*g<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  vector<pair<int, int>> c(26);
  vector<vector<int>> s(D, vector<int>(26));
  vector<int> t(D);
  
  cin >> D;
  for(int i = 0; i < 26; i++){
    cin >> c.at(i).first;
    c.at(i).second = 0;
  }
  
  for(int i = 0; i < D; i++){
    for(int j = 0; j < 26; j++){
      cin >> s.at(i).at(j);
    }
  }
  
  for(int i = 0; i < D; i++){
    cin >> t.at(i);
  }
  
  vector<int> M(1);
  cin >> M.at(0);
  vector<pair<int, int>> q(M.at(0));
  
  for(int i = 0; i < M.at(0); i++){
    int a = 0;
    int b = 0;
    cin >> a >> b;
    q.at(i).first = a;
    q.at(i).second = b;
  }

  int Pl = 0;
  int Mi = 0;
  
  for(int k = 0; k < M.at(0); k++){
    t.at(q.at(k).first-1) = q.at(k).second;
    for(int i = 0; i < D; i++){
      Pl += s.at(i).at(t.at(i)-1);
      c.at(t.at(i)-1).second = i + 1;
      for(int j = 0; j < 26; j++){
        Mi += c.at(j).first*(i+1 - c.at(j).second);
      }
      Pl -= Mi;
      Mi = 0;
    }
    cout << Pl << endl;
    Pl = 0;
    for(int i = 0; i < 26; i++){
      c.at(i).second = 0;
    }
  }
}

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


int main(){   
    char n;
    cin >> n;
    
    if(isupper(n)) cout << "A" << endl;
    else cout << "a" << endl;
}


Measured memory_bytes: 3632
use proconio::input;
use std::str::FromStr;

fn main() {
    input! {
        n: usize,
        mut cases: [String; n],
    }

    let mut ac = 0;
    let mut wa = 0;
    let mut tle = 0;
    let mut re = 0;

    for case in cases {
        let j = JudgeResult::from_str(case.trim()).unwrap();
        match j {
            JudgeResult::AC => ac += 1,
            JudgeResult::WA => wa += 1,
            JudgeResult::TLE => tle += 1,
            JudgeResult::RE => re += 1,
        }
    }

    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);
}

enum JudgeResult {
    AC,
    WA,
    TLE,
    RE,
}

impl FromStr for JudgeResult {
    type Err = ();
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "AC" => Ok(JudgeResult::AC),
            "WA" => Ok(JudgeResult::WA),
            "TLE" => Ok(JudgeResult::TLE),
            "RE" => Ok(JudgeResult::RE),
            _ => Err(()),
        }
    }
}


Measured memory_bytes: 7776
def resolve():
    N = int(input())
    R = [int(input()) for _ in range(N)]
    minR, maxR = R[0], -1 * (10**9)
    for i in range(1, N):
        maxR = max(maxR, R[i] - minR)
        minR = min(minR, R[i])
    print(maxR)


resolve()



Measured memory_bytes: 13600
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    string S;
    cin >> S;
    if (S[S.size()-1] == 's') {
        cout << S + "es" << endl;
    } else {
        cout << S + "s" << endl;
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll m,d;
  cin >> m >> d;
  ll juu,ichi,ans=0;
  for(ll i = 1; i<=m; i++){
    for(ll j=1; j<=d; j++){
      juu = j/10;
      ichi = j%10;
      if(j>=10 && ichi>=2 && juu >=2 && ichi*juu == i) ans++;
    }
  }
  cout << ans;
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a;
  d=a%10;
  c=(a%100-d)/10;
  b=(a%1000-c*10-d)/100;
  a/=1000;
  for(int i=0;i<8;++i)
  {
    int x,y,z;
    x=i%2;
    y=(i>>1)%2;
    z=(i>>2)%2;
    if(x==1)x=-1;
    else x=1;
    if(y==1)y=-1;
    else y=1;
    if(z==1)z=-1;
    else z=1;
    if(a+x*b+y*c+z*d==7)
    {
        cout << a << (x==1?"+":"-") << b << (y==1?"+":"-") << c << (z==1?"+":"-") << d << "=7" << "\n";
        return 0;
     }
  }
}

Measured memory_bytes: 256
// Justice will be served
// شهید حاج قاسم سلیمانی

#include <bits/stdc++.h>
using namespace std ;

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

#define PB push_back
#define F first
#define S second
#define _sz(x) (int)x.size()

#define debug(x) cerr << #x << " = " << x << endl

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

const int MAX_N = -1 ;
const int inf = 2e9 + 19 ;

int main() {
        ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;
        int n ;
  		cin >> n ;
        cout << n * n * n ;
        return (0) ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a;
int main()
{
	cin>>a;
	int ls,ls1;
	for(int i=0;i<a.length();i++)
	{
		if(a[i]=='C')
		{
			ls=i;
			break;
		}
	}
	for(int i=0;i<a.length();i++)
	{
		if(a[i]=='F')
		{
			ls1=i;
			if(ls1>ls)
			{
				cout<<"Yes";
				break;
			}
			else if(ls1<ls)
			{
				continue;
			}
		}
		if(i==a.length()-1)
		{
			cout<<"No";
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Network{
	private:
	int V;
	struct edge{
		ll to,cap,rev;
	};
	vector<vector<edge> > g;
	ll DFS(int v,int t,ll f,vi& iter,vi level){
		if(v==t) return f;
		for(int &i=iter[v];i<g[v].size();i++){
			edge &e=g[v][i];
			if(e.cap>0&&level[v]<level[e.to]){
				ll d=DFS(e.to,t,min(f,e.cap),iter,level);
				if(d>0){
					e.cap-=d;
					g[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	void BFS(int s,vi& level){
		level=vi(V,-1);
		queue<int> que;
		level[s]=0;
		que.push(s);
		while(!que.empty()){
			int v=que.front();
			que.pop();
			for(int i=0;i<g[v].size();i++){
				edge &e=g[v][i];
				if(e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	public:
	Network(int v){
		V=v;
		g=vector<vector<edge> >(v);
	}
	void add_edge(int s,int t,ll c){
		g[s].push_back(edge{t,c,(int)g[t].size()});
		g[t].push_back(edge{s,0,(int)g[s].size()-1});
	}
	ll Dinic(int s,int t){
		ll res=0;
		while(1){
			vi iter(V),level;
			BFS(s,level);
			if(level[t]<0) return res;
			ll f;
			while((f=DFS(s,t,inf,iter,level))>0) res+=f;
		}
	}
};

int n;

int main(){
	cin>>n;
	Network g(n+2);
	ll res=0;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		if(a>=0){
			g.add_edge(0,i,0);
			g.add_edge(i,n+1,a);
			res+=a;
		}
		else{
			g.add_edge(0,i,-a);
			g.add_edge(i,n+1,0);
		}
		for(int j=2*i;j<=n;j+=i) g.add_edge(i,j,INF);
	}
	cout<<res-g.Dinic(0,n+1)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int Y[]={1,0,-1,0};
int X[]={0,1,0,-1};
int main(){
  int w,h,i,j,k;
  char s[110][110]={};
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++)scanf("%s",s[i+1]+1);
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      if(s[i][j]-'#')continue;
      for(k=0;k<4;k++){
	if(s[i+Y[k]][j+X[k]]=='#')goto NEXT;
      }
      printf("No\n");
      return 0;
    NEXT:;
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define fs first 
#define sc second 
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
using namespace std;
ll n, m, k, t;

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


int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll sim = 0;
	cin >> m>>n;
	unordered_map<ll, ll> a;
	string t;
	ll l = 0, r = 0;
	for (int i = 0; i < n; i++) {
		cin >> k >> t;
		if (t == "AC") {
			if (a[k] == -1)continue;
			l++; r += a[k]; a[k] = -1;
		}
		if (t == "WA") {
			if (a[k] != -1)a[k]++;
		}
	}
	cout << l << ' ' << r;

}


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

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

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, q;
	cin >>n >>q;
	using T3 = tuple<ll, int, ll>;
	vector<T3> dt;
	rep(i, n){
		int s, t, x;
		cin >>s >>t >>x;
		dt.emplace_back(s-x, 1, x);
		dt.emplace_back(t-x, 5, x);
	}
	rep(i, q){
		int d; cin >>d;
		dt.emplace_back(d,  9, i);
	}
	sort(all(dt));
	VL ans(q);
	multiset<ll> mst;
	for(auto& z: dt){
		ll a, b, c;
		tie(a, b, c) = z;
		dbg(a,b,c);
		if(b==1) mst.insert(c);
		else if(b==5) mst.erase(mst.lower_bound(c));
		else ans[c] = sz(mst)? *mst.begin(): -1;
	}
	for(auto z: ans) cout<< z <<"\n";
	
	return 0;
}


Measured memory_bytes: 28260
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 10000
#define INF 10001000

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,a,n) for(int i = a; i < (n); i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll; 

int main()
{
    int n, x;
    int ans = 0;

    cin >> n >> x;

    vector<int> l(n);
    vector<int> d(n+1,0);
    
    rep(i,n) {
        int tmp;
        cin >> tmp;
        l[i] = tmp;
    }

    rep2(i,1,n+1){ d[i] = d[i-1] + l[i-1]; }
    rep2(i,0,n+1){ 
        if(d[i] <= x) { ans++; } 
        else { break; }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n, k = gets.split(' ').map(&:to_i)
arr = gets.split(' ').map(&:to_i)
 
ds = [0]
(1...n).each do |i|
  m = nil
  [0, i-k].max.upto(i-1) do |j|
    tmp = ds[j] + (arr[j] - arr[i]).abs
    m = tmp if !(m && m < tmp)
  end
  ds << m
end

puts ds[-1]

Measured memory_bytes: 11524
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

using P = pair<int,int>;

P merge(P a, P b) {
  int sum = a.second + b.second;
  if (a.second < b.first) return make_pair(b.first - a.second, sum);
  if (b.second < a.first) return make_pair(a.first - b.second, sum);
  return make_pair(a.first & b.first & 1, sum);
}

vector<int> g[128000];
ll A[128000];
bool visited[128000];
bool flag;

ll dfs(int v) {
  visited[v] = true;
  if (g[v].size() == 1) return A[v];
  vector<ll> vec;
  for (int i: g[v]) {
    if (visited[i]) continue;
    vec.push_back(dfs(i));
  }
  sort(ALL(vec));
  ll sum = accumulate(ALL(vec), 0LL);
  ll res = 2 * A[v] - sum;
  if (A[v] > sum || res < 0) flag = false;
  if (vec.back() * 2 > sum + res) flag = false;
  // cout << v << " " << res << endl;
  return res;
}

void solve(ll N, vector<ll> a, vector<ll> b) {
  REP(i,N-1) {
    int s = a[i] - 1, t = b[i] - 1;
    g[s].push_back(t);
    g[t].push_back(s);
  }
  int root = -1;
  REP(i,N) if (g[i].size() > 1) root = i;
  if (root == -1) { cout << (N == 2 && A[0] == A[1]) << endl; return; }
  flag = true;
  // cout << root << endl;
  if (dfs(root) != 0) flag = false;
  cout << flag << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> a((N-1)-1+1);
	vector<ll> b((N-1)-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &A[i]);
	}
	for (int i = 0 ; i <= (N-1)-1 ; i++) {
	  scanf("%lld", &a[i]);
	  scanf("%lld", &b[i]);
	}
	solve(N, a, b);
	return 0;
}


Measured memory_bytes: 18944
#include <cstdio>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <queue>
#include <utility>
#include <stack>

using namespace std;

typedef long long Long;

#define MN 100000
#define MQ 100000
int N, Q;
int parent[MN + 1];
bool marked[MN + 1];
pair<int, int> queries[MQ];
int group[MN + 1];

int fillGroup(int n) {
    if (group[n] >= 1) return group[n];
    return group[n] = fillGroup(parent[n]);
}
int findGroup(int n) {
    if (marked[ group[n] ]) return group[n];
    return group[n] = findGroup(parent[n]);
}

bool input() {
    scanf("%d %d", &N, &Q);
    if (N == 0 && Q == 0) return false;
    if (getchar() == EOF) return false;
    for (int i = 2; i <= N; i++) {
        int p;
        scanf("%d", &p);
        parent[i] = p;
    }
    memset(marked, false, N + 1);
    marked[1] = true;
    memset(group, 0, sizeof(int) * (N + 1));
    group[1] = 1;
    for (int i = 0; i < Q; i++) {
        char t; int n;
        scanf("%*[ \t\r\n]%c %d", &t, &n);
        if (t == 'M') {
            if (marked[n]) {
                queries[i] = make_pair('X', 0);
                continue;
            }
            marked[n] = true;
            group[n] = n;
        }
        queries[i] = make_pair(t, n);
    }
    for (int i = 1; i <= N; i++) {
        if (group[i] <= 0) fillGroup(i);
    }
    return true;
}

void solve() {
    Long ans = 0;
    for (int q = Q - 1; q >= 0; q--) {
        pair<int, int> query = queries[q];
        if (query.first == 'Q') {
            ans += findGroup(query.second);
        } else if (query.first == 'M') {
            marked[query.second] = false;
        }
        //for (int i = 1; i <= N; i++) cout << setw(3) << group[i]; cout << endl;
    }
    printf("%lld\n", ans);
}

int main() {
    while (input()) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3476
#include <iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    int L[N];
    int a=1;
    long long sum=0;
    for(int i=0;i<N;i++){
        cin>>L[i];
        if(a<L[i]){
            a=L[i];
        }sum +=L[i];
    }
    sum=sum-a;
    if(a>=sum){
        cout<<"No"<<endl;
    }else if(a<sum){
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b;
  cin>>a>>b;
  if(a<=b){
    cout<<a<<endl;
  }else{
    cout<<a-1<<endl;
  }
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(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 ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
    int N;
    while (cin >> N, N) {
        int minx = 0, maxx = 0;
        int miny = 0, maxy = 0;
        vector<pii> square(N);
        square[0] = {0, 0};
        FOR(i, 1, N) {
            int n, d;
            cin >> n >> d;
            int x = square[n].first + dx[d], y = square[n].second + dy[d];
            square[i] = {x, y};
            minx = min(minx, x);
            maxx = max(maxx, x);
            miny = min(miny, y);
            maxy = max(maxy, y);
        }
        cout << 1 + maxx - minx << " " << 1 + maxy - miny << endl;
    }
}

Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>


using namespace std;



int main() {

	int A, B, C, X, count=0;

	cin >> A >> B >>C >>X;

	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) count++;
			}
		}
	}

	cout << count;

	return 0;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    N, x = map(int, input().strip().split())
    A = map(int, input().strip().split())
    return N, x, A


def solve(N, x, A):
    count = 0
    for a in sorted(A):
        x -= a
        if x < 0:
            break
        count += 1
    if x > 0:
        count -= 1
    return max(count, 0)


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> list(3);
  for (int i=0; i<3; i++) {
    int t;
    cin >> t;
    list.at(i) = t;
  }
  sort(list.begin(),list.end());
  int a = list.at(0)+list.at(1)+list.at(2)*10;
  cout << a << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ab = br.readLine().split(" ");
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        System.out.println(problem109a(a, b));
    }

    private static String problem109a(int a, int b) {
        for (int c = 1; c <= 3; c++) {
            int times = a * b * c;
            if (times % 2 == 1) {
                return "Yes";
            }
        }
        return "No";
    }
}

Measured memory_bytes: 25324
#include<stdio.h>

int S[10000];
int T[500],n,q;
int linearsearch(int x){
  int i=0;
  S[n]=x;
  while(S[i]!=x){
    i++;
    if(i==n)return 0;
  }
  return 1;
}
     
int main()
{
  int i,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    count+=linearsearch(T[i]);
  }
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________


	ld a, v, b, w;
	cin >> a >> v >> b >> w;
	cout << fixed << setprecision(10);
	ld t;
	cin >> t;
	if (v == w && a != b)
	{
		cout << "NO" << en;
	}
	// else if (a > b)
	// {
	// 	cout << "NO" << en;
	// }
	else if (a < b && v < w)
	{
		cout << "NO" << en;
	}
	else if (a > b && v < w)
	{
		cout << "NO" << en;
	}
	else
	{
		ld x = abs(a - b) / abs(w - v);
		if (x <= t)
		{
			cout << "YES" << en;
		}
		else
		{
			cout << "NO" << en;
		}
	}

	return 0;
}



Measured memory_bytes: 3748