akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = 5;
            int sum = 0;
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++)
                ar[i] = in.nextInt();
            Arrays.sort(ar, Comparator.comparingInt(o -> o % 10));
            int j = 0;
            while (j < n && ar[j] % 10 == 0) {
                sum += ar[j];
                j++;
            }
            int e = j;
            for (int i = n - 1; i >= e; i--) {
                int curRes;
                if (i > e)
                    curRes = 10 * ((ar[i] + 9) / 10);
                else
                    curRes = ar[i];
                sum += curRes;
            }
            out.println(sum);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 28372
N = int(input())
route = [{} for _ in range(N)]
dist = [-1] * N
for i in range(N - 1):
    a, b, d = map(int, input().split())
    route[a-1][b-1] = d
    route[b-1][a-1] = d

Q, K = map(int, input().split())
dist[K-1] = 0
dfs_stack = [K-1]
while dfs_stack:
    s = dfs_stack.pop()
    for t, t_dist in route[s].items():
        if dist[t] == -1:
            dist[t] = dist[s] + t_dist
            dfs_stack.append(t)
for i in range(Q):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    print(dist[x] + dist[y])


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

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define int long long
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }


const int N=1e5+5,mod=1e9+7,bit=61;


signed main()
{
    fast;

    int t=1;
    //cin>>t;
    f(tc,1,t)
    {
        string s;
        cin>>s;
        int ans=0;
        int id=3;
        f(i,0,2)
        {
            if(s[i]=='R')
            {
                id=i;
                break;
            }
        }
        while(id<3 and s[id]=='R')
        {
            ans++;
            id++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a)
#define ld long double
const ll mod=1e9+7;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
int main() {
    ll sum;
    cin >> sum;
    ll temp=sum%500;
    ll ans=(sum/500)*1000;
    ans+=(temp/5)*5;
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
tbl = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    tbl[b - 1][f - 1][r - 1] += v
for j, row in enumerate(tbl):
    if j != 0:print("#" * 20)
    for k in row:
        print("", *k)


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

int main() {
	vector<int> num;
	int n, temp;
	cin >> n;
	vector<int> dp(n);
	for (int i = 0; i < n; ++i) {
		cin >> temp;
		num.push_back(temp);
	}
	for (int i = 1; i < n; ++i) {
		if (i == 1) {
			dp[i] = dp[i - 1] + abs(num[i] - num[i - 1]);
		} else {
			dp[i] = min(dp[i - 1] + abs(num[i] - num[i - 1]), dp[i - 2] + abs(num[i] - num[i - 2]));
		}
	}
	cout << dp[n - 1];
	return 0;
}


Measured memory_bytes: 3812
#include <iostream>

using namespace std;

int main()
{
  int n, m; cin >> n >> m;
  int cnt[n + 1];
  // 初期化
  for (int i = 1; i <= n; i++) cnt[i] = 0;

  for (int i = 1; i <= m; i++) {
    int a, b; cin >> a >> b;
    cnt[a] += 1;
    cnt[b] += 1;
  }

  for (int i = 1; i <= n; i++) cout << cnt[i] << endl;

  return 0;
}


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

int main()
{
	int n;
	while (cin >> n, n) {
		vector<int> v(n);
		for (int i = 0;i < n; i++) {
			cin >> v[i];
		}
		sort(v.begin(), v.end());
		int sum = 0;
		for (int i = 1; i < n-1; i++) {
			sum += v[i];
		}
		cout << sum / (n-2) << endl;
	}
	
	return 0;
}

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

//連結であることの判定
//dfs(再帰)による実装

void dfs(int node, vector<vector<bool> > G, vector<bool>& visited){
    //cout << node << endl;
    
    int n = G.size();
    visited[node] = true;

    for(int i = 0; i < n; i++){
        if(G[node][i] && !visited[i]){
            dfs(i, G, visited);
        }
    }
}

int main(){

    int V, E; cin >> V >> E;                          // V:= 頂点の数    E:= 辺の数
    vector<vector<bool> > G(V, vector<bool> (V, false));
    vector<pair<int, int> > edge(E);

    for(int i = 0; i < E; i++){
        int a, b; cin >> a >> b;
        a--;
        b--;
        edge[i].first = a;
        edge[i].second = b;        
        G[a][b] = G[b][a] = true;
    }

    //vector<bool> u(V, false);
    //dfs(0, G, u);
    //return 0;
    int ans = 0;
    for(int i = 0; i < E; i++){
        vector<bool> visited(V, false);
        G[edge[i].first][edge[i].second] = G[edge[i].second][edge[i].first] = false;
        //cout << edge[i].first << " " << edge[i].second << endl;
        dfs(0, G, visited);

        bool flag = true;
        for(int j = 0; j < V; j++){
            if(!visited[j]){
                flag = false;
                break;
            }
        }

        if(!flag) ans++;
        G[edge[i].first][edge[i].second] = G[edge[i].second][edge[i].first] = true;

    }

    cout << ans << endl;

    return 0;
}

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

int n;
vector<int> xs;

bool solve(int i, int m) {
    if(i == n) return m == 0;
    return solve(i + 1, m - xs[i]) || solve(i + 1, m);
}

int main() {
    cin >> n;
    xs = vector<int>(n);
    for(int i = 0; i < n; i++) cin >> xs[i];
    int q; cin >> q;
    while(q--) {
        int m; cin >> m;
        bool result = solve(0, m);
        cout << (result ? "yes" : "no") << endl;
    }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll N;
  cin>>N;
  ll A[N];
  ll sum[N]={};

  FOR(i,0,N-1){
    cin>>A[i];
    sum[A[i]]++;
  }

  ll ans=1;
  ll flag=0;
  if(N%2!=0){
    if(sum[0]!=1)flag=1;

  
    FOR(i,1,N/2){
      if(sum[2*i]!=2)flag=1;
      ans=ans*2%MOD;
  //cout<<flag<<endl;
    }
  }
  if(N%2==0){
    FOR(i,1,N/2){
      if(sum[2*i-1]!=2)flag=1;
      ans=ans*2%MOD;
    }
  }
  if(flag==1)ans=0;

  cout<<ans<<endl;

  return 0;
}
 


Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  cin >> s >> t;
  s += t;
  n = 0;
  t = "No";
  rep(i,0,s.sz)n += (s[i] - '0') * pow(10,s.sz-1-i);
  rep(i,1,n/2)if(i * i == n)t = "Yes";
  print(t);
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]

ans = 0
for i in range(N):
    for j in range(N):
        ans += (1.0 * (xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2) ** 0.5

print(ans / N)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        double[] probs = new double[n];
        for (int i = 0; i < n; i++) {
            probs[i] = sc.nextDouble();
        }

        double[][] dp = new double[n + 1][n + 1];
        dp[0][0] = 1.0;

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

                double p1 = dp[i-1][j];
                double p2 = (j > 0) ? dp[i-1][j-1] : 0;
                double p = probs[i - 1];
                dp[i][j] = p1 * (1.0 - p) + p2 * p;
            }
        }

        double result = 0.0;
        for (int i = n/2 + 1; i <= n; i++) {
            result += dp[n][i];
        }

        System.out.println(result);

    }
}

Measured memory_bytes: 123896
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
using namespace std;
const int maxn = 2e5+5;
ll a[maxn];
map<ll, ll>mp;

int main(){
	int n; cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		mp[-(a[i]+i)]++;
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		ans += mp[a[i]-i];
	}
	cout << ans << endl;
}

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

string a, b;

int main(void) {
    cin >> a >>  b;
    bool greaterA = false;
    if (a.size() > b.size()) greaterA = true;
    else if (a.size() == b.size()) {
        if (a == b) {
            cout << "EQUAL" << endl;
            return 0;
        }
        for (int i = 0; i < a.size(); i++) {
            if ((int)a[i] > (int)b[i]) {
                greaterA = true;
                break;
            } else if ((int)a[i] < (int)b[i]) 
                break;
            i++;
        }
    }
    if (greaterA) cout << "GREATER" << endl;
    else cout << "LESS" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
b = []
for i in a:
    b.append(i + 1)
    b.append(i)
    b.append(i - 1)
##辞書型 キーに要素、値に出現回数を出力
c = Counter(b)
##most_comonn (要素, 出現回数)という形のタプルを出現回数順に並べたリストを返す
##出現回数が最も多いものは[0],出現回数のみを出力するので[1]
print(c.most_common()[0][1])


Measured memory_bytes: 34888
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    s.push_back('K');
    vector<int> v(s.size());
    int itr = 0;
    ll ans = 0;
    vector<bool> A(s.size());
    REP(i, s.size()) {
        if (s[i] == 'A') {
            v[itr] = 0;
            A[itr] = true;
            itr++;
        }
        else if (s[i] == 'B' && i + 1 < s.size() && s[i+1] == 'C') {
            v[itr] = 1;
            A[itr] = false;
            itr++;
            i++;
        }
        else {
            for (int j = 0; j < itr-1; j++) {
                v[j + 1] += v[j];
            }
            if (itr > 0) {
                for (int j = 0; j < itr; j++) {
                    if (A[j]) {
                        ans += v[itr-1] - v[j];
                    }
                }
            }
            itr = 0;
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 1428
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	string s; cin >> s;
	int r = 0;
	for(char c : s) if(c == 'R') ++r;
	if(r <= 1 || r == 3) cout << r;
	else{
		if(s[1] == 'S') cout << 1;
		else cout << 2;
	}
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3608
import sys
# input = sys.stdin.readline

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

print(4 + (N + min(A, B, C, D, E) - 1) // min(A, B, C, D, E))

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	long long a[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	long long prev = 0;
	long long count = 0;
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] <= prev) count++;
		else count = 0;
		ans = max(ans, count);
		prev = a[i];
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4436
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(void){
    int N;
    scanf("%d",&N);

    //Map[i][j]...iの人がjの人に対してなんて言及しているか(1→正直,0→不親切,-1→言及なし)
    int Map[N][N];
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++) Map[i][j]=-1;
    }

    //Mapを埋める
    for(int i=0;i<N;i++){
        int A;
        scanf("%d",&A);
        int x,y;
        for(int j=0;j<A;j++){
            scanf("%d%d",&x,&y);
            Map[i][x-1]=y;
        }
    }

    int ans=0;
    for(int i=0;i<(1<<N);i++){
        int flg=1;
        for(int j=0;j<N;j++){
            if(!flg) break;

            int person; //jが正直ものなら1,真偽不明なら0
            if(i&(1<<j)) person=1;
            else person=0;

            for(int k=0;k<N;k++){
                if((i&(1<<k))==0) continue;
                
                if(Map[k][j]!=person){
                    if(Map[k][j]!=-1){
                        flg=0;
                        break;
                    }
                }
            }
        }
        if(flg) ans=MAX(ans,__builtin_popcount(i));
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<sstream>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s, t;
    cin >> s >> t;
    ll a = s.size(), b = t.size();
    vector<vector<ll>> dp(a+1, vector<ll>(b+1, 0));
    rep(i, a) {
        rep(j, b) {
            if (s[i] == t[j])
                dp[i+1][j+1] = dp[i][j] + 1;
            else
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        }
    }
    ll lcs = dp[a][b];
    stringstream ss;
    while (lcs > 0) {
        if (dp[a][b] == dp[a][b-1])
            b--;
        else if (dp[a][b] == dp[a-1][b])
            a--;
        else {
            ss << s[a-1];
            a--;
            b--;
            lcs--;
        }

    }
    string ans = ss.str();
    reverse(ans.begin(), ans.end());
    cout << ans << endl; 
    return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1000003;
int fac[mod];
void init(){
	fac[0]=1;
	for(int i=1;i<mod;++i)
		fac[i]=fac[i-1]*i%mod;
}
int Fac(int n){
	if(n>=mod) return 0;
	return fac[n];
}
int ksm(int b,int n){
	int res=1;
	while(n){
		if(n&1) res=res*b%mod;
		b=b*b%mod; n>>=1;
	}
	return res;
}
signed main(){
	init();
	int Q,x,d,n;
	cin>>Q;
	while(Q--){
		cin>>x>>d>>n;
		if(d==0){
			cout<<ksm(x,n)<<endl;
			continue;
		}
		x=x*ksm(d,mod-2)%mod;
	//	cout<<x<<endl;
		int a=Fac(x-1),b=Fac(x+n-1);
		b*=ksm(a,mod-2);b%=mod;
		b*=ksm(d,n);b%=mod;
		cout<<b<<endl;
	}
	return 0;
}

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

int main(){
  int n,k; cin >>n >>k; vector<int>v(n,1); int sum=0;
  for(int i=0; i<k; i++)
  {
    int t; cin >>t;
    for(int j=0; j<t; j++)
    {int s; cin >>s; v[s-1]=0;}
  }
  for(int i=0; i<n; i++) sum+=v[i]; 
  cout <<sum;
return 0;}

Measured memory_bytes: 3640
from heapq import heapify, heappush, heappop

k, t = map(int, input().split())
*a, = (-int(x) for x in input().split())

heapify(a)

eaten = 0
while a:
    to_eat = heappop(a)
    to_eat += 1
    if eaten:
        heappush(a, eaten)
        eaten = 0
    if to_eat == 0:
        continue
    elif to_eat < 0:
        eaten = to_eat

print(-eaten)


Measured memory_bytes: 3060
using System;
using System.Numerics;
using System.Text;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        Console.WriteLine(Parse(sc.Next()) / Parse(sc.Next()));
    }

    public BigInteger Parse(string s)
    {
        BigInteger result = 0;
        StringBuilder sb = new StringBuilder();
        int minus = s[0] == '-' ? 1 : 0;

        for (int i = minus; i < s.Length; i++)
        {
            sb.Append(s[i]);
            if ((i + 1) % 18 == minus)
            {
                result *= (long) 1e18;
                result += long.Parse(sb.ToString());
                sb = new StringBuilder();
            }
        }

        result *= (long) Math.Pow(10, sb.Length);
        result += long.Parse(sb.ToString());
        return minus == 1 ? -result : result;
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


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

using namespace std;

void rotate(int *x, int *y, int n)
{
    for (int i = 0; i < n; i++){
        int nx = -y[i], ny = x[i];
        x[i] = nx;
        y[i] = ny;
    }
}

bool check(int *x, int *y, int *x2, int *y2, int n)
{
    for (int i = 0; i < n - 1; i++){
        if (x[i + 1] - x[i] != x2[i + 1] - x2[i]) return (false);
        if (y[i + 1] - y[i] != y2[i + 1] - y2[i]) return (false);
    }
    
    return (true);
}

int main()
{
    int n;
    
    while (scanf("%d", &n) && n){
        int m;
        int x[64], y[64];
        
        scanf("%d", &m);
        for (int i = 0; i < m; i++){
            scanf("%d %d", x + i, y + i);
            if (i){
                x[i] -= x[0];
                y[i] -= y[0];
            }
        }
        x[0] = y[0] = 0;
        
        for (int T = 1; T <= n; T++){
            int ms;
            int xs[64], ys[64];
            
            scanf("%d", &ms);
            
            for (int i = 0; i < ms; i++){
                scanf("%d %d", xs + i, ys + i);
                if (i){
                    xs[i] -= xs[0];
                    ys[i] -= ys[0];
                }
            }
            xs[0] = ys[0] = 0;
            
            bool ok = false;
            
            if (ms == m){
                for (int i = 0; i < 4; i++){
                    ok |= check(x, y, xs, ys, m);
                    
                    reverse(xs, xs + ms);
                    reverse(ys, ys + ms);
                    ok |= check(x, y, xs, ys, m);
                    
                    reverse(xs, xs + ms);
                    reverse(ys, ys + ms);
                    rotate(xs, ys, ms);
                }
            }
            
            if (ok){
                printf("%d\n", T);
            }
        }
        
        printf("+++++\n");
    }
    
    return (0);
}

Measured memory_bytes: 1196
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <iostream>
using namespace std;
typedef long long LL;
typedef double DB;
const int Max = 1e5;
const int MOD = 1e9 + 7;


char a[10], ans[100];
LL n, m, num[100005];
int sum;

void dfs(int y, int b)
{
	int x = y;
	x = y + (int)(a[b] - '0');
	ans[b * 2 - 1] = a[b];
	ans[b * 2 - 2] = '+';
	if(b == 4)
	{
		if(x == 7) {
			for(int i = 1; i <= 7; i++) printf("%c", ans[i]);
			printf("=7");
			printf("\n");
			exit(0);
		}
	}
	if(b != 4)
	dfs(x, b + 1);
	x = y - (int)(a[b] - '0');
	ans[b * 2 - 1] = a[b];
	ans[b * 2 - 2] = '-';
	if(b == 4)
	{
		if(x == 7) {
			for(int i = 1; i <= 7; i++) printf("%c", ans[i]);
			printf("=7");
			printf("\n");
			exit(0);
		}
		return;
	}
	dfs(x, b + 1);

}
int main()
{
	scanf("%s", a + 1);
	ans[1] = a[1];
	sum = (a[1] - '0');
	dfs(sum, 2);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////
int main()
{ll x;
	cin>>x;
	ll A =100;
	ll t =0;
	while(A<x)
	{	A+= A*0.01;
		t++;

	}
	cout<<t;
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll> v;
	rep(i,0,n){
		ll a;
		cin>>a;
		v.pb(a);
	}
	sort(all(v));
	ll a;
	ll a1,a2;
	ll b = v[v.sz-1];
	if(b%2==0){
		a1 = b/2;
		a2 = b/2;
	}
	else{
		a1 = b/2;
		a2 = b/2+1;
	}
	ll mn = 2000000000;
	rep(i,0,v.sz-1){
		ll b1 = abs(v[i]-a1);
		ll b2 = abs(v[i]-a2);
		ll mn1 = min(b1,b2);
		if(mn>=mn1){
			mn = mn1;
			a = v[i];
		}
	}
	cout << b << " " << a << endl;
	return 0;
}

Measured memory_bytes: 1400
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        a: [Chars; h],
    }
    let mut row = vec![false; h];
    let mut col = vec![false; w];
    for i in 0..h {
        for j in 0..w {
            if a[i][j] == '#' {
                row[i] = true;
                col[j] = true;
            }
        }
    }
    for i in 0..h {
        if row[i] {
            let mut print = String::new();
            for j in 0..w {
                if col[j] {
                    print.push(a[i][j]);
                }
            }
            println!("{}", print);
        }
    }
}


Measured memory_bytes: 2240
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 2000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
char st[MN+5][MN+5];
int n,m,Q,s[MN+5][MN+5],a[MN+5][MN+5],b[MN+5][MN+5];
inline int C(int S[][MN+5],int u,int d,int l,int r){return S[d][r]-S[u-1][r]-S[d][l-1]+S[u-1][l-1];}
int main()
{
	n=read();m=read();Q=read();
	for(int i=1;i<=n;++i) scanf("%s",st[i]+1);
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) 
		s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(st[i][j]=='1'),
		a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+(st[i][j]=='1'&&st[i][j-1]=='1'),
		b[i][j]=b[i-1][j]+b[i][j-1]-b[i-1][j-1]+(st[i][j]=='1'&&st[i-1][j]=='1');
	for(int i=1;i<=Q;++i)
	{
		int X1=read(),Y1=read(),X2=read(),Y2=read();
		printf("%d\n",C(s,X1,X2,Y1,Y2)-C(a,X1,X2,Y1+1,Y2)-C(b,X1+1,X2,Y1,Y2));	
	}
	return 0;
}



Measured memory_bytes: 52864
/*in the name of Allah the most beneficent the most merciful.*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
// #define MOD 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define out(x) cout << #x << " -> " << x << endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
using namespace std;
const ll B = 20, N = 300010, M = 2000000;
ll n, a, b;
int solve()
{
    cin>>n>>a>>b;
    ll m = n%(a+b);
    ll res = (n/(a+b))*a;
    res+=min(a, m);
    printf("%lld\n", res);
    return 0;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    return solve();
}

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

int main(){
  int n,h[101],ans=0;
  
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> h[i];
  }
  h[0]=0;
  for(int i=1;i<=n;i++){
    if(h[i]>h[i-1]){
      ans+=h[i]-h[i-1];
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
/* Be your own light */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

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

    ll r;
    cin>>r;
    double d = 2* 3.141592653*r;
    printf("%.9f", d);
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>

using namespace std;

vector<vector<vector<int>>> moves{{
                                          {-1, 0}, {-1, -1},
                                          {0, -1}, {0, 1},
                                          {1, 0}, {1, -1}
                                  },
                                  {
                                          {-1, 0}, {-1, 1},
                                          {0, -1}, {0, 1},
                                          {1, 0}, {1, 1}
                                  }};
int w, h;
vector<vector<bool>> ban;
vector<vector<bool>> visited;

bool inRange(int x, int y) {
    return 0 <= x && x <= h + 1 && 0 <= y && y <= w + 1;
}

void dfs(int x, int y) {
    visited[x][y] = true;
    for (auto move:moves[x % 2]) {
        int nx = x + move[0];
        int ny = y + move[1];
        if (inRange(nx, ny) && !ban[nx][ny] && !visited[nx][ny]) {
            dfs(nx, ny);
        }
    }
}

int main() {
    cin >> w >> h;
    ban = vector<vector<bool>>(h + 2, vector<bool>(w + 2));
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            int tmp;
            cin >> tmp;
            ban[i][j] = tmp == 1;
        }
    }

    visited = vector<vector<bool>>(h + 2, vector<bool>(w + 2));
    dfs(0, 0);

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (!ban[i][j] && !visited[i][j])ban[i][j] = true;
        }
    }

    int ret = 0;
    for (int i = 0; i <= h + 1; i++) {
        for (int j = 0; j <= w + 1; j++) {
            for (auto move:moves[i % 2]) {
                int x = i + move[0];
                int y = j + move[1];

                if (inRange(x, y) && ban[i][j] != ban[x][y])ret++;
            }
        }
    }

    cout << ret / 2 << endl;
    return 0;
}


Measured memory_bytes: 3860
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    string s;
    cin >> s;
    int a[4];
    rep(i,4) {
        a[i] = s[i]-'0';
    }

    // (1<<n) == 2^n;
    // 外側で列挙，内側で各ビットをひとつずつみる
    for (int bit = 0; bit < (1<<3); bit++)
    {
        string s = "---";
        int res = a[0]; // A
        for (int i = 0; i < 3; i++)
        {
            if (bit & (1<<i)) {
                res += a[i+1];
                s[i] = '+';
            } else {
                res -= a[i+1];
                s[i] = '-';
            }
        }
        if (res == 7) {
            rep(i,3) {
                cout << a[i] << s[i];
            }
            cout << a[3] << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////


int main(){
    int n;
    cin>>n;
    vp xl(n);
    rep(i,n){
        int x,l;
        cin>>x>>l;
        xl[i].first=x+l;
        xl[i].second=x-l;
    }
    sort(all(xl));
    int fm=-INF,num=0;
    rep(i,n){
        if(xl[i].second<fm)num++;
        else fm=xl[i].first;
    }
    cout<<n-num<<endl;

    return 0;
}

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

#define N 100000

set<int> similarTo2017Number;

void set_similar_to_2017(int n){
    for (int i = 3; i <= n; i=i+2){
        bool isSimilar = true;
        for (int j = 2; j <= sqrt(i); j++){
            if(i % j == 0){
                isSimilar = false;
                break;
            }
            if( ((i+1)/2) % j == 0 ){
                isSimilar = false;
                break;
            } 
        }
        if (isSimilar){
            similarTo2017Number.insert(i);
        }
    }
}

int main() {
    vector<int> nSimilarTo2017(N+1,0);
    set_similar_to_2017(N);
    for (auto itr = similarTo2017Number.begin(); itr != similarTo2017Number.end(); itr++){
        nSimilarTo2017[(*itr)] = 1;
    }
    for (int i = 1; i <= N; i++){
        nSimilarTo2017[i] += nSimilarTo2017[i-1];
    }
    
    // 入力
    int q;
    cin >> q;

    for (int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        cout << nSimilarTo2017[r] - nSimilarTo2017[l-1] << endl;
    }

    return 0;
}


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


	int main() {
		int N,i,col=0;
		string s;
		cin >> N;
		for (i = 0; i < N; ++i) {
			cin >> s;
			if (s=="Y") {
				col = 1;
				break;
			}
		}
		if (col==1) {
			cout << "Four" << endl;
		}
		else cout << "Three" << endl;
	}

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

bool selected[101];

int main(){
  int n; cin >> n;
  vector<int> score(n);
  for(int i = 0; i < n; ++i) {
    int tmp; cin >> tmp;
	score.push_back(tmp);
  }
  sort(score.rbegin(), score.rend());
  int ans = 0;
  for(int i = 0; i < n; ++i)selected[i] = false;
  for(int i = 0; i < 101; ++i){
  	for(int j = 0; j < n; ++j){
      if(selected[j] == false && (ans + score[j]) % 10 != 0){
        ans += score[j];
        selected[j] = true;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0; 
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int dir = 0;
string s;

int main(){
    cin >> s;
    ll ans = 0;
    ll st = 0;
    rep(i,s.size()){
        if(s[i] == 'R'){
            if(st == dir){
                st = (st+1)%4;
                if(dir == 3)ans++;
            }
            dir = (dir+1)%4;
        }
        else{
            dir = (dir-1+4) % 4;
            if(dir == 0)st = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3208
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t h1,m1,h2,m2,k;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> h1 >> m1 >> h2 >> m2 >> k;
    auto ss = h1 * 60 + m1;
    auto ff = h2 * 60 + m2;
    out << ff - ss - k << endl;

    return 0;
}
#endif


Measured memory_bytes: 3160
#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    
    int R[n];
    
    for(int i=0;i<n;i++)
        scanf("%d",&R[i]);
    
    int max,min;
    max=R[1]-R[0];
    min=R[0];
    for(int i=1;i<n;i++)
    {
        if(max<R[i]-min)max=R[i]-min;
        if(min>R[i])min=R[i];
    }
    
    printf("%d\n",max);
    return 0;
}



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


ll mod = 1e9+7;

ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){ans = ans*base;}
        base *= base;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}

int arr[123456];


int main(){
    //freopen("ip.txt", "rt", stdin);
    //freopen("op.txt", "wt", stdout);
    int n;
    cin >> n;
    set <int> se;
    while(n--){
         int n1;
         cin >> n1;
         if(se.count(n1)) se.erase(se.find(n1));
         else se.insert(n1);
    }
    cout << se.size();
}


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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n, m;

int main()
{
	IOS;
	cin >> n >> m;
	int x, y, l = 0, r = n;
	while (m--) {
		cin >> x >> y;
		l = max(x, l), r = min(y, r);
	}
	cout << max(0, r - l + 1) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<int> Car;
    int Size = 0;
    int number;
    vector<int> Order;

    while(cin >> number)
    {

            if(number != 0)
            {
                Car.push_back(number);
            }
            else if(number == 0)
            {

                Order.push_back(Car[(Car.size())-1]);
                Car.pop_back();

            }




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

Measured memory_bytes: 1216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int L = int.Parse(input[1]);

        List<int> ap = new List<int>(N);
        for (int i = 0; i < N; i++)
        {
            ap.Add (L + i);
        }
        ap.Sort((a, b) => Math.Abs(a) - Math.Abs(b));
        ap.RemoveAt(0);
        
        Console.WriteLine(ap.Sum());
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  
  cin >> a >> b >> c;

  if (b - c >= 0) anss = "delicious";
  else if (a+b-c >= 0) anss = "safe";
  else anss = "dangerous";
  
  cout << anss << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int count;
	int point[200][2/*x,y*/];

	int n,d;

	while(1) {
		scanf( "%d", &count );
		if ( count == 0 ) { break; }

		point[0][0]=0;
		point[0][1]=0;
		for ( int i=1; i<count; i++ ) {
			scanf("%d %d", &n, &d);

			switch ( d ) {
			case 0: //left
				point[i][0] = point[n][0]-1;
				point[i][1] = point[n][1];
				break;
			case 1: //down
				point[i][0] = point[n][0];
				point[i][1] = point[n][1]-1;
				break;
			case 2: //right
				point[i][0] = point[n][0]+1;
				point[i][1] = point[n][1];
				break;
			case 3: //up
				point[i][0] = point[n][0];
				point[i][1] = point[n][1]+1;
				break;
			}
		}

		int xmin,xmax,ymin,ymax;
		xmin=0, xmax=0, ymin=0, ymax=0;
		for (int i=0; i<count; i++ ) {
			if ( xmax < point[i][0] ) { xmax = point[i][0]; }
			if ( xmin > point[i][0] ) { xmin = point[i][0]; }
			if ( ymax < point[i][1] ) { ymax = point[i][1]; }
			if ( ymin > point[i][1] ) { ymin = point[i][1]; }
		}
		
		printf("%d %d\n", xmax-xmin+1, ymax-ymin+1);
	}
	
	return 0;
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val N = nextLong()
    var ans = 0
    divisor(N).drop(1).forEach { x ->
        var w = N
        while (w % x == 0L) w /= x
        if (w % x == 1L) ans += 1
    }
    ans += divisor(N - 1).drop(1).size
    println(ans)
}

fun divisor(value: Long) =
    (1 .. Math.sqrt(value.toDouble()).toLong())
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .distinct()
        .sorted()


fun next() = readLine()!!
fun nextLong() = next().toLong()



Measured memory_bytes: 48504
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    string s;
    int ans = 700;
    
    cin >> s;
    
    if(s[0] == 'o') { ans += 100; }
    if(s[1] == 'o') { ans += 100; }
    if(s[2] == 'o') { ans += 100; }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256