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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b + c >= 22)
		cout << "bust" << endl;
	else
		cout << "win" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#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 Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string s,t;
    cin >> s >> t;
    int ans = 0;
    REP(i, 3){
        if(s[i]==t[i])ans++;
    }
    pr(ans);
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Stack;


class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){

		while(in.hasNext()){
			int n = in.nextInt();
			if(n == 0) return;
			System.out.println(toOct(n));
		}
		
	}

	String toOct(int n) {
		if(n == 0) return new String("0");
		StringBuilder ret = new StringBuilder();
		while(n > 0){
			int m = n % 8;
			if(m >= 4) m++;
			if(m > 5) m++;
			ret.append((char)('0' + m));
			n /= 8;
		}
		ret.reverse();
		return ret.toString();
	}

}

Measured memory_bytes: 54904
import java.util.*;

public class Main{
    public static edge[][] V=new edge[30][30];
    
    public static void main(String[] args){
        Scanner cin=new Scanner(System.in);
        while(true){
            int n=cin.nextInt();
            if(n==0)break;
            int m=cin.nextInt();
            int p=cin.nextInt();
            int a=cin.nextInt()-1;
            int b=cin.nextInt()-1;
            int[] ti=new int[n];
            int[] Vs=new int[m];
            for(int i=0;i<n;i++)ti[i]=cin.nextInt();

            Arrays.fill(Vs,0);

            for(int i=0;i<p;i++){
                int x=cin.nextInt()-1;
                int y=cin.nextInt()-1;
                int z=cin.nextInt();
                V[x][Vs[x]++]=new edge(y,z);
                V[y][Vs[y]++]=new edge(x,z);
            }
            Queue<node> q=new PriorityQueue<node>();
            q.add(new node(0,a,0));

            double[][] vis=new double[m][1<<n];
            Boolean[][] fix=new Boolean[m][1<<n];
            for(int i=0;i<m;i++){
                Arrays.fill(vis[i],1<<28);
                Arrays.fill(fix[i],false);
            }
            
            double ans=-1;
            
            while(q.isEmpty()==false){
                node cn=q.poll();

                if(fix[cn.v][cn.st])continue;
                fix[cn.v][cn.st]=true;
                if(cn.v==b){
                    ans=cn.cc;
                    break;
                }

                for(int i=0;i<n;i++){
                    if(((cn.st>>i)&1)==1)continue;
                    for(int j=0;j<Vs[cn.v];j++){
                        int nv=V[cn.v][j].v;
                        int tc=V[cn.v][j].c;
                        int nst=cn.st|(1<<i);
                        double nc=cn.cc+1.0*tc/ti[i];                        
                        if(vis[nv][nst]<=nc)continue;
                        vis[nv][nst]=nc;
                        q.add(new node(nc,nv,nst));
                    }
                }
            }
            if(ans<0)System.out.println("Impossible");
            else System.out.println(ans);
        }
    }

    public static class edge{
        public int v,c;
        public edge(int iv,int ic){
            v=iv;
            c=ic;
        }
    }
}

class node implements Comparable<node>{
    public double cc;
    public int v,st;
    public node(double icc,int iv,int ist){
        cc=icc;
        v=iv;
        st=ist;
    }
    public int compareTo(node s){
        if(cc>s.cc)return 1;
        else if(cc<s.cc)return -1;
        else return 0;
    }
}

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

const int N = 3005;
const long long INF = 0x3f3f3f3f3f3f3f3f;

int n, m, k;
long long g[N][N], f[N][N][5];

int main()
{
	scanf("%d%d%d", &n, &m, &k);
	for(int i = 0, r, c; i < k; ++i)
	{
		scanf("%d%d", &r, &c);
		scanf("%lld", &g[r][c]);
	}

	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
		{

			f[i][j][0] = max(f[i][j-1][0], f[i-1][j][4]);
			f[i][j][4] = f[i][j][0];
			for(int l = 1; l <= 3; ++l)
			{
				f[i][j][l] = max(max(f[i][j-1][l], f[i-1][j][4] + g[i][j]), f[i][j-1][l-1] + g[i][j]);
				f[i][j][4] = max(f[i][j][4], f[i][j][l]);
			}
		}

	cout << f[n][m][4]<< endl;
	return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int M = 200000;
int n, a[M], b[M];

int main() {
	cin >> n;
	inc(i, n) { scanf("%d", & a[i]); }
	inc(i, n) { scanf("%d", & b[i]); }
	
	int ans = 0;
	dec(k, 28 + 1) {
		inc(i, n) {
			a[i] &= (2 << k) - 1;
			b[i] &= (2 << k) - 1;
		}
		sort(a, a + n);
		sort(b, b + n, greater<>());
		
		int c = 0, p1 = 0, p2 = 0, p3 = 0;
		inc(i, n) {
			while(p1 < n && a[i] + b[p1] >= (1 << k)) { p1++; }
			while(p2 < n && a[i] + b[p2] >= (2 << k)) { p2++; }
			while(p3 < n && a[i] + b[p3] >= (3 << k)) { p3++; }
			c ^= (p1 - p2 + p3) & 1;
		}
		ans |= c << k;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

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

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

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }
  
  int N;
  cin >> N;
  
  for(int i = 0; i < N; i++) {
 	int b;
    cin >> b;
    for(int j = 0; j < 3; j++) {
      for(int k = 0; k < 3; k++) {
        if(A[j][k] == b) {
          A[j][k] = 0;
        }
      }
    }
  }
  
  for(int i = 0; i < 3; i++) {
    if(A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0) {
      cout << "Yes" << endl;
      return 0;
    }
    else if(A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  if(A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  else if(A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }
    ull operator"" _64u(unsigned long long x){ return ull(x); }

    template<class T>
    vector<T> make_vector(int n, T t){
        return vector<T>(n, t);
    }
    template<class ...Ts>
    auto make_vector(int n, Ts ... ts){
        return vector<decltype(make_vector(ts...))>(n, make_vector(ts...));
    }

    template<class T>
    ostream& operator<<(ostream& os, const vector<T>& v){
        for (auto &&x : v) { os << x << ' '; } cout << endl; return os ;
    }
}
using namespace utils;

class solver{
    istream& is;
    ostream& os;

public:
    solver(istream& I, ostream& O) :is(I), os(O) {}
    void run(){
        ll N;
        is >> N;
        if(!is) return;
        vector<int> d(N);
        for (int i = 0; i < N; ++i) {
            is >> d[i];
        } // end i
        ll sum = 0;
        for (int i = 0; i < N; ++i) {
            for (int j = i + 1; j < N; ++j) {
                sum += d[i] * d[j];
            } // end j
        } // end i
        os << sum << endl;

    }
};

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_A.txt";
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int loop = 0;
    while(fs) {
        loop++;
        cout << '#' << loop << "#------\n";
        solver(fs, cout).run();
    }
    if(loop <= 1) {
        cout << "===" << endl;
        while(cin) solver(cin, cout).run();
    }
#else
    solver(cin, cout).run();
#endif
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    ll n;
    cin >> n;
    string ans ;
    ll c = 26;
    while(n > 0){
        --n;
        ans += (n%26) + 'a' ;
        n /= 26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, q;
    cin >> n >> q;
    fenwick_tree<int> fw(n);
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        fw.add(i, a);
    }
    for(int qq=0; qq<q; qq++){
        int t, a, b;
        cin >> t >> a >> b;
        if(t) cout << fw.sum(a, b) << endl;
        else fw.add(a, b);
    }

    return 0;
}

Measured memory_bytes: 8216
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

constexpr int MOD = 1000000007;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> vp;
    for (int i = 1; i * i <= N; i++)
    {
        vp.emplace_back(i);
        if (i != N / i) vp.emplace_back(N / i);
    }

    sort(vp.begin(), vp.end());
    vector<lint> dp(vp.size());
    dp[0] = 1;
    REP(_, K)
    {
        reverse(dp.begin(), dp.end());
        IREP(i, dp.size() - 1)
        {
            (dp[i] += dp[i + 1]) %= MOD;
            (dp[i + 1] *= vp[i + 1] - vp[i]) %= MOD;
        }
    }
    cout << accumulate(dp.begin(), dp.end(), 0LL) % MOD << endl;
}


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

#define IO  ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define endl '\n'
#define f first
#define s second
#define ll long long
#define ld long double
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;
const int M=1e5+5;

int main() {
    IO
    int n,cnt=0;
    cin>>n;
    int arr[n+5],mn=1e9,x=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]%2==0) cnt++;
        x=0;
        while(arr[i]%2==0){
            x++;
            arr[i]/=2;
        }
        mn=min(mn,x);
    }
    if(cnt!=n){
        return cout<<0,0;
    }
    cout<<mn;
    return 0;
}


Measured memory_bytes: 3592
module diverta2019_1

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_A

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_A

    ! variables for this <subroutine>
    integer(INT8) :: len_sequence_total
    integer(INT8) :: len_sequence_consecutive

    ! STEP.01
    ! read out the ...
    ! 1. length of the given sequence
    ! 2. length of the       sequence to choose consecutively
    read(unit=INPUT_UNIT, fmt=*) len_sequence_total, len_sequence_consecutive

    ! STEP.02
    ! calculate the how many ways are there to choose `len_sequence_consecutive` consecutive integers ?
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') len_sequence_total - len_sequence_consecutive + 1_INT8

    ! STEP.END
    return

  end subroutine task_A

end module diverta2019_1


program main

  ! <module>s to import
  use, non_intrinsic :: diverta2019_1

  ! require all variables to be explicitly declared
  implicit none

  call task_A

end program main

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
main()
{
map<long long int, long long int >m;
long long int n, i, ans = 0;
cin >> n;
long long int a[n];
for(i=0;i<n;i++)
{
cin >> a[i];
m[a[i]]++;
}
for(auto it : m)
{
	ans+=((it.second*(it.second-1))/2);
}
for(i=0;i<n;i++)
{
	ans-=((m[a[i]]*(m[a[i]]-1))/2);
	ans+=(((m[a[i]]-1)*(m[a[i]]-2))/2);
	  cout << ans << endl;
	ans-=(((m[a[i]]-1)*(m[a[i]]-2))/2);
	ans+=((m[a[i]]*(m[a[i]]-1))/2);	  
}
	return 0;
}

Measured memory_bytes: 11008
sx, sy, tx, ty = [int(x) for x in input().split()]
dx = tx - sx
dy = ty - sy
print(dy*"U" + dx*"R" + dy*"D" + dx*"L" + "L" + (dy+1)*"U" + (dx+1)*"R" + "D" + "R" + (dy+1)*"D" + (dx+1)*"L" + "U")

Measured memory_bytes: 3060
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=ja
from heapq import heappop, heappush
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


class Dijkstra:
    """
    shortest_distansce(g): startノードからgoalノードまでの最短距離
    shortest_path(g): startノードからgoalノードまでの最短経路
    """
    def __init__(self, graph, start):
        """
        graph: 隣接リストによるグラフ
        start: 始点のノード番号
        """
        self.g = graph
        self.V = len(graph)

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = [float('inf')] * (self.V)
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = [None] * (self.V)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (0, start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if dist_u > self.dist[u]:
                continue
            for v, weight in self.g[u]:
                alt = self.dist[u] + weight
                if alt < self.dist[v] :
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        return self.dist[goal]

    def shortest_path(self, goal):
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]


def main():
    N,_,start,*edge = map(int, read().split())
    
    E = [[] for _ in range(N)]
    for a, b, w in zip(*[iter(edge)]*3):
        E[a].append((b, w))

    dijkstra = Dijkstra(E, start)
    
    for i in range(N):
        d = dijkstra.shortest_distance(i)
        if d == float('inf'):
            print("INF")
        else:
            print(d)


if __name__ == "__main__":
    main()


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

int main() {
    // input
    int N, Y;
    cin >> N >> Y;

    // solve
    int x = -1, y = -1, z = -1;

    for (int i = 0; i < N + 1; ++i) {
        for (int j = 0; j < N + 1; ++j) {
            if ((N - i - j) >= 0 && Y == 10000 * i + 5000 * j + 1000 * (N - i - j)) {
                x = i;
                y = j;
                z = N - i - j;
            }
        }
    }

    // output
    cout << x << " " << y << " " << z << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(int I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
int gcd(int a,int b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
int lcm(int a,int b){int c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	list<int> lst;
	list<int>::iterator itr = lst.begin();
	// 0 insert
	// 1 move
	// 2 erase
	int q;
	cin >> q;
	while(q--){
		int x,d;
		cin >> x;
		if(x!=2)cin>>d;
		if(x==0){
			itr = lst.insert(itr,d);
		}else if(x==1){
			for(int i=0;i<abs(d);i++){
				if(d<0)itr--;
				else itr++;
			}
		}else{
			itr = lst.erase(itr);
		}
	}
	for(itr = lst.begin();itr!=lst.end();++itr){
		cout << *itr << endl;
	}
}


Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n,a,b;
  cin >>n>>a>>b;
  string s;
  cin>>s;
  int goukaku=1;
  int count_B=1;
  rep(i,n){
    if(s[i]=='c'){
      cout<<"No"<<endl;
    }else if(s[i]=='b'){
      if(goukaku<=a+b&&count_B<=b){
        cout<<"Yes"<<endl;
        count_B++;
        goukaku++;
      }else{
        cout<<"No"<<endl;
      }
    }else{
      if(goukaku<=a+b){
        cout<<"Yes"<<endl;
        goukaku++;
      }else{
        cout<<"No"<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  int a[4]={0};
  for(int i=0;i<n;++i)
  {
    cin>>s;
    if(s=="AC")
      a[0]++;
    else if(s=="WA")
      a[1]++;
    else if(s=="TLE")
            a[2]++;
    else
            a[3]++;
  }
   for(int i=0;i<4;++i)
            {
              if(i==0)
                cout<<"AC x "<<a[i]<<endl;
         	  if(i==1)
                cout<<"WA x "<<a[i]<<endl;
              if(i==2)
                cout<<"TLE x "<<a[i]<<endl;
              if(i==3)
                cout<<"RE x "<<a[i]<<endl;
            }
           return 0;
  
}

Measured memory_bytes: 3236
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

function main()
    s, t = reads(String, String)
    println(s == t[begin:end-1] ? "Yes" : "No")
end

main()


Measured memory_bytes: 188900
/*
* @author:  codancer
* @createTime:  2020-07-05, 20:19:00
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
const int N = 1e6+100;
ll a[N];
int main(){
	int n;
	cin>>n;
	rep(i,1,n){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	ll ans=0;
	ans+=a[1];//a[2]
	int cnt=2;
	for(int i=3;i<=n;i++){
		ans+=a[cnt];
		if(i%2==0) ++cnt;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  string cards;
  string str1, str2;
  int m,h;

  for (;;){
    cin >> cards;
    if (cards == "-") break;

    cin >> m;

    for (int i = 0; i < m; i++){
      cin >> h;
      str1 = cards.substr(0,h);
      str2 = cards.substr(h,cards.size());
      cards = str2 + str1;
    }
    cout << cards << endl;
  }

  return 0;
}

Measured memory_bytes: 3196
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll tmp = 0;
    ll tmp_ans = 0;
    ll ans = 0;
    FOR(i,0,n){
        ll in;
        cin>>in;
        if(tmp>=in){
            tmp_ans++;
            tmp = in;
        }
        else{
            tmp = in;
            tmp_ans = 0;
        }
        ans = max(ans, tmp_ans);        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    dots = inputs[0].split(' ')
    types = set()
    for d in dots:
        types.add(d)
        if len(types) == 4:
            return "Four"
    return "Three"


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 4068
#include <stdio.h>
#define MAX 45

int F[MAX];

int fibonacci(int n){
  if(F[n] != -1) return F[n];
  if(n == 0 || n == 1){
    F[n] = 1;
  }else{
    F[n] = fibonacci(n-1) + fibonacci(n-2);
 }
  return F[n];
}

int main(void){
  int n, f;
  scanf("%d", &n);
  for(int i=0; i<=n; i++){
    F[i] = -1;
  }
  f = fibonacci(n);
  printf("%d\n", f);
  return 0;
}



Measured memory_bytes: 2664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll modpow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b&1)return a*modpow(a,b-1)%mod;
    ll k=modpow(a,b/2);
    return k*k%mod;
}
int main(){
    ll n,k;cin>>n>>k;
    vi hu,zero,sei;
    rep(i,n){
        ll a;cin>>a;
        if(a<0)hu.pb(-a);
        else if(a==0)zero.pb(a);
        else sei.pb(a);
    }
    sort(all(hu));sort(all(sei));
    if(hu.size()*sei.size()>=k){
        ll ng=0,ok=1e18+1;
        while(ok-ng>1){
            ll md=(ok+ng)/2;
            ll num=0;
            for(auto x:hu)num+=sei.size()-ub(sei,md/x);
            if(num<k)ok=md;
            else ng=md;
        }
        out(-ok);
        return 0;
    }
    k=n*(n-1)/2+1-k;
    if(hu.size()*(hu.size()-1)/2+sei.size()*(sei.size()-1)/2>=k){
        ll ng=0,ok=1e18+1;
        while(ok-ng>1){
            ll md=(ok+ng)/2;
            ll num=0;
            for(auto x:hu){
                num+=hu.size()-ub(hu,md/x);
                if(x*x>md)num--;
            }
            for(auto x:sei){
                num+=sei.size()-ub(sei,md/x);
                if(x*x>md)num--;
            }
            if(num/2<k)ok=md;
            else ng=md;
        }
        out(ok);
        return 0;
    }
    out(0);
}

Measured memory_bytes: 2548
import * as fs from 'fs';

namespace AtCoder.abc110 {

    class Program {
        /**
         * in
         *  1 5 2
         * out
         *  53
         */
        main(inp: string): void {
            const abc: number[] = inp.split(' ').map(Number);
            const abcSorted:number[] = abc.sort((a, b) => b - a);

            const x: string = abcSorted.slice(0, 2).join('');
            const y: string = abcSorted.slice(2).join('');

            console.log(parseInt(x) + parseInt(y));
        }
    }

    const prg = new Program();
    prg.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
}


Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
// #define mp make_pair
#define nt _int128
#define mod 1000000007
ll n,w,arr[105],brr[105];
ll dp[105][200005];
ll func()
{
    ll mx=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=100005;j++)
        {
            if(brr[i]>j)
                dp[i][j]=dp[i-1][j];
            else
            {
                dp[i][j]=dp[i-1][j];
                if(j==brr[i])
                {
                    if(dp[i][j]!=0)
                        dp[i][j]=min(dp[i][j],arr[i]);
                    else
                        dp[i][j]=arr[i];
                }
                else
                {
                    if(dp[i-1][j-brr[i]]!=0)
                    {
                        ll z=dp[i-1][j-brr[i]]+arr[i];
                        if(dp[i][j]==0)
                            dp[i][j]=z;
                        else
                            dp[i][j]=min(dp[i][j],z);
                    }
                }
            }

            if(dp[i][j]>0 and dp[i][j]<=w)
                mx=max(mx,j);
        }
    }
    // for(ll i=1;i<=n;i++)
    // {
    //     for(ll j=1;j<=28;j++)
    //         cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    return mx;

}
int main()
{
// #ifndef ONLINE_JUDGE
//        freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
        
        cin>>n>>w;
        for(ll i=1;i<=n;i++)
        {
            ll a,b;
            cin>>a>>b;
            arr[i]=a;
            brr[i]=b;
        }
        cout<<func();
    }
    return 0;
}

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

const int N = 100 * 1000 + 20;
int n;
long long ans = 1, inf = 1e18, a[N];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		if (!a[i])
			return cout << 0 << "\n", 0;
	for (int i = 0; i < n; i++) {
		if (inf / ans < a[i]) {
			cout << "-1\n";
			return 0;
		}
		ans *= a[i];
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 4416
#include <iostream>
using namespace std;
int main()
{
	int arr[5];
	for (int i = 0; i < 5; i++)
	{
		cin >> arr[i];
		if (arr[i] == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  if (n % 2 == 1) {
    int mid = (n + 1) / 2 - 1;
    cout << abs(b[mid] - a[mid]) + 1 << endl;
  } else {
    int mid0 = n / 2 - 1;
    int mid1 = n / 2;
    ll a_mid_2 = a[mid0] + a[mid1];
    ll b_mid_2 = b[mid0] + b[mid1];
    cout << abs(b_mid_2 - a_mid_2) + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 6428
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto L = new long[](N);
    auto R = new long[](N);
    foreach (i; 0 .. N)
    {
        long x, l;
        scan(x, l);
        L[i] = x - l;
        R[i] = x + l;
    }
    zip(R, L).sort();
    long cur = long.min;
    long ans;
    // writeln(L);
    // writeln(R);
    foreach (i; 0 .. N)
        if (cur <= L[i])
        {
            ans++;
            cur = R[i];
            // writefln("%s %s", L[i], R[i]);
        }
    writeln(ans);
}


Measured memory_bytes: 4732
#include <stdio.h>
#include <string.h>
int main(void)
{
    int info;
    char JOIOI[10000],i;
    while(scanf("%d",info)!=EOF)
    {
        int JOI=0,IOI=0;
        scanf("%s",&JOIOI);
        for(i=0;i<strlen(JOIOI)-2;i++)
        {
            if(JOIOI[i]=='J')
                if(JOIOI[i+1]=='O')
                    if(JOIOI[i+2]=='I')
                        JOI++;
            if(JOIOI[i]=='I')
                if(JOIOI[i+1]=='O')
                    if(JOIOI[i+2]=='I')
                        IOI++;
        }
        printf("%d\n%d\n",JOI,IOI);
    }
    return 0;
}

Measured memory_bytes: 548
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int days = sc.nextInt();
			char[] resp = sc.next().toCharArray();

			int[][] s = new int[2][7]; // scheduleCount
			s[0][0] = 1;
			final int d = 10007; // divider

			int p = 0; // previous
			for(int i = 0; i < days; i++) {
				p = (i + 1) % 2;
				final int c = i%2; // cursor
				switch(resp[i]) {
				case 'J':
			s[p][0]=(s[c][0]+s[c][1]+s[c][2]+s[c][6])%d;
			s[p][1]=(s[c][0]+s[c][1]+s[c][2]+s[c][4]+s[c][5]+s[c][6])%d;
			s[p][2]=(s[c][0]+s[c][1]+s[c][2]+s[c][3]+s[c][4]+s[c][6])%d;
					break;
				case 'O':
			s[p][2]=(s[c][0]+s[c][1]+s[c][2]+s[c][3]+s[c][4]+s[c][6])%d;
			s[p][3]=(s[c][2]+s[c][3]+s[c][4]+s[c][6])%d;
			s[p][4]=(s[c][1]+s[c][2]+s[c][3]+s[c][4]+s[c][5]+s[c][6])%d;
					break;
				case 'I':
			s[p][1]=(s[c][0]+s[c][1]+s[c][2]+s[c][4]+s[c][5]+s[c][6])%d;
			s[p][4]=(s[c][1]+s[c][2]+s[c][3]+s[c][4]+s[c][5]+s[c][6])%d;
			s[p][5]=(s[c][1]+s[c][4]+s[c][5]+s[c][6])%d;
					break;
				}
		s[p][6]=(s[c][0]+s[c][1]+s[c][2]+s[c][3]+s[c][4]+s[c][5]+s[c][6])% d;
				s[c] = new int[8];
			}
			int sum = 0;
			for(int sch :s[p]) {
				sum += sch;
			}
			System.out.println(sum % d);
		}
	}
}


Measured memory_bytes: 26240
#include <iostream>
using namespace std;
 
int main() 
{
  long long int a, b, x, count;
  cin >> a >> b >> x;
  if (a == 0) 
    count = b / x + 1;
  else
    count =  b / x - (a - 1) / x;
  cout << count << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
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<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

int sx, sy, tx, ty;
void solve(char u, char d, char l, char r) {
    rep(i, abs(tx - sx)) cout << (tx > sx ? r : l);
    rep(i, abs(ty - sy)) cout << (ty > sy ? u : d);
    
    rep(i, abs(tx - sx)) cout << (tx > sx ? l : r);
    rep(i, abs(ty - sy)) cout << (ty > sy ? d : u);
    
    cout << d;
    
    rep(i, abs(tx - sx) + 1) cout << (tx > sx ? r : l);
    rep(i, abs(ty - sy) + 1) cout << (ty > sy ? u : d);
    
    cout << l;
    cout << u;
    
    rep(i, abs(tx - sx) + 1) cout << (tx > sx ? l : r);
    rep(i, abs(ty - sy) + 1) cout << (ty > sy ? d : u);
    
    cout << r;
    
    cout << endl;
}
int main() {
    
    cin >> sx >> sy >> tx >> ty;
    
    if ((sx <= tx && sy <= ty) || (sy <= ty && sx >= tx)) {
        solve('U', 'D', 'L', 'R');
    } else {
        solve('D', 'U', 'R', 'L');
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,T;
	scanf("%d%d",&n,&T);
	int Mn=1e9;
	for (int i=1;i<=n;i++){
		int x,y; scanf("%d%d",&x,&y);
		if (y<=T) Mn=min(Mn,x);
	}
	if (Mn==1e9) puts("TLE");
	else printf("%d\n",Mn);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int ds[100100], dt[100100];
string s, t;
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    cin >> s >> t;
    for (int i = 0; i < (int) s.size(); i++) {
        if (s[i] == 'A') ds[i + 1] = ds[i] + 1;
        else ds[i + 1] = ds[i] - 1;
    }
    for (int i = 0; i < (int) t.size(); i++) {
        if (t[i] == 'A') dt[i + 1] = dt[i] + 1;
        else dt[i + 1] = dt[i] - 1;
    }

    int q;
    cin >> q;
    while (q--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int v = (ds[b] - ds[a - 1]) - (dt[d] - dt[c - 1]);
        if (v % 3) cout << "NO\n";
        else cout << "YES\n";
    }
}

Measured memory_bytes: 1744
#include <iostream>

int main(int argc, char const* argv[]) {
  using namespace std;

  int k, x;

  cin >> k;
  cin >> x;

  for (int i = x - k + 1; (i <= x + k - 1 && i <= 1000000); i++) {
    if (x >= -1000000)
      cout << i << " ";
  }

  cout << endl;

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector <long> hp(n);
    rep(i,n) cin >> hp[i];

    sort(all(hp));

    bool ok=true;

    while(ok){
        sort(all(hp));
        while(hp[0]==0){
            hp.erase(hp.begin(),hp.begin()+1);
        }
        if(hp.size()==1) ok=false;
        else{
            for(int i=1; i<hp.size(); i++){
                hp[i] = hp[i] % hp[0];
            }
        }
    }

    cout << hp[0] << endl;
}

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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int h, w, x;
char a[1001][1001];
int dp[1001][1001];

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> h >> w;
  rep(i, 1, h){
  	rep(j, 1, w){
  		cin >> a[i][j];
  	}
  }
  rep(i, 1, h){
  	rep(j, 1, w){
  		dp[i][j]=0;
  	}
  }
  dp[1][1]=1;
  rep(i, 1, h){
  	rep(j, 1, w){
  		if(i==1 && j==1) continue;
  		if(a[i][j]=='#') continue;
  		dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
  		// cout << "dp["<<i<<"]["<<j<<"] "<<dp[i][j]<<endl;
  	}
  }

  cout << dp[h][w];
}

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

typedef long long ll;

int main(){
  ll N;
  cin >> N;
  vector<ll> Ai(N);
  for (int i=0;i<N;i++){
    cin >> Ai[i];
  }
  ll p=0,q=0;
  for (int i=0;i<N;i=i+2){
    p += Ai[i];
  }
  for (int i=1;i<N;i=i+2){
    q += Ai[i];
  }
  vector<ll> Mi(N);
  Mi[0] = p - q;
  for (int i=0;i<N-1;i++){
    Mi[i+1] = (Ai[i] - Mi[i]/2)*2;
  }
  for (int i=0;i<N;i++){
    cout << Mi[i];
    if (i==N-1) cout << endl;
    else cout << " ";
  }

  return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

ll euclidean_gcd(ll a, ll b) {
    while (1) {
        if (a < b) swap(a, b);
        if (!b) break;
        a %= b;
    }
    return a;
}

vector< ll > divisor(ll n) {
    vector< ll > ret;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

bool is_prime(ll num)
{
    if(num<2)return false;
    else if(num==2)return true;
    else if(num%2==0)return false;

    ll sqrt_num=sqrt(num);
    for (ll i =3 ; i <= sqrt_num; i+=2)
    {
        if(num%i==0) return false;
    }
    return true;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    ll gcd = euclidean_gcd(a, b);
    vector<ll> c_divisors = divisor(gcd);
    vector<ll> ans;
    int size = c_divisors.size();
    ans.push_back(1);
    for (int i = 1; i < size; i++)
    {
        if(is_prime(c_divisors[i])) ans.push_back(c_divisors[i]);
    }
    cout<<ans.size()<<endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main () {
	int k;
	int n;
	char A, B, C;
	
	scanf("%d %d", &n, &k);
	getchar();
	char s[n];
	scanf("%s", &s);
	s[k-1] += 32; 
	printf("%s", s);
	return 0;
}

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

int main(){
    int N,M,C;
    cin >> N >> M >> C;
    vector<int> B(M);
    rep(i,M) cin >> B[i];
    vector<vector<int>> A(N,vector<int>(M));
    rep(i,N) rep(jj,M) cin >> A[i][jj];

    int cnt = 0;

    rep(i,N){
        int value = C;
        rep(jj,M) value += A[i][jj]*B[jj];
        if(value >0) cnt++;
    }

    cout << cnt << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
 
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N,K;cin>>N>>K;
    int ans(1);
    while(N--){
        int a=ans*2;
        int b=ans+K;
        ans=min(a,b);
    }
    cout<<ans<<endl;
	return 0;
}


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

int main(void){
    long long n;cin>>n;
    if(n%2!=0){
        cout<<0<<endl;
        return 0;
        //元が奇数だとどうあがいても偶数には行きつかないから
    }
    //2の倍数は腐るほど沸くから5の倍数をどう集めるかがカギ 10の倍数の中でしか出ないし5^nをどう出すか
    long long dight=5,res=0,now=0;
    while(dight<=n){
        now=n/dight;
        now/=2;res+=now;
        dight*=5;
    }
    cout<<res<<endl;
}



Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

// dp[i+1][j] = 消さずに残しておいた列の数がj個で, 残っている列の最右indexがiのときの最小コスト
// dp[i+1][j] = min(dp[k+1][j-1] + max(H[i] - H[k], 0)) where k <= i-1
int dp[305][305];

signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> H(N+1, 0);
    for (int i = 0; i < N; i++) cin >> H[i+1];
    fill(dp[0], dp[N+1], INF);
    dp[0][0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= N-K; ++j) {
            for (int k = -1; k <= i-1; ++k) {
                dp[i+1][j] = min(dp[i+1][j], dp[k+1][j-1] + max(H[i+1] - H[k+1], 0LL));
            }
        }
    }

    int ret = INF;
    for (int i = 0; i <= N; ++i) ret = min(ret, dp[i][N-K]);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1024
N,K = map(int,input().split())
mod = 10**9+7
ans = [0]*(K+1)
result = 0

for i in range(K,0,-1):
    c = K//i
    ans[i] += pow(c,N,mod)
    for j in range(i,K+1,i):
        if i != j:
            ans[i] -= ans[j]
    result += i*ans[i] % mod

print(result%mod)

Measured memory_bytes: 74376
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(ll i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))

using namespace std;

/*
N 100
W 10^5
wi W
vi 10^9

N W
w1 v1
...
wN vN
 */

ll dp[102][100001];
ll N, W;
ll w;
ll v;

// int main(){
//   N=1;
//   W=100000;

//   REP(i,N+1){
//     w=100000;
//     v=1000000000;
//     REP(j,W+1){
//       if(j<w)
//         dp[i+1][j] = dp[i][j];
//       else
//         dp[i+1][j] = max(dp[i][j], dp[i][j-w] + v);
//     }
//   }

//   cout << dp[N+1][W] << endl;

//   return 0;
// }


int main(){
  cin >> N >> W;

  REP(i,N){
    cin >> w >> v;
    REP(j,W+1){
      if(j<w)
        dp[i+1][j] = dp[i][j];
      else
        dp[i+1][j] = max(dp[i][j], dp[i][j-w] + v);
    }
  }

  cout << dp[N][W] << endl;

  return 0;
}


Measured memory_bytes: 78336
def cc127
    n,m = gets.chomp.split(/\s/).map{|x| x.to_i}

    l = 0
    r = 0
    z = false
    for i in 1..m
        nl,nr = gets.chomp.split(/\s/).map{|x| x.to_i}
        next if z
        if i == 1
            l = nl
            r = nr
        else
            if nl > r or nr < l
                z = true
                next
            end

            l = [l, nl].max
            r = [r, nr].min
        end
    end

    if r-l < 0 or z
        puts 0
        exit
    end
    puts r-l+1
end

cc127

Measured memory_bytes: 1916
//
//  main.cpp

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


int main(){	
	int n;
	cin >> n;
	int a,b;
	cin >> a >> b;
	int c;
	cin >> c;
	vector<int> topcal;
	int input;
	for(int i=0;i<n;i++){
		cin >> input;
		topcal.push_back(input);
	}
	
	sort(topcal.begin(),topcal.end(),greater<int>());
	
	int answer = 0;
	int cal = c;
	int price = a;
	answer = cal/price;
	for(int i=0;i<n;i++){
		cal += topcal[i];
		price += b;
		answer = max(answer,cal/price);
	}
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 3132