akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
using namespace std;

int main()
{
	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s[1001];

	cin >> a;
	if (a<=999)
	{
		cout << "ABC" << endl;

	}
	else
	{
		cout << "ABD" << endl;

	}
	return 0;
}

Measured memory_bytes: 256
N,M=list(map(int,input().split()))
l_n=list(map(int,input().split()))
k=[]
j=0
for i in range(1,1001):
   j+=i
   k.append(j/i)
l_n=[k[l_n[i]-1] for i in range(N)]
ans=sum(l_n[0:M])
sum_n=ans
for i in range(N-M):
   sum_n+=l_n[i+M]
   sum_n-=l_n[i]
   ans=max(ans,sum_n)
print(ans)

Measured memory_bytes: 25060
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum MO = 10L^^9 + 7;

int N;
int[] C;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      C = new int[N];
      foreach (i; 0 .. N) {
        C[i] = readInt();
      }
      
      auto prev = new int[N];
      int[int] last;
      foreach (i; 0 .. N) {
        if (C[i] in last) {
          prev[i] = last[C[i]];
        } else {
          prev[i] = -1;
        }
        last[C[i]] = i;
      }
      
      auto dp = new long[N + 1];
      dp[0] = 1;
      foreach (i; 0 .. N) {
        dp[i + 1] = dp[i];
        if (prev[i] != -1 && i - prev[i] >= 2) {
          (dp[i + 1] += dp[prev[i] + 1]) %= MO;
        }
      }
      debug {
        writeln("dp = ", dp);
      }
      writeln(dp[N]);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 21756
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;

//a, a + 1, a + 2, ... , b - 1, bの総和を求める関数(a <= b)。計算量はO(1)
Int Sum(Int a, Int b) {
	if (b < a)return 0;
	if ((b - a + 1) % 2 == 0)return (a + b) * (b - a + 1) / 2;
	else return (a + b) * ((b - a + 1) / 2) + (a + b) / 2;
}

void calc() {

	Int S, W; std::cin >> S >> W;
	if (S <= W)std::cout << "unsafe";
	else std::cout << "safe";

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 3604
import java.io.*;
import java.util.*;

class Main{
	public void run(){
		long H = nl();
		long W = nl();
		long N = nl();
		HashMap<Long, Integer> map = new HashMap<>();
		for(long i=0;i<N;i++){
			long a = nl();
			long b = nl();
			for(long y=a-1;y<=a+1;y++){
				for(long x=b-1;x<=b+1;x++){
					if(x-1<1 || x+1>W || y-1<1 || y+1>H){
						continue;
					}
//					String key = String.format("%9d%9d", y, x);
					long key = y * 10_0000_0000L + x;
					if(map.containsKey(key)){
						map.put(key, map.get(key) + 1);
					}else{
						map.put(key, 1);
					}
				}
			}
		}
		long[] result = new long[10];

		long sum = 0;
		for(Integer i : map.values()){
			result[i]++;
			sum++;
		}
		result[0] = ((H-2) * (W-2)) - sum;

		for(int i=0;i<10;i++){
			out.println(result[i]);
		}
	}

	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().run();
		out.flush();
	}

	public Main(){
	}

	int ni(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;	}

	long nl(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

	double nd(){
		return Double.parseDouble(next());
	}

	String next(){
		int c;
		while(!isAlNum(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	String nextLine(){
		int c;
		while(!isAlNumOrSpace(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNumOrSpace(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
	private static boolean isAlNumOrSpace(int c){
		return isAlNum(c) || c == ' ' || c == '\t';
	}
	void debug(Object... os){
		out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 97568
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    queue<ll> que;
    rep(i,9) que.push(i + 1);
    cin>>K;
    while(--K){
        ll a = que.front();
        que.pop();
        int b = a % 10;
        a *= 10;
        reps(i, max(0, b - 1), min(10, b + 2)){
            que.push(a + i);
        }
    }
    N = que.front();
    cout<<N<<endl;
}

Measured memory_bytes: 5148
import math
N = int(input())

sqN = math.floor(math.sqrt(N))
yaku1 = 1
yaku2 = 1
for i in range(sqN, 0, -1):
    if N % i == 0:
        yaku1 = i
        yaku2 = N // i
        break

print(yaku1+yaku2-2)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

class union_find {
    private:
        vector<int> par;
        vector<int> ran;
        vector<ll> size;
    public:
        union_find(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        ll show_size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    ran.resize(n);
    size.resize(n);
    rep(i,n) par[i] = i;
    rep(i,n) ran[i] = 0;
    rep(i,n) size[i] = 1;
};

int union_find::find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    ll t = show_size(x)+show_size(y);
    size[x] = size[y] = t;
    if(ran[x] < ran[y]){
        par[x] = y;
        //size[y] += size[x];
    }
    else{
        par[y] = x;
        //size[x] += size[y];
        if(ran[x] == ran[y]) ran[x]++;
    }
};

ll union_find::show_size(int x) {
    if(par[x] == x) return size[x];
    return show_size(par[x] = find(par[x]));
}

bool union_find::same(int x, int y) {
    return (find(x) == find(y));
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i,m){
		cin >> a[i] >> b[i];
		--a[i]; --b[i];
	}
	union_find uf(n);
	ll cnt = n * (n-1) / 2;
	vector<ll> ans(m);
	for(int i = m-1; i >= 0; --i){
		ans[i] = cnt;
		if(!uf.same(a[i], b[i])){
			cnt -= uf.show_size(a[i]) * uf.show_size(b[i]);
			uf.unite(a[i], b[i]);
		}
	}
	rep(i,m) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 6336
#include<iostream>
using namespace std;
int main() {

	int n = 1;
	long long int a[100005], b[100005], k = 0;
	long long int ans = 0;
	

	cin >> n;
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i];
	}
	for (int j = 0; j < n; j++) {
		cin >> b[j];
	}
	//a[n + 1] = a[n + 2] = b[n] = b[n + 1] = 0;
	long long int hoge = 0;
	for (int j = 0; j < n; j++) {
		if (a[j] >= b[j]) {
			ans += b[j];
			//a[j] -= b[j];
			//b[j] -= b[j];
			continue;
		}
		else {
			ans += a[j];
			//b[j] -= a[j];
			//a[j] -= a[j];
		}
		hoge = b[j] - a[j];
		if (hoge > a[j + 1]) {
			ans += a[j + 1];
			//b[j] -= a[j + 1];
			a[j + 1] -= a[j + 1];
		}
		else {
			ans += hoge;
			a[j + 1] -= hoge;
			//b[j] -= hoge;
		}
		//cout << ans << endl;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <algorithm>
#define maxn 305
using namespace std;

int a[maxn][maxn], n;
vector<pair<int, pair<int, int> > > distances;

int main(int argc, char** argv)
{
	scanf("%d", &n);
	for(int i=1; i<=n; i++)
		for(int j=1; j<=n; j++)
		{
			scanf("%d", a[i] + j);
			if(i < j) distances.emplace_back(a[i][j], make_pair(i, j));
		}
	sort(distances.begin(), distances.end());
	long long ans = 0;
	for(auto i: distances)
	{
		int x = i.second.first, y = i.second.second;
		bool add = true;
		for(int j=1; j<=n; j++)
			if(j != x && j != y)
			{
				if(a[x][j] + a[j][y] < a[x][y])
				{
					puts("-1");
					return 0;
				}
				if(a[x][j] + a[j][y] == a[x][y]) add = false;
			}
		if(add) ans += a[x][y];
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  int N;
  std::cin >> N;
  std::vector<int> L(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> L[i];
  }
  std::sort(L.begin(), L.end());
  int count = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        count += L[i] < L[j] && L[j] < L[k] && L[i] + L[j] > L[k];
      }
    }
  }
  std::cout << count << std::endl;
  return 0;
}


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

#define ll long long int
#define li int64_t

int main()
{
	int n,x,t;
	cin>>n>>x>>t;
	ll ans = 0;
	if(n % x == 0)
	{
		ans = (n/x)*t;
	}	
	else
	{
		ans = ((n/x)+1)*t;
	}
	cout<<ans;
}

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


int main(){
    string s;
    cin>>s;

    if(s=="Sunny"){
        cout<<"Cloudy"<<endl;
    }

    if(s=="Cloudy"){
        cout<<"Rainy"<<endl;
    }

    if(s=="Rainy"){
        cout<<"Sunny"<<endl;
    }

    return 0;
}

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

#include <iostream>
#include <vector>
// #include <map>
 #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

vector<int> shuffle(string str, int s_num) {
	vector<int> position(str.size());
	for (unsigned int i = 0; i < str.size(); i++) {
		position[i] = i;
	}

	int num;
	for (int i = 0; i < s_num; i++) {
		cin >> num;

		for (unsigned int j = 0; j < str.size(); j++) {
			if (position[j] < num) {
				position[j] = str.size() - (num - position[j]);
			} else {
				position[j] -= num;
			}
		}
	}

	return position;
}

string line_up(string str, vector<int> position) {
	string res(str.size(), ' ');
	for (unsigned int i = 0; i < str.size(); i++) {
		res[position[i]] = str[i];
	}

	return res;
}

int main() {
	while (1) {
		string str;
		cin >> str;
		if (str == "-") {
			break;
		}

		int s_num;
		cin >> s_num;

		vector<int> position = shuffle(str, s_num);
		string res = line_up(str, position);
		cout << res << endl;
	}
	//std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}



Measured memory_bytes: 3152
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
P = [ri() for _ in range(N)]

dp = [0] * (N+1)
for i in P:
    dp[i] = dp[i-1]+1

print(N-max(dp))
#40

Measured memory_bytes: 18880
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    double r1, r2; cin >> r1 >> r2;
    cout << setprecision(12) << r1 * r2 / (r1 + r2) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException{
		int h,w;
		String[] str;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();

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

			if(h==0 && w==0)break;

			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					builder.append("#");
				}
				builder.append("\n");
			}
			builder.append("\n");
		}
		builder.delete(builder.length() - 1, builder.length());

		System.out.println(builder.toString());
		br.close();
	}
}

Measured memory_bytes: 25104
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
// ABC102B - Maximum Difference

#include <bits/stdc++.h>
using namespace std;

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

	int minT = 1000000001;
	int maxT = 0;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		minT = min(A, minT);
		maxT = max(A, maxT);
	}

	cout << maxT - minT << endl;

	return 0;
}


Measured memory_bytes: 256
k=int(input())
s=9
l=[1,2,3,4,5,6,7,8,9]
n=0
while s<10**5+1:
  t=l[n]
  z=int(str(t)[-1])
  if z>0:  
    l.append(t*10+z-1)
    s+=1
  l.append(t*10+z)
  s+=1
  if z<9:
    l.append(t*10+z+1)
    s+=1
  n+=1
l.sort()
print(l[k-1])

Measured memory_bytes: 7240
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int X;
    X =  A - B;
    if(C > X){
        C = C -X;
    }else{
        C = 0;
    }
    cout << C << endl;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;
int v[100], w[100], dp[100][100001];
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n,W; cin >> n >> W;
        FOR(i,0,n){
            cin >> w[i] >> v[i];
        }
        FOR(i,0,100){
            FOR(j,0,100001)
                dp[i][j] = 1e18;
        }
        dp[0][0] = 0;
        dp[0][v[0]] = w[0];
        FOR(i,1,n){
            dp[i][0] = 0;
            FOR(j,1,100001){
                dp[i][j] = dp[i-1][j];
                if(j >= v[i])
                    dp[i][j] = min(dp[i][j],dp[i-1][j-v[i]] + w[i]);
            }
        }
        for(int i=100000;i>=0;i--){
            if(dp[n-1][i] <= W){
                cout << i ;
                return 0;
            }
        }
    }   
}

Measured memory_bytes: 81684
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,d,s1;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    d=a[0];
    s1=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<d)
        {
            s1=s1+d-a[i];
        }
        else
        {
            d=a[i];
        }
    }
    cout<<s1<<endl;
}


Measured memory_bytes: 5196
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    string s,t, tmp;
    cin >> s >> t;
    if(s.size() > t.size()){//必ずsの方がtよりも長くないようになった
        tmp = s;
        s = t;
        t = tmp;
    }
    vector<vector<ll> >dp(s.size() + 1, vector<ll>(t.size() + 1));
    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < t.size(); j++){
            if(s.at(i) == t.at(j)) dp.at(i + 1).at(j + 1) = max(dp.at(i + 1).at(j + 1), dp.at(i).at(j) + 1);
            dp.at(i + 1).at(j + 1) = max(dp.at(i + 1).at(j + 1), dp.at(i + 1).at(j));
            dp.at(i + 1).at(j + 1) = max(dp.at(i + 1).at(j + 1), dp.at(i).at(j + 1));
        }
    }
    string res = "";
    int i = s.size(), j = t.size();
    while(i > 0 && j > 0){
        if(dp.at(i).at(j) == dp.at(i).at(j - 1)) j--;   //jが更新されてた
        else if(dp.at(i).at(j) == dp.at(i - 1).at(j)) i--;  //iが更新されてた
        else{
            res = s.at(i - 1) + res;
            i--; j--;
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 70784
/*
 *  author : Atul Anand   
 *  created on : Wed Apr 01 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        boolean flag = false;
        for(int i = 1; i <= 9; i++){
            if(N % i == 0){
                if(N/i < 10){
                    flag = true;
                    break;
                }
            }
        }
        if(flag){
            println("Yes");
        }
        else{
            println("No");
        }
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A<=C){
      if(B<=C){
          cout<<0<<endl;
          return 0;
      }
      else if(B<=D){
          cout<<B-C<<endl;
          return 0;
      }
      else if(D<B){
          cout<<D-C<<endl;
          return 0;
      }
  }
  else if(A>C){
      if(D<=A){
          cout<<0<<endl;
          return 0;
      }
      else if(D<=B){
          cout<<D-A<<endl;
          return 0;
      }
      else if(B<D){
          cout<<B-A<<endl;
          return 0;
      }
  }
}


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

#define MAX_A 10
#define MAX_B 10
#define MAX_C 100

#define xx first
#define yy second

#define MAX_CATE 100

using namespace std;

int d[MAX_A + 1][MAX_B + 1];

int cate[MAX_C + 1][MAX_C + 1][MAX_C + 1];

vector <pair<pair<int, int>, int>> g[MAX_A + 1][MAX_B + 1];
vector <pair<int, int>> care[MAX_C + 1][MAX_C + 1][MAX_C + 1];

bool luat[MAX_A + 1][MAX_B + 1];

struct rezul
{
    int a, b, c;
};

int rez;
rezul rz[MAX_CATE + 1];

int A, B;

int main()
{
    cin >> A >> B;

    int i, j;
    for(i = 1; i <= A; i ++)
    {
        for(j = 1; j <= B; j ++)
            cin >> d[i][j];
    }

    int a, b, c, x, y;
    for(a = 0; a <= 100; a ++)
    {
        for(b = 0; b <= 100; b ++)
        {
            for(c = 0; c <= 100; c ++)
            {
                int ok = 1;
                int oke = 0;
                for(x = 1; x <= A && ok; x ++)
                {
                    for(y = 1; y <= B && ok; y ++)
                    {
                        ok = ok && (a * x + b * y + c >= d[x][y]);
                        oke = oke || (a * x + b * y + c == d[x][y]);
                    }
                }

                if(ok && oke)
                {
                    for(x = 1; x <= A; x ++)
                    {
                        for(y = 1; y <= B; y ++)
                        {
                            if(a * x + b * y + c == d[x][y])
                            {
                                cate[a][b][c] ++;
                                care[a][b][c].push_back({x, y});
                                g[x][y].push_back({{a, b}, c});
                            }
                        }
                    }
                }
            }
        }
    }

    int sum = 0;
    for(x = 1; x <= A; x ++)
    {
        for(y = 1; y <= B; y ++)
        {
            if(luat[x][y] == 0)
            {
                luat[x][y] = 1;
                if(g[x][y].size() == 0)
                {
                    cout << "Impossible\n";
                    return 0;
                }

                int a = g[x][y][0].xx.xx;
                int b = g[x][y][0].xx.yy;
                int c = g[x][y][0].yy;

                rz[++ rez] = {a, b, c};
                sum += a + b + 1;//(c > 0);

                for(auto u : care[a][b][c])
                    luat[u.xx][u.yy] = 1;
            }
        }
    }

    cout << "Possible\n";
    cout << "300 " << sum << "\n";
    assert(sum <= 300);

    int k = 2;
    int ant = 1;
    for(i = 1; i <= rez; i ++)
    {
        int a = rz[i].a;
        int b = rz[i].b;
        int c = rz[i].c;

        ant = 1;
        for(j = 1; j <= a; j ++)
        {
            cout << ant << " " << k << " X\n";
            ant = k;
            k ++;
        }


        for(j = 1; j <= b; j ++)
        {
            cout << ant << " " << k << " Y\n";
            ant = k;
            k ++;
        }

        cout << ant << " 300 " << c << "\n";
    }


    cout << "1 300" << "\n";

    return 0;
}


Measured memory_bytes: 27648
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

ll a[100];

int main()
{
    fastio();
    int n;cin>>n;
    rep(i,1,n) cin>>a[i];
    ll o = 1000;
    rep(i,1,n){
        int now = i;
        while(i+1<=n && a[i+1]>=a[i]) i++;
        o = o/a[now]*a[i] + o%a[now];
    }
    cout<<o<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x;
    int b=0;
    vector<int> a;
    for(int i=0;i<5;i++){
    cin >> x;
      a.push_back(x);
    }
  for(int k=0;k<5;k++){
      if(a[k]==0){
        b=k+1;
      }
  } 
     cout << b << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const long long INF=1e18L +5;
int main()
{
    int n;
    cin>>n;
    vector<long long int>a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<vector<long long int>>dp(n+1,vector<long long int>(n+1,INF));
    for(int l=n-1;l>=0;l--)
    {
        for(int r=l;r<n;r++)
        {
            if(l==r)dp[l][r]=0;
            else
            {
                long long int sum=0;
                for(int i=l;i<=r;i++)
                {
                    sum=sum+a[i];
                }
                for(int i=l;i<r;i++)
                {
                    dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+sum);
                }
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

signed main()
{
//	int a;cin>>a;
	int a,b;cin>>a>>b;
//	int a,b,c;cin>>a>>b>>c;
	int res;
	res = a-b;
	if(b != 1)
	cout << res << endl;
	else if(b == 1){
		cout << 0 << endl;
	}
    return 0;
}

Measured memory_bytes: 256
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

ll Parent[MAX+1];
ll Rank[MAX+1];

ll Find(ll v){
    while(v!=Parent[v]){
        v=Parent[v];
    }
    return v;
}

ll Union(ll u, ll v){
    u=Find(u);
    v=Find(v);
    ll ret=-1;
    if(u==v){
        return ret;
    }
    if(Rank[u]<Rank[v]){
        Parent[u]=v,ret=v;
    }else if(Rank[v]<Rank[u]){
        Parent[v]=u,ret=u;
    }else{
        Parent[v]=u,++Rank[u],ret=u;
    }
    return ret;
}

void Flash(){
    ll n, m;
    ll u, v;
    cin>>n>>m;
    for (ll i = 1; i <= n; i++) {
        Parent[i] = i;
        Rank[i] = 1;
    }
    for (ll i = 0; i < m; i++) {
        cin>>u>>v;
        Union(u, v);
    }
    set <ll> ss;
    for (ll i = 1; i <= n; i++) {
        ss.insert(Find(i));
    }
    cout<<ss.size() - 1<<"\n";
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


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

int main(){
  int n, k, ans=0; cin>>n >>k;
  for(int i=0;i<n;i++){
    int h; cin>>h;
    if(h>=k)ans++;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    s = list(input())
    n = len(s)
    cnt0, cnt1 = 0, 0

    for i in range(n):
        if i % 2 == 0 and s[i] != "0":
            cnt0 += 1
        elif i % 2 == 1 and s[i] != "1":
            cnt0 += 1

    for i in range(n):
        if i % 2 == 0 and s[i] != "1":
            cnt1 += 1
        elif i % 2 == 1 and s[i] != "0":
            cnt1 += 1

    print(min(cnt0, cnt1))


if __name__ == "__main__":
    main()


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

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

    int res = 1;
    rep(i, N)
    {
        if (res < K)
        {
            res += res;
        }
        else
        {
            res += K;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
#define mod 1000000007
int i,j,k,l;
static const int MAX_N=10e5;

	double A[MAX_N];
int main(void){
	int N;
		cin >> N;
	rep(i,0,N)cin >> A[i];
	double ans=0;
	rep(i,0,N){
		ans+=1/A[i];
	}printf("%f",1/ans);
	return 0;
}


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

using ll = long long int;
using P = pair<ll,ll>;
constexpr int INF = 1<<30;

int main() {
    int h, w;
    cin >> h >> w;
    int c[10][10];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin >> c[i][j];
        }
    }
    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
            }
        }
    }
    int ans = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a;
            cin >> a;
            if(a >= 0){
                ans += c[a][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
W = [int(input()) for i in range(n)]

right = sum(W)
left = max(W)-1

while left + 1< right:
    cnt = 1
    cur = 0
    mid = (right + left) // 2
    for w in W:
        if mid < cur + w:
            cur = w
            cnt += 1
        else:
            cur += w

    if cnt <= k:
        right = mid
    else:
        left = mid

print(right)

            





Measured memory_bytes: 9564
# frozen_string_literal: true
# require 'matrix'

def show(x)
  puts x.join(?\s)
end

def solve(n, y)
  c = y / 1_000
  # v = Vector[10,5,1]
  for x in 0..n
    for y in 0..(n-x)
      # w = Vector[x,y,(n - x - y)]
      z = n - x - y
      return [x,y,z] if c == 10*x+5*y+z
    end
  end
  return [-1,-1,-1]
end

def read
  gets.split.map(&:to_i)
end

show solve *read


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(ll i=0; i < n; i++)
#define ALL(n) begin(n), end(n)

ll n;

int main()
{
  cin >> n;

  ll sum = 0;
  REP(i, n){
    if((i+1) % 3 == 0 ||(i+1) % 5 == 0){
      continue;
    }else{
      sum += (i+1);
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  /*
  char s = 'A';
  for(int i = 0; i < 100; i++){
    cout << i << " "<<int(s + i) <<" "<<char(s + i)<< endl;
  }
  */
  string s;
  cin >> s;
  bool is_a = 0;
  int c_cnt = 0;
  int num_u = 0;
  for(int i = 0; i < s.size(); ++i){
    if(s[0] == 'A') is_a = 1;
    if(i >= 2 && i != s.size()-1){
      if(s[i] == 'C')c_cnt += 1;
    }
    if(int(s[i]) >= int('A') && int(s[i]) <= int('Z') ) num_u += 1;
  }
  if(is_a == 1 && c_cnt == 1 && num_u == 2){
    cout << "AC" << endl;
  }else{
    cout << "WA" << endl;
  }
  //cout << "is_a: " << is_a <<" "<<"  c_cnt: "<<c_cnt<<" "<<"  is_u: "<<num_u << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<((ll)n);i++)
#define rep1(i,n) for(ll i=1;i<=((ll)n);i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define meow(a) cout<<a<<" meow\n";
typedef pair<long long,long long> pii;
const ll maxn=200005;
const ll MOD=998244353;
ll n,k;
string s;
ll a[maxn];

int main()
{
    //IOS;
    while(cin>>s)
    {
        int num1=(s[0]-'0')*10+s[1]-'0';
        int num2=(s[2]-'0')*10+s[3]-'0';
        bool MMYY=false,YYMM=false;
        if(num1<=12&&num1>=1) MMYY=true;
        if(num2<=12&&num2>=1) YYMM=true;
        if(YYMM&&MMYY) cout<<"AMBIGUOUS\n";
        else if(YYMM) cout<<"YYMM\n";
        else if(MMYY) cout<<"MMYY\n";
        else cout<<"NA\n";


    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  char c[25];
  int f=0,len,i,j;
  scanf("%s", c);
  len = strlen(c);
  
  for(i=0;i<len;i++){
    for(j=i+1;j<len;j++){
      if(c[i] == c[j]){
	f = 1;
      }
    }
  }
  if(f == 0){
    printf("yes\n");
  }else{
    printf("no\n");
  }
  return 0;
}
    


Measured memory_bytes: 128
#include <iostream>

using namespace std;
long long int X;
int main(void) {

	cin >> X;

	long long int ans = 0;
	ans = (X / 11) * 2;
	X %= 11;

	if (X > 0) { X -= 6; ans++; }

	if (X > 0) { X -= 5; ans++; }

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define all(x) (x).begin(), (x).end()
#define print(x) do{ for (auto xi : x) cout << xi << " "; cout << endl; } while(0)

signed main() {
	int n, t; cin >> n >> t;
	vector<pair<int, int>> ab(n);
	for (int i = 0; i < n; ++i) cin >> ab[i].first >> ab[i].second;
	sort(all(ab));

	// most_delicious[i] := i番目以降で最もおいしいもの
	vector<int> most_delicious(n);
	most_delicious[n - 1] = ab[n - 1].second;
	for (int i = n - 2; i >= 0; --i)
		most_delicious[i] = max(most_delicious[i + 1], ab[i].second);

	vector<vector<int>> dp(n + 1);
	for (int i = 0; i <= n; ++i) dp[i].resize(t, 0);
	for (int i = 1; i <= n; ++i) {
		int a = ab[i - 1].first, b = ab[i - 1].second;
		for (int time = 0; time < t; ++time) {
			dp[i][time] = dp[i - 1][time];
			if (time >= a)
				dp[i][time] = max(dp[i][time], dp[i - 1][time - a] + b);
		}
	}

	//for (int i = 0; i <= n; ++i)
	//	print(dp[i]);

	int ans = 0;
	for (int time = 0; time < t; ++time)
		ans = max(ans, dp[n][time]);
	for (int i = 0; i < n - 1; ++i)
		for (int time = 0; time < t; ++time)
			ans = max(ans, dp[i + 1][time] + most_delicious[i + 1]);
	cout << ans << endl;

	return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int flg=a+b;
    flg +=c;

    if (flg>= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}

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

int main() {
    string S;
    cin >> S;

    if (S == "RRR") {
        cout << "3" << endl;
    }
    else if (S.substr(0, 2) == "RR" || S.substr(1, 2) == "RR") {
        cout << "2" << endl;
    }
    else if (S.at(0) == 'R' || S.at(1) == 'R' || S.at(2) == 'R') {
        cout << "1" << endl;
    }
    else {
        cout << "0" << endl;
    }

    return 0;
}

Measured memory_bytes: 3608
def linp():return list(map(int,input().split()))
n=int(input())
a=linp()
b=linp()
c=linp()
s=b[a[0]-1]
for i in range(1,n):
    s+=b[a[i]-1]
    if a[i]-a[i-1]==1:s+=c[a[i-1]-1]
print(s)

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

int main()
{
    int n,i;
    cin>>n;
    int a[n],temp[n];

    for(i=0;i<n;i++)
        cin>>temp[i];

    if(n%2==0)
    {
        for(i=0;i<n;i++)
        {
            if(i%2==0)
                a[(n/2)+i/2]=temp[i];

            else
                a[(n/2)-(i/2+1)]=temp[i];
        }
    }

    else
    {
        for(i=0;i<n;i++)
        {
            if(i%2==0)
                a[(n/2)-(i/2)]=temp[i];

            else
                a[(n/2)+((i/2)+1)]=temp[i];
        }
    }

    for(i=0;i<n;i++)
        cout<<a[i]<<" ";

    return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define scani(x) scanf("%d",&x)
#define scanc(x) scanf("%s",x)
#define printi(x) printf("%d",x)
#define printin(x) printf("%d\n",x)
#define printc(x) printf("%s",x)
#define repd(i,n,m) for(int i = n; i > m; i--)
#define repu(i,n,m) for(int i = 0; i < m; i++)
#define allprintu(i,n,m,a) for(int i = n; i < m; i++){if(i != m-1){printf("%d ",a[i]);}else{printf("%d",a[i]);}}
#define allprintd(i,n,m,a) for(int i = n; i > m; i--){if(i != 0){printf("%d ",a[i]);}else{printf("%d\n",a[i]);}}

#define MAX 20001

int top1;
int s1[MAX];

int top2;
typedef struct{
	int first,second;
}pair;
pair s2[MAX];

void initialize(){
	top1 = 0;
	top2 = 0;
}

int isempty1(){
	return top1 == 0;
}
int isfull1(){
	return top1 >= MAX - 1;
}
int isempty2(){
	return top2 == 0;
}
int isfull2(){
	return top2 >= MAX - 1;
}
void push1(int x){
	if(isfull1()){
		exit(1);
	}
	s1[++top1] = x;
}
void push2(int first, int second){
	if(isfull2()){
		exit(1);
	}
	pair x;
	x.first = first;
	x.second = second;
	s2[++top2]= x;
}

int pop1(){
	if(isempty1()){
		exit(1);
	}
	top1--;
	return s1[top1+1];
}
pair pop2(){
	if(isempty2()){
		exit(1);
	}
	top2--;
	return s2[top2+1];
}
	
int main(void){
	int i,j,a;
	int sum = 0;
	char ch[MAX];
	pair box;
	initialize();
	scanf("%s",ch);
	for(i = 0; ch[i] != '\0'; i++){
		if(ch[i] == '\\'){
			push1(i);
		}else if(ch[i] == '/' && isempty1() == 0){
			j = pop1();
			sum += i - j;
			a = i - j;
			while(isempty2() == 0 && s2[top2].first > j){
				a += s2[top2].second;
				box = pop2();
			}
			push2(j,a);
		}
	}
	printf("%d\n",sum);
	printi(top2);
	for(int k = 1; k <= top2; k++){
		printf(" %d",s2[k].second);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
typedef long long LL;

LL bit[maxn];
void add(int pos,LL val){
    for(int i=pos;i<maxn;i+=i&-i) bit[i]=(bit[i]+val)%mod;
}
LL ask(int pos){
    LL ret = 0;
    for(int i=pos;i>0;i-=i&-i)
        ret += bit[i];
    return ret%mod;
}

int l[maxn],r[maxn];

int main(void){
    add(1,1);
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++)
        scanf("%d%d",l+i,r+i);
    for(int i=2;i<=n;i++){
        LL tmp = 0;
        for(int j=1;j<=k;j++){
            if(i-l[j]<1) continue;
            int x = i-l[j];
            int y = max(1,i-r[j]);
            tmp += ask(x)-ask(y-1);
        }
        tmp = tmp%mod+mod;
        add(i,tmp%mod);
    }
    LL ans = ask(n)-ask(n-1)+mod;
    printf("%lld\n",ans%mod);
}



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

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

static const int dx[] = {-1, 0, 1, 0};
static const int dy[] = {0, -1, 0, 1};
int n;
int h, w;
int X1[1111], Y1[1111];
int X2[1111], Y2[1111];
bool maze[1111][1111];

inline bool check(int hx, int hy){ return 0 <= hx && hx < h - 1 && 0 <= hy && hy < w - 1;}

int main(int argc, char *argv[])
{
  while(cin >> w >> h, w){
    cin >> n;
    rep(i, n) cin >> Y1[i] >> X1[i] >> Y2[i] >> X2[i];

    vector<int> x, y;
    rep(i, n){
      x.push_back(X1[i]);
      x.push_back(X2[i]);
      y.push_back(Y1[i]);
      y.push_back(Y2[i]);
    }
    x.push_back(0);
    x.push_back(h);
    y.push_back(0);
    y.push_back(w);
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    y.erase(unique(y.begin(), y.end()), y.end());
    rep(i, n){
      X1[i] = find(x.begin(), x.end(), X1[i]) - x.begin();
      X2[i] = find(x.begin(), x.end(), X2[i]) - x.begin();
      Y1[i] = find(y.begin(), y.end(), Y1[i]) - y.begin();
      Y2[i] = find(y.begin(), y.end(), Y2[i]) - y.begin();
    }
    h = x.size();
    w = y.size();
    
    rep(i, h) rep(j, w) maze[i][j] = false;
    rep(i, h) maze[i][w - 1] = true;
    rep(j, w) maze[h - 1][j] = true;
    rep(k, n) erep(i, X1[k], X2[k] - 1) erep(j, Y1[k], Y2[k] - 1) maze[i][j] = true;

    int res = 0;
    rep(i, h) rep(j, w) if(!maze[i][j]) {
      res += 1;
      maze[i][j] = true;
      queue<pair<int, int> > que;
      que.push(make_pair(i, j));
      while(!que.empty()){
        pair<int, int> here = que.front();  que.pop();
        int hx = here.first;
        int hy = here.second;
        rep(k, 4){
          int nx = hx + dx[k];
          int ny = hy + dy[k];
          if(!check(nx, ny)) continue;
          if(!maze[nx][ny]){
            maze[nx][ny] = true;
            que.push(make_pair(nx, ny));
          }
        }
      }
    }

    cout << res << endl;
  }
  
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    int Snum = stoi(S);
    string res;
    int judge = 0;
    
    int t1 = Snum/1000;
    int t2 = (Snum-t1*1000)/100;
    int t3 = (Snum-t1*1000-t2*100)/10;
    int t4 = Snum-t1*1000-t2*100-t3*10;
    int ue = t1*10 + t2;
    int sita = t3*10 + t4;

    if(ue> 0 && ue<13) {
        if(sita > 0 && sita < 13) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if(sita > 0 && sita < 13) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }

    return 0;

}


Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pf push_front
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  rep(i,c-a)cout<<'R';
  rep(i,d-b)cout<<'U';
  rep(i,c-a)cout<<'L';
  rep(i,d-b)cout<<'D';
  cout<<'D';
  rep(i,c-a+1)cout<<'R';
  rep(i,d-b+1)cout<<'U';
  cout<<"LU";
  rep(i,c-a+1)cout<<'L';
  rep(i,d-b+1)cout<<'D';
  cout<<'R'<<endl;
  return 0;
}


Measured memory_bytes: 256