akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const int N = 2e6+5;

void solve(){
	int n;
	cin>>n;
	int a[n];
	map<int,int>cnt;
	rep(i,n){
		cin>>a[i];
		a[i]++;
		cnt[a[i]]++;
	}
	int ans=0;
	for(int i=1;i<=1e5+5;i++){
		umax(ans,cnt[i]+cnt[i-1]+cnt[i+1]);
	}
	cout<<ans;
}

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

Measured memory_bytes: 8668
def saidaikouyaku(a, b):
    if b > a:
        a, b = b, a

    while b != 0:
        a, b=b,(a%b)
    return a

A, B, C, D = map(int, input().split())
hani = B - A + 1
Cnum = B // C - (A - 1) // C
Dnum = B // D - (A - 1) // D
saisyoukoubai = C * D // saidaikouyaku(C, D)
koubainum = B // saisyoukoubai - int(A - 1) // saisyoukoubai
#print(hani)
#print(Cnum, Dnum, koubainum, saisyoukoubai)
print(hani - Cnum - Dnum + koubainum)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep1(i, n) for(ll i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

bool isPrime(ll a){
  if(a == 1) return false;
  if(a == 2) return true;
  if(a%2 == 0) return false;
  for(ll i=3;i*i<=a;i += 2){
    if(a%i == 0) return false;
  }
  return true;
}

int main(){
  ll n,p;
  cin >> n >> p;
  if(n == 1){
    cout << p << endl;
    return 0;
  }
  map<ll,ll> mp;
  ll range = p;
  for(ll i=2;i*i<=range;i++){
    if(i > p) break;
    if(!isPrime(i))continue;
    while(p%i == 0){
      mp[i] ++;
      p /= i;
    }
  }
  ll ans = 1;
  for(auto p : mp){
    while(p.second >= n){
      p.second -= n;
      ans *= p.first;
    }
  }
  cout << ans << endl;
}

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

int main(){
  
  string S; cin >> S;
  
  int cnt = 0;
  
  for(int i = 0 ; i < 3 ;i++){
    if(S[i] == '1'){
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	q := getNextInt(scanner)
	s := map[int]int{}
	for i := 0; i < q; i++ {
		t := getNextInt(scanner)
		x := getNextInt(scanner)
		switch t {
		case 0:
			s[x] = 1
			fmt.Fprintln(writer, len(s))
		case 1:
			fmt.Fprintln(writer, s[x])
		case 2:
			delete(s, x)
		}
	}
}



Measured memory_bytes: 13880
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c;
	if(a<b)  swap(a,b);
	if(a<c)  swap(a,c);
	if(b<c)  swap(b,c);
	cout<<a-c<<endl;
	return 0;
}

Measured memory_bytes: 256
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    fast;
	string a,b;cin>>a>>b;
	string g="";
	int n=b.length();
	for(int i=0; i<(n-1); i++)
		g+=b[i];
	
	if(g==a)
	{
		cout<<"Yes";
	}
	else
		cout<<"No";
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(void){
    int n,a[1001],i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=(n-1);i>=0;i--){
        if(i==0){
            printf("%d",a[i]);
        }
        else{
            printf("%d ",a[i]);
        }
    }
    printf("\n");


    return 0;
}

Measured memory_bytes: 1748
#include<stdio.h>

int a[21],n,m;

int es(int i,int m){
	if(!m) return 1;
	else if(i>=n) return 0;
	else return ((es(i+1,m))||(es(i+1,m-a[i])));
} 

int main(){
	int i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	scanf("%d",&k);
	for(i=0;i<k;i++){
		scanf("%d",&m);
		if(es(0,m)) printf("yes");
		else printf("no");
		printf("\n");
	}
}


Measured memory_bytes: 2760
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 998244353
inf = float("INF")
fact = [i for i in range(2 * 10 ** 5 + 1)]
fact[0] = 1
for i in range(2 * 10 ** 5):
    fact[i + 1] *= fact[i]
    fact[i + 1] %= mod
invfact = [None] * (2 * 10 ** 5 + 1)
invfact[-1] = pow(fact[-1], mod - 2, mod)
for i in range(2 * 10 ** 5, 0, -1):
    invfact[i - 1] = invfact[i] * i
    invfact[i - 1] %= mod
def combination_mod(n, k, mod):
    """ power_funcを用いて(nCk) mod p を求める """ 
    """ nCk = n!/((n-k)!k!)を使用 """
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = fact[n]
    b = invfact[k]
    c = invfact[n - k]
    return (a * b * c) % mod
#solve
def solve():
    n, m, k = LI()
    if m == 1:
        if n == k + 1:
            print(1)
            return

        else:
            print(0)
            return
    ans = 0
    tmp = m
    for i in range(n - 1):
        tmp *= m - 1
        tmp %= mod
    for i in range(k + 1):
        ans += tmp * combination_mod(n - 1, i, mod)
        tmp *= pow(m - 1, mod - 2, mod)
        tmp %= mod
        ans %= mod
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 96640
from operator import itemgetter

N, M = map(int, input().split())
PY = []

for i in range(M):
  PY.append([i, list(map(int,input().split())), 'x'])

PY.sort(key=itemgetter(1,2))
cnt_pref = {}

for i in range(M):  
  p, y = PY[i][1][0], PY[i][1][1]
  if (p in cnt_pref):
    cnt_pref[p] += 1
  else:
    cnt_pref[p] = 1
  PY[i][2] = str(p).zfill(6) + str(cnt_pref[p]).zfill(6)

PY.sort(key=itemgetter(0))
for i in PY:
  print(i[2])

Measured memory_bytes: 53088
#include<iostream>
using namespace std;
int main(){
	int n=0;cin>>n;
	int a[n]={0},b[n]={0},c[n]={0};
	long long p[n]={0};
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i]>>c[i];
		p[i]=(a[i]*a[i]+b[i]*b[i]-c[i]*c[i])*(b[i]*b[i]+c[i]*c[i]-a[i]*a[i])*(c[i]*c[i]+a[i]*a[i]-b[i]*b[i]);
		if(p[i]==0){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
	}
	return 0;
}
	

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

signed main(){
  int N,M;
  cin>>N>>M;
  cout<<(N-1)*(M-1)<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[2521];
const int MIN = 830;
const int MAX = 252;
vi a;
pii dfs(vi &a,int &p){
  if(p>=a.size()){
    return pii(0,99);
  }
  int po = a[p++];
  if(po==MIN){
    pii x = dfs(a,p);
    pii y = dfs(a,p);
    pii ret;
    ret.first = min(x.first,y.first);
    ret.second = min(x.second,y.second);
    return ret;
  }else if(po==MAX){
    pii x = dfs(a,p);
    pii y = dfs(a,p);
    pii ret;
    ret.first = max(x.first,y.first);
    ret.second = max(x.second,y.second);
    return ret;
  }else{
    return pii(po,po);
  }
}
int calc(vi &a){
  int x = a.back();
  pii tmp;
  int it;
  int ans;
  if(x<0){
    a.back() = -x;
    it = 0;
    tmp = dfs(a,it);
    if(tmp.second != tmp.first){
      a.back() = x;
      return -1;
    }
    int yes = tmp.first;
    a.back() = -x*10+9;
    it = 0;
    tmp = dfs(a,it);
    if(tmp.first != yes || tmp.second != yes){
      a.back() = x;
      return -1;
    }
    ans = tmp.first;
    a.back() = x;
  }else{
    it = 0;
    tmp = dfs(a,it);
    if(tmp.second != tmp.first)return -1;
    ans = tmp.first;
  }
  return ans;
}
void solve(){
  scanf("%s",s);
  n = strlen(s);
  a.clear();
  REP(i,n){
    char c = s[i];
    if(c=='_'){
      a.push_back(MIN);
    }else if(c=='^'){
      a.push_back(MAX);
    }else if(c=='('){
      // nothing
    }else if(c==',' || c=='?'){
      if(a.back()<0){
        a.back() = -a.back();
      }
    }else if(c==')'){
      // stack pop
      if(a.back()<0){
        a.back() = -a.back();
      }
      int x = a.back(); a.pop_back();
      int y = a.back(); a.pop_back();
      int op = a.back(); a.pop_back();
      if(op==MIN){
        a.push_back(min(x,y));
      }else if(op==MAX){
        a.push_back(max(x,y));
      }
    }else{
      int x = c-'0';
      if(a.size()>0 && a.back()<0){
        int y = -a.back(); a.pop_back();
        a.push_back(10*y + x);
      }else{
        a.push_back(-x);
      }
    }
    // check
    int k = calc(a);
    if(k!=-1){
      printf("%d %d\n",k,i+1);
      return;
    }
  }
}

int main(){
  int q;
  scanf("%d",&q);
  while(q--)solve();
  return 0;
}


Measured memory_bytes: 256
double p[333][333][333];
n;c[4];i,j,k;
main(a){
	for(;~scanf("%d",&a);)!n?n=a:c[a]++;
	for(k=0;k<=n;k++)for(j=0;j<=n;j++)for(i=0;i<=n;i++)
	{
		p[i][j][k]=i+j+k?(i*p[i?i-1:i][j][k]+j*p[i+1][j?j-1:j][k]+k*p[i][j+1][k?k-1:k]+n)/(i+j+k):0;
	}
	printf("%.9f",p[c[1]][c[2]][c[3]]);
}

Measured memory_bytes: 262144
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

const int MAX = 2000000;
vector<int> g[MAX];
int used[MAX];
int d[MAX];

bool dfs(int v) {
    used[v] = 1;
    for (auto u: g[v]) {
        if (used[u] == 1) return false;
        if (used[u] == 0) {
            if (dfs(u) == false) return false;
        }
    }
    used[v] = 2;
    return true;
}

void dfs2(int v) {
    if (d[v] > 0) return;
    if (g[v].size() == 0) {
        d[v] = 1;
        return;
    }
    for (auto u: g[v]) {
        dfs2(u);
        d[v] = max(d[v], d[u]+1);
    }
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n-1));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n-1; ++j) {
            int s = i, t;
            cin >> t;
            --t;
            if (s > t) swap(s, t);
            a[i][j] = (s << 10) | t;
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 1; j < n-1; ++j) {
            g[a[i][j-1]].push_back(a[i][j]);
        }
    }

    for (int i = 0; i < MAX; ++i) {
        if (used[i] == 0 && dfs(i) == false) {
            cout << -1 << endl;
            return 0;
        }
    }

    int ans = 1;
    for (int i = 0; i < MAX; ++i) {
        dfs2(i);
        ans = max(ans, d[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 82304
/*    Immediate gratification is a dream killer   */
#include<bits/stdc++.h>
using namespace std;
template <typename T>
void make_unique(vector<T>& vec) {
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()), vec.end());
}
#define ll long long
#define ld long double
#define endl '\n'
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,n) for(i=1;i<=n;i++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define rep(i, begin, end) for(i=begin;i<=end;i++)
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
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=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
}
const ll mod = 1000000007;
const ld PI = 3.141592653589793;
const int cons=100001;
ll N,M;
vl g[cons],vis(cons);
void dfs(ll node){
    vis[node]=1;
    for(ll child:g[node]){
        if(vis[child]==0){
            dfs(child);
        }
    }
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ll n=0,m=0,i=0,j=0,k=0,cnt=0,ans=0,sum=0,flag=0,pos=0,ind=0,mn=0,mx=0,res=0;
    cin>>N>>M;
    for(i=1;i<=M;i++){
        cin>>j>>k;
        g[j].pb(k);
        g[k].pb(j);
    }
    for(i=1;i<=N;i++){
        if(vis[i]==0){
            cnt++;
            dfs(i);
        }
    }
      cout<<cnt-1;  
        
    return 0;
}



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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int dfs(int x,int y,int H,int W,vector<vector<char>> &masu){
  if(masu[x][y] == '#'){

  }
}
bool palin(string S){
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
  string s;
  cin >> s;
  string ans;
  int N = s.size();
  rep(i,N){
    if(s[i] == '0') ans.push_back('0');
    else if(s[i] == '1') ans.push_back('1');
    else if(s[i] == 'B'){
      if(ans.size()) ans.pop_back();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    x: chars
    }
    println!("{}", if x[2]==x[3]&&x[4]==x[5] {"Yes"} else {"No"});
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string a, b, c;
    cin >> a >> b >> c;
    int posa, posb, posc;
    posa = posb = posc = 0;
    char turn = 'a';
    while(1) {
        if(turn == 'a') {
            if(posa == a.size()) {
                cout << "A" << endl;
                return 0;

            }
            turn = a[posa], posa++;
        
        }
        else if(turn == 'b') {
            if(posb == b.size()) {
                cout << "B" << endl;
                return 0;

            }
            turn = b[posb]; 
            posb++;
        }
        else {
            if(posc == c.size()) {
                cout << "C" << endl;
                return 0;
            }
            turn = c[posc]; posc++;
        }

    }

    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);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    System.out.printf("#");
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 63388
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),k=nxt();
    set <int> s;
    for(int i=0;i<10;i++)
        s.insert(i);
    for(int i=0;i<k;i++)
    {
        int x=nxt();
        s.erase(x);
    }
    int test=n;
    for(int i=n;i<100000;i++)
    {
        string x=to_string(i);
        bool f=1;
        for(int j=0;j<x.length();j++)
            if(s.count(x[j]-48)==0)
            {
                f=0;
                break;
            }
        if(f)
        {
            test=i;
            break;
        }
    }
    cout<<test<<endl;
    
    
    return 0;   
}


 
 


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

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

Measured memory_bytes: 3504
#include <iostream>
#include <algorithm>
#include <sstream>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <ctime>

#define X first
#define Y second
#define mp(x, y) make_pair(x, y)
#define pb(e) push_back(e)
#define rep(i, b, n) for (int i = (b); i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define each(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)

using namespace std;

typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef long long LINT;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef ostringstream OSS;
typedef vector<string> VS;

const int MAX_N = 24;
int N;
int color[MAX_N];
int ride[MAX_N];
int x[MAX_N];
int y[MAX_N];
int r[MAX_N];

bool isCollision ( int x1, int y1, int r1, int x2, int y2, int r2 )
{
	int xx = x1 - x2, yy = y1 - y2, rr = r1 + r2;
	return (xx * xx + yy * yy) < (rr * rr);
}

int dfs ( int state, int depth )
{
	if (depth == N/2) { return 0; }
	int res = 0;
	for (int i = 0; i < N; ++i) {
		if ((state & (1 << i)) && !(state & ride[i])) {
			for (int j = i+1; j < N; ++j) {
				if ((state & (1 << j)) && !(state & ride[j]) && color[i] == color[j]) {
					int next = state & ~((1 << i) | (1 << j));
					res = max(res, dfs(next, depth+1) + 2);
				}
			}
		}
	}
	return res;
}

char d[1 << MAX_N];

int main ( void )
{
	while (cin >> N, N) {
		fill(ride, ride+N, 0);
		rep (i, 0, N) {
			cin >> x[i] >> y[i] >> r[i] >> color[i];
			rep (j, 0, i) {
				if (isCollision(x[i], y[i], r[i], x[j], y[j], r[j])) {
					ride[i] |= (1 << j);
				}
			}
		}
		fill(d, d+(1 << N), -1);
		int state = (1 << N) - 1;
		char ans = 0;
		d[state] = 0;
		for (; state > 0; --state) {
			if (d[state] == -1) { continue; }
			rep (i, 0, N) {
				if (state & (1 << i) && !(state & ride[i])) {
					rep (j, i+1, N) {
						if (state & (1 << j) && !(state & ride[j]) && color[i] == color[j]) {
							int next = state & ~((1 << i) | (1 << j));
							d[next] = max<char>(d[next], d[state] + 2);
							ans = max<char>(ans, d[next]);
						}
					}
				}
			}
		}
		cout << (int)ans << endl;
		//cout << dfs((1 << N) - 1, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 17544
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(1, n - 1):
    if p[i] > min(p[i - 1], p[i + 1]) and p[i] < max(p[i - 1], p[i + 1]):
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a + b > c+d)
	{
		printf("Left\n");
	}
	if(a + b < c + d)
	{
		printf("Right\n");
	}
	if(a+b == c+d)
	{
		printf("Balanced\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int N;
int W;
long long dp[110][100100];
long long w[110];
long long v[110];

long long max(long long a, long long b)
{
	if (a > b)
		return a;
	return b;
}

int main(int argc, char const *argv[])
{
	scanf("%d%d", &N, &W);
	for (long long i = 0; i < N; i++)
		scanf("%lld%lld", w+i, v+i);

	for (long long i = 0; i < N; i++)
	{
		for (long long j = 0; j <= W; j++)
		{
			if (j - w[i] >= 0){
				dp[i+1][j] = max(dp[i][j - w[i]] + v[i], dp[i+1][j]);
			}

			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
		}
	}
	printf("%lld", dp[N][W]);
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

  vector<int> count(n + 1, 0);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    count.at(a)++;
  }
  sort(count.begin(), count.end());
  int c = 0;
  for (auto x : count) {
    if (x > 0) {
      c++;
    }
  }

  int ans = 0;
  int rem = c - k;
  for (auto x : count) {
    if (rem <= 0) {
      break;
    }
    if (x > 0) {
      ans += x;
      rem--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, i, j, k;
	char u[100][10];
	int p[100][11];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		for(j=0; j<10; j++){
			short U;
			scanf("%hd", &U);
			u[i][j]=U;
		}
	}
	for(i=0; i<n; i++){
		for(j=0; j<=10; j++){
			scanf("%d", &p[i][j]);
		}
	}
	int max = INT_MIN, now;
	for(i=1; i<(1<<10); i++){
		now=0;
		for(j=0; j<n; j++){
			int t=0;
			for(k=0; k<10; k++) if((i&(1<<k))!=0 && u[j][k]!=0) t++;
			now+=p[j][t];
		}
		if(now>max) max=now;
	}
	printf("%d\n", max);
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;


int main()
{
	int H=ty(),W=ty(),A=ty(),B=ty();

	for(int i=1;i<=B;i++)
	{
		for(int j=1;j<=A;j++)putchar('1');
		for(int j=A+1;j<=W;j++)putchar('0');
		puts("");
	}
	for(int i=B+1;i<=H;i++)
	{
		for(int j=1;j<=A;j++)putchar('0');
		for(int j=A+1;j<=W;j++)putchar('1');
		puts("");
	}

	return 0;
}


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

typedef long long long64;

long64 distance(long64 s, long64 t, long64 p)
{
	long64 d = abs(s - t);
	long64 d1 = abs(p - s);
	long64 d2 = abs(p - t);

	if (d1 < d2)
		return d1 + d;
	else
		return d2 + d;
}

int main()
{
	size_t s_num, t_num, p_num;
	std::cin >> s_num >> t_num >> p_num;

	std::vector<long64> s(s_num);
	std::vector<long64> t(t_num);
	std::vector<long64> p(p_num);

	for (size_t i = 0; i < s_num; i++)
	{
		std::cin >> s[i];
	}

	for (size_t i = 0; i < t_num; i++)
	{
		std::cin >> t[i];
	}

	for (size_t i = 0; i < p_num; i++)
	{
		std::cin >> p[i];
	}

	std::sort(s.begin(), s.end());
	std::sort(t.begin(), t.end());

	for (size_t i = 0; i < p.size(); i++)
	{
		long64 min_s = abs(s[0] - p[i]);
		size_t index_s = 0;
		long64 min_s_l;
		long64 min_s_r;
		long64 min_t_l;
		long64 min_t_r;

		auto find = [](long64& l, long64& r,long64 p, std::vector<long64>& array)
		{
			auto it_s = std::lower_bound(array.begin(), array.end(), p);
			if (it_s == array.end()) {
				r = l = array.size() - 1;
			}
			else {
				r = std::distance(array.begin(), it_s);
				if (it_s != array.begin()) {
					it_s--;
					if (it_s == array.end()) {
						l = r;
					}
					else {
						l = std::distance(array.begin(), it_s);;
					}
				}
				else {
					l = r = 0;
				}
			}
		};

		find(min_s_l, min_s_r, p[i], s);
		find(min_t_l, min_t_r, p[i], t);

		long64 mins[4] = {};
		mins[0] = distance(s[min_s_l], t[min_t_l], p[i]);
		mins[1] = distance(s[min_s_l], t[min_t_r], p[i]);
		mins[2] = distance(s[min_s_r], t[min_t_l], p[i]);
		mins[3] = distance(s[min_s_r], t[min_t_r], p[i]);


		long64 min = mins[0];
		for (size_t i = 0; i < 4; i++) {
			if (min > mins[i]) {
				min = mins[i];
			}
		}

		std::cout << min << std::endl;
	}

	return 0;
}

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

const int inf=1e6;

bool cmp(int x,int y)
{
	return x<y;
}

int main()
{
	int n;
	int a[101];
	cin>>n;
	for(int i=0;i<n;++i)
	 cin>>a[i];
	sort(a,a+n,cmp);
	int minn=inf;
	for(int i=a[0];i<=a[n-1];++i)
	{
		int sum=0;
		for(int j=0;j<n;++j)
		{
			sum+=pow(a[j]-i,2);
		}
		minn=min(minn,sum);
	}
	cout<<minn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int a[(1<<17)+10];
int t[(1<<17)+10];

void f(int n){
	int k=1;
	int cnt=2;
	a[0]=0;
	a[1]=1;
	
	while(k<n){
		repp(i,0,1<<k,2){
			t[2*i  ]=a[i  ];
			t[2*i+1]=a[i  ]|(1<<k);
			t[2*i+2]=a[i+1]|(1<<k);
			t[2*i+3]=a[i+1];			
		}
		rep(i,0,1<<k)t[2*(1<<k)+i]=a[(1<<k)-1-i]|(2<<k);
		rep(i,0,1<<k)t[3*(1<<k)+i]=a[i]|(3<<k);
		rep(i,0,4<<k)a[i]=t[i];
		k+=2;
	}
	
}

int g(int n){return n^(n>>1);}

int n,S,G;
int ans[(1<<17)+10];

void puts2(int n,int digit){rep(cnt,0,digit)putchar(n&(1LL<<(digit-1-cnt))?49:48);putchar(10);}

int main(){
	scanf("%d%d%d",&n,&S,&G);
	int x=__builtin_popcount(S^G);
	if(x%2!=1){
		puts("NO");
		return 0;
	}

	puts("YES");
	f(x);
	if(x==n){
		rep(i,0,1<<n)printf("%lld ",a[i]^S);
		return 0;
	}
	
	int cnt=0;
	//00→a0→a1→01→02→…→
	repp(j,0,1<<x,2){
		rep(i,0,1<<(n-x))ans[cnt++]=(g(i)<<x)|a[j];
		rep(i,0,1<<(n-x))ans[cnt++]=(g((1<<(n-x))-1-i)<<x)|a[j+1];
	}

	rep(i,0,1<<n){
		//元の位置に振り分け
		int temp=0;
		int x0=0,x1=x;
		rep(j,0,n){
			if(bit(S^G,j)){
				temp|=bit(ans[i],x0)<<j;
				x0++;
			}else{
				temp|=bit(ans[i],x1)<<j;
				x1++;
			}
		}
		ans[i]=temp^S;
	}
	rep(i,0,1<<n)printf("%d ",ans[i]);
//	rep(i,(1<<n)-10,1<<n)puts2(ans[i],17);
//	rep(i,1,1<<n)printf("%d",__builtin_popcountll(ans[i]^ans[i-1]));
}

Measured memory_bytes: 1536
N = int(input())
h = list(map(int, input().split()))

dp = [0]*(N)
dp[1] = abs(h[1]-h[0])
for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])

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

typedef long long ll;
typedef pair<int, int> ii;

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

    string s;
    cin >> n;
    unordered_map<string, int> mp;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      cin >> s;
      mp[s]++;
      cnt = max(cnt, mp[s]);
    }
    vector<string> res;
    for (auto k : mp) {
      if (k.second == cnt) {
        res.push_back(k.first);
      }
    }
    sort(res.begin(), res.end());
    for (auto str : res) {
      cout << str << endl;
    }

    return 0;
}


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

int main() {
  int H,W,i,j,k,l;
  string S,SC;
  cin >> H >> W;
  for(i=0;i<H;++i){
    cin >> SC;
    S += SC;
  }
  for(i=0;i<H;++i)
    for(j=0;j<W;++j)
      if(S.at(i*W+j)=='#')
        for(k=(i-(i>0)) ; k<(i+1+(i<(H-1))) ; ++k)
          for(l=(j-(j>0)) ; l<(j+1+(j<(W-1))) ; ++l)
            if(S.at(k*W+l)!='#')
              S.at(k*W+l)+=1;
  for(i=0;i<H;++i){
    for(j=0;j<W;++j){
      if(S.at(i*W+j)!='#')
        S.at(i*W+j) += '0' - '.';
      cout << S.at(i*W+j);
    }
    cout << endl;
  }
}


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

int main()
{
    int n;
    cin >> n;
    set<string> items;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        items.insert(s);
    }
    cout << items.size();
    return 0;
}


Measured memory_bytes: 19168
import math

def main():
    num_n, num_a, num_b = list(map(int, input().split()))
    count_list = []
    for i in range(1, num_n + 1):
        #print("num", i)
        digit_list = list(str(i))
        digit_list_int = [int(j) for j in digit_list]
        num_sum = sum(digit_list_int)
        if num_a <= num_sum and num_sum <= num_b: count_list.append(i)
    #print(count_list)
    print(sum(count_list))

    


if __name__ == '__main__':
    main()


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

main(){
  int k,ans;
  cin >> k;
  for(int i=2;i<=k;i++){
    if(i%2==0){
      for(int j=1;j<=k;j++){
        if(j%2==1){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    n, l = list(map(int, input().split()))
    lis = [i+l for i in range(n)]
    ans = sum(lis)
    if 0 in lis:
        pass
    elif lis[0] < 0:
        ans -= lis[-1]
    else:
        ans -= lis[0]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#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 cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	const int N =1e6;
    
     int mod= 1e9+7;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
   
     void solve(){
        
       int n;
       cin>>n;
       vi a(n+1,0),b(n+1,0),c(n,0);
       
       rep(i,1,n+1)
         cin>>a[i];
       rep(i,1,n+1) 
         cin>>b[i];
       rep(i,1,n)
         cin>>c[i];
         
        //~ sort(all(a));
        int sum=0;
        
        rep(i,1,n+1){
			
			if(i==1 && a[i+1]==a[i]+1){
			  sum+=b[a[i]];
			  sum+=b[a[i+1]]+c[a[i]];
			   i++;		  	 
			}
			
			else if(a[i]==a[i-1]+1){
				
				 sum+=b[a[i]]+c[a[i-1]];
			}
			
			else{
				sum+=b[a[i]];				
			}	
		}
		
		cout<<sum<<endl;     
         
     }
   
   
   
   
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


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

typedef long long                   ll;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<string , string>       pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define sep                         ' '
#define file_io                     freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(x)                    cerr << "$$$ " << x << '\n';
#define error2(x,y)                 cerr << "#F : " << x << "      #S : " << y << '\n';
#define pb                          push_back

const ll MX5 = 2*1e5+3;
const ll MX6 = 2*1e6+3;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ll MOD2= 998244353;

ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
ll bmm(ll a,ll b){
    return (a%b==0 ? b : bmm(b,a%b));
}

ll A[MX5],B[MX5],C[MX5];
ll dp[MX5][5];
int main(){
    fast_io
    //file_io
    ll n,k;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> A[i] >> B[i] >> C[i];
    }
    dp[0][0]=A[0];
    dp[0][1]=B[0];
    dp[0][2]=C[0];
    for(int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+A[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+B[i];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+C[i];
    }
    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 10496
def gcd(x,y):
    x,y=max(x,y),min(x,y)
    if y==0:
        return x
    return gcd(y, x%y)


a,b,c,d=map(int,input().split())
e=int(c*d/gcd(c,d))

rng=b-a+1
x=b//c-(a-1)//c
y=b//d-(a-1)//d
z=b//e-(a-1)//e
print(rng-x-y+z)

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

namespace aoj1
{
    class Program
    {
        static void Main()
        {
            int[] num = IntInput();
            int a = num[0];
            int b = num[1];
            int c = num[2];
            if (a < b && b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static int[] IntInput()
        {
            string[] strs = Console.ReadLine().Split(' ');
            int[] numbers = new int[strs.Length];
            for (int i = 0; i < strs.Length; i++)
            {
                numbers[i] = int.Parse(strs[i]);
            }
            return numbers;
        }
    }
}

Measured memory_bytes: 5304
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  ll n,W;
  cin>>n>>W;
  V<ll> v(n),w(n),m(n);
  for(int i=0;i<n;i++)cin>>v[i]>>w[i]>>m[i];
  V<ll> dp(W+1,-1);
  dp[0]=0;
  deque<P> deq;
  for(int i=0;i<n;i++){
      for(ll j=0;j<w[i];j++){
          deq.clear();
           for(ll k=0;w[i]*k+j<=W;k++){
               if(dp[w[i]*k+j]!=-1){
                   ll val=dp[w[i]*k+j]-v[i]*k;
                   while(deq.size()&&val>=deq.back().se)deq.pop_back();
                   deq.emplace_back(k,val);
               }
               if(deq.size()){
                   chmax(dp[w[i]*k+j],deq.front().se+k*v[i]);
                   if(deq.front().fi==k-m[i])deq.pop_front();
               }
           }
      }
  }
  cout<<*max_element(all(dp))<<"\n";
}


Measured memory_bytes: 3260
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c=0, d[100000], e[100000],f=0,g=0,h=0, count = 0;
	char ac,uc[100000];
	string manji,gage;
	cin >> a>>b>>c;
	if (b >= c) {
		cout << "delicious" << endl;
		return 0;
	}
	if (a + b >= c) {
		cout << "safe" << endl;
	 }
	else { cout << "dangerous" << endl; }
	return 0;
}

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

typedef long long llt;

const int MaxN = 100000 + 5, MaxQ = 100000 + 5;

int N, Q;
llt A[MaxN], X[MaxN];
llt pre[MaxN], sum[MaxN];

void init() {
  scanf("%d %d", &N, &Q);
  for (int i = 1; i <= N; ++i) scanf("%lld", &A[i]);
  for (int i = 1; i <= Q; ++i) scanf("%lld", &X[i]);
}

inline bool check(int l, llt x) {
  if (l == 1) return true;
  int lpos = N - 2 * l + 2, rpos = N - l;
  if (A[lpos] >= x) return true;
  if (x - A[lpos] > A[rpos + 1] - x) return false;
  else return true;
}

void solve() {
  pre[1] = sum[1] = A[1];
  for (int i = 2; i <= N; ++i)
    pre[i] = pre[i - 2] + A[i],
    sum[i] = sum[i - 1] + A[i];

  for (int i = 1; i <= Q; ++i) {
    llt x = X[i];

    int lbound = 1, rbound = (N + 1) / 2, ans = 0;
    while (lbound <= rbound) {
      int mid = (lbound + rbound) >> 1;
      if (check(mid, x) == true) {
        ans = mid;
        lbound = mid + 1;
      } else rbound = mid - 1;
    }

    // printf("ans = %d\n", ans);
    llt res = sum[N] - sum[N - ans];
    res += pre[N - 2 * ans];
    printf("%lld\n", res);
  }
}

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

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define ll long long int
#define M 1000000007

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    char grid[n][m];
    for(int i = 0; i<n; i++)
        for(int j = 0; j<m; j++)
            cin>>grid[i][j];
    if(grid[0][0] == '#')
    {
        cout<<"0";
        return 0;
    }
    ll dp[n][m];
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(int i = 0; i<n; i++)
    {
        for(int j = 0; j<m; j++)
        {
            if(grid[i][j] == '#')
                continue;
            if(i-1>=0)
                dp[i][j]=(dp[i][j]+dp[i-1][j])%M;
            if(j-1>=0)
                dp[i][j]=(dp[i][j]+dp[i][j-1])%M;
        }
    }
    cout<<dp[n-1][m-1];
    return 0;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<int> p(n, 0), a(n), b(n);
		for(int i=0; i<n; i++)cin >> p[i];
		for(int i=0; i < n; i++)a[i] = b[n-1-i] = (i+1)*n;
		for(int i=0; i < n; i++)a[p[i]-1] += i;
		for(int i=0; i<n; i++)cout << a[i] << " ";
		cout << "\n";
		for(int i=0; i<n; i++)cout << b[i] << " ";
		cout << "\n";
		
		return;
	};
};

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

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

const int MAXN = 100000+5;

int N;
int h[MAXN];
long sums[MAXN];
int aux;

int main() {
	int N;
	cin>>N;
	for(int i=0;i<N;i++) cin>>h[i];
	sums[1]=abs(h[1]-h[0]);
	for(int i=2;i<N;i++){
		sums[i] = sums[i-1] + abs(h[i]-h[i-1]);
		aux = sums[i-2] + abs(h[i]-h[i-2]);
		if(aux<sums[i]){
			sums[i]=aux;
		}
	}
	cout<<sums[N-1];
	return 0;
}

Measured memory_bytes: 1408