akhauriyash/Code-Regression huggingface dataset:
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});
let lines = [];
reader.on("line", line => {
  lines.push(line);
});
reader.on("close", () => {
  const linesNum1 = lines[0].split(' ');
  const linesNum2 = lines[1].split(' ');
  const summerTime1 = linesNum1.map(str =>{ return Number(str) });
  const summerTime2 = linesNum2.map(str =>{ return Number(str) });
  let homeWork = summerTime2.reduce((a,x) => a += x);
  if(summerTime1[0] >= homeWork){
    console.log(summerTime1[0] - homeWork)
  } else {
    console.log('-1')
  }
});

Measured memory_bytes: 30768
#include<stdio.h>
#include<math.h>

#define MAX_DATA_SIZE (100)

void calc_distance(double * distance, const int count, const double * x, const double * y, double p);

int main(void)
{
        int data_count, data_index;
        double x_data[MAX_DATA_SIZE], y_data[MAX_DATA_SIZE];
        double manhattan_distance, euclid_distance, cubic_distance, chebyshev_distance;

        scanf("%d", &data_count);

        for(data_index=0; data_index < data_count; data_index++){
                scanf("%lf", &x_data[data_index]);
        }

        for(data_index=0; data_index < data_count; data_index++){
                scanf("%lf", &y_data[data_index]);
        }

        calc_distance(&manhattan_distance, data_count, x_data, y_data, 1);
        calc_distance(&euclid_distance,    data_count, x_data, y_data, 2);
        calc_distance(&cubic_distance,     data_count, x_data, y_data, 3);
        calc_distance(&chebyshev_distance, data_count, x_data, y_data, 0);


        printf("%lf\n%lf\n%lf\n%lf\n", manhattan_distance, euclid_distance, cubic_distance, chebyshev_distance);

        return 0;
}

void calc_distance(double * distance, const int count, const double * x, const double * y, double p)
{
        int    index;
        double total, abs, result;

        total = 0;
        result = 0;

        if(p == 0){
                for(index=0; index < count; index++){
                        abs = fabs(x[index] - y[index]);
                        if(result < abs){
                                result = abs;
                        }
                }
        }
        else{
                for(index=0; index < count; index++){
                        abs = fabs(x[index] - y[index]);
                        total += pow(abs, p);
                }
                result = pow(total, 1.0 / p);
        }

        *distance = result;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+100;
int arr[maxn];
int main()
{
    int n,m;
    cin>>n>>m;
    int sum=0;
    for(int i=0;i<m;++i)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    cout<<max(-1,n-sum)<<endl;
    return 0;
}


Measured memory_bytes: 3672
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
inline int Rand(){return rand()*32768+rand();}
int n,mod,k;
int dp[303][303][303];
inline void add(int &x,int y){
	x+=y;if(x>=mod)x-=mod;
}
int main(){
	cin>>n>>k>>mod;
	dp[1][0][0]=1;
	for(int i=1;i<=k;i++){
		for(int j=0;j<=n;j++){
			for(int x=j;x>=0;x--){
				add(dp[i][j+1][x],(ll)dp[i][j][x]*(x+1)%mod);
				if(x)add(dp[i][j][x-1],dp[i][j][x]);
				else add(dp[i+1][j][j],dp[i][j][x]);
			}
		}
	}
	cout<<dp[k][n][0]<<endl;
	return 0;
}

Measured memory_bytes: 111536
n,m,k = map(int, input().split())

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

aa = [0]
bb = [0]

for i in range(n):
    aa.append(a[i] + aa[i])

for i in range(m):
    bb.append(b[i] + bb[i])

ans = 0
mstart = m
for i in range(n+1):
    if k - aa[i] < 0:
        break
    for j in range(mstart,-1,-1):
        if k - aa[i] - bb[j] >= 0:
            mstart = j
            break
    if ans < i + j :
        ans = i + j 

print(ans)

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

using namespace std;

int data[22][22];
int vis[22][22];
int cnt = 0;

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

void dfs(int x, int y){
  vis[x][y] = 1;
  cnt++;
  for(int i = 0; i < 4; i++){
    if(data[x + dx[i]][y + dy[i]] == 1 && vis[x + dx[i]][y + dy[i]] == 0){
      dfs(x + dx[i], y + dy[i]);
    }
  }
}

int main(){
  int w, h;
  while(cin >> w >> h && w + h){
    cnt = 0;
    for(int i = 0; i < 22; i++){
      for(int k = 0; k < 22; k++){
	data[i][k] = vis[i][k] = 0;
      }
    }
    pair<int,int> start;
    for(int i = 0; i < h; i++){
      string s;
      cin >> s;
      for(int k = 0; k < w; k++){
	if(s[k] == '.')
	  data[i + 1][k + 1] = 1;
	else if(s[k] == '@')
	  start.first = i + 1,start.second = k + 1;
      }
    }
    dfs(start.first, start.second);
    cout << cnt << endl;
  }
}

Measured memory_bytes: 3048
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

class Disjointset {
private:
	vector<int> p, rank;

public:
	Disjointset(int size) {
		p.resize(size, 0);
		rank.resize(size, 0);
		for (int i = 0; i < size; ++i) {
			p[i] = i;
		}
	}
	int find(int x) {
		if (p[x] != x)
			p[x] = find(p[x]);
		return p[x];
	}
	bool isSame(int x, int y) {
		return find(x) == find(y);
	}
	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		} else {
			if (x == y)
				++rank[y];
			p[x] = y;
		}
	}
	void unite(int x, int y) {
		link(find(x), find(y));
	}

};

int main() {

	int n, q;
	scanf("%d %d", &n, &q);

	Disjointset d(n);

	for (int i = 0; i < q; ++i) {
		int com, x, y;
		scanf("%d %d %d", &com, &x, &y);
		if (com == 0) {
			d.unite(x, y);
		} else {
			if (d.isSame(x, y)) {
				cout << 1 << endl;
			} else {
				cout << 0 << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3444
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>
#include	<string.h>

#define		MXCD	1000+5

int		main(void)
{
	int		q;
	int		i, j, k, m;
	int		a, b;
	char	str[MXCD];
	char	odr[MXCD];
	char	rwd[MXCD];
	char	tmp[MXCD];

	scanf("%s",str);
	scanf("%d",&q);

	for(i=0; i<q; i++)
	{
		scanf("%s",odr);
		scanf("%d",&a);
		scanf("%d",&b);

		if( strcmp("print", odr) == 0)
		{
			for(j=a; j<=b; j++)
			{
				printf("%c",str[j]);
			}
			printf("\n");
		}
		else if( strcmp("reverse", odr) == 0)
		{
			m = b;
			for(j=a; j<=b; j++)
			{
				tmp[m] = str[j];
				m=m-1;

			}
			for(j=a; j<=b; j++)
			{
				str[j] = tmp[j];
				//printf("str[%d]=%d\n",j,str[j]);
			}
		}
		else if( strcmp("replace", odr) == 0)
		{
			scanf("%s",rwd);
			for(j=a, k=0; j<=b; j++, k++)
			{
				str[j] = rwd[k];
			}
		}
	}

	return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}


void pre(){



}


void solve(){

    ll n,m;
    cin >> n >> m;
    ll sum=0;
    for(ll i=1;i<=m;i++){
        ll val;cin >> val;
        sum += val;
    }
    if(sum>=n){
        cout << "Yes";
    }else{
        cout << "No";
    }

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define SQ(a) (a)*(a)you
#define f first
#define s second
#define int long long
#define PB push_back
#define MP make_pair
#define db long double
#define all(a) a.begin(), a.end()
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define cases int testcases;cin>>testcases; while(testcases--)

int32_t main()
{
  IOS
  


    int a,p;
    cin>>a>>p;


    cout<<(3*a+p)/2;


return 0;
}

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

int main() {
  string w; cin >> w;
  int N = w.size();
  if (N % 2 == 1) {
    cout << "No" << endl;
  } else {
    vector<int> alp(26,0);
    for (int i =0; i<N; i++) {
      for (int j =0; j<26; j++) {
        if (w[i] == 'a' + j) alp[j]++;
      }
    }
    bool check = true;
    for (int i =0; i<26; i++) {
      if (alp[i] % 2 == 1) {
        check = false; break;
      }
    }
    if (check) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

class Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static Scanner sc = new Scanner(new InputStreamReader(System.in));

	public static void main (String[] args) throws Exception {
		float max = Float.MIN_VALUE;
		float min = Float.MAX_VALUE;
		while(true) {
			String str = br.readLine();
			if(str == null) break;
			float n = Float.parseFloat(str);
			if(max < n) max = n;
			if(min > n) min = n;
		}
		System.out.println(max-min);
	}
}

Measured memory_bytes: 17172
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var array = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            for (int i = 1; i <= n; i++)
            {
                Console.Write("node {0}: key = {1}, ", i, array[i - 1]);
                if ((i >> 1) > 0) Console.Write("parent key = {0}, ", array[(i >> 1) - 1]);
                if ((i << 1) <= n) Console.Write("left key = {0}, ", array[(i << 1) - 1]);
                if (((i << 1) + 1) <= n) Console.Write("right key = {0}, ", array[i << 1]);
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9112
#include <stdio.h>
int main(){
    int n,i,j,k,l;
    int dice[24][6];
    int label[24][6]={{1,2,3,4,5,6},{1,3,5,2,4,6},{1,4,2,5,3,6},{1,5,4,3,2,6},{2,1,4,3,6,5},{2,3,1,6,4,5},
    {2,4,6,1,3,5},{2,6,3,4,1,5},{3,1,2,5,6,4},{3,2,6,1,5,4},{3,5,1,6,2,4},{3,6,5,2,1,4},{4,1,5,2,6,3},
    {4,2,1,6,5,3},{4,5,6,1,2,3},{4,6,2,5,1,3},{5,1,3,4,6,2},{5,3,6,1,4,2},{5,4,1,6,3,2},{5,6,4,3,1,2},
    {6,2,4,3,5,1},{6,3,2,5,4,1},{6,4,5,2,3,1},{6,5,3,4,2,1}};
     
    scanf("%d",&n);
    int dices[n][6];
     
    for(i=0;i<n;i++){
        for(j=0;j<6;j++) scanf("%d",&dices[i][j]);
    }
     
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
             
            for(k=0;k<24;k++){
                for(l=0;l<6;l++) dice[k][l]=dices[j][label[k][l]-1];
            }
             
            for(k=0;k<24;k++){
                for(l=0;l<6;l++) {
                    if(dice[k][l]!=dices[i][l]) {
                        break;
                    }
                }
                if(l==6){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
     
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2108
from collections import defaultdict

h,w,n = map(int,input().split())

d = defaultdict(int)

for _ in range(n):
    a,b = map(int,input().split())

    for i in range(-1,2):
        for j in range(-1,2):
            if 1 < a+i < h and 1 < b+j < w:
                d[(a+i,b+j)] += 1

ans = [0]*10

for i in d.values():
    ans[i] += 1

ans[0] = (h-2)*(w-2)-sum(ans)
for i in ans:
    print(i)

Measured memory_bytes: 166860
#include<iostream>
#include<cstdlib>
#include<set>
#include<vector>
#include <algorithm>
#include <cmath>
using namespace std;
int abs(int n){
  if (n>=0) return n;
  else return -1*n;
}
int main(){
  vector<long long> v;
  int n,i;
  long long k;
  cin >>n;
  for (i=0;i<n;i++){
    cin>>k;
    k-=i+1;
    v.push_back(k);
  }
  sort(v.begin(),v.end());
  long long a,b,c,A,B,C;
  a=v[n/2];
  b=v[n/2-1];
  c=v[n/2+1];
  A=0;
  B=0;
  C=0;
  for (i=0;i<n;i++){
    A+=abs(v[i]-a);
    B+=abs(v[i]-b);
    C+=abs(v[i]-c);
  }
  cout<<min(A,min(B,C))<<endl;

  return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

bool prime(ll n) {
	if (n == 1) {
		return false;
	}
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;
}




int main() {
	int n;
	cin >> n;
	vector<int>prime_list;
	rep(i, 2, 55555) {
		if (prime(i))prime_list.push_back(i);
	}

	vector<int>ans;
	rep(i, 0, prime_list.size()) {
		if (prime_list[i] % 5 == 1)ans.push_back(prime_list[i]);
		if (ans.size() == n)break;
	}

	rep(i, 0, n) {
		cout << ans[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  int sum = 0;
  int X = N;
  while (N != 0)
  {
    sum += N % 10;
    N /= 10;
  }
  bool is_ok = true;
  if (X % sum != 0)
    is_ok = false;
  printYesNo(is_ok);
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

using namespace std;

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

typedef long long ll;
const int Mod = static_cast<int>(1e9 + 7);

int main()
{
	string c;
	cin >> c;
	int A[4];
	rep(i, 4)  A[i] = c[i] - '0';

	for (int bit = 0; bit < (1 << 3); bit++) {
		int sum = A[0];
		string s;
		for (int i = 0; i < 3; i++) {
			if (bit & (1 << i)) {
				sum += A[i + 1];
				s += '+';
			}
			else {
				sum -= A[i + 1];
				s += '-';
			}
		}
		if (sum == 7) {
			cout << A[0] << s[0] << A[1] << s[1] << A[2] << s[2] << A[3] << "=7" << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define SQR(a) ((a)*(a))
using namespace std;
typedef long long int ll;
typedef pair<int,int> pr;
typedef pair<pr,ll> ppr;
typedef vector<pr> vpr;
const int INF=1<<30;
int DP[4001][4001]={};
int main() {
	string s1,s2;
	while(cin >>s1 >> s2){
		REP(i,4001)
			REP(j,4001)
				DP[i][j]=0;
	int maxim=0;
	REP(i,s1.size())
		REP(j,s2.size()){
				if(s1[i]==s2[j])
				DP[i+1][j+1]=DP[i][j]+1;
				maxim=max(maxim,DP[i+1][j+1]);
			}
	cout << maxim << endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 63740
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
	
		Scanner sc=new Scanner(System.in);
		
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		if(A%2==1||B%2==1||C%2==1){
			System.out.println(0);
			System.exit(0);
		}
		Set<String> s=new HashSet<String>();
		int a=0,b=0,c=0;
		int count=0;
		while(true){
	

			count++;
			a=(B>>1)+(C>>1);
			b=(A>>1)+(C>>1);
			c=(A>>1)+(B>>1);
			if(a%2==1||b%2==1||c%2==1) break;
			String str=String.format("%010d", a)+String.format("%010d", b)+String.format("%010d", c);
			if(s.contains(str)){
				count=-1;
				break;
			}
			s.add(str);
			A=a;B=b;C=c;
		}
		System.out.println(count);
	}
	

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int n,m,q;
int ans;
vector<int> a,b,c,d;


void bfs(vector<int> A)
{
    if(A.size()==n+1)
    {
        int now=0;
        rep(i,q)
        {
            if(A[b[i]]-A[a[i]]==c[i])now+=d[i];
        }
        ans=max(ans,now);
        return;
    }
    A.push_back(A.back());
    while(A.back()<=m)
    {
        bfs(A);
        A.back()++;
    }

}
int main()
{
    cin>>n>>m>>q;
    a=b=c=d=vector<int>(q);
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    bfs(vector<int>(1,1));
    cout<<ans;

}


Measured memory_bytes: 3608
fun main(args: Array<String>) {
    val s = readLine()!!.toCharArray()
    val t = readLine()!!.toCharArray()
    val dp = Array(s.size + 1) { LongArray(t.size + 1) { 0L } }
    for (i in 0 until s.size) {
        for (j in 0 until t.size) {
            if (s[i] == t[j])
                dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i][j] + 1)
            dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i][j + 1])
            dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i + 1][j])
        }
    }
    var answer = ""
    var i = s.size
    var j = t.size
    while (i > 0 && j > 0) {
        when {
            dp[i][j] == dp[i - 1][j] -> i--
            dp[i][j] == dp[i][j - 1] -> j--
            else -> {
                answer = s[i - 1] + answer
                i--
                j--
            }
        }
    }
    println(answer)
}


Measured memory_bytes: 142316
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>

using namespace std;

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

int main(){
    vector<int> alfa_num;
    int count;
    string str, t="abcdefghijklmnopqrstrvwxyz", res = "Yes";
    cin >> str;
    for(int i = 0; i < t.size(); i++) {
        count = 0;
        for(int j = 0; j < str.size(); j++) {
            if(t[i] == str[j]) {
                count++;
            }
        }
        alfa_num.push_back(count);
    }

    for(int k = 0; k < t.size(); k++) {
        if(alfa_num[k] % 2 != 0) {
            res = "No";
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
dat = []
for _ in range(3):
    dat.append(list(map(int, input().split())))
f = True
a1,a2,a3,b1,b2,b3 = -1,-1,-1,-1,-1,-1
a1 = 0
b1 = dat[0][0]
b2 = dat[0][1]
b3 = dat[0][2]

a2 = dat[1][0] - b1
a3 = dat[2][0] - b1

if dat[1][1] != a2 + b2:
    f = False

if dat[1][2] != a2 + b3:
    f = False

if dat[2][1] != a3 + b2:
    f = False

if dat[2][2] != a3 + b3:
    f = False

#if 0 > a1 or 0>a2 or 0>a3 or 0>b1 or 0>b2 or 0>b3:
#    f = False

#print(a1,a2,a3,b1,b2,b3)
print("Yes" if f else "No")

Measured memory_bytes: 38384
A, B = map(int, input().split())

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = set(table)
    return table

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

a_set = divisor(A)
b_set = divisor(B)
S = a_set & b_set
S = list(S)
ans = 0

for s in S:
    if is_prime(s):
        ans += 1

print(ans+1)

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

signed main(){
    //cout << setprecision(12) ;
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> v(100010);
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        v[a].push_back(b);
    }
    priority_queue<ll,vector<ll>> pq;
    ll ans = 0;

    for(ll i=1;i<=m;i++){
        for(auto j:v[i]){
            pq.push(j);
        }
        if(!pq.empty()){
            ans += pq.top();
            pq.pop();
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c) << endl;
}


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

int main() {
	int n, x = 0, y = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 4 == 0) {
			x++;
		} else if (a % 2 == 0) {
			y++;
		}
	}
	cout << (x + y / 2 >= n / 2 ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>

int N;
int T;
int c,t;

int best_cost = 10000000000;
int main(){
    scanf("%d%d",&N,&T);
    for(int i=0;i<N;i++){
        scanf("%d%d",&c,&t);
        if(t <= T){
            best_cost = std::min(best_cost,c);
        }
    }

    if(best_cost > 10000000){
        printf("TLE\n");
    }else{
        printf("%d\n",best_cost);
    }


    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;



vector<ll> getdiv(int k) {
	vector<ll> res;
	for (int i = 1; i * i <= k; i++) {
		if (k % i == 0) {
			res.push_back(i);
			res.push_back(k / i);
			if (i == k / i)res.pop_back();
		}
	}
	sort(res.begin(), res.end());
	return res;
}


int main()
{
	

	double a, b,a1,a2,b1,b2;
	cin >> a >> b;
	a1 = a * 100 / 8;
	a2 = (a + 1) * 100 / 8;
	b1 = b* 10;
	b2 = (b+1) * 10;
	if (a2 < b1 || b2 < a1) {
		cout << -1;
	}
	else {
		if (a1 >= b1) {
			if (b2-a1 >= 1)
				cout << ceil(a1);
			else cout << -1;
		}
		else {
			if (a2 - b1 >= 1)
				cout << ceil(b1);
			else cout << -1;
		}
	}




}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
int K;
int X[50];
int Y[50];
int main(){
  int a, b, c, d, i, k;
  long long res=4611686016279904256LL;
  rd(N);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(X[Lj4PdHRW]);
      rd(Y[Lj4PdHRW]);
    }
  }
  for(a=0;a<(N);a++){
    for(b=0;b<(N);b++){
      if(X[a] < X[b]){
        for(c=0;c<(N);c++){
          for(d=0;d<(N);d++){
            if(Y[c] < Y[d]){
              k = 0;
              for(i=0;i<(N);i++){
                if(X[a] <= X[i]  &&  X[i] <= X[b] && Y[c] <= Y[i]  &&  Y[i] <= Y[d]){
                  k++;
                }
              }
              if(k >= K){
                chmin(res, (long long)(X[b]-X[a]) * (Y[d]-Y[c]));
              }
            }
          }
        }
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// int N, K, X[50], Y[50];
// {
//   int i, k;
//   int a, b, c, d;
//   ll res = ll_inf;
// 
//   rd(N,K,(X,Y)(N));
//   rep(a,N) rep(b,N) if(X[a] < X[b]) rep(c,N) rep(d,N) if(Y[c] < Y[d]) {
//     k = 0;
//     rep(i,N) if(X[a] <= X[i] <= X[b] && Y[c] <= Y[i] <= Y[d]) k++;
//     if(k >= K) res <?= (ll)(X[b]-X[a]) * (Y[d]-Y[c]);
//   }
//   wt(res);
// }


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

vector<int> adj[maxN];
int n, m, he[maxN];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	cin >> n >> m;
	for(int i = 0; i < n; i++) cin >> he[i];
	for(int i = 0, u, v; i < m; i++) {
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	auto fn = [&](int w) {
		for(int sn: adj[w])
			if(he[sn] >= he[w]) return false;
		return true;
	};

	int ans = 0;
	for(int i = 0; i < n; i++)
		if(fn(i)) ans++;
	cout << ans << '\n';
}



Measured memory_bytes: 9124
import java.util.Scanner;

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

        String o = sc.next();
        String e = sc.next();

        int i = 0;
        while (i < o.length() || i < e.length()) {
            if (i < o.length()) {
                System.out.print(o.charAt(i));
            }
            if (i < e.length()) {
                System.out.print(e.charAt(i));
            }
            i++;
        }
    }
}

Measured memory_bytes: 22996
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100005;
struct node{
    int u,v,nxt;
}edge[N*2];
int head[N],mcnt;
void add_edge(int u,int v){
    mcnt++;
    edge[mcnt].u=u;
    edge[mcnt].v=v;
    edge[mcnt].nxt=head[u];
    head[u]=mcnt;
}
int n,k,a[N],deep[N],ans;
void dfs(int u)
{
	for(int i=head[u];i;i=edge[i].nxt)
	{
		int v=edge[i].v;
		dfs(v);
		deep[u]=max(deep[u],(deep[v]+1)%k);
		if(u!=1&&deep[v]==k-1)
            ans++;
	}
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
	if(a[1]!=1)
        ans++;
	for(int i=2;i<=n;i++)
        add_edge(a[i],i);
	dfs(1);
	printf("%d\n",ans);
}


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

int main(void){
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i = 0; i < N; i++) cin >> h[i];
  int ans = 0;
  while(1){
    int i;
    for(i = 0; i < N && h[i] == 0; i++);
    if(i >= N) break;
    for(; i < N && h[i] > 0; i++) h[i]--;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,c=0,N,X;
    scanf("%d%d",&N,&X);
    int L[N],D[N+1];
    for(i=0;i<N;i++)
    {
        scanf("%d",&L[i]);

    }
    D[0]=0;
    for(i=0;i<N;i++)
    {
        D[i+1]=D[i]+L[i];

    }
    for(i=0;i<(N+1);i++)
    {
        if(D[i]<=X)
        c++;
    }
    printf("%d",c);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var strs = Console.ReadLine().Split();
            var a = int.Parse(strs[0]);
            var b = int.Parse(strs[1]);

            Console.WriteLine(a <= b ? a : a - 1);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll

int n,m;

signed main(){
  cin>>n>>m;

  vector<int> v;

  for(int i=1;i*i<=m;i++){
    if(m%i==0){
      if(m/i!=i) v.PB(m/i);
      v.PB(i);
    }
  }

  sort(all(v));

  reverse(all(v));

  for(int i=0;i<v.size();i++){
    if(v[i]*n<=m){
      cout<<v[i]<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let s: String = read();
    let cv: Vec<char> = s.chars().collect();
    if n % 2 == 1 {
        println!("No");
    } else {
        let m = n / 2;
        let mut b = true;
        for i in 0..m {
            if cv[i] != cv[i + m] {
                b = false;
                break;
            }
        }
        if b {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 4352
from heapq import heappop, heappush

sc = map(int, open(0).read().split())
ni = lambda: next(sc)

def solve(A):
    Q = []
    for i, ai in enumerate(A):
        for aij in ai:
            heappush(Q, aij)
        while len(Q) > i:
            heappop(Q)
    return sum(Q)

T = ni()
for _ in range(T):
    N = ni()
    A, B = [[] for _ in range(N + 1)], [[] for _ in range(N + 1)]

    ans = 0
    for _ in range(N):
        k, l, r = ni(), ni(), ni()
        if l >= r:
            A[k].append(l - r)
        else:
            B[k].append(r - l)
        ans += min(l, r)

    ans += solve(A) + solve(reversed(B))
    print(ans)

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

const int INF = 1000000000;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;		

		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}
		
		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					if(T[i][j]>T[i][k]+T[k][j]){
						T[i][j]=T[i][k]+T[k][j];
					}
				}
			}
		}
		int count1[10];
		for(int k=0;k<m;k++){
			int count=0;
			for(int i=0;i<m;i++){
				count=T[k][i]+count;
			}
			count1[k]=count;
		}
		int count2=count1[0];
		for(int k=0;k<m;k++){
			if(count1[k]<count2)
				count2=count1[k];
		}
		for(int k=0;k<m;k++){
			if(count1[k]==count2){
				cout<<k<<" "<<count2<<endl;
				break;
			}
		}

	}

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

int main() {
	typedef struct zahyou {
		double x, y;
	} z;

	z a, b, c, d;
	char ch;
	while (cin >> a.x) {
		cin >> ch >> a.y >> ch >> b.x >> ch >> b.y >> ch >> c.x >> ch >> c.y
		>> ch >> d.x >> ch >> d.y;
		//cout << a.x << ' ' << a.y << endl;
		//cout << b.x << ' ' << b.y << endl;
		//cout << c.x << ' ' << c.y << endl;
		//cout << d.x << ' ' << d.y << endl;

		int f = 0;
		double n, m;

		n = (a.x - c.x) * (b.y - a.y) - (a.y - c.y) * (b.x - a.x);
		m = (a.x - c.x) * (d.y - a.y) - (a.y - c.y) * (d.x - a.x);
		//cout << fixed << setprecision(4) << n << ' ' << m << endl;
		if (n * m > 0) f = 1;

		n = (b.x - d.x) * (a.y - b.y) - (b.y - d.y) * (a.x - b.x);
		m = (b.x - d.x) * (c.y - b.y) - (b.y - d.y) * (c.x - b.x);
		//cout << fixed << setprecision(4) << n << ' ' << m << endl;
		if (n * m > 0) f = 1;

		if (!f) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)

int main(){
    string s;
    cin >> s;
    rep(i, s.size() - 1){
        if(s[i] == 'A' && s[i + 1] == 'C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

int main(){
  long long int n, k, x, y;
  cin >> n >> k >> x >> y;
  long long int ans;
  if(n > k) ans = x*k + y*(n-k);
  else ans = x*n;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000

int beki(long long a,long long b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}


int gyakugen(int a){
	return beki(a,modulo-2);
}

struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		
		int b=gyakugen(kaijou[n]);
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
	int catalan(int n){
		return mod(combination(2*n,n)*gyakugen(n+1));
	}
	
};

int main(){
	
	int S;
	cin>>S;
	
	int ans = 0;
	combi C(1000000);
	for(int i=1;i<=S/3;i++){
		int T = S - i*3;
		ans = mod(ans + C.junretsu(i-1,T));
	}
	
	cout<<ans<<endl;
	
    return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll cnt[15][1005];
char grid[15][1005];
ll H, W, K;

int main(int argc, char **argv)
{
	cin >> H >> W >> K;
	REP(h, H)REP(w, W)
		cin >> grid[h][w];

	ll res{INF};
	for (ll bits = 0; bits < (1ll<<(H-1)); ++bits)
	{
		ll cntb = __builtin_popcount(bits);
		vector<ll> cntw(cntb+1, 0);

		ll cnt{cntb};
		REP(w, W)
		{
			vector<ll> cntw_copy;
			vector<ll> cntw_h_only(cntb+1, 0);
			cntw_copy = cntw;
			ll i{0};
			REP(h, H)
			{
				ll t = grid[h][w] - '0';
				cntw_copy[i] += (t == 1);
				cntw_h_only[i] += (t == 1);
				if (bits & (1ll << h))
				{
					++i;
				}
			}

			for (auto &e : cntw_h_only)
			{
				if (e > K)
				{
					cnt = INF; // no ans.
					break;
				}
			}

			bool is{false};
			for (auto &e : cntw_copy)
			{
				if (e > K)
					is = true;
			}

			if (is)
			{
				++cnt;
				assert(cntw_copy.size() == cntw.size());
				for(ll i = 0; i < (ll)cntw_copy.size(); ++i)
					cntw[i] = cntw_copy[i] - cntw[i];
				
			}
			else
			{
				cntw = cntw_copy;
			}
		}

		if (res > cnt)
		{
			// std::cout << "cnt : " << cnt << std::endl;
			for (ll i = 0; i < (ll)cntw.size(); ++i)
			{
			// 	std::cout << cntw[i]<< std::endl;
			}
			// std::cout << std::endl;
		}
		res = min(res, cnt);
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vvi abc(n, vi(3, 0));
    rep(i, n) rep(j, 3) cin >> abc[i][j];
    vvi dp(n+1, vi(3, 0));
    
    // i日目にj(A, B, C)の行動を選んだ場合の幸福度
    for(ll i=1; i<=n; i++){
        for(ll j=0; j<3; j++){
            dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + abc[i-1][j];
        }
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}

Measured memory_bytes: 11264
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n,x,m = gets.chomp.split.map(&:to_i)

loop_check = Array.new(m, false)

val = x
count = 0
sum = 0
val2count = Hash.new
a = []
cusum = []
until loop_check[val]
  loop_check[val] = true
  sum += val
  val2count[val] = count
  a[count] = val
  cusum[count] = sum
  count += 1

  if count == n
    puts sum
    exit
  end

  val = (val**2) % m
end
# p loop_check.map{|l| l ? 1 : 0}.join()

# p [count, sum, hash[val]]

count_at_loop = val2count[val]
if count_at_loop == 0
  first_sum = 0
else
  first_sum = cusum[count_at_loop - 1]
end

loop_sum = sum - first_sum
first_count = count_at_loop
loop_count = count - first_count
# p ['first_sum, loop_sum', first_sum, loop_sum]
# p ['first_count, loop_count', first_count, loop_count]
# p cusum

ans = first_sum
n -= first_count
# p [ans, n]

ans += (n / loop_count) * loop_sum
n = n % loop_count

# p [ans, n]
if n > 0
  loop_cusum = cusum[first_count..]
  # p loop_cusum
  ans += loop_cusum[n-1] - first_sum
end
puts ans


Measured memory_bytes: 18248
import java.util.Scanner;

public class Main {

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

        int min = (int) (b / 0.1);
        int max = min;
        int cur = (int) (max * 0.1);
        while (b == cur) {
            max++;
            cur = (int) (max * 0.1);
        }
        boolean hit = false;
        for (int i = min; i < max; i++) {
            int at = (int) (i * 0.08);
            int bt = (int) (i * 0.1);
            if (at == a && bt == b) {
                System.out.println(i);
                hit = true;
                break;
            }
        }
        if (!hit) {
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include<math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
int A[11111];
int tensuu[11111];
int main() {
    int a,b,c,d;
    cin >> a>>b>>c>>d;
    
    int ab, bc, ca;
    ab = abs(a - b);
    bc = abs(b - c);
    ca = abs(c - a);

    if ((ab <= d && bc <= d) || ca <= d)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    d=a+b+c;
    if(d>=22)
    {
        printf("bust\n");
    }
    else
        printf("win\n");
    return 0;
}


Measured memory_bytes: 128
N, X, Y = map(int, input().split())

ans = [0] * (N + 1)

for i in range(1, N):
  for j in range(i+1, N+1):
    dis1 = j-i
    dis2 = abs(X-i) + 1 + abs(Y - j)
    dis3 = abs(Y-i) + 1 + abs(X - j)
    d = min(dis1,dis2,dis3)
    ans[d] += 1

for i in range(1, N):
  print(ans[i])

Measured memory_bytes: 9288
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c, r = next(a), Counter(a), 0
if x == c[0] == 0:
    r = p = i = 1
    while c[i]:
        r = r * pow(p, c[i], M) % M
        p = c[i]
        n -= p
        i += 1
print((r, 0)[n > 1])


Measured memory_bytes: 22636
n, x = list(map(int, input().split()))
s = list(map(int,input().rstrip().split()))
s.sort()
s_sum = sum(s)
l = len(s)
flg = True

if s_sum < x:
    print(l - 1)
elif s_sum == x:
    print(l)
else:
    s.reverse()
    for ss in s:
        s_sum -= ss
        l -= 1
        if s_sum <= x:
            print(l)
            flg = False
            break

    if(flg): print(0)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int N; cin >> N;
    vector<int> A(N);
    vector<int> B(N-1); for (auto &b : B) cin >> b;
    for (int i = 0; i < N; i++) {
        A[i] = 1e9;
        if (i-1 >= 0) A[i] = min(A[i], B[i-1]);
        if (i < N-1) A[i] = min(A[i], B[i]);
    }
    cout << accumulate(begin(A), end(A), 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> A(N+1);
  rep(i, N+1) cin >> A[i];
  ll tmp = 0;
  vector<ll> mx(N+1);
  rrep(i, N+1) {
    tmp += A[i];
    mx[i] = tmp;
  }
  tmp = 1;
  ll ans = 1;
  rep(i, N+1) {
    if(tmp < A[i]) {
      cout << -1 << endl;
      return 0;
    }
    tmp -= A[i];
    tmp *= 2;
    ans += tmp;
    if(i != N && tmp > mx[i+1]) {
      ans -= tmp-mx[i+1];
      tmp = mx[i+1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4732
($a, $b) = split(/ /, <STDIN>);

$r = int($b / 0.1);

while(1){

	if((int($r * 0.08) == $a) and (int($r * 0.1) == $b)){
		print "$r\n";
		exit;
	}

	last if((int($r * 0.08) > $a) or (int($r * 0.1) > $b));

	$r++;

}

print "-1\n";


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

max_cake = N // 4
max_donut = N // 7

ans = 'No'
is_detected = False
for i in range(max_cake + 1):
  for j in range(max_donut + 1):
    if 4 * i + 7 * j == N:
      ans = 'Yes'
      is_detected = True
      break
  if is_detected:
    break

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

vector<ll> g(100010, 0);

int main(){
	ll n; cin >> n; 
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	for( auto k : a ) ++g[k];
	ll sum = accumulate( a.begin(), a.end(), 0ll );
	ll q; cin >> q;
	while( q-- ){
		ll b, c; cin >> b >> c;
		ll d = c-b;
		sum += g[b]*(c-b);
		cout << sum << endl;
		g[c] += g[b];
		g[b] = 0;
	}
}

Measured memory_bytes: 4844
mod = 1000000007


S = int(input())

m = [[0 for j in range(0, int(S / 3) + 1)] for i in range(0, S + 1)]

for s in range(3, S + 1):
    m[s][1] = 1

for n in range(2, int(S / 3) + 1):
    for s in range(3, S + 1):
        m[s][n] = (m[s - 1][n] + m[s - 3][n - 1]) % mod

res = 0
for n in range(1, int(S / 3) + 1):
    res += m[S][n]

print(res % mod)


Measured memory_bytes: 40752
#include <iostream>
#include <string>

using namespace std;
int main(){
	string s;
	cin >> s;
	long long int a;
	a = s.size();
	if (a % 2 == 0){
		for (int i = 0; i < a - 1; i += 2){
			cout << s[i];
		}
		cout << endl;
		return 0;
	}
	else{
		for (int i = 0; i < a ; i += 2){
			cout << s[i];
		}
		cout << endl;
		return 0;
	}
	return 0;
}

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

void solve() {
  int a,b; cin >> a >> b;

  cout << (a+b)%24 << endl;

  return;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3568
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<functional>
#include<algorithm>
using namespace std;

#define INF (1<<29)
#define EPS 1e-10
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
#define INDEX(v,x) (find(ALL(v),x)-v.begin())

typedef unsigned long long ull;

int d[100000];
int p[100000];
bool cut[100000];

int hoge(int a){//テァツ淞ュテァツオツ。
	if(p[a]==0)return a;
	if(cut[a]){
		if(p[a]==INF)return INF;
		return a+p[a];
	}
	cut[a]=true;
	int t=p[a];
	p[a] = INF;
	t = hoge(a+t);
	if(t!=INF)p[a]=t-a;
	return t;
}
int main(){
	int n;
	cin>>n;
	REP(i,n)cin>>p[i];
	REP(i,n){
		hoge(i);
	}
	fill(d,d+n,INF);
	d[0]=0;
	queue<int> q;
	q.push(0);
	while(!q.empty()){
		int a=q.front();q.pop();
		for(int i=1;i<=6;i++){
			int next=p[a+i];
			if(next==INF)continue;
			next=a+i+next;
			if(d[a]+1 < d[next]){
				d[next]=d[a]+1;
				q.push(next);
			}
		}
	}
	cout<<d[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 4696