akhauriyash/Code-Regression huggingface dataset:
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    s=list(input())
    k=inp()
    n=len(s)
    for i in range(n):
        s[i]=ord(s[i])
    for i in range(n):
        if i==n-1:
            s[i]+=k
            if s[i]>=123:
                s[i]=(s[i]-97)%26+97
        elif s[i]==97:
            s[i]='a'
            continue
        elif 123-s[i]<=k:
            k-=123-s[i]
            s[i]=97
        s[i]=chr(s[i])
    print(''.join(s))

if __name__ == "__main__":
    main()

Measured memory_bytes: 56084
a,b,op = [],[],[]
while True:
	inp = input().split()
	if inp[1] == "?":
		break
	else:
		a.append(int(inp[0]))
		b.append(int(inp[2]))
		op.append(inp[1])
for i in range(len(a)):
	if op[i] == "+":
		print(a[i]+b[i])
	elif op[i] == "-":
		print(a[i]-b[i])
	elif op[i] == "*":
		print(a[i]*b[i])
	elif op[i] == "/":
		print(a[i]//b[i])


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s[2];cin >> s[0] >> s[1];
    int n = s[0].size() + s[1].size();
    inc(i, 0, n){
        cout << s[i%2][i/2];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
def count(i, g, vis)
  return 0 if vis[i]
  vis[i]=true
  ret=1
  g[i].each{|j| ret+=count(j, g, vis)}
  return ret
end

n, m=gets.split.map(&:to_i)
as, bs=[], []
m.times do
  a, b=gets.split.map(&:to_i)
  as.push(a-1)
  bs.push(b-1)
end

num=0
m.times do |i|
  g=Array.new(n){[]}
  m.times do |j|
    next if i==j
    g[as[j]].push(bs[j])
    g[bs[j]].push(as[j])
  end
  num+=1 if count(0, g, Array.new(n){false})<n
end

puts num

Measured memory_bytes: 3964
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define pb push_back

int N, M;
string B[514];
bool E[514];
int dp[1 << 24][2];

//N < M
void mode1() {
  int ans = 0;
  rep(i, 1 << N) {
    rep(j, M)E[j] = false;
    int cnt = 0;
    rep(j, N) {
      if (i >> j & 1) { //use No.j
        cnt++;
        rep(k, M) {
          if (B[j][k] == '1')E[k] = !E[k];
        }
      }
    }
    bool flag = true;
    rep(j, M)if (E[j])flag = false;
    if (flag) ans = max(ans, cnt);
  }
  cout << ans << endl;
}

//N >= M
void mode2() {
  rep(i, 1 << M)dp[i][0] = -1;
  dp[0][0] = 0;
  bool k = 1;
  rep(i, N) {
    int W = 0;
    int d = 1;
    rep(j, M) { //入力を2進数に変換
      W += d * (B[i][M - j - 1] == '1');
      d *= 2;
    }
    rep(j, 1 << M)dp[j][k] = dp[j][!k];
    rep(j, 1 << M) {
      if (dp[j][!k] >= 0) {
        int x = j^W;
        dp[x][k] = max(dp[j][!k] + 1, dp[x][k]);
      }
    }
    k = !k;
  }
  cout << dp[0][!k] << endl;
}

int main() {
  while (true) {
    cin >> N >> M;
    if (N == 0 && M == 0)return 0;
    rep(i, N) cin >> B[i];
    if (N < M)
      mode1();
    else
      mode2();
  }
}


Measured memory_bytes: 35976
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
const int maxn = 10000001;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    //cin >> t;
   // while (t--) {
        int n;
        cin >> n;
        int dp[n][n] = {};
        f(n) {
            fr(j,0,n) {
                dp[i][j] = min({i,n-1-i,j,n-1-j});
            }
        }
        int ans = 0;
        int dx[] = {1,-1,0,0};
        int dy[] = {0,0,1,-1};
        int u[n][n] = {};
        f (n * n) {
            int x;
            cin >> x;
            x--;
            int xx = x / n;
            int yy = x % n;
            u[xx][yy] = 1;
            ans += dp[xx][yy];
            queue<pair<int,int>>q;
            q.push({xx,yy});
            while (q.size()) {
                auto now = q.front();
                q.pop();
                fr(k,0,4) {
                    int nx = now.F + dx[k];
                    int ny = now.S + dy[k];
                    if (nx < 0 || ny < 0 || nx >= n || ny >= n) {
                        continue;
                    }
                    if (dp[nx][ny] > dp[now.F][now.S] + (u[now.F][now.S] ^ 1)) {
                        dp[nx][ny] = dp[now.F][now.S] + (u[now.F][now.S] ^ 1);
                        q.push({nx,ny});
                    }
                }
            }
        }
        cout << ans << '\n';
    //}
}  


Measured memory_bytes: 5568
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
	string s,t;
	cin>>n>>s>>t;

	int count=0;
	for (int i = 1; i <= n; i++){
		if(s.substr(n-i,i)==t.substr(0,i))
			count=i;
	}

	cout<<2*n-count<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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 (b < a) { a = b; return 1; } return 0; }

#define keta setprecision(10) //10桁表示


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

	int n;
	cin >> n;
	string s;
	cin >> s;
	string tmp1 = "", tmp2 = "";

	for (int i = 0; i < n; i++)
	{
		tmp1.push_back(s[i]);
		for (int j = i + 1; j < n; j++)
		{
			tmp2.push_back(s[j]);
		}
		if (tmp1 == tmp2)
		{
			cout << "Yes" << endl;
			ret;
		}
		tmp2 = "";
	}
	cout << "No" << 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) {
	s := getNextString(scanner)
	n := len(s)
	var sum int
	for i := 0; i < n; i++ {
		sum += int(s[i] - '0')
	}
	if sum%3 == 0 {
		fmt.Fprintln(writer, "Yes")
		return
	}
	fmt.Fprintln(writer, "No")
}


Measured memory_bytes: 2196
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main() {
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if((A==B)&&A!=C)
    {
        printf("Yes\n");
    }
    else if((B==C)&&A!=C)
    {
        printf("Yes\n");
    }
    else if((A==C)&&A!=B)
    {
        printf("Yes\n");
    } else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
(defvar N (read))
(defvar y (/ (read) 1000))


(loop for A from (mod (- y N) 4) to (/ y 10) by 4
      with B = (/ (- y N (* 9 A)) 4) with C = (- N A B)
      unless (some #'minusp (list A B C))
      return (format t "~A ~A ~A" A B C)
      do (decf B 9) (incf C 5)
      finally (princ "-1 -1 -1"))

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    int N; cin >> N;
    vector<int> L(2*N);
    rep(i, 2*N) cin >> L[i];
    sort(L.begin(), L.end());

    int ans = 0;
    rep(i, N) ans += L[2*i];
    cout << ans << endl;
}



Measured memory_bytes: 256
/**
 * Created by hiramekun at 07:32 on 2020-03-31.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl a;
    a.eb(0);
    rep(i, n) {
        ll tmp;
        cin >> tmp;
        a.eb(tmp);
    }
    a.eb(0);
    n += 2;

    ll ans = 0;
    rep(i, n - 1) {
        ans += abs(a[i + 1] - a[i]);
    }

    for (ll i = 1; i < n - 1; ++i) {
        ll tmp = ans;
        tmp -= abs(a[i] - a[i - 1]);
        tmp -= abs(a[i] - a[i + 1]);
        tmp += abs(a[i - 1] - a[i + 1]);
        cout << tmp << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 2164
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




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

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<string> s(n);
  vector<ll> t(n);
  rep(i,n) cin>>s[i]>>t[i];
  string tmp;
  cin>>tmp;
  vector<ll> sum(n);
  sum[0]=t[0];
  rep(i,n-1){
    sum[i+1]=sum[i]+t[i+1];
  }
  
  ll ans=0;
  rep(i,n){
    if(s[i]==tmp){
      ans=i;
      break;
    }
  }
  cout<<Svec(t)-sum[ans]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >

#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	vl a(3); cin >> a[0] >> a[1] >> a[2];
	sort(all(a));
	cout << 10 * a[2] + a[1] + a[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int>::iterator I;
int main(){
  int n,m;cin>>n>>m;
  vector<int> v[n];
  for(int i=0;i<m;i++){
    int x,y;cin>>x>>y;
    v[y].push_back(-x);
  }
  for(int i=0;i<n;i++) sort(v[i].begin(),v[i].end());
  map<I,int> m1,m2;
  vector<I> vi;
  for(int i=0;i<n;i++){
    int t=i,b=i+1,p=-100000;
    vi.clear();
    while(1){
      if(t==0) break;
      I it = lower_bound(v[t].begin(),v[t].end(),p);
      if(it==v[t].end()) break;
      if(m1.find(it)!=m1.end()){
	t=m1[it];
	break;
      }
      p=*it;t--;
      vi.push_back(it);
    }
    for(int j=0;j<(int)vi.size();j++) m1[vi[j]]=t;
    vi.clear();
    p=-100000;
    while(1){
      if(b==n) break;
      I it = lower_bound(v[b].begin(),v[b].end(),p);
      if(it==v[b].end()) break;
      if(m2.find(it)!=m2.end()){
	b=m2[it];
	break;
      }
      p=*it;b++;
      vi.push_back(it);
    }
    for(int j=0;j<(int)vi.size();j++) m2[vi[j]]=b;
    cout << b-t << " \n"[i==n-1];
  }
  return 0;
}

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

using namespace std;

int main(){
	int n, d;
	cin >> n;
	long c = 1;
	for(int i = 0; i < n; i++){
		cin >> d;
		if(!(d & 1))
			c *= 2;
	}
	cout << (pow(3L, n) - c);
	return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)

const MOD = 1000000007

func main() {
	var s string
	fmt.Scan(&s)
	
	n := len(s)
	dp := make([][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([]int, 13)
	}

	if s[n-1] == '?' {
		for i := 0; i < 13; i++ {
			if i < 10 {
				dp[n-1][i] = 1
			} else {
				dp[n-1][i] = 0
			}
		}
	} else {
		c := int(s[n-1] - '0')
		for i := 0; i < 13; i++ {
			if i == c {
				dp[n-1][i] = 1
			} else {
				dp[n-1][i] = 0
			}
		}
	}
	
	digit := 10
	for i := n - 2; i >= 0; i-- {
		if s[i] == '?' {
			for m := 0; m < 10; m++ {
				for mod, cnt := range dp[i+1] {
					shifted := (mod + m * digit) % 13
					dp[i][shifted] += cnt
				}
			}
		} else {
			m := int(s[i] - '0')
			for mod, cnt := range dp[i+1] {
				shifted := (mod + m * digit) % 13
				dp[i][shifted] += cnt
			}
		}
		
		for j := 0; j < 13; j++ {
			dp[i][j] %= MOD
		}
		digit = (digit * 10) % 13
	}

	fmt.Println(dp[0][5])
}

Measured memory_bytes: 14592
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

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

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 2*(int)1e5 + 3;
const int MOD = (int)1e9 + 7;

int n, a, b;

int fpow(int x, int y) {
  if (y == 0)
    return 1;
  if (y&1)
    return x*fpow(x, y-1)%MOD;
  int res = fpow(x, y/2);
  return res*res%MOD;
}

int ne(int x, int y) {
  if (x == y || y == 0)
    return 1;
  int mia = 1;
  for (int i = 1; i <= y; ++i)
    mia = i*mia%MOD;
  int li = 1;
  for (int i = x-y+1; i <= x; ++i)
    li = i*li%MOD;
  return li*fpow(mia, MOD-2)%MOD;
}

signed main() {
  init_ios();
  cin >> n >> a >> b;
  int res = fpow(2, n);
  res = (res-1+MOD)%MOD;
  res = (res-ne(n, a)-ne(n, b))%MOD;
  if (res < 0)
    res += MOD;
  cout<<res<<"\n";
}

Measured memory_bytes: 256
/*
     Binary Search on prefix sum Array
*/
#include <bits/stdc++.h>
using namespace std;

#define gap " "
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

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

const int N=200009;
ll ar[N],br[N],n,m;
ll bsearch(ll sum)
{
    ll lo=0,hi=m,mid,ans=0;
    while(lo<=hi)
    {
        mid=(lo+hi)/2;
        if(br[mid]<=sum)
        {
            lo=mid+1;
            ans=mid;
        }
        else
        {
            hi=mid-1;
        }
    }
    return ans;
}
int main()
{
  //fastio; 
  ll i,r,k,num,ans,cnt,mx=0;
  scanf("%lld %lld %lld",&n,&m,&k);
  for(i=1; i<=n; i++)
  {
     scanf("%lld",&r);
     ar[i]=ar[i-1]+r;
  }

  for(i=1; i<=m; i++)
  {
     scanf("%lld",&r);
     br[i]=br[i-1]+r;
  }

  for(i=0; i<=n; i++)
  {
    r=ar[i];
    num=k-r;
    if(num>=0)
    {
       ans=bsearch(num);
       ans+=i;
       mx=max(ans,mx);
    }
  }
  printf("%lld\n",mx);
  return 0;
}

Measured memory_bytes: 6960
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        int[] dp = new int[10001];
        dp[0] = 1;
        for (int i = 0; i < n; i++) {
            for (int j = 10000; j >= 0; j--) {
                if (dp[j] == 0) {
                    continue;
                }
                if (j + a[i] <= 10000) {
                    dp[j + a[i]] = 1;
                }
            }
        }
        int ans = 0;
        for (int i = 0; i <= 10000; i++) {
            if (dp[i] == 1 && i % 10 != 0) {
                ans = Math.max(ans, i);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22740
#include "bits/stdc++.h"
using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> p(n+1);
	int x;
	for(int i=1;i<n+1;i++){
		cin>>x;
		p[x]=i;
	}
	
	vector<int> a(n+2);
	vector<int> b(n+2);
	
	a[1]=1;
	b[1]=1e9;
	
	for(int i=1;i<n+1;i++){
		if(p[i]-p[i+1]<0){
			a[i+1]=a[i]+abs(p[i]-p[i+1])+1;
			b[i+1]=b[i]-1;
		}else{
			a[i+1]=a[i]+1;
			b[i+1]=b[i]-1-abs(p[i]-p[i+1]);
		}
	}
	
	for(int i=1;i<n+1;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
	for(int i=1;i<n+1;i++){
		cout<<b[i]<<" ";
	}
	cout<<endl;
}

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int big,mid,small;
	big = max(a,max(b,c));
	small = min(a,min(b,c));
	mid = a+b+c-big-small;
	int op = 0;
	op+=(big-mid);
	int len = mid-small;
	op+=len/2;
	if(len%2) op+=2;
	cout<<op;
}

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

int main(){

    int h, w; cin >> h >> w;
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            string snuke; cin >> snuke;
            if(snuke == "snuke"){
                cout << (char)(j + 'A') << i + 1 << endl;
            }
        }
    }

    return 0;
}

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

using namespace std;

int main()
{
    #ifdef HOME
    freopen("input.txt", "rt", stdin);
    #endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(c, a));
    return 0;
}


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

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var input1 = Console.ReadLine().Split().ToArray();
            var input2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var input3 = Console.ReadLine();

            var A = input2[0];
            var B = input2[1];

            if (input3 == input1[0])
            {
                A -= 1;
            }
            else
            {
                B -= 1;
            }

            Console.WriteLine($"{A} {B}");
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<ctype.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long Abs(long long x){
	return x<0?-x:x;
}
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
long long a,sum[200007],ans=999999999999999ll;
int main(){
    int n=read();
    for(int i=1;i<=n;++i)a=read(),sum[i]=sum[i-1]+a;
    for(int i=1;i<n;++i)ans=min(ans,Abs(sum[n]-sum[i]-sum[i]));
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  i64 N;
  int X, M;
  cin >> N >> X >> M;
  vector<int> is(M+1, -1);
  vector<int> as;

  i64 x = X;
  int lc, lp;
  i64 result = 0;
  F0R(i, 100001) {
    //debug(x);
    is[x] = i;
    result += x;
    as.push_back(x);

    if (!--N) break;

    x = (x * x) % M;
    if (is[x] >= 0) {
      lc = i - is[x] + 1;
      lp = is[x];
      break;
    }
  }

  if (N) {
    i64 ls = 0; // loop sum
    FOR(i, lp, lp + lc) {
      ls += as[i];
    }
    result += N / lc * ls;
    N %= lc;

    FOR(i, lp, lp + N) {
      result += as[i];
    }
  }
  cout << result;
}
#endif


Measured memory_bytes: 3980
#include <iostream>
#include <string>
#include <sstream>
#include <vector>

#define SPACE string(" ")
using namespace std;

int main(void) {
	int n;
	cin >> n;
	cin >> ws;

	string str;
	vector<string> card;
	while (getline(cin, str)) {
		card.push_back(str);
	}

	vector<string> trump;
	for (int i = 1; i <= 52; i++) {
		stringstream ss;
		if (i <= 13) {
			ss << "S " << i;
		}
		else if (i <= 26) {
			ss << "H " << i - 13;
		}
		else if (i <= 39) {
			ss << "C " << i - 26;
		}
		else {
			ss << "D " << i - 39;
		}
		trump.push_back(ss.str());
	}

	vector<string>::iterator ti;
	for (int j = 0; j < card.size(); j++) {
		for (ti = trump.begin(); ti != trump.end();) {
			if (card[j] == *ti) {
				trump.erase(ti);
				break;
			}
			else {
				ti++;
			}
		}
	}

	for (int k = 0; k < trump.size(); k++) {
		cout << trump[k] << endl;
	}

	return 0;
}

Measured memory_bytes: 3172
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(N: int, A: "List[int]"):
    from collections import Counter
    c = Counter(A)

    for k,v in c.items():
        if(v == 2 or (k == 0 and v == 1)):
            pass
        else:
            print(0)
            exit()
        
    print((2 ** (N//2))%MOD)


    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

int main() {
    int A,B;
    cin >> A >> B;
    int count=0;
    int input=1;
    for(int i=0;i<30;i++){
        input+=(A-1);
        count++;
        if(input>=B) break;
    }
    if(B==1) cout << 0 << endl;
    else cout << count << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n,W = [int(i) for i in input().split()]
wv = [[int(i) for i in input().split()] for j in range(n)] # 縦「n」行

dp = [0]*(W+1)
dp[0]=0
newdp = [0]*(W+1)
for i in range(n):
    w, v = wv[i]
    for j in range(W+1):
        newdp[j] = dp[j]
    for j in range(W+1):
        if j+w <= W:
            newdp[j+w] = max(dp[j] + v, newdp[j+w])
    newdp, dp = dp, newdp
#    print(dp)

print(max(dp))    
    
#print(dp)

Measured memory_bytes: 43372
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    rep(i,100){
        rep(j,100){
            if(i*4+j*7 == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    
    
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc105.contest.atcoder.jp/tasks/abc105_b
// rm -r -f test;oj dl http://abc107.contest.atcoder.jp/tasks/abc107_b

Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
from collections import deque


def main():
    mod=10**9+7
    S=input()
    
    from collections import deque
    dq=deque()
    
    for c in S:
        dq.appendleft(c)
        
    rev=0
    Q=I()
    for _ in range(Q):
        q=input().split()
        if q[0]=="1":
            rev=(rev+1)%2
        else:
            f=int(q[1])
            c=q[2]
            
            if (rev+f)%2==1:
                dq.append(c)
            else:
                dq.appendleft(c)
                
    ans=[]
    if rev:
        while dq:
            ans.append(dq.popleft())
    else:
        while dq:
            ans.append(dq.pop())
            
    print(''.join(map(str, ans)))
        

        

main()


Measured memory_bytes: 144972
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

vector<int> g[N];
int n, m, Q, ans[N], ds[N], u[N];
int q[N * 100], qd[N], qb, qe, t = 1, f[N];

void paint (int c) {
        while (qb < qe) {
                int v = q[qb++];
                int d = qd[v];
                f[v]--;
                if (!f[v]) {
                        qd[v] = 0;
                }
                if (ans[v] != 0 && ds[v] >= d) {
                        continue;
                }
                if (!ans[v]) {
                        ans[v] = c;
                }
                ds[v] = d;
                if (d) {
                        for (int to : g[v]) {
                                if (u[to] != t) {
                                        u[to] = t;
                                        if (f[to] == 0) {
                                                q[qe++] = to;
                                        }
                                        f[to]++;
                                        qd[to] = max (qd[to], d - 1);
                                }
                        }
                }
        }
        qb = qe = 0; ++t;
}

int v[N], d[N], c[N];

inline void solve () {
        scanf ("%d%d", &n, &m);
        for (int i = 1; i <= m; i++) {
                int x, y;
                scanf ("%d%d", &x, &y);
                g[x].emplace_back (y);
                g[y].emplace_back (x);
        }
        scanf ("%d", &Q);
        for (int i = 1; i <= Q; i++) {
                scanf ("%d%d%d", &v[i], &d[i], &c[i]);
        }
        for (int i = Q; i >= 1; i--) {
                if (f[v[i]] == 0) {
                        q[qe++] = v[i];
                }
                f[v[i]]++;
                qd[v[i]] = max (qd[v[i]], d[i]);
                u[v[i]] = t;
                if (c[i] != c[i - 1]) {
                        paint (c[i]);
                }
        }
        for (int i = 1; i <= n; i++) {
                printf ("%d\n", ans[i]);
        }
}

int tests = 1;

int main () {
//        freopen (".in", "r", stdin);
//        freopen (".out", "w", stdout);
//        scanf ("%d", &tests);
        while (tests--) {
                solve ();
        }
        return 0;
}


Measured memory_bytes: 11768
#include<stdio.h>
int main(void){
    int a[3][3];
    int b,i,j,N,q;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            scanf("%d",&a[i][j]);
        }
    }
    scanf("%d",&N);
    for(q=0;q<N;q++){
        scanf("%d",&b);
        for(i=0;i<3;i++){
            for(j=0;j<3;j++){
            if(a[i][j] == b){
                a[i][j] = -1;
            }
            }
        }
    }
    
    for(i=0;i<3;i++){
        if(a[0][i] == a[2][i] && a[2][i] == a[1][i]){
            printf("Yes\n");
            return 0;
        }
    }
    for(i=0;i<3;i++){
        if(a[i][0] == a[i][1] && a[i][1] == a[i][2]){
            printf("Yes\n");
            return 0;
        }
    }
    if(a[0][0] == a[1][1] && a[1][1] == a[2][2]){
        printf("Yes\n");
        return 0;
    }
    if(a[2][0] == a[1][1] && a[1][1] == a[0][2]){
        printf("Yes\n");
        return 0;
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;
constexpr double EPS = 1e-10;

using Point = complex<double>;
using Line  = pair<Point, Point>;
double dot(Point p, Point q) { return (conj(p) * q).real(); }
double cross(Point p, Point q) { return (conj(p) * q).imag(); }
double slope(Line l) { return tan(arg(l.second - l.first)); }

Point project(Line l, Point p) { // project p onto line (s,t)
    return l.first + (l.second - l.first) * dot(p - l.first, l.second - l.first) / norm(l.second - l.first);
}

Point reflect(Line l, Point p) {
    return l.first + conj((p - l.first) / (l.second - l.first)) * (l.second - l.first);
}

int ccw(Point a, Point b, Point c) {
    b -= a; c -= a;
    if(cross(b, c) >  EPS) return +1; // counter-clockwise
    if(cross(b, c) < -EPS) return -1; // clockwise
    if(  dot(b, c) < -EPS) return +2; // c--a--b
    if(abs(b)+EPS < abs(c))return -2; // a--b--c
    return 0; // a--c--b
}

bool intersect(Line a, Line b) {
    return ccw(a.first, a.second, b.first) * ccw(a.first, a.second, b.second) <= 0 && 
           ccw(b.first, b.second, a.first) * ccw(b.first, b.second, a.second) <= 0;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int q;
    cin >> q;
    for(int i=0; i < q; ++i) {
        double a,b,c,d,e,f,g,h;
        cin >> a >> b >> c >> d >> e >> f >> g >> h;
        Line l1(Point(a,b),Point(c,d));
        Line l2(Point(e,f),Point(g,h));

        if(intersect(l1, l2)) cout << 1;
        else cout << 0;
        cout << '\n';
    }
    return 0;
}



Measured memory_bytes: 3340
in_num = []
conn_frg = 0
for i in range(5):
    in_num.append(int(input()))
line_num = int(input())

for j in range(4):
    k = j+1
    while k < 5:
        if abs(in_num[j] - in_num[k]) > line_num:
            conn_frg = 1
        k += 1

if conn_frg == 0:
    print('Yay!')
else:
    print(':(')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cmath>
#include <unistd.h>
#include <vector>
#include <queue>
#include <stack>
#define PI 3.14159265358979323846

using namespace std;

int main()
{
	char base;
	scanf("%c", &base);

	switch(base)
	{
		case 'A': printf("T\n");break;
		case 'T': printf("A\n");break;
		case 'C': printf("G\n");break;
		case 'G': printf("C\n");break;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    cout << a.front() << b.front() << c.front() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
using namespace std;

int main() {
    int n, a[100] = {}, m = 1000000, s[100] = {};
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int j = 0; j < 100; ++j) {
        for (int i = 0;i < n;++i) {
            s[j] += (j+1 - a[i]) * (j+1 - a[i]);
        }
        if (s[j] < m) {
            m = s[j];
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int i[11111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0;
  string s;
  cin >>s;
  if(s[0]=='o') d++;
  if(s[1]=='o') d++;
  if(s[2]=='o') d++;
  cout <<700+100*d<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
int N;
int X[10];
int Y[10];

int main() {
    cin >> N;
    int arr[10];
    rep(i, N) {
        cin >> X[i] >> Y[i];
        arr[i] = i;
    }
    double res = 0;
    do {
        double len = 0;
        int preX = X[arr[0]];
        int preY = Y[arr[0]];
        for(int i = 1; i < N; i++) {
            len = sqrt(pow((X[arr[i]]-preX), 2) + pow((Y[arr[i]]-preY), 2) );
            preX = X[arr[i]];
            preY = Y[arr[i]];
            res += len;
        }



    } while(next_permutation(arr, arr+N));
    int kai = 1;
    for(int i = 1; i <=N; i++) {
        kai *= i;
    }
    res = res /kai;
    printf("%.12f\n", res);
    return 0;
}


Measured memory_bytes: 256
// "header" {{{
#pragma GCC optimize("Ofast")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int64_t mod1 = 1000000007;
constexpr int64_t mod2 = 998244353;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){ return ((n + d -1) / d); }
inline int square(int a){ return a * a; }
// }}}

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<double> p(n+1);
    vector<vector<double> > dp(n+1,vector<double>(n+1));

    reps(i,n){
        cin >> p[i];
    }

    dp[0][0] = 1;
    reps(i,n){
        rep(j,n+1){
            if(j == 0){
                dp[i][j] = dp[i-1][j] * (1 - p[i]);
            }else{
                dp[i][j] = dp[i-1][j] * (1 - p[i]) + dp[i-1][j-1] * p[i];
            }
        }
    }
    
    double res = 0;
    for(int i = n; i >= updiv(n,2); --i){
        res += dp[n][i];
    }

    cout << Fixed << res << '\n';

    return 0;
}


Measured memory_bytes: 70784
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>
#include <cassert>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <ll,int> P;

ll B[SIZE],L[SIZE],U[SIZE];
P pos[SIZE];

int main()
{
	int n;
	ll X;
	scanf("%d %lld",&n,&X);
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld %lld %lld",&B[i],&L[i],&U[i]);
		pos[i]=P((X-B[i])*U[i]+B[i]*L[i],i);
		sum-=B[i]*L[i];
	}
	sort(pos,pos+n);
	ll ret=0;
	int last=0;
	for(int i=n-1;i>=0;i--)
	{
		P p=pos[i];
		if(sum+p.first>=0)
		{
			ret+=(ll) (n-i-1)*(ll) X;
			last=i+1;
			break;
		}
		sum+=p.first;
	}
	ll mn=X;
	sum=-sum;
	for(int i=0;i<last;i++)
	{
		int v=pos[i].second;
		mn=min(mn,(sum+L[v]-1)/L[v]);
		ll nsum=sum+B[v]*(U[v]-L[v]);
		mn=min(mn,(nsum+U[v]-1)/U[v]);
	}
	for(int i=last;i<n;i++)
	{
		int v=pos[i].second;
		ll nsum=sum+pos[i].first-pos[last-1].first;
		mn=min(mn,(nsum+L[v]-1)/L[v]);
		ll nsum2=nsum+B[v]*(U[v]-L[v]);
		mn=min(mn,(nsum2+U[v]-1)/U[v]);
	}
	printf("%lld\n",ret+mn);
	return 0;
}


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

int main() {
    int a,b,ans;
    cin >> a >> b;
    ans = a * b;
    if(a <= 9 && b <= 9 && ans < 82) {
        cout << ans << endl;
    }else {
        cout << -1 << endl;
    }

    
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int gcd(int x, int y){
  if(y==0)return x;
  return gcd(y,x%y);
}

int main(void){

  int x,y;
  cin >> x >> y;
  cout << gcd(x,y) << endl;
  
  return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  map<ll, ll> mp;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += mp[i - a.at(i)];
    mp[i + a.at(i)]++;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 27360
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;

bool cmp(pair<int,int> a, pair<int,int> b) { return a.second < b.second; }

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<int,int> > vp(M);
  rep(i,M){
    int a,b;
    cin >> a >> b;
    a--; b--;
    vp[i].first = a;
    vp[i].second = b;
  }
  sort(vp.begin(), vp.end(), cmp);
  
  int mi = 0;
  int ans = 0;
  rep(i,M){
    if(vp[i].first >= mi){
      mi = vp[i].second;
      ans++;
    }
  }
  cout << ans << endl;
}

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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;

bool is_product_overflow(ull a, ull b) {
	ull prod = a * b;
	return (prod / b != a);
}

void Main()
{
	int N;
	std::cin >> N;
	std::vector <ull> vec(N);
	for (auto& v : vec)
	{
		std::cin >> v;
	}

	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		const auto& x = vec[i];
		for (int j = i + 1; j < N; ++j) {
			const auto& y = vec[j];
			for (int k = j + 1; k < N; ++k) {
				const auto& z = vec[k];
				if(x + y <= z || y + z <= x || z + x <= y)
				{
					continue;
				}
				if (x != y && y != z && z != x) {
					if (x + y > z || x + z > y || y + z > x) {
						cnt++;
					}
				}
			}
		}
	}
	cout << cnt;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

struct State{
  std::vector<int> seq;
  int count=0;
  State(std::vector<int> s,int c):seq(s),count(c){}
};

int Solve(int k){

  std::string ini,unl;
  cin>>ini>>unl;
  std::stack<State> stk;
  std::vector<int> ini_vec(k);
  std::vector<int> unl_vec(k);
  for(int i=0;i<k;i++){
    ini_vec[i]=ini[i]-'0';
    unl_vec[i]=unl[i]-'0';
  }
  stk.push(State(ini_vec,0));
  int result=INT32_MAX;
  while(!stk.empty()){
    State curr=stk.top();
    stk.pop();
    bool found_odd=false;
    for(int i=0;i<k;i++){
      if(curr.seq[i]!=unl_vec[i]){
        //なおす
        found_odd=true;
        // int modifier_a=curr.seq[i]-unl_vec[i];
        int modifier_b=unl_vec[i]-curr.seq[i];
        std::vector<int> seq_a=curr.seq,seq_b=curr.seq;
        for(int j=i;j<k;j++){
          // seq_a[j]+=modifier_a;
          seq_b[j]+=modifier_b;
          // if(seq_a[j]<0){
          //   seq_a[j]+=10;
          // }else if(seq_a[j]>=10){
          //   seq_a[j]-=10;
          // }
          if(seq_b[j]<0){
            seq_b[j]+=10;
          }else if(seq_b[j]>=10){
            seq_b[j]-=10;
          }
          // stk.push(State(seq_a,curr.count+1));
          stk.push(State(seq_b,curr.count+1));
        }

        break;
      }
    }
    if(!found_odd){
      result=std::min(result,curr.count);
    }
  }

  return result;

}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  while(true){
    int k;
    cin>>k;
    if(k==0) break;
    cout<<Solve(k)<<endl;
  }



  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF = 1000000000000000;

string s;
int main(){
	int a, b, cnt=0,sum=1;
	cin >> a >> b;

	while(sum < b){
		sum+=a-1;
		cnt++;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256