akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt();
			int y = scanner.nextInt();
			int z = scanner.nextInt();
			int k = scanner.nextInt();
			scanner.nextLine();
			long[] a = new long[x];
			IntStream.range(0, x).forEach(i -> a[i] = scanner.nextLong());
			scanner.nextLine();
			Arrays.sort(a);

			long[] b = new long[y];
			IntStream.range(0, y).forEach(i -> b[i] = scanner.nextLong());
			scanner.nextLine();
			Arrays.sort(b);

			long[] c = new long[z];
			IntStream.range(0, z).forEach(i -> c[i] = scanner.nextLong());
			scanner.nextLine();
			Arrays.sort(c);

			long[] sum = new long[k];
			Queue<Sum> queue = new PriorityQueue<>((s1, s2) -> {
				if (s1.sum > s2.sum) {
					return -1;
				} else if (s1.sum == s2.sum) {
					return 0;
				} else {
					return 1;
				}
			});
			Set<Sum> set = new HashSet<>();
			Sum first = new Sum(a[x - 1] + b[y - 1] + c[z - 1], x - 1, y - 1, z - 1);
			queue.add(first);
			set.add(first);
			for (int j = 0; j < k; j++) {
				Sum now = queue.remove();
				sum[j] = now.sum;
				Sum sum1 = null, sum2 = null, sum3 = null;
				if (now.ia > 0) {
					sum1 = new Sum(a[now.ia - 1] + b[now.ib] + c[now.ic], now.ia - 1, now.ib, now.ic);
				}
				if (now.ib > 0) {
					sum2 = new Sum(a[now.ia] + b[now.ib - 1] + c[now.ic], now.ia, now.ib - 1, now.ic);
				}
				if (now.ic > 0) {
					sum3 = new Sum(a[now.ia] + b[now.ib] + c[now.ic - 1], now.ia, now.ib, now.ic - 1);
				}
				if ((null != sum1) && !set.contains(sum1)) {
					queue.add(sum1);
					set.add(sum1);
				}
				if ((null != sum2) && !set.contains(sum2)) {
					queue.add(sum2);
					set.add(sum2);
				}
				if ((null != sum3) && !set.contains(sum3)) {
					queue.add(sum3);
					set.add(sum3);
				}
			}
			Arrays.stream(sum).forEach(System.out::println);
		}
	}

	private static class Sum {
		long sum;
		int ia;
		int ib;
		int ic;

		Sum(long sum, int ia, int ib, int ic) {
			super();
			this.sum = sum;
			this.ia = ia;
			this.ib = ib;
			this.ic = ic;
		}

		@Override
		public int hashCode() {
			return Objects.hash(sum, ia, ib, ic);
		}

		@Override
		public boolean equals(Object obj) {
			if (null == obj) {
				return false;
			} else if (obj instanceof Sum) {
				return (sum == ((Sum) obj).sum) && (ia == ((Sum) obj).ia) && (ib == ((Sum) obj).ib)
						&& (ic == ((Sum) obj).ic);
			}
			return false;
		}

		@Override
		public String toString() {
			return "sum=" + sum + ",ia=" + ia + ",ib=" + ib + ",ic=" + ic;
		}
	}
}


Measured memory_bytes: 33456
import scala.io.StdIn
import scala.annotation.tailrec

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    val inputCards = getInputCards(StdIn.readInt(),0,Set())

    val suits = List("S","H","C","D")
    for(suit <- suits; number <- 1 to 13){
      if(!inputCards.contains(Card(suit,number))){
        println("%s %d".format(suit,number))
      }
    }
  }

  @tailrec
  def getInputCards(n:Int, i:Int, cards:Set[Card]): Set[Card] ={
    if(i == n){return cards}
    val in = StdIn.readLine().split(" ")
    getInputCards(n,i + 1,cards + Card(in(0).toString,in(1).toInt))
  }
}

case class Card(suit:String,number:Int)

Measured memory_bytes: 44164
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <iostream>
#include <functional>
#include <map>
using namespace std;
#define maxn 100005
char s[maxn];


int main()
{
	int n;
	long long t;
	cin >> n >> t;
	int cnt = 0;
	int min = 1e9;
	int max = 0;
	int a;
	int maxx = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		if (min>a)
		{
			min = a;
		}
		if (a - min > maxx)
		{
			maxx = a - min;
			cnt = 0;
		}
		if (a - min == maxx)
			cnt++;
	}
	cout << cnt << endl;



	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int n, A, B, C;
vector<int> l(0);

int dfs(int cur, int a, int b, int c){
    if(n == cur){
        int mini = min(a, b);
        mini = min(mini, c);
        if(mini > 0) return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        else return INF;
    }
    int ret0 = dfs(cur + 1, a, b, c);
    int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
    int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
    int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
    int ans = min(ret0, ret1);
    ans = min(ret2, ans);
    ans = min(ret3, ans);
    return ans;
}

int main(void){
    cin >> n >> A >> B >> C;
    REP(i, n){
        int num;
        cin >> num;
        l.push_back(num);
    }
    cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
N = int(input())
ais = input().split()
ai = []
for a in ais:
    ai.append(int(a))
ai.sort(reverse=True)
ret = 0
for i,a in enumerate(ai):
    if i > 2 * N:
        break
    if i % 2 == 0:
        continue
    else:
       ret += a
print(ret)

Measured memory_bytes: 37084
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    bool ans = false;
    cin >> a >> b >> c >> d;
    if(abs(a - c) <= d){
        ans = true;
    }
    if(abs(a - b) <= d && abs(b - c) <= d){
        ans = true;
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
	int n;
	int s[102];
	int ans=0;
	cin>>n;
	s[0]=0;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		ans+=s[i];
	}

	sort(s,s+n+1);
	int are=0;
	for(int i=0;i<n;i++){
		if((ans-s[i])%10){
			are=s[i];break;
		}
	}
	if((ans-are)%10)cout<<ans-are<<endl;
	else cout<<"0"<<endl;
	return(0);
}

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

int main()
{
	int x,a,b;

	cin >> x >> a >> b;

	if (b - a <= 0) {
		cout << "delicious" << endl;
	}

	else if (b - a >= x + 1) {
		cout << "dangerous" << endl;
	}

	else {
		cout << "safe" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
ll n, q;
int main(){
	scanf("%lld%lld",&n,&q);
	set<pair<ll, ll>> s1, s2;
	s1.insert(mk(n, n));
	s2.insert(mk(n, n));
	ll x, y;
	ll ans =0; 
	for(ll i=0; i<q; ++i){
		scanf("%lld%lld",&x,&y);
		if(x==1){
			auto tmp = s1.lower_bound(mk(y, -1))->sc;
			ans+=tmp-2;
			while(s2.size()>0){
				auto it = *s2.begin();
				if(it.sc<=y){
					break;
				}
				if(it.fs==tmp){
					s2.erase(s2.begin());
				}
				s2.insert(mk(tmp, y));
			}
		}
		else{
			auto tmp = s2.lower_bound(mk(y, -1))->sc;
			ans+=tmp-2;
			while(s1.size()>0){
				auto it = *s1.begin();
				if(it.sc<=y){
					break;
				}
				if(it.fs==tmp){
					s1.erase(s1.begin());
				}
				s1.insert(mk(tmp, y));
			}
		}
	}
	ans=(n-2)*(n-2)-ans;
	cout<<ans<<endl;
}

Measured memory_bytes: 9844
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define lld double
#define vi vector<ll>
#define pii pair<int,int>
#define piii pair<pii, ll>
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define ppb pop_back
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<x<<" "<<y<<"\n"
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
using namespace std;
const ll mod = 1e9+7;


int main()
{
    ll n,a,b;
    cin>>n>>a>>b;

    ll c = (n%(a+b));
    ll d = n/(a+b);

    cout<<d*a+min(a,c)<<endl;
    
}

Measured memory_bytes: 256
#include<cstdio>
#define Starseven main
#define ll long long
namespace lyt {
	void read(int &x){
	char ch=getchar();int re=0,op=1;
	while(ch<'0'||ch>'9'){if(ch=='-') op=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){re=(re<<3)+(re<<1)+ch-'0';ch=getchar();}
	x = re * op;
	return ;
	}
	void read(long long &x){
	char ch=getchar();long long re=0,op=1;
	while(ch<'0'||ch>'9'){if(ch=='-') op=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){re=(re<<3ll)+(re<<1ll)+ch-'0';ch=getchar();}
	x = re * op;
	return ;
	}
	void write(int x){
		if(x<0){putchar('-');x=-x;}
		if(x>9) write(x/10);
		putchar(x%10+'0');
		return ;
	}//¼ÇµÃ×Ô¼º¼Ó¿Õ¸ñºÍ»»ÐÐ 
	void write(long long x){
		if(x<0){putchar('-');x=-x;}
		if(x>9) write(x/10);
		putchar(x%10+'0');
		return ;
	}//¼ÇµÃ×Ô¼º¼Ó¿Õ¸ñºÍ»»ÐÐ
	int max(int x,int y){return x<y?y:x;}
	int min(int x,int y){return x<y?x:y;}
	int abs(int x){return x<0?-x:x;}
	long long max(long long x,long long y){return x<y?y:x;}
	long long min(long long x,long long y){return x<y?x:y;}
	long long abs(long long x){return x<0?-x:x;}
	double max(double x,double y){return x<y?y:x;}
	double min(double x,double y){return x<y?x:y;}
	double abs(double x){return x<0?-x:x;}
	void swap(int &a,int &b) {a ^= b ^= a ^= b;}
	void swap(long long &a,long long &b) {a ^= b ^= a ^= b;}
	ll Power(ll a, ll b, ll p) {
		ll re = 1;
		while(b) {
			if(b & 1ll) re = (re * a) % p;
			b >>= 1ll;
			a = (a * a) % p; 
		}
		return re;
	}
	int Power(int a, int b, int p) {
		int re = 1;
		while(b) {
			if(b & 1) re = 1ll * re * a % p;
			b >>= 1;
			a = 1ll * a * a % p; 
		}
		return re;
	}
}using namespace lyt;
const int N = 2020;
int n, pre[N], tail[N], k, size[N], dis[N], dp[N];
struct node {
	int next, to;
}mp[N << 2];

void Maketo(int from, int to) {
	mp[++k].next = tail[from];
	mp[k].to = to;
	tail[from] = k; 
	return ;
}

void Dfs(int x, int fa) {
	size[x] = pre[x];
	dis[x] = dp[x] = 0;
	int maxn = 0;
	for (int i = tail[x]; i; i = mp[i].next) {
		int y = mp[i].to;
		if(y == fa) continue;
		Dfs(y, x);
		size[x] += size[y];
		dis[y] += size[y];
		dis[x] += dis[y];
		if(!maxn || dis[maxn] < dis[y])
			maxn = y;
	}
	if(!maxn) return ;
	if(dis[x] - dis[maxn] >= dis[maxn]) dp[x] = dis[x] / 2;
	else dp[x] = dis[x] - dis[maxn] + min(dp[maxn] * 2, 2 * dis[x] - dis[maxn]) / 2;
	return ;
}

int Starseven(void) {
	read(n);
	char txt[2020];
	scanf("%s", txt + 1);
	for (int i = 1; i <= n; i++) {
		pre[i] = txt[i] - '0';
	}
	for (int i = 1; i < n; i++) {
		int u, v;
		read(u);
		read(v);
		Maketo(u, v);
		Maketo(v, u); 
	}
	int ans = 999999999;
	for (int i = 1; i <= n; i++) {
		Dfs(i, 0);
		if(dis[i] & 1) continue;
		if(dp[i] * 2 >= dis[i])
			ans = min(ans, dis[i] / 2);
	}
	if(ans == 999999999) puts("-1");
	else write(ans), puts("");
	return 0;	
}

Measured memory_bytes: 3380
//Max?????????
#include<iostream>
#include <vector>
using namespace std;

class HeapTree :public std::vector<int>
{
public:
	void InputSet() {
		std::vector<int> & a = *this;
		int n;
		cin >> n;
		a.resize(n,0);
		for(int i=0;i<n;++i) {
			cin >> a.at(i);
		}
	}
	bool has_parent(int i) {
		return i>0;
	}
	int parent_id(int i)
	{
		return (i+1)/2 - 1;
	}
	int left_id(int i)
	{
		return 2*(i+1)-1;
	}
	int right_id(int i){
		return 2*(i+1)+1-1;
	}
	bool has_left(int i) {
		return left_id(i) < (int)size();
	}
	bool has_right(int i) {
		return right_id(i) < (int)size();
	}
	void Print() {
		for (unsigned int i=0;i<size();++i){
			cout << " " << at(i);
		}
		cout << std::endl;
	}
	void maxHeapify(int i)
	{
		int largest = i;
		if (this->has_left(i) && at(left_id(i)) > at(i)) {
			largest = left_id(i);
		}
		if (this->has_right(i) && at(right_id(i)) > at(largest)) {
			largest = right_id(i);
		}
		if (largest != i) {
			std::swap(at(i),at(largest));
			maxHeapify(largest);
		}
	}
	void buildMaxHeap()
	{
		for (int i = int(size()/2)-1;i>=0;--i) {
			maxHeapify(i);
		}
	}
};


int main(){
	HeapTree A;
	A.InputSet();
	A.buildMaxHeap();
	A.Print();
}

Measured memory_bytes: 3116
#include<iostream>
using namespace std;
int i,a,n,s=1;
int main(){
	cin>>a>>n;
	for(i=1;i<=a;i++){
		if(s<n){
			s*=2;
			continue;
		}
		s+=n;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
s = gets.chomp
a = s.each_char.slice_when(&:!=).map(&:size)

a.unshift(0) if s[0] == '0'
a.push(0) if s[-1] == '0'

cum = [0]
tmp = 0
a.each { |e| cum << tmp += e }

size = cum.size
l = max = 0
w = 2 * k + 1

while l < size
  tmp = l + w > size ? size - 1 : l + w
  max = [cum[tmp] - cum[l], max].max
  l += 2
end

puts max

Measured memory_bytes: 19152
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int findsumofDigits(int n){
        int sum = 0;
        while(n >0){
            sum += n%10;
            n /= 10;
        }
        return sum;
    }

int main()
{
    int n;
    cin >> n;
    if(n%10 == 0) cout << "10" <<endl;
    else cout << findsumofDigits(n) << endl;
}




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

const int maxn = 1e5 + 10;
int n, a[maxn];
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
	int cnt1 = 0, cnt2 = 0;
	for (int i = 1; i <= n; i ++)
		if (a[i] & 1) ++ cnt1;
		else if (a[i] % 4 == 0) ++ cnt2;
	if (!(n - cnt1 - cnt2)) puts(cnt2 >= cnt1 - 1 ? "Yes" : "No");
	else puts(cnt2 >= cnt1 ? "Yes" : "No");
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	// sort method :: sort given array using insertion Sort
	public static void sort(int[] _A, int _n) {
		for (int i = 1; i < _n; ++i) {
			
			// print(_A);
			int tmp = _A[i];
			int j = i - 1;
			while (j >= 0 && _A[j] > tmp) {
				_A[j + 1] = _A[j];
				--j;
			}
			_A[j + 1] = tmp;
			print(_A);
			// System.out.println("i = " + i);
		}
		
	}
	
	// print method :: print array
	public static void print(int[] _A) {
		for (int i = 0; i < _A.length; ++i) {
			System.out.print(_A[i]);
			if (i != _A.length - 1)
				System.out.print(" ");
		}
		System.out.println();
	}

	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		////////////////////////////////////
		int n = 0;
		int[] A;
		
		n = sc.nextInt();
		sc.nextLine();
		A = new int[n];
		for (int i = 0; i < n; ++i)
			A[i] = sc.nextInt();
		
		print(A);
		sort(A, n);
		
		////////////////////////////////////
		sc.close();
	}
	
}

Measured memory_bytes: 34468
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif


#ifdef L_JUDGE
#pragma warning(disable:4996)
#endif

using namespace std;

template <typename T>
inline bool read(T& ret) {
    T x = 0, f = 1; char ch = getchar();
    while(ch!=EOF && (ch > '9' || ch < '0')) { if(ch == '-') f = -1; ch = getchar();  }
    if(EOF==ch)return false;
    do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
    ret = x * f;
    return true;
}


inline char nc() {
    static char buf[100000], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
}
template <typename T>
bool rn(T& v) {
    static char ch;
    while (ch != EOF && !isdigit(ch)) ch = nc();
    if (ch == EOF) return false;
    for (v = 0; isdigit(ch); ch = nc())
        v = v * 10 + ch - '0';
    return true;
}

template <typename T>
void o(T p) {
    static int stk[70], tp;
    if (p == 0) { putchar('0'); return; }
    if (p < 0) { p = -p; putchar('-'); }
    while (p) stk[++tp] = p % 10, p /= 10;
    while (tp) putchar(stk[tp--] + '0');
}


LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }



void Solve(){
}


int main(){
#ifdef L_JUDGE
    freopen("in1.txt","r",stdin);
    //		freopen("out.txt","w",stdout);
#endif
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    int N;
    cin>>N;
    int A[300];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int ans=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(A[i]==A[j])continue;
            for(int k=j+1;k<N;k++){
                if(A[i]==A[k])continue;
                if(A[j]==A[k])continue;
                if((A[i]+A[j]>A[k])&&(A[i]+A[k]>A[j])&&(A[j]+A[k]>A[i])){
                    ans++;
                    //cout<<A[i]<<" "<<A[j]<<" "<<A[k]<<endl;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;

#ifdef L_JUDGE
    fclose(stdin);
    fclose(stdout);
    //		system("out.txt");
#endif

	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
}

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

class KMP {
public:
    KMP(string pat): pat(pat) {
        int n = pat.size();
        T.resize(n + 1, -1);
        for(int i = 0, j = -1; i < n; T[++i] = ++j) {
            while(j >= 0 && pat[i] != pat[j]) j = T[j];
        }
    }

    vector<int> operator()(string corp) {
        size_t corpPos = 0, patPos = 0;
        
        vector<int> ret;
        while(corpPos + patPos < corp.size()) {
            if(pat[patPos] == corp[corpPos + patPos]) {
                ++patPos;
                if(patPos < pat.size()) continue;
            }

            if(patPos == pat.size()) ret.push_back(corpPos);
            corpPos = corpPos + patPos - T[patPos];
            if(patPos > 0) patPos = T[patPos];
        }
        return ret;
    }

private:
    string pat;
    vector<int> T;
};

class DAG {
public:
    DAG(const vector<vector<int>> &edges)
    : tsort_done(false), acyc(false) {
        V = edges.size();
        E.resize(V);
        for(int i = 0; i < V; ++i) {
            for(int to : edges[i]) {
                E[i].push_back(to);
            }
        }
    }

    bool tsort() {
        vector<int> indeg(V, 0);
        for(int i = 0; i < V; ++i) {
            for(int to : E[i]) ++indeg[to];
        }

        stack<int> done;
        for(int i = 0; i < V; ++i) {
            if(indeg[i] == 0) done.push(i);
        }

        while(!done.empty()) {
            int cur = done.top();
            done.pop();
            order.push_back(cur);
            for(int to : E[cur]) {
                --indeg[to];
                if(indeg[to] == 0) done.push(to);
            }
        }

        tsort_done = true;
        acyc = (order.size() == V);
        return acyc;
    }

    int longest_path() {
        if(!tsort_done) tsort();
        if(!acyc) return -1;

        dp.resize(V);
        for(int i = 0; i < V; ++i) {
            int cur = order[i];
            for(int to : E[cur]) {
                dp[to] = max(dp[to], dp[cur] + 1);
            }
        }

        return *max_element(begin(dp), end(dp));
    }

    bool acyclic() {
        if(!tsort_done) tsort();
        return acyc;
    }

    int operator[](int i) {
        if(!tsort_done) tsort();
        return order[i];
    }

private:
    int V;
    vector<vector<int>> E;
    vector<int> order;
    bool tsort_done;
    bool acyc;
    vector<int> dp;
};

int main() {
    string s, t;
    cin >> s >> t;
    string S = s;
    while(S.size() < s.size() + t.size() - 1) S += s;

    KMP kmp(t);
    vector<int> pos = kmp(S);

    vector<vector<int>> E(s.size());
    for(int i : pos) {
        if(i >= s.size()) break;
        E[i].push_back((i + t.size()) % s.size());
    }

    DAG dag(E);
    cout << (!dag.acyclic() ? -1 : dag.longest_path()) << endl;  
}

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

using namespace std;
typedef long long ll; 
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int e = a + b;
	int f = c + d;
	if (e > f)
		printf("Left\n");
	else if (e == f) 
		printf("Balanced\n");
	else
		printf("Right\n");
	return 0;
} 

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

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);

	int n = 0;
	cin >> n;

	int ans = 0;
	for (int i = 1; i <= (n / 2); ++i) {
		int a = n - i;
		if (a != i) {
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int[] t = new int[N];

        for (int i = 0; i < N; i++) {
            t[i] = sc.nextInt();
        }

        if (N == 1) {
            System.out.println(T);
            return;
        }

        // simple event-driven simulation
        long sum = 0;
        for (int i = 1; i < N; i++) {
            sum += Math.min(T, t[i] - t[i - 1]);
        }
        sum += T;
        System.out.println(sum);

        return;
    }

}

Measured memory_bytes: 64584
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int N; 
int A[100010];
bool isOKL(int num) {
    rep(i, N) {
        num -= num % A[i];
    }
    return num >= 2;
}

int binary_searchL() {
    int ng = 1;
    int ok = INF2;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (isOKL(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

bool isOKR(int num) {
    rep(i, N) {
        num -= num % A[i];
    }
    return num <= 2;
}

int binary_searchR() {
    int ng = INF2;
    int ok = 1;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (isOKR(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> A[i];
    int lower = binary_searchL();
    int upper = binary_searchR();
    if (lower > upper || lower < 2) {
        cout << -1 << endl;
    } else {
        cout << lower << " " << upper << endl;
    }
    //cout << binary_searchL() <<" " << binary_searchR()  << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int h,w;
	cin>>h>>w;
	rep(i,h){
		rep(j,w){
			string s;
			cin>>s;
			if(s=="snuke"){
				cout << char('A'+j)  << i+1<<endl;
			}
		}
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 764
S=input()
s=len(S)
Sk=[]
Sg=[]
for i in range(0,s,2):
    Sk.append(S[i])
for i in range(1,s,2):
    Sg.append(S[i])
Skx=Sk.count('L')
Sgx=Sg.count('R')
if Skx+Sgx==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 998244353;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> l(k), r(k);
  rep(i,k) cin >> l[i] >> r[i];

  vector<ll> dp(n+1,0);
  vector<ll> dpsum(n+1,0);
  dp[1] = 1;
  dpsum[1] = 1;
  for (int i = 2; i <= n; i++) {
    rep(j,k){
      int li = i-r[j];
      int ri = i-l[j];
      if (ri < 0) continue;      
      li = max(li,1);
      dp[i] += dpsum[ri] - dpsum[li-1];
      dp[i] += M;
      dp[i] %= M;
    }
    dpsum[i] = dpsum[i-1] + dp[i];
    dpsum[i] %= M;
  }

  dp[n] += M;
  cout << dp[n] % M << endl;
  return 0;
}


Measured memory_bytes: 6424
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
using namespace std;
char ch[110],cur[110];
bool check(int len,char to)
{
	for(int i=0;i<len;i++)	if(cur[i]!=to)	return false;
	return true;
}
int work(int len,char to,int cnt)
{
	if(check(len,to))	return cnt;
	for(int i=0;i<len;i++)
	{
		if(cur[i]==to)
		{
			if(i>0)	cur[i-1]=cur[i]=to;
			else	cur[i]=to;
		}
	}
	return work(len-1,to,cnt+1);
}
int main()
{
	int n,i,j,ans;
	scanf("%s",ch);
	n=strlen(ch);ans=n;
	for(i=0;i<26;i++)
	{
		memcpy(cur,ch,sizeof(ch));
		ans=min(ans,work(n,'a'+i,0));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
#define lint long long
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
class Hotel{
  public:
  int dist;
  int no;
  vector<int> d;
};
int mypow(int n,int x){
  int res=1;
  int cur=n;
  while(x>0){
    if(x&1)res*=cur;
    cur*=cur;
    x/=2;
  }
  return res;
}
signed main(){
  int n;cin>>n;
  vector<int> x(n);
  rep(i,n)cin>>x[i];
  x.push_back(inf);
  vector<Hotel> h(n+1);
  int l,q;cin>>l;
  cin>>q;
  rep(i,100){
    h[n].d.push_back(n);
  }
  rep(i,100){
    h[n-1].d.push_back(n);
  }
  rep(i,n-1){
    h[i].no=i;
    h[i].dist=x[i];
    auto it=lower_bound(ALL(x),x[i]+l);
    if(*it!=x[i]+l)--it;
    int ind=it-x.begin();
    h[i].d.push_back(ind);
  }
  rep1(k,100){
    rep(i,n){
      h[i].d.push_back(h[h[i].d[k-1]].d[k-1]);
    }
  }
  vector<int> res(q);
  rep(i,q){
    int a,b;cin>>a>>b;
    --a;--b;
    if(a>b){
      swap(a,b);
    }
    int buf=0;
    int cur=a;
    while(cur!=b){
      if(b<h[cur].d[0]){
        buf+=1;
        break;
      }
      auto it=lower_bound(ALL(h[cur].d),b);
      if(*it!=b)--it;
      rep(i,n){
        //printf("d[]=%lld\n",h[cur].d[i]);;
      }
      int ind=it-h[cur].d.begin();
      cur=*it;
      buf+=mypow(2,ind);
      //printf("cur = %lld, ind = %lld\n",cur,ind);
    }
    res[i]=buf;
  }
  for(const auto& val:res){
    cout<<val<<"\n";
  }
  return 0;
}
/*
10
1 2 3 4 5 6 7 8 9 10
3
1
2 10
*/

Measured memory_bytes: 108528
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;


struct list{
	int key;
	list *before, *next;
};
list *current=NULL;

void insert(int x){
	list *nextlist;

	nextlist=(list *)malloc(sizeof(list));

	nextlist->key=x;
	nextlist->before=current;
	nextlist->next=current->next;
	current->next->before=nextlist;
	current->next=nextlist;

	return;
}

void delete_eq(int x){

	list *del=current->next;
	while(del->key!=-1){
	if(del->key==x){
		del->before->next=del->next;
		del->next->before=del->before;
		break;
	}
	del=del->next;
	}
	return;
}	

void delete_first(){
	current->next->next->before=current;
	current->next=current->next->next;
	return;
}

void delete_last(){
	current->before->before->next=current;
	current->before=current->before->before;
	return;
}

void print_list(){
	list *head=current->next;
	while(head->key!=-1){
		cout<<head->key;
		head=head->next;
		if(head->key!=-1) cout << " ";
	}
	cout<<endl;
	return;
}

void init(){
	if(current==NULL){
		current=(list *)malloc(sizeof(list));
		current->key=-1;
		current->next=current;
		current->before=current;
	}
}
	

int main()
{

	int n,num;
	char types[20];
	scanf("%d",&num);
	init();
	for(int j=0;j<num;j++){
		scanf("%s",types);
		if(types[0]=='i'){
			scanf("%d",&n);
			insert(n);
		} 
		else if(types[6]=='F') delete_first();
		else if(types[6]=='L') delete_last();
		else{
			scanf("%d",&n);
			delete_eq(n);
		}
	}
	print_list();
	

	return 0;


}



Measured memory_bytes: 37528
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    ll A,B,C,K;
    cin>>A>>B>>C>>K;
    for(int i=0;i<=K;i++)
    {
        for(int j=0;j<=K;j++)
        {
            for(int k=0;k<=K;k++)
            {
                if(i+j+k==K)
                {
                    if(A*(1LL<<i)<B*(1LL<<j)&&(B*(1LL<<j))<(C*(1LL<<k)))
                    {
                        cout<<"Yes";
                        return 0;
                    }
                }
            }
        }
    }
    cout<<"No";
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[0];
  cin>>a[0]>>a[1]>>a[2];
  int f=0,s=0;
  for(int i=0;i<3;i++)
  {
    if(a[i]==5)
      f++;
    if(a[i]==7)
      s++;
  }
  if(f==2&&s==1)
  {
    cout<<"YES";
  }
  else
  {
    cout<<"NO";
  }
      
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    int n, m, a;
    cin >> n >> m;
    REP(i, m) {
        cin >> a;
        n -= a;
    }
    if(n<0) cout << -1 << endl;
    else cout << n << endl;
}


Measured memory_bytes: 3572
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	int N;
	cin >> N;

	int x, y;

	x = 800 * N;

	y = N / 15 * 200;

	cout << x - y << endl;

}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,K,x = 0;
  cin >> N >> K;
  
  int i =0;
  int sum =0;
  
  for(i=0;i<N;i++){
    cin >> x;
    if(K-x > x)
      sum += 2*x;
    else
      sum += 2*(K-x);
  }
  
  cout << sum << endl;
}
      
    

Measured memory_bytes: 256
n,m = map(int,input().split())
all_li = []
for _ in range(m):
    s,c = map(int,input().split())
    all_li.append([s,c])

def check(n):
    flag = True
    l = list(str(n))
    for a in all_li:
        if int(l[a[0]-1]) != a[1]:
            flag = False
            break
    return flag

if n == 1:
    for i in range(0,10):
        if check(i):
            print(i)
            break
    else:
        print(-1)
elif n == 2:
    for i in range(10,100):
        if check(i):
            print(i)
            break
    else:
        print(-1)
else:
    for i in range(100,1000):
        if check(i):
            print(i)
            break
    else:
        print(-1)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long LL;
int main()
{
	LL a,b,c,x,y;
	scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&x,&y);
	LL ans=x*a+y*b;
	LL ans1;
	if (x>=y) ans1=y*2*c+(x-y)*a;
	else ans1=x*2*c+(y-x)*b;
	ans1=min(ans1,c*max(x,y)*2);
	printf("%lld\n",min(ans,ans1));
	return 0;
}

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

int main() {
  string X;
  cin >> X;
  
  vector<int> v;
  int cnt = 0;
  for (int i = 0; i < X.size(); ++i) {
    if (X[i] == 'S') {
      cnt++;
    } else {
      v.push_back(cnt);
    }
  }
  
  int ans = X.size();
  cnt = 0;
  for (int i = 0; i < v.size(); ++i) {
    if (v[i] - cnt > 0) {
      ans -= 2;
      cnt++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b,c;
    cin >> a >> b >> c;
    if(a+b>=c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
using namespace std;


int main(){
	int q;
	cin >> q;
	int l[100000],r[100000];
	int sum[100003];
	for(int i = 0 ; i < q ; i++ ){
		cin >> l[i] >> r[i];
	}
	
	sum[3] = 0;
	for(int i = 3 ; i < 100000 ; i = i + 2 ){
		int check = 1;
		for(int j = 2 ; j * j < i + 1 ; j++ ){
			if( i % j == 0 || ( ( i + 1 ) / 2 ) % j == 0 ){
				check = 0;
				break;
			}
			else ;
		}
		sum[i + 2] = sum[i] + check;
	}
	
	for(int i = 0 ; i < q ; i++ ){
		cout << sum[r[i]+2] - sum[l[i]] << endl;
	}
	
	return 0;
}

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

const int maxn = 2e5 + 10;
char s[maxn];

int main() {
    int n;
    scanf("%d", &n);
    scanf("%s", s + 1);
    int ans = n;
    int x = 0;
    int y = 0;
    for (int i = 1; i <= n; i++) x += s[i] == '.';
    for (int i = 0; i <= n; i++) y += s[i] == '.', ans = min(ans, i + x - 2 * y);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a=="xxx"){
		cout<<700<<endl;
	}
	else if(a=="xxo"||a=="xox"||a=="oxx"){
		cout<<800<<endl;
	}
	else if(a=="ooo"){
		cout<<1000<<endl;
	}
	else{
		cout<<900<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
// #include<bits\stdc++.h>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<algorithm>

#define MOD 1000000007
using namespace std;

void solve(){
    long long x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    long long moves = x / d;
    long long opos = x % d;
    if (moves > k){
        cout << x - d * k;
        return;
    }
    if ((k - moves) % 2 == 0) cout << opos;
    else cout << d - opos;

}

int main()
{   
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    solve();
}  

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int S, h, m, s, restS;
    cin >> S;
    h = S / 3600;
    restS = S % 3600;
    m = restS / 60;
    s = restS % 60;
    cout << h << ':' << m << ':' <<s <<endl;
}

Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <ctype.h>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){ 
    int N,M; cin >> N >> M;
    vector<int> food(M);
    for (int i=0;i<N;i++){
        int K_i; cin >> K_i;
        for (int j=0;j<K_i;j++){
            int A_i; cin >> A_i;
            food[(A_i)-1]++;
        }
    }
    int ans=0;
    for (int i=0;i<M;i++){
        if (food[i]==N) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import re

def solve(N: int, S: str):
    dic_original = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
    ans = ""
    for s in S:
        s_r = dic_original[(dic_original.index(s) + N) % 26]
        ans += s_r
#        S_ = re.sub(s, s_r, S)
    print(ans)

def main():
    N = int(input())
    S = str(input())
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
using namespace std;
int n,k, arr[100009];
int dp[100009];
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> arr[i];
	dp[1] = 0;
	for (int i = 2; i <= n; i++) {
		dp[i] = 1000000009;
		int w = 0;
		for (int j = i - 1; j > 0; j--) {
			w++;
			if (w > k) break;
			dp[i] = min(dp[i], abs(arr[i] - arr[j]) + dp[j]);
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    n = sum(B) - sum(A)
    if n < 0:
        print("No")
        exit()

    n_need = 0
    for a, b in zip(A, B):
        if a > b:
            n_need += (a - b)
        elif a < b:
            n_need += (b - a) % 2

    ans = "Yes" if n_need <= n else "No"
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

const double PI = acos(-1);

int main() {
	int a, b, h, m;
	scanf("%d%d%d%d", &a, &b, &h, &m);
	
	double hAngle = 30.0 * (1.0 * h + 1.0 * m / 60);
	double mAngle = 6.0 * m;
	
	double minAngle = -1.0;
	
	if (mAngle >= hAngle) minAngle = min(mAngle - hAngle, hAngle - mAngle + 360);
	else minAngle = min(hAngle - mAngle, mAngle - hAngle + 360);
	
	printf("%.12lf\n", sqrt(1.0 * a * a + 1.0 * b * b - 2.0 * a * b * cos(1.0 * minAngle * PI / 180.0)));
}


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

int main() {
	string s;
	cin >> s;
	for (int i = 0;i < s.length();i += 2) {
		cout << s[i];
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

見れば分かるように、一文字飛ばしで出力するだけ
これBにしては簡単すぎないか？
*/

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int n,p1[200],p2[200],p3[200],i,j,cnt,box[200],x[200];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&p1[i],&p2[i],&p3[i]);
	}
	for(i=0;i<n;i++)	box[i]=0;
	for(i=0;i<n-1;i++){
		box[i]=p1[i];
		for(j=i+1;j<n;j++){
			if(box[i]==p1[j]){
				p1[i]=0;
				p1[j]=0;
			}
		}
		box[i]=p2[i];
		for(j=i+1;j<n;j++){
			if(box[i]==p2[j]){
				p2[i]=0;
				p2[j]=0;
			}
		}
		box[i]=p3[i];
		for(j=i+1;j<n;j++){
			if(box[i]==p3[j]){
				p3[i]=0;
				p3[j]=0;
			}
		}
	}
	for(i=0;i<n;i++){
		x[i]=p1[i]+p2[i]+p3[i];
		printf("%d\n",x[i]);
	}
	return 0;
}



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

int main(){
  int A, B;
  cin >> A >> B;
  int count=1;
  int ans=0;
  while(true){
    if(count>=B){
      break;
    }
    count+=A-1;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,i,j,k;
  scanf("%d",&n);

  for (i=1; i<n+1; i++){
    j=i%1000; //???3???                                                           
    k=i%100; //???2???                                                            
    if (i%3==0 || i%10==3 || j/100==3 || k/10==3 || (i-j)/1000==3){
      printf(" %d",i);
    }
  }     

  printf("\n");

  return 0;
}

Measured memory_bytes: 600
n=int(input())
l=[int(input()) for _ in range(n)]
l.sort()
m=sorted((-1)**(i+1) if i==0 or i==n-1 else 2*((-1)**(i+1)) for i in range(n))
f=lambda x,y:x*y
a=abs(sum(map(f,l,m)))
b=abs(sum(map(f,l[::-1],m)))
print(max(a,b))

Measured memory_bytes: 57944
#include <bits/stdc++.h>
using namespace std;
#define cant -5e18
typedef struct 
{
	int l;
	int r;
	int num;
} interval;

int cmp(const void *p, const void *q)
{
	return ((interval*)p)->r-((interval*)q)->r;
}

int main(int argc, char const *argv[])
{
	long long n, s;
	cin >> n >> s;

	interval lr[501]={};
	for (int i = 1; i <= n; ++i)
	{
		cin >> lr[i].l >> lr[i].r;
		lr[i].num=i;
	}

	long long w[n+1][n+1];
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			cin >> w[i][j];
		}
	}

	//ここまで入力

	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			for (int k = 1; k <= n; ++k)
			{
				w[j][k] = min(w[j][k], w[j][i]+w[i][k]);
			}
		}
	}

	//ここまでWF

	qsort(lr+1, n, sizeof(interval), cmp);


	for (int i = 1; i <= n; ++i)
	{
		if (s == lr[i].num)
		{
			s = i;
			break;
		}
	}

	long long dp[501]={}, tmp;
	int now = s;
	if (w[lr[s].num][lr[1].num]>lr[1].r) tmp = cant;
	else if (w[lr[s].num][lr[1].num]<lr[1].l) tmp = lr[1].r-lr[1].l;
	else tmp = lr[1].r-w[lr[s].num][lr[1].num];
	dp[1] = tmp;
	for (int i = 2; i <= n; ++i)
	{		
		if (w[lr[s].num][lr[i].num]>lr[i].r) tmp = cant;
		else if (w[lr[s].num][lr[i].num]<lr[i].l) tmp = lr[i].r-lr[i].l;
		else tmp = lr[i].r-w[lr[s].num][lr[i].num];
		dp[i] = tmp;
		for (int j = 1; j < i; ++j)
		{
			if (lr[j].r+w[lr[j].num][lr[i].num]>lr[i].r) tmp = cant;
			else if (lr[j].r+w[lr[j].num][lr[i].num]<lr[i].l) tmp = dp[j]+lr[i].r-lr[i].l;
			else tmp = dp[j]+lr[i].r-w[lr[j].num][lr[i].num]-lr[j].r;
			dp[i] = max(dp[i], tmp);
		}
	}

	long long ans = 0;
	for (int i = 1; i <= n; ++i)
	{	
		ans = max(ans, dp[i]);
	}

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





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

int main() {
  
  string s;
  cin >> s;
  
  int a = s.size();
  bool answer = true;
  
  for (int i = 0; i < a / 2; i++) {
    if (s.at(i) != s.at(a-i-1) || s.at(i) != s.at(a/2+1+i)) {
      answer = false;
      break;
    }
  }
  
  if(answer)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
IN=lambda:list(map(int,input().split()))
h,w=IN()

A=[["#"]*(w+1)]+[["#"]+list(input()) for i in range(h)]
C=[[0]*(w+1) for i in range(h+1)]
C[1][1]=1
for i in range(1,h+1):
  for j in range(1,w+1):
    if A[i][j]=='.' and not (i==1 and j==1):
      C[i][j] = C[i-1][j]+C[i][j-1]
print(C[-1][-1]%(10**9+7))

Measured memory_bytes: 164224
n=int(input())
x=list(map(int,input().split()))
ans=1
if 0 in x:
    print(0)
else:
    for i in x:
        ans*=i
        if ans>10**18:
            ans=-1
            break
    if ans==-1:
        print("-1")
    else:
        print(ans)

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

using namespace std;

int main() {
	int a, b;
	scanf("%d %d", &a, &b);

	if ((a + b) % 2 == 1)
		printf("IMPOSSIBLE");
	else
		printf("%d", (a + b) / 2);
	
	return 0;
}

Measured memory_bytes: 256
/*
 _____ ____ _____   ___   ___   ___   ___ 
|_   _/ __ \_   _| |__ \ / _ \ |__ \ / _ \
  | || |  | || |      ) | | | |   ) | | | |
  | || |  | || |     / /| | | |  / /| | | |
 _| || |__| || |_   / /_| |_| | / /_| |_| |
|_____\____/_____| |____|\___/ |____|\___/ 
*/
#include <bits/stdc++.h>
#include <fstream>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
// pair<int,int>ert(x==y); gives run time when false
using namespace std;
const int MAX = 1000*1000+1;
int main()
{
    CIN;
    ll n,k;
    cin >> n >> k;
    vll dp(n+1,vl(MAX,longlimit));
    dp[0][0] = 0;
    vl v(n),v1(n);
    rep(i,0,n){
        cin >> v[i] >> v1[i];
    }
    rep(idx,0,n){
        rep(val,0,MAX){
            if(dp[idx][val]==longlimit)continue;
            if((dp[idx][val] + v[idx]) <= k)
            dp[idx+1][val+v1[idx]] = min(dp[idx+1][val+v1[idx]],dp[idx][val] + v[idx]); 
            dp[idx+1][val] = min(dp[idx+1][val],dp[idx][val]);
        }
    }
    ll maxi = 0;
    rep(val,0,MAX){
        if(dp[n][val]!=longlimit){
            maxi = max(maxi,(ll)val);
        }
    }
    cout << maxi;
}


Measured memory_bytes: 797440
s = gets.chomp
n = s.size
s_t = s.slice(0..((n-1)/2)-1)
s_b = s.slice(((n+3)/2)-1..n-1)
if s == s.reverse && s_t == s_t.reverse && s_b == s_b.reverse
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
H,W,S= map(int, input().split())
grid=[[v for v in input()] for _ in range(H)]

ans=H*W
for row in range(1<<(H-1)):
    row_cut = str(bin(row))[2:].count("1")
    splits = [grid[0]]
    for i in range(H-1):
        if row & (1<<i):
            splits.append(grid[i+1][:])
        else:
            splits[-1]=[splits[-1][j]+grid[i+1][j] for j in range(W)]

    if any(max(v.count("1") for v in s)>S for s in splits):
        continue

    count=[[] for _ in range(len(splits))]
    for i,s in enumerate(splits):
        for v in s:
            count[i].append(v.count("1"))

    col_cut=0
    tmp_cnt=[count[i][0] for i in range(len(splits))]
    for i in range(1,W):
        merged_cnt=[tmp_cnt[j]+count[j][i] for j in range(len(splits))]
        if max(merged_cnt)>S:
            col_cut+=1
            tmp_cnt =[count[j][i] for j in range(len(splits))]
        else:
            tmp_cnt=merged_cnt
    ans = min(ans,col_cut+row_cut)


print(ans)
    



Measured memory_bytes: 84572