akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, M := sc.nextInt(), sc.nextInt()
	G := make([][]int, N)
	for i := 0; i < M; i++ {
		s, t := sc.nextInt(), sc.nextInt()
		G[s] = append(G[s], t)
		G[t] = append(G[t], s)
	}
	group := make([]int, N)
	for i := 0; i < N; i++ {
		group[i] = -1
	}
	var dfs func(cur int)
	dfs = func(cur int) {
		for i := 0; i < len(G[cur]); i++ {
			next := G[cur][i]
			if group[next] == -1 {
				group[next] = group[cur]
				dfs(next)
			}
		}
	}
	num := 0
	for i := 0; i < N; i++ {
		if group[i] == -1 {
			group[i] = num
			dfs(i)
			num++
		}
	}

	Q := sc.nextInt()
	for i := 0; i < Q; i++ {
		s, t := sc.nextInt(), sc.nextInt()
		if group[s] == group[t] {
			fmt.Fprintln(wtr, "yes")
		} else {
			fmt.Fprintln(wtr, "no")
		}
	}
	wtr.Flush()
}



Measured memory_bytes: 20688
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# define MOD 1000000000+7
# define INF 1000000000
using namespace std;


int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += i;
		if (ans >= n) {
			cout << i << endl;
			break;
		}
	}
}


Measured memory_bytes: 256
fun main() {
    val l = readLine()!!.split(" ")
    val n = l[0].toInt()
    val k = l[1].toLong()
    val array = readLine()!!.split(" ").map { it.toInt() - 1}
    val flags = Array(n){-1L}
    var current = 0
    var mod = 0L
    var remain = 0L
    for(i in 0..k-1){
        if(flags[current]!=-1L){
            mod = i-flags[current]
            remain = k-i
            break
        }
        flags[current] = i
        current = array[current]
    }
    if(mod==0L){
        println(current+1)
        return
    }
    val x = remain%mod
    if(x==0L) {
        println(current+1)
    }else{
        for(i in 0..x-1) {
            current = array[current]
        }
        println(current+1)
    }
}

Measured memory_bytes: 64772
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
using namespace std;
char s[1005];
int main(){
	cin>>s;
	printf("2018");
	for(int i=4;i<strlen(s);i++) printf("%c",s[i]);
	printf("\n");
	return 0;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B >= C) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef long long LL;

int main(void) {

    int n, m, l;
    scanf("%d %d %d", &n, &m, &l);

    int A[100][100];
    int B[100][100];
    LL C[100][100];

    int i, j, k;

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

    //B
    for (i = 0; i < m; ++i) {
        for (j = 0; j < l; ++j) {
            scanf("%d", &B[i][j]);
        }
    }

    //C: multiply
    for (i = 0; i < n; ++i) {
        for (j = 0; j < m; ++j) {
            for (k = 0; k < l; ++k) {
                C[i][k] += A[i][j] * B[j][k];
            }
        }
    }

    for (i = 0; i < n; ++i) {
        for (j = 0; j < l - 1; ++j) {
            printf("%lld ", C[i][j]);
        }
        printf("%lld\n", C[i][l - 1]);
    }

    return 0;
}

Measured memory_bytes: 756
n,k = map(int, open(0).read().split())

ans = 0

for b in range(k+1, n+1):
    c = n//b*(b-k)
    if k:
        d = max(0, n%b-k+1)
    else:
        d = n%b
    ans += c
    ans += d

print(ans)

Measured memory_bytes: 9136
#include<stdio.h>
#include<string.h>
int main(){
  int n,m,c,i,j,k,b;
  char s[100];
  while(scanf("%d %d",&n,&m),n||m){
    int f[1000]={0};
    b=0;
    for(i=1;i<=m;i++){//printf("%d ",b+1);
      scanf("%s",s);
      if(i%15==0){
	if(strcmp(s,"FizzBuzz\0"))f[b]=1;
      }
      else if(i%3==0){
	if(strcmp(s,"Fizz\0"))f[b]=1;
      }
      else if(i%5==0){
	if(strcmp(s,"Buzz\0"))f[b]=1;
      }
      else{
	for(k=c=0;s[k];k++){
	  c*=10;
	  c+=s[k]-'0';
	}//printf("%d\n",c);
	if(i-c)f[b]=1;
      }
      for(j=1;f[(b+j)%n];j++);
      if(j%n==0)break;
      b=(b+j)%n;
    }
    while(i++<m)scanf("%*s");
    for(i=j=0;i<n;i++){
      if(f[i]==0){
	if(j)printf(" ");
	printf("%d",i+1);
	j=1;
      }
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;scanf("%lld",&n);
    if(n&1){cout<<0<<endl;return 0;}
    ll ans=0;
    while(n)
    {
        n/=5;ans+=n/2;
    }
    printf("%lld\n",ans);
}


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

int main() {
    string S; cin >> S;
    int N=S.size();
    for (int i=N;i>=1;i--){
        for (int j=0;j<N-i+1;j++){
            string tmp=S.substr(j,i);
            for (int k=0;k<i;k++){
                char x = tmp[k];
                if (x!='A'&&x!='C'&&x!='G'&&x!='T') break;
                else if (k==i-1) {
                    cout << i << endl;
                    return 0;
                }
            }
        }
    }
    cout << "0" << endl;
    return 0;
}


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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    REP(i,N) cin>>A[i];

    ll ans=0;
    ll sum=0;
    ll r=0;
    REP(l,N){
        while(r<N&&sum+A[r]==(sum^A[r])){
            sum+=A[r];
            r++;
        }

        if(r==l) r++;
        else{
            sum-=A[l];
        }

        ans+=(r-l);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4796
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
   string S;
   cin >> S;

   bool issteped = true;

   for (int i = 0; i < S.size(); i++)
   {
      if(i % 2 == 0)
      {
         if(S[i] != 'R' && S[i] != 'U' && S[i] != 'D')
            issteped = false;
      }
      else
      {
         if(S[i] != 'L' && S[i] != 'U' && S[i] != 'D')
            issteped = false;
      }
   }
   if(issteped)
   {
      cout << "Yes" << endl;
   }else
   {
      cout << "No" << endl;
   }
   
   
   return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	if ((b - a) % 2) {
		printf("Borys\n");
	} else {
		printf("Alice\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  string s;
  cin >> s;
  int sum=0;
  rep(i,0,6)
    if(s[i] == '1')
      sum++;

  cout << sum << endl;
  ret 0;
}

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

using namespace std;

int main( ) {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,a,b;
	t = 1;
	while(t--) {
	 cin >> a >> b;
	 if((a % 12 == 4 || a % 12 == 6 || a % 12 == 9 || a % 12 == 11) && (b % 12 == 4 || b % 12 == 6 || b % 12 == 9 || b % 12 == 11))
	  cout << "Yes" << endl;
	 else if((a % 12 == 1 || a % 12 == 3 || a % 12 == 5 || a % 12 == 7 || a % 12 == 8 || a % 12 == 10 || a == 12) && (b % 12 == 1 || b % 12 == 3 || b % 12 == 5 || b % 12 == 7 || b % 12 == 8 || b % 12 == 10 || b == 12))
	  cout << "Yes" << endl;
	 else
	  cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main (){
	long long N,L[90];
	while(~scanf("%lld",&N)){
		L[0] = 2;
		L[1] = 1;
		for(int i = 2;i <= N;i++){
			L[i] = L[i - 1] + L[i - 2];
		}
		printf("%lld\n",L[N]);
	}
	return 0;
}
		

Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

s = input()
if "RRR" in s:
    print(3)
elif "RR" in s:
    print(2)
elif "R" in s:
    print(1)
else:
    print(0)


Measured memory_bytes: 68064
#include <iostream>
#include <string>
using namespace std;
int c[8];
class DICE{
  public:
  void setdice(char a);
};
void DICE::setdice(char a){
  if(a=='S'){
      c[7]=c[1];
      c[1]=c[5];
      c[5]=c[6];
      c[6]=c[2];
      c[2]=c[7];
  }
  else if(a=='W'){
      c[7]=c[1];
      c[1]=c[3];
      c[3]=c[6];
      c[6]=c[4];
      c[4]=c[7];
  }
  else if(a=='N'){
      c[7]=c[1];
      c[1]=c[2];
      c[2]=c[6];
      c[6]=c[5];
      c[5]=c[7];
  }
  else{
      c[7]=c[1];
      c[1]=c[4];
      c[4]=c[6];
      c[6]=c[3];
      c[3]=c[7];
  }
}
int main(void){
  DICE dice;
  int n,a,b;
  for(int i=1;i<=6;i++){
      cin>>c[i];
  }
  cin>>n;
  for(int i=0;i<n;i++){
      cin>>a>>b;
      if(a==c[3] || a==c[4]){
          while(c[1] !=a) dice.setdice('E');
      }
      else{
          while(c[1] !=a) dice.setdice('S');
      }
      dice.setdice('N');
      while(c[1] !=b) dice.setdice('W');
      dice.setdice('S');
      cout<<c[3]<<endl;
  }
}


Measured memory_bytes: 3084
#include <stdio.h>
int main(){
int a,b,c,d,e,f;
scanf("%d %d %d",&a,&b,&c);
d=10*a+b+c;
e=10*b+a+c;
f=10*c+a+b;
if (d>e & d>f){
printf("%d",d);}
else if (e>f){
printf("%d",e);}
else {
printf("%d",f);}
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int isLeap(int y) {
  if(y%4==0) {
    if(y%400==0) return 1;
    else if(y%100==0) return 0;
    return 1;
  } else return 0;
}

main() {
  int fst=0;
  int cnt;
  int i,a,b;
  while(scanf("%d %d",&a,&b),a!=0&&b!=0) {
    if(!fst) fst++;
    else puts("");
    cnt=0;
    for(i=a;i<=b;i++) {
      if(isLeap(i)) {printf("%d\n",i);cnt++;}
    }
    if(cnt==0) puts("NA");
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <string>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

constexpr long long mod = 1e9 + 7;

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	long long all_seq = 1;
	long long all_seq_without_09 = 1, all_seq_without_0 = 1;
	for (int i = 1; i <= n; ++i) {
		all_seq = (all_seq * 10) % mod;
		all_seq_without_09 = (all_seq_without_09 * 8) % mod;
		all_seq_without_0 = (all_seq_without_0 * 9) % mod;
	}

	all_seq_without_0 *= 2;
	all_seq_without_0 %= mod;
	all_seq_without_0 = ((all_seq_without_0 - all_seq_without_09) + mod) % mod;

	cout << ((all_seq - all_seq_without_0) + mod) % mod << "\n";

	return 0;

}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  rep(i, n) cin >> a[i];
  rep(i, n) mp[a[i]]++;

  int ans = 0;
  for(auto p: mp){
    int x = p.first;
    int n = p.second;
    if(n < x) ans += n;
    else ans += n - x;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];

    unordered_map<ll, ll> m;
    ll prev = 0;
    m[prev]++;
    REP(i, 0, N) {
        prev += A[i];
        m[prev]++;
    }

    ll ans = 0;
    for (auto elm : m) ans += elm.second * (elm.second - 1) / 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9288
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef double db;
typedef long long li;
typedef long double ld;

typedef pr<int, int> ii;
typedef pr<ld,ld> dd;

typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;

typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;

typedef set<int> s_i;
typedef set<char> s_c;

const int MOD = 998244353;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
bool vs[200005];
int dp[200005];
int en[200005];
vi G[200005];
struct it
{
	vector<int> arr;
	void build(int n)
	{
		arr.assign(4*n+5, INT_MIN);
	}
	void update(int id, int l, int r, int pos, int val)
	{
		if(pos<l or r<pos) return;
		if(l==r and l==pos) arr[id]=val;
		else if(l!=r)
		{
			update(2*id, l, (l+r)/2, pos, val);
			update(2*id+1, (l+r)/2+1, r, pos, val);
			arr[id]=max(arr[2*id], arr[2*id+1]);
		}
	}
	int get(int id, int l, int r, int L, int R)
	{
		if(R<l or r<L) return INT_MIN;
		if(L<=l and r<=R) return arr[id];
		return max(get(2*id, l, (l+r)/2, L, R), get(2*id+1, (l+r)/2+1, r, L, R));
	}
};
int dfs(int u)
{
	vs[u]=1;
	int ans=1;
	for(auto v: G[u])
	{
		ans=ans*dfs(v)%MOD;
	}
	ans=(ans+1)%MOD;
	return ans;
}
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	int n;
	cin>>n;
	it IT;
	IT.build(n);
	vii v(1);
	for(int i=1; i<=n; i++)
	{
		int a, d;
		cin>>a>>d; d=d+a-1;
		v.eb(a, d);
	}
	sort(begin(v)+1, end(v));
	for(int i=n; i>=1; i--)
	{
		int l=i, r=n;
		while(l<r)
		{
			int mid=(l+r+1)/2;
			if(v[mid].fi<=v[i].se) l=mid;
			else r=mid-1;
		}
		dp[i]=max(i, IT.get(1, 1, n,  i, l));
		IT.update(1, 1, n, i, dp[i]);
		en[dp[i]]++;
	}
	stack<int> st;
	for(int i=1; i<=n; i++)
	{
		if(!st.empty()) G[st.top()].eb(i);
		st.push(i);
		while(en[i]--)
		{
			st.pop();
		}
	}
	int ans=1;
	for(int i=1; i<=n; i++)
	{
		if(!vs[i]) ans=ans*dfs(i)%MOD;
	}
	while(ans<0) ans+=MOD;
	cout<<ans;
}
/*
8
-59 27
34 20
69 4
-22 38
62 24
5 25
-19 27
61 11
*/



Measured memory_bytes: 37908
#include<cstdio>
#include<cstring>
#include<algorithm>
int X1,Y1,X2,Y2;
int main()
{
    scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
    printf("%d %d %d %d\n",X2-(Y2-Y1),Y2-(X1-X2),X1-(Y2-Y1),Y2-(X1-X2)-(Y2-Y1));
}


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

int main(){
  int a,b,c,t;
  int bells[3]={a,b,c};

  cin >> a >> b >> c;
  
  if ( a > b ) { t=a; a=b; b=t;}
  if ( b > c ) { t=b; b=c; c=t;}
  if ( a > b ) { t=a; a=b; b=t;}
 
  cout << a+b << endl;

 return 0;
}

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

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>


using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll INFLL = 1LL<<62;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

string s;
string a = "AKIHABARA";
int idx[4] = {0, 4, 6, 8};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    int n = s.size();
    if (n > 9) {
        cout << "NO" << endl;
        return 0;
    }
    if (n == 9) {
        if (s == "AKIHABARA") {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
        return 0;
    } 
    rep(i, 1<<4) {
        string tmp;
        bool check[9] = {};
        rep(j, 4) {
            if (i>>j & 1) {
                check[idx[j]] = true;
            }
        }
        rep(j, 9) {
            if (check[j]) continue;
            tmp += a[j];
        }
        if (s == tmp) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <vector>

#define REP(a, b) for (int a = 0; a < b; a++)
#define FORU(a, b, c) for (int a = b; a <= c; a++)
#define FORD(a, b, c) for (int a = b; a >= c; a--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;

int main() {
	int n, maks = 0, tot = 0, arr[15];

	scanf("%d", &n);

	REP(i, n) {
		scanf("%d", &arr[i]);

		tot += arr[i];
		maks = max(maks, arr[i]);
	}

	tot -= maks;

	if (maks < tot) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;	
}


Measured memory_bytes: 128
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0

for i in range(n):
    a=list(map(int,input().split()))
    k=c
    for j in range(m):
        k+=a[j]*b[j]
    if(k>0):
        ans+=1

print(ans)

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<vector<long long>> mll;
typedef vector<pair<long long, long long>> vpl;
typedef pair<long long, long long> pll;
#define minimize(var, val) (var = min((val), var))
const long long MOD = 1e9 + 7;

template <typename Type>
class Matrix {
   public:
    long long rows, cols;
    vector<vector<Type>> mat;

    Matrix(long long n, bool identity = true) {
        this->rows = n;
        this->cols = n;
        mat = vector<vector<Type>>(n, vector<Type>(n, 0));
        if (identity) {
            for (int i = 0; i < this->rows; i++)
                mat[i][i] = 1;
        }
    }
    Matrix(long long n, long long m) {
        this->rows = n;
        this->cols = m;
        mat = vector<vector<Type>>(n, vector<Type>(m, 0));
    }
    Matrix(vector<vector<Type>> m) {
        this->rows = m.size();
        this->cols = rows > 0 ? m[0].size() : 0;
        this->mat = m;
    }
    friend vector<Type> operator*(Matrix<Type> x, vector<Type> y) {
        vector<Type> res(y.size());
        assert(x.cols == y.size());
        for (int i = 0; i < x.cols; i++) {
            for (int j = 0; j < x.rows; j++) {
                res[i] = x[i][j] * y[j];
            }
        }
        return res;
    }
    friend Matrix<Type> operator*(Matrix<Type> x, Matrix<Type> y) {
        assert(x.cols == y.rows);
        Matrix res(x.rows, y.cols);
        for (int i = 0; i < x.rows; i++) {
            for (int j = 0; j < y.cols; j++) {
                for (int k = 0; k < x.cols; k++) {
                    res.mat[i][j] =
                        (res.mat[i][j] + x.mat[i][k] * y.mat[k][j]) % MOD;
                }
            }
        }
        return res;
    }
    friend Matrix<Type> operator^(Matrix<Type> mat, long long pow) {
        Matrix<Type> cumulative = mat, result(mat.rows, true);
        for (; pow > 0; pow /= 2) {
            if (pow & 1)
                result = result * cumulative;
            cumulative = cumulative * cumulative;
        }
        return result;
    }
};

int main() {
    ll n, k;
    cin >> n >> k;
    Matrix<ll> dp(n, false);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> dp.mat[i][j];
    dp = dp ^ k;
    ll ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans = (ans + dp.mat[i][j]) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 384
n = int(input())
marchSentence = ["M", "A", "R", "C", "H"]
marchCount = [0, 0, 0, 0, 0]
marchSum = 0
for i in range(n):
    s = input()
    if marchSentence.count(s[0]) > 0:
        num = marchSentence.index(s[0])
        if num > -1:
            marchCount[num] += 1

for a in range(0, 3):
    for b in range(a + 1, 4):
        for c in range(b + 1, 5):
            marchSum += marchCount[a] * marchCount[b] * marchCount[c]
print(marchSum)


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

int main(){
  char s;
  cin >> s;
  if(s-'a'>=0) cout << 'a' << "\n";
  else cout << 'A' << "\n";
  
  return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_

#define BIG 10000000000 //10

#define LAST 10000000 //10^7


LONG D;
vector<LONG> cost(26);
//vector<vector<ULONG>> sati(D + 1, vector<ULONG>(27));
vector<vector<LONG>> sati;
vector<LONG> answer;
vector<int> lastDate(26, -1);
LONG satVal = 0;


LONG calcSabunScore(int eventType, LONG date) {

	LONG sabun = sati[date][eventType];
	// costsum
	LONG costSum = 0;
	for (int i = 0; i < 26; i++) {
		if (i != eventType) {
			costSum += cost[i] * (date - lastDate[i]);
		}
	}

	sabun -= costSum;
	

	return sabun;

}


int main(void) {
	// for A

	cin >> D;

	vector<LONG> tmpans(D);
	answer = tmpans;


	for (int i = 0; i < 26; i++) {
		cin >> cost[i];
	}



	for (int d = 0; d < D; d++) {
		vector<LONG> tmpsati(26);
		for (int i = 0; i < 26; i++) {
			cin >> tmpsati[i];
		}
		sati.push_back(tmpsati);
	}
	// finish data input


	// answerを決める
	LONG totalScore = 0;
	for (int d = 0; d < D; d++) {
		int maxI = 0;
		LONG maxsabun = -1000000;
		for (int i = 0; i < 26; i++) {
			LONG sabun = calcSabunScore(i, d);
			if (sabun > maxsabun) {
				maxsabun = sabun;
				maxI = i;
			}
		}
		answer[d] = maxI;
		lastDate[maxI] = d;

		totalScore += maxsabun;

	}

	//randomchange
	int changeAtOnce = 3;
	int numChange = 150000;


	for (int c = 0; c < numChange; c++) {
		vector<LONG> answer2(D);

		for (int d = 0; d < D; d++)answer2[d] = answer[d];

		for (int cao = 0; cao < changeAtOnce; cao++) {
			int date = rand() % D;
			int newEvent = rand() % 26;

			answer2[date] = newEvent;
		}

			LONG totalScore2 = 0;

			// calc score
			for (int i = 0; i < 26; i++)lastDate[i] = -1;
			for (int d = 0; d < D; d++) {
				LONG sabun = calcSabunScore(answer2[d], d);
				totalScore2 += sabun;
				lastDate[answer2[d]] = d;
			}

			// これがよさそうならこれにする
			if (totalScore2 > totalScore) {
				totalScore = totalScore2;
				for (int d = 0; d < D; d++)answer[d] = answer2[d];
			}

		
	}


	// output
	for (int d = 0; d < D; d++) {
		cout << answer[d] + 1 << endl;
	}

	return 0;
}



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

int main() {
    long long r, d, x[15];
    cin >> r >> d >> x[0];
    for (int i = 1; i <= 10; i++) {
        x[i] = x[i - 1] * r - d;
    }
    for (int i = 1; i <= 10; i++) {
        cout << x[i] << endl;
    }
    return 0;
}

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

using pp = pair<int, int>;
int N, M;
vector<vector<pp>> G;
vector<int> u, v;

bool dfs(int u, int p, int v, long long &path) {
    if(u == v) {
        path = 0;
        return true;
    }
    for(auto e : G[u]) {
        if(e.first == p) continue;
        if(dfs(e.first, u, v, path)) {
            path |= (1LL << e.second);
            return true;
        }
    }
    return false;
}

long long solve() {
    vector<long long> path(M, 0);
    for(int i=0; i<M; ++i) dfs(u[i], -1, v[i], path[i]);
    
    long long res = 0;
    for(int k=0; k<(1<<M); ++k) {
        long long vacant = 0;
        for(int i=0; i<M; ++i) {
            if(k & (1 << i)) vacant |= path[i];
        }
        long long cnt = N - 1 - __builtin_popcountll(vacant);
        if(__builtin_popcount(k) % 2 == 0) res += (1LL << cnt);
        else res -= (1LL << cnt);
    }
    return res;
}

int main() {
    cin >> N;
    G.resize(N);
    for(int i=0; i+1<N; ++i) {
        int a, b; cin >> a >> b;
        --a; --b;
        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
    }
    cin >> M;
    u.resize(M); v.resize(M);
    for(int i=0; i<M; ++i) {
        cin >> u[i] >> v[i];
        --u[i]; --v[i];
    }
    cout << solve() << '\n';
}

Measured memory_bytes: 256
A, B, C = sorted(map(int, input().split()))
num = 0
if (C - A) % 2 == 0:
    num += (C - A) // 2
    if (C - B) % 2 == 0:
        num += (C - B) // 2
    else:
        num += (C - B) // 2
        num += 2
else:
    num += (C - A) // 2
    if (C - B) % 2 == 0:
        num += (C - B) // 2
        num += 2
    else:
        num += (C - B) // 2
        num += 1
print(num)


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set> 
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define ii pair<int, int>
#define vii vector<ii>
#define f(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define sz(a) (int)(a).size()
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
int x[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int y[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 998244353, N = 2e5 + 5;
const double pi = acos(-1);

int arr[N], dp[N];

int main()
{
	assem99;

	int n; cin >> n;
	f(i, 0, n) cin >> arr[i];
	dp[0] = 0; dp[1] = abs(arr[1] - arr[0]);
	f(i, 2, n)
	{
		dp[i] = min(abs(arr[i - 1] - arr[i]) + dp[i - 1], abs(arr[i - 2] - arr[i]) + dp[i - 2]);
	}
	cout << dp[n - 1];

	return 0;
}

Measured memory_bytes: 1024
#                               #
    # author : samars_diary #
    # 13-09-2020 │ 12:41:59 #
#                               #

import sys, os.path

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    n,x,t=mii()
    print(t*(n//x)+t*(bool(n%x)))
solve()

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define int int64_t
#define pcnt __builtin_popcount
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define vec vector<int>
#define mat vector<vector<int>> //mat データ名(縦,vec(横));
int INF = 1000000000000000001; //10^18+1
int MOD = 1000000007; //10^9+7
//cout << fixed << setprecision(15); (小数点以下表示)

signed main () {
  string S;
  cin >> S;
  if(S=="ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
}

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

string s[233];
int t[233];
string X;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> s[i] >> t[i];
    }
    cin >> X;
    int ans = 0;
    for (int i = N - 1; i >= 0; --i) {
        if (s[i] == X) break;
        ans += t[i];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>

int main(void){

int a,b;

scanf("%d %d",&a,&b);

if(a<b){

printf("a < b\n");

}

if(a>b){

printf("a > b\n");

}

if(a==b){

printf("a == b\n");

}

return 0;

}

Measured memory_bytes: 580
#include <stdio.h>
#include <stdlib.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
typedef long long ll;

typedef struct {
	ll cost, cnt;
} Item;

ll n, m;
Item a[100005];

int cmp(const Item *a, const Item *b);

int main()
{
	ll ans = 0;
	ll drink = 0;

	scanf("%lld %lld", &n, &m);
	for (ll i = 0; i < n; i++) {
		scanf("%lld %lld", &a[i].cost, &a[i].cnt);
	}

	qsort(a, n, sizeof(Item), (int (*)(const void *, const void *))cmp);
	
	ll i = 0;
	while (drink < m) {
		if (drink + a[i].cnt <= m) {
			ans = ans + a[i].cost * a[i].cnt;
			drink = drink + a[i].cnt;
		} else {
			ll work = m - drink;
			ans = ans + a[i].cost * work;
			drink += work;
		}

		i++;
	}

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

	return 0;
}

int cmp(const Item *a, const Item *b)
{
	if (a->cost > b->cost) {
		return 1;
	} else if (a->cost == b->cost) {
		return 0;
	} else {
		return -1;
	}
}


Measured memory_bytes: 3324
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            Dictionary<int, int> T = new Dictionary<int, int>();
            var temp = A.OrderBy(a => a).ToArray();
            for (int i = 0; i < n; i++) T[temp[i]] = i;

            bool[] V = new bool[n];

            int s = A.Min();
            int result = 0;

            for (int i = 0; i < n; i++)
            {
                if (V[i]) continue;

                int cur = i;
                int sum = 0;
                int min = A[cur];
                int an = 0;

                while (!V[cur])
                {
                    V[cur] = true;
                    an++;

                    if (min > A[cur]) min = A[cur];
                    sum += A[cur];
                    cur = T[A[cur]];
                }
                result += Math.Min(sum + (an - 2) * min, min + sum + (an + 1) * s);
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 10296
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
using namespace std;
using ll = long long;
using graph = std::vector<std::vector<long long>>;
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll A,B,C;
    A = a[n - 1];
    ll M = 0;
    ll absm = 1ll << 50;
    ll half = (A % 2 == 0) ? A / 2 : (A + 1) / 2;
    for(int i = 0; i < n; i++) {
        if (abs(half - a[i]) < absm) {
            absm = abs(half - a[i]);
            //cout << absm;
            B = a[i];
        }
    }
    cout << A << " " << B << endl;

}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    ll aa = 0;
    rep(i, n) {
        cin >> a[i] >> b[i];
    }

    reverse(all(a));
    reverse(all(b));

    rep(i, n) {
        int num = ((a[i]+aa+b[i]-1)/b[i])*b[i]-a[i]-aa;
        aa += num;
    }

    cout << aa << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, A, B;
    cin >> N >> A >> B;
    ll temp1 = N % (A + B);
    ll temp2 = N / (A + B);
    cout << A * temp2 + min(temp1, A) << endl;
    return 0;
}


Measured memory_bytes: 3564
M, D = map(int, input().split())

ans = 0
if M == 1 or D < 20:
    print(0)
    quit()

for i in range(2, M+1):
    for j in range(21 , D+1):
        if i == (j // 10) * (j % 10) and j % 10 > 1:
            ans += 1
print(ans)

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

int main() {
  int x;
  cin >> x;
  if (400 <= x && x < 600)
    cout << 8 << endl;
  if (600 <= x && x < 800)
    cout << 7 << endl;
  if (800 <= x && x < 1000)
    cout << 6 << endl;
  if (1000 <= x && x < 1200)
    cout << 5 << endl;
  if (1200 <= x && x < 1400)
    cout << 4 << endl;
  if (1400 <= x && x < 1600)
    cout << 3 << endl;
  if (1600 <= x && x < 1800)
    cout << 2 << endl;
  if (1800 <= x && x < 2000)
    cout << 1 << endl;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(){
  int A,B,x,z,m;
  cin>>A>>B;
  z=A+B;
  x=A-B;
  m=A*B;
  if(z>=x&&z>=m){
    cout<<z;
  }
  else if(x>=z&&x>m){
    cout<<x;
  }
  else if(m>=x&&m>=z){
    cout<<m;
  }
return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

const debug = true

func main() {
	var N int
	fmt.Scan(&N)
	nums := scanNums(N)
	var sumsFromZero []int

	var sumsMax int
	sameNums := map[int]int{}

	sumsFromZero = append(sumsFromZero, nums[0])
	sameNums[nums[0]]++
	sameNums[0]++
	for i := 1; i < N; i++ {
		k := sumsFromZero[i-1] + nums[i]
		sumsFromZero = append(sumsFromZero, k)
		if sumsMax < sumsFromZero[i] {
			sumsMax = sumsFromZero[i]
		}
		sameNums[k]++
	}

	sumsFromZero = append([]int{0}, sumsFromZero...)

	sum := 0
	for _, v := range sameNums {
		sum += combination(v, 2)
	}

	fmt.Println(sum)
}

func combination(n, r int) (cmb int) {
	a := 1
	b := 1
	for i := 0; i < r; i++ {
		a *= n - i
		b *= r - i
	}
	return (a / b)
}

func scanNums(length int) (nums []int) {
	var num int
	for i := 0; i < length; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 20736
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <queue>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(VI::iterator it=(v).begin();it!=(v).end();++it)
#define MOD 1000000007


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

  VI A;
  REP(i, M) {
    int a;
    cin >> a;
    A.PB(a);
  }
  SORT(A);

  int dp[N+1];
  REP(i, N+1)
    dp[i] = 0;

  // queue<int> q;
  // q.push(0);
  // while (!q.empty()) {
  //   int p = q.front(); q.pop();
  //   VI::iterator it = lower_bound(ALL(A), p);
  //   if (it != A.end() && *it == p)
  //     continue;
  //   ++count[p];
  //   count[p] %= MOD;
  //   if (p > N)
  //     continue;
  //   q.push(p + 1);
  //   q.push(p + 2);
  // }
  dp[0] = 1;

  VI::iterator it = lower_bound(ALL(A), 1);
  if (it != A.end() && *it == 1)
    dp[1] = 0;
  else
    dp[1] = 1;

  FOR(i, 2, N + 1) {
    VI::iterator it = lower_bound(ALL(A), i);
    if (it != A.end() && *it == i)
      continue;
    dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
  }

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


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

N, Q = map(int, input().split())
a = [0]*(N) #1 index
b = [0]*(N) #1 index
p = [0]*(Q+1) #1 index
x = [0]*(Q+1) #1 index
counter = [0]*(N+1) #1 index
for i in range(1, N):
    a[i], b[i] = map(int, input().split())
for i in range(1, Q+1):
    p[i], x[i] = map(int, input().split())
    counter[p[i]] += x[i]

from collections import deque
graph = {i: deque() for i in range(1, N+1)}
for i in range(1, N):
    graph[a[i]].append(b[i])
    graph[b[i]].append(a[i])


def dfs(v):
    seen = [0]*(N+1)
    stack = []
    seen[v] = 1
    stack.append(v)
    while stack:
        s = stack[-1]
        if not graph[s]:
            stack.pop()
            continue
        g = graph[s].popleft()
        if seen[g]:
            continue
        seen[g] = 1
        stack.append(g)
        counter[g] += counter[s]

dfs(v=1)
print(*counter[1:])


Measured memory_bytes: 193492
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <ll , ll>;
void in(ll &x);
const ll N = 3050;
#define singleCase
// #define multipleCase
const ll M = 998244353;
ll n, s;
ll dp[N][N], a[N];

ll f(ll cur , ll rem) {
   if (cur > n) return rem == 0;
   ll &sol = dp[cur][rem];
   if (sol != -1) return sol;
   sol = 0;
   if (rem >= a[cur]) (sol += f(cur + 1 , rem - a[cur])) %= M;
   (sol += 2 * f(cur + 1 , rem)) %= M;
   return sol;
}

void work() {
   in(n); in(s);
   for (ll i = 1 ; i <= n ; i++) {
      in(a[i]);
   }
   memset (dp , -1 , sizeof dp);
   printf("%lld\n" , f(1 , s));
   return;
}

int main() {
   #ifdef multipleCase
      ll nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(ll &x) {
	bool neg = false;
	register ll c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 76528
#include <iostream>
using namespace std;
int main(){
  int K, T;
  cin >> K >> T;
  int A[T];
  for(int i = 0; i < T; ++i) cin >> A[i];
  int M = 1, m = 0;
  for(int i = 0; i < T; ++i){
    M = max(M,A[i]);
  }
  if(M <= (K+1)/2) cout << 0 << endl;
  else cout << M - (K-M+1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
string s;

int32_t main(){_
   
   cin >> s;

   bool yes = false;
   for (int i = 0; i < (int)(s.size()); ++i)
   {
      yes |= s[i] == '7';
   }

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

   return 0;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int w,a,b;
  cin >> w >> a >> b;
  if(min(a+w,b+w)-max(a,b) >=0){
	cout << 0 << endl;
	return 0;
  }else if(a+w < b){
	cout << b - a - w << endl;
  }else{
	cout << a - b - w << endl;
  }
}


Measured memory_bytes: 256
L,R=map(int,input().split())
if (R-L)>673:
    print(0)
else:
    ans=10000
    for i in range(L,R+1):
        for j in range(L,R+1):
            if i!=j and ans>((i*j)%2019):
                ans=((i*j)%2019)
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
typedef long long ll;
typedef long double ld;

ll power(ll base, ll exp){
    ll ans = 1;
    while(exp){
        if(exp&1) ans = (ans*base);
        base = (base*base);
        exp>>=1;
    }
    return ans;
}
 
int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    int n,p,a,x=0,y=0;
    cin>>n>>p;
    rep(i,0,n){
        cin>>a;
        if(a%2==0){
            x++;
        }
        else{
            y++;
        }
    }
    if(p==0){
        if(y==0){
            cout<<power(2,x+y)<<endl;
            return 0;
        }
        cout<<power(2,x+y-1)<<endl;
    }
    else{
        if(y==0){
            cout<<0<<endl;
            return 0;
        }
        cout<<power(2,x+y-1)<<endl;
    }
} 

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

int main(){
  char c;
  cin >> c;
  char a,o,e,u,i;
  if(c == 'a' || c == 'o' || c == 'e' || c == 'u' || c == 'i'){
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n%2 == 1){
    cout << "No" << endl;
  }
  else{
    int m = n/2;
    int c = 0;
    for(int i=0;i<m;i++){
      if(s.at(i) != s.at(i+m)){
        c = 1;
        break;
      }
    }
    if(c==0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;
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() {
    int N; cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];

    vector<int> dp(N, INF);
    dp[0] = 0;
    for (int i = 1; i < N; i++) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define MAXN 61

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

	long long n, i, j, k, x, MOD = 1000000007, ans, ct;
	cin >> n;
	ans = 0;
	vector<long long> p(MAXN), c0(MAXN, 0), c1(MAXN, 0), a(n + 1);
	for (i = 0; i < MAXN; i++) p[i] = 1LL << i;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
		for (j = 0; j < MAXN; j++) {
			if (a[i] & p[j]) c1[j]++;
			else c0[j]++;
		}
	}

	for (i = 0; i < MAXN; i++) {
		ct = (c0[i] * c1[i]) % MOD;
		ans = (ans + ct * (p[i] % MOD)) % MOD;;
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 2560