akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    vector<int> ans(26,0);
    char c;
    while(scanf("%c",&c)!=EOF){
        if(c>='a'&&c<='z')ans[c-'a']++;
        if(c>='A'&&c<='Z')ans[c-'A']++;
    }
    c='a';
    rep(i,26){
        printf("%c : %d\n",c+i,ans[i]);
    }
}


Measured memory_bytes: 3200
N=int(input())
A=list(map(int,input().split()))
import math
a=A[0]
for i in range(1,N):
  a=math.gcd(a,A[i])
def f():
  a=A[0]
  for i in range(1,N):
    a=math.gcd(a,A[i])
  if a==1:
    print("setwise coprime")
    exit()
  else:
    print("not coprime")
    exit()
  
D=[0]*(10**6+1)
for i in range(2,10**6+1):
  for j in range(2*i,10**6+1,i):
    if D[j]==0:
      D[j]=i
for i in range(10**6+1):
  if D[i]==0:
    D[i]=i

s=set()
import copy
for i in range(N):
  tmp=set()
  k=A[i]
  while k>1:
    tmp.add(D[k])
    k=k//D[k]
  for i in tmp:
    if i in s:
      f()
    else:
      s.add(i)


print("pairwise coprime")


Measured memory_bytes: 189716
import java.util.Scanner;

// Integral Rectangles
public class Main {

	public void run() {
		Scanner sc = new Scanner(System.in);
		for(;;){
			int h = sc.nextInt(), w = sc.nextInt();
			if((h|w)==0)break;
			int H = 150, W = 150;
			for(int y=1;y<=150;y++)for(int x=y+1;x<=150;x++){
				if (0 < comp(y, x, h, w) && comp(y, x, H, W) < 0){
					H = y; W = x;
				}
			}
			System.out.println(H+" "+W);
		}
	}
	
	public int comp(int y, int x, int h, int w){
		if (h*h + w*w != y*y + x*x) return y*y+x*x - (h*h+w*w);
		return y-h;
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 20436
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n;
string s;

signed main(){
    cin >> n >> s;
    ll ret = 0;
    for(int i=0; i<s.size()-2; i++){
        if(s[i]=='A')
        if(s[i+1]=='B')
        if(s[i+2]=='C') ret++;
    }
    cout << ret << endl;
    return 0;
}

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

typedef long long ll;

vector<ll> A;

int solve(int dp[], ll k) {
    // bcout << dp[k] << " : " << k << endl;
    if (dp[k] != 0) {
        return dp[k];
    }

    for (ll i = 0; i < A.size(); i++) {
        if (k - A[i] < 0) {
            continue;
        } else {
            if (solve(dp, k - A[i]) == 2) {
                dp[k] = 1;
                return dp[k];
            }
        }
    }

    dp[k] = 2;
    return dp[k];
}

int main() {
    ll N, K;
    cin >> N >> K;

    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }

    int dp[K + 1];
    // memset(dp, 0, sizeof(dp));
    for (ll i = 0; i < K + 1; i++) {
        dp[i] = 0;
    }
    dp[0] = 2;


    if (solve(dp, K) == 1) {
        cout << "First";
    } else {
        cout << "Second";
    }
    return 0;
}

Measured memory_bytes: 5376
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args){

		solve_abc163_b();
	}
  
  
	public static void solve_abc163_b(){

		FastScanner sc = new FastScanner(System.in);
		
		long n = sc.nextLong();
		int m = sc.nextInt();
		
		for(int i=0;i<m;i++){
			
			n = n - sc.nextLong();
		}
		
		
		if(n < 0) n = -1;
		
		System.out.println(n);


	}
}

Measured memory_bytes: 27748
N = int(input())
F = [[int(i) for i in input().split()] for j in range(N)]
P = [[int(i) for i in input().split()] for j in range(N)]

ci = 0
c = []
P_max = -1000000000
for i in range(2):
    for j in range(2):
        for k in range(2):
            for l in range(2):
                for m in range(2):
                    for n in range(2):
                        for o in range(2):
                            for p in range(2):
                                for q in range(2):
                                    for r in range(2):
                                        if i==0 and j==0 and k==0 and l==0 and m==0 and n==0 and o==0 and p==0 and q==0:
                                            r = 1
                                        P_sample = 0
                                        for s in range(N):
                                            ci = F[s][0]*i + F[s][1]*j + F[s][2]*k + F[s][3]*l + F[s][4]*m + F[s][5]*n + F[s][6]*o + F[s][7]*p + F[s][8]*q + F[s][9]*r
                                            P_sample += P[s][ci]
                                        P_max = max(P_max, P_sample)

print(P_max)


Measured memory_bytes: 9288
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        ArrayList<Integer> listx = new ArrayList<Integer>();
        ArrayList<Integer> listy = new ArrayList<Integer>();

        for(int i=0; i<N; i++){
            listx.add(sc.nextInt());
        }
        listx.add(X);
        for(int i=0; i<M; i++){
            listy.add(sc.nextInt());
        }
        listy.add(Y);

        Collections.sort(listx);
        Collections.sort(listy);
       
        if(listx.get(N)>=listy.get(0)){
            System.out.println("War");
        }
        else{
            System.out.println("No War");
        }
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int K; cin >> K;
  int A, B; cin >> A >> B;
  int i = 1, C = K * i;
  while(C <=1000){
    if(C >= A && C <= B){
      cout << "OK" << endl;
      return 0;
    }
    i++;
    C = K * i;
  }
  cout << "NG" << endl;
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	string ans = "AC";

	if (s.at(0) != 'A') { ans = "WA"; }

	if (isupper(s.at(1)) || isupper((s.at(s.size() - 1))))
	{
		ans = "WA";
	}

	int count = 0;
	for (int i = 2; i < s.size() - 1; i++)
	{
		
		if (isupper(s.at(i)))
		{
			if (s.at(i) == 'C')
			{
				count++;
			}
		}
	}
	if (count != 1)
	{
		ans = "WA";
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#Write and Erase
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())
A.sort()
n = 1
p = 0
for i in range(N-1):
    if A[i] != A[i+1]:
        n = n + 1
        p = 0
    else:
        if p == 0:
            n = n - 1
            p = p + 1
        else:
            n = n + 1
            p = p - 1
print(n)

Measured memory_bytes: 7396
#include "iostream"
#include "sstream"
#include "string"
#include "cstring"
#include "cstdio"
#include "cstdlib"
#include "cmath"
#include "algorithm"
#include "utility"
#include "vector"
#include "map"
#include "unordered_map"
#include "set"
#include "bitset"
#include "unordered_set"
#include "list"
#include "deque"
#include "functional"
#include "ctime"
#include "tuple"
#include "memory"
#include "limits"
#include "stack"
#include "forward_list"
#include "iterator"
#include "array"
#include "random"
#include "queue"


using namespace std;

// Functions
vector<string> StrSplit(string work, char delim, int rep);

template <typename T, typename Display> 
void print_vector(const vector<T>& vec, Display disp);

vector<string> StrSplit(string work, char delim, int rep = 0) {
    // rep == 1: Also insert empty strings
    vector<string> flds;
    if (!flds.empty()) flds.clear();  // empty vector if necessary
    string buf = "";
    int i = 0;
    while (i < work.size()) {
        if (work[i] != delim)
            buf += work[i];
        else if (rep == 1) {
            flds.push_back(buf);
            buf = "";
        } else if (!buf.empty()) {
            flds.push_back(buf);
            buf = "";
        }
        i++;
    }
    if (!buf.empty())
        flds.push_back(buf);
    cout << flds.size() << endl;
    return flds;
}

template <typename T, typename Display> 
void print_vector(const vector<T>& vec, Display disp) {
    for (const auto& val:vec) {
        disp(val);
    }
}

class Point {
public:
    typedef int pos_type;
    pos_type x,y;
    explicit Point(pos_type x_in, pos_type y_in):x(x_in), y(y_in) {}
    explicit Point():x(), y() {}
    bool operator < (const Point& other) const {
        if (x != other.x) return x < other.x;
        return y < other.y;
    }
    bool operator == (const Point& other) const {
        return x == other.x && y == other.y;
    }
    void print() {
        // for debug
        cout << "(" << x << "," << y << ")";
    }
};

#define MP make_pair
#define debug false
#define UNM unordered_map
#define UNS unordered_set

typedef vector<int> VI;
typedef vector<VI> Mat;
typedef pair<int,int> PI;

class Solution {
public:
    void solve() {
        const string A = "CODEFESTIVAL2016";
        string str;
        while (cin >> str) {
            int ans = 0;
            int N = str.size();
            for (int i = 0; i < N; ++i) {
                if (A[i] != str[i]) ans++;
            }
            cout << ans << endl;
        }
    }
};


int main() {
    Solution sol;
    sol.solve();
    return 0;
}


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

int main() {
  int k, q;
  scanf("%d %d", &k, &q);
  vector<int> d(k);
  for (int i = 0; i < k; i++) 
    scanf("%d", &d[i]);
  
  for (int i = 0; i < q; i++) {
    int n, x, m;
    scanf("%d %d %d", &n, &x, &m);
    
    vector<int> a(k), b(k);
    int eq = d[0] % m == 0;
    b[0] = d[0] % m;
    for (int j = 1; j < k; j++) {
      b[j] = b[j - 1] + d[j] % m;
      a[j] = a[j - 1] + b[j] / m;
      b[j] = b[j] % m;
      if (d[j] % m == 0) eq++;
    }
    
    int rounds = (n - 1) / k;
    long long sa = 1LL * a.back() * rounds;
    long long sb = x % m + 1LL * b.back() * rounds;
    if ((n - 1) % k > 0) {
      sa += a[(n - 1) % k - 1];
      sb += b[(n - 1) % k - 1];
    }
    sa += sb / m;

    int ans = n - 1 - sa - eq * rounds;
    for (int j = 0; j < (n - 1) % k; j++)
      if (d[j] % m == 0) ans--;
    printf("%d\n", ans);
  }

  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<string> data_1(N);
	vector<int> data_2(N);

	for (int i = 0;i < N;i++) {
		cin >> data_1[i] >> data_2[i];
	}

	vector<int>ans(N);
	int count;
	for (int i = 0;i < N;i++) {
		count = N - 1;
		for (int j = 0;j < N;j++) {
			if (data_1[i] < data_1[j]) {
				count--;
			}
			else if (data_1[i] == data_1[j]) {
				if (data_2[i] > data_2[j]) {
					count--;
				}
			}
		}
		ans[count] = i+1;
	}

	for (int i = 0;i < N;i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	list := make([]int, n+1)
	list[0] = 2
	list[1] = 1
	for i := 2; i <= n; i++ {
		list[i] = list[i-2] + list[i-1]
	}
	fmt.Println(list[n])

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define _for(i, a, b) for (int i = (a); i < (b); i++)
#define _count(i, a, b) for (int i = (a); i <= b; i++)
#define PB emplace_back
#define MINI -2147483648
#define MAXI 2147483647
#define MAXLL 9223372036854775807
#define MINLL -9223372036854775808
#define VI vector<int>
#define VB vector<bool>
#define VLL vector<long long>
#define LL long long
#define ULL unsigned long long
#define ALL(X) X.begin(), X.end() 
#define pii pair<int, int>
#define F first
#define S second
#define mp make_pair
//#define Remilia_is_so_cute
#define StarBurst std::ios::sync_with_stdio(false),cin.tie(NULL);
#define lowerBit(x) x&-x
using namespace std;
 
inline void R_P(vector<int> &vec) {
  int temp;
  cin>>temp;
  vec.push_back(temp);
} 
inline bool checkMax(int &base, int test) {
  return (test > base) ? base = test, true : false; 
}
 
inline bool checkMin(int &base, int test){
  return (test < base)? base = test, true : false;
}
template <class T>
void test(vector<T> &vec, const string &warn) {
  cout<<warn<<'\n';
  _for(i, 0, vec.size())
    cout<<vec[i]<<' ';
  cout<<"\nTest end..............\n";
}
 
int main () {
  StarBurst
  #ifdef Remilia_is_so_cute
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  
  int d, t, s; cin >> d >> t >> s;
  if (t * s >= d)
    cout << "Yes\n";
  else
    cout << "No\n";
 
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

// [left, right) の乱数生成
template<class T> T randrange(T left, T right) {
    static mt19937 mt{ std::random_device{}() };
    uniform_real_distribution<double> rnd(left, right);
    return (is_integral<T>::value ? floor(rnd(mt)) : rnd(mt));
}

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

    vector<double> x(n), y(n);
    for(lint i=0; i<n; i++)  cin >> x[i] >> y[i];

    auto dist = [&](double cx, double cy) {
        double res = -1e18;
        for(lint i=0; i<n; i++)  res = max(res, hypot(x[i]-cx, y[i]-cy));
        return res;
    };

    double cx = 0, cy = 0, r = 1;
    for(lint _=0; _<1e6; _++) {
        double nx = cx + randrange(-r, r);
        double ny = cy + randrange(-r, r);

        if(dist(nx, ny) < dist(cx, cy))  cx = nx, cy = ny;
        r *= 0.99999;
    }

    cout << setprecision(18) << fixed;
    cout << dist(cx, cy) << endl;
}

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

int main()
{
  string s;
  cin>>s;
  
  if(s=="SUN")
    cout<<7<<endl;
  else if(s=="MON")
    cout<<6<<endl;
  else if(s=="TUE")
    cout<<5<<endl;
  else if(s=="WED")
    cout<<4<<endl;
  else if(s=="THU")
    cout<<3<<endl;
  else if(s=="FRI")
    cout<<2<<endl;
  else if(s=="SAT")
    cout<<1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>

typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    vector<int> g[n];
    vector<pair<int,int>> edge;
    repi(i, n, 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
        edge.push_back({a,b});
    }

    queue<int> q;
    vector<int> used(n,0);
    vector<int> parent(n,0);
    int max_color = 0;
    map<pair<int,int>,int> edge_color;
    q.push(0);
    used[0] = 1;
    while(!q.empty()){
        int now = q.front();
        q.pop();
        int color_num = 0;
        for(auto next : g[now]){
            if(used[next] != 1){//色を塗っていない
                color_num++;
                used[next] = 1;
                if(color_num == parent[now]){
                    color_num++;
                }
                edge_color[{now,next}] = color_num;
                parent[next] = color_num;
                q.push(next);
            }
        }
        max_color = max(max_color,color_num);
    }
    cout << max_color << endl;
    for(auto i : edge){
        cout << edge_color[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 13812
kinds = Hash.new(0)

n, k = gets.split.map(&:to_i)
gets.split.each {|a| kinds[a.to_i] += 1}

tmp = kinds.map {|a, b| b}.sort_by {|e| -e}.drop(k)

puts tmp.empty? ? 0 : tmp.inject(&:+)

Measured memory_bytes: 36996
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def make_divisors(n: int):
    lower_divs = []
    upper_divs = []
    i = 1
    while i**2 <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n // i)
        i += 1
    return lower_divs + upper_divs[::-1]


def main():
    n = input_int()
    divs = make_divisors(n)
    ans = 0
    for div in divs:
        m = (n // div) - 1
        if m == 0:
            continue
        if n // m == n % m:
            ans += m
    print(ans)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 65896
N = int(input())
A = list(map(int, input().split()))
if N % 2 == 0:
    NINF = -(10 ** 16)
    dp = [[NINF for j in range(2)] for i in range(N)]
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    for i in range(N):
        if i - 2 >= 0:
            if dp[i - 2][0] != NINF:
                dp[i][0] = dp[i - 2][0] + A[i]
            if dp[i - 2][1] != NINF:
                dp[i][1] = dp[i - 2][1] + A[i]
        if i - 3 >= 0:
            dp[i][1] = max(dp[i][1], dp[i - 3][0] + A[i])

    res = max(dp[N - 1][1], dp[N - 2][0])
else:
    NINF = -(10 ** 16)
    dp = [[NINF for j in range(3)] for i in range(N)]
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    dp[2][2] = A[2]
    for i in range(N):
        if i - 2 >= 0:
            if dp[i - 2][0] != NINF:
                dp[i][0] = dp[i - 2][0] + A[i]
            if dp[i - 2][1] != NINF:
                dp[i][1] = dp[i - 2][1] + A[i]
            if dp[i - 2][2] != NINF:
                dp[i][2] = dp[i - 2][2] + A[i]
        if i - 3 >= 0:
            dp[i][1] = max(dp[i][1], dp[i - 3][0] + A[i])
            dp[i][2] = max(dp[i][2], dp[i - 3][1] + A[i])
        if i - 4 >= 0:
            dp[i][2] = max(dp[i][2], dp[i - 4][0] + A[i])

    res = max(dp[N - 1][2], dp[N - 2][1], dp[N - 3][0])

print(res)


Measured memory_bytes: 117332
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
using namespace std;
int a[4][4];
int main()
{
	for (int i = 1; i <= 3; i++)
		for (int j = 1; j <= 3; j++)
			cin >> a[i][j];
	for (int k = -2000; k <= 2000; k++) {
		int a2, a3, b1, b2, b3;
		int a1 = k;
		b1 = a[1][1] - k;
		b2 = a[1][2] - k;
		b3 = a[1][3] - k;
		a2 = a[2][1] - b1;
		a3 = a[3][1] - b1;
		int flag = 0;
		if (a[2][2] != a2 + b2) 
			flag = 1;
		if (a[2][3] != a2 + b3) 
			flag = 1;
		if (a[3][2] != a3 + b2) 
			flag = 1;
		if (a[3][3] != a3 + b3) 
			flag = 1;
		if (!flag) 
		{
			cout << "Yes" << endl; 
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 1e9;
    for (int si = 0; si < s.size(); si++) {
        if (si + t.size() > s.size()) {
            break;
        }
        int cnt = 0;
        for (int i = 0; i < t.size(); i++) {
            if (s[si + i] != t[i]) {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int n,k,ev;
ll ret,evr;

int main(){
    I(n); I(k);
    ret = n/k;
    ret *= n/k;
    ret *= n/k;

    if (k%2==0){
        REP(i,n+1){
            if (i%k == k/2) ev++;
        } 
        evr = ev;
        evr *= ev;
        evr *= ev;
        ret += evr;
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int traveral(string);
int main()
{
    string s;
    cin>>s;
    if(traveral(s)) cout<<"Yes";
    else            cout<<"No";
    return 0;
}
int traveral(string s)
{
    int i,j;
    for(i = 0;i < s.length();i++)
    {
        if(s[i] == 'C')
        {
            for(j = i+1 ;j < s.length(); j++)
            {
                if(s[j] == 'F')
                {
                    return 1;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
/*int mainn(){
    int x;cin>>x;
    if(x==0)cout<<1<<endl;
    else if(x==1)cout<<0<<endl;
    return 0;
}
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    max(a*b,max(c*d,max(a*)))
}
*/
ll modexp(ll x,ll y){
    if(y==0)return 1%mod;
    ll ans=modexp(x,y/2)%mod;
    ans=((ans%mod)*(ans%mod))%mod;
    if(y&1)ans=((x%mod)*(ans%mod))%mod;
    return ans%mod;
}
int main(){
    ll N;cin>>N;
    ll ans=0;
    ans+=modexp(10,N)%mod;
    ans=((ans%mod)-((2*modexp(9,N))%mod))%mod;
    ans=(ans+mod)%mod;
    ans=((ans%mod)+(modexp(8,N)%mod))%mod;
    cout<<ans<<endl;
}

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

int main() {
	int N;
	cin >> N;
	
    vector<int> di;
    rep(i,N){
        int tmpdi;
        cin >> tmpdi;
        di.push_back(tmpdi);
    }
    
    sort(di.begin(),di.end());

    int K_MAX = di.at(N/2);
    int K_MIN = di.at((N/2) - 1);

    cout << K_MAX - K_MIN << endl;
	return 0;
}


Measured memory_bytes: 892
Option Strict On
Module Module1

    Sub Main()
        Dim s As String = Console.ReadLine()
        Dim len As Integer = Strings.Len(s)
        ' Console.WriteLine(len)
        'Console.ReadLine()
        Dim counter0 As Integer = 0
        Dim counter1 As Integer = 0
        Dim color As String = "0"
        For i As Integer = 0 To len - 1
            If Mid(s, i + 1, 1) <> color Then
                counter0 += 1
            End If
            If color = "0" Then
                color = "1"
            Else
                color = "0"
            End If
        Next
        color = "1"
        For i As Integer = 0 To len - 1
            If Mid(s, i + 1, 1) <> color Then
                counter1 += 1
            End If
            If color = "0" Then
                color = "1"
            Else
                color = "0"
            End If
        Next
        If counter0 < counter1 Then
            Console.WriteLine(counter0)
        Else
            Console.WriteLine(counter1)
        End If
        Console.ReadLine()
    End Sub

End Module

Measured memory_bytes: 24792
#include <bits/stdc++.h>
 
using namespace std;
 
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-8;
const double pi=acos(-1.0);
const int K=1e6+7;
const int mod=1e9+7;
 
int r,c,n,x,y,ans[200][200];
 
int main(void)
{
    scanf("%d%d%d",&r,&c,&n);
    y=1,x=1;
    for(int i=1,cnt;i<=n;i++)
    {
        scanf("%d",&cnt);
        while(cnt--)
        {
            ans[x][y]=i;
            if(y==c&&x%2==1)
                y=c,x++;
            else if(y==1&&x%2==0)
                y=1,x++;
            else if(x&1)
                y++;
            else
                y--;
        }
    }
    for(int i=1;i<=r;i++)
    for(int j=1;j<=c;j++)
        printf("%d%c",ans[i][j],j==c?'\n':' ');
    return 0;
}

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

int main() {
    int x, y, z, v[4], a[55], b[55];
    while(cin >> x >> y >> z, x){
        for(int i=0;i<x;i++){
            cin >> v[i];
        }
        fill(a,a+y+1,0);
        fill(b,b+y+1,0);
        for(int i=0;i<z;i++){
            int n, e, w;
            cin >> n >> e >> w;
            if(e==1){
                b[n] = w;
            }
            else if(e==2){
                a[n] = w;
            }
            else{
                a[n] = -w;
            }
        }
        double dp[55][5005]{};
        dp[0][0] = 1;
        for(int i=0;i<y;i++){
            for(int j=0;j<=5000;j++){
                for(int k=0;k<x;k++){
                    int ni = min(i+v[k], y);
                    int nj = max(j+a[ni], 0);
                    ni = min(ni+b[ni], y);
                    dp[ni][nj] += dp[i][j]/x;
                }
            }
        }
        double ans = 0;
        for(int i=0;i<=5000;i++){
            ans += dp[y][i]*i;
        }
        cout << int(ans) << endl;
    }
    
    return 0;
}



Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
#define bug(a)       cerr << #a << " : " << a << endl;
#define md 1000000007
#define itc(n) char(n+48)
#define cti(ch) (ch-48)
#define pb push_back
template<class T>void ExEuclid(T n, T m, T &a, T &b, T &gcd){if(m==0){gcd=n;a=1;b=0;return;}ExEuclid(m,n%m,a,b,gcd);T x=a;a=b;b=x-(n/m)*a;}
template<class T>T gcd(T n, T m){if(m==0){return n;}gcd(m,n%m);}
template<class T>T lcm(T n, T m){return (n*m)/gcd(n,m);}
template<class T>string to_string(T n){ostringstream convert;convert<<n;return convert.str();}
template<class T>ll to_int(T s){ll num=0,power=0;for(int i=s.size()-1; i>=0; i--)num+=(pow(10.0,power++)*(s[i]-'0'));return num;}
template<class T>bool is_mod(T n, T m){if(n%m==0)return true;return false;}
template<class T>bool is_upper(T s){for(int i=0; i<s.size(); i++)if(s[i]>90 || s[i]<65)return false;return true;}
template<class T>bool is_lower(T s){for(int i=0; i<s.size(); i++)if(s[i]>122 || s[i]<97)return false;return true;}
template<class T>bool is_palindrome(T s){T s1=s;reverse(s1.begin(),s1.end());if(s==s1)return true;return false;}
template<class T>int digit_sum(T s){int sum=0; for(int i=0; i<s.size(); i++)sum+=cti(s[i]);return sum;}
template<class T>T mod(T n, T m){return ((n%m)+m)%m;}
template<class T>T Big_mod(T base, T power, T MOD){
    if(power==1)return base;
    if(power & 1)return ((base%MOD)*(Big_mod(base,power-1,MOD))%MOD)%MOD;
    else {T temp=(Big_mod(base,power>>1,MOD));return ((temp%MOD)*(temp%MOD))%MOD;}
}
template<class T>T doStringSum(T s1, T s2){int len1=s1.length(), len2=s2.length();
    if(len1<len2)return doStringSum(s2, s1);
    T ans="";int carry=0, i, s;
    for(i=1;i<=len1;i++){s = carry+cti(s1[len1-i]);if(i<=len2)s += cti(s2[len2-i]);
    ans = itc(s%10)+ans;carry = s/10;}if(carry!=0)ans = itc(carry)+ans;
    return ans;
}
template<class T>T dostringmultiply(T s1, T s2){int len1=s1.length(), len2=s2.length();
    if(len1<len2)return dostringmultiply(s2,s1);
    int i,j,p, carry=0;T result, net="", c;
    for(i=len2-1;i>=0;i--){carry=0;result="";c="";
    for(j=len1-1;j>=0;j--){p=cti(s1[j])*cti(s2[i]);result = itc((p+carry)%10)+result;carry=(p+carry)/10;}
    if(carry!=0){c=to_string(carry);result=c+result;}
    for(j=i;j<len2-1;j++)result+="0";net=doStringSum(net,result);}
    return net;
}
template<class T>T nCr(T n, T r)
    {if(r > n - r) r = n - r;T ans = 1;T i;
    for(i = 1; i <= r; i++){ans *=(n-r+i);ans%=md;ans /= i;}
    return ans%md;
}

int main()
{
    fast;

    string s;
    cin>>s;
    int cnt=0;
    for(int i=0; i<s.size(); i++)if(s[i]=='x')cnt++;
    if(cnt<8)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n, num[100000] = {0}, minus = 0, min = 1000000000;
	long long ans = 0;
	scanf("%d", &n);getchar();
	for(int i = 0; i < n; i++){
		scanf("%d", &num[i]);getchar();
		if(num[i] < 0){
			minus++;
			num[i] *= -1;
		}
		if(num[i] < min){
			min = num[i];
		}
	}
	if(minus % 2 == 0){
		for(int i = 0; i < n; i++){
			ans += num[i];
		}
		printf("%lld\n", ans);
	}else{
		for(int i = 0; i < n; i++){
			ans += num[i];
		}
		printf("%lld\n", ans - 2 * min);
	}
	return 0;
}

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

const int INF = 1e9;
using lint = long long;
const lint LINF = 1e18;
#define bit(n) ((lint)1 << n);

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

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

    int a, b;
    cin >> a >> b;
    if (a >= 13) {
        cout << b << endl;
    } else if (a >= 6) {
        cout << b / 2 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#define rec(n,i) for(int i=0;i<n;i++)
using namespace std;
int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int ans = N - A;
	ans = ans - ((ans / B)*B);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N, M;

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

    vi cnt(N, 1), red(N);
    red[0] = 1;
    rep(i, M){
        int x, y;
        scanf("%d%d", &x, &y);
        --x; --y;
        if(red[x] == 1 && cnt[x] == 1){
            red[x] = 0;
            red[y] = 1;
        } else{
            red[y] |= red[x];
        }
        --cnt[x];
        ++cnt[y];
    }
    int ans = 0;
    rep(x, N)if(red[x])ans++;
    cout << ans << endl;
}

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

int main() {
    int n, k, d, a;
    set<int> st;
    cin >> n >> k;
    rep(i, k) {
        cin >> d;
        rep(i, d) {
            cin >> a;
            st.insert(a);
        }
    }
    cout << n - st.size() << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
int main(){
    char x;
    cin >> x;
    bool vowl = false;
    char vowel[5] = {'a' , 'e' , 'i' , 'o' , 'u'};
    for (int i = 0 ; i < 5 ; i++){
        if (x == vowel[i]) vowl = true;
    }
    if (vowl) cout << "vowel";
    else cout << "consonant";
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
//#define _CRTDBG_MAP_ALLOC
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll LINF = 9187201950435737471;
const ll nLINF = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const int MAXN = 2000 + 15;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const int BLOCK = 500;
const double PI = acos(-1);
//auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
auto seed = 194113341;
mt19937 rnd(seed);

bool isEqual(double a, double b) {
    return abs(a - b) <= EPS;
}

#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) ((_v) * (_v))
#define vi vector <int>
#define vpi vector <pair <int, int> >
#define eb emplace_back
#define pb push_back
#define mod(x, m) ((x) % m + (x < 0 ? m: 0))


inline void IO() {
#if buyolitsez
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
}

template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

//#define int int64_t

void solve() {
    int x;
    cin >> x;
    x %= 10;
    if (x == 2 || x == 4 || x == 5 || x == 7 || x == 9) {
        cout << "hon";
    }
    else if (x == 0 || x == 1 || x == 6 || x == 8) {
        cout << "pon";
    }
    else {
        cout << "bon";
    }
}

signed main() {
    IO();
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3616
use io::*;
use std::*;

fn solve(S: String) {
    if S == "ABC" {
        println!("{}", "ARC");
    } else {
        println!("{}", "ABC");
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut S: String;
    S = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(S)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

typedef long long ll;
using namespace std;

int main()
{
  string s;
  string t;

  cin >> s;
  cin >> t;

  int a = 0;
  for(int i = 0; i<s.size(); i++){
    if(s==t){
      a++;
      break;
    } else {
      s = s.back() + s.substr(0, s.size()-1);
    }
  }


  if(a>0)cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string G[6] = {"..rr....",
	       "..rr....",
	       "ggyybbww",
	       "ggyybbww",
	       "..oo....",
	       "..oo...."};
void roll(int i1, int j1, int i2, int j2, int i3, int j3, int i4, int j4){
  char t = G[i1][j1];
  G[i1][j1] = G[i2][j2];
  G[i2][j2] = G[i3][j3];
  G[i3][j3] = G[i4][j4];
  G[i4][j4] = t;
}

main(){
  string com; cin >> com;
  for ( int i = 0; i < com.size(); i++ ){
    if ( com[i] == 'F' ){
      roll(2, 2, 3, 2, 3, 3, 2, 3);
      roll(2, 1, 4, 2, 3, 4, 1, 3);
      roll(3, 1, 4, 3, 2, 4, 1, 2);
    } else if ( com[i] == 'U' ){
      roll(0, 2, 1, 2, 1, 3, 0, 3);
      roll(2, 2, 2, 4, 2, 6, 2, 0);
      roll(2, 3, 2, 5, 2, 7, 2, 1);
    } else if ( com[i] == 'D' ){
      roll(4, 2, 5, 2, 5, 3, 4, 3);
      roll(3, 1, 3, 7, 3, 5, 3, 3);
      roll(3, 0, 3, 6, 3, 4, 3, 2);
    } else if ( com[i] == 'L' ){
      roll(2, 0, 3, 0, 3, 1, 2, 1);
      roll(2, 7, 5, 2, 3, 2, 1, 2);
      roll(3, 7, 4, 2, 2, 2, 0, 2);
    } else if ( com[i] == 'R' ){
      roll(2, 4, 3, 4, 3, 5, 2, 5);
      roll(2, 3, 4, 3, 3, 6, 0, 3);
      roll(3, 3, 5, 3, 2, 6, 1, 3);
    } else if ( com[i] == 'B' ){
      roll(2, 6, 3, 6, 3, 7, 2, 7);
      roll(2, 5, 5, 3, 3, 0, 0, 2);
      roll(3, 5, 5, 2, 2, 0, 0, 3);
    }
  }
  for ( int i = 0; i < 6; i++ ) cout << G[i] << endl;
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#define MOD 1000000007LL
typedef long long ll;
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    ll alpha[26] = {};
    for(int i = 0; i < s.size(); i++) {
        alpha[s[i]-'a']++;
    }
    ll ans = 1;
    for(int i = 0; i < 26; i++) {
        //cout << alpha[i] << endl;
        ans *= (alpha[i]+1LL);
        ans %= MOD;
    }
    ans += MOD;
    ans -= 1;
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 512
N = int(input())
B = list(map(int,input().split()))
A = [0] * N
A[0] = B[0]
A[N-1] = B[N-2]
for i in range(1, N-1, 1):
    A[i]=min(B[i-1], B[i])
Sum = 0
for i in range(N):
    Sum += A[i]
print(Sum)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int x,a,b;
  cin>>x>>a>>b;
  if(abs(x-a)<abs(x-b))cout<<"A"<<endl;
  else cout<<"B"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	cin >> N;
	vector<int> L(N), sum(N + 1);
	sum[0] = 0;
	int max_id = 0;
	REP(i, N) {
		cin >> L[i];
		sum[i + 1] = sum[i] + L[i];
		if (L[i] > L[max_id]) max_id = i;
	}
	string res = "No\n";
	if (L[max_id] < sum[N] - L[max_id]) res = "Yes\n";
	cout << res;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int a1,a2,b1,b2;
	cin>>a1>>a2>>b1>>b2;
	if(a1+a2>b1+b2) cout<<"Left"<<endl;
	else if(a1+a2==b1+b2) cout<<"Balanced"<<endl;
	else cout<<"Right"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF  numeric_limits<int_fast64_t>::max();
#define intf int_fast64_t
int main(){
    string s,t;
    cin >>s >>t;
    rep(i,s.size()){
        if(s[i]!=t[i]){
            cout << "No"<<endl;
            return 0;
        }
    }
    cout << "Yes"<<endl;
}

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

using namespace std;

#define ll           long long int 
#define endl         '\n'

static const int maxn = 2e5 + 5;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	
	int n;
	cin >> n;
	int mini = n + 1;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		mini = min(mini, x);
		if (mini >= x) {
			++ans;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3556
n = io.read("*n")
t = {}
for i = 1, n do
  a = io.read("*n")
  if not t[a] then t[a] = 0 end
  t[a] = t[a] + 1
end
if n % 2 == 0 then
  hn = n // 2
  v = true
  for i = 1, hn do
    z = i * 2 - 1
    if t[z] ~= 2 then v = false break end
  end
  if v then
    r = 1
    for i = 1, hn do
      r = (r * 2) % 1000000007
    end
    print(r)
  else
    print(0)
  end
else
  v = t[0] == 1
  hn = n // 2
  r = 1
  for i = 2, n, 2 do
    if t[i] ~= 2 then v = false break end
    r = (r * 2) % 1000000007
  end
  if v then
    print(r)
  else
    print(0)
  end
end


Measured memory_bytes: 3440
//#pragma GCC optimize("Ofast")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>


#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MAX = 100010;
int MOD = (ll)1000000000 + 7;
ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<ll, int>P;//firstは距離、secondは頂点番号



int main() {
	int N;
	int mx = 0;
	int sum = 0;
	cin >> N;
	REP(i, N) {
		int l; cin >> l;
		sum += l;
		mx = max(mx, l);
	}
	sum -= mx;
	if (mx < sum) {
		print("Yes");
	}
	else print("No");
}


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

int main() {
    int n,m,sum=0;
    cin>>n>>m;
    vector<int> a(m);
    rep(i,m) {
        cin>>a[i];
        sum+=a[i];
    }
    if (sum>n) cout<<-1<<endl;
    else cout<<n-sum<<endl;
}


Measured memory_bytes: 3640