akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=505;
int h,w,tot;
char ch[N];
char f[N][N],g[N][N];
char ans[N*N*2];
int main(){
	h=read(); w=read();
	for(int i=1;i<=h;i++){f[i][1]=1; g[i][w]=1;}
	for(int i=1;i<=h;i++){
		if(i&1)for(int j=2;j<w;j++)f[i][j]=1; else for(int j=2;j<w;j++)g[i][j]=1;
	}
	for(int i=1;i<=h;i++){
		scanf("%s",ch+1);
		for(int j=1;j<=w;j++)if(ch[j]=='#')f[i][j]=g[i][j]=1;
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)ans[tot++]=f[i][j]?'#':'.'; ans[tot++]='\n';
	}
	ans[tot++]='\n';
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)ans[tot++]=g[i][j]?'#':'.'; ans[tot++]='\n';
	}
	puts(ans);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define overload4(_1, _2, _3, _4, name, ...) name
#define overload3(_1, _2, _3, name, ...) name
#define rep1(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
template <class T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
typedef pair<int, int> P;

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main() {  // TODO
  double D, T, S;
  cin >> D >> T >> S;
  double a = D / S;
  if (a <= T) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3708
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO
  int R, G;
  cin >> R >> G;

  cout << 2 * G - R << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 3000

void swap(int *x,int *y);

int main(void)
{
	int x[N],y[N],count=0,i;
	
	while(1){
		scanf("%d %d",&x[count],&y[count]);
		count++;
		
		if(x[count-1]==0 && y[count-1]==0){
			break;
		}
	}
	
	for(i=0;i<count-1;i++){
		if(x[i]>y[i]){
			swap(x+i,y+i);
		}
		printf("%d %d\n",x[i],y[i]);
	}
	
	return 0;
}

void swap(int *x,int *y)
{
	int tmp;
	
	tmp=*x;
	*x=*y;
	*y=tmp;
}


Measured memory_bytes: 2060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int n,x;
	cin >> n >> x;
	vector<int> l(n);
	for(int i=0;i<n;i++)
		cin >> l[i];
	int now=0;
	int ans=1;
	for(int i=0;i<n;i++)
	{
		now+=l[i];
		if(now<=x)ans++;
	}

	cout << ans << endl;
		


	
}

Measured memory_bytes: 256
let n, s = Scanf.scanf " %d %s" @@ fun a b -> a, b
let ans = ref 0
let _ =
  for i = 1 to n - 1 do
    let c = ref 0 in
    for j = Char.code 'a' to Char.code 'z' do
      if String.contains (String.sub s 0 i) @@ Char.chr j && String.contains (String.sub s i @@ n - i) @@ Char.chr j then incr c done;
    ans := max !ans !c done;
  Printf.printf "%d\n" !ans

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

  
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
  	long A[N];
  	int idx = 0;
  	long total = 0;
  	long min_val = 1000000001;
  	int count = 0;
  	while(cin >> A[idx])
    {
      if(A[idx] < 0)
      {
        count++;
      }
      if(abs(A[idx]) < min_val) min_val = abs(A[idx]); 

      total += abs(A[idx]);
      idx++;
    }
  	
  	if(count % 2 == 0) cout << total << endl;
  	else cout << total - 2 * abs(min_val) << endl;
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
count_AC = 0
count_WA = 0
count_TLE = 0
count_RE = 0


for i in range(N):
    x = input()
    if x == "AC":
        count_AC += 1
    elif x == "WA":
        count_WA += 1
    elif x == "TLE":
        count_TLE += 1
    elif x ==  "RE":
        count_RE += 1

print("AC", "x", count_AC)
print("WA", "x", count_WA)
print("TLE", "x", count_TLE)
print("RE", "x", count_RE)

Measured memory_bytes: 9072
import numpy as np
from typing import List, Tuple

N = int(input())
X = list(map(int, input()))


def binary_mod(bits: List[int], div: int) -> int:
    if div == 0:
        return 0

    val = 0
    for b in bits:
        val = (val * 2 + b) % div
    return val


def f(x):
    cnt = 0
    while x > 0:
        x = x % bin(x).count('1')
        cnt += 1
    return cnt


popcount = sum(X)
div1 = popcount + 1
div2 = popcount - 1

if popcount == 0:
    print('\n'.join(map(str, [1] * N)))
else:
    rem1 = binary_mod(X, div1)
    rem2 = binary_mod(X, div2)

    for i in range(N):
        if X[i] == 0:
            r = (rem1 + pow(2, N - 1 - i, div1)) % div1
            print(f(r) + 1)
        else:
            if div2 > 0:
                r = (rem2 - pow(2, N - 1 - i, div2) + div2) % div2
                print(f(r) + 1)
            else:
                print(0)


Measured memory_bytes: 29052
import scala.math.BigDecimal
import scala.math.BigDecimal.RoundingMode
import scala.io.StdIn.readInt
object Main {
    def main(args: Array[String]): Unit = {
        println("0.00000000 0.00000000")
        koch(new Point(0.0, 0.0), 0, 100, readInt)
    }
    def koch(point: Point, angle: Int, len: Double, count: Int): Point = {
        if (count == 0) {
            val p = point.add(len * cos(angle), len * sin(angle))
            println(p)
            p
        } else {
            val nextLen = len / 3.0
            List(0, 60, 300, 360).foldLeft(point) { (p, a) =>
                koch(p, angle + a, nextLen, count - 1)
            }
        }
    }
    def cos(angle: Int) = Math.cos(Math.toRadians(angle % 360))
    def sin(angle: Int) = Math.sin(Math.toRadians(angle % 360))
}
case class Point(x: Double, y: Double) {
    override def toString(): String = {
        val a = "%.8f".format(BigDecimal(x).setScale(8, RoundingMode.HALF_UP))
        val b = "%.8f".format(BigDecimal(y).setScale(8, RoundingMode.HALF_UP))
        a + " " + b
    }
    def add(xx: Double, yy: Double): Point = new Point(x + xx, y + yy)
}


Measured memory_bytes: 74020
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt(), X = sc.nextInt();
    int N = 1 + (K - 1) + (K - 1);
    int F = X - K + 1;
    for (int i = 0; i < N; i++) System.out.println(F++);
  }
}

Measured memory_bytes: 22996
import java.util.Scanner;                                                   
import java.util.Arrays;
   
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
        while(true) {
            int x = scan.nextInt(), y = scan.nextInt();
            int[] data = {x, y};
            Arrays.sort(data);     
            if(x == 0 && y == 0) break;
            else {
                System.out.println(data[0] + " " + data[1]);
            } 
        } 
    } 
}

Measured memory_bytes: 36472
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll dp[11];

ll powll(ll x, ll y){
    if (y==0) return 1;
    else return x * powll(x, y-1);
}

int main() {
    string s;
    cin >> s;
    int n = s.length();
    VL a(n);
    REP(i,n) a[i] = s[i]-'0';

    FOR(i,1,n){
        ll x = 0;
        FOR(j,1,i){
            x += a[i-j]*powll(10,j-1);
            dp[i] += dp[i-j] + x*(1<<max(i-j-1,0));
        }
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i ++)
#define pb push_back
#define mp make_pair

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 2282282287;
const ll power = 49999;

/*
Нас по звукам узнавай:
Ня Кавай, Ня Кавай
Мы орем на весь трамвай:
Ня Кавай
Никогда не забывай:
Ня Кавай, Ня Кавай
Лучше к нам не приставай
Ня Кавай
*/

ll d, g;
ll p[17], c[17];
ll mins = mod;

void count(ll a)
{
	ll pco = 0;
	ll sco = 0;
	forn(i, 0, d)
	{
		if (a & (1 << i))
		{
			pco += c[i] + p[i] * (i+1) * 100;
			sco += p[i];
		}
	}
	if (pco >= g)
	{
		mins = min(mins, sco);
		return;
	}
	for (ll i = d - 1; i >= 0; i--)
	{
		if (!(a&(1 << i)))
		{
			ll f = (g - pco) / ((i + 1) * 100);
			ll s = (((g - pco) % ((i + 1) * 100)) > 0);
			ll adder = min(p[i], f + s);
			pco += adder * (i+1) * 100;
			sco += adder;
			break;
		}
	}
	if (pco >= g)
		mins = min(mins, sco);
}

int main()
{
	/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	*/
	cin >> d >> g;
	forn(i, 0, d)
		cin >> p[i] >> c[i];

	forn(i, 0, 1 << d)
	{
		count(i);
	}
	cout << mins;
	return 0;
}


Measured memory_bytes: 256
using System;

namespace ABC074B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            int med = K / 2;
            string[] bufs = Console.ReadLine().Split(' ');

            int res = 0;

            for (int i = 0; i < N; i++)
            {
                int pos = int.Parse(bufs[i]);
                if (pos <= med)
                {
                    res += pos << 1;
                }
                else
                {
                    res += (K - pos) << 1;
                }
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    ll n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin>>a[i];
        a[i]-=1;
    }
    vector<int> check(n,-1);
    int tmp=0;
    vector<int> v;
    int now=0;
    while(check[now]==-1){
        v.push_back(now);
        check[now]=tmp++;
        now=a[now];
    }
    int start=check[now];
    if(k<start) cout<<v[k]+1;
    else{
        k-=start;
        k%=v.size()-start;
        cout<<v[start+k]+1;
    }

    return 0;
}


Measured memory_bytes: 5852
#include <bits/stdc++.h>
#define _xx ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long LL;
const int mod=1e9+7;
const int MAXN=1e3+100;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<(min(a,b)+min(c,d))<<endl;
}


Measured memory_bytes: 256
// AOJ 1509 Rental DVD Shop NEO
// 2018.1.30 bal4u

#include <stdio.h>

#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int a, b, c, d, e, na, nb, nc, k, ans;
	
	while (a = in()) {
		b = in(), c = in(), d = in(), e = in();
		na = in(), nb = in(), nc = in();
		
		if (nc >= d) ans = e*nc + b*nb + a*na;
		else {
            ans = c*nc + b*nb + a*na;
			k = d-nc;
			if (k <= nb) nb -= k, k = 0;
			else         k -= nb, nb = 0;
			if (k <= na) na -= k;
			else         k -= na, na = 0;

			k = e*d + b*nb + a*na;
			if (ans > k) ans = k;
		}
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 2076
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = 10000000;
const long long INFL = (1LL<<50);
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}




int main() {
    ll n;cin>>n;
    vector<ll> v(3*n);cin>>v;
    ll presum=0;
    priority_queue<ll,vector<ll>,greater<ll>>pq1;
    for(auto i = 0;i<n;i++){
        pq1.push(v[i]);
        presum+=v[i];
    }
    ll aftsum=0;
    priority_queue<ll> pq2;
    for(auto i = 0;i<n;i++){
        pq2.push(v[3*n-i-1]);
        aftsum+=v[3*n-i-1];
    }
    map<ll,ll> p;
    p[n-1] = presum;
    repsg(k,n,2*n){
        if(pq1.top()< v[k]){presum+=-pq1.top()+v[k];pq1.pop();pq1.push(v[k]);}
        p[k] = presum;
    }
    
    map<ll,ll> q;
    q[2*n-1]=aftsum;
    
    for(auto k = 2*n-2;k>=n-1;k--){
        if(pq2.top()>v[k+1]){aftsum+=-pq2.top()+v[k+1];pq2.pop();pq2.push(v[k+1]);}
        q[k]=aftsum;
    }
    
    ll mx= - INFL;
    
    repsg(k,n-1,2*n){
//        cout<<p[k]<<" " << q[k]<<endl;
        mx = max(mx,p[k]-q[k]);
    }
    cout<<mx<<endl;
    
    
    
    return 0;
}












Measured memory_bytes: 16628
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b,c,d = f()
    if a+b == c+d:
        print('Balanced')
    elif a+b>c+d:
        print('Left')
    else:
        print('Right')

solve()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

vector<int> ans;

void dfs(vector<vector<pair<ll, ll>>> &g, int start, int color) {
    ans[start] = color;
    for (auto e : g[start]) {
        if (ans[e.first] == -1) {
            if (e.second % 2 == 0) {
                dfs(g, e.first, color);
            } else {
                dfs(g, e.first, 1 - color);
            }
        }
    }
}


int main() {
    int N;
    cin >> N;
    vector<vector<pair<ll, ll>>> graph(N);
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        graph[u - 1].push_back({v - 1, w});
        graph[v - 1].push_back({u - 1, w});
    }

    ans.assign(N, -1);
    dfs(graph, 0, 1);

    rep(i, N){
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 9600
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            string a,b,c;
            cin>>a>>b;
            int x,y;
            cin>>x>>y;
            cin>>c;
            if(a==c)
                --x;
            else
                --y;
            cout<<x<<" "<<y<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
#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;
    vector<int> a(N);
    rep(i,N) cin >> a.at(i);
    int cnt = 0;
    rep(i,N) if (a.at(i) == cnt + 1) ++cnt;
    if (cnt != 0) cout << N - cnt << endl;
    else cout << -1 << endl;
}


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

int main()
{
    int n,W;
    cin>>n>>W;
    int v[n],w[n];
    for(int i=0;i<n;i++)cin>>w[i]>>v[i];
    long long a[n][W+1];
    for(int i=0;i<W+1;i++)a[0][i]=(i<w[0])?0:v[0];
    for(int i=1;i<n;i++){
        for(int j=0;j<=W;j++){
             if(j<w[i])a[i][j]=a[i-1][j];
             else a[i][j]=(v[i]+a[i-1][j-w[i]])>a[i-1][j]?(v[i]+a[i-1][j-w[i]]):a[i-1][j];
        }
    }
   /*for(int i=0;i<n;i++){
        for(int j=0;j<=W;j++)cout<<a[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<a[n-1][W];
	return 0;
}

Measured memory_bytes: 78336
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i += 2) {
        cout << s[i];
    }
    cout << endl;

    return 0;
}

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

H,W = list(map(int,input().split()))
S = [ input().rstrip() for _ in range(H)] #マップの読み込み
dp = [[float('inf')]*W for _ in range(H)] #コスト
if S[0][0] == '#':#はじめが'#'なら1,else 0
    dp[0][0] = 1
else:
    dp[0][0] = 0

for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:#スタート地点は無視
            continue
        a = float('inf')
        b = float('inf')
        # S[i][j]にくるには i-1 かj-1からくるしかない
        if i >= 1:
            a = dp[i-1][j] + ( S[i-1][j] =='.' and S[i][j] =='#') #i-1からくる
        
        if j >= j:
            b=  dp[i][j-1] + ( S[i][j-1] =='.' and S[i][j] =='#') #j-1からくる

        dp[i][j] = min(a,b)#a,bの小さいほうが最小コスト
print(dp[i][j])


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

int sum_digit(int num){
	int sum = 0;
	while(num != 0){
		sum += num % 10;
		num = num / 10;
	}
	return sum;
}

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

	int min = 1000000;
	for(int i = 1;i<n;i++){
		int asum = sum_digit(i);
		int bsum = sum_digit(n-i);
		min = (asum + bsum) < min ? (asum+bsum) : min;
	}

	cout << min << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL<<60;

int main(){
    Int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k&1){
        cout << b-a << endl;
    }else{
        cout << a-b << endl;
    }
}

Measured memory_bytes: 256
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

LL a, b, c;

int main(int argc, char const *argv[]) {
    // code
    cin >> a >> b >> c;
    LL d = c - a - b;
    if (d <= 0) {
        puts("No");
        return 0;
    }

    LL x = a * b * 4, y = d * d;
    if (x < y)
        puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  long long ans=0;
  cin>>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  if(n<=k)cout<<0<<endl;
  
  else 
  {
    sort(a.begin(),a.end());
    for(int i=0;i<(n-k);i++)ans+=a[i];
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(){
  int N, M, i;
  cin >> N;
  M = N/1.08;
  M *= 1.08;
  if(M != N){
    M = N/1.08;
    M++;
    M *= 1.08;
    if(M != N){
      cout << ":(" << endl;
      return 0;
    } else{
       M /= 1.08;
       M++;
    }
  } else {
    M /= 1.08;
  }
  
  cout << M <<  endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

struct point
{
	double x, y;
	point(double x = 0, double y = 0) :x(x), y(y) {};
	
	point operator + (point p) { return point(x + p.x, y + p.y); }
	point operator - (point p) { return point(x - p.x, y - p.y); }
	point operator * (double s) { return point(x * s, y * s); }
	point operator / (double s) { return point(x / s, y / s); }

	double abs() { return sqrt(norm()); }
	double norm() { return x*x + y*y; }

	bool operator < (const point &p) const
	{
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const point &p) const
	{
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}

};
struct line
{
	point a, b;
	line(double x1 = 0, double y1 = 0, double x2 = 0, double y2 = 0) :a(point(x1, y1)), b(point(x2, y2)) {};

	point univec() { return (b - a) / (b-a).norm(); }
};

double dot(point a, point b)
{
	return a.x*b.x + a.y*b.y;
}

point project(line l, point p)
{
	point base = l.b - l.a;
	double r = dot(p - l.a, base) / base.norm();
	return l.a + base*r;
}

int main()
{
	double a[4];
	REP(i, 4) cin >> a[i];
	line l(a[0], a[1], a[2], a[3]);
	int q;
	cin >> q;
	while (q--)
	{
		int x, y;
		cin >> x >> y;
		point p(x, y);
		auto ans = project(l, p);
		cout << D10 << ans.x << " " << ans.y << endl;
	}
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    string dream = "dream";
    string dreamer = "dreamer";
    string erase = "erase";
    string eraser = "eraser";
    reverse(dream.begin(), dream.end());
    reverse(dreamer.begin(), dreamer.end());
    reverse(erase.begin(), erase.end());
    reverse(eraser.begin(), eraser.end());

    int i;
    for (i = 0; i < s.size(); i++) {
        if (dream == s.substr(i,5)) {
            i += 4;
            continue;
        }
        else if (dreamer == s.substr(i,7)) {
            i += 6;
            continue;
        }
        else if (erase == s.substr(i,5)) {
            i += 4;
            continue;
        }
        else if (eraser == s.substr(i,6)) {
            i += 5;
            continue;
        }
        else {
            break;
        }
    }

    if (i == s.size()) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3760
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  a =a*b;
  b =c*d;
  if(a>b){
    cout<<a<<endl;
    return 0;
  } else{
    cout<<b<<endl;
    return 0;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint A, B;
    cin >> A >> B;
    cout << ((A % 3 == 0|| B % 3 == 0 || (A + B) % 3 == 0) ? "Possible" : "Impossible") << "\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
		int N, K;
		cin >> N >> K;
		int A[N];
		for (int i = 0; i < N; i++) {
				cin >> A[i];
		}

		cout << ((N-1) + (K-1) - 1) / (K-1) << endl;
		return 0;
}


Measured memory_bytes: 640
#include <iostream>

int main()
{
	int N = 0;
	long long D = 0, X = 0, Y = 0;

	std::cin >> N >> D;

	int answer = 0;

	for (int count = 0; count < N; count++)
	{
		std::cin >> X >> Y;

		if (((X*X) + (Y*Y) - (D*D)) > 0)
		{
			continue;
		}

		++answer;
	}

	std::cout << answer << std::endl;
}


Measured memory_bytes: 3188
using System;

class weight
{
    public static void Main()
    {
        int a;
        int[] binary = new int[100];
        string s;
        while ((s = Console.ReadLine()) != null) 
        {
            a = int.Parse(s);
            for (int i=0 ;;i++)
            {
                if (a == 0) break;
                binary[i] = a % 2;
                a /= 2;
                if (binary[i] == 1)
                    if (a == 0) Console.Write(binary[i] * Math.Pow(2, i));
                    else Console.Write("{0} ", binary[i] * Math.Pow(2, i));
            }
            Console.Write("\n");
        }
    }
}

Measured memory_bytes: 9260
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
using namespace std;
struct ST_CITY {
	long lnInputNo;	// 入力時の順番
	long lnKenNo;
	long lnYear;
	char szNo[13];	// 認識番号
};
int cmpCity(const void* a, const void* b)
{
	ST_CITY* pa = (ST_CITY*)a;
	ST_CITY* pb = (ST_CITY*)b;
	long lnRet = 0;
	if (pa->lnKenNo == pb->lnKenNo)
		lnRet = pa->lnYear - pb->lnYear;
	else
		lnRet = pa->lnKenNo - pb->lnKenNo;
	return lnRet;
}
int cmpCityInit(const void* a, const void* b)
{
	ST_CITY* pa = (ST_CITY*)a;
	ST_CITY* pb = (ST_CITY*)b;
	return  pa->lnInputNo - pb->lnInputNo;
}

int main()
{
	int nCntKen, nCntAllCity;
	cin >> nCntKen >> nCntAllCity;

//	ST_CITY stCity[100000];
	ST_CITY* stCity = (ST_CITY*)malloc(sizeof(ST_CITY) * 100000);
	for (int i = 0; i < nCntAllCity; i++)
	{
		cin >> stCity[i].lnKenNo >> stCity[i].lnYear;
		stCity[i].lnInputNo = i;
	}

	// 県No、年の順に並べ替え
	qsort(stCity, nCntAllCity, sizeof(ST_CITY), cmpCity);

	long lnPrevKenNo = -1;
	long lnCityIndex = 0;
	for (int i = 0; i < nCntAllCity; i++)
	{
		if (lnPrevKenNo != stCity[i].lnKenNo)
		{
			lnPrevKenNo = stCity[i].lnKenNo;
			lnCityIndex = 1;
		}
		sprintf(stCity[i].szNo, "%06d%06d\n", stCity[i].lnKenNo, lnCityIndex);

		lnCityIndex++;
	}

	// 初回の入力順に並べ替え
	qsort(stCity, nCntAllCity, sizeof(ST_CITY), cmpCityInit);
	for (int i = 0; i < nCntAllCity; i++)
	{
		cout << stCity[i].szNo;
	}

	free(stCity);

	return 0;
}


Measured memory_bytes: 7012
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){

    string s;
    getline(cin,s);

    for(int i = 0; i < s.size(); i++){

        if('a' <= s[i] && s[i] <= 'z'){
            s[i] -= 'a'-'A';
        }
        else if('A' <= s[i] && s[i] <= 'Z'){
            s[i] += 'a' - 'A';
        }

        cout << s[i];

    }

    cout << endl;

}


Measured memory_bytes: 3192
#include "bits/stdc++.h"

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    vector<string> t(20);
    t[0] = "KIHBR";
    t[1] = "AKIHBR";
    t[2] = "KIHABR";
    t[3] = "KIHBAR";
    t[4] = "KIHBRA";
    t[5] = "AKIHABR";
    t[6] = "AKIHBAR";
    t[7] = "AKIHBRA";
    t[8] = "KIHABAR";
    t[9] = "KIHABRA";
    t[10] = "KIHBARA";
    t[11] = "AKIHABAR";
    t[12] = "AKIHABRA";
    t[13] = "AKIHBARA";
    t[14] = "KIHABARA";
    t[15] = "AKIHABARA";
    for (int i = 0; i < 16; ++i) {
        if (s == t[i]) {
            cout << "YES" << "\n";
            return 0;
        }
    }
    cout << "NO" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int a[25][25];
ll dp[2222222];

int main(void){
	int n,i,j,m;
	cin >> n;
	fill(dp,dp+2222222,0ll);
	dp[0] = 1ll;
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			cin >> a[i][j];
		}
	}
	for(i=0; i<(1<<n); ++i){
		m = 0;
		for(j=0; j<n; ++j){
			if(i&(1<<j)){
				++m;
			}
		}
		for(j=0; j<n; ++j){
			if(i&(1<<j)){
				continue;
			}
			if(a[m][j]){
				add_mod(dp[i+(1<<j)],dp[i]);
			}
		}
	}
	cout << (dp[(1<<n)-1]) << endl;
	return 0;
}


Measured memory_bytes: 17664
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n;
  cin>>n;
  ll a[n+1];
  rep(i,n)cin>>a[i];
  rep(i,n-1)a[i+1]+=a[i];
  a[n]=0;
  sort(a,a+n+1);
  ll ans=0;
  ll cnt=0;
  ll pos=longinf;
  rep(i,n+1){
    if(a[i]==pos)cnt++;
    else{
      ans+=cnt*(cnt-1)/2;
      cnt=1;
      pos=a[i];
      }
    }
  ans+=cnt*(cnt-1)/2;
  cout<<ans<<endl;
  return 0;
  }

Measured memory_bytes: 1792
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

class DSU {
public:
  int n;
  vector<int> p, ww;
  DSU(int _n) : n(_n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
    ww.resize(n);
    fill(ww.begin(), ww.end(), 1);
  }
  int root(int x) {
    return (p[x] == x ?  x : p[x] = root(p[x]));
  }
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x != y) {
      if(ww[x] > ww[y])
        swap(x, y);
      p[y] = x;
      ww[x] += ww[y];
      ww[y] = 0;
    }
  }
};

void solve() {
  int n, m;
  cin >> n >> m;
  DSU d(n);
  for(int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    d.unite(x, y);
  }
  int maxi = 0;
  for(int i = 0; i < n; i++) {
    maxi = max(maxi, d.ww[i]);
  }
  cout << maxi << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(10);
  int t = 1;
  //cin >> t;
  for(int tt = 1; tt <= t; tt++) {
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

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

s=[input() for _ in range(n)]
AC_a=0
WA_a=0
TLE_a=0
RE_a=0

for i in range(n):
    if s[i]=='AC':
        AC_a+=1
    elif s[i]=='WA':
        WA_a+=1
    elif s[i]=='TLE':
        TLE_a+=1
    elif s[i]=='RE':
        RE_a+=1
print('AC','x',AC_a)
print('WA','x',WA_a)
print('TLE','x',TLE_a)
print('RE','x',RE_a)

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

using namespace std;

int main(){
	while(true){
		int n;//競技者の数
		int m;//優勝した競技者の番号
		int p;//掛け金すべてプールされた後の控除率
		cin >> n >> m >> p;
		if(n==0 && m == 0 && p == 0){
			break;
		}
		int allcnt = 0;//投票したすべての枚数
		int viccnt = 0;//当選した枚数
		for(int i=0;i<n;i++){
			int num;//i+1番目の競技者にかけた人数
			cin >> num;
			allcnt += num;
			if(i+1 == m){
				viccnt += num;
			}
		}
		int result;
		if(viccnt == 0){
			result = 0;
		}else{
			int pool = 100 * allcnt * (100 - p) /100;//控除後のプールされたお金
			result = pool/viccnt;
		}
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main()
{
	int i,j,k=0,n;
	cin >> n;
	for(i=0;i*4<=n;i++)
	{
		for(j=0;j*7<=n;j++)
		{
			if(i*4+j*7==n)
			{
				k=1;
				break;
			}
		}
	}
	if(k)
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
	double vmin;
	while(cin >> vmin){
		int N=1;
		while(1){
			if(vmin*vmin < 2*9.8*(5*N-5)) break;
			N++;
		}
		cout << N << endl;
	}
	return 0;
}

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

int main()
{
    //("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n; cin>>n;
    long long int sum =0;
    for(long long int i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
        {
            continue;
        }
        sum = sum + i;

    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)998244353;
const ll HIGHINF = (ll)1e18;
ll MAX = 310000;

vll fac(MAX, 0), finv(MAX, 0), inv(MAX, 0);

ll initCombTable() {
  fac.at(0) = 1; fac.at(1) = 1;
  finv.at(0) = 1; finv.at(1) = 1;
  inv.at(1) = 1;
  rep(i, 2, MAX) {
    fac.at(i) = fac.at(i-1) * i % MOD;
    inv.at(i) = MOD - inv.at(MOD%i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i-1) * inv.at(i) % MOD;
  }
}

ll nCk(ll n, ll k) {
  if (n < 0 || k < 0 || n < k) return 0;
  return fac.at(n) * (finv.at(k) * finv.at(n-k)%MOD) % MOD;
}

int main() {
  initCombTable();
  ll n, a, b, k; cin >> n >> a >> b >> k;
  ll ans = 0;
  REP(i, n+1) {  // i: aで塗る個数
    ll rc = i;
    if ((k-rc*a)%b != 0) continue;
    ll bc = (k-rc*a)/b;
    ans += (nCk(n, rc) * nCk(n, bc)) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string A;
  cin >> A;

  vll z(26, 0);
  REP(i, A.size()){
    z[A[i]-'a']++;
  }

  ll ans = (A.size()*(A.size()-1))/2;
  REP(i, 26){
    ans -= (z[i]*(z[i]-1))/2;
  }

  cout << ans+1 << "\n";

  return 0;
}

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


template<typename T>
struct BIT{
    int n;
    vector<T> d;
    BIT(int n = 0):n(n),d(n+1){}
    void add(int i,T x=1){
        for(i++;i<=n;i += i&-i){
            d[i] += x;
        }
    }
    T sum(int i){
        T x = 0;
        for(i++;i;i -= i&-i){
            x += d[i];
        }
        return x;
    }
};

int main(){
    int n,q;cin >> n >> q;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> pi(n+1,-1);
    vector<vector<int>> ps(n);
    rep(i,n){
        int l = pi[a[i]];
        if(l != -1) ps[l].push_back(i);
        pi[a[i]] = i;
    }

    vector<vector<P>> qs(n);
    rep(i,q){
        int l,r;cin >> l >> r;
        --l; --r;
        qs[l].emplace_back(r,i);
    }

    vector<int> ans(q);
    BIT<int> d(n);
    for(int x = n-1;x>=0;--x){
        for(int y:ps[x]) d.add(y,1);
        for(P p:qs[x]){
            ans[p.second] = (p.first-x+1) - d.sum(p.first);
        }
    }

    rep(i,q) cout << ans[i] << endl;

    
 }

Measured memory_bytes: 59940
// noobie_corleone
#include <bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   1000000007
#define eps                   0.000000000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
//vector<int> adj[200010];
//vector<int> value(200010),par(200010),vis(200010,0),fi(200010,0),g(200010,0),col(200010,-1);
int myrandom (int i) { return std::rand()%i;}

int main()
{
	int n,k;
	cin>>n>>k;
	vector<ll> h(n+1);
	fr(i,1,n+1)
	{
		cin>>h[i];
	}
	vector<ll> dp(n+1,inf);
	dp[1]=0;
	fr(i,2,n+1)
	{
		ll a = max((int)i-k, 1);
		for(ll j=i-1;j>=a;j--)
		{
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

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


    if( B-A <= 0 ) cout << "delicious" << endl;
    else if( X < B-A ) cout << "dangerous" << endl;
    else cout << "safe" << endl;


    return 0;
}


Measured memory_bytes: 256
import heapq
import itertools

def solve():
    N, M, _ = list(map(int, input().split()))
    R = list(map(int, input().split()))
    R = map(lambda x: x-1, R)
    G = [[] for i in range(N)]

    for i in range(M):
        A, B, C = list(map(int, input().split()))
        A -= 1
        B -= 1
        G[A].append((C, B))
        G[B].append((C, A))


    def dijkstra(d):
        que = []

        tar = -1
        for i in range(len(d)):
            if d[i] == -1:
                break
            if d[i] == 0:
                tar = i
            heapq.heappush(que, (d[i], i))

        while len(que) != 0:
            dist, node = heapq.heappop(que)
            for (cost, to) in G[node]:
                if d[to] > d[node] + cost:
                    d[to] = d[node] + cost
                    heapq.heappush(que, (dist + cost, to))

        return d


    ds = [[1e16 for i in range(N)] for j in range(N)]

    for i in range(N):
        ds[i][i] = 0

    for i in range(N):
        ds[i] = dijkstra(ds[i])
        for j in range(N):
            ds[j][i] = ds[i][j]

    res = 1e16
    for r in list(itertools.permutations(R)):
        d = 0
        for i in range(len(r)-1):
            d += ds[r[i]][r[i+1]]
        res = min(res, d)

    return res

print(solve())

Measured memory_bytes: 83160
n=int(input())
w=[input() for i in range(n)]
if len(w)!=len(set(w)):
    print('No')
else:
    ans=0
    for j in range(n-1):
        if w[j][-1]==w[j+1][0]:
            ans+=1
    if ans==n-1:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define per(i,n) for (int i = (n)-1; i >=0; --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    int k,s;
    cin>>k>>s;
    int ans = 0;
    for(int x=0; x<=min(s,k); x++){
        for(int y=0; y<=min(s-x,k); y++){
            if(s-x-y<=k)ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll X;


int main(){
	cin>>X;
	ll res = 0;
	res += (X / 500) * 1000;
	X = X % 500;
	res += (X / 5) * 5;
	cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
def cmb(n,r,mod):
    if r<0 or r>n:return 0
    return g1[r]*g2[r]%mod


mod=10**9+7
n,a,b=map(int,input().split())
k=max(a,b)
g1=[1,n]
g2=[1,1]
inverse=[0,1]

for i,j in enumerate(range(n-1,((n-k+1)-1),-1)):
    i=i+2
    g1.append((g1[-1]*j)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1]%mod))

N=pow(2,n,mod)-1
print((N-cmb(n,b,mod)-cmb(n,a,mod))%mod)

Measured memory_bytes: 27016