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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===




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

	vector<Vi> g(N + M);

	for (int i = 0; i < N; ++i) {
		int K;
		cin >> K;
		for (int j = 0; j < K; ++j) {
			int L;
			cin >> L;
			--L;
			g[i].push_back(N + L);
			g[N + L].push_back(i);
		}
	}

	int cnt = 0;
	vector<bool> pass(N + M);
	queue<int> q;
	q.push(0);
	pass[0] = true;
	++cnt;
	while (!q.empty()) {
		int node = q.front();
		q.pop();
		for (const auto& chd : g[node]) {
			if (pass[chd]) continue;
			q.push(chd);
			pass[chd] = true;
			if (chd < N) ++cnt;
		}
	}
	

	cout << (cnt == N ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 8952
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
int n;
long long a[maxn];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) scanf("%lld",a+i);
	sort(a+1,a+n+1,greater<long long>());
	int st=n;
	for(int i=2;i<=n;i++) if(a[i]<0) {st=i;break;}
	long long ans=0;
	for(int i=1;i<st;i++) ans+=a[i];
	for(int i=st;i<=n;i++) ans-=a[i];
	cout<<ans<<endl;
	for(int i=2;i<st;i++) cout<<a[st]<<' '<<a[i]<<endl,a[st]-=a[i];
	for(int i=st;i<=n;i++) cout<<a[1]<<' '<<a[i]<<endl,a[1]-=a[i];
	return 0;
}

Measured memory_bytes: 4436
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef pair<int,int> P;

int main() {
    int i,j,n,p,q,temp;
    int t=0;
    int flag=0;
    string s;
    int k;
    cin>>n>>k;
    long long int ans=k;
    for(i=0; i<n-1; ++i){
        ans=ans*(k-1);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace _0009 {

	public static class Program {

		public static void Main() {
			// var cache = new Dictionary<int, bool>();
			var cache = new int[1000000];

			string input;
			while (!string.IsNullOrEmpty(input = Console.ReadLine())) {
				var x = int.Parse(input);
				var count = 0;
				if (x < 2) {
					count = 0;
				} else {
					count = 1;

					for (int i = 3; i <= x; i += 2) {
						bool prime;
						if (cache[i] != 0) {
							//if (cache.ContainsKey(i)) {
							prime = cache[i] == 1 ? true : false;
						} else {
							prime = true;
							for (int j = 3; j <= Math.Sqrt(i); j += 2) {
								if (i % j == 0) {
									prime = false;
									break;
								}
							}

							// cache.Add(i, prime);
							cache[i] = prime ? 1 : 2;
						}

						if (prime) {
							count++;
						}
					}
				}

				Console.WriteLine(count);
			}
		}

		//private static bool IsPrime(int x) {
		//	if (x == 2) {
		//		return true;
		//	}
		//	if (x < 2 || x % 2 == 0) {
		//		return false;
		//	}

		//	for (int i = 3; i <= Math.Sqrt(x); i += 2) {
		//		if (x % i == 0) {
		//			return false;
		//		}
		//	}

		//	return true;
		//}

	}

}

Measured memory_bytes: 13092
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#define int ll
#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;

const int N = 1e5 + 10;
string ar;
int d;
int dp[N][102][2];

int fun(int pos , int tyt , int sum){
    if(pos == ar.size())
        return sum == 0;
    auto & res = dp[pos][sum][tyt];
    if(res != -1)
        return res;
    int lim = tyt ? ar[pos] - '0' : 9;
    int ans = 0;
    for(int i = 0 ; i <= lim ; i++)
        ans = (ans % MOD + fun(pos + 1 , tyt & (i == lim) , (sum + i) % d) % MOD) % MOD; 
    return res = ans;
}

signed main(){

#ifndef ONLINE_JUDGE
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);
    
    memset(dp , -1 , sizeof dp);
    cin >> ar;
    cin >> d;
    cout << (fun(0 , 1 , 0) - 1 + MOD) % MOD << '\n';;
    

    return 0;

}



Measured memory_bytes: 163828
#include <iostream>
#include<cstring>
#include<algorithm>
#include<cmath>


using namespace std;
int main(void){
    
    int N,M;
    cin>>N>>M;
    if(N==M)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
    
    
    
    
    
    return 0;
    
}


Measured memory_bytes: 256
N = int(input())
A_list = list(map(int,input().split()))
B_list = list(map(int,input().split()))
C_list = list(map(int,input().split()))
ans = sum(B_list)

for i in range(1,N):
    
    if A_list[i] == A_list[i-1]+1 :
        ans += C_list[A_list[i]-2]
print(ans)
    

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int a;
	int b;
	cin >> a;
	cin >> b;

	if (a > b)
	{
		cout << "a > b" << endl;
	}
	if (a < b)
	{
		cout << "a < b" << endl;
	}
	if (a == b)
	{
		cout << "a == b" << endl;
	}


	
	return 0;
}


/*if (a > b)
{
	cout << "a > b" << endl;
}
if (a < b)
{
	cout << "a < b" << endl;
}
if (a == b)
{
	cout << "a == b" << endl;
}*/

Measured memory_bytes: 3072
n,u,v=[int(j) for j in input().split()]
u,v=u-1,v-1
l=[[] for i in range(n)]
for i in range(n-1):
    a,b=[int(j)-1 for j in input().split()]
    l[a].append(b)
    l[b].append(a)
k=[10**18 for i in range(n)]
from collections import deque
q=deque([u])
k[u]=0
s=set()
while q:
    p=q.popleft()
    s.add(p)
    for i in l[p]:
        if i not in s:
            q.append(i)
            k[i]=k[p]+1

k2=[10**18 for i in range(n)]
from collections import deque
q=deque([v])
k2[v]=0
s=set()
while q:
    p=q.popleft()
    s.add(p)
    for i in l[p]:
        if i not in s:
            q.append(i)
            k2[i]=k2[p]+1
ans=0
for i in range(n):
    if k[i]<=k2[i]:
        if ans<k2[i]:
            ans=k2[i]

print(ans-1)


Measured memory_bytes: 36256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,ans;
	cin>>a>>b;
	if((a==1&&b==2)||(a==2&&b==1))cout<<'3';
	if((a==1&&b==3)||(a==3&&b==1))cout<<'2';
	if((a==2&&b==3)||(a==3&&b==2))cout<<'1';
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

  string S;
  cin >> S ;
  int pos=0;
  while (S.find("hi",pos) == pos){
    pos+=2;
  }

  if (S.length() == pos){
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}

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


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

    int n, cnt = 0;;
    cin >> n;
    vector <int> arr(n);
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }

    for(int i=0;i<n;i++){
        while((arr[i] & 1) == 0){
            arr[i]/=2;
            cnt++;
        }
    }

    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  (n:m:_) <- fmap (map read . words) getLine :: IO [Int]
  abs <- replicateM m $ (\(a:b:_) -> (a,b)) . map read . words <$> getLine :: IO [(Int, Int)]
  putStr . unlines . map show $ solve' n m abs
  -- solve n m abs
  -- return ()

solve' n m abs = tail . reverse . scanl' (-) (pairs n) $ unfoldr f (initial, reverse abs)
  where
    initial = ufFromList [1..n]
    -- f :: (UnionFind Int, [(Int, Int)]) -> Maybe (Int, (UnionFind Int, [(Int, Int)]))
    f (_, []) = Nothing
    f (uf, !(!a,!b):abs) = Just (if pa == pb then 0 else na * nb, (newUf, abs))
      where
        pa = ufFind a uf
        na = ufSize a uf
        pb = ufFind b uf
        nb = ufSize b uf
        newUf = ufUnite a b uf

pairs n = n * (n - 1) `div` 2

type UnionFind = (IntMap.IntMap Int, IntMap.IntMap Int)

ufFromList :: [Int] -> UnionFind
ufFromList as = (IntMap.fromList $ zip as as, IntMap.fromList $ zip as (repeat 1))

ufIsRoot :: Int -> UnionFind -> Bool
ufIsRoot k uf = k == ((fst uf) IntMap.! k)

ufFind :: Int -> UnionFind -> Int
ufFind k uf | ufIsRoot k uf = k
            | otherwise = ufFind ((fst uf) IntMap.! k) uf

ufSize :: Int -> UnionFind -> Int
ufSize k uf = let p = ufFind k uf in (snd uf) IntMap.! p

ufUnite :: Int -> Int -> UnionFind -> UnionFind
ufUnite k l uf 
  | (ufFind k uf) == (ufFind l uf) = uf
  | otherwise = if nk < nl 
                then (IntMap.adjust (\_->pl) pk $ fst uf, IntMap.adjust (\_->nk+nl) pl $ snd uf)
                else (IntMap.adjust (\_->pk) pl $ fst uf, IntMap.adjust (\_->nk+nl) pk $ snd uf)
    where
      pk = ufFind k uf
      nk = ufSize k uf
      pl = ufFind l uf
      nl = ufSize l uf


Measured memory_bytes: 130428
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main(){
  int n,ans=0,zerocount,zero=0;
  cin >> n;
  int h[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  while(1){
    zerocount = 0;
    if(h[0] != 0){
      zerocount ++;
    }
    for(int j=1;j<n;j++){
      if(h[j-1]==0 && h[j]!=0){
        zerocount ++;
      }
    }
    zero = 0;
    for(int j=0;j<n;j++){
      if(h[j]!=0){
        h[j] --;
        zero ++;
      }
    }
 //   cout << "--"<<zerocount<<"--"<<endl;
    ans += zerocount;
  	if(zero == 0){
      break;
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(a > 0){
    c = c-b;
    if(c <= 0){
      break;
    }
    a =  a-d;
  }
    if(c <= 0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
    
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	string S, T, U;
	int A, B;

	cin >> S >> T >> A >> B >> U;

	if (U == S) {
		A--;
	}
	if (U == T) {
		B--;
	}

	printf("%d %d\n", A, B);

	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author SimplyDivine
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int h = in.nextInt();
            int w = in.nextInt();
            char[][] a = new char[h][w];
            for (int i = 0; i < h; i++) {
                a[i] = in.next().toCharArray();
            }
            for (int i = 0; i < h + 2; i++) {
                for (int j = 0; j < w + 2; j++) {
                    if (i == 0 || i == h + 1 || j == 0 || j == w + 1) {
                        out.print("#");
                    } else out.print(a[i - 1][j - 1]);
                }
                out.println();
            }
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream i) {
            br = new BufferedReader(new
                    InputStreamReader(i));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
import java.util.*;
import static java.lang.Math.ceil;
class Main{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int health = input.nextInt();
		int n = input.nextInt();
		Vector<Integer> a = new Vector<>(n);
		int sum = 0;
		for(int i = 0;i < n; ++i){
			int x = input.nextInt();
			a.add(x);
		}
		for(int i = 0;i < n; ++i){
			sum += a.get(i);
		}
		if(sum >= health){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 62080
from collections import deque

N, Q = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
# print(G)

DP = [0] * N
for j in range(Q):
    p, x = map(int, input().split())
    DP[p-1] += x

# BFS
que = deque([])
que.append((0, DP[0]))
while que:
    p = que.popleft()
    v = p[1]
    for i in G[p[0]]:
        DP[i] += v
        que.append((i, DP[i]))

print(*DP)


Measured memory_bytes: 52872
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++) 
typedef long long ll;
using namespace std;

/*class Uni {
public:*/
    vector<int> parent; //親ノード
    vector<int> Siz; //集合の大きさ

    // n要素で初期化
    void init(int n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    int root(int x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {

        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }

        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }

        Siz[x] += Siz[y];
        parent[y] = x;
    }

    // xとyが同じ集合に属するかどうか
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    int size(int x) {
        return Siz[root(x)];
    }
//};

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

    vector<int> a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    init(n);

    vector<ll> ans(m);
    ans[m-1] = (ll)n*(n-1)/2;
    for(int i = m-1; i >= 1; i--) {

        if(same(a[i], b[i])) {
            ans[i-1] = ans[i];
        }
        else {
            ans[i-1] = ans[i] - (ll)size(a[i]) * size(b[i]);
            unite(a[i], b[i]);
        }
    }

    rep(i, m) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define maxinum ((1<<(x+y+z))-1)
long long n, x, y, z, f[45][140005];
bool exist(long long t){
	if((t & (1<<(x+y+z-1))) == 0 || (t & (1<<(y+z-1))) == 0 || (t & (1<<(z-1))) == 0)
		return true;
	return false;
}
long long pow(long long t){
	long long cnt = 1;
	for(int i = 1; i <= t; i++)
		cnt = (cnt * 10) % mod;
	return cnt;
}
int main(){
	scanf("%lld %lld %lld %lld", &n, &x, &y, &z);
	f[0][0] = 1;
	for(long long i = 1; i <= n; i++)
		for(long long j = 0; j <= maxinum; j++)
			if(exist(j)){
				for(long long k = 1; k <= 10; k++){
					long long cur = (((j<<k) | (1<<(k-1))) & maxinum);
					if(exist(cur))
						f[i][cur] = (f[i][cur] + f[i-1][j]) % mod;
				}
			}
	long long ans = 0;
	for(long long i = 0; i <= maxinum; i++)
		if(exist(i))
			ans = (ans + f[n][i]) % mod;
	printf("%lld", (pow(n)-ans+mod) % mod);
    return 0;
}

Measured memory_bytes: 44160
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	ll a, b;
	cin >> a >> b;
	ll ans = (a * b) / __gcd(a, b);
	cout << ans << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
a = sorted([int(i) for i in input().split()])
heapq.heapify(a)
l = []

for _ in range(m):
    b, c = map(int, input().split())
    l.append((b, c))

l = sorted(l, key=lambda x: x[1], reverse=True)

for b, c in l:
    if a[0] >= c:
        break
    for _ in range(b):
        if a[0] < c:
            heapq.heappushpop(a, c)
        else:
            break

print(sum(a))

Measured memory_bytes: 23272
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
//vector<int>G[MAXN];
//int dis[MAXN][MAXN];
int ans[MAXN]={0};
int main()
{
    //memset(dis,1,sizeof dis);
    int n;
    int x,y;
    cin >> n >> x >> y;
    //dis[x][x]=0;
    //dis[y][y]=0;
    for(int i=1;i<=n;++i){
        for(int j=i;j<=n;j++){
            int num = j-i;
            num = min(num,abs(i-x)+abs(j-y)+1);
			num=min(num,abs(i-y)+abs(j-x)+1);
            ans[num]++;
        }
        //    dis[i][j]=dis[j][i]=j-i;
    }
//    for(int i=1;i<=x;++i){
//        for(int j=y;j<=n;++j)
//            dis[i][j]=dis[j][i]=dis[i][x]+dis[y][j]+1;
//    }
//    for(int i=n-1;i>0;i--){
//
//        if(i<=x){
//
//        }
//        else if(i>=y){
//            for(int j=1;j<=x;j++){
//                dis[i][j]=dis[j][i]=dis[i][y]+dis[x][j]+1;
//            }
//        }
//        else{
//
//        }
//        for(int j=i+1;j<=n;j++){
//            ans[dis[i][j]]++;
//        }
//    }
//    for(int i=1;i<=n;i++){
//        for(int j=1;j<=n;j++)
//            cout << dis[i][j] << " \n"[j==n];
//
//    }
    for(int i=1;i<n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}


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

class Dice
{
public:
	int label[7];
	int orientation[7];

	Dice() { }
	Dice(int l[6]) : orientation{0,1,2,3,4,5,6}
	{
		for(int i=1; i<7; ++i) label[i] = l[i-1];
	}

	int getIndex(int l) const {
		int i=0;
		while(++i<7) if(l == label[i]) break;
		return i;
	}

	int getFace(int top, int front) const {
		// top then front
		int i=0;
		static const int loops[3][4] = { {2,3,5,4}, {1,2,6,5}, {1,3,6,4}};
		static const int result[3] = {1,3,5};

		for(int j=0; j<3 && i==0; ++j)
			for(int k=0; k<4 && i==0; ++k)
				if(loops[j][k] == top) {
					if(loops[j][(k+1)%4] == front) i = result[j];
					else if(loops[j][(k+3)%4] == front) i = 7 - result[j];
				}
		return label[i];
	}

};


int main()
{
	int label[6];
	for(auto &l : label) cin >> l;

	Dice dice(label);

	int q; cin >> q;
	while(q--) {
		int top, front;
		cin >> top >> front;
		top = dice.getIndex(top);
		front = dice.getIndex(front);
		cout << dice.getFace(top, front) << '\n';
	}
	
	return 0;
}



Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[110];

int solve() {
    int cnt = 0;
    for (int i = 0; i < n; i+=2) {
        if (a[i] % 2 == 1)
            cnt++;
    }
    return cnt;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3196
import sys
input = sys.stdin.readline
from itertools import accumulate
N,K = map(int,input().split())
A = [int(input()) for i in range(N)]

class SegmentTree:
    def __init__(self,data,op,default):
        N = len(data)
        self.N = N
        self.op = op
        self.default = default
        self.l = 2**((N-1).bit_length())
        self.data = [default]*self.l + data + [default]*(self.l-N)
        for i in range(self.l-1,0,-1):
            self.data[i] = op(self.data[2*i], self.data[2*i+1])

    def get_data(self, i=None):
        if i is None:
            return self.data[self.l:self.l + self.N]
        else:
            return self.data[self.l+i]

    def set(self,i,val):
        i += self.l
        self.data[i] = val
        i = i//2
        while i > 0:
            self.data[i] = self.op(self.data[2*i], self.data[2*i+1])
            i = i//2

    def get(self,i,j):
        i += self.l
        j += self.l
        s = self.default 
        while j-i > 0:
            if i & 1:
                s = self.op(s,self.data[i])
                i += 1
            if j & 1:
                s = self.op(s,self.data[j-1])
                j -= 1
            i, j = i//2, j//2
        return s

M = 300000

seg = SegmentTree([0]*(M+1), max, 0)
for a in A:
    l = max(a-K,0)
    r = min(a+K+1, M+1)
    m = seg.get(l,r)
    seg.set(a, m+1)

print(seg.get(0,M))


Measured memory_bytes: 135824
#include<stdio.h>
#include<stdlib.h>
#define INF 2000000000
typedef struct {
  char m;
  int n;
} Card;
int c=0;
Card L[50000],R[50000];
void swap(Card *a,Card *b){
  Card tmp;
  tmp=*a;
  *a=*b;
  *b=tmp;
}
void merge(Card *A,int left,int mid,int right){
  int n1,n2,i,j,k;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1].n=INF;
  R[n2].n=INF;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i].n<=R[j].n){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      j++;
    }
    c++;
  }
}

void mergeSort(Card *A,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2 ;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
} 


int partition(Card *A,int p,int r){
  int i,j;
  Card x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].n<=x.n){
      i++;
      swap(&A[i],&A[j]);
    }
  }
  swap(&A[i+1],&A[r]);
  return i+1;
}

void quicksort(Card *A,int p,int r){
  int q;
  if(p<r){
    q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}
  
int main(){
  int i,n,flag=0;
  Card A[100000],B[100000];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf(" %c%d",&A[i].m,&A[i].n);
    B[i]=A[i];
  }
  quicksort(A,1,n);
  mergeSort(B,1,n+1);
  for(i=1;i<=n;i++){
    if(A[i].m!=B[i].m) flag=1;
  }
  if(flag==1) printf("Not stable\n");
  else printf("Stable\n");
  for(i=1;i<=n;i++) printf("%c %d\n",A[i].m,A[i].n);
  return 0;
}



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

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import maximum_bipartite_matching
import numpy as np

N = int(input())

X = []
Y = []
for i in range(N):
    X.append([int(i) for i in input().split()])

for i in range(N):
    Y.append([int(i) for i in input().split()])

data = []
for i in range(len(X)):
    for j in range(N):
        if X[i][0] < Y[j][0] and X[i][1] < Y[j][1]:
            data.append([i,j,1])


if not data:
    print(0)
    exit()

edge = np.array(data, dtype = np.int64).T
# graph = csr_matrix((edge[2], (edge[:2] - 1)), (V, V))
graph = csr_matrix((edge[2], (edge[:2])), (len(X), len(Y)))           # 番号のデクリメントが不要な場合

matching = maximum_bipartite_matching(graph, perm_type="column")

print(sum(d!=-1 for d in matching))

Measured memory_bytes: 38212
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 2005;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
const ll mm=1e18;
#define Se second
#define Fi first

int main()
{
    ios::sync_with_stdio(false);
    ll x,y;
    cin>>x>>y;
    if(x%y==0)
    {
        cout<<-1<<endl;
        return 0;
    }
    for(ll i=x;i<=mm;i+=x)
    {
        if(i%y!=0)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	int t[300] = { 0 };
	int w, x, y, z;
	cin >> w >> x >> y >> z;
	int ans = 0;
	
	rep(i, w, x) {
		t[i] += 1;
	}

	rep(i, y, z) {
		t[i] += 1;
	}

	rep(i, 0, max(x, z)) {
		if (t[i] == 2) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    ll a,b,c;
    cin >> a >> b >> c;
    if (4*a*b<(c-a-b)*(c-a-b) && c-a-b>=0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;   
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){
	int a[10]={0
	};
	int x1,x2,x3,x4;
	cin>>x1>>x2>>x3>>x4;
	a[x1]++;
	a[x2]++;
	a[x3]++;
	a[x4]++;
//	for(int i=0;i<=9;i++)
	//cout<<a[i];
	if(a[1]==1&&a[9]==1&&a[7]==1&&a[4]==1)
	cout<<"YES";
	else
	cout<<"NO";
}

Measured memory_bytes: 256
import math

s = input().rstrip().split()

a = int(s[0])
b = int(s[1])
c = int(s[2])

k = int(input())

m = max(a,b,c)

n = math.pow(2,k)

ans = a + b + c + m*(n-1)

print("{}".format(int(ans)))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

#define LL long long
#define SIZE 10000000
void solve(LL x) {
    char *str = (char*)malloc(SIZE * sizeof(char));
    LL size = SIZE;
    LL i, mod, cnt;
    for(cnt = 0; (x > 0) || (x < 0); ++cnt) {
        mod = x % -2;
        x /= -2;
        if(mod == -1) { ++x; mod = 1; }

        if(cnt - 4 > size) {
            size *= 2;
            char *tmp = (char*)malloc(size * sizeof(char));
            for(i = 0; i < cnt; ++i) { tmp[i] = str[i]; }
            free(str);
            str = tmp;
        }

        //printf("x : %lld mod : %lld\n", x, mod);
        if(mod == 1) { str[cnt] = '1'; }
        else if(mod == 0) { str[cnt] = '0'; }
    }

    if(cnt == 0) { printf("0\n"); return; }
    for(i = cnt-1; i >= 0; --i) {
        printf("%c", str[i]);
    }
    printf("\n");
}

int main()
{
    LL n;
    scanf("%lld", &n);
    //printf("n = %lld\n", n);
    solve(n);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>

#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF=10000000;

int N;
vector<int> vs[10010];
int n[10010]={};
int c[10010];
int d[10010];
bool finish[10010]={};
P edges[10010];
int CalcM(){
    int ans=0;
    for(int i=0;i<N-1;i++){
        int f=edges[i].first;
        int s=edges[i].second;
        ans+=min(d[f],d[s]);
    }
    return ans;
}
int main(){
    cin>>N;
    for(int i=0;i<N-1;i++){
        int a,b;
        cin>>a>>b;a--;b--;
        edges[i]=P(a,b);
        vs[a].push_back(b);
        vs[b].push_back(a);
        n[a]++;n[b]++;
    }
    for(int i=0;i<N;i++){
        cin>>c[i];
    }
    sort(c,c+N);
    queue<int> q;
    q.push(0);
    int now=N-1;
    while(now>=0){
        int t=q.front();q.pop();
        finish[t]=true;
        n[t]=INF;
        d[t]=c[now];
        now--;
        for(auto v:vs[t]){
            if(!finish[v]){
                q.push(v);
            }
        }
    }
    cout<<CalcM()<<endl;
    for(int i=0;i<N;i++){
        cout<<d[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 1152
s = gets.chomp

if s[0] != 'A'
  puts 'WA'
  exit
end

(2...s.size-1).each do |i|
  if s[i] == 'C'
    s.slice!(0)
    s.slice!(i-1)

    if s == s.downcase
      puts 'AC'
      exit
    end
  end
end
puts 'WA'

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main(){
	int n;
	int has4=0,hasno=0,has2=0,buf;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>buf;
		if(buf%4==0)has4++;
		else if(buf%2==0)has2++;
		else hasno++;
	}
	if(has2==0){
		if(has4>=hasno-1)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}else{
		if(has4>=hasno)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int h[n];
    rep(i,n)cin >> h[i];
    
    int dp[n+1];
    rep(i,n)dp[i+1] = 1e9;
    dp[0] = 0;
    
    for(int i = 0;i < n;i++){
        dp[i+1] = min(dp[i+1],dp[i] + abs(h[i+1] - h[i]));
        dp[i+2] = min(dp[i+2],dp[i] + abs(h[i+2] - h[i]));
    }
    
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4316
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n%2){
        cout << "No" << endl;
    }else{
        rep(i,n/2)if(s[i] != s[n/2+i]){
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
    }

}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define pb emplace_back
#define inf (int)1e9
#define ff first
#define ss second
#define ll long long
#define sp(n) cout << setprecision(n) << fixed
#define hellcat ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define give(x) cout << #x << " " << x << endl
#define debug cout << "dddd" << '\n'
#define debarr(a, n) for (int i = 0; i < n; ++i) cout << a[i] << ' '; cout << endl
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

template <class S, class T>
inline S smax(S &l, T r) {
  return l = max(l, (S)r);
}
template <class S, class T>
inline bool smin(S &l, T r) {
  return l = min(l, (S)r);
}

bitset<110> mark;

int32_t main () {
  hellcat;

	int n, k;
	cin >> n >> k;

	for (int i = 0; i < k; ++i) {
		int d;
		cin >> d;
		for (int j = 0; j < d; ++j) {
			int a;
			cin >> a;
			a--;
			mark[a] = true;
		}
	}

	int ans = 0;
	for (int i = 0; i < n; ++i)
		if (!mark[i])
			ans++;

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

const unsigned long long INF = 1LL << 60;

//////////////////////////////////////////////////////////////

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << " " << a * 2 + b * 2 << endl;
}



Measured memory_bytes: 3028
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 998244353;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
struct mi {
	ll v; explicit operator ll() const { return v; }
	mi() { v = 0; }
	mi(ll _v) { 
		v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
		if (v < 0) v += MOD;
	}
	friend bool operator==(const mi& a, const mi& b) { 
		return a.v == b.v; }
	friend bool operator!=(const mi& a, const mi& b) { 
		return !(a == b); }
	friend bool operator<(const mi& a, const mi& b) { 
		return a.v < b.v; }
   
	mi& operator+=(const mi& m) { 
		if ((v += m.v) >= MOD) v -= MOD; 
		return *this; }
	mi& operator-=(const mi& m) { 
		if ((v -= m.v) < 0) v += MOD; 
		return *this; }
	mi& operator*=(const mi& m) { 
		v = v*m.v%MOD; return *this; }
	mi& operator/=(const mi& m) { return (*this) *= inv(m); }
	friend mi pow(mi a, ll p) {
		mi ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend mi inv(const mi& a) { assert(a.v != 0); 
		return pow(a,MOD-2); }
		
	mi operator-() const { return mi(-v); }
	mi& operator++() { return *this += 1; }
	mi& operator--() { return *this -= 1; }
	friend mi operator+(mi a, const mi& b) { return a += b; }
	friend mi operator-(mi a, const mi& b) { return a -= b; }
	friend mi operator*(mi a, const mi& b) { return a *= b; }
	friend mi operator/(mi a, const mi& b) { return a /= b; }
    friend ostream& operator<<(ostream& os, const mi& m) {
        os << m.v; return os;
    }
    friend istream& operator>>(istream& is, mi& m) {
        ll x; is >> x;
        m.v = x;
        return is;
    }
};


typedef vector<mi> vmi;
typedef pair<mi,mi> pmi;
typedef vector<pmi> vpmi;
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, S; cin >> N >> S;
    mi dp[N+1][S+1];
    F0R(i, N+1) F0R(j, S+1) dp[i][j] = 0;
    dp[0][0] = pow((mi) 2, N);
    int A[N]; F0R(i, N) cin >> A[i];
    mi inv2 = 2; inv2 = inv(inv2);
    F0R(i, N) {
        F0R(j, S+1) {
            dp[i+1][j] += dp[i][j];
            if (j + A[i] <= S) {
                dp[i+1][j+A[i]] += dp[i][j] * inv2;
            }
        }
    }

    cout << dp[N][S] << endl;
	return 0;
}




Measured memory_bytes: 73912
n,t,e=map(int, input().split())
x=list(map(int, input().split()))
number=-1

for i in range(n):
    for j in range(1,((t+e)//x[i])+1):
        if(j*x[i]>=t-e and j*x[i]<=t+e):
            number=i+1
            break
        
    else:
        continue
    break

print(number)


Measured memory_bytes: 5596
import java.util.*;

public class Main{
  public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
	  int a = sc.nextInt();
	  int b = a/100;
	  int c = a - b*100;
	  if(b > 12 || b < 1) {
		  if(c > 12 || c < 1) {
			  System.out.println("NA");
		  }
		  else {
			  System.out.println("YYMM");
		  }
	  }
	  else if(b < 13 && b > 0) {
		  if(c > 12 || c < 1) {
			  System.out.println("MMYY");
		  }
		  else {
			  System.out.println("AMBIGUOUS");
		  }
	  }
  }
}

Measured memory_bytes: 24020
S=raw_input();l=len(S);f=S.find('C');A=0
if S[:1]=='A':
	A+=1
	S="a"+S[1:]
if S[2:l-1].count('C')==1:
	A+=1
	S=S[:f]+'c'+S[f+1:]
if S.islower():
	A+=1
print('AC'if A==3 else'WA')

Measured memory_bytes: 2568
n = gets.to_i
num = gets.chomp.split(' ').map(&:to_i)
num = num.select{|i|i.even?}
flag = true
num.each do |i|
    if (i%3!=0)&&(i%5!=0)
        flag = false
        break
    end
end
if flag
    puts "APPROVED"
else
    puts "DENIED"
end

Measured memory_bytes: 1788
N = int(input())
A = [int(input()) for _ in range(N)]
used = [False for _ in range(N)]

crntbtn = 1
cnt=0
while(True):
  used[crntbtn-1] = True
  crntbtn = A[crntbtn-1]
  cnt += 1
  if crntbtn == 2:
    print(cnt)
    break
  else:
    if used[crntbtn-1] == True:
      print(-1)
      break


Measured memory_bytes: 7888
#include<iostream>
#include<fstream>
#include<unordered_map>
#include<cmath>
using namespace std;
const int DN=3e5+5,M=998244353;
long long n,a,b,k,f,fact[DN],cnt,rez;
long long ve(long long a,long long b)
{
    long long p=1,r=1,c=a;
    while(p<=b)
    {
        if(p&b)
            r=(1LL*r*c)%M;
        c=(1LL*c*c)%M;
        p=p*2;
    }
    return r;
}
long long comb(long long n,long long k)
{
    long long r=(fact[n]*ve(fact[k],M-2))%M;
    r=(r*ve(fact[n-k],M-2))%M;
    return r;
}
int main()
{
    cin>>n>>a>>b>>k;
    fact[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=(1LL*fact[i-1]*i)%M;
    for(long long i=0;i<=n;i++)
    {
        f=k-i*a;
        if(f%b)
            continue;
        cnt=f/b;
        if(cnt<0||cnt>n)
            continue;
        rez=(rez+comb(n,i)*comb(n,cnt))%M;
    }
    cout<<rez;
}


Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * Strings of Impurity
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();
            String T = sc.next();

            @SuppressWarnings("unchecked")
            List<Integer>[] clist = new List[26];
            for (int i = 0; i < 26; i++) {
                clist[i] = new ArrayList<Integer>();
            }

            for (int i = 0; i < S.length(); i++) {
                clist[(int) (S.charAt(i) - 97)].add(i);
            }

            int[][] index = new int[26][];
            for (int i = 0; i < 26; i++) {
                index[i] = clist[i].stream().mapToInt(Integer::intValue).toArray();
            }

            long con = 0;
            int pre = -1;
            for (char c : T.toCharArray()) {
                int[] idx = index[(int) (c - 97)];
                if (idx.length == 0) {
                    System.out.println(-1);
                    return;
                }

                int pos = Arrays.binarySearch(idx, pre + 1);

                int i;
                if (pos >= 0) {
                    i = idx[pos];
                } else {
                    pos = -(pos + 1);
                    if (pos < idx.length) {
                        i = idx[pos];
                    } else {
                        con++;
                        i = idx[0];
                    }
                }

                pre = i;
            }

            System.out.println(con * S.length() + pre + 1);
        }
    }

}


Measured memory_bytes: 33576
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long
const double pi = 3.141592653589793;

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//階乗
ll fact(ll a) {
	int ans = 1;
	for (int i = 1; i <= a; i++) {
		ans *= i;
	}
	return ans;
}

//コンビネーション
ll combi(ll a, ll b) {
	return fact(a) / (fact(b) * fact(a - b));
}

int main() {
	int a, b;	//a:h, b:m cm
	int h, m;	//hour, minutes
	cin >> a >> b >> h >> m;
	pair<double,double>p;	//a:p,座標(x,y)
	pair<double, double>q;	//b:q,座標(x,y)
	p.first = cos(2.5 * pi - pi / 6 * h - pi / 360 * m) * a;
	p.second = sin(2.5 * pi - pi / 6 * h - pi / 360 * m) * a;
	q.first = cos(2.5 * pi - pi / 30 * m) * b;
	q.second = sin(2.5 * pi - pi / 30 * m) * b;

	double ans = 0;
	double d_x= abs(p.first - q.first);
	double d_y = abs(p.second - q.second);
	ans = sqrt(d_x * d_x + d_y * d_y);
	cout << fixed << setprecision(15) << ans << endl;

	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    vector<string> ss = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin >> s;
    for(int i=0; i<ss.size(); i++)
        if (ss[i] == s) {
            cout << 7 - i << endl;
            return 0;
        }

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 256
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>
 
using namespace std;
 
int main(){
 long int L;
 long int R;
 long int m = 2019;
 long int i,j;
 cin >> L >> R;
 if(R-L>= 2019)m=0;
else{for(i=L;i<=R;i++){
  for(j=i+1;j<=R;j++){
    m = min(m,((i*j)%2019));
  }}
 }
 cout << m << endl; 
}


Measured memory_bytes: 256
#include <stdio.h>

int main( void ) {

	int n, a[5000], i, j;
	long long sum, max;

	while ( scanf( "%d", &n ) && n != 0 ) {

		max = -100000;

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

		for ( i = 0; i < n; i++ ) {

			sum = 0;

			for ( j = i; j < n; j++ ) {

				sum += a[j];

				if ( sum > max ) { max = sum; }

			}

		}

		printf( "%lld\n", max );

	}

	return 0;

}

Measured memory_bytes: 616
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

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

	for(int n; cin >> n, n;) {
		vector<int> c(1, 1), color;
		int first;
		cin >> first;

		color.push_back(first);
		
		for(int i = 1; i < n; ++i) {
			int in;
			cin >> in;

			if(in == color[color.size() - 1])
				++c[c.size() - 1];

			else {
				color.push_back(in);
				c.push_back(1);
			}
		}

		int ans = n;
		for(int i = 1; i < c.size() - 1; ++i) {
			if(c[i] == 1 || c[i] == 3) {
				if(c[i] == 3)
					--c[i - 1];

				int l = i - 1, r = i + 1;
				while(l >= 0 && r < c.size() && color[l] == color[r] && c[l] + c[r] >= 4) {
					--l;
					++r;
				}

				int tmp = 0;
				for(int j = 0; j <= l; ++j)
					tmp += c[j];

				for(int j = r; j < c.size(); ++j)
					tmp += c[j];

				if(c[i] == 3)
					++c[i - 1];

				else if(l == i - 1)
					continue;

				chmin(ans, tmp);
			}
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1308
###############################################################################
#Imports
import collections
import itertools
from functools import lru_cache
import sys
import math
from decimal import Decimal
###############################################################################
#Constants
MOD = int(1e9)+7
###############################################################################
#Helper


def helper():
	pass
###############################################################################
#Solver


def solve():
	a, b = input().split(' ')
	a, b = int(a), Decimal(b)
	print(int(a*b))


###############################################################################
#Driver
t = 1
for _ in range(t):
	solve()
###############################################################################


Measured memory_bytes: 71372
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    f(i,0,s.size()-1){
        if(s[i]=='1')
          cout<<"9";
        else if(s[i]=='9')
          cout<<"1";
    }
}   
    
    
     

     
   





Measured memory_bytes: 3644
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int a, b;

int main(){
	cin >> a >> b;
	
	if(a < 6) cout << 0 << endl;
	else if(a < 13) cout << b/2 << endl;
	else cout << b <<  endl;
 	
	return 0;
}

Measured memory_bytes: 256
(setq *n* (read))
(setq *l* (read))

(defun tastes (n l i)
  (if (<= n i)
    nil
    (append (list (+ L i)) (tastes n l (1+ i)))
    ))

(defun get-min (l)
  (if (equal (cdr l) nil)
    (car l)
    (let ((prov (get-min (cdr l))))
      (if (< (abs (car l)) (abs prov))
        (car l)
        prov
        ))))

(setq *scheduled* (tastes *n* *l* 0))
(setq *min* (get-min *scheduled*))

(print (- (apply #'+ *scheduled*) *min*))

Measured memory_bytes: 13536