akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second > b.second;
    }
}
bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}

const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
int main() {
    string S,T;
    cin>>S>>T;
    
    ll SN = S.size();
    ll TN = T.size();
    string CS = S;
    vector<string> ans;
    rep(i,SN -TN+1){
        S=CS;
        rep(j,TN){
            if(S[i+j] != T[j] && S[i+j]!='?'){
                break;
            }else{
                S[i+j] = T[j];
            }
            if(j==TN-1){
                ans.pb(S);
            }
        }
    }

    if(ans.size() != 0){
        rep(i,ans.size()){
            rep(j,SN){
                if(ans[i][j] == '?'){
                    ans[i][j] = 'a';
                }
            }
        }
        sort(all(ans));
        cout<<ans[0]<<endl;
    }else{
        cout<<"UNRESTORABLE"<<endl;
    }
    return 0;
    

}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int n;
long long int a[100001];
long long int dp[100001];
int main(void){
    // Your code here!
    int i;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        dp[i] = 1000010000;
    }
    for(i=0;i<n;i++){
        auto it = lower_bound(dp,dp+n,a[i]);
        *it = a[i];
    }
    /*for(i=0;i<n;i++){
        cout << dp[i];
    }*/
    int ans = lower_bound(dp,dp+n,1000010000) - dp;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4648
import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner cin = new Scanner(new BufferedInputStream(System.in));

        int n ;
        while(cin.hasNext())
        {
            n = cin.nextInt();
            int a[] = new int[10];

            while(n>0)
            {
                for(int i=0; i<10; ++i)
                {
                    a[i] = cin.nextInt();
                }
                int l, r;
                l = r =0;
                boolean ans = true;
                for(int i=0; i<10; ++i)
                {
                    if(a[i] > l)
                    {
                        l = a[i];
                    }else if(a[i] > r)
                    {
                        r = a[i];
                    }else {
                        ans = false;
                        break;
                    }
                }
                System.out.format("%s\n", ans?"YES":"NO");
                n--;
            }
        }

    }
}



Measured memory_bytes: 26356
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << ", ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << " ]" ;
}

#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
#define sz(a) (ll)(a).size()
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

void solve(){
    ll x;
    cin >> x;
    if(x >= 30){
        print("Yes");
    }
    else print("No");
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    #ifndef ONLINE_JUDGE
        end_routine();
    #endif
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <math.h>
int main() {
  int N;
  int M;

  scanf("%d %d", &N, &M);
  int s[M];
  int c[M];
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &s[i], &c[i]);
  }
  // check1
  int a = 0;

  for (int i = 0; i < M; i++) {
    if (s[i] == 1 && c[i] == 0) {
      if (N >= 2) {
        a = -1;
        break;
      }
    }
    for (int j = 0; j < M; j++) {

      if (s[i] == s[j]) {
        if (i < j) {
          s[j] = 0;
        }
        if (i > j) {
          s[i] = 0;
        }

        if (c[i] != c[j]) {
          a = -1;
          break;
        }
      }
    }
  }
  int ans = 0;

  for (int i = 0; i < M; i++) {

    for (int j = 1; j < 10; j++) {

      if (s[i] == j) {
        ans += c[i] * pow(10, N - (j - 1) - 1);

        continue;
      }
    }
  }
  if (N >= 2) {
    if (ans < pow(10, N - 1)) {
      ans += pow(10, N - 1);
    }
  }
  if (a == -1) {
    printf("-1\n");
  } else {
    printf("%d\n", ans);
  }
}


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

int main(){
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<int> a(n),b(m);
    int ma = -10000;
    int mi = 10e4;
    for(int i=0;i<n;i++){
        cin >> a.at(i);
        ma = max(a.at(i),ma);
    }
    for(int i=0;i<m;i++){
        cin >> b.at(i);
        mi = min (b.at(i),mi);
    }
    bool ans = true;
    for(int i=x+1;i<=y;i++){
        if(x<i&& x<=y&&ma<i&&mi>=i ){
            cout << "No War" << endl;
            ans = false;
            break;
        }
    }
    if(ans){
        cout <<"War" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> PL;
typedef long double ldouble;

int n, m, q;
vector <int> E[100010];
int Q[100010][3];

int D[100010];
int color[100010];

void dfs(int v, int d, int c){
	if(D[v] >= d)return;
	D[v] = d;
	if(color[v] == 0)color[v] = c;
	if(d == 0)return;
	for(int e : E[v]){
		dfs(e, d-1, c);
	}
}

void solve(){
	scanf("%d%d", &n, &m);
	rep(i, m){
		int x, y; scanf("%d%d", &x, &y);
		E[x].pb(y);
		E[y].pb(x);
	}
	scanf("%d", &q);
	rep(i, q){
		rep(j, 3)scanf("%d", Q[i]+j);
	}
	for(int i=1;i<=n;i++)D[i] = -1;
	for(int i=q-1;i>=0;i--){
		int v = Q[i][0], d = Q[i][1], c = Q[i][2];
		dfs(v, d, c);
	}
	
	for(int i=1;i<=n;i++)printf("%d\n", color[i]);
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
}

Measured memory_bytes: 8440
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int n, k, a[MAXN];

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	scanf("%d%d", &n, &k);
	for (int i=0; i<n; i++) scanf("%d", &a[i]);
	
	ll ans = 0;
	if (a[0] > k) {
		ans += a[0] - k;
		a[0] = k;
	}
	for (int i=1; i<n; i++) {
		if (a[i] + a[i - 1] > k) {
			int dif = a[i] + a[i - 1] - k;
			a[i] -= dif;
			ans += (ll) dif;
		}
	}
	
	cout << ans << endl;


}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
using ppa = pair<pa, int>;
#define SORT(v, n) sort(v, v + n);
#define ALL(v) v.begin(), v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v), greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)), v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define rrep(i, n) RFOR(i, 0, n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a, b) a = min(a, b)
#define maxs(a, b) a = max(a, b)

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

// 8近傍
// int dy[]={0,0,1,-1,1,1,-1,-1};
// int dx[]={1,-1,0,0,1,-1,1,-1};

// const ll MOD = 1000000007;

ll pow_mod(ll a, ll b, ll mod) {
    ll tmp = 1;
    a %= mod;
    if (b > 0) {
        tmp = pow_mod(a, b / 2, mod);
        if (b % 2)
            tmp = (((tmp * tmp) % mod) * a) % mod;
        else
            tmp = (tmp * tmp) % mod;
    }
    return tmp;
}

void solve() {
    int k,t; cin >> k >> t;
    vector<int> a(t);
    rep(i,t) cin >> a[i];
    GRESORT(a);
    rep(i,t){
        a[i+1] = abs(a[i+1]-a[i]);
    }
    int ans = a[t-1] - 1;
    cout << (ans == -1 ? 0 : ans) << endl;
}

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

    solve();

    return 0;
}


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

struct Edge
{
    int to;
};
using Graph = vector<vector<Edge>>;

vector<bool> seen;  // 訪問済みかどうか
void dfs(const Graph &G, int v)
{
    seen[v] = true;
    for(auto e: G[v])
    {
        // 訪問済みでなければ探索する
        if(!seen[e.to])
        {
            dfs(G, e.to);
        }
    }
}

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

    Graph G(N);
    for(int i=0; i<M; i++)
    {
        int a,b;
        cin >> a >> b;
        G[a-1].push_back({b-1});
        G[b-1].push_back({a-1});
    }

    seen.assign(N, false);
    int count = 0;
    for(int i=0; i<N; i++)
    {
        if(!seen[i])
        {
            dfs(G,i);
            count += 1;
        }
    }

    cout << count-1 << endl;
    return 0;
}

Measured memory_bytes: 9568
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;

void solve() {
	ll n; cin >>n;
	rep(i,0,n) cout << "ACL";
}

int main(int argc, char * argv[]) 
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:/Users/Fish_Brother/Desktop/in", "r", stdin);
	//freopen("C:/Users/Fish_Brother/Desktop/out", "w", stdout);
#endif

	//int t; cin >> t; while(t--)
	solve();

    return 0;
}

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

int main()
{
	int x;
	cin >> x;
	vector<bool> ex(x + 1);
	ex[1] = true;
	for (int i = 2; i < x; i++) {
		int a = i*i;
		
		while (a <= x) {
			ex[a] = true;
			a *= i;
		}
	}
	for (int i = x; i >= 1; i--) {
		if (ex[i]) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
long long l[100];
long long hoge(long long x)
{
    if (x == 1) {
        return 1;
    } else if (x == 0) {
        return 2;
    }
    if (l[x] == 0) {
        l[x] = hoge(x - 1) + hoge(x - 2);
    }
    return l[x];
}
long long N;
signed main()
{
    scanf("%lld", &N);
    printf("%lld\n", hoge(N));
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
  int c, d, n;
  bool b = false;
int main()
{
  cin >> n;
  for(int i = 0; i < 26; i++){
    for(int j = 0; j< 14; j++){
      if(4*i + 7*j == n) b = true;
    }  
  }
  if (b) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}

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

int N;
struct point{
	vector<int> dest;
	vector<int> dist;
	int color;
};
/*場所にアクセスするときはマイナス１*/
void dfs(int x, vector<point>& mass){
	for(int i = 0; i < mass.at(x-1).dest.size(); i++){
		int destination = mass.at(x-1).dest.at(i);
		int distance = mass.at(x-1).dist.at(i);
		if(mass.at(destination-1).color != -1) continue;
		if(distance%2 == 0) mass.at(destination-1).color = mass.at(x-1).color;
		if(distance%2 != 0) mass.at(destination-1).color = abs(mass.at(x-1).color-1);
		dfs(destination, mass);
	}
}

int main(){
	cin >>N;
	vector<point> mass(N);
	for(int i=0; i<N-1; i++){
		int a, b, c;
		cin >> a >> b >> c;
		mass.at(a-1).color = -1; //行は１小さい数になっている
		mass.at(a-1).dest.push_back(b);
		mass.at(a-1).dist.push_back(c);
		mass.at(b-1).color = -1;
		mass.at(b-1).dest.push_back(a);
		mass.at(b-1).dist.push_back(c);
	}
	mass.at(0).color = 1;
	dfs(1, mass);
	for(int i = 0; i < N; i++){
		cout << mass.at(i).color << endl;
	}
}


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

using namespace std;

int main()
{
  int n;
  double ans[4];

  scanf("%d", &n);

  int x[n], y[n];

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

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

  //p=1
  for (int j = 0; j < 3; j++)
  {
    for (int i = 0; i < n; i++)
    {
      ans[j] += pow(fabs(x[i] - y[i]), j + 1);
    }
    ans[j] = pow(ans[j], 1.0 / (j + 1));
  }

  for (int i = 0; i < n; i++)
  {
    if (ans[3] < fabs(x[i] - y[i]))
    {
      ans[3] = fabs(x[i] - y[i]);
    }
  }

  for (int i = 0; i < 4; i++)
  {
    printf("%lf\n", ans[i]);
  }
}


Measured memory_bytes: 3376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    string s, t;
    cin >> s;
    rep (i, 0, s.size()) {
        if (s[i] == 'x') continue;
        t += s[i];
    }
    rep (i, 0, t.size()) {
        if (t[i] != t[t.size() - 1 - i]) {
            cout << -1 << "\n";
            return 0;
        }
    }
    int nl = 0, nr = s.size() - 1;
    int ans = 0;
    while (nl < nr) {
        int cntl = 0, cntr = 0;
        while (s[nl] == 'x') {
            nl++;
            cntl++;
        }
        while (s[nr] == 'x') {
            nr--;
            cntr++;
        }
        // cout << nl << " " << nr << "\n";
        // cout << cntl << " " << cntr << "\n";
        nl++, nr--;
        ans += abs (cntr - cntl);
    }
    cout << ans << "\n";
}

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

void solve()
{
    int n,k;
    scanf("%d %d",&n,&k);
    vector<int>a;
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        a.push_back(x);
    }
    int sum=0;
    sort(a.begin(),a.end());
    for(int i=0;i<k;i++)
    {
        sum+=a[i];
    }
    printf("%d",sum);
}
int main()
{
    solve();
}



Measured memory_bytes: 3792
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=0;i<=a;i++){
		if(2*i+4*(a-i)==b){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3596
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("C:\\Users\\BOG\\Desktop\\path.txt");ofstream out("C:\\Users\\BOG\\Desktop\\crd.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    ll a; cin>>a;
    if(a%2){
        cout<<0;
        return 0;
    }
    ll o =0, cur = 5;
    for(; cur<=a; cur*=5){
        o += a/(cur*2);
    }
    cout<<o;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<functional>
#include<list>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<string.h>
#include<limits.h>
using namespace std;

string x[10001];
string y[10001];
signed main() {
	int b;
	cin >> b;
	for (int c = 0; c < b; c++) {
		string d; cin >> d;
		string e, f;
		for (char g : d) {
			if (g == '?') {
				e += 'a';
				f += 'z';
			}
			else {
				e += g;
				f += g;
			}
		}
		x[c] = e;
		y[c] = f;
	}
	string S; cin >> S;
	x[b] = y[b] = S;
	sort(x, x + b + 1);
	sort(y, y + b + 1);
	bool K = false;
	vector<int>V;
	for (int i = 0; i <= b; i++) {
		if (y[i] == S) {
			K = true;
		}
		if (K)V.push_back(i + 1);
		if (x[i] == S) {
			K = false;
		}
	}
	for (int i = 0; i< V.size(); i++) {
		if (i)cout << " ";
		cout << V[i];
	}
	puts("");
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    string c;
    priority_queue<string,vector<string>,greater<string> >q;
    for(int i=0;i<a;i++){
        cin>>c;
        q.push(c);
    }
    while(q.size()>0){
        string b;
		b=q.top();
        cout<<b;
        q.pop();
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

vector<int> v;

void dfs(int l, int r, int depth, string s){

    if(depth == v.size()){
        if(l == r){
            cout << s << endl;
        }
        return ;
    }

    dfs(l + v[depth], r, depth + 1, s + "+");

    dfs(l, r, depth + 1, s + "0");

    dfs(l, r + v[depth], depth + 1, s + "-");

    return ;
}


int main(){
    int w; cin>>w;
    int num = 1;
    int sum = 0;
    while(sum < w){
        v.emplace_back(num);
        sum += num;
        num *= 3;
    }

    sort(v.begin(), v.end(), greater<int>());

    dfs(0, w, 0, "");
}


Measured memory_bytes: 3200
M=998244353;n,A,B,K=map(int,input().split());F=[1];a=0
for i in range(n):F+=[F[-1]*(n-i)*pow(i+1,M-2,M)%M]
for i in range(n+1):
 r=K-i*A
 if r%B==0and 0<=r//B<=n:a+=F[i]*F[r//B]
print(a%M)

Measured memory_bytes: 73500
def mp(h, w) :
	for i in range(h):
		for j in range(w):
			if ( (i+j) % 2 == 0):
				print("#", end = '')
			else:
				print('.', end = '')
		print()
	print()




while True:
	h, w = map(int, input().split())
	if h == 0 and w == 0 : break
	mp(h, w)


Measured memory_bytes: 7004
#include<iostream>
#include<stdio.h>
using namespace std;

int bubble(int A[], int n)
{
	int sw=0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main()
{
	int i, n, A[100],sw;

	scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%d", &A[i]);

	sw = bubble(A, n);

	for (i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl << sw << endl;

	
}


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

using namespace std;
#define ll long long
#define ld long double

ll binPow(ll a, ll b) {
    ll ans = 1;
    while(b > 0) {
        if(b & 1) ans *= a;
        a *= a;
        b >>= 1;
    }
    return ans;
}

ll binPowMod(ll a, ll b, ll m) {
    ll ans = 1;
    a %= m;
    while(b > 0) {
        if(b & 1) ans *= a % m;
        a *= a % m;
        b >>= 1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int k, x;
    cin >> k >> x;
    if(500 * k >= x) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
s=input()
x=0
if s[0]=="A" and s[1]!="C" and s[-1]!="C":
    for i in range(len(s)):
        if s.count("C")==1:
            if s[i].isupper():
                x+=1
        else:
            print("WA")
            exit()
    if x==2:
        print("AC")
    else:
        print("WA")

else:
    print("WA")

Measured memory_bytes: 3060
#include "iostream"
using namespace std;

int main(){
  
  int A,B;
  
  cin >> A >> B;
  
  if(A<=5){
    
    cout << 0;
  
  }else  if(A<=12){
    
    cout <<B/2;
        
  }else{
    
    cout <<B;
    
  }


	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def solve(N, K, A_list):
    A_list = list(sorted(A_list))
    if max(A_list) < K:
        return False

    if K in A_list:
        return True

    x = A_list[0]
    min_d = INF
    for a in A_list:
        min_d = min(min_d, gcd(a, x))

    for a in A_list:
        if a > K and (a - K) % min_d == 0:
            return True
    return False


def main():
    N, K = map(int, input().split())
    A_list = list(map(int, input().split()))

    print("POSSIBLE" if solve(N, K, A_list) else "IMPOSSIBLE")


if __name__ == '__main__':
    main()

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


def loop(i):
    j = (10 * i) % K
    if dp[i] < dp[j-1] + 1 and dp[i] < dp[j]:
        dp[j] = dp[i]
        return j, True
    if dp[j-1] + 1 < dp[i] and dp[j-1] + 1 < dp[j]:
        dp[j] = dp[j-1] + 1
        return j, True
    return j, False


K = int(input())

dp = [K + 1 for _ in range(K)]

dp[1] = 1
for i in range(1, K):
    if i == 1:
        pass
    else:
        dp[i] = min(dp[i-1] + 1, dp[i])
    l = i
    while True:
        l, updated = loop(l)
        if not updated:
            break

dp[0] = min(dp[K - 1] + 1, dp[0])
print(dp[0])


Measured memory_bytes: 45424
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

class DAG {
    int n;
    vvi adj;
    vi used;

public:
    vi sorted;
    DAG(int n) : n(n), adj(n), used(n) {}

    void addArc(int a, int b) {
        adj[a].push_back(b);
    }
    
    void tsort() {
        function<void(int)> dfs = [&](int v) {
            if (used[v]) return;
            used[v] = 1;
            for (int s: adj[v]) {
                dfs(s);
            }
            sorted.push_back(v);
        };
        for (int i = 0; i < n; i++) {
            dfs(i);
        }
        reverse(sorted.begin(), sorted.end());
    }
};

int main() {
    int v, e;
    cin >> v >> e;
    DAG g(v);
    for (int i = 0; i < e; i++) {
        int a, b;
        cin >> a >> b;
        g.addArc(a, b);
    }
    g.tsort();
    for (int v: g.sorted) {
        cout << v << endl;
    }
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

struct Bitree {
	typedef int btT;
	vector<btT> bv;
	Bitree() : bv(100) {}
	Bitree(int n) : bv(n + 3) {}
	btT sum(int i) {
		btT res=0; for(i++; i>0; i -= i & -i) res += bv[i]; return res;
	}
	btT sum(int a, int b) {return sum(b) - (a? sum(a-1): 0);}
	void add(int i, btT x){for(i++; i<(int)bv.size(); i += i & -i) bv[i] += x; }
	void updt(int i, btT x){ add(i, x - sum(i,i));} //replace, update
};

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, q;
	cin >>n >>q;
	VI c(n);
	rep(i, n) cin >>c[i];
	vector<vector<pii>> qy(n);
	rep(i, q){
		int l, r; cin >>l >>r;
		qy[l-1].emplace_back(r-1, i);
	}
	
	VI ks(n+1, -1), ans(q); vector<VI> dt(n+1);
	rep(i, n){
		if(ks[c[i]] !=-1) dt[ks[c[i]]].push_back(i);
		ks[c[i]] =i;
	}
	Bitree bt(n+2);
	repr(s, n-1, 0){
		for(auto x: dt[s]) bt.add(x, 1);
		for(auto [r, gy]: qy[s]){
			ans[gy] = (r-s+1) - bt.sum(r);
		}
	}
	
	rep(i, q) cout <<ans[i] <<"\n";
	return 0;
}



Measured memory_bytes: 59828
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

K = intinp()
A, B = mapint_inp()

ans = False
for i in range(A, B+1):
    if i%K == 0:
        ans = True
    
if ans:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9176
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    string S, T;
    cin >> S >> T;
    int length = S.size();
    bool isCorrect = (length + 1 == T.size());

    for (int i = 0; i < length; i++) {
        if(S[i] != T[i]) isCorrect = false;
    }
    
    if (isCorrect) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

map<ll, ll> decompositPrime(ll n) {
  map<ll, ll> res;
  ll a = 2;
  while (n >= a * a) {
    if (n % a == 0) {
      n /= a;
      if (res.count(a) == 0) res[a] = 0;
      res[a]++;
    } else {
      a++;
    }
  }
  if (n > 1) {
    //   debug("n>1", n);
    if (res.count(n) == 0) res[n] = 0;
    res[n]++;
  }

  return res;
}
ll res = -1;
// sum:現在の和
// v:個数
// w:終了条件
// k:何を足したか
void dfs(ll sum, ll v, ll w, ll k) {
  debug(sum, v, w, k);
  // 数列の長さが N に達したら打ち切り
  if (sum == w) {
    // debug("max", res, sum);
    res = max(res, v);
    return;
  }
  if (sum > w) {
    return;
  }
  for (ll i = k + 1; i <= w - sum; i++) {
    dfs(sum + i, v + 1, w, i);
    // debug("dfs");
  }
}

int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n;
  cin >> n;
  map<ll, ll> bunkai = decompositPrime(n);
  ll res2 = 0;
  for (pair<ll, ll> i : bunkai) {
    debug(i.first, i.second);
    res = -1;
    dfs(0, 0, i.second, 0);
    // cout << res << endl;
    res2 += res;
    // ll temp = 0;
    // ll j;
    // debug(i.first, i.second);
    // for (j = 1; i.second >= temp; j++) {
    //   debug(j, temp);
    //   temp += j;
    // }
    // debug(j);
    // res += j;
  }
  cout << res2 << endl;

  return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int X = sc.nextInt();
            int T = sc.nextInt();
            System.out.println(((N / X) + (N % X == 0 ? 0 : 1)) * T);
        }
    }
}


Measured memory_bytes: 27084
#include <iostream>
#include <cstdint>
#include <numeric>

using namespace std;

uint32_t table[200];

uint32_t gcd(uint32_t m, uint32_t n) {
	if (m == 0)
		return n;

	uint32_t tmp = m;
	m = n % m;
	n = tmp;

	return gcd(m, n);
}

int main(int argc, char const* argv[]) {
	uint32_t K;

	cin >> K;

	for (uint32_t i = 1; i <= K; i++) {
		for (uint32_t j = i; j <= K; j++) {
			uint32_t g = gcd(i, j);
			if (i != j)
				table[g] += 2;
			else
				table[g] += 1;
		}
	}

	uint64_t cnt = 0;

	for (uint32_t i = 1; i <= K; i++) {
		for (uint32_t j = 1; j <= K; j++) {
			uint32_t tmp = gcd(i, j);
			cnt += table[j] * tmp;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
bool find_two(vector<int> v, int mode[14]) {
    for(int r = 0; r < 5; r++) {
        if(mode[v[r]] == 2) return(true);
    }
    return(false);
}
bool isSequencial(vector<int> v) {
    if((v[0]==1&&v[1]==2&&v[2]==3&&v[3]==4&&v[4]==5) || (v[0]==1&&v[1]==10&&v[2]==11&&v[3]==12&&v[4]==13)) { return(true);}
    for(int r = 1; r < 5; r++) {
        if(v[r] - 1 != v[r - 1]) return(false);
    }
    return(true);
}

int main(void) {
    vector<int> v(5);
    while(scanf("%d,%d,%d,%d,%d", &v[0], &v[1], &v[2], &v[3], &v[4]) != EOF) {
        //頻度記録
        int mode[14]; memset(mode, 0, sizeof(mode));
        int max = -1;
        for(int r = 0; r < 5; r++) {
            mode[v[r]]++; if(mode[v[r]] > max) max = mode[v[r]];
        }
        sort(v.begin(), v.end());
        if(max == 4) {
            cout << "four card" << endl;
        } else if(max == 3) {
            if(find_two(v, mode)) cout << "full house" << endl;
            else                  cout << "three card" << endl;
        } else if(isSequencial(v)) {
            cout << "straight" << endl;
        } else if(max == 2) {
            int count = 0;
            for(int r = 0; r < 14; r++) {
                if(mode[r] == 2) count++;
            }
            if(count == 2) {
                cout << "two pair" << endl;
            } else if(count == 1) {
                cout << "one pair" << endl;
            } else cout << "null" << endl;
        } else {
            cout << "null" << endl;
        }
    }
    return(0);
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    string s,t;cin>>s>>t;
    int cnt=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]==t[i])
            cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 256
#include <cctype>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cmath>
#define pk putchar(' ')
#define ph puts("")
typedef long long ll;
using namespace std;
template <class T>
void rd(T &x)
{
    x = 0;
    int f = 1;
    char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
    while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    x *= f;
}
template <class T>
void pt(T x)
{
    if (x < 0)
        putchar('-'), x = (~x) + 1;
    if (x > 9)
        pt(x / 10);
    putchar(x % 10 ^ 48);
}
int main() 
{
	char s[4];
	scanf("%s", s);
	if (s[1] == 'R')
		printf("ABC\n");
	else
		printf("ARC\n");
    return 0;
}

Measured memory_bytes: 1644
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Scanner;

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

    static class ABC081APlacingMarbles {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.println(in.next().chars().filter(i -> i > '0').count());
        }

    }
}



Measured memory_bytes: 30548
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
int d[10][10]; // 앞이 i, 뒤가 j일때 올 수 있는 개수

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		string tmp = to_string(i);
		int x = tmp[0] - '0';
		int y = tmp[tmp.size() - 1] - '0';
		d[x][y] += 1;
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		string tmp = to_string(i);
		int x = tmp[0] - '0';
		int y = tmp[tmp.size() - 1] - '0';
		if (x == 0 || y == 0)continue;
		ans += (ll)d[y][x];
	}
	cout << ans << '\n';



}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    s += 'R';
    int rc=0,lc=0;
    vector<pair<int, int>> a;
    for(int i=0; i<n; i++){
        if(s[i] == 'R') rc++;
        else{
            lc++;
            if(s[i+1] == 'R'){
                a.push_back(make_pair(rc,lc));
                rc = 0;
                lc = 0;
            }
        }
    }
    for(int i=0; i<a.size(); i++){
        int t = a[i].first + a[i].second;
        for(int j=0; j<a[i].first -1 ; j++){
            cout << 0 << ' ';
        }
        if(a[i].first % 2){
            cout << t - t/2 << ' ' << t/2 << ' ';
        }
        else cout << t/2 << ' ' << t - t/2 << ' ';
        for(int j=0; j<a[i].second -1; j++){
            cout << 0 << ' ';
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int i, n;
	i = 1;
	while (cin >> n) {
		if (n == 0) break;
		printf("Case %d: %d\n", i, n);
		++i;
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353
typedef vector<ll> vl;
typedef vector<vl> matrix;//A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Sortup(V) sort(V.begin(), V.end())
#define Sortdown(V) sort(V.rbegin(), V.rend())
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;}
void CumuSum(vl &A){rep(i,A.size())if(i)A[i]+=A[i-1];}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
ll llpowMOD(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;res%=MOD;e%=MOD;}return res;}
bool bit(ll subset, ll Rsift){ return ((subset)>>(Rsift))&1; }

ll gcd(ll A, ll B){
    if(A<B) swap(A,B);
    while(B){
        ll w = A%B;
        A = B;
        B = w;
    }
    return A;
}

ll lcm(ll A, ll B){return A/gcd(A,B)*B;}

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

    // solution comes here

    ll N;
    cin >> N;
    vl a(N);
    rep(i, N) cin >> a[i];

    ll ans=0, target=1;
    bool non=true;
    rep(i, N){
        if(a[i] == target){
            target++;
            non=false;
        }
        else ans++;
    }

    if(non) cout << "-1" << nl;
    else    cout << ans << nl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int input=sc.nextInt();
		int profit_max=-1000000000;
		int min=1000000000;
		int tmp=0;
		for(int i=0; i<input; i++) {
			if(i!=0) {
				tmp=sc.nextInt();
				profit_max=Math.max(tmp-min, profit_max);
				if(min>tmp) {
					min=tmp;
				}
			}
			else {
				min=sc.nextInt();
			}
		}
		System.out.println(profit_max);
	}
}


Measured memory_bytes: 98852
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int[] array = new int[]{s.nextInt(), s.nextInt(), s.nextInt()};
        Arrays.sort(array);

        System.out.println(Arrays.equals(array, new int[]{5, 5, 7}) ? "YES" : "NO");
    }

}

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

int main(){
  int i,j,a;
  int n,*array;
  int key;

  scanf("%d",&n);

  array =(int *)malloc(n * sizeof(int));
  
  for(i=0;i<n;i++){
    scanf("%d",&array[i]);
  }

  for(i=1;i<=n;i++){

    
    for(a=0;a<n;a++){
      printf("%d",array[a]);
      if(a!=n-1) printf(" ");
    }
    printf("\n");

    
    key=array[i];
    j=i-1;
    while(j>=0 && array[j]>key){
      array[j+1]=array[j];
      j--;
    }
    array[j+1]=key;


  }
  
  return 0;
}



Measured memory_bytes: 2068
import java.util.*;

public class Main{
    public static void main(String[] args){
    //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] D = new int[N];
        for(int i=0;i<N;i++){
            D[i] = sc.nextInt();
        }
    //処理
        Arrays.sort(D);
        System.out.println(D[N/2]-D[N/2-1]);

        sc.close();

    }
}


Measured memory_bytes: 52392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll mod2=998244353;
  
  ll N;
  cin>>N;
  
  vector<ll>D(N);
  vector<ll>d(N);
 
  bool flag=false;
  rep(i,N){
    cin>>D[i];
    if(D[0]!=0){
      flag=true;
    }
 if(i!=0&&D[i]==0){
flag=true;
}
  }
  sort(all(D));
  
 for(ll i=1;i<N;i++){
if(D[i]!=D[i-1]){
if(D[i]-D[i-1]!=1){
flag=true;
}
}
 }

  ll num=0;
  ll ans=1;
  
  if(flag){
    cout<<0<<endl;
  }
else{
sort(all(D));

for(ll i=1;i<N;i++){
  if(D[i]!=D[i-1]){
    num=D[i-1];
    
  }
  
d[i]=(D.end()-lower_bound(all(D),num))-(D.end()-lower_bound(all(D),D[i]));
}
  
  for(ll i=1;i<N;i++){
    d[i]%=mod2;
ans*=d[i];
    ans%=mod2;
  }
  cout<<ans<<endl;

}
  

  
}







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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// }}} 1

int main() {

    int n;
    Scd(n);

    printf ("%d\n", n*(n+1)/2);

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int a = N * (N-1) / 2;
        int b = M * (M-1) / 2;
        System.out.println(a + b);
        sc.close();
    }
}


Measured memory_bytes: 35684
s[100],t[100];
main(n){
	int i,j,h;
	for(;scanf("%d",&n)*n;){
		memset(s,9,sizeof(s));
		memset(t,0,sizeof(t));
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				scanf("%d",&h);
				if(h<s[i])
					s[i]=h;
				if(h>t[j])
					t[j]=h;
			}
		}
		h=0;
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				if(s[i]==t[j])
					h=s[i];
			}
		}
		printf("%d\n",h);
	}
}

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

int main(void){
    int a = 0, b = 0; 
    int max = -1000;

    scanf("%d%d", &a, &b);

//    printf("%d\n", b);
    if(max < a + b){
        max = a + b;
    }
    if(max < a * b){
        max = a * b;
    }
    /*
    if(b < 0){
        if(max < a - (1) * b){
            max = a - (1) * b;
        }
    }
    if(b >= 0){
        if(max < a - b){
            max = a - b;
        }
    }
    */
    if(max < a - b){
        max = a - b;
    }

    printf("%d\n", max);

    return 0;
} 


Measured memory_bytes: 256