akhauriyash/Code-Regression huggingface dataset:
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int R, D, X2K;
    cin >> R >> D >> X2K;

    int x = R * X2K - D;
    REP(i,10) {
        cout << x << endl;
        x = R * x - D;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		int m=s.nextInt();
		
		disjointSet dsu=new disjointSet();
		
		for(int i=1;i<=n;i++)
		{
			dsu.makeset(i);
		}
		
		for(int i=0;i<m;i++)
		{
			int a=s.nextInt();
			int b=s.nextInt();
			
			dsu.union(a,b);
		}
		
		HashMap<Integer,Integer> map=new HashMap<>();
		
		for(int i=1;i<=n;i++)
		{
			int p=dsu.findParentNode(dsu.map.get(i)).data;
			
			if(map.containsKey(p))
			{
				map.put(p,map.get(p)+1);
			}
			else
			{
				map.put(p, 1);
			}
		}
		
		int max=0;
		
		for(Map.Entry<Integer,Integer> entry:map.entrySet())
		{
			max=Math.max(max,entry.getValue());
		}
		
		System.out.println(max);
		
	}
	
}

class disjointSet {
	
	// We could use an ArrayList but that is space consuming to FIND a node
	// HashMap is more convenient
	
	HashMap<Integer,Node> map=new HashMap<>();
	
	public class Node
	{
		int data;
		int rank;
		Node parent;
	}
	
	public void makeset(int data)
	{
		Node node=new Node();
		
		node.data=data;
		node.rank=0;
		node.parent=node;
		
		map.put(data, node);
		
	}
	
	public void union(int data1,int data2)
	{
		Node node1=map.get(data1);
		Node node2=map.get(data2);
		
		Node parent1=findParentNode(node1);
		Node parent2=findParentNode(node2);
		
		if(parent1.data==parent2.data)
			return;
		
		if(parent1.rank>=parent2.rank)
		{
			parent1.rank=(parent1.rank==parent2.rank) ? parent1.rank=parent1.rank+1 : parent1.rank;
			parent2.parent=parent1;
		}
		else
		{
			parent1.parent=parent2;
		}
	}

	public Node findParentNode(Node node)
	{
		if(node.parent==node)
			return node;
		
		node.parent=findParentNode(node.parent);
		
		return node.parent;
			
	}
	
	public int findParentValue(int data)
	{
		Node node=map.get(data);
		return node.parent.data;
	}

	
}


Measured memory_bytes: 80424
#include<bits/stdc++.h>
typedef long long  ll ;
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define bug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}


int main() {
    fast()
    ll a,b,c;
    cin>>a>>b>>c;


    ll r =a-c;

    ll s=r<0?r+b:b;
    r=r<0?0:r;

    s=s<0?0:s;

   cout<<r<< " "<<s<<endl;






}


Measured memory_bytes: 256
from itertools import accumulate as acc
from bisect import bisect_left as bl

def ans(n):
    tmp=0
    for i in range(N):
        tmp+=abs(a[i]-a[n-1])
    return tmp


N=int(input())
a=list(map(int,input().split()))
a=list(acc(a))

ans=10**18
for j in range(1,N-2):
    x=a[j]/2
    p=bl(a,x)
    if p==j: p-=1
    elif p>0 and x-a[p-1]<a[p]-x: p-=1

    y=(a[j]+a[N-1])/2

    q=bl(a,y)
    if q==N-1: q-=1
    elif q>j+1 and y-a[q-1]<a[q]-y: q-=1

    P,Q,R,S=a[p], a[j]-a[p], a[q]-a[j], a[N-1]-a[q]
    ans=min(ans, max(P,Q,R,S)-min(P,Q,R,S))

print(ans)

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

int main() {
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
	    cin>>a[i];
	}
	int count=0;
	 for(int i=1;i<=n;i++) 
	 {
	     if(i%2==1 && a[i]%2==1) count++;
	 } 
	 cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3636
/*****************************
Filename: dfdkljfd.cpp
Author: hbb
Create: 2020-04-04 20:11:33
 *****************************/
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = INT_MAX >> 1;
typedef long long int LL;

LL n, k;

int main(){
	scanf("%lld %lld", &n, &k);
	LL ans = n % k;
	ans = min(ans, abs(ans - k));
	printf("%lld\n", ans);
}

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

int main()
{
    int K,S;
    cin >> K >> S;
    int sum = 0;
    for(int i=0; i<=K; i++){
        for(int j=0; j<=K; j++){
            int z = S-i-j;
            if(z>=0 && z<=K){
                sum++;
            }
        }
    }
    cout << sum << endl;
    return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}


///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll N,K;
    cin >> N >> K;
    vector<int> A(N+5);
    vector<ll> vis(N+5);
    REP(i,N){
        cin >> A[i+1];
    }

    int nowp = 1;
    ll nowd = 0;

    while(1){
        vis[nowp] = nowd;
        int next = A[nowp];

        if (K == nowd){
            cout << nowp << endl;
            return 0;
        }
        nowd++;
        if (vis[next] > 0){
            break;
        }else{
            nowp = next;
        }
    }

    ll a = vis[A[nowp]];
    ll d = nowd - a;

    ll rest = K - a;
    rest %= d;

    REP(i,rest){
        nowp = A[nowp];
    }

    cout << A[nowp] << endl;

    //DB2(a,d);
}

Measured memory_bytes: 5636
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))
def chk(mid,a,n,k):
    cuts=0
    for i in a:
        if i <= mid:
            continue
        cuts += i//mid+(-1 if i%mid==0 else 0)
    return (True if cuts<=k else False)

n,k = rm()
a = rl()
lo = 1
hi = 10**9
ans = 10**9
while lo < hi :
    mid = (lo+hi)//2
    if chk(mid,a,n,k):
        hi=mid
        ans=mid
    else:
        lo = mid+1
print(ans)

Measured memory_bytes: 107272
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();

        if ((n + 1) / 2 < k) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }
}






Measured memory_bytes: 23764
#include<cstdio>
using namespace std;
typedef long long ll;
int i,j,k,ch,ff;
char s[10];
void R(int &x) {
	x=ff=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(int x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
void R(ll &x) {
	x=ff=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(ll x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
bool check(ll x) {
	putchar('?');
	putchar(' ');
	W(x);
	puts("");fflush(stdout);
	scanf("%s",s);
	return s[0]=='Y';
}
int main() {
	ll n=1;
	while (n<=100000000000ll && check(n)) n*=10;
	if (n>100000000000ll) {
		n=10;
		while (!check(n-1)) n*=10;
		putchar('!');
		putchar(' ');
		W(n/10);
		puts("");fflush(stdout);
		return 0;
	}
	ll l=n/10,r=n-1,mid;
	while (l<r) {
		mid=(l+r-1)>>1;
		if (check(mid*10)) r=mid;
		else l=mid+1;
	}
	putchar('!');
	putchar(' ');
	W(l);
	puts("");fflush(stdout);
}

Measured memory_bytes: 504
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL;
const int mod = 1e9 + 7; 

//#define CI cpp_int
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << " " ;
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define setBits(n) __builtin_popcountll(n)
#define MX *max_element
#define MN *min_element
#define TC int t; cin >> t; while (t--) 

void Panda() {
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    for(int i = a; i <= b; i++) {
    	string s = to_string(i);
    	reverse(ALL(s));
    	if(s == to_string(i)) cnt++;
    }
    cout << cnt << endl;
}
  
int32_t main() {
 
    FAST;

 
    Panda();

    return 0; 
} 

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

using namespace std;

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

int main(){
    int i;
    //入力
    int a,b;
    cin>>a>>b;
    //処理
    //出力
    if(a>b){
        rep(i,a){
            cout<<b;
        }
    }else{
        rep(i,b){
            cout<<a;
        }
    }
}

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

int main(void)
{
    int n;
    cin >> n;
    int a[n][3], b[n];
    for(int i=0; i<n; i++)
        for(int j=0; j<3; j++)
            cin >> a[i][j];
    for(int i=0; i<n; i++)
        b[i] = 0;

    for(int i=0; i<3; i++) {
        for(int j=0; j<n; j++) {
            bool ok = true;
            for(int k=0; k<n; k++) {
                if(j != k && a[j][i] == a[k][i]) {
                    ok = false;
                    break;
                }
            }
            if(ok)
                b[j] += a[j][i];
        }
    }

    for(int i=0; i<n; i++)
        cout << b[i] << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int>a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  vector<int>s(N);
  for (int i = 0; i < N; i++) s[i] = a[i];
  sort(s.begin(), s.end(), greater<int>());
  if (s[0] == s[1]) {
    for (int i = 0; i < N; i++) cout << s[0] << endl;
  }
  else {
    for (int i = 0; i < N; i++) {
      if (a[i] == s[0]) cout << s[1] << endl;
      else cout << s[0] << endl;
    }
  }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,K;
  
  cin>>N>>K;
  
  vector<int> A(N);
for (int i = 0; i < N; i++) {
   A.at(i)=0;
}
    
  
  int d;
  int sw;
  
  for(int i=0;i<K;i++){
    cin>>d;
    for(int i=0;i<d;i++){
      cin>>sw;
      A.at(sw-1)=1;
    }
  }
  
  int sw1=0;
  
  for(int i=0;i<N;i++){
    if(A.at(i)==0){
      sw1++;
    }
  }
  
  cout<<sw1<<endl;
    
    
    
  
  
}


Measured memory_bytes: 3628
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;


fn main() {
    let n: usize = read!();
    let mut blue = HashMap::new();
    for _ in 0..n {
        let s: String = read!();
        let b = blue.entry(s).or_insert(0);
        *b += 1;
    }
    let m: usize = read!();
    for _ in 0..m {
        let s: String = read!();
        let b = blue.entry(s).or_insert(0);
        *b -= 1;
    }
    let mut ans = 0;
    for (s, v) in &blue {
        ans = ans.max(*v);
    }
    println!("{}", ans);
}

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

#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

const long long MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> Aj(N);
    rep(i, N) {
        cin >> A[i];
    }
    ll tot = 0;
    rep(i, N) {
        tot += A[N - i - 1];
        tot %= MOD;
        Aj[N - i - 1] = tot;
    }

    tot = 0;
    rep(i, N - 1) {
        tot += A[i] * Aj[i + 1];
        tot %= MOD;
    }
    cout << tot << endl;

    return 0;
}


Measured memory_bytes: 6408
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>



using namespace std;


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

	vector<int> a;
	vector<int> b;

	for (int i = 0; i < n - 1; i++) {
		int tmp;
		cin >> tmp;
		b.emplace_back(tmp);
	}

	a.emplace_back(b[0]);
	for (int i = 1; i < n-1; i++) {
		a.emplace_back(b[i-1]);
		if (a[i] > b[i]) {
			a[i] = b[i];
		}
	}
	a.emplace_back(b[n-2]);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
	}

	cout << sum << endl;
	
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Node
{
    Node(int t, ll y, ll s) : to(t), y(y), s(s) {}
    int to;
    ll y;
    ll s;
};
struct Vertex
{
    vector<Node> n;
};

Vertex V[100005];

//! Sから都市iまで、yenを使って移動する最小コスト
ll X[100005];
//! Tから都市iまで、snukを使って移動する最小コスト
ll Y[100005];
ll ans[100005];

int main()
{
    int N, M, S, T;
    cin >> N >> M >> S >> T;
    S--;
    T--;
    REP(i, M)
    {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        V[u].n.push_back(Node(v, a, b));
        V[v].n.push_back(Node(u, a, b));
    }
    REP(i, N)
    {
        X[i] = Y[i] = INF;
    }
    {
        priority_queue<pll, vector<pll>, function<bool(pll, pll)>> q([](pll a, pll b) { return a.second > b.second; });
        q.push(pll(S, 0));
        while (!q.empty())
        {
            pll t = q.top();
            q.pop();
            if (t.second >= X[t.first])
                continue;
            X[t.first] = t.second;
            REP(i, V[t.first].n.size())
            {
                int to = V[t.first].n[i].to;
                if (t.second + V[t.first].n[i].y >= X[to])
                    continue;
                q.push(pll(to, t.second + V[t.first].n[i].y));
            }
        }
    }
    {
        priority_queue<pll, vector<pll>, function<bool(pll, pll)>> q([](pll a, pll b) { return a.second > b.second; });
        q.push(pll(T, 0));
        while (!q.empty())
        {
            pll t = q.top();
            q.pop();
            if (t.second >= Y[t.first])
                continue;
            Y[t.first] = t.second;
            REP(i, V[t.first].n.size())
            {
                int to = V[t.first].n[i].to;
                if (t.second + V[t.first].n[i].s >= Y[to])
                    continue;
                q.push(pll(to, t.second + V[t.first].n[i].s));
            }
        }
    }

    REP(i, N)
    {
        ans[N - 1 - i] = INF - (X[N - 1 - i] + Y[N - 1 - i]);
        if (i > 0)
        {
            ans[N - 1 - i] = std::max(ans[N - 1 - i], ans[N - i]);
        }
    }
    REP(i, N)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 14468
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)n; i++)
#define repf(i, a, b) for (long long i = (long long)a; i < (long long)b; i++)
#define repr(i, a, b) for (long long i = (long long)a; i > (long long)b; i--)

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

int main(void) {
    llong n,m;

    cin >> n >> m;
    vecllong s(n);
    vecllong t(m);

    rep(i,n){
        cin >> s[i];
    }
    rep(i,m){
        cin >> t[i];
    }

    vvecllong ans(n+1, vecllong(m+1,0));

    rep(i,m+1){
        ans[0][i] = 1;
    }
    rep(i,n+1){
        ans[i][0] = 1;
    }

    for(llong i=1; i<=n; i++){
        for(llong j=1; j<=m; j++){
            if(s[i-1] == t[j-1]){
                ans[i][j] = ans[i-1][j] + ans[i][j-1];
            }else{
                ans[i][j] = ans[i-1][j] + ans[i][j-1] - ans[i-1][j-1] + MOD;
            }
            ans[i][j] %= MOD;
        }
    }

    cout << (ans[n][m] % MOD) << endl;

    return 0;
}

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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    int n;
    cin >> n;

    int mex = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x == mex + 1) mex++;
    }

    cout << (mex ? n - mex : -1);
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3652
n = int(input(''))

mod = 1000000007

cnt_all= 10**n%mod
cnt_90=8**n%mod
cnt_9=9**n%mod
cnt_0=cnt_9%mod
cnt=(cnt_all + cnt_90 - cnt_9 - cnt_0)%mod
#print("{} - {} - {} + {} = {}".format(cnt_all,cnt_9,cnt_0,cnt_90,cnt))
print(cnt)


Measured memory_bytes: 10572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

ll prime(ll n){
  bool flag=true;
  if (n==1)
    flag=false;
  else if (n%2==0){
    flag=false;
    if(n==2)
      flag=true;
  }
  else {
    for (ll i=3;i<=sqrt(n);i+=2){
      if (n%i==0)
        flag=false;
    }
  }
  return flag;
}

int MAX_r=1e5;

int main(){
  int Q,l,r;
  cin >> Q;
  vector<int> a(MAX_r+1,0);
  rep(i,MAX_r+1){
    if(prime(i)&prime((i+1)/2))
      a[i]=1;
  }
  vector<int> S(MAX_r+2,0);
  rep(i,MAX_r+2){
    S[i+1]=S[i]+a[i];
  }
  rep(i,Q){
    cin >> l >> r;
    cout <<S[r+1]-S[l]<<endl;
  }
}

Measured memory_bytes: 1408
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int w = sc.nextInt();
      int[][] cost = new int[10][10];
      for(int i = 0; i <= 9; i++)
        for(int j = 0; j<= 9; j++)
          cost[i][j] = sc.nextInt();

      int[][] grid = new int[h][w];
      for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
          grid[i][j] = sc.nextInt();

      for(int k = 0; k <= 9; k++)
        for(int i = 0; i <= 9; i++)
          for(int j = 0; j <= 9; j++)
            cost[i][j] = Math.min(cost[i][j], cost[i][k] + cost[k][j]);

      long res = 0L;
      for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
          if(grid[i][j] == -1)
            continue;
          else
            res += cost[grid[i][j]][1];
      System.out.println(res);
  }
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    string s;
    cin >> s;

    int p = 0, q = 0;
    rep(i, 0, s.size()) {
        bool x = i % 2 == 0 && s[i] == '1';
        bool y = i % 2 == 1 && s[i] == '0';
        if (x || y) {
            ++p;
        } else {
            ++q;
        }
    }
    cout << min(p, q) << endl;

    return 0;
}

Measured memory_bytes: 512
//
//  Odds of Oddness.cpp
//  National Olympiad in Informatics in Provinces
//
//  Created by 黄子齐 on 2019/9/28.
//  Copyright © 2019 黄子齐. All rights reserved.
//

#include <stdio.h>
int n;
int main() {
//    freopen("mytestdata.in", "r", stdin);
    scanf("%d", &n);
    int k = n/2;
    int l = n-k;
    double p = (double)l/(double)n;
    printf("%.8f\n", p);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main(){
  int n,i,j,ax,ay,bx,by,a,b,c,d,x[400],y[400],mi;
  double s,max,m;
  while(scanf("%d",&n),n){
    for(i=ax=by=bx=0;i<n;i++)scanf("%d %d",&x[i],&y[i]);
    ay=-1;
    int f[400]={0};
    for(i=s=0;i<n;i++){
      for(j=max=0;j<n;j++){
	if(f[j])continue;
	a=bx-ax;
	b=by-ay;
	c=x[j]-bx;
	d=y[j]-by;
	m=(a*c+b*d)/hypot(a,b)/hypot(c,d);
	if(a*d>b*c)m=1-m;
	else       m+=3;
	if(fabs(max-m)<0.00000001){
	  if(hypot(x[mi]-bx,y[mi]-by)>hypot(x[j]-bx,y[j]-by))mi=j;
	}
	if(max<m){
	  max=m;
	  mi=j;
	}
      }
      f[mi]=1;
      ax=bx;
      ay=by;
      bx=x[mi];
      by=y[mi];//printf("%d %d\n",bx,by);
      s+=hypot(bx-ax,by-ay);  
    }
    printf("%.1f\n",s);
  }
  return 0;
}

Measured memory_bytes: 652
package main

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

type MyScanner struct {
	sc *bufio.Scanner
}

type MyWriter struct {
	stdout io.Writer
}

type MyPut interface{}

func getScanner(fp io.Reader) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 500001), 500000)
	return sc
}

func getHugeScanner(fp io.Reader, size int) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, size), size)
	return sc
}

func (mysc *MyScanner)String() string {
	mysc.sc.Scan()
	return mysc.sc.Text()
}

func (mysc *MyScanner)Int() int {
	i, _ := strconv.Atoi(mysc.String())
	return i
}

func (mysc *MyScanner)Int64() int64 {
	i, _ := strconv.ParseInt(mysc.String(), 10, 64)
	return i
}

func (mysc *MyScanner)Float64() float64 {
	i, _ := strconv.ParseFloat(mysc.String(), 64)
	return i
}

func (mw MyWriter)Puts(v MyPut) {
	_, _ = fmt.Fprintf(mw.stdout, "%v\n", v)
}

func Done(a [][]int) bool {
	for i := 0; i < len(a); i++ {
		if len(a[i]) > 0 {
			return false
		}
	}
	return true
}

type Pair struct {
	a int
	b int
}

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := MyScanner{getScanner(stdin)}
	mw := MyWriter{stdout}

	n := sc.Int()

	a := make([][]int, n)

	for i := 0; i < n; i++ {
		a[i] = make([]int, n - 1)
		for j := 0; j < n - 1; j++ {
			in := sc.Int()
			in--
			a[i][j] = in
		}
	}

	p := make(map[Pair]int)

	Check := func(i int) {
		if len(a[i]) == 0 {
			return
		}
		j := a[i][0]
		if len(a[j]) == 0 {
			return
		}
		if a[j][0] == i {
			if j < i {
				i, j = j, i
			}
			p[Pair{i, j}] = 0
		}
		return
	}

	for i := 0; i < n; i++ {
		Check(i)
	}

	ans := 0
	for len(p) > 0 {
		ans++
		for k := range p {
			a[k.a] = a[k.a][1:]
			a[k.b] = a[k.b][1:]
		}
		q := p
		p = make(map[Pair]int)
		for k := range q {
			Check(k.a)
			Check(k.b)
		}
	}

	for i := 0; i < len(a); i++ {
		if len(a[i]) > 0 {
			mw.Puts(-1)
			return
		}
	}

	mw.Puts(ans)

}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}

Measured memory_bytes: 18304
#include <bits/stdc++.h>  
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vl vector<ll>
#define mod 1000000007


int main()
{
    ll a,b,c,k;cin>>a>>b>>c>>k;
    if(k<=a)
    cout<<k<<"\n";
    else
    {
        ll ans=0;
        if(k>a)
        {
            ans+=a;
            k-=a;
        }
        if(k>b)
        {
            k-=b;
            if(k<=c)
            ans-=k;
        }
        cout<<ans<<"\n";
    }

}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <random>

#include <fstream>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

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

int main(void)
{
    
    ll d, tmp;
    deque<ll> c, s, res, t, typ(26, 0);
    
    cin >> d;
    
    for(int i = 0; i < 26; i++)
    {
        cin >> tmp;
        c.push_back(tmp);
    }
    
    for(ll i = 0; i < d; i++)
    {
        for(ll j = 0; j < 26; j++)
        {
            cin >> tmp;
            s.push_back(tmp);
        }
    }
    
    for(ll i = 0; i < d; i++)
    {
        ll key = 0;
        for(ll j = 1; j < 26; j++)
        {
            if(s[i*26+j] > s[i*26+key])
            {
                key = j;
            }
        }
        t.push_back(key);
    }
    
    for(ll i = 0; i < d; i++)
    {
        tmp = t[i] + 1;
        if(i == 0)
        {
            res.push_back(s[26*i+tmp-1]);
        }
        else
        {
            res.push_back(s[26*i+tmp-1] + res[i - 1]);
        }
        for(ll j = 0; j < 26; j++)
        {
            if(j+1==tmp)
            {
                typ[j] = 0;
            }
            else
            {
                typ[j]++;
                res[i] -= c[j]*typ[j];
            }
        }
        
        for(ll a = 0; a < 5000; a++)
        {
            ll ttmp = rand()%26 + 1;
            ll ttres;
            
            if(i == 0 && a == 0)
            {
                ttres = s[26*i+tmp-1];
            }
            else if(a == 0)
            {
                ttres = s[26*i+ttmp-1] + res[i - 1];
            }
            
            for(ll j = 0; j < 26; j++)
            {
                if(j+1==ttmp)
                {
                }
                else
                {
                    ttres -= c[j]*typ[j];
                }
            }
            
            if(res[i] < ttres)
            {
                t[i] = ttmp - 1;
                res[i] = ttres;
            }
        }
    }
    
    for(ll i = 0; i < d; i++)
    {
        cout << t[i] + 1 << endl;
    }
    
    return 0;
}

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

int main(){
    long long N;
    cin >> N;
    long long i;
    long long P[N], Q[N];
    for(i = 0; i < N; i++){
        cin >> P[i];
    }
    for(i = 0; i < N; i++){
        cin >> Q[i];
    }

    long long a = 0, b = 0;
    long long s[N], t[N];
    for(i = 0; i < N; i++){
        s[i] = i+1;
        t[i] = i+1;
    }
    do{
        a++;
        for(i = 0; i < N; i++){
            if(P[i] != s[i]){
                break;
            }
        }
        if(i == N){
            break;
        }
    }while(next_permutation(s, s+N));
    do{
        b++;
        for(i = 0; i < N; i++){
            if(Q[i] != t[i]){
                break;
            }
        }
        if(i == N){
            break;
        }
    }while(next_permutation(t, t+N));
    
    cout << max(a-b,b-a) << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) ((x).begin()),((x).end())
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimization ("unroll-loops")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using pii = pair<int, int>;
using ppp = pair<int , pii>;

int32_t main()
{
	int t; cin >> t;
	for (int i = 1; i<=100000; i++)
	{
		if (100*i <= t && t <= 105*i)
		{
			printf("1\n");
			return 0;
		}
	}
	printf("0");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int> p(n),q(n);
    for (int i = 0;i < n;i++) cin >> p[i];
    for (int i = 0;i < n;i++) cin >> q[i];

    vector<int> raw(n);
    for (int i = 1;i <= n;i++){
        raw[i-1] = i;
    }
    sort(raw.begin(),raw.end());

    int j = 0,a = 0,b = 0;
    do{
        if(raw == p) a = j;
        if (raw == q) b = j;
        j++;
    }while(next_permutation(raw.begin(),raw.end()));
    
    cout << abs(a-b) << endl;

    return 0;
}   

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>

using namespace std;

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		(1000000)
#define Rep(i,n) for(int i = 0; i < (n); i++ )

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define	show(x)	 copy( (x).begin(), (x).end(), ostream_iterator<int>(cout, ",") );	// container<int>を全て表示

using namespace std;

typedef long long ll;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);


map<ll, ll> prime_factor2(ll N)
{
	map<ll, ll> ret;

	for (ll i = 2; i * i <= N; ++i ) {
		while ( N % i == 0 ) {
			ret[i]++;
			N /= i;
		}
	}

	if (N != 1) ret[N]++;
	return ret;
}

int main()
{
	ll N = 0;
	ll ret = 1;
	ll div_num = 0x3B9ACA07;
	map<ll, ll> prime;
	map<ll, ll>::iterator itr;

	cin >> N;

	for (ll i = N; i != 0; i--) {
		map<ll, ll> tmp = prime_factor2(i);

		for (itr = tmp.begin(); itr != tmp.end(); itr++) {
			ll index = itr->first;
			prime[index] += itr->second;
		}
	}

	for (itr = prime.begin(); itr != prime.end(); itr++) {
		ret *= (itr->second + 1);
		ret %= div_num;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 3/19
// Problem:Make a Rectangle c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << "\n";
#define OK(ok) cout << (ok ? "Yes" : "No") <<　"\n";
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1e9 + 1;


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

  CIN(N);
  set< ll > s;
  vector< ll > t;
  REP(i, N) {
    LCIN(a);
    if (s.erase(a)) t.emplace_back(a);
    else s.insert(a);
  }
  
  sort(ALL(t));
  reverse(ALL(t));
  ll ans;
  if (t.size() < 2) ans = 0;
  else ans = t[0] * t[1];
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4992
#include <iostream>
//#include <fstream>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, const char * argv[]) {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    
    int N, L;
    cin >> N >> L;
    
    vector<int> vec(N);
    vector<int> absvec(N);
    
    for (int i=0; i<N; i++)
    {
        vec[i] = L + (i+1) - 1;
        absvec[i] = abs(L + (i+1) - 1);
//        cout << "vec[i] : " << vec[i] << endl;
    }
    
    vector<int>::iterator minIt = min_element(absvec.begin(), absvec.end());
    size_t minIndex = std::distance(absvec.begin(), minIt);
    
    int sum = accumulate(vec.begin(), vec.end(), -vec[minIndex]);
//    cout << min << endl;
    cout << sum << endl;
    
    return 0;
}


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

int main() {
  int n,m,c;
  cin >> n >> m >> c;
  int b[m];
  for(int i=0;i<m;i++) cin >> b[i];
  vector<vector<int>>a(n,vector<int>(m));
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  
  int cnt=0;
  for(int i=0;i<n;i++){
    int sum=c;
    for(int j=0;j<m;j++){
      sum+=a[i][j]*b[j];
    }
    if(sum>0){
      cnt++;
    }
  }
  
  cout << cnt ;
}
      


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdlib.h>
using namespace std;
int main(){
    int a,b,k;
    int j=0;
    int m[1000]={0};
    scanf("%d %d %d",&a,&b,&k);
    for(int i=min(a,b);i>0;i--){
        if(a%i==0&&b%i==0) m[j]=i;
        j++;
    }
    sort(m,m+1000);
    reverse(m,m+1000);
    cout<<m[k-1];
}


Measured memory_bytes: 256
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

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


long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}


int cnt[MAXN];
int a[MAXN];
int b[MAXN];

int res;

void del(int x) {
	int pos = a[x] - cnt[a[x]] + 1;
	if (pos <= 0) return;
	b[pos]--;
	if (b[pos] == 0) {
		res++;
	}
}

void add(int x) {
	int pos = a[x] - cnt[a[x]] +1;
	if (pos <= 0) return;
	if (b[pos] == 0) {
		res--;
	}
	b[pos] ++;
}

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt(), m = readInt();
    res = n;
    for (int i = 1; i <= n; i++) {
    	a[i] = readInt();
		cnt[a[i]]++;
		int pos = a[i] - cnt[a[i]] + 1;
		if (pos >= 1) {
			if (!b[pos]) {
				res--;
			}
			b[pos]++;
		}
    }
    while(m--) {
    	int x = readInt(), y = readInt();
    	del(x);
		cnt[a[x]]--;
		a[x] = y;
		cnt[a[x]]++;
    	add(x);
    	cout <<res << endl;
    }
    return 0;
}

Measured memory_bytes: 10496
/*
 * ID: adityaa
 * LANG: C++
 */
#include <bits/stdc++.h>
using namespace std;

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mem(x, y) memset(x, y, sizeof x);
#define fi first
#define se second
#define pb push_back
#define pii pair<int , int>
#define asdfg y1
#define int long long
#define double long double
#define endl '\n'
#define PI 3.14159265359

/*-----------------------------------------------------------------------*/

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

/*-----------------------------------------------------------------------*/

// check base cases n = 0 , n = 1
// max / min questions - check for binary search
const int maxn = (int) 3010;
const double EPS = 1e-9;
const int INF = (int)1e18 + 18;
const int mod = (int) 998244353;
int n , m , dp[maxn][maxn];
int pre[maxn][maxn];
string s , t;

signed main() {
    
    fio;
    cin >> s >> t;
    n = s.length(); m = t.length();
    s = '*' + s; t = '#' + t;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(s[i] == t[j]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
                pre[i][j] = 1;
            } else {
                if(dp[i - 1][j] > dp[i][j - 1]){
                    dp[i][j] = dp[i - 1][j];
                    pre[i][j] = 2;
                } else {
                    dp[i][j] = dp[i][j - 1];
                    pre[i][j] = 3;
                }
            }
        }
    }
    
    int i = n , j = m;
    string ans = "";
    while(i && j){
        if(pre[i][j] == 1){
            ans += s[i];
            i--; j--;
        }
        else if(pre[i][j] == 2){
            i--;
        }
        else j--;
    }
    
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    
    return 0;
    
}


Measured memory_bytes: 141568
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	
	long long int N, max, res = 0;
	vector<long long int> A;


	cin >> N;

	rep(i, N){
		long long int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}

	max = A[0];

	for(int i = 1; i < N; i++){
		if(A[i] < max){
			res += (max - A[i]);
		}else{
			max = A[i];
		}
	}


	cout << res;
 
 
	return 0;
}

Measured memory_bytes: 5360
#include<stdio.h>
#include<string.h>
char c[9][6]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
char s[1025];
int main(){
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf(" %s",s);
		int len=strlen(s);
		int p=-1;
		int cnt=0;
		for(j=0;j<len;j++){
			if(s[j]=='0'){
				if(p==-1)continue;
				if(p==0)cnt%=5;
				else if(p==6||p==8)cnt%=4;
				else cnt%=3;
				printf("%c",c[p][cnt]);
				p=-1;
				cnt=0;
			}else{
				if(p==-1)p=s[j]-'1';
				else cnt++;
			}
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1016
#include <iostream>
//#include<cmath>
using namespace std;

int main() {
    int k,x,a,b;
    cin>>k>>x;
    a=x-k+1;
    b=x+k-1;
    for(int i=a;i<=b;i++){
        cout<<i<<" ";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N=0,X=0,Y=0,result=0;
    cin>>N;
    X=(N/15)*200;
    Y=N*800;
    result=Y-X;
    cout<<result<<"\n";
    return 0;
 
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main(void)
{
     int i,j,k,n,m;
     scanf("%d%d%d",&n,&m,&k);
     for(i=1;i<=100000;i++)
     {
          if(i*m+(i+1)*k>n)
          {
               printf("%d\n",i-1);
               break;
          }
     }
     return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int n, m;
string s[1005];
int dp[1005][1005];
const int mod = 1000000007;
int sol(int i,int j) {
	if (i < 0 || i >= n || j < 0 || j >= m)return 0;
	if (i == n - 1 && j == m - 1)return 1;
	if (s[i][j] == '#')return 0;
	if (dp[i][j] == -1) {
		int x = sol(i + 1, j);
		int y = sol(i, j + 1);
		dp[i][j] = (x%mod + y%mod)%mod;
		return dp[i][j]%mod;
	}
	else return dp[i][j]%mod;
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			dp[i][j] = -1;
	
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cout<<sol(0, 0)%mod<<endl;
}

Measured memory_bytes: 5376
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int MAX_N = 100000;
int MAX_Q = 100000;

int main(void){
    string S;
    int N, Q;
    int L[MAX_Q];
    int R[MAX_Q];
    int cnt_L[MAX_N];


    cin >> N >> Q;
    cin >> S;

    rep(i, Q){
        cin >> L[i] >> R[i];
    }

    int idx = 0;
    cnt_L[0] = 0;

    rep(i, N - 1){
        string b = S.substr(i, 2);
        
        if (b == "AC"){
            cnt_L[i + 1] = cnt_L[i] + 1;
        }else{
            cnt_L[i + 1] = cnt_L[i];
        }
    }

    rep(q, Q){
        int l = L[q] - 1;
        int r = R[q] - 1;
        cout << cnt_L[r] - cnt_L[l] << endl;
    }

    return 0;
}

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

const int MAX_N = 100;

int main() {
  int n, x;
  int l[MAX_N + 1];
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> l[i];

  int sum = 0;
  int ans = 1;
  for (int i = 0; i < n; i++) {
    sum += l[i];
    if (sum <= x) ans++;
    else break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <vector>
#include <functional>
#include <algorithm>
#include <map>
#include <queue>
#define inf INT_MAX/2
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
struct office {
    int minl[100001], w, h, is, js, maps[500][500];
    bool used[500][500];
    office () {}
    office (int w, int h, int is, int js) : w(w), h(h), is(is), js(js) {
        for (int i=0; i<h; i++) for (int j=0; j<w; j++) {
            used[i][j]=false;
        }
    }
    void calc(int r) {
        fill(minl, minl+(r+1), inf);
        if (maps[is][js]==0) return;
        minl[0]=0;
        draw(r);
        for (int i=r-1; i>=0; i--) {
            minl[i]=min(minl[i], minl[i+1]);
//            printf("%d %d\n",i,minl[i]);
        }
    }
    bool isin(int x, int y) {
        return x>=0&&x<h&&y>=0&&y<w;
    }
    void draw(int r) {
        priority_queue<PP, vector<PP>, greater<PP> > que;
        que.push(make_pair(1,P(is,js)));
        int l=1, cnt=0;
        used[is][js]=true;
        while (!que.empty()) {
            PP p=que.top(); que.pop();
            l=max(l, p.first);
            int x=p.second.first, y=p.second.second;
            cnt++;
            if (cnt>=r) minl[r]=min(minl[r], l);
            else minl[cnt]=min(minl[cnt], l);
            for (int i=0; i<4; i++) {
                int nx=x+dx[i], ny=y+dy[i];
                if (isin(nx,ny)&&!used[nx][ny]) {
                    que.push(make_pair(maps[nx][ny],P(nx,ny)));
                    used[nx][ny]=true;
                }
            }
       }
    }
};
int main() {
    int r;
    while (scanf("%d",&r)) {
        if (!r) break;
        office o1, o2;
        int w, h, x, y;
        scanf("%d%d%d%d",&w,&h,&x,&y);
        o1=office(w,h,y-1,x-1);
        for (int i=0; i<h; i++) for (int j=0; j<w; j++) {
            scanf("%d",&o1.maps[i][j]);
        }
        scanf("%d%d%d%d",&w,&h,&x,&y);
        o2=office(w,h,y-1,x-1);
        for (int i=0; i<h; i++) for (int j=0; j<w; j++) {
            scanf("%d",&o2.maps[i][j]);
        }
        o1.calc(r); o2.calc(r);
        int res=inf;
        for (int i=r; i>=0; i--) {
            res=min(res, o1.minl[i]+o2.minl[r-i]);
        }
        printf("%d\n",res);
    }
}

Measured memory_bytes: 7864