akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    if(a + b < c){
      System.out.println(0 + " " + 0);
      System.exit(0);
    }
    if(a < c){
      c -= a;
      b -= c;
      System.out.println(0 + " " + b);
    }else{
      a -= c;
      System.out.println(a + " " + b);
    }
    
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
int main(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    h = h + m/60;
    double ang = min((5 * h) -m, 60 - ((5 * h) -m));
    //cout << ang << endl;
    ang *= 6.0;
    ang = (ang*1.0/180.0)*acos(-1);
    //cout << acos(-1) << ang << endl;
    //cout << h << endl;
    cout << fixed << setprecision(10) << sqrt(a*a*1.0 + b*b*1.0 - 2*a*b*cos(ang));
    //cout << cos(ang);
    return 0;
}


Measured memory_bytes: 4212
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
#include <map>
#include <utility>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
 //各位の和　
int wa(ll x)
{
ll sum = 0;
while(x!=0){
  sum += x% 10;
  x /= 10;
}
return sum;
}
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文
//if(isupper('A'))->大なら真


//グローバル変数宣言
ll p=0,q=0,r=0,s;

int main()
{
  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  c*=2;
  s=5000000000;
  rep(i,100001)
  {
    p=x-i;
    q=y-i;
    if(p<0)p=0;
    if(q<0)q=0;
    r=c*i+a*p+b*q;
    s=min(s,r);
  }
  print(s)
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m; cin >> n >> m; int total = 0;
    int a[1000];
    FOR(i,n){
        cin >> a[i]; total += a[i];
    }
    double c = (double)total/(4*(double)m);
    int counter = 0;
    FOR(i,n){
        if(a[i] >= c) counter++;
    }
    if(counter < m) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
int main()
{
    fio;
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        rep(i,n)
        cin>>a[i];
        ll XOR=0;
        rep(i,n)
        {
            XOR^=a[i];
        }
        rep(i,n)
        {
            cout<<(XOR^a[i])<<" ";
        }
    }
}

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

typedef long long ll;

using namespace std;

int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.in","w",stdout);
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,n;
    cin>>n;
    vector<ll> v(n);
    ll m(0),ans(0);
    for(i=0;i<n;i++){
    	cin>>v[i];
    	m=max(v[i],m);
    	ans+=m-v[i];
    }
    cout<<ans;

	
	
	







	return 0;
}

Measured memory_bytes: 4796
from collections import deque
n,x,y = map(int,input().split())
to = [[] for _ in range(n)]
for i in range(n-1):
    to[i].append(i+1)
    to[i+1].append(i)
x -= 1
y -= 1
to[x].append(y)
to[y].append(x)
ans = [0]*(n-1)
dist = [-1]*n
Q = deque()
for i in range(n):
    Q.clear()
    for j in range(n): dist[j] = -1
    Q.append((i,-1))
    dist[i] = 0
    while Q:
        cur,prev = Q.popleft()
        for nxt in to[cur]:
            if nxt == prev: continue
            if dist[nxt] != -1: continue
            Q.append((nxt,cur))
            dist[nxt] = dist[cur]+1
            ans[dist[cur]] += 1

print("\n".join(map(str,(map(lambda x:x//2,ans)))))

Measured memory_bytes: 44124
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Sorted Arrays
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int INF = 1 << 30;

/* typedef */

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

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &as[i]);

  int pa = as[0], cnt = 1, dir = 0;
  for (int i = 1; i < n; i++) {
    if (pa == as[i]) continue;
    if (pa < as[i]) { // inc
      if (dir < 0) cnt++, dir = 0;
      else dir = 1;
    }
    else { // dec
      if (dir > 0) cnt++, dir = 0;
      else dir = -1;
    }
    pa = as[i];
  }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define tmp(x) std::cout<<"& "<<(x)<<" &\n"
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;

using namespace std;
const int maxn=2e5+100;
int n,t;
int a[111];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    rep(i,1,n)cin>>a[i];
    sort(a+1,a+1+n);
    int ans=0;
    rep(i,1,n){
    	rep(j,i+1,n){
    		rep(k,j+1,n){
    			if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])++ans;
//				,cout<<a[i]<<' '<<a[j]<<' '<<a[k]<<'\n';
			}
		}
	}
 
 
 	cout<<ans;
 
    return 0;
}

Measured memory_bytes: 3656
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    ll C;
    cin >> C;
    ll K;
    cin >> K;
    ll count=0;
    while(A>=B){B*=2;count++;}
    while(B>=C){C*=2;count++;}
    if(count<=K)prt("Yes");
    else prt("No");

    return 0;
}



Measured memory_bytes: 3636
import numpy as np
N,K = map(int,input().split())
res = np.zeros(K+1, dtype=np.int64)
ans = 0
MOD = 10**9+7
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return np.array(divisors, dtype=np.int64)

for k in range(K,0,-1):
    y = make_divisors(k)
    s = K//k
    tmp = pow(s, N, MOD)
    ans += k*(tmp-res[k])
    # print(res[k], tmp, ans)
    res[y] += tmp-res[k]
print(ans%MOD)

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const char c[10][10] = {"aa.", "..a", "..a"};

const char s[4][10][10] = {
	{"aabc", "ddbc", "bcaa", "bcdd"},
	{"aabba", "bcc.a", "b..cb", "a..cb", "abbaa"},
	{"aabc..", "ddbc..", "..aabc", "..ddbc", "bc..aa", "bc..dd"},
	{"aabbcc.", "dd.dd.a", "..d..da", "..d..db", "dd.dd.b", "..d..dc", "..d..dc"}
};

int n;
char a[1005][1005];

int main() {
	read(n);
	if (n == 2) {
		print(-1);
		return 0;
	}
	if (n == 3) {
		for (int i = 0; i < n; ++i) {
			printStr(c[i]);
		}
		return 0;
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			a[i][j] = '.';
		}
	}
	for (int k = 0; k + 4 < n; k += 4) {
		for (int i = k; i < k + 4; ++i) {
			for (int j = k; j < k + 4; ++j) {
				a[i][j] = s[0][i - k][j - k];
			}
		}
	}
	int r = n % 4 + 4;
	for (int i = n - r; i < n; ++i) {
		for (int j = n - r; j < n; ++j) {
			a[i][j] = s[r - 4][i - n + r][j - n + r];
		}
	}
	for (int i = 0; i < n; ++i) {
		printStr(a[i], n);
	}
}


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

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int tmp = A + B - C - D;
    if(tmp > 0) {
        cout << "Left" << endl;
    } else if(tmp == 0) {
        cout << "Balanced" << endl;
    } else {
        cout << "Right" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll K; cin >> K;
	string S; cin >> S;
	string t;
	if (S.size() <= K) {
		cout << S << endl;
		return 0;
	}
	else {
		for (int i = 0; i < K; i++) {
			t += S[i];
		}
	}
	t += "...";

	cout << t << endl;
}

Measured memory_bytes: 11012
import math
def sosu(n) :
    for i in range(3, int(math.sqrt(n))+1, 2) :
        if n % i == 0 :
            return False
    return True

S = [0, 0, 1, 2, 2, 3, 3, 4, 4, 4, 4]
for i in range(11, 1000000) :
    if i % 2 == 0 :
        S.append(S[i-1])
    elif sosu(i) :
        S.append(S[i-1]+1)
    else :
        S.append(S[i-1])


while True :
    try :
        n = int(input())
    except EOFError :
        break
    
    print(S[n])


Measured memory_bytes: 16000
n,*l, = [list(map(int,s.split()))for s in open(0)]
cnt = 0
for i in range(len(l)-1):
    for j in range(i+1,len(l)):
        dist = 0
        for d in range(n[1]):
            dist += (l[i][d] - l[j][d])**2
        if (dist**(0.5))%1 ==0:
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
using namespace std;


int main() {
	long int N, K;
	cin >> N >> K;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec[i];
	}
	
	
	sort(vec.begin(),vec.end());


	vector<int> sortvec=vec;

	
	sortvec.erase(unique(sortvec.begin(), sortvec.end()), sortvec.end());
	//vec ソート
	//vecsort ソート　消す
	vector<int> vec1;
	

	if (sortvec.size() <= K) {
		cout << 0 << endl;
	}
	else {
		
		long int W = vec[0];
		long int R = 0;
		for (int i = 0; i < N; i++) {
			if (W == vec[i]) {
				R++;
				if (i == N - 1) {
					vec1.push_back(R);
				}
			}
			else {
				vec1.push_back(R);
				R = 1;
				W = vec[i];
				if (i == N - 1) {
					vec1.push_back(1);
				}
			}
	     }
		long int H = 0;
		
		sort(vec1.begin(), vec1.end());
		for (int y = 0; sortvec.size() - K > y; y++) {
			H += vec1[y];
		}
		cout << H << endl;
	}

	
	

	return 0;
}


Measured memory_bytes: 2936
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => long.Parse(elem)).ToArray();
            var N = items[0];
            var K = items[1];
            var answer = N % K;
            answer = Math.Min(answer, Math.Abs(answer - K));
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int count = 1;
		
		if (n < 105) {
			System.out.println(0);
			System.exit(0);
		}
		
		int cnt;
		for (int i = 107; i <= n; i+=2) {
			cnt = 2;
			for (int j = 2; j < i; j++) {
				if (i % j == 0) cnt++;
			}
			if (cnt == 8) count++;
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 23892
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int wl[64],tk[8]={0,5,7,5,7,7,0,0},seq,nowl,i,j,n,yn;
	char s[16];
	while(scanf("%d",&n) , n != 0){
		for(i = 1;i <= n;i++){
			scanf("%s",s);
			wl[i] = strlen(s);
		}
		yn = 0;
		for(i = 1;i <= n;i++){
			seq = 1;
			nowl = 0;
			j = i;
			while(1){
				nowl+=wl[j];
				if(nowl == tk[seq]){
					if(seq == 5){
						printf("%d\n",i);
						yn = 1;
						break;
					}
					else{
						seq++;
						nowl = 0;
					}
				}
				else if(nowl > tk[seq]){break;}
				j++;
			}
			if(yn){break;}
		}
	}
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a;
  while(n--)
  {
    cin>>m>>b;
    c=sqrt(m*m+b*b);
    //cout<<c<<endl;
    if(sqrt(m*m+b*b)<=a) k++;
  }
  cout<<k;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3672
t = []
count = 0
t += input()
for i in range(len(t)):
    if i == 0:
        if t[i] != "A":
            count = 2
            break
    elif i == 1 or i == len(t)-1:
        if t[i] == t[i].upper():
            count = 2
            break
    else:
        if t[i] == "C" and count == 0:
            count += 1
        elif t[i] == t[i].upper():
            count = 2
            break
if count == 1:
    print("AC")
else:
    print("WA")

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

int main() {
  int x, n;
  cin >> x >> n;
  
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  
  sort(p.begin(), p.end());
  int ma = x;
  for (int i : p) {
    if (ma == i) ma++;
    else if (ma > x) break;
  }
  if (ma == x) {
    cout << ma << endl;
    return 0;
  }
  
  reverse(p.begin(), p.end());
  int mi = x;
  for (int i : p) {
    if (mi == i) mi--;
    else if (mi < x) break;
  }
  
  int ans = 0;
  if (x - mi <= ma - x) {
    ans += mi;
  }
  if (x - mi > ma - x) {
    ans += ma;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3584
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        char[] cubes = s.toCharArray();
        int[] colors = new int[n];

        ArrayDeque<Integer> stack = new ArrayDeque<>();

        for (int i = 0; i < n; i++) {
            colors[i] = Character.getNumericValue(cubes[i]);
        }

        for (int c : colors) {
            if (stack.isEmpty()) {
                stack.push(c);
            } else {
                if (stack.peek() != c) {
                    stack.pop();
                } else {
                    stack.push(c);
                }
            }
        }

        System.out.println(n - stack.size());
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

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

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int a, b, c;

	cin >> a >> b >> c;

	a *= 100;
	a += b * 10;
	a += c;

	if (a % 4 == 0) Out("YES");
	else Out("NO");
	
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  string w[n];
  for(int i=0; i<n; i++){
    cin >> w[i];
    if(i>0){
      if(w[i-1][w[i-1].size()-1] != w[i][0]){
        cout << "No" << endl;
        return 0;
      }
    }
    for(int j=0; j<i; j++){
      if(w[i] == w[j]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
      

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N;
	cin>>N;
	for(int i=111;i<=999;i+=111)
		if(N<=i)
		{
			cout<<i<<endl;
			return 0;
		}
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////




int main() {

	int H, W, K;
	cin >> H >> W >> K;

	char s[500][500];

	repn(i, H) {
		repn(j, W) {
			cin >> s[i][j];
		}
	}

	int ex[500] = {};//その行にいちごがあるか

	int last = 0;

	repn(i, H) {
		repn(j, W) {
			if (s[i][j] == '#') {
				last = i;
				ex[i] = 1; }
		}
	}

	int ans[500][500];

	int str = 0;

	repn(i, H) {

		
		if (ex[i] == 1) {

			str++;


			int l=0;

			repn(j, W) {
				if (s[i][j] == '#') { l = j; }
			}

			repn(j, W) {
				ans[i][j] = str;
				if (s[i][j] == '#'&&j != l) { str++; }
			}

		}

	}

	int t[500] = {};//直近のいちご行


	repn(i, H) {
		
		if (ex[i] == 0) {
			for(int j=H; j>i; j--) {
				if (ex[j] == 1) { t[i] = j; }
			}

			if (t[i] == 0) { t[i] = last; }
		}

	}


	repn(i, H) {
		repn(j, W) {
			if (ex[i] == 0) {
				ans[i][j] = ans[t[i]][j];
			}
		}
	}
	
	repn(i, H) {
		repn(j, W) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}

	system("PAUSE");
}


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

void solve(long long N, std::vector<long long> a){
    ll cnt = 0;
    ll pos = 1;
    for(ll i = 0; i < N; i++){
        if(pos == a[i]){
            pos++;
        }else{
            cnt++;
        }
    }
    if(cnt == N) cnt = -1;
    cout << cnt << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 4856
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <functional>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int c4 = 0, c2 = 0, c0 = 0;
    int i;
    int val;
    for(i = 0; i < n; i++) {
        cin >> val;
        if(val % 4 == 0) {
            c4++;
        }
        else if(val % 2 == 0) {
            c2++;
        }
        else {
            c0++;
        }
    }
    if(c0 <= c4) {
        cout << "Yes";
    }
    else if(c2 == 0 && c0 <= c4 + 1) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }


    return 0;
}



Measured memory_bytes: 256
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int r;cin>>r;
  p(r*r);
  return 0;
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

/*
int main(void){
	int32 N;
	cin >> N;
	vector<int64> v(N);
	REP(i, N) cin >> v[i];

	int64 maxi = 0;
	int64 res = 0;
	REP(i, N){
		int64 cnt = (v[i]-1)/(maxi+1);
		if(cnt){ res += cnt; chmax(maxi, 1); }
		else maxi = v[i];
	}
	cout << res << endl;
}
*/


int main(void){
	int32 M, N, K;
	scanf("%d %d %d", &N, &M, &K);
	int64 A[112345];
	deque<PLL> deq[301];
	REP(i, N) scanf("%lld", &A[i]);

	REP(i, N){
		for(int32 j = K-1;j >= 1;j--){
			while(deq[j-1].size() && i-deq[j-1].front().sc > M) deq[j-1].pop_front();
			if(deq[j-1].empty()) continue;
			int64 val = deq[j-1].front().fs+A[i]*(j+1);
			while(deq[j].size() && val > deq[j].back().fs) deq[j].pop_back();

			deq[j].push_back(PLL(val, i));
		}
		while(deq[0].size() && A[i] > deq[0].back().fs) deq[0].pop_back();
		deq[0].push_back(PLL(A[i], i));
	}

	cout << deq[K-1].front().fs << endl;
}

Measured memory_bytes: 1280
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),x = 0,ans=0;
        sc.nextLine();
        String s = sc.nextLine();
        for(int i = 0; i < n; i++){
            if(s.charAt(i)=='I')x++;
            else x--;
            if(ans<x)ans=x;
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 21332
import sys
stdin = sys.stdin
from itertools import accumulate, groupby
mod = 10**9 + 7

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))


a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = ni()
print(a[k-1])

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ans;
ll mod = 1e9 + 7;
ll ar[2005];
ll no[2005];
ll inv;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>ar[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)continue;
            if(j>i&&ar[i]>ar[j])inv++;
            if(ar[i]>ar[j])no[i]++;
        }
    }
    for(int i=0;i<n;i++){
        ll g=k-1LL;
        ll cur=no[i];
        ll b=g*(g+1LL);
        b/=2LL;
      	b%=mod;
        cur*=b;
        if(cur>=mod)cur%=mod;
        ans+=cur;
        if(ans>=mod)ans-=mod;
    }
    inv*=k;
    inv%=mod;
    ans+=inv;
    ans%=mod;
    cout<<ans;
    return 0;
}


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

int main(){
  long long h;
  cin >> h;
  if(h ==1){cout << h << endl;
           return 0;}
  long long a[1000] = {};
  int i=0;
  while(h!=1){
  if(h%2== 1){h=(h-1)/2;}else{h=h/2;}
    i++;}
  long long ans=0;
  for(int q=0;q<i;q++){
  if(q==0){ans+=3;}
  if(q>=1){ans=ans*2+1;}
    
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 101
 
main(){
  
  int M[N][N];
  int n,m,k,l,i,j;
   
  scanf("%d",&n);
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      M[i][j]=0;
    }
  } 
     
  for(i=0;i<n;i++){
    scanf("%d%d",&m,&k);    
    for(j=0;j<k;j++){
      scanf("%d",&l);
      M[m][l]=1;      
    }
  }
     
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j==n){
	if(M[i][j]!=0) printf("1");
	else printf("0");
	break;    
      }
     
      if(M[i][j]!=0) printf("1 ");
      else printf("0 ");   
    }
    printf("\n");

  }
  return 0;
}

Measured memory_bytes: 620
#include<stdio.h>
 
int main(){
  int i, j, n, p, count=0;
  int A[100];
 
  scanf("%d",&n);
 
  for(i=0 ; i<n ; i++) scanf("%d",&A[i]);
 
  for(i=0 ; i<n ; i++){
    for(j=n-1 ; j>i ; j--){
      if(A[j] < A[j-1]){
    p = A[j];
    A[j] = A[j-1];
    A[j-1] = p;
    count++;
      }
    }
  }
  for(i=0 ; i<n-1 ; i++) printf("%d ",A[i]);
  printf("%d\n%d\n",A[i],count);
 
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T &a, T b) {
        if(a<b) {
                a=b;
                return 1;
        }
        return 0;
}
template<class T> inline bool chmin(T &a, T b) {
        if(a>b) {
                a=b;
                return 1;
        }
        return 0;
}
const ll INF = 1LL << 60;

int main() {
        int n,w,sumValue=0; cin >> n >> w;
        vector<int> weight(n);
        vector<int> value(n);
        for(int i=0; i<n; i++) {
                cin >> weight[i] >> value[i];
                sumValue+=value[i];
        }
        // 品物の価値の総和が0からのパターンで動的計画法を使う
        vector<vector<ll> > dp(n+1,vector<ll>(sumValue+1,INF));
        dp[0][0]=0;
        for(int i=1; i<=n; i++) {
          for(int j=0; j<=sumValue; j++) {
            chmin(dp[i][j], dp[i-1][j]);
            if(j>=value[i-1]) chmin(dp[i][j], dp[i-1][j-value[i-1]]+weight[i-1]);
            //cout << "i: " << i << ", j: " << j << "," << dp[i][j] << endl;
          }
        }
        ll res=0;
        for(int i=0; i<=sumValue; i++){
          if(dp[n][i] <= w) res = i;
        }
        cout << res << endl;
}


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

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] moji = s.toCharArray();
        int cnt =0;
        int[] moji2 = new int[s.length()];

        for(int i = 0;i<moji.length;i++){
            moji2[i]=(int)moji[i];
           // System.out.println(moji2[i]);
        }

        Arrays.sort(moji2);

        for(int i=0;i<moji2.length-1;i++){
            if(moji2[i]+1!=moji2[i+1] && moji2[i]!=moji2[i+1] ){
                //System.out.println(moji2[i]);
                //System.out.println(moji2[i+1]);
                cnt=moji2[i]+1;
                break;
            }
            if(i==moji2.length-2){
                if(moji2[i+1]!=122){
                    cnt=moji2[i+1]+1;
                   // System.out.println(cnt);
                }
            }
        }
        if(moji.length==1){
            System.out.println((char)(moji2[0]+1));
        }else if(cnt!=0&&moji2[0]!=97){
        System.out.println("a");
        }else if(cnt!=0){
            System.out.println((char)(cnt));
        }else{
            System.out.println("None");
        }

    }
}




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

int main()
{
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    int a[n];
    a[n-1]=0;
    a[n-2]=abs(h[n-1]-h[n-2]);
    for(int i=n-3;i>=0;i--)
    {
        // a[i]=min(a[i+1]+abs(h[i]-h[i+1]),a[i+2]+abs(h[i]-h[i+2]));
        int min=INT_MAX;
        for(int j=1;j<=k&&i+j<n;j++)
        {
            if((a[i+j]+abs(h[i]-h[i+j]))<min)
            min=(a[i+j]+abs(h[i]-h[i+j]));
        }
        a[i]=min;
    }
    cout<<a[0];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
    deque<char> s;
    string st;
    cin >> st;
    for (int i = 0; i < st.length(); i++)
    {
        s.push_back(st[i]);
    }
    int queries;
    cin >> queries;
    int flag = 0;
    for (int i = 0; i < queries; i++)
    {
        int choice;
        cin >> choice;
        if (choice == 1)
        {
            flag = 1 - flag;
        }
        if (choice == 2)
        {
            int pos;
            char ex;
            cin >> pos >> ex;
            if (pos == 1 && flag == 0)
                s.push_front(ex);
            if (pos == 1 && flag == 1)
                s.push_back(ex);
            if (pos == 2 && flag == 0)
                s.push_back(ex);
            if (pos == 2 && flag == 1)
                s.push_front(ex);
        }
    }
    if (flag == 0)
    {
        for (deque<char>::iterator i = s.begin(); i != s.end(); i++)
            cout << *i;
    }
    else
    {
        while (s.size())
        {
            cout << s.back();
            s.pop_back();
        }
    }
    cout << endl;
}

Measured memory_bytes: 896
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int h=sc.nextInt();
    int n=sc.nextInt();
    int[] dp=new int[h+1];
    int[] at=new int[n];
    int[] mp=new int[n];
    for(int i=0;i<n;i++){
      at[i]=sc.nextInt();
      mp[i]=sc.nextInt();
    }
    Arrays.fill(dp,Integer.MAX_VALUE);
    dp[0]=0;
    for(int i=0;i<=h;i++){
      if(dp[i]!=Integer.MAX_VALUE){
        for(int j=0;j<n;j++){
          dp[Math.min(i+at[j],h)]=
            Math.min(
              dp[i]+mp[j],
              dp[Math.min(i+at[j],h)]
            );
        }
      }
    }
    System.out.println(dp[h]);
  }
}

Measured memory_bytes: 28224
a = gets.chomp.split(' ').map{|i| i.to_i}
k = gets.chomp.to_i
idx = -1
max = 0
sum = 0
3.times do |i|
        sum += a[i]
        if max < a[i]
                idx = i
                max = a[i]
        end
end
sum = sum - a[idx] + a[idx] * (2 ** k)
puts sum


Measured memory_bytes: 1788
n = io.read("*n")
a, b = io.read("*n", "*n")
t = {0, 0, 0}
for i = 1, n do
  p = io.read("*n")
  if p <= a then
    t[1] = t[1] + 1
  elseif p <= b then
    t[2] = t[2] + 1
  else
    t[3] = t[3] + 1
  end
end
print(math.min(table.unpack(t)))


Measured memory_bytes: 760
///#pragma GCC optimize("O3,unroll-loops")
///#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 200005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll fast_exp(ll x, ll n, ll m)
{
    ll res = 1;
    while(n>0)
    {
        if(n%2==1)
            res = (res * x) % m;
        x = (x * x) % m;
        n/=2;
    }
    return res%m;
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet1;

const int N = 1000006;
ll inv[N], cnt[N], ans[N], sum[N], sq[N];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    FASTIO;
    int n, m;
    cin>>n>>m;
    ll sum = 0;
    for(int i = 0; i < m; i++)
    {
        int a;
        cin>>a;
        sum+=(ll)a;
    }
    cout<<max(-1LL, (ll)n-sum)<<endl;

    //End();
    return 0;
}


Measured memory_bytes: 3664
N = int(input())

A = list(map(int, input().split()))

import sys

if 0 in A:
    print(0)
    sys.exit(0)

ans = 1
for i in range(len(A)):
    ans *= A[i]
    if (ans > int(1e18)):
        print(-1)
        sys.exit(0)
if ans > int(1e18):
    print(-1)
else:
    print(ans)

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

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

 int check=0;

 for (int i=0; i<N; i++){
  string S;
  cin >> S;
  if (S=="Y"){
   check=1;
  }
 }

 if (check==0){
  cout << "Three" << endl;
 }
 else{
  cout << "Four" << endl;
 }
}

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

int main() {
    string s, t;
    double c;
    cin >> s >> t;
    c = sqrt(stoi(s + t));
    cout << ((int)c - c ? "No" : "Yes") << endl;
}


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

using namespace std;

int n, a[100010];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    int sum = 0;
    for (auto i : a) sum += i;

    cout << (sum % 2 ? "NO" : "YES") << endl;

    return 0;
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    int n,m;
    while (cin >> n >> m) {
        int lft = 1, rht = n;
        FOR(i,0,m) {
            int a,b; cin >> a >> b;
            lft = max(lft,a);
            rht = min(rht,b);
        }
        cout << max(0,rht-lft+1) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#AGC002 A 23:04 - 
'''
問題
整数a,bが与えられる。ただしa<=bである。
このときa,a+1,...,bをすべて掛け合わせた積が正か負か0かを判定せよ
ただしa,bは-10**9以上10**9以下かつa<=b

考察
a*b<=0なら答えは0
a*b>0かつa+b>0なら答えは正
a*b>0かつa+b<0なら...
	aからbまで奇数個の数があれば答えは負
		つまりa-bが偶数なら答えは負
	aからbまで偶数個の数があれば答えは正
		つまりa-bが奇数なら答えは正
'''

a,b=map(int,input().split(' '))

if a*b<=0:
	print('Zero')
elif a+b>0 or (a+b<0 and (a-b)%2==1):
	print('Positive')
else:
	print('Negative')

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
typedef long long ll;

const int mod = 998244353;

int main() {

    int n, k;
    cin >> n >> k;
    vector<int> l(k), r(k);
    for (int i = 0; i < k;i++){
        cin >> l[i] >> r[i];
    }

    vector<ll> dp(n + 1);
    vector<ll> pre(n + 1);
    dp[1] = 1;
    pre[1] = 1;

    for (int j = 2; j <= n;j++){
        for (int i = 0; i < k;i++){
            dp[j] = (dp[j] + pre[max(j - l[i], 0)] - pre[max(0, j - r[i] - 1)] + mod) % mod;
        }
        pre[j] = (pre[j - 1] + dp[j]) % mod;
    }

    cout << dp[n];

    return 0;
}

Measured memory_bytes: 6412
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#define ll long long
using namespace std;



int main(){
   
  ll N,R,ans;

  cin>>N>>R;

  if(N>=10) ans=R;
  else ans=R+100*(10-N);

  cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import fractions
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

b = a[0]
for i in range(1, n):
    b = b * a[i] // fractions.gcd(b, a[i])

ans=0
for g in range(n):
    ans+=b//a[g]
print(ans%mod)

Measured memory_bytes: 6200
def bubbleSort(A, N):
    flag = 1
    count = 0
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                A[j] , A[j-1] = A[j-1], A[j]
                count += 1
                flag = 1
    return count

N = int(input())
A = list(map(int,input().split()))
count = bubbleSort(A,N)
print(" ".join(map(str,A)))
print(count)


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

int main() {

  int N, K, C;
  cin >> N >> K >> C;

  string S;
  cin >> S;

  vector<int> saitan(K);
  vector<int> saichi(K);

  int j = 0;
  for(int i = 0; i < N && j < K; i++){
    if(S[i] == 'o'){
      saitan[j] = i;
      i += C;
      j++;
    }
  }

  j = 0;
  for(int i = 0; i < N && j < K; i++){
    if(S[N - 1 - i] == 'o'){
      saichi[K - 1 - j] = N - 1 - i;
      i += C;
      j++;
    }
  }

  for(int i = 0; i < K; i++){
    if(saitan[i] == saichi[i]){
      cout << saitan[i] + 1 << endl;
    }
  }
}

Measured memory_bytes: 3332
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
 //       Scanner sc = new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String cardAbc;
        int cardNum;//カードの枚数
        int shuffleNum;//シャフルする枚数
        int shuffleTimes;//シャフルする回数

//  ArrayList<String> cardArray = new ArrayList<String>();
        String copy = "";
        
        while((cardAbc = br.readLine()) != null){
            if("-".equals(cardAbc)){
                break;
//            shuffleTimes= Integer.parseInt(br.readLine());
//            cardNum = cardAbc.length();
 //           String[] card = new String[cardNum];
 //           card = cardAbc.split("");
//            for(String a:cardAbc){
            }else{
             cardNum = cardAbc.length();
        //    System.out.println("cardAbc" + cardAbc);
        //    System.out.println("cardNum" + cardNum);                
                 shuffleTimes = Integer.parseInt(br.readLine());
        //    System.out.println("shuffleTimes" + shuffleTimes);
                
                 for(int i = 0; i <shuffleTimes;i++){
                     shuffleNum = Integer.parseInt(br.readLine());
                     copy += cardAbc.substring(shuffleNum,(cardAbc.length())); 
                 //    System.out.println("copy" + i + copy);                    
                     copy += cardAbc.substring(0,shuffleNum);
                //     System.out.println("copy" + i + copy);

                     cardAbc = copy;
                     copy ="";
                 }//System.out.println("ans" + cardAbc);
                 System.out.println(cardAbc);
 
            }
        }
    }
}
                 



Measured memory_bytes: 24464
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
#define INF 1000000001
int main() {
    int x,y,a,b,c;
    cin >>x>>y>>a>>b>>c;
    vector<int> p(a);
    vector<int> q(b);
    vector<int> r(c);
    for (int i = 0; i < a; i++){
        cin>>p[i];
    }
    for (int i = 0; i < b; i++){
        cin>>q[i];
    }
    for (int i = 0; i < c; i++){
        cin>>r[i];
    }
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    sort(r.begin(),r.end(),greater<int>());
    p.push_back(INF);
    q.push_back(INF);
    r.push_back(0);
    int p_index=a-x;
    int q_index=b-y;
    int r_index=0;
    LL ans=0;
    for (int i = 0; i < x+y; i++){
        if(p[p_index]<q[q_index]){
            if(p[p_index]<r[r_index]){
                ans+=r[r_index];
                if(r_index!=c)r_index++;
                if(p_index!=a)p_index++;
            }else{
                ans+=p[p_index];
                if(p_index!=a)p_index++;
            }
        }else{
            if(q[q_index]<r[r_index]){
                ans+=r[r_index];
                if(r_index!=c)r_index++;
                if(q_index!=b)q_index++;
            }else{
                ans+=q[q_index];
                if(q_index!=b)q_index++;
            }
        }
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 1792