akhauriyash/Code-Regression huggingface dataset:
n,m,x,y = map(int,input().split())
a = list(map(int,input().split()))
a.append(x)
b = list(map(int,input().split()))
b.append(y)
for i in range(x+1,y+1):
  if max(a) < i <= min(b):
    print("No War")
    break
else:
  print("War")

Measured memory_bytes: 3444
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    char s[20];
    char ans[20];
    cin >> s;
    int pos = 0;
    imfor(i, strlen(s)) {
        if (s[i] == 'B') {
            pos = max(0, pos - 1);
        }
        else {
            ans[pos] = s[i];
            pos++;
        }
    }
    imfor(i, pos) {
        cout << ans[i];
    }
    cout << endl;
}

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

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

    vector<long long int> H(N);
    
    for(int i=0; i<N; i++){
        cin >> H[i];
    }
    sort(H.begin(),H.end(),greater<int>());
   
   long long int ans = 0;
    for(int i=K; i<N; i++){
        ans += H[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
n,m=map(int,input().split())
l=list(map(int,input().split()))
tmp=[0]*n

for i in range(m):
    a,b=map(int,input().split())
    if l[a-1] >= l[b-1]:
        tmp[b-1]=-1
    if l[a-1] <= l[b-1]:
        tmp[a-1]=-1

print(tmp.count(0))

Measured memory_bytes: 20144
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b,aa=0,bb=0,j=0,k=0,l=0,s,t,u,v;
    cin>>n;
    vector<int> A(100005,0),B(100005,0),AA(100005,-1),BB(100005,-1);
    for(int i=0;i<n/2;i++){
    	cin>>a>>b;
        A[a-1]++; 
        B[b-1]++;
        aa=max(aa,A[a-1]);
        bb=max(bb,B[b-1]);
    }
    for(int i=0;i<100005;i++){
    	if(A[i]==aa) {
          AA[j]=i;j++;
        }
        if(B[i]==bb){
          BB[k]=i;k++;
        }
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(AA.begin(), AA.end());
    sort(BB.begin(), BB.end());
    if(AA[100004]!=BB[100004]){
      cout<<n-aa-bb;
    }
    else{
      cout<<min(n-A[100004]-B[100003],n-A[100003]-B[100004]);
    }
}
 


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>

char str[8192];
int length;
std::vector<char*> table(8192);

struct Info {
	int start, length;
};

int find_diff(int);

int main()
{
	int k;
	Info ans[5]{};

	scanf("%s", str);
	for (int i = 0; str[i] != '\0'; ++i)
	{
		table[i] = str + i;
		length = i;
	}
	length++;
	scanf("%d", &k);

	for (int i = 0; i < 26; ++i)
	{
		std::sort(table.begin(), table.begin() + length,
			[](const char* l, const char* r) {return strcmp(l, r) < 0; }
		);
	}

	ans[0] = Info({ 0, 0 });
	for (int i = 1; i < k; ++i)
	{
		if (table[ans[i - 1].start] + ans[i - 1].length + 1 < str + length)
		{
			ans[i].start = ans[i - 1].start;
			ans[i].length = ans[i - 1].length + 1;
		}
		else
		{
			ans[i].start = ans[i - 1].start + 1;
			ans[i].length = find_diff(ans[i - 1].start);
		}
	}

	for (int i = 0; i <= ans[k - 1].length; ++i)
	{
		printf("%c", table[ans[k - 1].start][i]);
	}
	printf("\n");

	return 0;
}

int find_diff(int pre)
{
	for (int i = 0;; ++i)
	{
		if (table[pre][i] != table[pre + 1][i]) return i;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long s,a,b,c;
int main()
{
    cin>>s;
    a=s/11;
    b=s-a*11;
    if (!b) c=0;
    else if (b>6) c=2;
    else c=1;
    cout<<a+a+c<<endl;
    return 0;
}


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

const int MAX_N = 100000;
bool isPrime[MAX_N+1];
int sum[MAX_N+1], q, l, r;
     
int main() {
    // Sieve of Eratosthenes
    for (int i = 0; i <= MAX_N; i++) {
        isPrime[i] = true;
    }
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i <= sqrt(MAX_N); i++) {
        for (int j = i + i; j <= MAX_N; j += i) {
            isPrime[j] = false;
        }
    }
    // sum
    for (int i = 3; i <= MAX_N; i += 2) {
        if (isPrime[i] && isPrime[(i+1)/2]) {
            sum[i]++;
        }
    }
    for (int i = 3; i <= MAX_N; i++) sum[i] += sum[i-1];
    // input and output
    cin >> q;
    while (q--) {
        scanf("%d %d", &l, &r);
        cout << sum[r] - sum[l-1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	ll a, b;
	int k;
	cin >> a >> b >> k;
	if ((b-a) <= 2 * k - 1) {
		for (int i = a; i <= b; i++) cout << i << endl;
		return 0;
	}
	for (int i = a; i < a + k; i++) {
		cout << i << endl;
	}
	for (int i = b - k + 1; i <= b; i++) {
		cout << i << endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                while(sc.hasNext()){
                        int a = sc.nextInt();
                        int b = sc.nextInt();
                        System.out.println(gcd(a,b) + " " + lcm(a,b));
                }   
                sc.close();
        }   
        static int gcd(int a, int b){
                if(a < b){ 
                        int tmp = a;
                        a = b;
                        b = tmp;
                }   
                do{ 
                        int r = a%b;
                        a = b;
                        b = r;
                }while(b != 0); 
                return a;
        }   
        static int lcm(int a, int b){
                int _a = a;
                int _b = b;
                while(_a != _b){
                        if(_a < _b){
                                _a += a;
                        }else{
                                _b += b;
                        }   
                }   
                return _a; 
        }   
}

Measured memory_bytes: 12000
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()
m= "hi"
# for i in range():
l = len(s) // 2
if l * m == s:
    print("Yes")
else:
    print("No")

# if s // 2



Measured memory_bytes: 5780
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
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 long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

string s;
ll n,ans=0;

void dfs(ll x,ll y,ll z){
  if(x==n){
    ans += y+z;
  }else{
    dfs(x+1,y+z,s[x+1]-'0');
    dfs(x+1,y,10*z+s[x+1]-'0');
  }
}
 
int main(){
  cin >> s;
  n = s.size()-1;
  dfs(0,0,s[0]-'0');
  cout << ans << endl;
  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(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 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-10;

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

int main(void){
	int32 N;
	vector<int32> A(3);
	string s;
	cin >> A[0] >> A[1];
  cout << (A[0]-1)*(A[1]-1) << endl;
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val a = StdIn.readLine().split(" ").map(_.toInt)
  import scala.math.min
  val r = min(min(a(0) + a(1), a(1) + a(2)), a(0) + a(2)) 
  
  println(r)
  
}

Measured memory_bytes: 25508
N,T = map(int, input().split())
abl = []
for _ in range(N):
    a,b = map(int, input().split())
    abl.append((a,b))

abl.sort()
dp = [ [0]*6001 for _ in range(N+1) ]

for i in range(N):
    a,b = abl[i]
    for t in range(6001):
        dp[i+1][t] = max(dp[i+1][t], dp[i][t])
    for t in range(T+1):
        if t < T:
            # dp[i+1][t+a] = max(dp[i+1][t+a], dp[i][t+a])
            dp[i+1][t+a] = max(dp[i][t]+b, dp[i][t+a])


ans = max(dp[N])
print(ans)

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

using namespace std;

#define int long long

signed main()
{
	cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);

	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s[0] == s[1] && s[2] == s[3] && s[0] != s[3])
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); ++i)
// using namespace atcoder;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//マクロ
// forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())       // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))    //最大値を求める
#define MIN(x) *min_element(ALL(x))    //最小値を求める
//定数
#define INF 1000000000000  // 10^12:極めて大きい値,∞
#define inf 2147483647     // int値の最大値
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back                             // vectorヘの挿入
#define MP make_pair                             // pairのコンストラクタ
#define F first                                  // pairの一つ目の要素
#define S second                                 // pairの二つ目の要素
#define CST(x) cout << fixed << setprecision(x)  //小数点以下の桁数指定
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
//各桁の和
int sumDight(int x) {
    int sum = 0;
    while (x > 0) {
        sum += (x % 10);
        x /= 10;
    }
    return sum;
}
//回文数
int divideReverse(int x) {
    int reverse = 0;
    int r;
    while (x > 0) {
        r = x % 10;
        reverse = reverse * 10 + r;
        x /= 10;
    }
    return reverse;
}

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

    int n, m;
    cin >> n;
    vector<string> s(110);
    rep(i, n) cin >> s[i];
    cin >> m;
    vector<string> t(110);
   rep(i, m) cin >> t[i];

    map<string, int> a;
    rep(i, n) { a[s[i]] += 1; }
    rep(i, m) a[t[i]] -= 1;
    int ma =0;
    for (auto p :a){
        ma = max(max(0, ma), a[p.first]);

    }
    cout << ma << endl;
}


Measured memory_bytes: 3636
n,k = map(int,input().split())
d = [0 for _ in range(k)]
sunuke = [0 for _ in range(n)]

#k種類のお菓子
for i in range(k):
  d[i] = int(input())
  a = list(map(int,input().split()))
  for i in a:
  	sunuke[i-1] += 1
  
print(sunuke.count(0))
  
  
  
 
  
  

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

int main(){
  int n,d,p,q;

  for(;;){
    cin >> n;
    if(!n)break;

    vector<string> board;
    for(int z=0;z<n;z++){
      cin >> d >> p >> q;

      int x,y;
      if(d==1){
	x = p;
	y = 1;
      }else{
	x = 1;
	y = p;
      }

      int tmp = -1;
      for(int i=0;i<x;i++){
	for(int j=(int)board.size()-1;j>=0;j--){
	  if(board[j][q+i-1]=='#'){
	    tmp = max(tmp,j);
	    break;
	  }
	}
      }
      for(int i=tmp+1;i<(int)board.size();i++){
	for(int j=0;j<x;j++)board[i][q+j-1] = '#';
	y--;
	if(!y)break;
      }

      string block;
      for(int i=0;i<q-1;i++)block.push_back('.');
      for(int i=0;i<x;i++)block.push_back('#');
      while(block.size()<5)block.push_back('.');
      while(y--)board.push_back(block);

      for(int i=0;i<(int)board.size();i++){
	bool f = true;
	for(int j=0;j<5;j++)
	  if(board[i][j] == '.')f = false;
	if(f){
	  board.erase(board.begin()+i);
	  i--;
	}
      }
      /*
      for(int i=0;i<(int)board.size();i++)cout << board[i] << endl;
      cout << endl;
      */
    }
    int ans = 0;
    for(int i=0;i<(int)board.size();i++)
      for(int j=0;j<5;j++)
	if(board[i][j] == '#')ans++;
    cout << ans << endl;
  }
}

Measured memory_bytes: 1156
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e9;

struct edge{int to,cost;};
typedef pair<int,int> P;//firstは最短距離,secondは頂点番号


int main(){
	double x[2];
	int ans[4][2];
	CLR(ans);
	while(cin>>x[0]>>x[1]){
		REP(i,2){
			if(x[i]>=1.1)ans[0][i]++;
			else if(x[i]>=0.6)ans[1][i]++;
			else if(x[i]>=0.2)ans[2][i]++;
			else ans[3][i]++;
		}
	}
	
	
	REP(i,4)cout<<ans[i][0]<<" "<<ans[i][1]<<endl;
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
const ll MINF = LLONG_MIN;
const int INT_INF = INT_MAX;

int main()
{
    ll n;
    cin >> n;
    ll cnt[10][10];
    ll res = 0;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            cnt[i][j] = 0;
        }
    }
    for (ll k = 0; k < n; k++)
    {
        string s = to_string(k + 1);
        cnt[s[0] - '0'][s[s.length() - 1] - '0']++;
    }
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            res += cnt[i][j] * cnt[j][i];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
n = int(input())

maximum_profit = -10**9
r0 = int(input())
r_min = r0
for i in range(1, n):
    r1 = int(input())
    if r0 < r_min:
        r_min = r0
    profit = r1 - r_min
    if profit > maximum_profit:
        maximum_profit = profit
    r0 = r1
print(maximum_profit)

Measured memory_bytes: 7688
import java.util.Scanner;
//import java.lang.Math;
import java.util.ArrayList;

class Main{
	
	public static void main(String[] arg){
	
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		ArrayList<Integer> array= new ArrayList<Integer>();
		for(int i=0;i<n;i++){
			int nn=sc.nextInt();
		switch(nn){
				
		
		case 0:
			int trval=sc.nextInt();
			array.add(trval);
			break;
		case 2:
			array.remove(array.size()-1);
			break;
		
		case 1:
			trval=sc.nextInt();
				System.out.println(array.get(trval));
			break;
		}
		
		
		
		
		}
}}


Measured memory_bytes: 141604
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
import           Data.IORef
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           System.IO

(+.+) = T.append
(!.!) = T.index

main :: IO ()
main = palindromicNumbers

palindromicNumbers :: IO ()
palindromicNumbers = do
  ab <- T.getLine
  let [aT, bT] = T.split (== ' ') ab
      a = read $ T.unpack aT :: Int
      b = read $ T.unpack bT :: Int
      ans = length [n | n <- [a..b], let nT = T.pack $ show n in T.reverse nT == nT]
  print ans

Measured memory_bytes: 1020
n=int(input())
a=list(map(int,input().split()))
b,c=[],[]
d=0
for i in range(n):
    if a[i]%4==0:
        b.append(1)
    elif a[i]%4!=0 and a[i]%2!=0:
        c.append(1)
    elif a[i]%4!=0 and a[i]%2==0:
        d+=1
b=sum(b)
c=sum(c)
if d>=1 and c<=b:
    print("Yes")
elif c<=b+1 and d==0:
    print("Yes")
else:
    print("No")
    

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

int main(){ 
    int sn;
    cin >> sn;
    string n = to_string(sn);
    int a = n.size();
    if(a < 3){
        cout << "0" << endl;
        return 0;
    }else{
        sn %= 10000;
    }

    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100-i; j++){
            for(int k = 0; k < 100-i-j; k++){
                for(int l = 0; l < 100-i-j-k; l++){
                    for(int m = 0; m < 100-i-j-k-l; m++){

                            int check = (100*i)+(101*j)+(102*k)+(103*l)+(104*m);
                            if(sn - check < 0) continue;
                            if((sn - check)%105 == 0){
                                cout << "1" << endl;
                                return 0;
                            }                                    
                                            
                        }
                    }
                }
            }
            
    }
    cout << "0" << endl;
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;

int main(void)
{
    cout << std::fixed << std::setprecision(10);
    std::string s;
    std::string answer;
    cin >> s;
    for (int i = 1; i <= (int)s.size(); i++)
    {
        if (i % 2 == 1)
        {
            answer += s[i - 1];
        }
    }
    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
// ll mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,i,j,temp,temp2,x,y,sum=0,o,n,m;
    cin >>n >> m;
    vector <ll> a(n);
    for(i=0;i<m;i++){
        cin  >> a[i];
        sum+= a[i];
    }
    if(sum>n) cout << "-1";
    else cout << n-sum;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

const int MOD = int(1e9) + 7;

int n, m;
int x[100000];

int solve(int n) {
    forn(i, n) {
        scanf("%d", x + i);
    }
    int sum = 0, ans = 0;
    forn(i, n) {
        ans = (ans + (LL)i * x[i] - sum) % MOD;
        sum += x[i];
        if (sum >= MOD) {
            sum -= MOD;
        }
        if (sum < 0) {
            sum += MOD;
        }
    }
    if (ans < 0) {
        ans += MOD;
    }
    return ans;
}

int main() {
    cin >> n >> m;
    int ans1 = solve(n);
    int ans2 = solve(m);
    int ans = (LL)ans1 * ans2 % MOD;
    cout << ans << endl;
    return 0;
}


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

int main(){
	int N;
	cin >> N;
	vector<long long> A(N);
	for(int i = 0; i < N; i++){
		cin >> A[i];
		if(A[i] < 0) A[i] *= (-1);
	}
	sort(A.begin(), A.end());
	long long ans = A.at(N - 1) - A.at(0);
	cout << ans << endl;
}

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


 if ( n%1000==0) cout << "0";
 else cout << 1000 - (n%1000);



return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  string t = s.substr(5,2);
  if(stoi(t) < 5){
    cout << "Heisei"<<endl;
  }else{
    cout << "TBD"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"
#define unordered_map umap
typedef long long ll;
typedef long double ld;
ll min(ll x,ll y){return (x<y ? x:y);}
ll max(ll x,ll y){return (x>y ? x:y);}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}
bool isPrime(int n){if(n<2){return false;}for(int i=2;i<sqrt(n)+1;i++){if(n%i==0) return false;}return true;}


int main(){
  int R; cin>>R;
  string s;
  if(R<1200){s="ABC";}
  else if(R<2800){s="ARC";}
  else{s="AGC";}
  cout<<s<<"\n";
}


Measured memory_bytes: 256
import bisect

abcd = []
n, k = map(int, input().split()) 
v_list = list(map(int, input().split())) 

for a in range(0, k+1):
    for b in range(0, k+1-a):
        for c in range(0, k+1-a-b):
            d = k-a-b-c
            abcd.append([a,b,c,d])


ans = 0
for curr_abcd in abcd:
    a,b,c,d = curr_abcd
    cd = c+d
    if a + b >= n:
        have = sorted(v_list)
    else:
        have = sorted(v_list[0:a] + v_list[n-b:n]) 

    minus_cnt = bisect.bisect_right(have,0)
    have = have[ min(minus_cnt, cd) : ]
    curr_sum = sum(have) 
    ans = max(ans, curr_sum)

print(ans)

Measured memory_bytes: 23924
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
D = LIST()

q = deque([""])

s = set([i for i in range(0, 10)]) 
d = set(D)
kouho = s - d
kouho = sorted(list(set(kouho)))
while q:
    a = q.popleft()
    # print(q)

    if len(a) != 0:
        if int(a) >= N:
            print(a)
            break
    for d in kouho:
        b = deepcopy(a)
        # if len(b) == 0 and d == 0:
        #     pass
        # else:
        b += str(d)
        q.append(b)
    



Measured memory_bytes: 7416
N=gets.to_i
temp=N.times.map{gets.split.map(&:to_i)}.transpose.map{|t|t.map.with_index{|e,i|[e,i]}}
temp[1].sort!{|a,b|a[0]<=>b[0]}
cnt="Yes"
fc,lc =0,0
N.times do |i|
  fc+=temp[0][temp[1][i][1]][0]
  lc=temp[1][i][0]
  cnt="No" if lc<fc
end
puts cnt

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

int main() {
int N;
 cin>>N;
  vector<float> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<N-1;i++){
vec.at(i+1)=vec.at(i)/2+vec.at(i+1)/2;
  }
  
  cout<<vec.at(N-1)<<endl;
 }


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

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

int main()
{
    string s;
    cin >> s;
    vector<int> v(4);
    rep(i, s.length()){
        v.at(i) = s[i] - '0';
    }

    for (int i = 0; i < (1 << 3);i++){
        int tmp = v.at(0);
        for (int j = 0; j < 3;j++){
            if(i & (1 << j)){
                tmp += v[j + 1];
            }
            else{
                tmp -= v[j + 1];
            }
        }
        if(tmp == 7){
            cout << v[0];
            for (int j = 0; j < 3;j++){
                if(i & (1 << j)){
                    cout << '+';
                }
                else{
                    cout << '-';
                }
                cout << v[j + 1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}

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

int main(){
  vector<char> X(10);
  for(int i=0;i<10;i++){
  cin >> X.at(i);
  }
  
  X.at(3) = '8';
  
  for(int i=0;i<10;i++){
  cout << X.at(i);
  }
  
}


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

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int l = sc.nextInt();
		int []a = new int [n];
		
		for(int i = 0; i < n ; i++) {
			a[i] = l + i;
		}
		int min = 100;
		int sum = 0;
		
		for(int j = 0; j < n ; j++) {
			if(Math.abs(min) > Math.abs(a[j])) {
				min = a[j];
			    }
			sum += a[j];	
		}
		System.out.println((sum - min));
		
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h> //g++-9で実行（gcc version 9.3.0），g++だとデフォルトのclang

using namespace std;

//#define int long long                         //intでオーバフローした時の切り替え用
#define debug(x) cerr << #x << ": " << x << endl //エラー出力として変数名と変数の中身表示
#define DEBUG_VEC(v)                   \
    cerr << #v << ":";                 \
    for (int i = 0; i < v.size(); i++) \
        cerr << " " << v[i];           \
    cerr << endl;
#define DEBUG_MAT(v)                          \
    cerr << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cerr << v[i][j] << " ";           \
        }                                     \
        cerr << endl;                         \
    }
#define Sp(p) cout << setprecision(25) << fixed << p << endl; //小数点以下を25桁で表示
#define all(obj) (obj).begin(), (obj).end()
#define pb push_back

//usingエイリアス（別名という意味，型定義のこと）
using ll = long long;
//template <class T> using Vec = std::vector<T>;//エイリアステンプレート

const ll MOD = (ll)1e9 + 7;
//const ll MOD = 998244353;
const ll INF = (ll)1e18 + 1;
const double EPS = 1e-9;
const long double pi = 3.1415926535897932384626433832795028841971L;

//マクロでintをlong longと定義したときはsinged
int main()
{
    cin.tie(0);                  //cinとcoutの同期を切る（高速化)
    ios::sync_with_stdio(false); //iostreamとstdioの同期を切る（高速化)


    ll X;
    cin >> X;
    for(ll A=0;A<INF;A++){
       ll tmp = A*A*A*A*A-X;
       if (tmp>=0){
               for(ll B=0;B<INF;B++){
                   ll tmp2 = B*B*B*B*B;
                   if (tmp2==tmp){
                       cout << A <<" "<< B << endl;
                       return 0;
                   }                   
                   else if(tmp2>tmp){break;}
               }
       }
       else{
           ll tmp3 = -1*tmp;
           for(ll B=0;B<INF;B++){
                   ll tmp2 = B*B*B*B*B;
                   if (tmp2==tmp3){
                       cout << A <<" "<< (-1)*B << endl;
                       return 0;
                   }
                   else if(tmp2>tmp3){break;}
               }
       }
    }
    return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<algorithm>
#include<stack>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n = 0;
int adl[MAX][MAX], deg[MAX];
int adm[MAX][MAX];
int color[MAX];
int d[MAX][2];
stack<int> depth;


void dfs() {
  int time = 1;
  for ( int i = 0; i < n; i++ ) {
    color[i] = WHITE;
  }
  depth.push(0);
  color[0] = GRAY;
  d[0][0] = time++;

  while (!depth.empty()) {
    int top = depth.top();

    int next = NIL;
    for (int i = 0; i < n; i++) {
      if (adm[top][i] == 1 && color[i] == WHITE) {
        next = i;
        depth.push(i);
        color[i] = GRAY;
        d[i][0] = time++;
        break;
      }
    }

    if (next == NIL) {
      color[top] = BLACK;
      d[top][1] = time++;
      depth.pop();
    }
    // WHITEになっている島を探す
    if (depth.empty()) {
      for (int i = 0; i < n; i++) {
        if (color[i] == WHITE) {
          depth.push(i);
          color[i] = GRAY;
          d[i][0] = time++;
          break;
        }
      }
    }

  }
}

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      adm[i][j] = 0;
    }
  }
  for ( int i = 0; i < n; i++ ) {
    int num;
    scanf("%d", &num);
    num--;
    scanf("%d", &deg[num]);
    for ( int j = 0; j < deg[num]; j++) {
      scanf("%d", &adl[num][j]);
      adl[num][j]--;
      adm[num][adl[num][j]] = 1;
    }
  }

  dfs();

  for ( int i = 0; i < n; i++ ) {
    printf("%d %d %d\n", i+1, d[i][0], d[i][1]);
  }



  return 0;
}



Measured memory_bytes: 2756
import sys

def find(A,i,B,j):#Bのｊ番目以降の文字列がAのi番目以降の文字列と一致する場合は１を返す
    if(A[i]!=B[j]):
        return 0
    elif(j==len(B)-1):
        return 1
    else:
        return find(A,(i+1)%len(A),B,j+1)



str=list(input())
key=list(input())
for i in range(0,len(str)):
    if(find(str,i,key,0)):
        print("Yes")
        sys.exit()
print("No")


Measured memory_bytes: 5580
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
static void Main(string[] args){
  var N = int.Parse(Console.ReadLine());
  var list=new List<int>();
  for(int i=0;i<N;i++){
  list.Add(int.Parse(Console.ReadLine()));
  }
  Console.WriteLine(list.Distinct().Count());
}
}

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {
	static final long MOD = 1000000007L;
	
	Main() {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		
		init(M);
		
		//全事象
		long ans = permutation(M, N) * permutation(M, N) % MOD;
		
		//余事象
		long sub = 0;
		for (int k = 1; k <= N; k++) {
			long temp = combination(N, k) * permutation(M-k, N-k) % MOD;
			
			if ( (k & 1) == 1 ) {
				sub = (sub + temp) % MOD;
			} else {
				sub = (sub - temp) % MOD;
				if (sub < 0L)
					sub += MOD;
			}
		}
		sub = sub * permutation(M, N) % MOD;
		ans = (ans - sub) % MOD;
		if (ans < 0L)
			ans += MOD;
		
		System.out.println(ans);
	}
	
	public static void main(String[] args) {
		new Main();
	}
	
	long[] fac, finv, inv;
	
	void init(int max) {
		max += 1;
		fac  = new long[max];
		finv = new long[max];
		inv  = new long[max];
		
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < max; i++) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[(int) (MOD % i)] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}
	
	long combination(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}
	
	long permutation(int n, int k){
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * finv[n-k] % MOD;
	}
}


Measured memory_bytes: 47640
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
void solve()
{
	string s; int k;
	cin >> s >> k;
	set<string>  v;
	for(int i = 1; i <= 5; ++i){
		for(int j = 0; j <= sz(s) - i; ++j){
			v.insert(s.substr(j, i));
		}
	}
	k--;
	while(k--) v.erase(v.begin());
	cout << *v.begin() << '\n';
}


 // a b c a b c a b c a b c
 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	//cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 1664
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 100010
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int n,cnt=0;
bool flag[N];
int main(){
//	freopen("a.in","r",stdin);
	n=read();
	for(int i=1;i<=n;++i){
		int x=read();if(!flag[x]) cnt++,flag[x]=1;
	}printf("%d\n",(n-cnt)&1?cnt-1:cnt);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void)
{

	int a[10];
	int i, ans;

	scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]);
	

	for (i = 0; i < 5; i++) {
		if (a[i] == 0) {
			ans = i + 1;
			break;
		}
	}

	printf("%d", ans);


	return 0;
}

Measured memory_bytes: 2144
#include <iostream>
#include <climits>
#include <vector>

class TMinimumMultiplications
{
	std::vector<std::vector<int> > FTable;
	std::vector<std::pair<int, int> >& FMatrixChain;
	
	int GetMinimum(int Begin, int End);
public:
	TMinimumMultiplications(std::vector<std::pair<int, int> >& MatrixChain);
	
	int Get(int Begin, int End);
};

TMinimumMultiplications::TMinimumMultiplications(std::vector<std::pair<int, int> >& MatrixChain)
: FMatrixChain(MatrixChain), FTable(MatrixChain.size(), std::vector<int>(MatrixChain.size(), -1))
{
}

int TMinimumMultiplications::GetMinimum(int Begin, int End)
{
	int Minimum = INT_MAX;
	for(int i = Begin; i < End; ++i){
		int Total = Get(Begin, i) + Get(i + 1, End) + FMatrixChain[Begin].first * FMatrixChain[i + 1].first * FMatrixChain[End].second;
		if(Minimum > Total) Minimum = Total;
	}
	return Minimum;
}

int TMinimumMultiplications::Get(int Begin, int End)
{
	if(Begin == End) return 0;
	if(FTable[Begin][End] < 0){
		FTable[Begin][End] = GetMinimum(Begin, End);
	}
	return FTable[Begin][End];
}

int main()
{
	int Count;
	std::cin >> Count;
	std::vector<std::pair<int, int> > MatrixChain;
	for(int i = 0; i < Count; ++i){
		int Row, Col;
		std::cin >> Row >> Col;
		MatrixChain.push_back(std::make_pair(Row, Col));
	}
	TMinimumMultiplications Minimum(MatrixChain);
	std::cout << Minimum.Get(0, MatrixChain.size() - 1) << std::endl;
	return 0;
}

Measured memory_bytes: 3172
//作者：中国江苏省南京市李硕睿
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
const int N=1e5+7;
vector<int> adj[N];
int mark[N];
int nim[N];
void dfs(int v,int p){
	for (auto u:adj[v])
		if (u!=p){
			dfs(u,v);
			nim[v]^=nim[u]+1;
		}
}
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for (int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--; 
		v--;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	dfs(0,-1);
	cout<<(nim[0] ? "Alice" : "Bob")<<"\n";
	return 0;
}

Measured memory_bytes: 12416
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma comment(linker, "/STACK:2000000")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'
using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 2e5+5, LG = 19, MOD = 1e9+7;
const int SQ =320;
const long double EPS = 1e-7;
int n, k;
int cnt[100005];
ll ans[100005];
int fast(int b,int e){
  int res=1;
  for(;e;e>>=1,b=1ll*b*b%MOD)
    if(e&1)res=1ll*res*b%MOD;
  return res;
}
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
  int n, k; cin >> n >> k;
  for(int j = 1; j <= k; j++){
    for(int i=j;i<=k;i+=j)cnt[j]++;
  }
  ll out=0;
  for(int i = k; i >= 1; --i){
    ans[i]+=fast(cnt[i],n);
    ans[i]%=MOD;
    for(int j = i+i;j<=k;j+=i)ans[i]-=ans[j];
    ans[i]%=MOD;
    if(ans[i]<0)ans[i]+=MOD;
    out+=ans[i]*i;
    out%=MOD;
  }

  cout<<out<<'\n';


  return 0;
}


Measured memory_bytes: 4812
n, x = map(int, input().split())
M = []
ans = 0
for i in range(n):
    m = int(input())
    M.append(m)
M.sort()
now = 0
#print(M)
for i in range(n):
    now += M[i]
    if now > x:
        print(ans)
        exit()
    else:
        ans += 1
while True:    
    now += M[0]
    if now > x:
        print(ans)
        exit()
    else:
        ans += 1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    ll a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);


    ll ans = 0; 

    if(a%2==1&&b%2==1&&c%2==1){
        ans = min(a*b,min(b*c,c*a));
    }
    
    cout << ans << endl;
    return 0;
}
 
 


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pll = P<LL,LL>;
using Pdd = P<double,double>;
using Psi = P<string,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T1,typename T2> using M = map< T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

int main(){
    int n;
    cin>>n;
    Vi v1(n/2),v2(n/2);
    V<Pii> p1(100005),p2(100005);
    REP(i,100001){
        p1[i].se = i;
        p2[i].se = i;
    }
    REP(i,n/2){
        cin>>v1[i]>>v2[i];
        p1[v1[i]].fi++;
        p2[v2[i]].fi++;
    }

    sort(ALL(p1),greater<Pii>());
    sort(ALL(p2),greater<Pii>());

    if(p1[0].se != p2[0].se){
        int c1 = n/2 - p1[0].fi;
        int c2 = n/2 - p2[0].fi;
        cout<<c1+c2<<endl;
    }else{
        int c1_1 = n/2 - p1[0].fi;
        int c2_1 = n/2 - p2[1].fi;
        int c1_2 = n/2 - p1[1].fi;
        int c2_2 = n/2 - p2[0].fi;
        cout<<min(c1_1+c2_1,c1_2+c2_2)<<endl;
    }

    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    int n, m=0, flag=0;
    int num=1;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++){
        if(a[i]!=num){ m++; }
        else         { num++; flag=1; }
    }
    if(!flag) m = -1;
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 1024
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$M) = explode(" ",trim(fgets(STDIN)));
//$v = explode(" ",trim(fgets(STDIN)));
$S = trim(fgets(STDIN));
$T = trim(fgets(STDIN));

$L = lcm($N,$M);

for($i=1;$i<5;$i++) {
  $sz = $i*$L;
  $a = array();

  $ng = 0;
  for($j=0;$j<=$N-1;$j++) {
    $p = (int)($j*($sz/$N))+1;
    if (isset($a[$p-1])&&$a[$p-1]!=$S[$j]) {
      $ng = 1;
      break;
    }
    $a[$p-1]=$S[$j];
  }
  for($j=0;$j<=$M-1;$j++) {
    $p = (int)($j*($sz/$M))+1;
    if (isset($a[$p-1])&&$a[$p-1]!=$T[$j]) {
      $ng = 1;
      break;
    }
    $a[$p-1]=$T[$j];
  }
  if ($ng == 0) {
    printf("%d\n",$i*$L);
    exit;
  }
}
printf("-1\n");

function gcd($a,$b) {
    if ($b == 0) return $a;
      return gcd($b,$a%$b);
}
function lcm($a,$b) {
    $l = gcd($a,$b);
      return $a / $l * $b;
}


Measured memory_bytes: 33188
#include <stdio.h>
int main(void){
	int n;
	int i;
	int c;
	int d=0;
	scanf("%d",&c);
	for(i=1;i<10;i++){
		for(n=1;n<10;n++){
			if(i*n == c){
				d++;
			}
		}
	}
	if(d==0){
		printf("No");
	}else{
		printf("Yes");
	}
return(0);
}

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

int main() {
  int height, width;
  char s[100][101], fs[102][103];
  
  cin >> height >> width;
  rep(i, height)
    scanf("%s", s[i]);
  
  rep(i, height + 2){
  	rep(j, width + 2)
      fs[i][j] = '#';
  }
  
  rep(i, height){
  	rep(j, width)
      fs[i+1][j+1] = s[i][j];
  }
  
  rep(i, height + 2){
  	rep(j, width + 2)
      cout << fs[i][j];
    cout << endl;
  }
  
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n * 3];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        Arrays.sort(a);
        long result = 0;
        for (int i = 0; i < 2 * n; i += 2) {
            result += a[n * 3 - 1 - (i + 1)];
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 68936
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  string t;
  cin>>t;
  int flag=1;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      cout<<"No"<<endl;
      flag=0;
      break;
    }
  }
  if(flag==1){
    cout<<"Yes"<<endl;
  }
  return 0;
}
      

Measured memory_bytes: 3620