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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

typedef long long ll;

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

  int A,B;
  cin >> A >> B;
  cout << (B+A-3) / (A-1) << endl;

  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}


int main(){
  string s,t;
  cin>>s>>t;
  int c=0;
  for(int i = 0; i < 3; i++){
    if(s[i]==t[i]){
      c++;
    }
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstring>

using namespace std;

using vi = vector<int>;
vi X;
int n;
vector<vi> C;
int used[207];
bool isprime(int n) {
	if (n <= 2)return false;
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return true;
}
bool dfs(int v) {
	used[v] = true;
	if (v == X.size() + 1) return true;
	for (int i = 0; i < X.size() + 2; i++) {
		if (!used[i] && C[v][i] > 0) {
			if (dfs(i)) {
				C[v][i]--;
				C[i][v]++;
				return true;
			}
		}
	}
	return false;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (!X.empty() && X.back() == x) {
			X.pop_back();
			X.push_back(x + 1);
		}
		else {
			X.push_back(x);
			X.push_back(x + 1);
		}
	}
	int E = 0;
	int O = 0;
	for (int x : X) {
		if (x % 2 == 0) {
			E++;
		}
		else {
			O++;
		}
	}
		
	C.resize(X.size()+2, vi(X.size()+2, 0));
	for (int i = 0; i < X.size(); i++) {
		if (X[i] % 2 == 0) {
			C[X.size()][i] = 1;
		}
		else {
			C[i][X.size() + 1] = 1;
		}
	}
	for (int i = 0; i < X.size(); i++) {
		for (int j = i; j < X.size(); j++) {
			if (isprime(abs(X[i] - X[j]))) {
				int a = i;
				int b = j;
				if (X[b] % 2 == 0)swap(a, b);
				C[a][b] = 1;
			}
		}
	}
	int ans = 0;
	while (dfs(X.size())) {
		for (int i = 0; i < 207; i++)used[i] = false;
		ans++;
	}
	if ((E - ans) % 2 == 0) {
		cout << ans + (E - ans + O - ans) << endl;
	}
	else {
		cout << ans + (E - ans - 1 + O - ans - 1) + 3 << endl;
	}
}




Measured memory_bytes: 384
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 2e5 + 5;
const int mod = 1e9 + 7;

long long fpow(long long a, long long b, long long m) {
    if (!b) return 1;
    long long t = fpow(a, b / 2, m);
    if (b & 1) return t * t % m * a % m;
    else return t * t % m;
}

long long f[N];
long long g[N];
int h, w, a, b;

long long fac[N];
long long inv[N];

long long comb(int n, int m) {
    return fac[n] * inv[m] % mod * inv[n - m] % mod;
}

signed main() {
    cin >> h >> w >> a >> b;
    int n = w + h;
    
    fac[0] = inv[0] = 1ll;
    for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
    inv[n] = fpow(fac[n], mod - 2, mod);
    for (int i = n - 1; i; i--) inv[i] = inv[i + 1] * (i + 1) % mod;

    long long ans = comb(h + w - 2, h - 1);
    for (int i = 1; i <= b; i++)
        ans = (ans - comb(w - i + a - 1, a - 1)
                   * comb(h - a + i - 2, i - 1) % mod + mod) % mod;
    
    cout << ans << endl;
}

Measured memory_bytes: 6716
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
import random
def resolve():
    A,B,N=pin()
    def f(A,B,x):
        t=(A*x)//B
        s=x//B
        return t-A*s
    ans=0
    for i in range(8*(10**6)):
        k=random.randint(0,N)
        ans=max(ans,f(A,B,k))
    print(ans)
#%%submit!
resolve()

Measured memory_bytes: 78612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <map>
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define rep(i,l,r)  for(int i=l;i<=r;i++)
#define pre(i,r,l)  for(int i=r;i>=l;i--)
#define pii pair<int,int>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const int maxn = 1000005;
inline int read(){
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}

int main() {
    int n, k; cin >> n >> k;
   vector<int> v(n);
   rep(i, 0, n-1) cin >> v[i];
   sort(v.begin(), v.end());
   int sum = 0;
   rep(i, 0, k-1) sum += v[i];
   cout << sum << endl;
}


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)

/*
    
*/


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    int a, b, c;
    cin >> a >> b >> c;

    if(b - a == c - b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
dp = [[0] * 3 for i in range(100010)]

N = int(input())
a = [list(map(int, input().split())) for i in range(N)]

for i in range(1, N+1):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i][k] = max(dp[i][k], dp[i-1][j] + a[i-1][k])

print(max(dp[N]))


Measured memory_bytes: 50360
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003LL;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

template <typename T>
class Dinic {
    T inf;
    struct Edge {int to, rev; T cap;};
    vector<vector<Edge>> G;
    vector<int> dist, iter;
    bool bfs(int s, int t) {
        dist.assign(G.size(), -1);
        queue<int> q;
        dist[s] = 0;
        q.push(s);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (Edge &e : G[v]) {
                if (dist[e.to] != -1 || e.cap == 0) continue;
                dist[e.to] = dist[v] + 1;
                q.push(e.to);
            }
        }
        return dist[t] != -1;
    }
    T dfs(int now, int t, T min_cap) {
        if (now == t) return min_cap;
        for (int &i = iter[now]; i < G[now].size(); ++i) {
            Edge &e = G[now][i];
            if (e.cap == 0 || dist[e.to] != dist[now] + 1) continue;
            T d = dfs(e.to, t, min(min_cap, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
        return 0;
    }
public:
    Dinic(int V) : G(V), inf(numeric_limits<T>::max()) {}
    void AddEdge(int from, int to, T cap) {
        G[from].push_back(Edge{to, (int)G[to].size(), cap});
        G[to].push_back(Edge{from, (int)G[from].size() - 1, 0});
    }
    T MaxFlow(int s, int t) {
        T ans = 0;
        while (bfs(s, t)) {
            iter.assign(G.size(), 0);
            T f = 0;
            while ((f = dfs(s, t, inf)) > 0) ans += f;
        }
        return ans;
    }
};

// Main
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    Dinic<ll> G(n + 2);
    ll ans = 0;
    rep(i, n) {
        int x = max(a[i], 0);
        G.AddEdge(0, i + 1, x - a[i]);
        G.AddEdge(i + 1, n + 1, x);
        ans += x;
    }
    rep(i, 1, n + 1) for (int j = 2 * i; j <= n; j += i) G.AddEdge(i, j, INF);
    ans -= G.MaxFlow(0, n + 1);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3688
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	double x1=in<double>(),y1=in<double>(),x2=in<double>(),y2=in<double>();
	printf("%.10lf\n",hypot(x2-x1,y2-y1));
		
	return 0;
}



Measured memory_bytes: 3264
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for n_500 in range(A+1):
	for n_100 in range(B+1):
		tmp = X - 500*n_500 - 100*n_100
		n_50 = tmp//50
		if 0 <= n_50 <= C:
			ans += 1

print(ans)


Measured memory_bytes: 4208
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        long ans = 0;
        long  a[]=new long[10000001];
        while(t-->0)
        {
        int n=sc.nextInt();
        pop(a,n);
        for(int i=1;i<=n;i++)
        {
            ans+=i*a[i];
        }
        pw.println(ans);
        }
           pw.close();
    }
    static void pop(long a[],int n)
    {
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= n; j += i) {
                a[j]++;
            }
        }
    }
}
  


Measured memory_bytes: 116060
(N, K), As = readlines.map{|l| l.split.map(&:to_i)}

a = As.reject{|x| x >= K}.sort
n = a.size
s, ans  = 0, n
while n > 1
  s += a[n - 1]
  if a[n - 2] + s < K
    n -= 1
    next
  elsif a[0] + s >= K
    ans = 0
    break
  else
  u = (0 .. n - 2).bsearch{|x| s + a[x] >= K}
  ans -= n - u
  n = u
  end
end
puts ans

Measured memory_bytes: 2044
import numpy as np
from numba import njit
i4 = np.int32
i8 = np.int64

INF = 1000000000


@njit
def solve(s, ch, cw):
    H = s.shape[0]
    W = s.shape[1] - 1
    ah = H + 4
    aw = W + 4

    a = np.full((ah, aw), -1, i4)
    for i in range(H):
        for j in range(W):
            if s[i, j] == 46:
                a[i + 2, j + 2] = INF

    sh1 = np.empty(1000000, i4)
    sw1 = np.empty(1000000, i4)
    p1 = 0
    sh2 = np.empty(1000000, i4)
    sw2 = np.empty(1000000, i4)
    p2 = 0

    def push2(h2, w2, dis2):
        nonlocal p2, sh2, sw2

    dis = 0
    a[ch + 1, cw + 1] = dis
    sh1[p1] = ch + 1
    sw1[p1] = cw + 1
    p1 += 1

    while True:
        while p1 > 0:
            p1 -= 1
            h = sh1[p1]
            w = sw1[p1]
            for i in range(-2, 3):
                for j in range(-2, 3):
                    if ((i == 1 or i == -1) and j == 0) or (i == 0 and (j == 1 or j == -1)):
                        if a[h + i, w + j] > dis:
                            a[h + i, w + j] = dis
                            sh1[p1] = h + i
                            sw1[p1] = w + j
                            p1 += 1
                    else:
                        if a[h + i, w + j] > dis + 1:
                            push2(h + i, w + j, dis + 1)
                            a[h + i, w + j] = dis + 1
                            sh2[p2] = h + i
                            sw2[p2] = w + j
                            p2 += 1

        dis += 1
        for i in range(p2):
            if a[sh2[i], sw2[i]] == dis:
                sh1[p1] = sh2[i]
                sw1[p1] = sw2[i]
                p1 += 1
        p2 = 0

        if p1 == 0:
            break

    return a


def main(in_file):
    stdin = open(in_file)
    H, W = [int(x) for x in stdin.readline().split()]
    ch, cw = [int(x) for x in stdin.readline().split()]
    dh, dw = [int(x) for x in stdin.readline().split()]
    s = np.frombuffer(np.array(stdin.read()), i4).reshape((H, W + 1))
    a = solve(s, ch, cw)
    ans = a[dh + 1, dw + 1]
    if ans == INF:
        print(-1)
    else:
        print(ans)


main('/dev/stdin')


Measured memory_bytes: 123832
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;

int main()
{
//	freopen("std.in","r",stdin);
	string s,t;cin>>s>>t;
	int a,b;cin>>a>>b;
	string u;cin>>u;
	if(u==s) --a;
	else --b;
	printf("%d %d\n",a,b);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

long long inf = 1000000007;

int x, a;

int main(){
  cin >> x >> a;
  if(x < a){
    cout << 0 << endl;
  }else{
    cout << 10 << endl;
  }
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename T>
std::tuple<T, T, T> extgcd(T a, T b){
    T s1 = 1, t1 = 0, s2 = 0, t2 = 1;
    while(b != 0){
        std::tie(s1, t1, s2, t2) = std::make_tuple(s2, t2, s1 - (a / b) * s2, t1 - (a / b) * t2);
        std::tie(a, b) = std::make_tuple(b, a % b);
    }
    return std::make_tuple(s1, t1, a);
}

template <typename T>
T mod_expt(T a, std::int64_t n, T mod){
    T power {1};
    while(n > 0){
        if(n & 1){power = power * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return power;
}

// 注意: a と mod が互いに素である必要がある
template <typename T>
T mod_inverse(T a, T mod){
    T b;
    std::tie(b, std::ignore, std::ignore) = extgcd(a, mod);
    if(b < 0){b += mod;}
    return b;
}

template <typename T>
struct Combinatorics{
    T modulo;
    std::vector<T> fact, inv_fact;

    Combinatorics(T max, T modulo) : modulo(modulo), fact(max + 1), inv_fact(max + 1) {
        fact[0] = 1;
        for(T i=1;i<=max;++i){
            fact[i] = i * fact[i - 1] % modulo;
        }

        inv_fact[max] = mod_inverse(fact[max], modulo);
        for(T i=max;i>0;--i){
            inv_fact[i - 1] = i * inv_fact[i] % modulo;
        }
    }

    T nPk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[n - k] % modulo;
    }

    T nCk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[k] % modulo * inv_fact[n - k] % modulo;
    }

    T nHk(T n, T k){
        if(n == 0 && k == 0){return 1;}
        return nCk(n + k - 1, k);
    }
};

constexpr ll MOD = 998244353;
int K, N;
Combinatorics<ll> comb(5000, MOD);

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

    std::cin >> K >> N;

    for(int i=2;i<=2*K;++i){
        int x = i;
        if(x > K + 1){
            x -= 2 * (x - K - 1);
        }

        int a = (x - 1) / 2, b = (x - 1) & 1, c = K - (2 * a + b);
        ll cnt = 0;

        // B の箱に入れない
        for(int j=0;j<=a&&j<=N;++j){ // A の箱に入れる個数
            cnt = (cnt + comb.nCk(a, j) * comb.nHk(j + c, N - j) % MOD * mod_expt<ll>(2ll, j, MOD) % MOD) % MOD;
        }

        // B の箱に1個だけ入れる
        if(b > 0){
            for(int j=0;j<=a&&j+1<=N;++j){ // A の箱に入れる個数
                cnt = (cnt + comb.nCk(a, j) * comb.nHk(j + c, N - j - 1) % MOD * mod_expt<ll>(2ll, j, MOD) % MOD) % MOD;
            }
        }

        std::cout << cnt << std::endl;
    }
}


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

int find(int n){
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main(){
	int N, A, B;
	int total = 0;
	cin >> N >> A >> B;
	
	for(int i = 1; i <= N; i++){
		int sum = find(i);
		if (sum >= A && sum <= B) total += i;
	}
	cout << total << endl;
}


Measured memory_bytes: 256
// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define Nayon ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b
#define v_sum(a)         accumulate(a.begin(),a.end(),0)
#define v_max(a)         *max_element(a.begin(),a.end())
#define v_min(a)         *min_element(a.begin(),a.end())
#define v_uni(a)         a.erase(unique(a.begin(),a.end()),a.end())

using namespace std;

const ll mod=1e9+7;



ll multi(ll x)
{
	ll y=1,i,j;
	for(i=0;i<x;i++){
		y=y*10;
		y=y%mod;
	}
	return y;
}

ll multi1(ll x)
{
	ll y=1,i,j;
	for(i=0;i<x;i++){
		y=y*9;
		y=y%mod;
	}
	return y;
}

ll multi2(ll x)
{
	ll y=1,i,j;
	for(i=0;i<x;i++){
		y=y*8;
		y=y%mod;
	}
	return y;
}

int main()
{
	Nayon;
	ll n,i,j,ans,ans1,ans2;
	cin>>n;
	if(n==1){
		cout<<0<<nl;
		return 0;
	}
	if(n==2){
		cout<<2<<nl;
		return 0;
	}
	ans=multi(n);
	ans1=multi1(n);
	ans2=multi2(n);
	ans1=(2*ans1)%mod;
	cout<<(((ans+ans2)-ans1)+mod)%mod<<nl;

	return 0;

}

//Happy Coding...........

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	int c,ans;
	string a;
	cin>>c>>a;
	ans=c;
	for(int i=1;i<c;i++)
	{
		if(a[i]==a[i-1])
		{
			ans--;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 512
N,M = list(map(int, input().split()))
H = list(map(int, input().split()))
E = [[] for _ in range(N)]

for i in range(M):
  a,b = list(map(int, input().split()))
  a,b = a-1, b-1
  E[a].append(b)
  E[b].append(a)
  
ans = 0

for i in range(N):
  flg = True
  for p in E[i]:
    if H[i] > H[p]:
      continue
    else:
      flg = False
      break
  if flg:
    ans += 1
    
print(ans)

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> vec(M, vector<int>(2));
    for(int i = 0; i < M; i++){
        cin >> vec.at(i).at(0) >> vec.at(i).at(1);
    }

    int ma = 1000000, mi = 1;
    for(int i = 0; i < M; i++){
        ma = min(ma, vec.at(i).at(1));
        mi = max(mi, vec.at(i).at(0));
    }

    int ans;
    if(mi <= ma){
        ans = ma - mi + 1;
    }
    else{
        ans = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 8788
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
        int M = sc.nextInt();
        int aList[] = new int[A];//aの値段
        int bList[] = new int[B];//bの値段
        int x[] = new int[M];
        int y[] = new int[M];
        int c[] = new int[M];
        int answer = 0;
        
        for(int i = 0;i < A; i++){
          aList[i] = sc.nextInt();
        }
      	for(int i = 0;i < B; i++){
          bList[i] = sc.nextInt();
        }      	
        for(int i = 0;i < M; i++){
          x[i] = sc.nextInt();
          y[i] = sc.nextInt();
          c[i] = sc.nextInt();
        }
        answer = aList[x[0] - 1] + bList[y[0] - 1] - c[0];
      	for(int i = 1;i < M; i++){
          if(aList[x[i] - 1] + bList[y[i] - 1] - c[i] <= answer){
            answer = aList[x[i] - 1] + bList[y[i]-1] - c[i];
          }
        }
      	
        Arrays.sort(aList);
        Arrays.sort(bList);
        if(aList[0] + bList[0] < answer){
        answer = aList[0] + bList[0];
        }
      	
        System.out.println(answer);   
    }
}

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

using namespace std;

int N, Q, H, S, D;
vector < long long > a;
string s;
long long sol;

int main() {
    a.resize(4);
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    
    cin >> N;
    
    if (a[1] > 2LL * a[0]) {
        a[1] = 2LL * a[0];
    }
    
    if (a[2] > 4LL * a[0]) {
        a[2] = 4LL * a[0];
    }
    
    if (a[3] > 8LL * a[0]) {
        a[3] = 8LL * a[0];
    }
    if (a[2] > 2LL * a[1]) {
        a[2] = 2LL * a[1];
    }
    
    if (a[3] > 4LL * a[1]) {
        a[3] = 4LL * a[1];
    }
    
    if (a[3] > 2LL * a[2]) {
        a[3] = 2LL * a[2];
    }
    
    while (N) {
        if (N >= 2) {
            sol += a[3] * 1LL * (N / 2);
            N %= 2;
        } else if (N >= 1) {
            sol += 1LL * N * a[2];
            N = 0;
        }
    }
    
    
    cout << sol << '\n';
    return 0;
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    ll n;
    cin >> n;

    vector<ll> pow26(1, 1);

    rep(i, 12){
        pow26.push_back(pow26[i] * 26);
    }

    vector<ll> sum26(13);
    sum26[1] = 26;

    for(int i = 2; i <= 12; i++){
        sum26[i] = sum26[i - 1] + pow26[i];
        //cerr << sum26[i] << " ";
    }
    //cerr << endl;

    sum26[0] = 0;

    int len = 1;

    rep(i, 12){
        if(n > sum26[i + 1]) len = i + 2;
    }

    cerr << "len : " << len << endl;

    n = n - sum26[len - 1] - 1;

    cerr << "rest n : " << n << endl;
    vector<ll> mod26(13);

    for(int i = len - 1; i >= 0; i--){
        mod26[i] = n / pow26[i];

        cout << (char)('a' + mod26[i]);

        n -= mod26[i] * pow26[i];
    }

    return 0;
}


Measured memory_bytes: 3608
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);

            if( h == 0 && w == 0)break;
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    System.out.print("#");
                }
                System.out.print("\n");
            }
            System.out.println("");
        }

    }
}

Measured memory_bytes: 33352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
// #include "prettyprint.hpp"

using namespace std;
using ll = long long;

int main()
{
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    S[K - 1] = S[K - 1] + 0x20;
    cout << S << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int x,y;
    scanf("%d%d",&x,&y);
    
    if(x>y)
    {
        printf("%d",(2*x-1));
    }
    else if(x<y)
    {
        printf("%d",(2*y-1));
    }
    else if(x==y)
    {
        printf("%d",(x+y));
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <cmath>
#include <ctime>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<ll> vl;
typedef vector< vector<ll> > vvl;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forv(i, v) forn(i, v.size())
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back

int main() {
#ifdef NEREVAR_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    vs s(n);
    forn(i, n) cin >> s[i];
    int x = 0, y = 0;
    int cnt = 0;
    forn(i, n) {
        forn(j, m) {
            if (s[i][j] == '#') cnt++;
        }
    }
    if (cnt != n + m - 1) {
        puts("Impossible");
        return 0;
    }
    forn(it, cnt - 1) {
        bool canX = x + 1 < n && s[x + 1][y] == '#';
        bool canY = y + 1 < m && s[x][y + 1] == '#';
        if (canX ^ canY) {
            if (canX) x++; else y++;
        } else {
            puts("Impossible");
            return 0;
        }
    }
    puts("Possible");
    return 0;
    return 0;
}


Measured memory_bytes: 892
MOD=10**9+7

N,M=gets.split.map &:to_i
a=Array.new(N+2)
M.times{a[gets.to_i]=true}

dp=Array.new(N+2){0}
dp[0]=1
N.times do |i|
  dp[i+1]+=dp[i] unless a[i+1]
  dp[i+2]+=dp[i] unless a[i+2]
  dp[i+1] %= MOD
  dp[i+2] %= MOD
end
p dp[N]

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){    
  int R;
  cin >> R;
  if(R < 1200) cout << "ABC" << endl;
  else if(R < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint  = long long;
const lint MAX = 1000001;
const lint MOD = 1000000007;

lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

lint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){
  lint X, Y; cin >> X >> Y;
  if((X + Y) % 3 != 0 || X > 2*Y || Y > 2*X){
    cout << 0 << endl;
    return 0; 
  }
  COMinit();
  lint x = (X + Y)/3, y = (-X + 2*Y)/3;
  cout << COM(x, y) << endl;
}

Measured memory_bytes: 23680
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var sides = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse);

            var sortedSides = sides.OrderBy(side => side);

            // 実装1（愚直に。遅いと思ったらこっちのほうが速かった。もう一度動かしてみたら逆転したので誤差ですね。）
            //if (sortedSides.Last() < sortedSides.Sum() - sortedSides.Last())
            //{
            //    Console.WriteLine("Yes");
            //}
            //else
            //{
            //    Console.WriteLine("No");
            //}

            // 実装2（こっちのほうが効率がいいかも？実際はこっちのほうが遅かった。範囲を足し合わせる処理があるから？もう一度動かしてみたら逆転したので誤差ですね。）
            if (sortedSides.Last() < sortedSides.Take(sortedSides.Count() - 1).Sum())
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

//vector<int> name(size,syokiti);
//vector<vector<int>> name(size,vector<int>(size,syokiti));

int main(void)
{
	int num;
	cin >> num;

	vector<int> a(num);
	for (int i = 0; i < num; i++) {
		cin >> a[i];
	}

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

	reverse(a.begin(), a.end());
	
	int ans = 0;
	for (int i = 0; i < num; i++) {
		if (i % 2 == 0) {
			ans += a[i];
		}
		else {
			ans -= a[i];
		}
	}
	cout << ans << endl;
}


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

typedef long long ll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forr(i,m,n) for(ll i=m;i<n;i++)
#define testcase int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define rev(v) v.rbegin(),v.rend()
#define pb push_back
#define endl "\n"
#define print(v) forr(i,0,v.size())cout<<v[i]<<" ";cout<<endl;
#define print_map(m) for(auto it=m.begin(); it!=m.end();it++) cout<<(*it).first<<" "<<(*it).second<<endl;
#define vi vector<int>
#define vp vector< pair<int, int> >

ll maxi(ll a, ll b){
	if(a>b) return a;
	return b;
}

ll mini(ll a, ll b){
	if(a>b) return b;
	return a;
}

bool sorter(pair<int, int> a, pair<int, int> b){
	if(a.second!=b.second) return a.second>b.second;
	return a.first>b.first;
}

int main(){
	fastio
	int n,m; cin>>n>>m;
	ll a=0;
	forr(i,0,m) {int tt; cin>>tt; a+=tt;}
	if(a>n) cout<<-1<<endl;
	else cout<<n-a<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

bool ama[114]={};
signed main(){
    int a,b,c;
    bool rullonz = false;
    scanf("%d%d%d",&a,&b,&c);

    int cur = a%b;
    while(1){
        ama[cur] = 1;
        cur = (cur+a)%b;
        if(ama[cur]) break;
        if(cur==c){
            rullonz = true;
            break;
        }
    }
    if(rullonz) puts("YES");
    else puts("NO");
    return 0;
}

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

int main() {
    string s;
    cin>>s;
    int atama,osiri,ans=1;
    bool a=true;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='A'&&a){
            atama=i;
            a=false;
        }
        if(s.at(i)=='Z')osiri=i;
    }
    ans+=osiri-atama;
    cout<<ans<<endl;
}


Measured memory_bytes: 640
import itertools

N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]

# 重複組み合わせ: nHr = n+r-1Cr を考える
ans = 0
R = [i for i in range(1, M+1)]
# print(R)

for comb in itertools.combinations_with_replacement(R, N):
    temp = 0
    for abcd in ABCD:
        a, b, c, d = abcd
        if comb[b-1] - comb[a-1] == c:
            temp += d
    if temp >= ans:
        ans = temp

    # print("comb: {}, temp: {}, ans: {}".format(comb, temp, ans))

print(ans)


Measured memory_bytes: 9156
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i<b; i++)
typedef long long ll;
int main() {
    int n, t; cin >> n >> t;
      vector<int> vt(n);
      for(int i=0; i<n; i++) cin >> vt[i];
      
      int sum=0;
      for(int i=0; i<n; i++) {
        if(i>0) sum+=min(vt[i]-vt[i-1],t);
      }
      cout << sum+t << endl;
    return 0;
}

Measured memory_bytes: 4048
fun main() {
    val N = readLine()?.toLong() ?: return
    1.until(3501).forEach { i ->
        1.until(3501).forEach { j ->
            val a = (N * i * j)
            val b = ((4 * i * j) - N * j - N * i)
            if (b > 0 && a % b == 0L) {
                println("$i $j ${a / b}")
                return
            }
        }
    }
}

Measured memory_bytes: 35092
#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() {
  ll X;
  cin >> X;
  cout << (X/500)*1000 + ((X%500)/5)*5 << endl;
  
  return 0;
}

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

#define N 36

typedef struct card{
  int num;
  char mark;
}Card;

void BubbleSort(Card *a, int n);
void SelectionSort(Card *a, int n);

int main(void){
  int i, n, check = 0;
  Card a[N], b[N];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf(" %c%d", &(a[i].mark), &(a[i].num));
    b[i] = a[i];
  }
  BubbleSort(a, n);
  SelectionSort(b, n);

  for(i = 0; i < n; i++){
    printf("%c%d", a[i].mark, a[i].num);
    if(i < n-1){
      printf(" ");
    }
    if(a[i].mark != b[i].mark){
      check++;
    }
  }
  printf("\nStable\n");
  for(i = 0; i < n; i++){
    printf("%c%d", b[i].mark, b[i].num);
    if(i < n-1){
      printf(" ");
    }
  }
  if(check == 0){
    printf("\nStable\n");
  }else{
    printf("\nNot stable\n");
  }
  return 0;
}

void BubbleSort(Card *a, int n){
  int flag, i, j;
  Card temp;

  for(i = n; i > 0; i--){
    flag = 0;
    for(j = 1; j < i; j++){
      if(a[j-1].num > a[j].num){
	temp = a[j-1];
	a[j-1] = a[j];
	a[j] = temp;
	flag = 1;
      }
    }
    if(flag == 0)  break;
  }
}


void SelectionSort(Card *a, int n){
  int min, i, j;
  Card temp;

  for(i = 0; i < n-1; i++){
    min = i;
    for(j = i+1; j < n; j++){
      if(a[min].num > a[j].num){
	min = j;
      }
    }
    if(min != i){
      temp = a[i];
      a[i] = a[min];
      a[min] = temp;
    }
  }
}

Measured memory_bytes: 612
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define MP make_pair
#define F first
#define S second

int main(){
	int n;
    cin >> n;
    if(n==1){
    	cout << "Hello World" << endl;
    }
  	else{
    	int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
	
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const a = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    
    let list = [];

    for(let i=a[0]; i<a[a.length - 1]; i++) {
        let temp = 0;
        
        for(let j in a) {
            temp += Math.pow(a[j] - i, 2);
        }
        
        list.push(temp);
    }
    
    if(list.length) {
        console.log(Math.min(...list));
    } else {
        console.log(0);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7884
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int,int>;

const int mx = 2e5+5;

int n, m;
ll dp[1<<16];
int a[16][16];
ll values[1<<16];

ll fun(int mark){
    if(mark == 0) return 0;

    ll &ans = dp[mark];
    if(~ans) return ans;

    ans = LLONG_MIN;
    for(int cur=mark; cur>0; cur=(cur-1)&mark)
        ans = max(ans, values[cur]+fun(mark ^ cur));
    return ans;
}

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

    cin >> n;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin >> a[i][j];
    m = (1<<n) - 1;

    for(int i=1; i<=m; i++){
        vector<int> v;
        for(int j=0; j<n; j++)
            if(i & (1<<j))
                v.push_back(j);
        ll tot = 0;
        for(int j=0; j<v.size(); j++)
            for(int k=j+1; k<v.size(); k++)
                tot += a[v[j]][v[k]];
        values[i] = tot;
    }memset(dp, -1, sizeof dp);

    ll ans = fun(m);
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 4656
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

vector<vector<int>> g(100005);
ll dp[100005][2];
bool visited[100005];
const ll MOD = 1000000007;

ll rec(int p, int s, int col /*1なら黒*/) {
	if (dp[s][col] != -1) return dp[s][col];
	if (p != -1 && g[s].size() == 1) return dp[s][col] = 1;

	ll res = 1;
	for (int v: g[s]) {
		if (v == p) continue;
		if (col) res = (res * rec(s, v, 0)) % MOD;
		else res = (res * (rec(s, v, 0) + rec(s, v, 1)) % MOD) % MOD;
	} 
	return dp[s][col] = res;
}

int main() {
	int n;
	cin >> n;
	rep (i, n - 1) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		g[x].pb(y);
		g[y].pb(x);
	}

	memset(dp, -1, sizeof(dp));

	rec(-1, 0, 0);
	rec(-1, 0, 1);

	cout << (dp[0][0] + dp[0][1]) % MOD << endl;
	return 0;
}

Measured memory_bytes: 15616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0; i<n; i++)
		cin>>arr[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2; i<n; i++)
	{
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int a,b,c;cin>>a>>b>>c;
    rep(i,b+1){
        int na=a*i;
        if(na%b==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int h, w;
vector<string>board;

int solve(){
    int ans = 0;
    rep(i, 0, h){
        rep(j, 0, w){
            if(board[i][j]!='.')continue;
            vector<vector<int>>m(h,vector<int>(w,-12));
            queue<pii>que;
            que.push(pii(i, j));
            m[i][j]=0;
            while(!que.empty()){
                pii now = que.front();
                que.pop();
                int x = now.first;
                int y = now.second;
                rep(k, 0, 4){
                    int nx = x+dx[k];
                    int ny = y+dy[k];
                    if(nx<0 || ny<0 || nx>=h || ny>=w)continue;
                    if(board[nx][ny]=='#')continue;
                    if(m[nx][ny]==-12){
                        //m[nx][ny] = m[x][y] + 1;
                        chmax(m[nx][ny],m[x][y]+1);
                        que.push(pii(nx,ny));
                        ans = max(ans,m[nx][ny]);
                        //cout << ans << endl;
                    }
                }
            }
        }
    }
    return ans;
}
int main() {
    cin >> h >> w;
    board.resize(h);
    rep(i, 0, h)cin >>board[i]; 
    cout << solve() << endl;
}

Measured memory_bytes: 256
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
def inNL(n):
    return [list(map(int,input().split())) for i in range(n)]

n,m = inL()
h = inL()
ab = inNL(m)

l = [1]*n
for a,b in ab:
    if h[a-1]>h[b-1]:
        l[b-1] = 0
    elif h[a-1]==h[b-1]:
        l[a-1]=l[b-1]=0
    else:
        l[a-1] = 0
#print(l)
print(l.count(1))


Measured memory_bytes: 96300
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
   
typedef struct dice{
    int face[6];
}dice;
   
void rotate(dice *d, char dir)
{
    int temp;
    switch(dir) {
    case 'N':
        temp=d->face[0];
        d->face[0]=d->face[1];
        d->face[1]=d->face[5];
        d->face[5]=d->face[4];
        d->face[4]=temp;
        break;
    case 'E':
        temp=d->face[0];
        d->face[0]=d->face[3];
        d->face[3]=d->face[5];
        d->face[5]=d->face[2];
        d->face[2]=temp;
        break;
    case 'W':
        temp=d->face[0];
        d->face[0]=d->face[2];
        d->face[2]=d->face[5];
        d->face[5]=d->face[3];
        d->face[3]=temp;
        break;
    case 'S':
        temp=d->face[0];
        d->face[0]=d->face[4];
        d->face[4]=d->face[5];
        d->face[5]=d->face[1];
        d->face[1]=temp;
        break;
    }
}
   
int isSame(dice d1, dice d2)
{
    static const char dir[]="NNNESSSWNNNESSSWNNNESSSW";
    int i, j;
    for(i=0; i<24; i++) {
        for(j=0; j<6 && d1.face[j]==d2.face[j]; j++);
        if(j==6) return 1;
        rotate(&d2, dir[i]);
    }
    return 0;
}
   
int main()
{
    dice d[100];
    int i, j, n;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        for(j=0; j<6; j++) {
            scanf("%d", &d[i].face[j]);
        }
        for(j=0; j<i; j++) {
            if(isSame(d[i], d[j])) {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

ll n, a;
ll ans = INF;

void solve(ll k) {
  ll ng = k, ok = (k + 10)*n;
  while (ng + 1 < ok) {
    ll mid = (ng + ok) / 2;
    ll s_mi = mid / (k + 1);
    ll ma_num = mid % (k + 1);
    ll mi_num = k + 1 - ma_num;
    ll mai = 1;
    rep (i, mi_num) {
      if (mai >= n) continue;
      mai *= s_mi;
      if (mai <= 0) mai = n;
    }
    rep (i, ma_num) {
      if (mai >= n) continue;
      mai *= (s_mi + 1);
      if (mai <= 0) mai = n;
    }

    if (mai >= n) {
      ok = mid;
    }
    else {
      ng = mid;
    }
  }

  ans = min(ans, a * k + ok);
}

int main() {
  cin >> n >> a;
  for (int k = 0; k <= min(n, 50LL
); k++) {
    solve(k);
  }

  cout << ans << endl;

}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

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

int32_t main(){
  DESYNC;
  int r,D, x;
  cin >> r >> D >> x;
  for(int i=0; i<10; i++){
    x = x*r - D;
    cout << x << endl;
  }
}



Measured memory_bytes: 256