akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE OverloadedStrings #-}
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe
import Data.String
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as BS
---------------------------------------------------------------------------------
main = do
  k <- getInt
  print $ sum [gcd a (gcd b c) |a<-[1..k], b<-[1..k], c<-[1..k]]
  
  
  
---------------------------------------------------------------------------------

{-ByteString関連-}
--IO
getLine' = BS.getLine
getContents' = BS.getContents
getLineList = BS.words <$> getLine'
getContentList = BS.words <$> getContents'
getInt = fst . fromJust . BS.readInt <$> getLine'
getIntListw = map (fst . fromJust. BS.readInt) .BS.words <$> getLine'
getIntListl = map (fst . fromJust. BS.readInt) .BS.lines <$> getContents'
getInteger = fst . fromJust. BS.readInteger <$> getLine'
putStr' = BS.putStr
putStrLn' = BS.putStrLn
--演算子
bs1 |++| bs2 = BS.append bs1 bs2
chr |:+| bs2 = BS.cons chr bs2
bs1 |+:| chr = BS.snoc bs1 chr

{-elem関連-}
--elemの第一引数をリストにしたもの。
--elemList "abc" "atcoder" -> [True,False,True]
elemList [] _ = []
elemList (x:xs) list  = elem x list : elemList xs list

--elemIndexの第一引数をリストにしたもの。
elemIndexList [] list = []
elemIndexList (x:xs) list  = elemIndex x list : elemIndexList xs list

--elemIndicesの第一引数をリストにしたもの。
elemIndicesList [] list = []
elemIndicesList (x:xs) list  = elemIndices x list : elemIndicesList xs list

--length . nubの代わり
count _ [] c = c
count [] (y:ys) c = count [y] ys (c+1)
count (x:xs) (y:ys) c
  |y==x = count (y:x:xs) ys c
  |y/=x = count (y:x:xs) ys (c+1)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d, K;
  cin >> a >> b >> c >> d >> K;
  int x = a * 60 + b;
  int y = c * 60 + d;
  cout << (y - K) - x << endl;
}


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

#define int long long
#define all(s) s.begin(), s.end()
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) ((x >> y) & 1)

const int MOD = 1000000007;

int power(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) res = 1LL * res * x % MOD;
        x = 1LL * x * x % MOD;
        y >>= 1;
    }
    return res;
}

// int inv(int x) {
//     return power(x, MOD - 2);
// }

// int fac[N], ifac[N];

// void init_combi() {
//     fac[0] = 1;
//     ifac[0] = 1;
//     for (int i = 1; i < N; i++) {
//         fac[i] = 1LL * fac[i - 1] * i % MOD;
//         ifac[i] = inv(fac[i]); 
//     }
// }

// int C(int n, int k) {
//     return 1LL * ifac[k] * ifac[n - k] % MOD * fac[n] % MOD;
// }

main() {
    ios::sync_with_stdio(false); cin.tie(0); 
    cout.tie(0);
    int n;
    cin >> n;
    int ans = (power(10, n) - 2 * power(9, n) + power(8, n)) % MOD;
    if (ans < 0) ans += MOD;
    cout << ans;
    return 0;
}

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

using namespace std;

const int H = 10;
string s[H];

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

  int h, w, k;
  cin >> h >> w >> k;
  for (int i = 0; i < h; ++i) {
    cin >> s[i];
  }
  int ans = 1e9;
  int hh = h - 1;
  for (int mask = 0; mask < (1 << hh); ++mask) {
    int cur = __builtin_popcount(mask);
    vector<int> cc, sm;
    for (int i = 0; i < hh; ++i) {
      if ((mask >> i) & 1) {
        cc.push_back(i);
        sm.push_back(0);
      }
    }
    cc.push_back(hh);
    sm.push_back(0);
    vector<int> val(h);
    for (int i = 0; i < h; ++i) {
      val[i] = lower_bound(cc.begin(), cc.end(), i) - cc.begin();
    }
    for (int j = 0; j < w; ++j) {
      vector<int> kek(sm.size());
      for (int i = 0; i < h; ++i) {
        kek[val[i]] += s[i][j] == '1';
      }
      bool ok = true;
      for (int i = 0; i < sm.size(); ++i) {
        if (kek[i] > k) {
          cur = 1e9;
        }
        if (kek[i] + sm[i] > k) {
          ok = false;
        }
      }
      if (ok) {
        for (int i = 0; i < sm.size(); ++i) {
          sm[i] += kek[i];
        }
      } else {
        ++cur;
        sm = kek;
      }
    }
    ans = min(ans, cur);
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 384
def f(x,y):
    d=(x*x+y*y)**0.5
    return x-y/d,y+x/d
while True:
    n=input()
    if n==-1:
        break
    x,y=1.0,0
    for i in xrange(n-1):
        x,y=f(x,y)
    print x,y

Measured memory_bytes: 4364
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),k=sc.nextInt(),ans=0;
		for(int i=0;i<n;i++)
		{
			int x=sc.nextInt();
			if(x>=k) ans++;
		}
		System.out.print(ans);
	}

}







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

int main(){
    ll h,w;
    cin>>h>>w;
    ll a=0,b = 0,c = 0;
    ll ans = 1e+15;
    if((h*w)%3 == 0){
        cout<<"0";
        return 0;
    }
    if(h==2 && w==2)
    {
        cout<<"1";
        return 0;
    }
    ll d = h*w;

    for(ll i=1;i<w-1;i++)
    {
        a=i*h;
        b= (w-i)*h/2;
        if(h%2!=0)
        {
            b -= b%(w-i);
        }
        c = (w-i)*h-b;
        //cout<<a<<","<<b<<","<<c<<endl;
        //ll temp=max(a,b,c)-min(a,b,c);
        ll tmax=max(a,b);
        ll tmin=min(a,b);
        ll temp=max(tmax,c)-min(tmin,c);
        if(temp<ans)ans=temp;

        
    }
    //cout<<h<<endl;
    ll l = w/3;
    ans = min(ans,h);
    ll t = w;
    w = h;
    h=t;

    for(ll i=1;i<w-1;i++)
    {
        a=i*h;
        b= (w-i)*h/2;
        if(h%2!=0)
        {
            b -= b%(w-i);
        }
        c = (w-i)*h-b;
        ll tmax=max(a,b);
        ll tmin=min(a,b);
        ll temp=max(tmax,c)-min(tmin,c);
        if(temp<ans)ans=temp;

        
    }
    ans=min(ans,h);
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll x;cin>>x;
     long long int cur=100;
    int ans=0;
    while(cur<x){
        ans++;
        cur=ll(cur*1.01);
       // cout<<cur<<endl;
    }
    cout<<ans;
}

Measured memory_bytes: 3596
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // abs(), qsort()
#include <math.h>           // sqrt(), round()
#include <stdbool.h>

// #define DEBUG 1
#define MAX_N 12

int n;
int r[MAX_N];
int w;
int lineno;
#ifdef DEBUG
double wmin;
#endif

int
cmp_func(const void *l_, const void *r_)
{
	const int *l = (const int*) l_;
	const int *r = (const int*) r_;

	if (*l < *r)
		return -1;

	if (*l > *r)
		return 1;

	return 0;
}

double
width(const int a[MAX_N * 2 - 1])
{
	double tw = a[0];
	for (int i = 1; i < n; ++i)
	{
		int rc = a[i - 1] + a[i];
		int ra = abs(a[i - 1] - a[i]);
		tw += sqrt(rc * rc - ra * ra);
	}

	tw += a[n - 1];
	tw = round(tw * 1000000000.0) / 1000000000.0;
	return tw;
}

bool
solve()
{
	qsort(r, n, sizeof(int), cmp_func);

	int a[MAX_N * 2 - 1];
	int l = 0, h = n - 1;
	int tl = n - 1, th = n - 1;
	a[tl] = r[h--];

	for (int i = 1; i < n; ++i)
	{
		int b;
		if (i & 1)
			b = r[l++];
		else
			b = r[h--];

		int lw = abs(a[tl] - b);
		int hw = abs(a[th] - b);
		if (lw > hw)
			a[--tl] = b;
		else if (lw < hw)
			a[++th] = b;
		else
		{
			if (a[tl] < a[th])
				a[--tl] = b;
			else
				a[++th] = b;
		}
	}

#ifndef DEBUG
	double wmin = width(&a[tl]);
#else
	wmin = width(&a[tl]);
#endif

	l = 0, h = n - 1;
	tl = n - 1; th = n - 1;
	a[tl] = r[l++];

	for (int i = 1; i < n; ++i)
	{
		int b;
		if (i & 1)
			b = r[h--];
		else
			b = r[l++];

		int lw = abs(a[tl] - b);
		int hw = abs(a[th] - b);
		if (lw > hw)
			a[--tl] = b;
		else if (lw < hw)
			a[++th] = b;
		else
		{
			if (a[tl] < a[th])
				a[--tl] = b;
			else
				a[++th] = b;
		}
	}

	double d = width(&a[tl]);
	if (d < wmin)
		wmin = d;

	return wmin <= w;
}

bool
ope_line()
{

	lineno++;
	int i = scanf("%d", &w);
	if (i == EOF)
		return false;

	for (n = 0;; ++n)
	{
		char c;
		scanf("%c", &c);
		if (c == '\n' || c == EOF)
			break;

		scanf("%d", &r[n]);
	}

#ifndef DEBUG
	printf("%s\n", solve() ? "OK" : "NA");
#else
	bool b = solve();
	printf("%s: %.9f\n", b ? "OK" : "NA", wmin);
#endif
	return true;
}

int
main(int argc, char **argv)
{
	lineno = 0;
	while (true) // process for each line
	{
		if (!ope_line())
			break;
	}

	return 0;
}

Measured memory_bytes: 1760
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
    #include <cassert>
    #include <iomanip>
    #include <sstream>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,N) FOR(i,0,N)
#define FORD(i,b,a) for(int i=(int)(b)-1;i>=a;--i)
typedef long long LL;
typedef pair<int,int> PII;
const int INF=1e9+7;
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define dprintf(...) printf(__VA_ARGS__)
const int maxn=1e5+10;
int a,b,c,x,y;
int ans=INF;
int main()
{
	scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
	int res;
	REP(i,max(x,y)+1)
	{
		res=i*2*c+max(0,x-i)*a+max(0,y-i)*b;
	//	if(i==100000)
	//	cout<<i<<" "<<res<<endl;
		ans=min(res,ans); 
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<i64>();
    let o = n / 2 + n % 2;
    println!("{}", o as f64 / n as f64);
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll a;
    double b;
    cin >> a >> b;
    int ib = b*100+0.3;
    a = a*ib;
    cout << a/100 <<endl;
    
}

Measured memory_bytes: 3720
#include <stdio.h>

int main()
{
    int a,b;
    scanf("%d %d",&a, &b);
    if((a*b*1)%2==1){
        printf("Yes\n");
    }else if ((a*b*2)%2==1)
    {
    printf("Yes\n");
    }else if ((a*b*3)%2==1)
    {
        printf("Yes\n");
    }else
    {
        printf("No\n");
    }
    
    
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    scan(N);
    vector<int> h(N);
    scan(h);

    vector<int> dp(N);
    FOR(i, 1, N) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        if (0 <= i - 2) {
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
    print(dp[N - 1]);

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>

typedef long long ll;
const ll MOD = 1e9 + 7;
using namespace std;

vector<vector<ll>> g(1e6);

ll dp[1000000][2];

ll dfs(ll now,ll col,ll bef){
    ll i, j, k;
    if(dp[now][col])
        return dp[now][col];
    else {
        ll ret = 1;
        ll s = g[now].size();
        for(i = 0; i < s; i++){
            if(g[now][i] != bef){
                if(col == 0){
                    ret = (ret * (dfs(g[now][i], col ^ 1, now) + dfs(g[now][i], col, now))) % MOD;
                }
                else ret = (ret * dfs(g[now][i], col^1, now)) % MOD;
            }
        }
        return dp[now][col] = ret;
    }
}

int main(){
    ll n,i,j;
    cin >> n;
    for(i = 0; i < n-1;i++){
        ll x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    cout << (dfs(1, 0, 0) + dfs(1, 1, 0)) % MOD << endl;
    return 0;
}

Measured memory_bytes: 36736
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int N, K;
vector<int> use;
int ans = INF;
void dfs(int sum){
  if (sum >= N){
    ans = min(ans, sum);
    return;
  }
  for (int v: use){
    if (sum == 0 && v == 0) continue;
    sum = sum * 10 + v;
    dfs(sum);
    sum /= 10;
  }
}

int main(){
  cin >> N >> K;
  vector<int> d(K); rep(i, K) cin >> d[i];
  rep(i, 10) {
    if (!count(d.begin(), d.end(), i)) use.push_back(i);
  }
  dfs(0);
  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, k = map(int, input().split())
    d = [None] * k
    A = [None] * k
    for i in range(k):
        d[i] = int(input())
        A[i] = map(int, input().split())

    N = [True] * n
    for i in range(k):
        for a in A[i]:
            N[a-1] = False
    print(sum(N))

if __name__ == '__main__':
    main()



Measured memory_bytes: 9716
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

void mergeSort(int, int);
void merge(int, int, int);

int n, c=0;
int S[500000];

int main(){
  int i;

  scanf("%d",&n);
  if( n<1 || 500000<n ) exit(1);

  for( i=0 ; i<n ; i++ ){
    scanf("%d",&S[i]);
    if( S[i]<0 || 1000000000<S[i] ) exit(2);
  }

  mergeSort(0, n);
  
  for( i=0 ; i<n ; i++ ){
    if(i == n-1){
      printf("%d\n",S[i]);
    }
    else{
      printf("%d ",S[i]);
    }
  }
  printf("%d\n",c);


  return 0;
}

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

void merge(int left, int mid, int right){
  int i,j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1];
  int R[n2+1];

  for( i=0 ; i<n1 ; i++ ){
    L[i] = S[left+i];
  }
  for( i=0 ; i<n2 ; i++ ){
    R[i] = S[mid+i];
  }

  L[n1] = INT_MAX;
  R[n2] = INT_MAX;

  i=0;
  j=0;
  
  for( k=left ; k<right ; k++ ){
    if(L[i] < R[j]){
      S[k] = L[i];
      i++;
    }
    else{
      S[k] = R[j];
      j++;
    }
    c++;
  }
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dbg(x) cerr << #x << " : " << x << endl;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    int n;
    cin >> n;
    cout << pow(n,3) << endl;
    return 0;
} 

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int a,b; cin >> a >> b;
    if(a==1) a=14; if(b==1) b=14;
    if(a>b) out("Alice");
    else if(a==b) out("Draw");
    else out("Bob");

    return 0;
}

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

using namespace std;
#define ll long long
const int MAXN = 2e5 + 1;
int mass[301][301];
int ans[301][301];
int summcolomn[301];
vector<int> res;

void solve() {
    string s;
    cin>>s;
    if(s=="SUN") cout<<7;
    else if(s=="MON") cout<<6;
    else if(s=="TUE") cout<<5;
    else if(s=="WED") cout<<4;
    else if(s=="THU") cout<<3;
    else if(s=="FRI") cout<<2;
    else if(s=="SAT") cout<<1;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}


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

#define ll long long
#define llu unsigned long long
#define ld long double
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(x) x.begin(),x.end()
#define foreach(it,v) for( __typeof((v).begin())it = (v).begin() ; it != (v).end() ; it++ )
#define present(v,x) (v).find(x) != (v).end()
#define cpresent(v,x) (find(all(v),x) != (v).end())
#define mset(x,v) memset(x, v, sizeof(x))
#define sz(x) (int)x.size()
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }

inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int addmod(int a, int val, int p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline int submod(int a, int val, int p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

string LCS(string s, string t){
	int n = (int)s.length();
	int m = (int)t.length();
	int dp[n+1][m+1];

	for(int i=0; i<=n; i++)
		for(int j=0; j<=m; j++)
			if(i==0 or j==0)
				dp[i][j] = 0;
			else if(s[i-1]==t[j-1])
				dp[i][j] = dp[i-1][j-1] + 1;
			else
				dp[i][j] = max(dp[i][j-1], dp[i-1][j]);

	string l;
	int i=n, j=m;
	while(i>0 and j>0){
		if(s[i-1]==t[j-1]){
			l.push_back(s[i-1]);
			i--; j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
			i--;
		else
			j--;
	}
	reverse(all(l));

	return l;
}

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

	string s, t;
	cin >> s >> t;
	cout << LCS(s, t) << endl;

	return 0;
}

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

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long

const int N = 3e3 + 5;
int dp[N][N], a[N], n;	

int rec(int s, int e){
	if(e < s)
		return 0;
	if(dp[s][e] != -LLONG_MAX)
		return dp[s][e];
	return dp[s][e] = max(a[s] - rec(s + 1, e), a[e] - rec(s, e - 1));
}
	
void solve(){
	cin >> n;
	for(int i = 0 ; i < n ; i++){
		cin >> a[i];	
	}
	for(int i = 0 ; i <= n ; i++){
		for(int j = 0 ; j <= n ; j++){
			dp[i][j] = -LLONG_MAX;		
		}	
	}
	cout << rec(0, n - 1);
}

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 70912
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n = II()
    S = [''] * n
    for i in range(n):
        S[i] = input()
        
    print(len(set(S)))

if __name__ == '__main__':
    solve()


Measured memory_bytes: 35556
class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  int = (): number => {
    const ret = parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
}
function rep(n: number) {
  let a = [];
  for (let i = 0; i < n; i++) a.push(i);
  return a;
}
function bitCount(n: number) {
  if (n == 0) return 0;
  return bitCount(n >> 1) + (n & 1);
}
function solve(xWall: number, S: string[], H: number, W: number, K: number) {
  const compact = rep(W).map(j => {
    let count = [0];
    for (let i = 0; i < H; i++) {
      if (i != 0 && (xWall >> (i - 1)) & 1) count.push(0);
      count[count.length - 1] += S[i][j] == "1" ? 1 : 0;
    }
    return count;
  });
  const bucketSize = compact[0].length;
  let ans = bitCount(xWall);
  let start = 0;
  let currentSum = compact[0].map(_ => 0);
  for (let j = 0; j < W; j++) {
    const nextSum = rep(bucketSize).map(i => currentSum[i] + compact[j][i]);
    // console.log("nextSum:", nextSum);
    if (nextSum.some(v => v > K)) {
      if (start === j) return Infinity;
      start = j;
      ans += 1;
      currentSum = compact[j];
    } else {
      currentSum = nextSum;
    }
  }
  // console.log("x:" + xWall, ans);
  return ans;
}
function Main({ int, str, strs, ints }: NormalInput) {
  const [H, W, K] = ints(3);
  const S = strs(H);
  const step = Math.pow(2, H - 1);
  let min = Infinity;
  for (let i = 0; i < step; i++) {
    min = Math.min(solve(i, S, H, W, K), min);
  }
  console.log(min);
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 23932
#include<iostream>
using namespace std;
int main(){
	int a[10],b;
	for(int i=0;i<10;i++){
		cin>>a[i];
  }
   for(int i=0;i<10;i++){
	   for(int j=i+1;j<10;j++){
		   if(a[i]<a[j]){
			   b=a[i];
			   a[i]=a[j];
			   a[j]=b;}
	         }

	   }

   for(int i=0;i<3;i++)
          {cout<<a[i]<<endl;}
	return 0;
}
	

Measured memory_bytes: 1160
#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;
typedef vector<vector<int> > Graph;
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; }

int main(){
    string s;
    cin >> s;
    int n = (int)s.size();
    vector<int> ans(n+1);
    int r=0,l=0,now;
    rep(i,n-1){
        if(s[i]=='R'&&s[i+1]=='R'){
            r++;
        }
        else if(s[i]=='R'&&s[i+1]=='L'){
            now = i;
            ans[now]+=r/2+1;
            ans[now+1]+=(r+1)/2+1;
            r=0;
        }
        else if(s[i]=='L'&&s[i+1]=='L'){
            l++;
        }
        else if(s[i]=='L'&&s[i+1]=='R'){
            ans[now]+=(l+1)/2;
            ans[now+1]+=l/2;
            l=0;
        }
    }
    ans[now]+=(l+1)/2;
    ans[now+1]+=l/2;
    rep(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {
    private void solve() {
        int n = sc.nextInt();
        while (n > 0) {
            if (n % 10 == 7) {
                out.println("Yes");
                return;
            }
            n /= 10;
        }
        out.println("No");
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


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

typedef long long LL;

#define REP(i, n) for(LL i = 0; i < (LL)(n); i++)
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

template<typename T>
T gcd(T a, T b) {
    T r, temp;

    while(1) {
        if(a < b) {
            temp = a;
            a = b;
            b = temp;
        }
        if(b < 1) continue;

        while((r = a % b) != 0) {
            a = b;
            b = r;
        }
        return b;
    }
}

int main() {
    LL K;
    cin >> K;
    LL res = 0;
    FOR(i, 1, K + 1) {
        FOR(j, 1, K + 1) {
            FOR(k, 1, K + 1) {
                res += gcd(gcd(i, j), k);
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3632
/* Just_Do_It ___________ICARUS__________________*/
	                 
	#include <bits/stdc++.h>
	using namespace std;
	       
	typedef long long ll;
	#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	#define rep(i,a,n) for(ll i=a;i<n;i++)
	#define per(i,a,n) for (ll i=n-1;i>=a;i--)
	#define te ll t; std::cin >> t; while(t--)
	#define SZ 100001
	//# define M_PIl  3.141592653589793238462643383279502884L 
	/*   Proceed with CAUTION   */

	int main(){
		fastio;
		ll n,k;
		cin>>n>>k;
		ll a[n];
		rep(i,0,n) cin>>a[i];
		ll m=abs(k-a[0]);
		rep(i,0,n) m = __gcd(m,abs(k-a[i]));
		cout<<m<<endl;
	}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(){
  int i,j,cnt=0;
  char s[3];
  scanf("%s",s);
  for(i=0; i<2; i++){
    j=i+1;
    if(s[i]!=s[j]){
      cnt++;
    }
  }
  if(cnt!=0){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

ll get_ldigit(ll n) {
	ll ldigit = 0;
	while (n > 0) {
		ldigit = n;
		n /= 10;
	}
	return ldigit;
}

int main() {
	ll n;
	ll res = 0;
	scanf("%lld", &n);
	static ll digits[10][10];
	FOR(i, 1, n) {
		digits[get_ldigit(i)][i % 10]++;
	}
	FOR(i, 1, 9) {
		FOR(j, 1, 9) {
			if (i == j) {
				res += digits[i][j] * (digits[i][j] - 1);
				res += digits[i][j];
			}
			else {
				res += digits[i][j] * digits[j][i];
			}
		}
	}
	printf("%lld\n", res);
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  vecll cnt(n+1);
  FOR(i,1,n+1) {
    for(int j = i; j <= n; j += i) {
      ++cnt[j];
    }
  }
  ll ans = 0;
  REP(i,n+1) {
    ans += i * cnt[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 81336
#エラストテネスのふるいを用いることを考える
#出たものの倍数をいれるダメリストを準備しておく。
#各a[i]についてダメリストに入っていないものが求める個数である
#同じものが複数回出てくるもの（Counterを使えばいい）に関してはダメリストにその数もいれれば良い
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort()
min_a=a[0]
max_a=a[n-1]
#同じものが複数回出てくるもののcheck
dic=Counter(a)
#別リスト
check=set()

for i in range(n):
  if a[i] not in check:
    if dic[a[i]]>=2:
      check.add(a[i])
    for j in range(2,int((max_a)/a[i])+1):
      check.add(a[i]*j)
ans=0
for i in range(n):
  if a[i] not in check:
    ans=ans+1

print(ans)

  
    
    

Measured memory_bytes: 92804
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

#define MOD 1000000007

using namespace std;

int main()
{
	long long x, y;
	long long xtimes, ytimes, tot;
	long long diff;
	vector <long long > bits;

	long long temp = MOD - 2;

	while (temp)
	{
		bits.push_back(temp % 2);

		temp /= 2;
	}

	scanf("%lld %lld", &x, &y);

	if ((x + y) % 3)
	{
		printf("0\n");

		return 0;
	}

	if (x < y)
	{
		temp = x;
		x = y;
		y = temp;
	}

	diff = x - y;

	tot = (x + y) / 3;

	xtimes = (tot + diff) / 2;
	ytimes = tot - xtimes;

	if (ytimes < 0)
	{
		printf("0\n");

		return 0;
	}

	long long perm = 1;

	for (long long i = ytimes+1; i <= xtimes + ytimes; i++)
	{
		perm = perm*i%MOD;
	}

	long long sol;

	sol = perm;

	perm = 1;

	for (long long i = 1; i <= xtimes; i++)
	{
		perm = perm*i%MOD;
	};

	temp = perm;

	long long div = 1;

	for (int i = 0; i < bits.size(); i++)
	{
		if (bits[i])
		{
			div = div*temp%MOD;
		}

		temp = temp*temp%MOD;
	}

	sol = sol*div%MOD;

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

	return 0;
}

Measured memory_bytes: 256
a,b,c = [int(x) for x in input().split()]

ans = 0

while True:
    if a == b == c and a % 2 == 0:
        print(-1)
        break
    elif a == b == c and a % 2 != 0:
        print(ans)
        break
    elif a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
        print(ans)
        break
    else:
        t_a = a // 2
        t_b = b // 2
        t_c = c // 2
        a = t_b + t_c
        b = t_a + t_c
        c = t_a + t_b
        ans += 1

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <iterator>
#include <limits>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#define LL long long
#define PII pair<int, int>
using namespace std;
const int MAXN = 40000;

int N, M, cnt[10005];
bool cake[15][10005];

void flip(int r) {
    for (int i = 0; i < M; i++) {
        cake[r][i] ? cnt[i]-- : cnt[i]++;
        cake[r][i] ^= 1;
    }
}

int main() {
    while (cin >> N >> M) {
        if (N == 0 && M == 0) break;
        for (int i = 0; i < M; i++) cnt[i] = 0;

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                cin >> cake[i][j];
                if (cake[i][j]) cnt[j]++;
            }
        }

        int ans = 0;
        for (int S = 0; S < (1 << N); S++) {
            for (int i = 0; i < N; i++) {
                if ((S >> i) & 1) {
                    flip(i);
                }
            }

            int res = 0;
            for (int i = 0; i < M; i++) {
                res += max(cnt[i], N - cnt[i]);
            }

            for (int i = 0; i < N; i++) {
                if ((S >> i) & 1) {
                    flip(i);
                }
            }

            ans = max(ans, res);
        }

        cout << ans << "\n";
    }
}



Measured memory_bytes: 3192
MOD = 10**9 + 7
import sys
input = sys.stdin.readline
S = int(input())

num = 2010
fact = [1] * (num+1)
ifact = [1] * (num+1)

for i in range(1,num+1):
    fact[i] = (fact[i-1] * i) % MOD
ifact[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(1,num+1)[::-1]:
    ifact[i-1] = (ifact[i] * i)% MOD

def nPr(n,r):
    if r > n:
        return 0
    return (fact[n] * ifact[n-r]) % MOD
def nCr(n,r):
    if r > n:
        return 0
    return (fact[n] * ifact[r] * ifact[n-r]) % MOD

if S <= 2:
    print(0)
    exit()

ans = 0
for i in range(1, S):
    n,r = S-3*i,i-1
    temp = nCr(n+r,r)
    ans += temp
    ans %= MOD
print(ans)



Measured memory_bytes: 67516
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var A = sc.nextInt();
        var B = sc.nextInt();
        if (Abs(A - B) % 2 == 0) {
            WriteLine(Min(A,B) + (Abs(A-B) / 2));
            
            
        } else {
            WriteLine("IMPOSSIBLE");
        }
    }
    
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

// http://drken1215.hatenablog.com/entry/2018/06/08/210000
constexpr int MAX = 510000;
constexpr ll MOD = 1e9+7;

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

ll H(ll n, ll k) {
  return COM(n+k, k);
}

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

  COMinit();
  ll h, w, a, b;
  cin >> h >> w >> a >> b;
  ll ans = 0;
  rep(i, h-a) {
    ans += (H(b-1, i) * H(h-i-1, w-b-1))%MOD;
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 12160
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  int ans = 0;
  int temp = 0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
        temp++;
    }else{
        ans=max(ans,temp);
        temp = 0;
    }
  }
  ans=max(ans,temp);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
# = map(int, input().split())
# = list(map(int, input().split()))
k, n = map(int, input().split())
a = list(map(int, input().split()))
b = [a[0]+k-a[n-1]]
for i in range(n-1):
    b.append(a[i+1]-a[i])
print(k-max(b))


Measured memory_bytes: 26420
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>

using namespace std;
int main()
{
	int n, d;
	cin >> n >> d;
	if (n % (2 * d + 1) == 0) {
		cout << n / (2 * d + 1) << endl;
	}
	else {
		int  ans;
		ans = n / (2 * d + 1) + 1;
		cout << ans << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];
    if(N%2 == 0){
        ll l[N/2+1], r[N/2+1];
        l[0] = r[0] = 0;
        rep2(i, 1, N/2){
            l[i] = l[i-1]+A[(i-1)*2];
            r[i] = r[i-1]+A[(i-1)*2+1];
        }
        //rep(i, N/2+1) cout << l[i] << ' ' << r[i] << endl;
        ll ans = l[N/2];
        rep(i, N/2+1){
            ll tmp = l[i]+r[N/2]-r[i];
            ans = max(ans, tmp);
        }
        cout << ans << endl;
        return 0;
    }
    ll M[N/2];
    M[0] = A[1]-A[0];
    rep2(i, 1, N/2-1){
        M[i] = A[2*i+1]-A[2*i];
        if(M[i-1] > 0) M[i] += M[i-1];
    }
    //rep(i, N/2) cout << M[i] << ' ';
    //cout << endl;
    ll ans, m = INF, sum = 0;
    rep(i, N){
        if(i%2 == 0){
            sum += A[i], m = min(m, A[i]);
        }
    }
    ans = sum-m;
    rep(i, N/2){
        ll tmp = sum-A[(i+1)*2] + M[i];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6716
use strict;
my ($n, $a, $b) = glob<>;
my $ans = 0;
for (1..$n) {
  my $sum = 0;
  for (my $i = $_; $i > 0; $i /= 10) {
    $sum += $i % 10;
  }
  $ans += $_ if $a <= $sum && $sum <= $b;
}
print $ans

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

int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	int ans = 0;
	for (int d = 1; d * d <= m; ++d) {
		if (m % d == 0) {
			int d1 = d;
			int d2 = m / d;
			if (m / d1 >= n) ans = max(ans, d1);
			if (m / d2 >= n) ans = max(ans, d2);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include    <iomanip>
#include    <map>
#include    <set>
using namespace std;
int abs(int x){
    if(x<0){
        return -x;
    }
    return x;
}
int main(){
    int n1,n2,n3;
    int a[1000],b[1000];
    while(cin>>n1>>n2>>n3&&n1!=0){
        int load=0;
        for (int i=0; i<n3; i++) {
            cin>>a[i]>>b[i];
        }
        for (int i=0; i<n3-1; i++) {
            int d=a[i]-a[i+1];
            int e=b[i]-b[i+1];
            if((d*e)>0){
                if (d>0) {
                    int temp=min(d,e);
                    d-=temp;
                    e-=temp;
                    load+=temp;
                }else{
                    int temp=max(d,e);
                    d-=temp;
                    e-=temp;
                    load+=abs(temp);
                }
            }
            load+=(abs(d)+abs(e));
        }
        
        cout<<load<<endl;
    }
    return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Feb  9 21:00:01 JST 2020
 **/

signed main() {
    Int n;
    cin >> n;
    set<Int> s;
    REP(i, n) {
        Int x;
        cin >> x;
        if (s.count(x)) {
            cout << "NO" << endl;
            return 0;
        }
        s.insert(x);
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 9600
import sys
letras= list()
lines = sys.stdin.readlines()
for linea in lines:
    c = linea.split()
    c = list(map(str,c))
list(c)
for k in range(len(c)):
  x = c[k]
  a = list(x)
  letras.append(a[0])
b = "".join(letras)
print(b.upper())

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int N; cin >> N;
	lli Y; cin >> Y;
	int a = -1, b = -1, c = -1;

	if (10000 * N >= Y) {
		rep(i, 0, N + 1) {
			rep(j, 0, N - i + 1) {
				if (i*10000+j*5000+(N-i-j)*1000==Y) {
					a = i, b = j, c = N - i - j;
					break;
				}
			}
		}
	}
	printf("%d %d %d\n", a, b, c);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pbds tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

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

    w(tt)
    {
        int a, b;
        cin >> a >> b;

        if (b > a)
            swap(a, b);

        if (a == b || a + 1 == b)
        {
            cout << 2 * (a - 1) << "\n";
        }
        else
        {
            int sq = sqrt(a * b);
            if (sq * sq == a * b)
                sq--;

            if (sq * (sq + 1) >= a * b)
            {
                cout << 2 * (sq - 1) << "\n";
            }
            else
            {
                cout << 2 * (sq - 1) + 1 << "\n";
            }
        }
    }

    return 0;
}

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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B&&A==C)cout<<1<<endl;
  else if(A==B&&A!=C||A!=B&&B==C||A==C&&C!=B)cout<<2<<endl;
  else cout<<3<<endl;
  return 0;
}



Measured memory_bytes: 256