akhauriyash/Code-Regression huggingface dataset:
N, A, B, C, D = map(int, input().split())
S = input()

A -= 1
B -= 1
C -= 1
D -= 1

def check():
	for i in range(A + 1, C - 1):
		if S[i] == S[i + 1] == "#":
			return False

	for i in range(B + 1, D - 1):
		if S[i] == S[i + 1] == "#":
			return False
	
	if D < C:
		for i in range(B, D + 1):
			if S[i - 1] == S[i] == S[i + 1] == ".":
				return True
		return False
	else:
		return True

if check():
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3572
N,A,B,C,D=map(int,input().split())
S=input()[A-1:max(C,D)]

if "##" in S:
  print("No")
elif D>C:
  print("Yes")
else:
  if "..." in S[B-2:min(C,D)+1]:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int D, G; cin >> D >> G;
    VI p(D),c(D);
    rep(i,D) cin >> p[i] >> c[i];
 
    int ans = INF;
    rep(bit,(1<<D)){
        int C = 0, num = 0, res = -1;
        rep(i,D){
            if (bit & (1<<i)) {
                C += 100*(i+1)*p[i] + c[i];
                num += p[i];
            } else res = i;
        }
        if (C < G) {
            if ((G - C + 100*(res+1) - 1) / (100*(res+1)) >= p[res]) continue;
            else num += (G - C + 100*(res+1) - 1) / (100*(res+1));
        }
        ans = min(ans, num);
    }
    ANS;

    return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, x) = readLine()!!.split(" ").map { it.toInt() }
    val inputs = readLine()!!.split(" ").map { it.toInt() }

    var sum = 0
    var cnt = 1
    for ( l in inputs) {
        sum += l
        cnt += 1

        // 加えて超えた場合
        if(sum > x) {
            cnt -= 1
            break
        }
    }

    println(cnt)
}

Measured memory_bytes: 37824
/* ex3_3
  terakura */
 
#include <stdio.h>
 
int main(void){
 
    int n, bace, digits = 0;
 
    scanf("%d %d", &n, &bace);
 
  //nをbaceで割った商が0になるまで繰り返す
    while(n>0){
      n = n/bace;    //nにnをbで割った商を代入
      digits++;    //digitsに１をたす
    }
 
    printf("%d\n", digits);    //桁数を出力
 
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void)
{
  uint64_t N, M;
  cin >> N >> M;
  uint64_t n = min(N, M);
  uint64_t m = max(N, M);
  if(n == 1 && m == 1) cout << 1 << endl;
  else if(n == 1) cout << N*M - 2 << endl;
  else cout << N*M - (2*M + 2*N - 4) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

struct edge {
  int to;
  ll cost;
  edge(int to, ll cost) : to(to), cost(cost) {}
};

class LCA {
public:
  int V, logV;
  vector<int> depth, len;
  vector<vector<int> > parent; // parent[i][v]: ノードvの(i+1)個上の親

  LCA(int V) {
    this->V = V;
    logV = 0;
    while(V > (1LL<<logV)) logV++;
    this->depth = vector<int>(V);
    this->len = vector<int>(V);
    this->parent = vector<vector<int> >(logV, vector<int>(V));
  }

  void init(int v, int par, int d, int l, vector<vector<edge>>& G) {
    depth[v] = d;       // rootからの深さ
    parent[0][v] = par; // 親
    len[v] = l;         // rootからの距離
    for(int i=0; i<(int)G[v].size(); i++) {
      int w = G[v][i].to;   // 子ノード
      int lc = G[v][i].cost; // 子ノードとの距離
      if(w == par) continue;
      init(w, v, d+1, lc + l, G);
    }
  }

  void build() {
    for(int k=0; k+1<logV; k++) {
      for(int v=0; v<V; v++) {
        if(parent[k][v] < 0) parent[k+1][v] = -1;
        else parent[k+1][v] = parent[k][parent[k][v]];
      }
    }
  }

  int query(int u, int v) {
    if(depth[u] > depth[v]) swap(u, v);
    for(int k=0; k<logV; k++) {
      if((depth[v] - depth[u]) >> k & 1)
        v = parent[k][v];
    }
    if(u == v) return u;

    for(int k=logV-1; k>=0; k--) {
      if(parent[k][u] != parent[k][v]) {
        u = parent[k][u];
        v = parent[k][v];
      }
    }
    return parent[0][u];
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<vector<edge>> G(N);
  map<pair<int, int>, int> mp;
  rep(i, N-1) {
    int a, b;
    cin >> a >> b; a--; b--;
    G[a].push_back({b, 1});
    G[b].push_back({a, 1});
    mp[{min(a, b), max(a, b)}] = i;
  }
  LCA lca(N);
  lca.init(0, -1, 0, 0, G);
  lca.build();
  vector<ll> V(N-1);
  int M;
  cin >> M;
  rep(i, M) {
    int u, v;
    cin >> u >> v; u--; v--;
    int z = lca.query(u, v);
    int cur = u;
    while(cur != z) {
      if(!mp.count({min(cur, lca.parent[0][cur]),
              max(cur, lca.parent[0][cur])})) {
        cout << "something wrong\n";
      }
      int e = mp[{min(cur, lca.parent[0][cur]),
                  max(cur, lca.parent[0][cur])}];
      V[e] |= 1<<i;
      cur = lca.parent[0][cur];
    }
    cur = v;
    while(cur != z) {
      if(!mp.count({min(cur, lca.parent[0][cur]),
              max(cur, lca.parent[0][cur])})) {
        cout << "something wrong\n";
      }
      int e = mp[{min(cur, lca.parent[0][cur]),
                  max(cur, lca.parent[0][cur])}];
      V[e] |= 1<<i;
      cur = lca.parent[0][cur];
    }
  }
  vector<vector<ll>> dp(N, vector<ll>(1<<M));
  dp[0][0] = 1;
  rep(i, N-1) {
    rep(j, 1<<M) {
      dp[i+1][j] += dp[i][j];
      dp[i+1][j|V[i]] += dp[i][j];
    }
  }
  cout << dp[N-1][(1<<M)-1] << "\n";
  return 0;
}


Measured memory_bytes: 421044
#include<stdio.h>
#include<math.h>
int main(void){
    double t,v,y,ans;

    while(scanf("%lf",&v)!=EOF){
        t=v/9.8;
        y=t*t*4.9;
        ans=(y+5)/5;
        ans=ceil(ans);
        printf("%.0f\n",ans);
    }

    return 0;
}

Measured memory_bytes: 652
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
int n, m, x;
int c[16], a[16][16];
int main(){
	cin>>n>>m>>x;
	rep(i, n){
		cin >> c[i];
		rep(j, m) cin >> a[i][j];
	}
	ll ans = 1e18;
	rep(mask,(1<<n)){
		int sum[16]={};
		ll r = 0;
		rep(i, n){
			if( ((mask>>i)&1) == 0 ) continue;
			rep(j, m) sum[j] += a[i][j];
			r += c[i];
		}
		rep(j, m){
			if(sum[j] < x) goto nxt;
		}
		chmin(ans, r); nxt:;
	}
	if(ans > 5e17) ans = -1;
	cout<<ans<<endl;
}

Measured memory_bytes: 3628
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		long N = sc.nextLong();
		List<Integer> list = new ArrayList<Integer>();
		int[] n = new int[(int) N];
		for (int i = 0; i < N; i++) {
			n[i] = sc.nextInt();
		}
		for (long i = 0; i < N; i++) {
			int num = n[(int) i];
			int j = LowerBoundCollection(list, num);
			if (list.size() == 0) {
				list.add(num);
				continue;
			}
			if (list.size() < j || j > 0) {
				list.set(j - 1, num);
			} else {
				list.add(0, num);
			}
		}
		System.out.println(list.size());
	}

	public static int LowerBoundCollection(List<Integer> ary, int target) {
		int result = Collections.binarySearch(ary, target, new LowerBoundComparator<>());
		int insertionPoint = (result >= 0) ? result : ~result;
		return insertionPoint;
	}

	public static class LowerBoundComparator<T extends Comparable<? super T>>
			implements Comparator<T> {
		public int compare(T x, T y) {
			return (x.compareTo(y) >= 0) ? 1 : -1;
		}
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

using namespace std;
using ll = long long;

ll a,b,n;
ll cal(ll k) {
    return (a*k)/b-a*(k/b);
}

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

    {
        ll ans=0;
        ll t=0;
        ll cnt=1;
        while(t<=min(b,n)) {
        ans=max(ans,cal(t));
            ll nt;
            nt=(b*cnt-a*t+a-1)/a;
            t+=nt;
            ++cnt;
        }
        cout<<ans<<endl;
    }


    return 0;
}


Measured memory_bytes: 3592
n = int(input())
l = sorted(list(map(int, input().split())))

if n % 2 == 1:
    print(0)
    exit(0)

a, b = l[:n//2], l[n//2:]

if a[-1] == b[0]:
    print(0)
else:
    print(b[0] - a[-1])

Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define FRU                                  freopen("out.txt","w",stdout);
#define FRO                                  freopen("in.txt","r",stdin);
#define pb                                   push_back
#define pf                                   push_front
#define ppb                                  pop_back()
#define ppf                                  pop_front()
#define mp                                   make_pair
#define ff                                   first
#define ss                                   second
#define flash                                ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mem(ara,n)                           memset(ara,n,sizeof ara)
#define fr(i,j,n)                            for(i=j;i<n;i++)
#define rf(i,j,n)                            for(i=n;i>=j;i--)
#define inf                                  2147483647
#define ll                                   long long
#define ull                                  unsigned long long
#define pii                                  pair<int,int>
#define vi                                   vector<int>
#define vll                                  vector <long long>
#define vch                                  vector <char>
#define itr                                  ::iterator
#define msi                                  map<string,int>
#define psi                                  pair <string,int>
#define vii                                  vector <pair<int,int> >
#define all(n)                               n.begin(),n.end()
#define INF                                  10000000000000000LL
#define pi                                   3.1415926535897932384626434
#define sii                                  set <int>
#define max3(a,b,c)                          max(a,max(b,c))
#define min3(a,b,c)                          min(a,min(b,c))
#define mid3(a,b,c)                          min(max(a,b),max(b,c),max(a,b))
#define max4(a,b,c,d)                        max(max(a,b),max(c,d))
#define min4(a,b,c,d)                        min(min(a,b),min(c,d))
#define endl                                 '\n'
#define endll                                cout<<"\n";
#define spc                                  ' '
#define ld                                   long double

using namespace std;



int main()
{
    flash
    string s,st;
    int n,t,T,i,j,J,I,k,m;
    char ch;
    cin>>n;
    int boss[200005]={0};
    fr(i,1,n)
    {
        cin>>m;
        boss[m]++;
    }
    fr(i,1,n+1)cout<<boss[i]<<endl;
    return 0;
}




Measured memory_bytes: 4412
//3人でカードゲームイージー

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "

using p = pair<ll,string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    vector<string>s(3);
    cin>>s[0]>>s[1]>>s[2];
    int o = s[0][0]-97;
    s[0].erase(0,1);
    while(true){
        if(o==0&&s[0].empty()){cout<<"A"<<nnn;return 0;}
        else if(o==1&&s[1].empty()){cout<<"B"<<nnn;return 0;}
        else if(o==2&&s[2].empty()){cout<<"C"<<nnn;return 0;}
        int c = s[o][0];
        s[o].erase(0,1);
        o=c-97;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc=new Scanner(System.in);
      String po=sc.nextLine();
      String popo=sc.nextLine();
      for(int i=0;i<popo.length();i++){
      	System.out.print(po.substring(i,i+1)+popo.substring(i,i+1));
      }
      System.out.println((po.length()==popo.length())?"":po.substring(po.length()-1,po.length()));
    }
}


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

int main() {
  ll r,d,x;
  cin >> r >> d >> x;
  rep(i,10){
  	x=r*x-d;
  	cout << x << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 500010


int main() {
	char a[N];
	long long b[N];
	f(i, N)a[i] = 0;
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%s", a);
	n = strlen(a);
	b[0] = 0;
	f(i, n) {
		if (a[i] == '<')b[i + 1] = b[i] + 1;
		else b[i + 1] = 0;
	}
	for (int i = n - 1; i >= 0; i--) {
		if (a[i] == '>')b[i] = max(b[i], b[i + 1] + 1);
	}
	f(i, n + 1)ans += b[i];
	printf("%lld\n", ans);


	return 0;
}


Measured memory_bytes: 4608
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val count = Array(n + 1) { 0 }
    for (i in 0 until m) {
        val a = sc.nextInt()
        val b = sc.nextInt()
        if (a != 1 && b != 1) {
            count[a]++
            count[b]++
        } else if (a == 1) {
            count[b]++
        } else {
            count[a]++
        }
    }
    println(if (count.all { it % 2 == 0 }) "YES" else "NO")
}

fun compress(a: Array<Int>): Array<Int> {
    val n = a.count()
    val b = a.sorted().distinct().toTypedArray()
    val c = Array(n) { 0 }
    for (i in 0 until n) {
        c[i] = Arrays.binarySearch(b, a[i])
    }
    return c
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

using namespace std;
using ll = long long;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;

    for(int i = 0; i < N - 1; i++) {
        vector<bool> A(26, 0);
        int anstemp = 0;
        for(int j = 0; j < i; j++) {
            A.at(S.at(j) - 'a') = 1;
        }
        for(int j = i; j < N; j++) {
            if(A.at(S.at(j) - 'a')) {
                A.at(S.at(j) - 'a') = 0;
                anstemp++;
            }
        }
        ans = max(ans, anstemp);
    }
    cout << ans << endl;



    return 0;
}

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

int n, x;
ll minstamina = __LONG_LONG_MAX__;
int cords[100];

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        cords[i] = x;
    }

    for (int center = 1; center <= 100; center++)
    {
        ll stamina = 0;
        for (int i = 0; i < n; i++)
        {
            stamina += (cords[i] - center) * (cords[i] - center);
        }
        minstamina = min(stamina, minstamina);
    }

    cout << minstamina;
    cin >> n;
}

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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> F(h);
    rep(i, h) cin >> F[i];

    //前処理用のはいれちゅを用意
    int L[h][w], R[h][w], U[h][w], D[h][w];

    rep(i, h)
    {
        int cnt = 0;
        rep(j, w)
        {
            cnt++;
            if (F[i][j] == '#')
                cnt = 0;
            L[i][j] = cnt;
        }
    }

    rep(i, h)
    {
        int cnt = 0;
        rep(j, w)
        {
            cnt++;
            if (F[h - i - 1][w - j - 1] == '#')
                cnt = 0;
            R[h - i - 1][w - j - 1] = cnt;
        }
    }

    rep(j, w)
    {
        int cnt = 0;
        rep(i, h)
        {
            cnt++;
            if (F[i][j] == '#')
                cnt = 0;
            U[i][j] = cnt;
        }
    }

    rep(j, w)
    {
        int cnt = 0;
        rep(i, h)
        {
            cnt++;
            if (F[h - i - 1][w - j - 1] == '#')
                cnt = 0;
            D[h - i - 1][w - j - 1] = cnt;
        }
    }

    //前処理終わり

    int ans = 0;
    rep(i, h)
    {
        rep(j, w)
        {
            int res = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
            ans = max(ans, res);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 66816
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
//using namespace atcoder;

template<typename T>
struct Doubling{
	const int LOG_X;
	bool flag1, flag2;
	vector<vector<T>> dp;

	Doubling(int n,ll x):LOG_X(log2(x)+1){//n:配列のサイズ,x:遷移する回数
		flag1 = false;
		flag2 = false;
		dp.assign(LOG_X, vector<T>(n, -1));
	}

	void init(vector<T> &a){//適宜変える
		int n = a.size();
		flag1 = true;
		rep(i, n)
		{
			dp[0][i] = a[i];
		}
	}

	void build(){
		assert(flag1);
		flag2 = true;
		for (int k = 0; k + 1 < LOG_X; ++k)
		{
			for (int i = 0; i < dp[0].size();++i){
				if(dp[k][i]==-1){//2^k先の要素がないなら2^(k+1)先の要素もない
					dp[k + 1][i] = -1;
				}
				else{//2^k*2^k=2^(k+1)
					dp[k + 1][i] = dp[k][dp[k][i]];
				}
			}
		}
	}

	T query(int s,ll x){//s:スタート地点,x:遷移回数
		assert(flag2);
		for (int i = LOG_X - 1; i >= 0; i--)
		{
			if(x&(1LL<<i)){
				s = dp[i][s];
			}
		}
		return s;
	}
};

void solve(){
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;++i){
		ans+=(n-1)/i;
	}
	cout<<ans<<"\n";
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const ll INF = 1<<30;
const ll MOD = (ll)1e9 + 7;
const ll MAX_N = (ll)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(ll i = 0; i < (ll) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    ll n; cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++)
    {
        if(i % 3 != 0 && i % 5 != 0)
        {
            ans += i;
        }
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3648
A,B,K = map(int, input().split())

if B-A+1<= 2*K:
    print(*range(A,B+1), sep="\n")
else:
    a = list(range(A,A+K))
    b = list(range(B-K+1,B+1))
    C = sorted(set(a+b))
    print(*C, sep="\n")

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;
using vb=vector<bool>;using vs=vector<string>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<typename T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){o<<'('<<p.fst<<", "<<p.snd<<')';return o;}

int sign(long long x) {
  return x < 0 ? -1 : 1;
}

int solve() {
  int x = read<int>();
  int y = read<int>();
  if (x == y) return 0;
  if (x == -y) return 1;

  int ax = abs(x);
  int ay = abs(y);

  int ans = 0;
  if (ax < ay) {
    if (x < 0) {
      ans++;
    }
    ans += ay - ax;
    if (y < 0) ans++;
  }
  else {
    if (x > 0) ans++;
    ans += ax - ay;
    if (y > 0) ans++;
  }
  return ans;
}
void Main() { cout << solve() << endl; }

int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
char c[110];
int main(){

  int a,b;
  cin >> a >> b;
  for(int i=0;i<b;i++)c[i]='0'+a;
  string s=c;
  for(int i=0;i<a;i++)c[i]='0'+b;
  c[a]=0;
  string s1=c;
  printf("%s\n",min(s,s1).c_str());
}

Measured memory_bytes: 3624
import java.util.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        Set<String> set = new HashSet<String>();
        for(int i=0;i<N;i++) {
            set.add(sc.next());
        }
        List<String> list = new ArrayList<String>(set);
        System.out.println(list.size());
    }
}


Measured memory_bytes: 76788
/*
------------------------------------------------------
 
    Dilon Mein Tum Apni Betaabiyan Leke Chal Rahe Ho,
    Toh Zinda Ho Tum.
       
    Nazar Mein Khwabon Ki Bijliyan Leke Chal Rahe Ho,
    Toh Zinda Ho Tum.
	
    Hawa Ke Jhokon Ke Jaise Aazad Rehno Sikho,
    Tum Ek Dariya Ke Jaise Lehron Mein Behna Sikho,
    Har Ek lamhe Se Tum Milo Khole Apni Bhaayein,
    Har Ek Pal Ek Naya Samha Dekhen Yeh Nigahaein,
    
    Jo Apni Aankhon Mein Hairaniyan Leke Chal Rahe Ho,
    Toh Zinda Ho Tum.
    
    Dilon Mein Tum Apni Betaabiyan Leke Chal Rahe Ho,
    Toh Zinda Ho Tum.   
 
    - Imran ( Zindagi Na Milegi Dobara )
 
-------------------------------------------------------	                                                                                                
 
	Author :- Gaurang_Kothiya
	Nirma University
 
*/ 
 
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  
 
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ld long double
#define f(i,x,n) for(auto i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(auto i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007
 
 
 
 
 
void Solve()
{	
	ll a,b;
	cin>>a>>b;
	cout<< a*b ;
	
}
 
 
 
 
signed main() 
{
	speed	
	
	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
} 

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define for_each(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);
typedef long double ld;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll l = 4 * a * b;
    ll r = (c - a - b) * (c - a - b);
    if (l < r && (c - a - b) > 0)
        CYES;
    else
        CNO;
    return 0;
}


Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,a[100010];

int main()
{
	cin>>n;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	cout<<a[n/2]-a[n/2-1]<<endl;
	rt0;
}

Measured memory_bytes: 640
///******* In the name of Allah *******///

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

int main()
{
    int m = 65,n,i,j,k,l;
    char a[53],b[10013];
    for(i=0;i<=25;i++)
    {
        a[i] = m;
        m++;
    }
    m = 97;
    for(i=26;i<=51;i++)
    {
        a[i] = m;
        m++;
    }
//    for(i=0;i<=51;i++)
//    {
//        cout<<a[i]<<endl;
//    }
    cin>>n;
    cin>>b;
    l = strlen(b);
    for(i=0;i<l;i++)
    {
        for(j=0;j<=51;j++)
        {
            if(b[i]==a[j])
            {
                k = j+n;
                if(k>25)
                {
                    b[i] = a[k] - 32;
                    break;
                }
                else if(k<=25)
                {
                    b[i] = a[k];
                    break;
                }
            }
        }
    }
    for(i=0;i<l;i++)
    {
        cout<<b[i];
    }

    return 0;
}


Measured memory_bytes: 256
loop do
  n, x = gets.split.map(&:to_i)
  break if n == 0 && x == 0

  ans = 0
  1.upto(n-2) do |i|
    (i+1).upto(n-1) do |j|
      (j+1).upto(n) do |k|
        ans += 1 if i + j + k == x
      end
    end
  end

  puts ans
end



Measured memory_bytes: 6852
#include <iostream>
#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 <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint n; cin >> n;
  vector<lint> x(n);
  vector<lint> y(n);

  vector<lint> plus(n);
  vector<lint> minus(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    plus[i] = x[i] + y[i];
    minus[i] = x[i] - y[i];
  }

  sort(ALL(plus));
  sort(ALL(minus));

  lint ans = 0;

  ans = max(ans, plus[n - 1] - plus[0]);
  ans = max(ans, plus[0] - plus[n - 1]);

  ans = max(ans, minus[n - 1] - minus[0]);
  ans = max(ans, minus[0] - minus[n - 1]);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9212
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	string s;
	cin >> s;
	cout << (s == "ARC" ? "ABC" : "ARC");
}


Measured memory_bytes: 3656
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

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

	if (S[0] != 'A')
	{
		cout << "WA" << endl;
		return 0;
	}

	int count = 0;
	int idx = 0;
	FOR(i, 2, SIZE(S) - 1)
	{
		if (S[i] == 'C')
		{
			count++;
			idx = i;
		}
	}
	if (count != 1)
	{
		cout << "WA" << endl;
		return 0;
	}

	FOR(i, 1, SIZE(S))
	{
		if (i == idx)
			continue;

		string str = S.substr(i, 1);
		transform(str.begin(), str.end(), str.begin(), ::tolower);
		if (str != S.substr(i, 1))
		{
			cout << "WA" << endl;
			return 0;
		}
	}

	cout << "AC" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back

#define ll long long


int n;
double a[11111];

int main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    double sum=0;
    rep(i,n)sum+=1.0/a[i];
    printf("%.10lf\n",1.0/sum);
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ITP1_4_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = double.Parse(Console.ReadLine());
            Console.WriteLine("{0:#.000000} {1:#.000000}", Math.PI * r * r, Math.PI * 2 * r);
        }
    }
}

Measured memory_bytes: 9328
#include <bits/stdc++.h>
using namespace std;
int p[100002], q[100002], r[100002];
long long sum[100002];
int main(){
    int x, y, a, b, c;
    scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
    for(int i=1;i<=a;i++) scanf("%d", &p[i]);
    for(int i=1;i<=b;i++) scanf("%d", &q[i]);
    for(int i=1;i<=c;i++) scanf("%d", &r[i]);
    sort(p+1, p+1+a), sort(q+1, q+1+b), sort(r+1, r+1+c);
    reverse(p+1, p+1+a), reverse(q+1, q+1+b), reverse(r+1, r+1+c);
    long long ans = 0, tmp = 0;
    for(int i=1;i<=c;i++) sum[i] = sum[i-1] + r[i];
    int j = 1, k = 1;
    for(int i=0;i<=x+y;i++){
        if(x+y-i <= c) ans = max(ans, tmp + sum[x+y-i]);
        if(j <= x && k <= y && p[j] >= q[k]){
            tmp += p[j];
            j++;
        }
        else if(j <= x && k <= y && q[k] >= p[j]){
            tmp += q[k];
            k++;
        }
        else if(j <= x){
            tmp += p[j];
            j++;
        }
        else if(k <= y){
            tmp += q[k];
            k++;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int firstappear[205000];
int lastappear[205000];

ll N, K;
ll A[205000];
l_l dp[205000][102];
vector<int> ans;
bool used[205000];

l_l now;

void f(int index) {
    if(index == -1) return;
    if(dp[now.first][index].second + now.second < K) {
        now.second += dp[now.first][index].second;
        now.first = dp[now.first][index].first;
    }
    f(index - 1);
}

int main() {
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int val = 0; val <= 2e5; val++) {
        firstappear[val] = -1;
        lastappear[val] = -1;
    }
    for(int i = 0; i < N; i++) {
        if(firstappear[A[i]] != -1) {
            dp[lastappear[A[i]]][0].first = (i + 1) % N;
            if(i == (N - 1)) dp[lastappear[A[i]]][0].second++;
            lastappear[A[i]] = i;
            continue;
        } else {
            firstappear[A[i]] = i;
            lastappear[A[i]] = i;
            continue;
        }
    }
    for(int val = 1; val <= 2e5; val++) {
        if(firstappear[val] == -1) continue;
        dp[lastappear[val]][0] = {(firstappear[val] + 1) % N, 1 + ((firstappear[val] + 1) / (N))};
    }
    /*
    for(int i = 0; i < N; i++) {
        cerr << i << " " << dp[i][0].first << " " << dp[i][0].second << endl;
    }
    */
    for(int timer = 1; timer <= 100; timer++) {
        for(int index = 0; index < N; index++) {
            dp[index][timer].second += dp[index][timer-1].second;
            int now = dp[index][timer - 1].first;
            dp[index][timer].second += dp[now][timer-1].second;
            chmin(dp[index][timer].second, (ll)1e17);
            dp[index][timer].first = dp[now][timer-1].first;
        }
    }
    now = {0, 0};
    f(100);
    //cerr << now.first << " " << now.second << endl;
    while(now.second < K) {
        int pos = now.first;
        if(used[A[pos]]) {
            while(used[A[pos]]) {
                used[ans.back()] = false;
                ans.pop_back();
            }
        } else {
            used[A[pos]] = true;
            ans.push_back(A[pos]);
        }
        now.first++;
        if(now.first == N) {
            now.first = 0;
            now.second++;
        }
    }
    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 326388
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair <int, int> pii;
typedef pair <int, pii> ppp;

vector <ppp> all;
int K[500010], L[500010], R[500010];
int vis[500010];
int n;

struct Segment_tree {
	int T[2000010], lazy[2000010];
	void pushdown(int now) {
		T[now << 1] += lazy[now], T[now << 1 | 1] += lazy[now];
		lazy[now << 1] += lazy[now], lazy[now << 1 | 1] += lazy[now];
		lazy[now] = 0;
	}
	void Build(int now, int l, int r) {
		lazy[now] = 0;
		if (l == r) {
			T[now] = l;
			return ;
		}
		int mid = l + r >> 1;
		Build(now << 1, l, mid), Build(now << 1 | 1, mid + 1, r);
		T[now] = min(T[now << 1], T[now << 1 | 1]);
	}
	void Update(int now, int l, int r, int L, int R) {
		if (l == L && r == R) {
			T[now]--, lazy[now]--;
			return ;
		}
		pushdown(now);
		int mid = l + r >> 1;
		if (R <= mid) Update(now << 1, l, mid, L, R);
		else if (L > mid) Update(now << 1 | 1, mid + 1, r, L, R);
		else Update(now << 1, l, mid, L, mid), Update(now << 1 | 1, mid + 1, r, mid + 1, R);
		T[now] = min(T[now << 1], T[now << 1 | 1]);
	}
	int Query(int now, int l, int r, int L, int R) {
		if (l == L && r == R) return T[now];
		pushdown(now);
		int mid = l + r >> 1;
		if (R <= mid) return Query(now << 1, l, mid, L, R);
		if (L > mid) return Query(now << 1 | 1, mid + 1, r, L, R);
		return min(Query(now << 1, l, mid, L, mid), Query(now << 1 | 1, mid + 1, r, mid + 1, R));
	}
}seg1, seg2;

void read(int &x) {
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	x = c - '0', c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
}

int main () {
//	freopen("b.in", "r", stdin);
//	freopen("b.out", "w", stdout);
	int T; read(T);
	while (T--) {
		read(n);
		seg1.Build(1, 1, n), seg2.Build(1, 1, n);
		memset(vis, 0, sizeof(vis));
		all.clear();
		for (int i = 0; i < n; i++) {
			read(K[i]), read(L[i]), read(R[i]);
			all.push_back(mp(L[i] - R[i], mp(i, 0)));
			if (K[i] != n) all.push_back(mp(R[i] - L[i], mp(i, 1)));
		}
		sort(all.begin(), all.end()), reverse(all.begin(), all.end());
		long long ans = 0;
		for (int i = 0; i < all.size(); i++) {
			int x = all[i].se.fi, p = all[i].se.se, val = all[i].fi;
			if (vis[x]) continue;
			if (!p) {
				if (seg1.Query(1, 1, n, K[x], n) > 0) {
					seg1.Update(1, 1, n, K[x], n);
					ans += val + R[x], vis[x] = 1;
				}
			} else {
				if (seg2.Query(1, 1, n, n - K[x], n) > 0) {
					seg2.Update(1, 1, n, n - K[x], n);
					ans += val + L[x], vis[x] = 1;
				}
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}
/*
3
3
2 1 9
2 6 6
3 7 4
4
4 7 8
4 7 9
4 1 5
1 10 10
8
5 1 5
1 4 5
1 8 7
5 8 3
1 1 2
8 8 2
1 3 7
5 9 8


*/

Measured memory_bytes: 21216
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>
#include<list>

using namespace std;


int main()
{
	long long N, n, dig, sum = 0, ans = 0;
	int flag = 1;

	cin >> N;

	n = N;
	while (n) {
		dig = n % 10;
		ans += dig;
		n = n / 10;
	}

	if (ans == 1)ans = 10;
	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

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

int main(){

int n, q;
cin >> n >> q;

string S;
cin >> S;

vector<int> x(q);
vector<int> y(q);
     for(int i = 0; i < q; i++){ 
           cin >> x.at(i) >> y.at(i);
     }

vector<int>sum(n + 1);
sum.at(0) = 0;
sum.at(1) = 0;
int cnt = 0;
     for(int i = 1; i < n ; i++){ 
          if(S.at(i - 1) == 'A' && S.at(i) == 'C'){
               cnt++;
               
          }
          sum.at(i + 1) = cnt;
     } 

     for(int i = 0; i < q; i++){ 
          int ans = sum.at(y.at(i)) - sum.at(x.at(i)); 
          cout << ans << endl;
     }

}


Measured memory_bytes: 2304
x=[]
u=[]
N = int(input())
for i in range(N):
  X, U = input().strip().split(' ')
  x.append(X)
  u.append(U)
sum = 0
  
for i in range(N):
  if u[i] == "JPY":
    sum = sum + int(x[i])
  else:
    sum = sum + float(x[i]) * 380000

print(sum)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (long) 1e9 + 7;

int main(){
    
    long x, money = 100;
    cin >> x;
    
    long ans = 0;
    
    while(money < x){
        ans++;
        money += money / 100;
    }
    
    cout << ans << "\n";
    
    return 0;
}



Measured memory_bytes: 3164
#include<stdio.h>
int main()
{
  int a,b,k,a_,amari,kouyaku,answer;
  scanf("%d %d %d",&a,&b,&k);
  if (a>b)  //bよりaを小さくする a<b
  {
    a_=a;
    a=b;
    b=a_;
  }
  while(1)
  {
    amari=b%a;
    if (amari==0)
    {
      kouyaku=a;
      break;
    }
    b=amari;
    a_=a;
    a=b;
    b=a_;
  }
  for( answer=kouyaku; answer>=1; answer-- )
  {
    if( kouyaku%answer == 0 ) k--;
    if (k==0) break;
  }
  printf("%d",answer);
  return 0;
}

Measured memory_bytes: 128