akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int N, M, nr;
long long ans[100009], q[100009], coef[100009];

void add (long long qnt, long long l)
{
    if (l <= q[1])
    {
        ans[l] += qnt;
        return ;
    }
    int p = 1, u = nr, mij, ras = 0;
    while (p <= u)
    {
        mij = (p + u) >> 1;
        if (q[mij] <= l) ras = mij, p = mij + 1;
        else u = mij - 1;
    }
    long long c = l / q[ras], r = l % q[ras];
    coef[ras] += 1LL * qnt * c, add (qnt, r);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M), nr = 1, q[1] = N;
while (M --)
{
    long long x;
    scanf ("%lld", &x);
    while (nr > 0 && q[nr] >= x)
        nr --;
    q[++nr] = x;
}
coef[nr] = 1;
for (int i=nr; i>1; i--)
{
    long long c = q[i] / q[i - 1], r = q[i] % q[i - 1];
    coef[i - 1] += 1LL * c * coef[i];
    add (coef[i], r);
}
ans[q[1]] += coef[1];
for (int i=q[1]; i>=1; i--)
    ans[i - 1] += ans[i];
for (int i=1; i<=N; i++)
    if (i <= q[1]) printf ("%lld\n", ans[i]);
    else printf ("0\n");
return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin >> n >> m;
	vector<int> p(100010);
	vector<string> s(100010);
	if(m==0){
	    cout << 0 << " " << 0;
	}
	else{
	for (int i = 0; i < m; ++i){
		cin >> p.at(i) >> s.at(i);
	}
	vector<int> a(n+1);
	vector<int> w(n+1);
	for (int i = 0; i < m; ++i)
	{
		if(s.at(i)=="AC"){
			if(a.at(p.at(i))!=0){
				a.at(p.at(i))=a.at(p.at(i));
			}
			else{
				a.at(p.at(i))++;
			}
			
		}
		else{
			if(a.at(p.at(i))==0){
				w.at(p.at(i))++;
			}
			else{
				w.at(p.at(i))=w.at(p.at(i));
			}
		}
	}

	int acount=0;
	int sum=0;
	for (int i = 0; i < n+1; ++i)
	{
		if(a.at(i)!=0){
			acount++;
			sum = sum + w.at(i);
		}

	}
	
	cout << acount << " " << sum << endl;
}
		
	}

Measured memory_bytes: 6912
import java.util.ArrayList;
import java.util.*;
 class Main
{
	public static void main (String[] args)
	 {
		Scanner sc=new Scanner(System.in); 
		int i,j;
		int n=sc.nextInt();
		int m=sc.nextInt();
		HashMap<Integer,Integer> h=new HashMap();
		HashMap<Integer,Integer> v=new HashMap();
		for(i=1;i<=n;i++)
		{
			h.put(i, sc.nextInt());
			v.put(i,1);
		}
		
		int in,og;
		for(i=0;i<m;i++)
		{
			in=sc.nextInt();
			og=sc.nextInt();
			
		 if(h.get(in)>=h.get(og))
			{
				v.put(og, -1);
			}
			if(h.get(in)<=h.get(og))
			{
				v.put(in,-1);
			}
		}
		int count=0;
		for(i=1;i<=n;i++)
		{
			if(v.get(i)!=-1)
				count++;
		}
		
		
			
		System.out.println(count);
		
			
	}
}

Measured memory_bytes: 82596
import java.util.LinkedList;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		String field[][]=
			{
				{"A","B","C"},
				{"D","E","F"},
				{"G","H","I"}	
			};
		int dx[]={1,0,0,-1};
		int dy[]={0,1,-1,0};
		for(;;)
		{
			int n=in.nextInt();//battery
			if(n==0)
				return;
			String te=in.nextLine();
			String str[]=in.nextLine().split(" ");
			String s=str[0];//start
			String t=str[1];//charge
			String b=str[2];//no-enter
			double ans=1;
			int sh=-1,sw=-1;
			int th=-1,tw=-1;
			double dp[][][]=new double[n+1][3][3];
			for(int i=0;i<3;i++)
				for(int j=0;j<3;j++)
				{
					if(s.equals(field[i][j]))
					{
						sh=i;
						sw=j;
					}
					if(t.equals(field[i][j]))
					{
						th=i;
						tw=j;
					}
				}
			dp[n][sh][sw]=1;
			for(int i=n-1;i>=0;i--)
				for(int j=0;j<3;j++)
					for(int k=0;k<3;k++)	
						for(int l=0;l<4;l++)
						{
							int h=j+dy[l];
							int w=k+dx[l];
							if(0<=h&&h<3&&0<=w&&w<3&&!field[h][w].equals(b))
								dp[i][h][w]+=dp[i+1][j][k]/4;
							else
								dp[i][j][k]+=dp[i+1][j][k]/4;
						}
			System.out.printf("%.8f\n",dp[0][th][tw]);
		}
	}
}

Measured memory_bytes: 12000
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        List<Integer> m = new ArrayList<>();
        IntStream.range(0, n).forEach(i -> m.add(sc.nextInt()));

        int count = 0;
        for (int i = 0; i < n; i++) {
            if (x < m.get(i)) {
                System.out.println(count);
                return;
            }
            x -= m.get(i);
            count++;
        }
        Optional<Integer> min = m.stream().min(Integer::compareTo);
        System.out.println(count + (x / min.get()));
    }

}


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

int main(){
  int x;
  cin>>x;
  int k;
  int pmin=131072;
  for (int i=x;i<131072;i++){
    for (int j=2;j<400;j++){
      if(i%j==0&&i!=j){
        k=j;
        break;
      }
      if(i%j!=0){
        k=j;
        continue;
      }
    }
    if(i%k!=0){
    int p=i;
    if(pmin>p) pmin=p;
    }
  }
  cout <<pmin<<endl;
}
  

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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int s, w;
    cin >> s >> w;

    if(s <= w)
        cout << "unsafe";
    else
        cout << "safe";
    cout << "\n";
    return 0;

}


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

int main() {
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> A(N);
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        for (int j = 0; j < a; j++) {
            int x, y; cin >> x >> y; x--; 
            if (y == 0) { y = -1; } 
            A[i].emplace_back(x, y);
        }
    }
    
    int ans = 0;
    
    for (long long bit = 0; bit < (1<<N); bit++) {
        vector<bool> say(N);
        int res = 0;
        for (long long i = 0; i < N; i++) {
            if (bit & (1<<i)) {
                say[i] = true;
                res++;
            } else {
                say[i] = false;
            }
        }
        
        bool ok = true;
        for (int i = 0; i < N; i++) {
            if (say[i] == false) continue;
            for (int j = 0; j < A[i].size(); j++) {
                int x, y; tie(x, y) = A[i][j];
                if (say[x] == true && y == -1) ok = false;
                if (say[x] == false && y == 1) ok = false;
            }
        }
        if (ok == true) ans = max(ans, res);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
k = int(input())
from collections import deque
dic = {1:1}
queue = deque([[1,1]])
while queue:
    v,cost = queue.popleft()
    if not (v+1)%k in dic or cost+1<dic[(v+1)%k]:
        dic[(v+1)%k] = cost+1
        queue.appendleft([(v+1)%k,cost+1])
    if not v*10%k in dic or cost<dic[v*10%k]:
        dic[v*10%k] = cost
        queue.append([v*10%k,cost])

print(dic[0])

Measured memory_bytes: 21692
### constant

UOPS = {'-' => [2, 1, 0]}

BOPS = {
  '*' => [[0, 0, 0], [0, 1, 1], [0, 1, 2]],
  '+' => [[0, 1, 2], [1, 1, 2], [2, 2, 2]]
}

VARNAME = 'PQR'

### subroutines
#<fml> := '0'-'2' | '-'<fml> | '('<fml>'*'<fml>')' | '('<fml>'+'<fml>')'

def formula(fml)
  chpos = fml[$pos]
  $pos += 1
  val = nil

  case chpos
  when '0'..'2'
    val = chpos.to_i
  when '-'
    v0 = formula(fml)
    val = UOPS[chpos][v0]
  else
    v0 = formula(fml)
    op = fml[$pos]
    $pos += 1
    v1 = formula(fml)
    $pos += 1
    #p [v0, op, v1]
    val = BOPS[op][v0][v1]
  end

  val
end

### main

loop do
  fml = gets.strip
  break if fml == '.'

  count = 0
  vvals = [0, 0, 0]

  loop do
    fml0 = fml.clone.tr(VARNAME, vvals.join(''))
    $pos = 0
    val = formula(fml0)
    count += 1 if val == 2

    k = 0
    while k < 3
      vvals[k] += 1
      break if vvals[k] <= 2
      vvals[k] = 0
      k += 1
    end
    break if k >= 3
  end

  puts count
end

Measured memory_bytes: 6120
#include <iostream>
#include <algorithm>
int W =0, H = 0, N = 0;
int main(void){
    std::cin >> W >> H >> N;
    int x,y,z;
    int a = 0, b = 0, c = W, d = H;
    for(int i=0; i<N; ++i){
        std::cin >> x >> y >> z;
        if(z == 1)      a = std::max(a, x);
        else if(z == 2) c = std::min(c, x);
        else if(z == 3) b = std::max(b, y);
        else if(z == 4) d = std::min(d, y);
    }
    if(c<a || d<b) std::cout << 0 << std::endl;
    else           std::cout << (c-a)*(d-b) << std::endl;
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    string s = to_string(n);
    int sum = 0;
    for (int i = 0; i < s.size(); i++) {
        sum += s[i] - '0';
    }
    if (n % sum == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, m, tot = 0;
	cin >> n >> m;
	vector<int> a(n);
	rep(snip_i, n){
		cin >> a.at(snip_i);
		tot += a.at(snip_i);
	}
	sort(a.begin(), a.end(), greater<int>());
	rep(i, m){
		if((double)a.at(i) < (double)tot/(4*m)){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll A;
long double B;

int main(){
    cin >> A >> B;
    long double C = B * A;
    cout << fixed << setprecision(0) << floor(C) << endl;
    return 0;
}

Measured memory_bytes: 3796
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc063.contest.atcoder.jp/tasks/arc063_b>
問題文============================================================
 N 個の町が一直線上に並んでいます。
 行商人の高橋君は町 1 から出発し、リンゴの売買をしながら町 N へと向かいます。
 
 はじめ高橋君は町 1 におり、リンゴを 1 つも持っていません。
 高橋君は次のいずれかの行動を繰り返し行います。
 
 移動: 町 i (i<N) にいるとき、町 i+1 へ移動する。
 リンゴの売買: リンゴを好きな個数だけ売買する。
 ここで、町 i (1≦i≦N) ではリンゴの買値も売値もともに Ai 円とする。ここで Ai は相異なる整数です。
 1 つの町で売買するリンゴの個数に制限はありませんが、
 旅の中で売買するリンゴの個数は合計で (買う個数と売る個数を合わせて) T 個以下にしなくてはなりません。
 
 高橋君は旅の利益、すなわちリンゴを売った代金から買った代金を引いた値を最大にするように旅をするとします。
 旅が終わったときに持っていたリンゴの価値は考えず、旅の中で売買した金額だけを考えます。
 
 この旅に先立って、
 青木君は任意の町 i に対して Ai を好きな非負整数 Ai' に変えるという操作を好きなだけ行うことができます。
 ただし、この操作は行うごとに |Ai−Ai'| のコストがかかります。
 操作後には異なる町の間でリンゴの値段が同じになっていても構いません。
 
 青木君の目的はできるだけ少ない合計コストの操作で高橋君の利益を少なくとも 1 円下げることです。
 合計コストの最小値を求めてください。
 
 ただし、元の状態で高橋君が 1 円以上の利益を上げられることは仮定して構いません。
 

=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,T; cin >> N >> T;
    vector<ll> A(N);
    for(auto &in:A) cin >> in;
    ll minv = A[0], maxdiff = -LINF;
    for(int i = 0; i < N;i++){
        minv = min(A[i],minv);
        maxdiff = max(maxdiff,A[i] - minv);
    }
    
    ll maxdiff_cnt = 0;
    minv = A[0];
    for(int i = 0; i < N;i++){
        minv = min(A[i],minv);
        if(A[i] - minv == maxdiff) maxdiff_cnt++;
    }
    cout << maxdiff_cnt << endl;
	return 0;
}


Measured memory_bytes: 1024
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}



int main(){
    ll x,n=1;
    cin>>x;
    while(n*(n+1)/2<x) n++;
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n>>m>>k;

    l(i,0,10)
    {
      x=n*k-m;
      cout<<x<<endl;
      k=x;
    }






}











Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

template <typename T>
struct Graph {
    int V, E;
    struct Edge {
        int from, to;
        T cost;
    };
    vector<vector<Edge>> edge;
    vector<vector<T>> dist;
    vector<Edge> es;

    Graph(int V, int E) : V(V), E(E) {
        edge.assign(V, vector<Edge>(0));
        dist.assign(V, vector<T>(0));
    }

    void input(bool is_direct, bool inputc, bool index0 = false) {
        int a, b;
        T c = 0;
        for (int i = 0; i < E; i++) {
            cin >> a >> b;
            if (inputc) cin >> c;
            if (!index0) a--, b--;
            edge[a].push_back((Edge){a, b, c});
            es.push_back((Edge){a, b, c});
            if (!is_direct) {
                edge[b].push_back((Edge){b, a, c});
                es.push_back((Edge){b, a, c});
            }
        }
        if (!is_direct) E *= 2;
    }

    void add_edge(int from, int to, T cost, bool is_direct) {
        edge[from].push_back({from, to, cost});
        es.push_back({from, to, cost});
        if (!is_direct) {
            edge[to].push_back({to, from, cost});
            es.push_back({to, from, cost});
            E++;
        }
        E++;
    }

    vector<int> ans;
    void bfs(int r = 0) {
        ans.resize(V, V + 10);
        vector<bool> visited(V, false);
        queue<int> q;
        q.push(r);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            if (visited[v]) continue;
            visited[v] = true;
            for (const auto& e : edge[v]) {
                if (ans[e.to] == V + 10) ans[e.to] = v;
                q.push(e.to);
            }
        }
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    Graph<int> g(N, M);
    g.input(false, false);
    g.bfs();
    cout << "Yes" << endl;
    for (int i = 1; i < N; i++) cout << g.ans[i] + 1 << endl;
    return 0;
}

Measured memory_bytes: 21436
s=input()
a=s.count('a')
b=s.count('b')
c=s.count('c')
if len(set(list(s)))==1 and len(s)>1:
  print('NO')
elif len(set(list(s)))==2 and len(s)>2:
  print('NO')
elif abs(a-b)<=1 and abs(b-c)<=1 and abs(c-a)<=1:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  map<pair<int, int>, int> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int p = x[i] - x[j];
      int q = y[i] - y[j];
      if (p != 0 || q != 0) {
        m[make_pair(p, q)] += 1;
      }
    }
  }
  int cnt = -1;
  for (auto i = m.begin(); i != m.end(); i++) {
    if (cnt < i->second) {
      cnt = i->second;
    }
  }
  int ans = n - cnt;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

a, b, c, k = Is()
if a >= k:
    print(k)
elif a + b >= k:
    print(a)
else:
    print(a-k+a+b)


Measured memory_bytes: 72456
def read_input():
    s = input()
    return s

def check_even_string(s):
    if len(s) % 2:
        return False

    mid = len(s)//2
    if s[:mid] == s[mid:]:
        return True

    return False


def submit():
    s = read_input()

    for i in range(1, len(s)):
        if check_even_string(s[:-i]):
            print(len(s[:-i]))
            return

if __name__ == '__main__':
    submit()

Measured memory_bytes: 3060
"""
AtCoder Educational DP Contest
https://atcoder.jp/contests/dp/tasks/dp_k

K - Stones
"""
import collections

def solve(xs):
    dp = collections.defaultdict(bool)
    dp[0] = False

    for j in range(1, K + 1):
        iterable = ((j >= x) and (not dp[j - x]) for x in xs)
        dp[j] = any(iterable)
    return dp[K]

N, K = map(int, input().split())
choices = collections.Counter([float(s) for s in input().split()])
assert len(choices) == N
res = solve(choices)
print("First" if res else "Second")


Measured memory_bytes: 60508
while as = gets
   as = as.split.map(&:to_i)
   bs = gets.split.map(&:to_i)
   hit,blow = 0,0
   as.each_with_index do|a,i|
        bs.each_with_index do|b,j|
         if a == b
            if i == j
               hit += 1
            else
               blow += 1
            end
         end
      end
   end
   print "%d %d\n" % [hit,blow]
end


Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, k;
double ans;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 1, n+1){
    double d = 1.0;
    int j = i;
    while(j < k){
      j <<= 1;
      d /= 2;
    }
    ans += d;
  }
  ans /= n;
  dout(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}



int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<vector<P>> g(n);
    rep(i,n-1) {
        int a,b; cin>>a>>b;
        --a,--b;
        g[a].emplace_back(b,i);
        g[b].emplace_back(a,i);
    }

    vector<int> ans(n-1);
    auto dfs = [&](auto &&f, int x, int par, int pc) -> void {
        int col = 1;
        for (auto &&e: g[x]) {
            if (e.first==par) continue;
            col += (pc==col);
            ans[e.second] = col;
            f(f,e.first,x,col);
            ++col;
        }
    };

    dfs(dfs,0,-1,-1);
    cout << *max_element(ans.begin(), ans.end()) << endl;
    rep(i,n-1) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 8320
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] A = nextIntArray(sc, N);
		int[] B = nextIntArray(sc, N);
		int[] C = nextIntArray(sc, N);

		sc.close();

		Arrays.sort(A);
		Arrays.sort(B);
		Arrays.sort(C);

		long ans = 0;

		//解説の方法
//		for(int i=0;i<N;i++) { //Bについて
//			int ai = upperBound(A, 0, A.length, B[i]-1);
//			long an = ai;
//			
//			int ci = upperBound(C, 0, C.length, B[i]);
//			long cn = N-ci;
//			
//			ans += an*cn;
//		}

		
		// Bを選んだ時に、選ぶことのできるCの数をあらかじめ数える
		long[] B2 = new long[N];
		for(int i=0;i<N;i++) {
			int ci = upperBound(C, 0, C.length, B[i]);
			B2[i] = N-ci;
		}
		
		// Bを決めたときにそれ以降のすべてのBについてのCとの組み合わせの数
		long[] B3 = new long[N];
		B3[N-1] = B2[N-1];
		for(int i=N-2;i>=0;i--) {
			B3[i] = B3[i+1] + B2[i];
		}
		
		// Aについて順番にためす
		for (int i = 0; i < N; i++) {
			int bi = upperBound(B, 0, B.length, A[i]);

			if(bi<N) {
				ans += B3[bi];
			}
		}

		out.println(ans);

	}

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

	private static int upperBound(int[] a, int st, int ed, int k) {
		if (st == ed - 1) {
			if (a[st] <= k) {
				return st + 1;
			} else {
				return st;
			}
		}

		int m = (ed - st) / 2 + st;
		if (a[m] <= k) {
			//右側
			return upperBound(a, m, ed, k);
		} else {
			//左側
			return upperBound(a, st, m, k);
		}

	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 94608
S=input()
T=input()
max_match=0

for i in range(1+len(S)-len(T)):
    count=0
    for j in range(len(T)):
        if S[i+j]==T[j]:
            count+=1
    if max_match <=count:
        max_match=count
print(len(T)-max_match)

Measured memory_bytes: 9016
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail
{
  template <typename T, std::size_t NDIMS>
  struct vector_builder
  {
    using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
      if (!dims.empty())
        dims.pop_back();
      return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
    }
  };

  template <typename T>
  struct vector_builder<T, 1>
  {
    using type = std::vector<T>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      return type(dims.empty() ? 0 : dims.back(), v);
    }
  };
} // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T &v, SIZE_T... dims)
{
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

const string YES = "Yes";
const string NO = "No";

void solve(long long N)
{
  cout << ((
               N / 100 % 10 == 7 || N / 10 % 10 == 7 || N % 10 == 7

               )
               ? YES
               : NO)
       << endl;
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int* A = (int*)malloc(N*sizeof(int));
    int v,j;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    for(int k=0;k<N;k++){
        if(k<N-1){
            cout<<A[k]<<" ";
        }
        else{
            cout<<A[k]<<endl;
        }
    }

    for(int i=1;i<N;i++){
        v=A[i];
        j=i-1;
        while(j>=0 and A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;

        for(int k=0;k<N;k++){
            if(k<N-1){
                cout<<A[k]<<" ";
            }
            else{
                cout<<A[k]<<endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

ll row,pathlength;
ll adjacency[51][51];
ll temp[51][51];
ll result[51][51];

void resultiply()
{
    ll store;
    for(ll i=0;i<row;i++)
    {
        for(ll j=0;j<row;j++)
        {
            temp[i][j]=0;
            for(ll k=0;k<row;k++)
            {
                store=(result[i][k]*adjacency[k][j]);
                if(store>=MOD)
                {
                    store=store%MOD;
                }
                temp[i][j]=(temp[i][j]+store);
                if(temp[i][j]>=MOD)
                {
                    temp[i][j]-=MOD;
                }
            }
        }
    }
    for(ll i=0;i<row;i++)
    {
        for(ll j=0;j<row;j++)
        {
            result[i][j]=temp[i][j];
        }
    }
}

void basemultiply()
{
    ll store;
    for(ll i=0;i<row;i++)
    {
        for(ll j=0;j<row;j++)
        {
            temp[i][j]=0;
            for(ll k=0;k<row;k++)
            {
                store=(adjacency[i][k]*adjacency[k][j]);
                if(store>=MOD)
                {
                    store=store%MOD;
                }
                temp[i][j]=(temp[i][j]+store);
                if(temp[i][j]>=MOD)
                {
                    temp[i][j]-=MOD;
                }
            }
        }
    }
    for(ll i=0;i<row;i++)
    {
        for(ll j=0;j<row;j++)
        {
            adjacency[i][j]=temp[i][j];
        }
    }
}

void matrixexpo()
{
    while(pathlength)
    {
        if(pathlength&1)
        {
            resultiply();
        }
        basemultiply();
        pathlength>>=1;
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin>>row>>pathlength;
    for(ll i=0;i<row;i++)
    {
        for(ll j=0;j<row;j++)    
        {
            cin>>adjacency[i][j];
            result[i][j]=0;
        }
        result[i][i]=1;
    }
    matrixexpo();
    ll ans=0;
    for(ll i=0;i<row;i++)
    {
        for(ll j=0;j<row;j++)
        {
            ans=(ans+result[i][j])%MOD;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
const double PI = acos(-1);
typedef long long ll;

int main() {
  int N;
  cin>>N;
  cout<<pow(N,3)<<endl;
}



Measured memory_bytes: 512
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let abc = lines.next().unwrap().unwrap();
    let mut abc = abc.split_whitespace();
    let a: i32 = abc.next().unwrap().parse().unwrap();
    let b: i32 = abc.next().unwrap().parse().unwrap();
    let c: i32 = abc.next().unwrap().parse().unwrap();

    let ans = if a == b && c != a || a == c && b != a || b == c && a != b {
        "Yes"
    } else {
        "No"
    };

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


Measured memory_bytes: 4352
#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")
#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<ll,ll>;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define debug(x) cerr << #x << ": " << x << "\n"//手動デバッグ
#define YES(c) cout<<((c)?"YES\n":"NO\n"),0
#define Yes(c) cout<<((c)?"Yes\n":"No\n"),0
#define O(p) cout<<p<<"\n",0
#define OS(p) cout<<p<<" ",0
#define ON(p) cout<<p,0
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define endl "\n"//endlを置き換える
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定

const int dy[4]={1,0,-1,0};
const int dx[4]={0,1,0,-1};//^>v<

template<class T=int> T in(){
    T x;
    cin>>x;
    return (x);
}
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
//------------------------------------------------------------




//------------------------------------------------------------
int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
//------------------------------------------------------------
    int n=in();
    vector<vector<vector<int>>> V(4,vector<vector<int>>(3,vector<int>(10,0)));
    rep(i,n){
        int a,b,c,d;cin>>a>>b>>c>>d;
        V[a-1][b-1][c-1]+=d;
    }
    rep(i,4){
        rep(j,3){
            rep(k,10){
                cout<<" "<<V[i][j][k];
            }
            cout<<endl;
        }
        rep(s,20){
            if(i!=3){
                ON("#");
            }
        }
        if(i!=3){
            cout<<endl;
        }
    }
    
    
    
    
    
    
    
    
    
    
    
//------------------------------------------------------------
	return 0;
}



Measured memory_bytes: 3104
#include <stdio.h>
#define BUFMAX 5

int main(){
    char buf[BUFMAX];
    char week[7][4] = {"sun","mon","tue","wed","thu","fri","sat"};
    int day;

    fgets(buf,BUFMAX,stdin);
    buf[BUFMAX-1] = '\0';
    sscanf(buf,"%d", &day);
    day += 4;
    if(day > 6){
      day = day % 7;
    }
    printf("%s\n", week[day]);
    return 0;
}



Measured memory_bytes: 2140
#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
#include <utility>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)


int main(){
    long long N,A,B,tmp;
    cin >> N >> A >> B;
    tmp =N/(A+B);
    if(N%(A+B) <= A){

       cout << tmp*A +N%(A+B) <<endl;
       return 0;
    }
    cout << tmp*A +A <<endl;
    return 0;
}

    


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int 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;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

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

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

// index が条件を満たすかどうか

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> s(60);
	vector<pair<int, int>> t;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		s[a].push_back(b);
		s[b].push_back(a);
		t.push_back(make_pair(a, b));
	}
	int ans = 0;
	for (int i = 0; i < t.size(); i++) {
		int a, b;
		a = t[i].first;
		b = t[i].second;
		int seen[60] = {};
		queue<int> q;
		q.push(1);
		seen[1] = 1;
		while (q.size() != 0) {
			int serch = q.front();
			q.pop();
			for (int j : s[serch]) {
				if ((seen[j] == 0) && !((serch == a && j == b) || (serch == b && j == a))) {
					q.push(j);
					seen[j] = 1;
				}
			}
		}
		for (int i = 1; i <= n; i++) {
			if (seen[i] == 0) {
				ans++;
				break;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int n,m,A,B;
ll f[200005],inv[200005];
ll quick_pow(ll a,ll b){
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1) ans=ans*a%mod;
	return ans;
}
ll C(int n,int m){
	return f[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	scanf("%d%d%d%d",&n,&m,&A,&B);
	n--;m--;
	f[0]=inv[0]=1;
	for(int i=1;i<=200002;i++) f[i]=f[i-1]*i%mod,inv[i]=quick_pow(f[i],mod-2);
	ll ans=C(n+m,n);
	for(int i=1;i<=B;i++) ans=(ans-C(n-A+i-1,i-1)*C(A+m-i,m-i+1))%mod;
	ans=(ans+mod)%mod;
	printf("%lld",ans);
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int>x(n);
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>x[i];
    if(i%2==0&&x[i]%2!=0){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
/* ****Ragnar7 _Lawliet_**** */
/* First, solve the problem.Then write the code. */
#include<bits/stdc++.h>
#define ll          long long
#define ld 			long double
#define hell        1000000007
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen ("input.txt","r",stdin);
	// freopen ("output.txt","w",stdout);
	#endif
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		string s,t;
		cin>>s>>t;
		ll n = s.size();
		ll m = t.size();
		ll ans = hell;
		for(ll i=0;i<=n-m;i++)
		{
			ll cnt = 0;
			for(ll j=i;j<i+m;j++)
				if(s[j]!=t[j-i])
					cnt++;
			ans=min(ans,cnt);
		}
		cout<<ans;
		
	}

	
	time
	return 0;
}

Measured memory_bytes: 3684
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());

        long ba = 0; // B**A
        long onlya = 0; // (B以外)**A
        long onlyb = 0; // B**(A以外)
        long ans = 0;
        for (int i = 0; i < n; i++)
        {
            string s = Console.ReadLine();
            if (s[0] == 'B' && s[s.Length - 1] == 'A') ba++;
            else if (s[0] == 'B') onlyb++;
            else if (s[s.Length - 1] == 'A') onlya++;
            for (int j = 0; j < s.Length - 1; j++)
            {
                if (s[j] == 'A' && s[j + 1] == 'B') ans++;
            }
        }

        // 3通りの場合分け
        // ba==0のときonly同士くっつける
        // ba!=0のとき&&onlyがあるとき
        // ba!=0のとき&&onlyがないとき
        if (ba == 0) ans += Math.Min(onlya, onlyb);
        else if (onlya + onlyb > 0) ans += ba + Math.Min(onlya, onlyb);
        else ans += ba - 1;

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


template<class T>
class SegTree {
public:
	int n;
	vector<T>data;
	T def;
	function<T(T, T)>operation;
	function<T(T, T)>update;


	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return def;
		if (a <= l && r <= b)return data[k];
		else {
			T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
			T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
			return operation(c1, c2);
		}
	}

	SegTree(size_t _n, T _def, function<T(T, T)>_operation,
		function<T(T, T)>_update)
		:def(_def), operation(_operation), update(_update) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		data = vector<T>(2 * n - 1, def);
	}

	void change(int i, T x) {
		i += n - 1;
		data[i] = update(data[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			data[i] = operation(data[2 * i + 1], data[2 * i + 2]);
		}
	}

	//[a,b)
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}

	T operator[](int i) {
		return data[i + n - 1];
	}
};

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

	int N, Q;
	cin >> N >> Q;
	vector<SegTree<ll>>seg;
	seg.pb(SegTree<ll>(N, 0, [](ll a, ll b) {return a + b;}, [](ll a, ll b) {return a+b;}));

	for (int i = 0; i < Q; i++) {
		int c, x, y;
		cin >> c >> x >> y;
		if (c == 0) {
			x--;
			seg[0].change(x, y);
		}
		else {
			x--, y--;
			puts(seg[0].query(x, y + 1));
		}
	}
	return 0;
}


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

ll get_gcd(ll a,ll b) {
	if (a%b==0) {
		return(b);
    } else {
		return(get_gcd(b, a%b));
    }
}

vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for (ll i = 2; i*i <= n; ++i) {
        if (n%i) continue;
        res.emplace_back(i, 0);
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    ll A, B; cin >> A >> B;
    ll min_ab = min(A, B);
    ll gcd = get_gcd(A, B);

    auto res = factorize(gcd);
    cout << int(res.size())+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define pii pair < int, int >
typedef vector<int> vi;
typedef   long long ll;
const int mod =1e9+7;



void solve(){
	int a,b;
	cin>>a>>b;
	cout<<a*b;
}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}

priority_queue<int, vector<int>, greater<int>> pq;
vector<int> v;

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

    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 && i % 5) sum += i;
    }

    printf("%lld", sum);
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;

    ll index = 0;
    rep (i, S.size()) {
        if (S[i] == 'B') {
            index = i;
            break;
        }
    }

    ll ans = 0;
    ll cnt = 0;
    for (ll i = index; i < S.size(); i++) {
        if (S[i] == 'W') {
            ans += (i-index-cnt);
            cnt++;
        }
    }

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

Measured memory_bytes: 720