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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}


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

  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.length()){
    if(s[i] != t[i]){
      ans++;
    }
  }

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


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

int main(void){
 
    int N;
    cin >> N;
    
    if(N %2 == 0){
        cout << (double)1 / 2 <<endl;
    }
    else{
        cout << (double)((N / 2) + 1) / N <<endl;
    }
}

Measured memory_bytes: 3700
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
    string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
    long n = long.Parse(input[0]);
    long k = long.Parse(input[1]);
    long p = 1000000007;
    long answer = 0;
    if(n >= k)
    {
      answer = ModFactorial(n-1,p);
      answer *= DivideModFactorial(n-k,p);
      answer %= p;
      answer *= DivideModFactorial(k-1,p);
      answer %= p;
    }
    Console.WriteLine(answer);
	}

  static long MathPow(long x, long a)//戻り値はx^a
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x;
  
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
      }
    memo *= memo;
    num *= 2;
    }
    return answer;
  }

  static long DivideMod(long x, long a, long p)//戻り値はx^a(mod p)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x%p;
    
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
        answer %= p;
      }
    memo *= memo;
    memo %= p;
    num *= 2;
    }
    return answer;
  }

  static long DivideModReverse(long x, long p)//戻り値はx^-1(mod p), pは素数
  {
    long answer = DivideMod(x, p-2, p);
    return answer;
  }

  static long ModFactorial(long x, long p)//戻り値はx!(mod p)
  {
    long answer = 1;
    for(int i = 2; i <= x; i++)
    {
      answer *= i;
      answer %= p;
    }
    return answer;
  }

  static long DivideModFactorial(long x, long p)//戻り値はx!^-1(mod p), pは素数
  {
    long answer = 1;
    for(long i = x; i >= 2; i--)
    {
      answer *= DivideModReverse(i, p);
      answer %= p;
    }
    return answer;
  }

  static long Comb(long a, long b, long p)//戻り値は組み合わせC(a,b)のmod p
  {
    long answer = 1;
    for(long i = a; i > a-b; i--)
    {
      answer *= i;
      answer %= p;
    }
    answer *= DivideModFactorial(b, p);
    answer %= p;
    return answer;
  }
  
}



Measured memory_bytes: 19880
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int coin[]={1,5,10,50,100,500},sum=0;
		
		for(int i=0;i<6;i++){
			sum+=coin[i]*Integer.parseInt(in.next());
		}
		
		if(sum>=1000)System.out.println(1);
		else System.out.println(0);
	}

}



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

using namespace std;

#define int64 long long 
#define fi first
#define se second
const int mod = (int) 1e9 + 7;

const int nax = 2e5 + 5;


void test_case(){
	int64 a, b ,c, d;
	cin >>a >> b >> c >> d;
	int64 ans = a*c;
	ans = max(ans, a*d);
	ans = max(ans, b*c);
	ans = max(ans, b*d);
	cout<<ans;
}

int main(){
	int t=1;
	//cin>>t;
	while(t--){
		test_case();
	}
}


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


int main(){
    int A,B,C,D;

    scanf("%d %d %d %d", &A, &B, &C, &D);

    while(1){
        C -= B;
        if(C <= 0){
            printf("Yes");
            return 0;
        }
        A -= D;
        if(A <= 0){
            printf("No");
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1728
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, k;
	string s;
	
	cin >> n >> k;
	cin >> s;

	int res = 0;

	for (int i = n-1; i > 0; i--)
	{
		if (s[i] == 'R' && s[i] == s[i - 1])
		{
			res++;
		}
	}

	for (int i = 0; i < n - 1; i++)
	{
		if (s[i] == 'L' && s[i] == s[i + 1])
		{
			res++;
		}
	}

	cout << min(n - 1, res + 2 * k) << '\n';

	return 0;
}

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

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

    vector<long long int> h(n);
    for(int i=0; i<n; i++){
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    reverse(h.begin(), h.end());

    long long int ans = 0;
    for(int i=k; i<n; i++){
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long a[] = new long[N];
		long dif[] = new long[N];

		for (int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
			dif[i] = a[i] - i - 1;
		}
		Arrays.sort(dif);
		long median = 0;

		if (N == 1) {
			System.out.println(0);
			return;
		}

		median = dif[N/2];

		long ans = 0;
		for (int i = 0; i < N; i++) {
			ans += Math.abs(dif[i] - median);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 93000
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=507;
using bn=bitset<nax*nax>;
const int d=63;

int n;

struct bity
{
	vll wek;
	bity(){}
	bity(int v)
	{
		wek.resize((v/d)+2, 0);
	}
	void ustaw(int v)
	{
		wek[v/d]|=(1LL<<(v%d));
	}
	void zeruj()
	{
		fill(wek.begin(), wek.end(), 0);
	}
	int licz()
	{
		int ret=0;
		for (const ll &i : wek)
			ret+=__builtin_popcountll(i);
		return ret;
	}
};

void oruj(bity &a, const bity &b)
{
	int r=min(a.wek.size(), b.wek.size());
	for (int i=0; i<r; i++)
		a.wek[i]|=b.wek[i];
}

char wcz[nax];
int tab[nax][nax];

bity oso[nax][10];

ll wyn;

int ile[nax];
int num[nax][nax];

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
	{
		scanf("%s", wcz+1);
		for (int j=1; j<=n; j++)
		{
			if (wcz[j]=='#')
			{
				tab[i][j]=-1;
			}
			else
			{
				tab[i][j]=wcz[j]-'0';
				ile[tab[i][j]]++;
				num[i][j]=ile[tab[i][j]];
			}
		}
	}
	for (int i=1; i<=n; i++)
		for (int j=1; j<=9; j++)
			oso[i][j]=bity(ile[j]);
	for (int i=n; i; i--)
	{
		for (int j=n; j; j--)
		{
			if (tab[i][j]==-1)
			{
				for (int l=1; l<=9; l++)
					oso[j][l].zeruj();
				continue;
			}
			for (int l=1; l<10; l++)
				oruj(oso[j][l], oso[j+1][l]);
			//~ oso[j]|=oso[j+1];
			for (int l=1; l<10; l++)
			{
				//~ if (oso[j][l].licz())
					//~ debug() << i << " " << j << " to " << l << " " << oso[j][l].licz();
				wyn+=l*tab[i][j]*oso[j][l].licz();
			}
			//~ oso[j][num(i, j)]=1;
			oso[j][tab[i][j]].ustaw(num[i][j]);
		}
	}
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 19840
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdio>

#define F first
#define S second
using namespace std;

typedef pair<double,double> P;
const int MAX = 1005;
P ans[MAX];

int main(){


  ans[0] = P(1,0);
  ans[1] = P(1,1);

  double theta = 0;

  for(int i = 2; i < MAX; i++){
    double len = ans[i-2].F*ans[i-2].F+ans[i-2].S*ans[i-2].S;
    theta += atan(1.0/sqrt(len));
    //   cout << i << " " << sqrt(len) << endl;
    ans[i] = P(ans[i-1].F-sin(theta), ans[i-1].S+cos(theta));
    // cout << theta << " " << sin(theta) << endl;
    //  ans[i] = rotate(ans[i-1],theta);
  }

  int n;
  while(cin >> n && n != -1) printf("%.2f\n %.2f\n",ans[n-1].F,ans[n-1].S);
  return 0;
}

Measured memory_bytes: 1268
n,m = map(int,input().split())

a = [input() for i in range(n)]
b = [input() for i in range(m)]

ans = 0
for i in range(n-m+1):
  for j in range(n-m+1):
    t = [k[j:j+m] for k in a[i:i+m]]
    if t == b :
      ans = 1

print("Yes" if ans else "No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
main()
{
    int a,b,c,d,x[100],y[100][100],e=0,f=0,i,j,k,l;
    cin>>a>>b;
    for(i=0;i<a;i++)
    {
        for(j=0;j<b;j++)
            cin>>y[i][j];
    }
    for(i=0;i<a-1;i++)
    { for(k=i+1;k<a;k++){
        c=0;
        for(j=0;j<b;j++)
        {
           d=abs(y[i][j]-y[k][j]);
           c+=d*d;
        }
       l=sqrt(c);
        if(l*l==c)
            e++;
    }}
    cout<<e<<endl;
    return 0;
}


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

int main() {
  int a,b;
  string s;
  cin >> a >> b >> s;
  bool ans = true;

  for(int i = 0; i < a; i++){
    if(s[i] == '-'){
      ans = false;
    }
  }
    if(s[a] != '-'){
      ans = false;
    }
  for(int i = a+1; i < a+b+1; i++){
    if(s[i] == '-'){
      ans = false;
    }
  }

  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }



  return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let _line = parse_line::<String>();
    let line = parse_line::<String>();
    let splited = line.split("ABC");
    let ss: Vec<&str> = splited.collect();
    println!("{}", ss.len() - 1);
}

fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include <stdio.h>
#define N 100001
int main(void){
  int i,j=0;
  char s[N]={},ans[N]={};
  scanf("%s",s);
  for(i=0;;i++){
    if(i%2==0){
      ans[j]=s[i];
      j++;
    }
    if(s[i]==0){
      break;
    }
  }
  printf("%s\n",ans);
  return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
    int n; cin >> n;
    vector < vector<int> > f(n, vector<int> (10));
    vector < vector<int> > p(n, vector<int> (11));
    REP(i,n){
        REP(j, 10){
            cin >> f[i][j];
        }
    }
    REP(i,n){
        REP(j, 11){
            cin >> p[i][j];
        }
    }
    vector<int> c(n);
    int ans = -2000000000;
    FOR(i, 1, 1024){
        bitset<10> joi(i);
        REP(j, n){
            c[j] = 0;
            REP(k, 10){
                c[j] += joi[k] * f[j][k];
            }
        }
        int kari_ans = 0;
        REP(j, n){
            kari_ans += p[j][c[j]];
        }
        ans = max(ans, kari_ans);

    }
    cout << ans;
}

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

int main() {
	int x = 1;
	int a,b;
	int ans = -1;
	cin >> a >> b;
	if(floor(b/a)==1){
	for(x=1;x<=1009;x++){
	    if(x*8/100==a&&x/10==b){
	        ans = x;
	        goto outer;
	    }
	}
	}
	outer: cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fp(i,l,r) for(register int i = (l);i <= (r);++i)
#define fd(i,l,r) for(register int i = (l);i >= (r);--i)
#define MAXN (int)7e3
#define st static int
#define it inline int
#define bt inline bool
#define vt inline void
using namespace std;

char ch[1000][4];

it init(){
	cin>>ch[1]>>ch[2]>>ch[3];
	printf("%c%c%c\n",ch[1][0],ch[2][0],ch[3][0]);
	return 0;
}

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

Measured memory_bytes: 256
r, c = map(int,input().split())
b=[]
for i in range(r):    
        a=list(map(int,input().split()))
        a.append(sum(a))
        b.append(a)
        a=map(str,a)
        print(" ".join(a))
d=[]
for i in range(c+1):
    cs=[]
    for j in range(r):
        cs.append(b[j][i])
    d.append(sum(cs))
d=map(str,d)
print(" ".join(d))

Measured memory_bytes: 7768
#include <bits/stdc++.h>
using namespace std;
#define int long long 
const int MAXPUI = 62;
const int MAXN = 51;
const int MOD = 1000 * 1000 * 1000 + 7;
int nbChemins[MAXPUI][MAXN][MAXN];
int sol[MAXN][MAXN];
int32_t main()
{
	int N , X;
	cin >> N >> X;
	for (int i = 0 ; i < N  ; i++)
	{
		for (int j = 0 ; j < N  ;j ++)
		{
			cin >> nbChemins[0][i][j];
		}
	}

	for (int i = 1 ; i < MAXPUI ; i++)
	{
		for (int milieu = 0 ; milieu < N ; milieu++)
		{
			for (int debut = 0 ; debut < N ; debut++)
			{
				for (int fin = 0 ; fin < N ; fin++)
				{
					nbChemins[i][debut][fin] = (nbChemins[i][debut][fin]  + nbChemins[i - 1][debut][milieu] * nbChemins[i - 1][milieu][fin]) % MOD;
				}

			}
		}
	}
	bool ok = false;
	for (int i = 0 ; i < MAXPUI ; i++)
	{
		if (X & (1ll<<i))
		{
			if (!ok)
			{
				for (int j = 0 ; j < N ;  j++)
				{
					for (int k = 0 ; k < N ; k++)
					{
						sol[j][k] = nbChemins[i][j][k];
					}
				}
				ok = true;
				continue;
			}
			int copie[N][N]; for (int j = 0 ; j < N ; j++) for (int k = 0 ; k < N ; k++) {copie[j][k] = sol[j][k]; sol[j][k] = 0;}
			for (int milieu = 0 ; milieu < N ; milieu++)
			{
				for (int debut = 0 ; debut < N ; debut++)
				{
					for (int fin = 0 ; fin < N ; fin++)
					{
						sol[debut][fin] = (sol[debut][fin]  + nbChemins[i][debut][milieu] * copie[milieu][fin]) % MOD;
					}

				}
			}
		}
	}
	int s = 0;
	for (int i = 0 ; i < N ; i++)
	{
		for (int j = 0 ; j < N ; j++)
		{
			s = (sol[i][j] + s) % MOD;
		}
	}
	cout<<s<<endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<int(b);i++)
using namespace std;
int main()
{
    int n, k;
    cin >> n;
    map<int, int> m;
    REP(i, 0, n) {
        cin >> k;
        m[k]++;
    }
    long long ans = 0;
    for (auto p: m) {
        if (p.first < p.second) {
            ans += p.second - p.first;
        } else if (p.first > p.second) {
            ans += p.second;
        }
    }
    cout << ans << endl;
}


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



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	V<tuple<string, int, int>> rest(n);
	rep(i, n) {
		string s;
		int p;
		cin >> s >> p;
		rest[i] = make_tuple(s, -p, i + 1);
	}
	
	sort(all(rest));
	
	rep(i, n)cout << get<2>(rest[i]) << endl;
}

Measured memory_bytes: 3572
#include <stdio.h>

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long llong;

struct State {
  State() {
    pos[0] = pos[1] = 0;
  }
  void set_bit(int n) {
    bits |= 1U << n;
  }
  void reset_bit(int n) {
    bits &= ~(1U << n);
  }
  bool is_set(int n) {
    return bits & (1U << n);
  }
  unsigned int bits = 0;
  int pos[2];
};

static int ord(char x) {
  switch (x) {
    case 'R':
      return 0;
    case 'G':
      return 1;
    case 'B':
      return 2;
    default:
      break;
  }
  return 0;
}

vector<int> reverse_num[3];

static llong recurse_last(const string& s, int start, State& state) {
  int lookfor = 0;  // R
  if (state.bits == 5)
    lookfor = 1;  // G
  else if (state.bits == 3)
    lookfor = 2;  // B

  int ret = reverse_num[lookfor][start];

  int illegal_pos = state.pos[1] * 2 - state.pos[0];
  if (illegal_pos < s.size() && ord(s[illegal_pos]) == lookfor)
    --ret;

  return ret;
}

static llong recurse_sub(const string& s, int start, State& state) {
  llong sum = 0;
  for (int i = start; i < s.size() - 1; ++i) {
    int o = ord(s[i]);
    if (state.is_set(o))
      continue;
    state.set_bit(o);
    state.pos[1] = i;
    sum += recurse_last(s, i + 1, state);
    state.reset_bit(o);
  }
  return sum;
}

static void recurse_top(const string& s, llong& sum) {
  for (int i = 0; i < s.size() - 2; ++i) {
    State state;
    state.set_bit(ord(s[i]));
    state.pos[0] = i;
    sum += recurse_sub(s, i + 1, state);
  }
}

void DRGBTriplets(std::istream& in, std::ostream& out) {
  int n;
  string s;
  in >> n;
  in >> s;

  int count[3];
  count[0] = count[1] = count[2] = 0;
  for (int i = 0; i < s.size(); ++i) {
    ++count[ord(s[s.size() - 1 - i])];
    reverse_num[0].push_back(count[0]);
    reverse_num[1].push_back(count[1]);
    reverse_num[2].push_back(count[2]);
  }
  reverse(reverse_num[0].begin(), reverse_num[0].end());
  reverse(reverse_num[1].begin(), reverse_num[1].end());
  reverse(reverse_num[2].begin(), reverse_num[2].end());

  llong sum = 0;
  recurse_top(s, sum);
  out << sum << endl;
}

int main(int argc, char** argv) { DRGBTriplets(cin, cout); return 0; }

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

using namespace std;

using bs = bitset< 800 >;
using ss = bitset< 100 >;


int main()
{
  int W, H, M, N;
  int mat[800][800], beet[100][100];

  auto to = [&](char c)
  {
    if(islower(c)) return (c - 'a' + 10);
    if(isupper(c)) return (c - 'A' + 36);
    if(isdigit(c)) return (c - '0' + 0);
    return (~0);
  };


  cin >> W >> H >> M >> N;
  for(int i = 0; i < H; i++) {
    string s;
    cin >> s;
    for(int j = 0; j < W; j++) {
      mat[i][j] = to(s[j]);
    }
  }

  for(int i = 0; i < N; i++) {
    string s;
    cin >> s;
    for(int j = 0; j < M; j++) {
      beet[i][j] = to(s[j]);
    }
  }

  ss mask = 1;
  mask <<= M - 1;

  auto matching = [&](vector< int > &latte, vector< int > &malta)
  {
    bs ret;
    int tail = 0;
    ss bit1[62], bit2;
    for(int i = 0; i < malta.size(); i++) {
      if(malta[i] < 0) for(int j = 0; j < 62; j++) bit1[j][i] = true;
      else bit1[malta[i]][i] = true;
    }
    for(int i = 0; i < W; i++) {
      bit2 <<= 1;
      bit2 |= 1;
      if(~latte[i]) bit2 &= bit1[latte[i]];
      if((bit2 & mask).count()) ret[i] = true;
    }
    return (ret);
  };

  bs bits[800][100];
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < N; j++) {
      vector< int > vec1(W), vec2(M);
      for(int k = 0; k < W; k++) vec1[k] = mat[i][k];
      for(int k = 0; k < M; k++) vec2[k] = beet[j][k];
      bits[i][j] = matching(vec1, vec2);
    }
  }

  int ret = 0;
  for(int i = 0; i <= H - N; i++) {
    for(int k = 0; k < W; k++) {
      bool flag = true;
      for(int j = 0; j < N; j++) {
        flag &= bits[i + j][j][k];
      }
      ret += flag;
    }
  }

  cout << ret << endl;
}

Measured memory_bytes: 13712
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

const long long INF = LLONG_MAX;
const long long MOD = 1000000007;
const long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k1,k2,k3;
ll ans = 0, sum = 0, cnt = 0;
//long double d;
string s/*1, s2, s3*/;
bool flag = false;

/*--------------------template--------------------*/

int main() {
    cin >>n>>m>>k1>>k2>>k3;
	vi a(k1),b(k2),c(k3);
	veccin(a);veccin(b);veccin(c);
	sort(ALL(a));sort(ALL(b));sort(ALL(c));
	vp apple;
	REP(i,k1){
    	apple.push_back(make_pair(a[i],0));
    }
  	REP(i,k2){
    	apple.push_back(make_pair(b[i],1));
    }
	REP(i,k3){
    	apple.push_back(make_pair(c[i],2));
    }
	sort(ALL(apple));
	reverse(ALL(apple));
	vi tmp;
    for(ll i=0; n||m; ++i){
    	dbg(apple[i].first);
    	dbg(apple[i].second);
    	dbglf;
      	if(apple[i].second==0&&n){
        	n--;sum+=(apple[i].first);
        }else if(apple[i].second==1&&m){
        	m--;sum+=(apple[i].first);
        }else if(apple[i].second==2){
        	tmp.push_back(apple[i].first);
        }
		if(tmp.size()==n+m){
      		REP(j,tmp.size()){
         		sum+=tmp[j];   
            }
        	n=0;m=0;
        }
    	
    }
	cout << sum;
}


Measured memory_bytes: 12908
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  string S;
  cin>>S;
  vector<vector<int> > edge(N);
  int a, b;
  for(int i=0;i<M;++i) {
    cin>>a>>b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  vector<pair<int, int> > arr(N);
  int anum, bnum;
  queue<int> que;
  for(int i=0;i<N;++i) {
    anum = 0;
    bnum = 0;
    for(int j=0;j<edge[i].size();++j) {
      if(S[edge[i][j]]=='A') anum++;
      else bnum++;
    }
    arr[i] = mp(anum, bnum);
    if(anum==0 || bnum==0) que.push(i);
  }
  int state;
  pair<int, int> nodes;
  map<int, int> amap;
  while(!que.empty()) {
    state = que.front();que.pop();
    if(amap[state]>0) continue;
    amap[state]++;
    for(int i=0;i<edge[state].size();++i) {
      anum = arr[edge[state][i]].fi;
      bnum = arr[edge[state][i]].se;
      if(S[state]=='A') anum--;
      else bnum--;
      arr[edge[state][i]] = mp(anum, bnum);
      if(anum==0 || bnum==0) que.push(edge[state][i]);
    }
  }
  bool can = false;
  for(int i=0;i<N;++i) {
    if(arr[i].fi>0 && arr[i].se>0) can = true;
  }
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 23604
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;


// sortの仕方
// 	■ string s の場合
// 	昇順: sort(s.begin(), s.end())
// 	降順: sort(s.rbegin(), s.rend())
//
// 	■ ll a[N] の場合
// 	昇順: sort(a, a+N)
// 	降順: 不明

// vector の使い方
// 宣言：
// vector<int> v;
// vector<int> v(N);
// 初期化:
// vector<int> v(10, 5); 要素数10，全ての要素の値5．
// vector<int> v = {1, 2, 3};
// 代入：
// v[0] = 3;
// sort:
// sort(v.begin(), v.end());
//

// int alph2int(char character) {
//     int x = character - 'a';
//     return x;
// }

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

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

int main(int argc, char *argv[]){
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	for (int i=0; i<N; i++) {
		cin >> h[i];
	}

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

	int ans = h[K-1] - h[0];
	for (int i=0; i<=N-K; i++) {
		int ans_tmp = h[i+K-1] - h[i];
		if (ans_tmp < ans) {
			ans = ans_tmp;
		}
		//cout << h[i+K-1] << " " << h[i] << " " << ans_tmp << endl;
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
import numpy as np
N = int(input())
A = list(map(int,input().split()))

npA = np.sort(A)

ans = 0
while len(npA) > 0 and N >= npA[0]:
    i = np.min(npA)
    tmp = np.sum(npA == i)
    if tmp > i:
        ans += tmp - i
    elif tmp < i:
        ans += tmp
    npA = np.delete(npA, range(tmp))


print(ans + len(npA))


Measured memory_bytes: 23332
N,K= map(int,input().split())
P=list(map(int,input().split()))
mx=0
for i in range(K):
 mx+=(P[i]+1)/2
 now=mx
if N>K:
 for j in range(N-K):
  now=now+((P[K+j]+1)/2)-((P[j]+1)/2)
  mx=max(mx,now)
print(mx)

Measured memory_bytes: 71792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N,K;
  cin>>N>>K;
  ll c[N+1];
  ll ans=0;
  ll ma=0,mi=0;
  for(int i=0;i<=N;i++){
    ma+=N-i;
    mi+=i;
    c[i]=ma-mi+1;
  }
  for(int i=K-1;i<=N;i++){
    ans+=c[i];
    ans%=INF;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5068
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
const int maxn = 2e5+100;
int a[maxn];
int cmp(int x, int y)
{
    return x>y;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n ;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a+n, cmp);
    // for (int i = 0; i < n; ++i)
    //     cout << a[i] << " "; cout << endl;
    int i = 0,  now = 1;
    int t = 0;
    ll res = 0;
    while (t < n-1)
    {
        res += a[i];
        now = (now+1)%2;
        if (now == 0) i++;
        t++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4436
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 15 20:35:57 2019

@author: Yamazaki Kenichi
"""

S = input()

w = ["Sunny", "Cloudy", "Rainy"]
if S == "Sunny":
    print(w[1])
elif S == "Cloudy":
    print(w[2])
else:
    print(w[0])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll g, d, p, c;
    pair<int, int> pc[20];
    cin >> d >> g;
    rep(i, d){
        cin >> p >> c;
        pc[i] = make_pair(p, c);
    }

    ll res = inf;
    for(int bit=0; bit < (1<<d); bit++){
        ll cnt = 0;
        ll sum = 0;
        for(int i=0; i<d; i++){
            if(bit & (1<<i)){
                cnt += pc[i].first;
                sum += 100*(i+1)*pc[i].first + pc[i].second;
            }
        }
        if(sum >= g){
            res = min(res, cnt);
            continue;
        }
        for(int i=d-1; i>=0; i--){
            if(bit & (1<<i)) continue;
            ll psum = 0;
            while(psum < pc[i].first && sum < g){
                sum += 100*(i+1);
                psum++;
                cnt++;
            }
            //cout << bit sp sum sp cnt << endl;
            if(sum >= g){
                res = min(res, cnt);
                break;
            }
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define BUF_SIZE 20

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

#define NUM_MAX 100000

int main(void) {
    int queries;
    static int prime[NUM_MAX+1];
    static int cum[NUM_MAX+1];
    int i, j;
    for(i = 0; i < NUM_MAX+1; i++) prime[i] = 1;
    queries = get_int();
    // sieve of Eratosthenes
    for(i = 2; i <= NUM_MAX; i++) {
        int ulimit = NUM_MAX/i;
        // sieve (ja word as "furui")
        for(j = 2; j <= ulimit; j++) {
            prime[i*j] = 0;
        }
    }
    // calc. Note that i is odd nummer
    for(i = 3; i <= NUM_MAX; i+=2) {
        int half = (i+1)/2;
        cum[i] = (prime[i] && prime[half]);
    }

    // calc cumulative
    for(i = 1; i <= NUM_MAX; i++) {
        cum[i] = cum[i] + cum[i-1];
    }

#ifdef DEBUG
    for(i = 2; i <= 10; i++) { printf("%d:%d ", i, cum[i]); }
    putchar('\n');
#endif

    for(i = 0; i < queries; i++) {
        int l, r;
        get_int2(&l, &r); // [l, r]
        // 1-indexed -> 0-indexed
        l--; r--;
        // [l, r) -> [l, r+1]
        r++;
        printf("%d\n", cum[r] - cum[l]);
    }
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
    #include <algorithm>
    #define int long long
    using namespace std;
    
    signed main()
    {
    int ans = 0;
    int n, a, b;
    int x[100005];
    int now = 1;
    cin >> n;
    cin >> a >> b;
    for (int i = 0; i < n; i++) {
    cin >> x[i];
    }
    now = x[0];
    for (int i = 1; i < n; i++) {
    ans += min(a * (x[i] - now), b);
    now = x[i];
    }
    cout << ans << endl;
    return 0;
    }

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 998244353;

long long int A[110000], B[110000];
P p[110000], p2[110000];

int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	for(int i = 0; i < N; i++){
		cin >> B[i];
		p[i] = P(B[i], A[i]);
	}
	sort(A, A + N);
	sort(B, B + N);
	sort(p, p + N);
	for(int i = 0; i < N; i++){
		if(A[i] > B[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	for(int i = 1; i < N; i++){
		if(A[i] <= B[i - 1]){
			cout << "Yes" << endl;
			return 0;
		}
	}
	for(int i = 0; i < N; i++){
		p2[i] = P(p[i].second, i);
	}
	sort(p2, p2 + N);
	int pos = p2[0].second;
	int cnt = 0;
	while(pos != 0){
		cnt += 1;
		pos = p2[pos].second;
	}
	if(cnt == N - 1){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

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

int main(void){
  vector<int> a(5, 0);
  vector<int> b(5, 0);
  for(int i = 0; i < 5; i ++)
    cin >> a.at(i);

  int res = 0, maxel = 0;

  for(int i = 0; i < 5; i ++){
    int temp;
    if(a.at(i) % 10 != 0)
      temp = 10 - a.at(i)%10;
    else
      temp = 0;

    res += a.at(i) + temp; 

    maxel = max(maxel, temp);
  }

  cout << res - maxel << endl;

  return 0;
}


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

int main(void){
  int N;
  cin >> N;
  int p[100000];
  bool complete[100000];
  int sum;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    complete[i] = false;
  }

  bool end = false;
  while (end == false) {
    end = true;
    for (int i = 0; i < N; i++) {
      if (p[i] > 0) {
	end = false;
      }
      if (i < N) {
	if ((p[i] > 0) && (p[i+1] > 0)) {
	  p[i]--;
	} else if ((p[i] > 0) && (p[i+1] == 0)){
	  p[i]--;
	  sum++;
	}
      } else {
	if ((p[i-1] == 0) && (p[i] > 0)) {
	  p[i]--;
	  sum++;
	}
      }
    }
  }
  cout << sum << endl; 

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define cases int t; cin >> t; while (t--)
#define pb push_back
using namespace std;
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n; cin >> n;
    string a[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        sort(a[i].begin(), a[i].end());
    }
    ll cnt = 0;
    sort(a, a+n);
    for (ll i = 0; i < n-1; i++)
    {
        bool temp = false; ll d;
        for (ll j = i+1; a[j]==a[i]; j++) 
        {
            temp = true;
            d = j;
        }
        if (temp) 
        {
            for (int j = 0; j<=(d-i);j++) cnt += j;
            i = d;
        }
        
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 5760
n=int(input())
txy=[[int(i) for i in input().split()] for j in range(n)]

x=0
y=0
ans=True
for i in range(n):
    if abs(txy[i][1]-x)+abs(txy[i][2]-y)<=txy[i][0] and (txy[i][0]-(abs(txy[i][1]-x)+abs(txy[i][2]-y)))%2==0:
        ans=True
    else:
        ans=False
        break
print('Yes' if ans else 'No')

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

#define ll long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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 gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    //COMint();
    ll X;cin>>X;
    ll Y;cin>>Y;
    ll ans;
    if(X%Y==0){
        ans=-1;
        print(ans);
        return 0;
    }else{
        if(Y==1){
            ans=-1;
            print(ans);
            return 0;
        }
        if((lcm(X,Y)-X)%Y>0){
            //debug(lcm(X,Y));
            ans=lcm(X,Y)-X;
            if(ans<0){
                ans=ans+lcm(X,Y);
            }
            print(ans);
            return 0;
        }else{
            ans=-1;
            print(ans);
            return 0;

        }
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoderBeginner155
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int N = Convert.ToInt32(line);
            
            line = Console.ReadLine();
            var data = line.Split(new char[] { ' ' });
            int[] nums = data.Select(i => Convert.ToInt32(i)).ToArray();
            bool isDenied = false;
            for (int i = 0; i < N; i++)
            {
                if (nums[i] % 2 != 0) { continue; }
                if (nums[i] % 3 != 0 && nums[i] % 5 != 0)
                {
                    isDenied = true;
                }
            }
            if (isDenied)
            {
                Console.WriteLine("DENIED");
            }
            else
            {
                Console.WriteLine("APPROVED");
            }
        }
    }
}


Measured memory_bytes: 13268
//14:54
#include <stdio.h>
#include <queue>

using namespace std;

typedef pair<int,int> P;

int h, w, n;
char field[1000][1001];
queue<P> qu;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int d[1000][1000];


void init(){
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      d[i][j] = -1;
    }
  }
  queue<P> empty;
  swap(qu,empty);
}

int solve(){
  int hp = 1;
  int cnt;
  init();
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(field[i][j] == 'S'){
        qu.push(P(i,j));
        d[i][j] = 0;
      }
    }
  }
  while(qu.size()){
    P p = qu.front();
    qu.pop();
    int y = p.first;
    int x = p.second;
    if(hp == n + 1)
      return d[y][x];
    if(hp == field[y][x] - '0'){
      hp++;
      cnt = d[y][x];
      init();
      d[y][x] = cnt;
    }
    for(int i = 0; i < 4; i++){
      int ny = y + dy[i];
      int nx = x + dx[i];
      if(ny >= 0 && ny < h && nx >= 0 && nx < w && field[ny][nx] != 'X' && d[ny][nx] == -1){
        d[ny][nx] = d[y][x] + 1;
        qu.push(P(ny,nx));
      }
    }
  }
  return 0;
}

int main(){
  scanf("%d %d %d", &h, &w, &n);
  for(int i = 0; i < h; i++){
    scanf("%s", field[i]);
  }
  printf("%d\n", solve() - 1);
  return 0;
}

Measured memory_bytes: 7512
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-13 12:11:29
**/

#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n; string s; cin >> s;

  int64 ans = 0;

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (s[i] == s[j]) continue;
      for (int k = j + 1; k < n; ++k) {
        if (s[j] != s[k] && s[i] != s[k] && j - i != k - j) ++ans;
      }
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3648
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = [0] * M
y = [0] * M
c = [0] * M
discount = []
for i in range(M):
    x[i], y[i], c[i] = map(int, input().split())
    d = a[x[i] - 1] + b[y[i] - 1] - c[i]
    discount.append(d)
normal = min(a) + min(b)
print(min([normal, min(discount)]))


Measured memory_bytes: 27348
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

using namespace std;

int main() {
  long long n;
  cin >> n;
  long long l[100] = {0};
  l[0] = 2;
  l[1] = 1;
  for(int i = 2; i < 100; i++) l[i] = l[i - 1] + l[i - 2];
  cout << l[n] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String s = sc.next();
		String c= sc.next();
		a = a.substring(0,1);
		s = s.substring(0,1);
		c = c.substring(0,1);
			System.out.println(a + s + c);		
	}
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, ll>a,pair<ll,ll>b)
{
    return a.fi>=b.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll n,m; cin>>n>>m;
ll k; cin>>k;
vi arr(n);
rep(i,0,n)cin>>arr[i];
vi brr(m);
rep(i,0,m)cin>>brr[i];
vi prefa(n),prefb(m);
prefa[0] = arr[0];
prefb[0] = brr[0];
rep(i,1,n)prefa[i] = prefa[i-1] +arr[i];
rep(i,1,m)prefb[i] = prefb[i-1]+ brr[i];
ll ans = 0;
rep(i,0,n)
{

    ll temp = i+1;
    ll res = k - prefa[i];
    ll l = 0,r = m-1;
    ll pos = -1;
    while(l<=r)
    {
        ll mid = l+(r-l)/2;
        if(prefb[mid]<=res)
        {
            pos = mid;
            l = mid+1;
        }
        else r = mid - 1;
    }
    if(res>=0)ans = max(ans,temp+pos+1);
}
ll l = 0,r = m-1;
ll pos = -1;
while(l<=r)
{
    ll mid = l+(r-l)/2;
    if(prefb[mid]<=k)
    {
        pos = mid;
        l = mid+1;
    }
    else r = mid - 1;
}
ans = max(ans,pos+1);
cout<<ans<<endl;
return 0;
}
/*
1
8
1 7 3 4 7 6 2 9
*/


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

int A, B, K;

int main() {
    cin >> A >> B >> K;

    int th = 0;
    int ans = 0;
    for (int i = min(A, B); i >= 1; i--) {
        if (A % i == 0 && B % i == 0) {
            // cout << i << endl;
            th++;
        }

        if (th == K) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
def q4():
    import math
    A, B, N = (int(i) for i in input().split())
    x = B - 1 if N >= B else N
    ans = math.floor(x*A//B) - A * math.floor(x//B)
    return ans


if __name__ == '__main__':
    ans = q4()
    print(ans)


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int h[N];
  int ans=0;
  for (int i=0;i<N;i++){
    cin >> h[i];
    if(h[i]>=K) ans++;
  }
  cout << ans;
}


Measured memory_bytes: 640