akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;


namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            int N = int.Parse(Console.ReadLine());
            var a = cin.SplitReader();
            int M = a.Max();
            int m = a.Min();
            int c = a.Count(x => x == m);
            string ans;

            if (M - m > 1) { ans = "No"; }
            else
            {
                if (M == m)
                {
                    if (m == N - 1 || N / 2 >= m)
                    {
                        ans = "Yes";
                    }
                    else
                    {
                        ans = "No";
                    }
                }
                else
                {
                    if (M > c && (N - c) / 2 >= M - c)
                    {
                        ans = "Yes";
                    }
                    else
                    {
                        ans = "No";
                    }
                }
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
        }

        

    }
    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

   public static class Tool
        {
            static public void Initialize<T>(ref T[] array, T initialvalue)
            {
                for (var i = 0; i < array.Length; i++)
                {
                    array[i] = initialvalue;
                }
            }
            static public long ModuloP(long value, long mod)
            {
                long r = value % mod;

                if (r * mod < 0)
                {
                    r += mod;
                }
                return r;
            }

        }

   struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
   {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
   }

    


}






Measured memory_bytes: 20192
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //配列(vector)vの重複要素を削除


void solve(){
    ll h, w;
    cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << '\n';
        exit(0);
    }

    if(h%2 == 0){
        cout << (h/2)*w << '\n';
    }else{
        cout << h*(w/2) + (h/2 + 1)*(w%2) << '\n';
    }
}

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

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	char w[10],t[1000],c[]="END_OF_TEXT";
	int count=0,i,i2;
	cin>>w;
	while(1){
		cin>>t;
		if(strstr(t,c)!=NULL){break;}
		for(i=0;t[i]!='\0';i++){
			if(t[i]-'a'<0){
				t[i]=t[i]+32;
			}
		}
		if((strlen(w))==(strlen(t))){
			if(strstr(t,w)!=NULL){
				count++;
			}
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string s;
    string S; cin >> S;
    s = S;
    int ans = 1e5;
    for(int i = 0; i < 26; i++) {
        char c = (char)('a'+i);
        int cnt = 0;
        S = s;
        while(1) {
            bool ok = true;
            int M = S.size();
            char pre = S[0];
            REP(i,M) {
                if(pre != S[i]) ok = false;
                pre = S[i];
            }
            if(ok) break;
            string T = "";
            REP(i,M-1) {
                if(S[i] == c || S[i+1] == c) T += c;
                else T += S[i];
            }
            cnt++;
            //cout << T << endl;
            S = T;
        }
        chmin(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;


template <class T> T gcd(T a, T b){
    if(b>a) T tmp = a, a=b, b=tmp;
    if(b==0) return a;
    else return gcd(b,a%b);
}

template <class T> T gcd_n(const vector<T> &V){
    T tmp=V[0];
    for( auto v : V) tmp = gcd(tmp, v);
    return tmp;
}

template <class T> T lcm(T a, T b){
    if(a==0 || b==0) return 0;
    else 
    {
        T g=gcd(a,b);
        return g*(a/g)*(b/g);
    }
}
template <class T> T lcm_n(const vector<T> &V){
    T gcd_ = gcd_n(V);
    T tmp = V[0];
    for(auto v : V) tmp = lcm(tmp, v);
    return tmp;
}

int main(){
    int n;
    cin >> n;
    vector<int> V(n);
    REP(i,n) cin >> V[i];
    cout << gcd_n(V) << endl;
    return 0;
}

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

int main(){
	string str;
	cin >> str;
	int M = str.length();
	int N = 0, W = 0, S = 0, E = 0;
	for(int i = 0; i < M; i++){
		if(str[i] == 'N')N++;
		if(str[i] == 'W')W++;
		if(str[i] == 'S')S++;
		if(str[i] == 'E')E++;
	}
	//N - S, W - E
	
	bool J = true;
	bool D = true;
	
	if(min(N, S) == 0){
		if(max(N, S) != 0){
			J = false;
		}else{
			J = true;
		}
	}
	
	if(min(W, E) == 0){
		if(max(W, E) != 0){
			D = false;
		}else{
			D = true;
		}
	}
	
	cout << ((J && D) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_STR_MAX		200005									// 最大文字列長
#define D_CHAR_CNT		26										// 文字種類数

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Str[D_STR_MAX];									// 文字列

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
long long
fMain(
)
{
	int i;

	// 文字列 - 取得
	fgets(sc1Str, sizeof(sc1Str), szpFpI);

	// 文字数
	int li1Cnt[D_CHAR_CNT];
	memset(li1Cnt, 0, sizeof(li1Cnt));

	// パターン数 - 取得
	long long llPCnt = 1;
	for (i = 0; ; i++) {
		int liNo = sc1Str[i] - 'a';
		if (liNo < 0 || D_CHAR_CNT <= liNo) {
			break;
		}

		// パターン数 - 加算
		llPCnt += i - li1Cnt[liNo];

		// 文字数 - 加算
		li1Cnt[liNo]++;
	}

	return llPCnt;
}

// １回実行
int
fOne(
)
{
	long long llRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	llRet = fMain();

	// １行出力
	sprintf(lc1Buf, "%lld\n", llRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll v[500][50],v2[500][50],a[10005];
char s[100][8];
int main()
{
    ll n,m,k,i,j,l,ans=0,K,x=1,y=1,r,d;
    scanf("%lld",&n);
   for(i=1;i<=n;i++)
   {
       scanf("%lld",&a[i]);
       if(i%2==1&&a[i]%2==1)
       {
           ans++;
       }
   }
   printf("%lld\n",ans);



    return 0;

}


Measured memory_bytes: 3736
#include<stdio.h>
#include<string.h>
 
int lcs(char *x, char *y){
    int c[1001][1001],i,j;
    int numberx = strlen(x)+1;
    int numbery = strlen(y)+1;
    int maxl=0,max=0;
 
     
    for(i=1;i<numberx;i++){
        for(j=1;j<numbery;j++){
            if(x[i-1]==y[j-1])
                c[i][j]=c[i-1][j-1]+1;
            else{
                if(c[i-1][j]>c[i][j-1]) c[i][j] = c[i-1][j];
                else c[i][j]=c[i][j-1];
            }
            if(c[i][j]>maxl) maxl=c[i][j];
        }
    }
    return maxl;
}
 
int main(){
    char s1[1001],s2[1001];
    int n,i;
     
    scanf("%d",&n);
     
    for(i=0;i<n;i++){
        scanf("%s",s1);
        scanf("%s",s2);
        printf("%d\n",lcs(s1,s2));
    }
    return 0;
}


Measured memory_bytes: 5656
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
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; }

int main(){
	int n; cin>>n;
	vector<int> a(n);
	rep(i,0,n) cin>>a[i];
	int cnt=0;
	rep(i,0,n){
		if(i%2==0){
			if(a[i]%2==1) cnt++;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> s(100020);
	long long int sum = 0;
	priority_queue<int> q;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		if (a > M) {
			continue;
		}
		s[a].push_back(b);
	}
	for (int i = 1; i <= M; i++) {
		int max = 0;
			for (int j:s[i]) {
				q.push(j);
			}
		if (!q.empty()) {
			max = q.top();
			q.pop();
		}
		sum = max + sum;
	}
	cout << sum;
}

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

import numpy as np

U = 10 ** 5
is_prime = np.zeros(U+1, dtype=np.bool)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3,U+1,2):
    if p*p > U:
        break
    if is_prime[p]:
        is_prime[p*p::2*p] = 0

primes = is_prime.nonzero()[0].astype(np.int64)

MM = 510
M = 255

A = np.ones((MM,MM), dtype = np.int64)
for n in range(MM):
    if n % 2 == 0:
        A[n,::2] *= primes[n//2:n//2+M]
        A[n,::2] *= primes[MM+M-n//2:2*MM-n//2]
        A[n,1::2] *= A[n,::2]
        A[n,1:-1:2] *= A[n,2::2]
        A[n,1::2] += 1
    elif n % 2 == 1:
        A[n,1::2] *= primes[(n+1)//2:(n+1)//2+M]
        A[n,1::2] *= primes[MM+M-(n-1)//2:2*MM-(n-1)//2]
        A[n,::2] *= A[n,1::2]
        A[n,2::2] *= A[n,1:-1:2]
        A[n,::2] += 1

N = int(input())
A = A[1:N+1,1:N+1]

answer = '\n'.join(' '.join(row) for row in A.astype(str))
print(answer)

Measured memory_bytes: 40972
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int main() {
	int n, a, b, ans[3];
	fill(ans, ans + 3,0);
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		if (k <= a)ans[0]++;
		else if (k <= b)ans[1]++;
		else ans[2]++;
	}
	cout << min(ans[0], min(ans[1], ans[2])) << endl;
}


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

using namespace std;

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

	int n, m;
	cin >> n >> m;

	vector<pair<int, int> > a;
	for(int i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		a.emplace_back(x, y);
	}

	sort(a.begin(), a.end());
	long long ans = 0;
	for(int i = 0; i < n; ++i) {
		long long d = min(m, a[i].second);
		ans += d * a[i].first;
		m -= d;
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 4212
#include <cstdio>
#include <cmath>
#define Inf 5000000000000000

int main(){
    char s[101];
    unsigned long long k;
    scanf("%s\n%lld",s,&k);
    int a;
    unsigned long long count = 0;
    for(int i = 0; s[i] != '\0'; i++){
        a = s[i] - 48;
        if(a == 1){
            count++;
            if(count == k){
                printf("%d\n",a);

                return 0;
            }
            continue;
        }else{
            for(unsigned long long j = 1; j <= Inf; j++){
                if(count + pow(a,j) >= k){
                    printf("%d\n",a);

                    return 0;
                }
            }
            count += pow(a,Inf);
        }
    }

    return 0;
}

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

int main() {
	int x, y;
	cin >> x >> y;

	if (x * 4 < y || y % 2 == 1 || y < x*2) {
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;


	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define wi while
#define vl vector<ll>
#define vi vector<int>
#define map map<char,ll>
#define endl "\n"
const int mxN = 200001;
int main()
{
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt = 1;
    for(int i=1;i<s.size();++i)
    {
        if(s[i]==s[i-1])
            continue;
        else
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;

}


Measured memory_bytes: 3704
#include <iostream>

using namespace std;

int n;
int a[100005];
int l[100005], r[100005];

int gcd(int a, int b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}

int main(void)
{
	cin >> n;
	for(int i = 1; i<= n; i++ ) cin >> a[i];
	
	for(int i = 1; i <= n; i++) l[i] = gcd(l[i-1], a[i]);
	for(int i = n; i >= 1; i--) r[i] = gcd(r[i+1], a[i]);
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans = max(ans, gcd(l[i-1], r[i+1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long multi_GCD(vector<long long>&v) {
	long long m = v[0];
	for (int i = 0; i < v.size() - 1; i++) {
		m = GCD(m, v[i + 1]);
	}
	return m;
}
int main() {
	int n, x;
	cin >> n >> x;
	vector<ll>v(n);

	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	v.push_back(x);
	vector<ll>nv(n, 0);
	for (int i = 0; i < n; i++) {
		nv[i] = abs(v[i] - v[i + 1]);
	}
	cout << multi_GCD(nv) << endl;
}

//#define int long long
//signed main() {	
//}

Measured memory_bytes: 1792
def main():
    n, a, b = map(int, input().split())
    if a == b:
        print(1)
        return 0
    elif a > b or n == 1:
        print(0)
        return 0
    else:
        print((b-a)*(n-2)+1)
        return 0

if __name__ == '__main__':
    main()


Measured memory_bytes: 61844
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<limits>
#include<stack>
#include<array>
#include<stdio.h>
#include<cstring>

using namespace std;

typedef unsigned long long ll;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;

int INF = 1000000009; //std::numeric_limits<int>::max();
ll LLINF = 1e15;
int NINF = std::numeric_limits<int>::min();
int MOD = 1e9+7;

int col[] = {1,0,-1,0,1,1,-1,-1};
int row[] = {0,1,0,-1,1,-1,1,-1};

//knight moves
int cc[] = {1,2,2,1,-1,-1,-2,-2};
int rr[] = {-2,-1,1,2,-2,2,1,-1};


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios::sync_with_stdio(0);
    //cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    cout << (a+b)%24 ;
    
    
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<class T>
struct Edge
{
    T to;
    T cost;

    Edge(T to, T cost) :
        to{ to },
        cost{ cost }
    {}
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;

/*!
@fn dijkstra
@brief 重み付き有向グラフにおける単一始点sからの最短路を計算する
*/
template<class T>
vector<T> dijkstra(T s, const WeightedGraph<T>& g)
{
    const auto INF = numeric_limits<T>::max();
    vector<T> d(g.size(), INF);

    using P = pair<T, T>;
    priority_queue<P, vector<P>, greater<P>> que;

    d[s] = 0;
    que.emplace(d[s], s);

    while (!que.empty()) {
        P p = que.top();
        que.pop();

        T v = p.second;

        if (d[v] < p.first) {
            continue;
        }

        for (const auto& e : g[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.emplace(d[e.to], e.to);
            }
        }
    }

    return d;
}

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

    WeightedGraph<ll> g(N);

    for (ll i = 0; i < N-1; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;

        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }

    ll Q, K;
    cin >> Q >> K;
    --K;

    auto d = dijkstra(K, g);

    for (ll i = 0; i < Q; ++i) {
        int x, y;
        cin >> x >> y;
        --x; --y;

        cout << d[x] + d[y] << endl;
    }

    return 0;
}


Measured memory_bytes: 11120
S = input()
N = len(S)
ans = 0
pl = ["", "+"]

for n in range(2**(N-1)):
  b = "{:012b}".format(n)
  b = b[12-N+1:]
  eval_str=""
  for i in range(N-1):
    eval_str = eval_str + S[i] + pl[int(b[i])]
  eval_str = eval_str + S[N-1]
  ans = ans + eval(eval_str)
print(ans)

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

int main() {
  int a,b,c;
  cin >> a >> b;
  c = a*b;
  
  if(c %2 == 0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
}



Measured memory_bytes: 3608
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(A: int, B: int, C: int):
    ret = max(0, C - (A - B))
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
bool call=0; ll ansss;
void grader(){ //ansss=rand(1,10);
	cin>>ansss;
	call=1;
} void backans(ll ans){if(ans!=ansss){cerr<<ansss<<'\n';assert(0);}}
bool ask(ll x) { if(x<=ansss)return to_string(x)<=to_string(ansss); else return to_string(x)>to_string(ansss);}
ll query(ll x) { if(x==0)return 1; if(call)return ask(x);
	cout<<"? "<<x<<endl;
	char ans; cin>>ans;
	return ans=='Y';
}
ll gen(ll zeros){
	ll num=1;
	while(zeros--)num*=10;
	return num;
}
void check(){
	if(query(100000000000ll)){
		ll test=99999999999ll;
		while(test!=0&&query(test)){
			test/=10;
		}
		cout<<"! "<<(test>0?gen((ll)log10l(test)+1):1)<<'\n'; exit(0);
	}
}
int main()
{
	FAST
	// while(1){grader();
	check();
	ll start=1;
	while(query(start)){
		start*=10;
	}
	// while yes set en, st ans tho
	ll st=start/10,en=start-1,mid=0;
	while(en-st>1){
		mid=(st+en)>>1ll;
		if(query(mid*10)==0)st=mid;
		else en=mid;
	}
	cout<<"! "<<en<<'\n';
	// backans(en);}
}


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

int min(int a,int b){return a < b ? a : b;}

int main()
{
    int n,v[100000],num[100005][2] = {0},i,j,max[2][2] = {0};

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&v[i]);
        num[v[i]][i % 2]++;
    }

    for (i = 0; i < 2; i++)
    {
        for (j = 0; j <= 100000; j++)
        {
            if(num[max[i][0]][i] < num[j][i])
            {
                max[i][1] = max[i][0];
                max[i][0] = j;
            }
            else if (num[max[i][1]][i] < num[j][i])
            {
                max[i][1] = j;
            }
        }
    }
    if(max[0][0] != max[1][0])
    {
        printf("%d",n - num[max[0][0]][0] - num[max[1][0]][1]);
    }
    else if(max[0][1] == 0 || max[1][1] == 0)
    {
        printf("%d",n / 2);
    }
    else
    {
        printf("%d",min(n / 2 - num[max[0][1]][0] + n / 2 - num[max[1][0]][1] , n / 2 - num[max[1][1]][1] + n / 2 - num[max[0][0]][0]));
    }
    
}

Measured memory_bytes: 1280
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::HashMap;

fn main() {
    input!{
      n: usize,
      aa: [usize; n],
    }
    let mut aa = aa;
    aa.sort();

    let mut map: HashMap<usize, Vec<usize>> = HashMap::new();

    let mut used = vec![false; n];
    let mut ans = 0;

    for i in 0..n {
        let a = aa[i];
        let e = map.entry(a).or_insert(vec![]);
        e.push(i);
    }

    for r in (0..n).rev() {
        if used[r] {
            continue;
        }

        let a = aa[r];
        for x in 0..32 {
            let p = 2usize << x;
            if p < a {
                continue;
            }
            let t = p - a;
            if let Some(vs) = map.get_mut(&t) {
                while let Some(v) = vs.pop() {
                    if v != r && !used[v] {
                        used[v] = true;
                        used[r] = true;
                        ans += 1;
                        break;
                    }
                }
            }
            if used[r] {
                break;
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 24692
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  int n,k; cin>>n>>k;
  vector<int>p(n);
  for(auto &i:p) cin>>i;
  sort(p.begin(),p.end());
  int ans{};
  for(int i=0; i<k; i++){
    ans += p.at(i);
  }
  cout << ans << endl;
  
  
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
int f(int n,int k) {
	if(n==1) return 0;
	return (f(n-1,k)+k)%n;
}
int main() {
	int n,k,m;
	while(scanf("%d %d %d",&n,&k,&m),n) {
		printf("%d\n",(m+f(n-1,k))%n+1);
	}
}

Measured memory_bytes: 3396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) cout << "Left" << endl;
  else if (A + B == C + D) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    string s, t; cin >> s >> t;
    cout << (s == t.substr(0, s.length()) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
    ll n,k,s;
    cin>>n>>k>>s;
    ll a[n];
    for(int x=0;x<k;x++)
    {
        a[x]=s;
    }
    if(s==1e9)
    {
        for(int x=k;x<n;x++)
        {
            a[x]=1;
        }
    }
    else
    {
        for(int x=k;x<n;x++)
        {
            a[x]=s+1;
        }
    }
    for(int x=0;x<n;x++)
        cout<<a[x]<<" ";
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define er erase
#define bg begin()
#define ed end()
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define enter cout << "\n"
#define space cout << " "
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (n); ++i)
#define fj(st,n) for (int j = (st); j <= (n); ++j)
#define fk(st,n) for (int k = (st); k <= (n); ++k)
#define fq(st,n) for (int q = (st); q <= (n); ++q)
#define fw(st,n) for (int w = (st); w <= (n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (n); ++(i))
#define ei(st,n) for (int i = (st); i >= (n); --i)
#define ej(st,n) for (int j = (st); j >= (n); --j)
#define ek(st,n) for (int k = (st); k >= (n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (n); --(i))
#define ri(st,n) for (int i = (st); i < (n); ++i)
#define rj(st,n) for (int j = (st); j < (n); ++j)
#define rk(st,n) for (int k = (st); k < (n); ++k)
#define rq(st,n) for (int q = (st); q < (n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = (int)1e9;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 10000007;
const int maxn = (int) 2 * 1e4 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

ll ans;
ll n, a[maxn], st, s, tok;
pair <ll, ll> d[maxn][11];

int main() {
//    fin("t.in");
    sync;
    cin >> n;
    fi(1, n) {
    	cin >> a[i];
    }
    ans = 0;
    st = 1;
    fi(0, 18) {
    	memset(d, -1, sizeof d);
    	d[1][0].X = 0;
    	d[1][0].Y = 0;
    	fj(1, n) {
    		fk(0, 9) {
    			d[j + 1][k] = d[j][k];
    		}
    		fk(0, 9) {
    			if (d[j][k].X == -1)
    				continue;

    			s = d[j][k].X + a[j];
    			tok = ((ll)k + (s / st)) % 10;
    			if (d[j + 1][tok].X == -1)
    				d[j + 1][tok] = mp(s % st, s % st);
  				d[j + 1][tok].X = min(d[j + 1][tok].X, s % st);
  				d[j + 1][tok].Y = max(d[j + 1][tok].Y, s % st);

    			s = d[j][k].Y + a[j];
    			tok = ((ll)k + (s / st)) % 10;
    			if (d[j + 1][tok].X == -1)
    				d[j + 1][tok] = mp(s % st, s % st);
  				d[j + 1][tok].X = min(d[j + 1][tok].X, s % st);
  				d[j + 1][tok].Y = max(d[j + 1][tok].Y, s % st);

    		}
    	}
    	ej(9, 1) {
    		if (d[n + 1][j].X != -1) {
    			ans += j;
//    			cout << j << endl;
    			break;
    		}
    	}
    	st *= 10;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


 
int main() {
	int N, K;
	cin >> N >> K;
	
	vector<int> A(N);

	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		A[i] = a;		
	}
	
	sort(A.begin(), A.end(),std::greater<int>());
	
	long long sum = 0;
	for(int i = K; i < N; i++){
		sum += A[i];
		
	}
	
	cout << sum << endl;
	//for(const auto & e: A) cout << e << " ";
	
	
	
    return 0;
}





Measured memory_bytes: 1024
#include<stdio.h>

#define INFTY 300000000;

int min(int a, int b){
  return a > b ? b : a;
}

int max(int a, int b){
  return a > b ? a : b;
}

int main(){
  int n, k;
  scanf("%d %d", &n, &k);
  
  int x[n];
  int th = 0;
  for(int i = 0; i < n; i++){
    int in;
    scanf("%d", i + x);
  }
  
  int ans = INFTY;
  
  int *left = x + max(th - k, 0);
  int *right = x + min(left + k - 1 - x, n - 1);
  
  while(right < x + n){
    ans = min(ans, max(-*(left), *(right)) + 2 * min(-min(*(left), 0), max(*(right), 0)));
    left++;
    right++;
  }
  
  printf("%d", ans);
  
  return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;

int main() {
	int H, W, N;
	cin >> H >> W >> N;
	
	typedef pair< int, int > pii;
	map< pii, int > cnt;
	for_(i,0,N) {
		int a, b;
		cin >> a >> b;
		for_(y,-2,1) for_(x,-2,1) {
			int yy = a + y, xx = b + x;
			if (yy < 1 || yy > H-2 || xx < 1 || xx > W-2) continue;
			cnt[pii(yy, xx)]++;
		}
	}
	
	vector< lint > ans(10, 0);
	for (auto x : cnt) ans[x.second]++;
	ans[0] = lint(H-2) * (W-2) - accumulate(ans.begin() + 1, ans.end(), lint());
	
	for_(i,0,10) cout << ans[i] << endl;
}

Measured memory_bytes: 56448
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)   (((a) > (b)) ? (a) : (b))       /* ２個の値の最大値 */
#define min(a, b)   (((a) < (b)) ? (a) : (b))       /* ２個の値の最小値 */
#define ENTER       printf("\n")                    /* 改行プリント */
int DBG = 0;                                        /* デバッグプリント 提出時は0 */
/* main *************************************************************/
int calc(long long x) {
    int i = 0;
    while (x >0) {
        i += x % 10;
        x /= 10;
    }
    return i;
}
int main()
{
    int     p,a,b,c,i,j,k,n,m,x,y,ans = 0;
    long long lx ;

    scanf("%d %d %d", &a, &n, &m);

    for(y=1;y<=m;y++) {
        lx = y+a;
        for(i=2;i<=n;i++) {
            lx *= y+a;
        }
        if (lx > m) break;
        if (calc(lx) == y) ans++;
        if (DBG) printf("y:%d lx:%lld x:%d ans:%d\n",y,lx,x,ans);
    }

    printf("%d\n", ans);

    return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    
    vector<vector<int> > e(N, vector<int>());
    vector<int> in_num(N, 0);
    for(int i=0; i<N-1+M; i++) {
        int s, t;
        cin >> s >> t;
        e[s-1].push_back(t-1);
        in_num[t-1]++;
    }
    
    queue<int> que;
    for(int i=0; i<N; i++) {
        if(in_num[i]==0) {
            que.push(i);
        }
    }
    
    vector<int> ans(N, 0);
    while(!que.empty()) {
        int tmp=que.front();
        que.pop();
        for(int i=0; i<e[tmp].size(); i++) {
            in_num[e[tmp][i]]--;
            if(in_num[e[tmp][i]]==0) {
                que.push(e[tmp][i]);
                ans[e[tmp][i]] = tmp+1;
            }
        }
    }
    
    for(int i=0; i<N; i++) {
        cout << ans[i] << endl;
    }

    return 0;
    
}

Measured memory_bytes: 7040
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  int line[n],i,cnt=0;
  
  for(i = 0 ; i < n ; i++){
      scanf("%d",&line[i]);
  }
  
  for(i = 1 ; i < n - 1 ; i++){
      if((line[i+1] > line[i] && line[i] > line[i-1])||(line[i+1] < line[i] &&line[i] < line[i-1])){
          cnt++;
      }
  }
  
  printf("%d",cnt);
  
  
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
using namespace std;
#define INF 100000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

//http://drken1215.hatenablog.com/entry/2019/03/17/130800
vector<int> places[210000];
ll dp[210000];
void add(ll &a,ll b){
    a+=b;
    if(a>=MOD) a-=MOD;
}

int main(){
    int N;
    cin>>N;
    vector<int> c(N);
    for(int i=0;i<N;i++) cin>>c[i];

    for(int i=0;i<210000;i++) places[i].clear();
    for(int i=0;i<N;i++) places[c[i]].push_back(i);

    dp[0]=1;
    for(int i=1;i<=N;i++){
        add(dp[i],dp[i-1]);

        int color=c[i-1];
        int it=lower_bound(places[color].begin(),places[color].end(),i-1)-places[color].begin();
        if(it>0){
            int j=places[color][it-1];
            if((i-1)-j>1) add(dp[i],dp[j+1]);
        }
    }
    cout<<dp[N]<<endl;
}



Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c[101],cnt=0;
	cin>>a>>b;
	for (int i=0;i<a;i++)
		c[i]=0;
	for (int i=a;i<101;i++)
		c[i]=2;
	for (int i=0;i<b;i++)
	{
		int d;
		cin>>d;
		for (int n=0;n<d;n++)
		{
			int e;
			cin>>e;
			c[e-1]=1;
		}
	}
	for (int i=0;i<a;i++)
		if (c[i]==0)
			cnt++;
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
    ll n, ans = 1e18;
    cin >> n;
    for(ll i = 1; i*i <= n; ++i){
        if(n%i != 0) continue;
        ll j = n/i;
        ans = min(ans, i+j-2);


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


  

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int x,y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x==0 && y==0)break;
        if(x >= y) printf("%d %d\n", y, x);
        else if(x < y) printf("%d %d\n", x, y);
        //if(x > y) printf("%d %d\n", x, y);
    }
}


Measured memory_bytes: 2708
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

""" 道は一本！ """

N, M = map(int, readline().split())
H = [0] + list(map(int, readline().split()))
A = [0] * (N + 1)

m = map(int, read().split())
for a, b in zip(m, m):
    for _ in range(2):
        A[a] = max(A[a], H[b])
        a, b = b, a

print(sum(x > y for x, y in zip(H, A)))

Measured memory_bytes: 25728
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    ll N, c=1, count=0;

    cin >> N;

    vector<int> a(N);

    rep(i,N) {
        cin >> a[i];
        if(c!=a[i]) {
            count++;
        } else {
            c++;
        }
    }

    if(c==1) {
        cout << -1 << endl;
    } else {
        cout << count << endl;
    }

    return 0;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a;
  
  cin >> n;
  cin >> a;
  
  int r = n % 500;
  
  if (r <= a) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3632
function main(input) {
  let [a,b,h,m] = input[0].trim().split(" ").map(i => parseInt(i));
  const p = [(h*5*6)+30/60*m,m*6];
  const diff = Math.max(...p)-Math.min(...p);
  const rad = Math.min(diff, 360-diff) * Math.PI / 180;
  const cosine = Math.cos(rad);
  const result = a*a + b*b - (2*a*b*cosine);
  console.log(Math.sqrt(result));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 29820
N,M = map(int,input().split())
total_value_p_p_p = []
total_value_p_p_m = []
total_value_p_m_p = []
total_value_p_m_m = []
total_value_m_p_p = []
total_value_m_p_m = []
total_value_m_m_p = []
total_value_m_m_m = []

for _ in range(N):
    A,B,C = map(int,input().split())
    total_value_p_p_p.append(A+B+C)
    total_value_p_p_m.append(A+B-C)
    total_value_p_m_p.append(A-B+C)
    total_value_p_m_m.append(A-B-C)
    total_value_m_p_p.append(-A+B+C)
    total_value_m_p_m.append(-A+B-C)
    total_value_m_m_p.append(-A-B+C)
    total_value_m_m_m.append(-A-B-C)


def f(value):
    value = sorted(value ,key=lambda x:-x)
    return sum(value[:M])

total_value_list = [total_value_p_p_p,
                    total_value_p_p_m,
                    total_value_p_m_p,
                    total_value_p_m_m,
                    total_value_m_p_p,
                    total_value_m_p_m,
                    total_value_m_m_p,
                    total_value_m_m_m]
ans = 0
for a in total_value_list:
 ans = max(ans , f(a))

print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <array>
#include <algorithm>

using namespace std;

array<array<int, 2>, 100000> number;

int judge(int N) {
	static int count = 0;
	if (N == -2) {
		return -1;
	}
	else if (N == 1) {
		return count;
	}else if (number[N][1] == 0) {
		count++;
		number[N][1] = -2;
		judge(number[N][0]-1);
	}else {
		judge(-2);
	}
}

int main(void) {
	
	int roop;
	cin >> roop;
	for (int i = 0; i < roop; i++) {
		cin >> number[i][0];
	}

	cout << judge(0) << endl;
	return 0;
}



Measured memory_bytes: 1024
N = int(input())
W = [input() for _ in range(N)]
flag = True
InitChar = W[0][0]

for i in W:
    if i[0] == InitChar:
        InitChar = i[-1]
    else:
        flag = False
        break

if len(set(W)) != len(W):
    flag = False

print("Yes" if flag else "No")

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

using namespace std;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
	
	int N; cin>>N;
	vector<long> A(N+1), B(N);
	for (auto& a : A) cin>>a;
	for (auto& b : B) cin>>b;
	long ans = 0;
	long cap = 0;
	for (size_t i = 0; i <= N; i++) {
	    long beat_pred = min(cap, A[i]);
	    ans += beat_pred;
	    A[i] -= beat_pred;
	    if (i == N)
	        break;
	    long beat_now = min(B[i], A[i]);
	    ans += beat_now;
	    cap = B[i] - beat_now;
	}
	cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl


using ll = long long;
const ll mod = 1e9+7;
#define int long long


signed main(){
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  bool flag=1;
  ll ans=3;

  bool flag2=0;
  if(s[0]==t[0]){
    flag2=1;
  }
  for(int i=0;i<n;i++){
    if(s[i]==t[i] && flag){
      if(flag2){
        flag=1;
        flag2=0;
        continue;
      }
      ans=((ans%mod)*2)%mod;
      flag=1;
    }
    else if(s[i]!=t[i] &&flag){
      i++;
      ans=((ans%mod)*2)%mod;
  //    ans%=mod;
      flag=0;
    }else if(s[i]==t[i]&& !flag){
      flag=1;
    }
    else if(s[i]!=t[i]&&!flag){
    //  ans%=mod;

      ans=(3*(ans%mod))%mod;
      //ans%=mod;
      flag=0;
      i++;
    }
  //  ans%=mod;

  }
  //dump(ans);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int w;
	int n;

	cin >> w >> n;
	int ws[w+1];

	for(int i = 1; i <= w; ++i)ws[i] = i;

	for(int i = 0; i < n; ++i){
		int a,b;
		int tmp;
		char d;
		cin >> a >> d >>b;
		tmp   = ws[a];
		ws[a] = ws[b];
		ws[b] = tmp;
	}
	
	for(int i = 1; i <= w; ++i)cout << ws[i] << endl;

	return 0;
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

//ceil(n/m)
int int_ceil(int n, int m)
{
	if (n % m == 0) return n / m;
	return n / m + 1;
}

signed main()
{
	int N;
	int A[5];
	cin >> N;
	REP(i, 5) cin >> A[i];

	int cur = N;
	for (int i = 0; i < 5; i++)
	{
		cur = min(cur, A[i]);
	}
	
	int n = int_ceil(N, cur);
	cout << n + 4 << endl;
}



Measured memory_bytes: 3156
n,x=map(int, input().split())
if x==1 or x==2*n-1:print('No')
else:
    print('Yes')
    a=list(range(1,2*n))
    b=[]
    b.append(a.pop(x))
    b.append(a.pop(x-1))
    b.append(a.pop(x-2))
    for i in a[:n-2]+b+a[n-2:]:
        print(i)

Measured memory_bytes: 14540
import java.util.Scanner;

public class Main {

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

		String a = sc.nextLine();
		String[] aArray = a.split("");
		
		int res = 0;
		
		for(int i=0; i<aArray.length; i++) {
			if(aArray[i].equals("1")) {
				res++;
			}
		}
		
		System.out.println(res);
	}

}


Measured memory_bytes: 21844
K, N = map(int, input().split()) 
A = list(map(int, input().split()))
B = []
B.append(A[0] - A[N-1] + K )

for i in range(N-1):
    a = A[i+1] - A[i]
    B.append(a)

print (K - max(B))

Measured memory_bytes: 32328
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;	
	cin >> N;
	VI in(N,0),P(N);
	
	REP(i, N) {
		int v;
		cin >> v;
		v = (i + v) % N;
		P[i] = v;
		in[v]++;
	}
	queue<int> Q;
	REP(i, N)if (in[i] == 0)Q.push(i);
	int res = 0;
	while (!Q.empty()) {
		int u = Q.front();
		Q.pop();
		res++;
		int v = P[u];
		in[v]--;
		if (in[v] == 0)Q.push(v);
	}

	cout << N - res << endl;

	return 0;
}




Measured memory_bytes: 4528