akhauriyash/Code-Regression huggingface dataset:
n, y = map(int, input().split())

for a in range(n+1):
    for b in range(n+1):
        c = max(n - (a + b), 0)
        if a+b+c == n and 10000*a + 5000*b + 1000*c == y:
            print(a, b, c)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 67572
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int solve(int x, int y)
{
    if ((0 <= x && x <= y) || (x <= y && y <= 0)) return y - x;
    if ((Int)x * y <= 0) return abs(abs(y) - abs(x)) + 1;
    return abs(abs(y) - abs(x)) + 2;
}
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int x, y; cin >> x >> y;
    cout << solve(x, y) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000003;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005];
//bool used[500005];
bool flag,dame;


int main(){
	cin >> n >> a >> b >> c >> d;
    a--;b--;c--;d--;
    cin >> s;
    if(c < d){
        //大小が一致する
        for(i=0;i<n-1;i++){
            if(s[i] == '#' && s[i+1] == '#'){
                if(a < i && i < c)dame = true;
                if(b < i && i < d)dame = true;
            }
        }   
        Yes(!dame);
    }else{
        bool ok = false;
        for(i=0;i<n-2;i++){
            if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.'){
                if(b <= i+1 && i+1 <= d){
                    ok = true;
                }
            }
        }
        for(i=0;i<n-1;i++){
            if(s[i] == '#' && s[i+1] == '#'){
                if(a < i && i < c)ok = false;
            }
        }
        Yes(ok);
    }

	return 0;
}

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

int main()
{
  int N,A,B,i,sum;
  int a=0,b=0,c=0,d=0,e=0;
  scanf("%d %d %d",&N,&A,&B);
  
  for(i=0;i<=N;i++)
  {
    a=0;
    b=0;
    c=0;
    d=0;
    e=0;
  
  if(i-10000>=0)
  {
    a=floor(i/10000);
  }
    
  if(i-1000>=0)
  {
    b=floor(i/1000)-a*10;
  }
  
  if(i-100>=0)
  {
    c=floor(i/100)-a*100-b*10;
  }
  
  if(i-10>=0)
  {
    d=floor(i/10)-a*1000-b*100-c*10;
  }  
  
  e=i-a*10000-b*1000-c*100-d*10;
  
  if(a+b+c+d+e>=A && a+b+c+d+e<=B)
  {
    sum=sum+i;
  }

  }
  printf("%d",sum);
  return 0; 
}


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

long long N, M;
vector<pair<long long, long long> > tree[100005];
long long ans[100005];

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

	for(long long i = 0; i < 100005; i++){
		ans[i] = -1;
	}

	for(long long i = 0; i < M; i++){
		long long l, r, c;
		cin >> l >> r >> c; l--; r--;
		tree[l].push_back(make_pair(r, c));
	}

	//                    cost   , point
	priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> > > Q;
	Q.push(make_pair(0, 0));

	while(!Q.empty()){
		long long cost = Q.top().first;
		long long point = Q.top().second;
		Q.pop();
		if(ans[point] >= 0){
			continue;
		}
		ans[point] = cost;

		for(long long i = 0; i < tree[point].size(); i++){
			long long nextcost = cost + tree[point][i].second;
			long long nextpoint = tree[point][i].first;
			if(ans[nextpoint] < 0){
				Q.push(make_pair(nextcost, nextpoint));
			}
		}

		if(point > 0 && ans[point - 1] < 0){
			Q.push(make_pair(cost, point - 1));
		}
	}

	cout << ans[N-1] << endl;
}



Measured memory_bytes: 7928
#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
typedef pair<int, int> P;
int A[100010];
int B[100100];
P p[100010];
P A2[100010];
int N; 

struct UnionFind {
	vector<int> par;
	UnionFind(int x) : par(x, -1) {}
	void init(int x) { par.assign(x, -1); }
	int root(int x) {
		if (par[x] <= -1) return x;
		else return root(par[x]);
	}
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return -par[root(x)];
	}
};
map<int, int> mp;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) p[i] = {B[i], A[i]};
    sort(p, p + N);
    sort(A, A + N);
    sort(B, B + N);
    rep(i, N) {
        if (A[i] > B[i]) {
            cout << "No" << endl;
            return 0;
        }
    }


    rep(i, N) mp[A[i]] = i;
    UnionFind UF(N);
    rep(i, N) {
        UF.merge(i, mp[p[i].second]);
        //cout << i << " "<< mp[p[i].second] << endl;
    }
    if (UF.size(0) < N) {
        //cout << UF.size(0) << endl;
        cout << "Yes" << endl;
        return 0;
    }
    rep(i, N - 1) {
        if (A[i + 1] <= p[i].first && A[i]<= p[i + 1].first  ) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl; 





    return 0;
}

//73 39 25 85 58 2
//2| 39 25 85 58 73
//2 25 39| 85 58 73
//2 25 39 58| 85 73
//2 25 39 58 73 85|
//-----------------
//10 37 55 68 78 88

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int v[3010][3010];
int main(){
    string s,t;cin>>s>>t;
    rep(i,s.size()){
        rep(j,t.size()){
            if(s[i]==t[j])v[i+1][j+1]=max({v[i+1][j],v[i][j+1],v[i][j]+1});
            else v[i+1][j+1]=max(v[i+1][j],v[i][j+1]);
        }
    }
    string ans="";
    int i=s.size(),j=t.size();
    while(i>0&&j>0){
        if(i&&(v[i-1][j]==v[i][j]))i--;
        else if(j&&(v[i][j-1]==v[i][j]))j--;
        else{
            i--;j--;
          ans+=t[j];
        }
    }
  reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long double t;
	long double k;
	cin>>t>>k;
	int c = 0;
	while(t--){
		long double a, b;
		cin>>a>>b;
		long double x = sqrt((a*a) + (b*b));
		if(x<=k)
			c++;
	}
	cout<<c<<endl;
}

Measured memory_bytes: 3860
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int h = sc.nextInt();
		int w = sc.nextInt();
        
        for (int parent = 1; parent <= h; parent++) {
          for (int child = 1; child <= w; child++) {
             if (sc.next().equals("snuke")) {
               // 出力
		       System.out.println(getCharForNumber(child) + parent);
               break;
             }
          }
        }
	}
  private static String getCharForNumber(int i) {
    return i > 0 && i < 27 ? String.valueOf((char)(i + 64)) : null;
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	string n;
	int ans=0;
	
	cin>>n;
	n[3]='8';
	cout<<n<<endl;
	return 0;
}

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

using namespace std;
#define PI acos(-1)

int main()
{
	int A, B, C, X;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> X;

	int num = 0;

	for (int a = 0; a <= A; a++)
	{
		for (int b = 0; b <= B; b++)
		{
			for (int c = 0; c <= C; c++)
			{
				if ((500 * a + 100 * b + 50 * c) == X) 
				{
					num++;
				}

				if ((500 * a + 100 * b + 50 * c) > X)
				{
				break;
				}
				
			}
		}
	}

	cout << num;
}



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

int main(){
    string a;
    cin>>a;
    if(a[0]>= 'a' && a[0] <= 'z')
        cout<<"a"<<endl;
        else
        cout<<"A"<<endl;
}


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

typedef unsigned long long ull;
typedef long long ll;

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

int main()
{
  ll N,a;
  vector<ll> n;
  cin >> N;

  rep(i,N)
  {
    cin >> a;
    n.push_back(a);
  }

  sort(n.begin(),n.end());

  ll l=0;
  for(int i = N-1; i >= 0; i--)
  {
    if(i-1>=0)
      if(n[i]==n[i-1])
        if(l==0)
          l = n[i--];
        else
        {
          cout << l*n[i] << endl;
          return 0;
        }
  }
  cout << 0 << endl;
  return 0;
}



Measured memory_bytes: 1400
def main():

    S = input()
    N = len(S)
    pair = [[0, N-1], [0, (N-1)//2-1], [(N+3)//2-1, N-1]]
    for i, j in pair:
        d = j-i+1
        for k in range(d//2):
            if S[i+k] != S[j-k]:
                return "No"
    return "Yes"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 38452
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

bool pos(ll n,ll k,vector<pair<bool,bool>>& dp)
{
	bool res=true;
	if(n==1 || n%k==1)
	return true;
	if(n<0)return false;
	if(dp[n].first)return dp[n].second;
	if(n%k==0)
	res&=pos(n/k,k,dp);
	else 
	res&=pos(n-k,k,dp);
	
	if(res)
	{
		dp[n]={true,true};
	}
	else dp[n]={true,false};

	return res;

}
bool f(long long x, long long y)
{
	if(y==1) return false;
	while (x % y == 0)
	{
		x /= y;
	}
	return x % y == 1;
}
vector<ll> div(ll n)
{
	vector<ll> d;
	for (ll i = 1; i <= sqrt(n); ++i)
	{
		if (n % i == 0)
		{
			d.pb(i);
			if (n / i != i)
				d.pb(n / i);
		}
	}
	return d;
}
int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	//vis res
	
	ll ans=div(n-1).size()-1;
	//cout<<ans<<endl;
	vector<ll> divs=div(n);
	for(auto x:divs)
	{
		//cout<<x<<endl;
		ans+=f(n,x);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>

// https://umbccd.io/challenges


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

using namespace std;


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

	ll ans = 0;

	for (ll i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			continue;
		}
		ans += i;
	}
	cout << ans << endl;

 	return 0;
}


Measured memory_bytes: 3192
object Main {
  def main(args:Array[String]) {
    val N = readLine().toInt
    val A = readLine().split(' ').map(_.toInt)
    val B = readLine().split(' ').map(_.toInt)

    var count = 0l
    for(i <- 0 until N) {
      if(A(i) <= B(i)) {
        count += A(i)
        B(i) -= A(i)
      }else if(A(i) > B(i)) {
        count += B(i)
        B(i) = 0
      }
      if(A(i + 1) <= B(i)){
        count += A(i + 1)
        A(i + 1) = 0
      }else if(A(i + 1) > B(i)) {
        count += B(i)
        A(i + 1) -= B(i)
      }
    }
    println(count)
  }
}


Measured memory_bytes: 74484
while 1:
  try: n,m=map(int,input().split());
  except: break
  rs=[]
  while 1:
    line=input()
    if line=="0 0 0": break
    s,t,e=map(int,line.split())
    rs.append((s-1,t-1,e))
  l=int(input())
  b=[list(map(int,input().split())) for _ in range(l)]
  
  c=[[0]*n for _ in range(l)]
  for s,t,e in rs:
    for i in range(l):
      c[i][s]+=b[i][t]*e
  
  for i in range(l):
    print(" ".join(str(x) for x in c[i]))

Measured memory_bytes: 87640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    vector<int> a(3);
    for(int i = 0; i < 3; ++i){
        cin >> a.at(i);
    }
    
    sort(a.begin(), a.end());
    
    cout << a.at(0) + a.at(1) << endl;
    
}


Measured memory_bytes: 3576
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, h: [usize; n]);

    let mut buff = h[n - 1];
    for &v in h.iter().rev() {
        if buff + 1 == v || buff == v {
            continue;
        }
        if buff > v {
            buff = v;
            continue;
        }
        println!("{}", "No");
        return;
    }

    println!("{}", "Yes");
}


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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  string S1,S2;
  for(int i=0;i<S.size()/2;i++){
    S1+=S[i];
  }
  for(int i=S.size()/2;i<N;i++){
    S2+=S[i];
  }
  if(S1==S2)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = (int)s.size();
    vint cnt(3,0);
    for(char c: s){
        cnt[(int)(c-'a')]++;
    }
    sort(ALL(cnt));
    if(l==1){
        puts("YES");
        return 0;
    }else if(l==2){
        if(cnt[1]==1){
            puts("YES");
            return 0;
        }
    }else{
        if(cnt[2]<=cnt[0]+1){
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int MOD = 1e9 + 7, N = 2e3 + 10;
int a[N];

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    int sum1 = 0, sum2 = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) {
            if (a[i] > a[j]) sum2++;
            if (i < j && a[i] > a[j]) sum1++;
        }
    int ans = (1LL * sum1 * k + 1LL*sum2*(1LL*k*(k-1)/2%MOD)) % MOD;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  string S, T, U;
  i64 A, B;
  cin >> S >> T >> A >> B >> U;
  if(U==S) A--;
  else B--;
  cout << A << " " << B << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  if(s=="Sunny") pr("Cloudy");
  else if(s=="Cloudy") pr("Rainy");
  else pr("Sunny");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <cmath>

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

namespace
{
	ll GCD(ll a, ll b)
	{
		return a == 0 ? b : GCD(b % a, a);
	}


	ll LCM(ll a, ll b)
	{
		return a * b / GCD(a, b);
	}
}

void AGC028A()
{
	int N, M;
	cin >> N >> M;
	string S, T;
	cin >> S;
	cin >> T;

	ll X = LCM(N, M);
	ll Y = GCD(N, M);
	int n = X / N;
	int m = X / M;
	ll x = LCM(n, m);
	int nn = x / n;
	int mm = x / m;
	for (int i = 0; i < max(N,M); ++i)
	{
		if (nn * i >= N || mm * i >= M)
			break;
		char s = S[nn * i];
		char t = T[mm * i];
		if (s != t)
		{
			cout << -1 << endl;
			return;
		}

	}
	cout << X << endl;


}
int main()
{
	AGC028A();
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int n;
    cin >> n;
    n = n % 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon";
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon";
    }else {
        cout << "bon";
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <map>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int N; ll M; cin>>N>>M;
  ll sum = 0;
  map<ll, ll> cnt;
  cnt[0LL] = 1;
  ll ans = 0;
  REP(i, N) {
    ll a; cin>>a;
    sum = (sum + a) % M;
    ll c = cnt[sum];
    ans += c;
    cnt[sum]++;

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


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main(){
  int D,T,S;cin >> D >> T >> S;
  cout << ((T*S >= D) ? "Yes\n":"No\n");
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int64_t x;
    cin>>x;
    int64_t a=0,b=0;
    for(int i=-500;i<=500;i++){
        for(int j=-500;j<=500;j++){
            if(pow(i,5)-pow(j,5)==x){
                a=i;
                b=j;
                break;
            }
        }
    }
    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 3964
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

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 LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    rep(i,1,361){
        if(x * i % 360 == 0){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3548
array=[int(input()) for i in range(5)]
array2=[array[i]%10 for i in range(5)]
n=10
sum=0
for i in range(5): 
    if array2[i]<n and array2[i]!=0: n=array2[i]
    if array2[i]!=0: sum += int(array[i]/10)+1
    else: sum += int(array[i]/10)
if n!=10: print(sum*10-(10-n))
else: print(sum*10)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int H,W,INF=1e9;
char s[1005];
int t[1005][1005];
int dp[1005][1005][16];

int main(){
  scanf("%d %d",&H,&W);
  for(int i=0;i<H;i++){
    scanf("%s",s);
    for(int j=0;j<W;j++){
      if(s[j]!='.')t[i+1][j+1]=s[j]-'0';
    }
  }
  int ans=INF;
  fill((int*)dp,(int*)dp[1005],INF);
  dp[1][1][0]=0;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      for(int bit=0;bit<(1<<4);bit++){
        if(dp[i][j][bit]==INF)continue;
        int cost=dp[i][j][bit];
        int a=bit>>0&1,b=bit>>1&1,c=bit>>2&1,d=bit>>3&1;
        int nbit,ncost;
        
        nbit=b+2*0+4*1+8*1;
        ncost=cost+t[i][j]+t[i+1][j]+t[i][j-1]*(1-c);
        dp[i][j+1][nbit]=min(dp[i][j+1][nbit],ncost);
        
        nbit=1*b+2*0+4*1+8*0;
        ncost=cost+t[i][j]+t[i-1][j]*(1-a)+t[i][j-1]*(1-c);
        dp[i][j+1][nbit]=min(dp[i][j+1][nbit],ncost);
        
        nbit=1*b+2*0+4*1+8*1;
        ncost=cost+t[i][j]+t[i-1][j]*(1-a)+t[i+1][j];
        dp[i][j+1][nbit]=min(dp[i][j+1][nbit],ncost);
        
        nbit=1+2*1+4*d+8*0;
        ncost=cost+t[i][j]+t[i][j+1]+t[i][j-1]*(1-c);
        dp[i+1][j][nbit]=min(dp[i+1][j][nbit],ncost);
        
        nbit=1+2*0+4*d+8*0;
        ncost=cost+t[i][j]+t[i-1][j]*(1-a)+t[i][j-1]*(1-c);
        dp[i+1][j][nbit]=min(dp[i+1][j][nbit],ncost);

        nbit=1+2*1+4*d+8*0;
        ncost=cost+t[i][j]+t[i-1][j]*(1-a)+t[i][j+1];
        dp[i+1][j][nbit]=min(dp[i+1][j][nbit],ncost);

        if(i==H&&j==W)ans=min(ans,ncost);
      }
    }
  }
  
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 68252
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

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

  std::string S;
  std::cin >> S;
  std::string T = S;

  std::reverse(T.begin(), T.end());
  std::string::iterator it;

  ll cnt = 0LL;
  for (ll i = 0; i < (ll)S.length() / 2; ++i) {
    if (S[i] != T[i]) cnt++;
  }

  print(cnt);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

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

    ll l;
    cin >> l;

    double c = l/3.0;
    printf("%lf\n", c*c*c);

    return 0;
}


Measured memory_bytes: 256
#! python

from collections import defaultdict

#K, X = [int(x) for x in input().split()]

N = int(input())
S = []
for _i in range(N):
    S.append(input())

sortedS = ["".join(sorted(s)) for s in S]

cnt = defaultdict(int)
for s in sortedS:
    cnt[s] += 1

ans = 0
for s,c in cnt.items():
    if c >= 2:
        ans += c * (c-1) // 2
print(ans)


Measured memory_bytes: 26864
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<cstdio>
#include<cstring>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
//#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
const int MAX = 2510000;
const int MOD = 998244353;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();
    ll n,m;cin>>n>>m;
    ll ans = COM(3*m+n-1,n-1);
    fr(i,m){
        ans -= COM(n-2+i,n-2)*n;
        ans %=MOD;
        if (ans < 0){
            ans +=MOD;
        }
    }
    for(ll i = m+1;i<=min(3*m,n);i++){
        if((3*m-i)%2==0){
            ans -= COM(n,i)*COM((3*m-i)/2 + n -1,n-1);
            ans %=MOD;
            if (ans < 0){
                ans +=MOD;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  char c; cin >> c;
  if (c == 'A') cout << 'T' << endl;
  if (c == 'T') cout << 'A' << endl;
  if (c == 'G') cout << 'C' << endl;
  if (c == 'C') cout << 'G' << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

int N, A;

void solve() {
    bool pos = true;
    cin >> N;
    for (int i = 0; i < N; i++) {
		cin >> A;
		if (!(A % 2) && A % 3 && A % 5) pos = false;
	}
	if (pos) cout << "APPROVED";
	else cout << "DENIED";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


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

using namespace std;

int solve() {
	int costs[4] = { 0 };
	int count[4] = { 1, 2, 4, 8 };
	cin >> costs[0];
	for (int i = 1; i < 4; ++i) {
		cin >> costs[i];
		costs[i] = min(costs[i], costs[i - 1] * 2);
	}
	long long n;
	cin >> n;
	n *= 4;
	long long ans = 0;
	for (int i = 3; i >= 0; i--) {
		ans += (long long)(n / count[i])*costs[i];
		n %= count[i];
	}
	cout << ans << endl;
	return 0;
}

int main() {
	return solve();
}

Measured memory_bytes: 256
#include <stdio.h>

int a[105];

int main() {

	int N;

	scanf("%d",&N);

	int i,j;

	for (i = 0; i < N; i++) {
		scanf(" %d",&a[i]);
	}

	int ans = (1 << 30);

	for (i = -100; i <= 100; i++) {
		int cost = 0;
		for (j = 0; j < N; j++) {
			cost += (a[j]-i)*(a[j]-i);
		}
		if (ans > cost) { ans = cost; }
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define gcd            __gcd
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x,y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    nitin;
    int a,b;
    cin>>a>>b;
    if(0>=a && 0<=b)
    {
        cout<<"Zero"<<endl;
    }
    else{
        if(b>0)
            b=-1;
        if(a>0 ||(abs(-a+1+b)%2==0))
        cout<<"Positive"<<endl;
        else
            cout<<"Negative"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3588
import collections 
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

s = list(input())
t = list(input())
ans = []

for i in range(len(s)-len(t)+1)[::-1]:
    bb = True
    for j in range(len(t)):
        if s[i+j] == '?':
            continue
        else:
            if s[i+j] != t[j]:
                bb = False
    if bb == True:
        ss = s[:]
        for _ in range(len(s)):
            if _ < i:
                if ss[_] == '?':
                    ss[_] = 'a'
            elif _ < i + len(t):
                ss[_] = t[_-i]
            else:
                if ss[_] == '?':
                    ss[_] = 'a'
        ans.append(''.join(ss))

if ans == []:
    print('UNRESTORABLE')
else:
    ans.sort
    print(ans[0])

Measured memory_bytes: 4204
#include<iostream>
#include<stdio.h>

using namespace std;

int a[15];
int main(){
    for(int i=0; i<4; i++) {
        int x;
        cin >> x;
        a[x]++;
    }
    cout << ( (a[1]&&a[9])&&(a[7]&&a[4]) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=500010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int main(){
	int n;
	while(cin>>n){
		int ans=0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					for(int l=0;l<10;l++){
						if(i+j+k+l==n){
							ans++;
						}
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
		
		int H,W,K;
		cin>>H>>W>>K;
		
		if(W==1){
			ce(1)
		}else{
		
			int amida[H+1][W+2];
			int size=1<<(W-1);
			fx(W+2){
				amida[0][x]=0;
			}
          amida[0][1]=1;
			fyg(H+1,1){
              fx(W+2){
				amida[y][x]=0;
			  }
				fx(size){
					bool flag=false;
					fz(W){
						if((x>>z)&1==1 && (x>>(z+1))&1==1){
							flag=true;
                          break;
						}
					}
					if(flag){
                      continue;
                    }
					fz(W+1){
						if(z>=1&&(x>>(z-1))&1==1){
							amida[y][z+1]=(amida[y][z+1]+amida[y-1][z])%MOD;
						
						}else if(z<W&&(x>>z)&1==1){
                          amida[y][z+1]=(amida[y][z+1]+amida[y-1][z+2])%MOD;
                        }else{
                          amida[y][z+1]=(amida[y][z+1]+amida[y-1][z+1])%MOD;
                        }
					}
				}

			}
          		ce(amida[H][K])
		}
		
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    ll ans = 0, N, M; cin >> N >> M;
    vll A(N); REP(i, N) cin >> A[i];
    vector<pll> B(M); REP(i, M) cin >> B[i].second >> B[i].first;
    REP(i, N) B.push_back(make_pair(A[i], 1));
    sort(ALL(B), greater<>());
    ll i = 0;
    while(N > 0)
    {
        if(B[i].second < N)
        {
            ans += B[i].first * B[i].second;
            N -= B[i].second;
            i++;
        }
        else
        {
            ans += B[i].first * N;
            break;
        }
    }
    cout << ans << endl;
}
    
signed main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 8580
#pragma warning(disable:4996)


#include<iostream>
#include<algorithm>
//#include<unordered_map>
#include<fstream>
#include<iomanip>
#include<string>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<sstream>
#include<cstdio>
#include<ctime>
#include<cstdlib>
#define INF 0x3f3f3f3f
#define inf 0x7FFFFFFF
#define MOD 1000000007
#define pii pair<ll,ll>
#define eps 1e-8
#define equals(a,b) (fabs(a-b)<eps)
#define bug puts("bug")
#define re  register
#define fi first
#define se second
const int maxn = 2e5+ 5;
const double Inf = 10000.0;
const double PI = acos(-1.0);
typedef  long long ll;
using namespace std;

int n, m;
ll k;
ll a[maxn], b[maxn];
ll sum1[maxn];
ll sum2[maxn];

bool check(int x) {
	for (int i = x - m ; i <= min(x,n); i++) {
		if (sum1[i] + sum2[x - i] <= k) {
			//cout << x << " " << i <<" "<< x - i << endl;
			return 1;
		}
	}
	return 0;
}

int main() {
	scanf("%d%d%lld", &n, &m, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", a + i );  sum1[i] = sum1[i - 1] + a[i];
	}
	for (int i = 1; i <= m; i++) {
		scanf("%lld", b + i); sum2[i] = sum2[i - 1] + b[i];
	}
	int l = 0, r = n + m;
	while (l < r) {
		int mid = l + r + 1 >> 1;
		if (check(mid)) l = mid;
		else r = mid - 1;
	}
	if (check(l)) printf("%d", l);
	else printf("%d", l-1);
}

Measured memory_bytes: 10060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// Greedy 0に気を付ける
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n + 1];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}

		// sortするとカード番号がずれるのでソートはしない。
		long ans = 0L;
		for (int i = 1; i <= n; i++) {
			// Ai同士でペアを作って、1余ったら残して次とペアにしたいのでmodする
			ans += a[i - 1] / 2;
			a[i - 1] %= 2;

			// Aiの残り部分と次の値がペアにできるなら先にペアにしておく
			if (a[i] > 0 && a[i - 1] > 0) {
				ans++;
				a[i]--;
				a[i - 1]--;
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 62336
#include <iostream>
using namespace std;
int main() {
	int A, B, K;
	cin >> A >> B >> K;
	int cnt = 0;
	for (int i = A; i >= 1; --i) {
		if (A % i == 0 && B % i == 0) {
			++cnt;
			if (cnt == K) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   N : Integer;
begin
   Get (N);
   N := N-N/10*10;
   if N = 3 then
      Put_Line ("bon");
   elsif N = 0 then
      Put_Line ("pon");
   elsif N = 1 then
      Put_Line ("pon");
   elsif N = 6 then
      Put_Line ("pon");
   elsif N = 8 then
      Put_Line ("pon");
   else
      Put_Line ("hon");
   end if;
end Solve;

Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <ctime>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair < int, int >
#define ull unsigned long long
#define pll pair < ll, ll >
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()

const int inf = (1ll << 30) - 1;
const int maxn = (int) 1e5 + 10;

using namespace std;
int n;       
int a, b;
string x = "Alice";
string y = "Borys";
void solve(){
	cin >> n >> a >> b;
	if((b-a) & 1) cout << y << endl;
	else cout << x << endl;

}

int main () {
	#ifdef LOCAL
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
	#endif
    int t=1;
    //scanf("%d", &t);
    for(int i=1; i <= t; i++){
      //printf("Case #%d\n", i);
      solve();
    }

    return 0;
}



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



int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> data.at(i).at(j);
    }
  }
  
  vector<bool> row(H, false);
  vector<bool> col(W, false);
  
  for (int h = 0; h < H; ++h) {
    for (int w = 0; w < W; ++w) {
      if (data.at(h).at(w) == '#') {
        row.at(h) = true;
        col.at(w) = true;
      }
    }
  }
  for (int h = 0; h < H; ++h) {
    if(row.at(h)) {
      for (int w = 0; w < W; ++w) {
        if (col.at(w)) {
          cout << data.at(h).at(w);
        }
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int s,h,m,ss;
    cin>>s;
    h=s/3600;
    m=(s-3600*h)/60;
    ss=s-3600*h-60*m;
    cout<<h<<":"<<m<<":"<<ss<<endl;
    return 0;
}


Measured memory_bytes: 3092
H, W = map(int, input().split())

matrix = []

visited = set()

for i in range(H):
    matrix.append(list(input()))

visited = set()

for i in range(H):
    for j in range(W):
        if matrix[i][j] == '#' and (i, j) not in visited:
            for ud, lr in ((-1, 0), (1, 0), (0, -1), (0, 1)):
                if not(0 <= i+ud < H and 0 <= j+lr < W)  or matrix[i+ud][j+lr] == '#':
                    continue
                visited.add((i+ud, j+lr))
                matrix[i+ud][j+lr] = '#'

res = 0

while visited:
    res += 1
    buf = set()
    for i, j in visited:
        if matrix[i][j] == '#' and (i, j) not in buf:
            for ud, lr in ((-1, 0), (1, 0), (0, -1), (0, 1)):
                if not(0 <= i+ud < H and 0 <= j+lr < W)  or matrix[i+ud][j+lr] == '#':
                    continue
                buf.add((i+ud, j+lr))
                matrix[i+ud][j+lr] = '#'
    if not buf:
        break
    visited = buf

print(res)



Measured memory_bytes: 174104
def myAnswer(R:int,G:int,B:int,N:int) -> int:
   ans = 0
   for i in range(0,N+1,R):
      for j in range(0,N+1,G):
         k = N - j - i
         if( k % B != 0 or k < 0):
            continue
         else:
            # print(i,j,k)
            ans += 1

   return ans

def modelAnswer():
   return
def main():
   R,G,B,N = map(int,input().split())
   print(myAnswer(R,G,B,N))
if __name__ == '__main__':
   main()

Measured memory_bytes: 40684