akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int H,W,N;
    cin >> H >> W >> N;
    int rr,cc;
    cin >> rr >> cc;
    rr--; cc--;
    string S,T;
    cin >> S >> T;
    bool ans = true;
    //U
    int r,c;
    r = rr; c = cc;
    REP(i,N) {
        if (S[i] == 'D') {
            r++;
            if (r == H) {
                ans = false;
            }
        }
        if (T[i] == 'U' && r != 0) {
            r--;
        }
    }
    //D
    r = rr; c = cc;
    REP(i,N) {
        if (S[i] == 'U') {
            r--;
            if (r == -1) {
                ans = false;
            }
        }
        if (T[i] == 'D' && r != H-1) {
            r++;
        }
    }
    //R
    r = rr; c = cc;
    REP(i,N) {
        if (S[i] == 'R') {
            c++;
            if (c == W) {
                ans = false;
            }
        }
        if (T[i] == 'L' && c != 0) {
            c--;
        }
    }
    //L
    r = rr; c = cc;
    REP(i,N) {
        if (S[i] == 'L') {
            c--;
            if (c == -1) {
                ans = false;
            }
        }
        if (T[i] == 'R' && c != W-1) {
            c++;
        }
    }

    if (ans) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 776
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = null;
		try{
			br = new BufferedReader(new InputStreamReader(System.in));
			String buf;
			while((buf = br.readLine())!=null){
				int JOI =0,IOI=0;
				for(int i = 0; i < buf.length() -2;i++){
					String data = buf.substring(i, i+3);
					if(data.equals("JOI"))JOI++;
					if(data.equals("IOI"))IOI++;
				}
				System.out.println(JOI);
				System.out.println(IOI);
			}
		}finally{
			if(!(br == null))br.close();
		}
	}
}

Measured memory_bytes: 20092
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
#define MAX 1000000

using namespace std;
typedef pair<double,double> dd;
int N,M;
int par[MAX];

void init()
{
  rep(i,MAX)par[i] = i;
}

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

void unit(int x,int y)
{
  x = find(x);
  y = find(y);
  if(x!=y)par[x] = y;
}

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

struct Pox
{
  int from,to;
  double cost;
  Pox(int from=-1,int to=-1,double cost=0):from(from),to(to),cost(cost){}
};



bool cmp(const Pox &p1, const Pox& p2)
{
  return p1.cost > p2.cost;
}

double kruskal(vector<Pox> &G)
{
  sort(G.begin(),G.end(),cmp);
  double res = 0;
  rep(i,G.size())
    {
      Pox pox = G[i];
      if(!same(pox.from,pox.to))
	{
	  unit(pox.from,pox.to);
	  res += pox.cost;
	}
    }
  return res;
}


int main()
{
  while(cin >> N >> M)
    {
      init();
      vector<Pox> G;
      vector<dd> coor(N+1);
      REP(i,1,N+1)cin >> coor[i].F >> coor[i].S;

      double totalCost = 0;
      rep(i,M)
	{
	  int f,t;
	  cin >> f >> t;
	  double cost = sqrt(pow(coor[f].F-coor[t].F,2)+pow(coor[f].S-coor[t].S,2));
	  totalCost += cost;
	  G.push_back(Pox(f,t,cost));

	}

      cout << setiosflags(ios::fixed) << setprecision(10) << totalCost - kruskal(G) << endl;

    }
  return 0;
}

Measured memory_bytes: 5884
import java.io.PrintWriter
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun Int.pow(n: Int) = pow(n.toLong())
fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
fun Long.pow(n: Int) = pow(n.toLong())
fun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    println(N * (N + 1) / 2)
}


Measured memory_bytes: 34144
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){

	long long  a,arr[4],b,c,d;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	arr[0] = a*c;
	arr[1] = a*d;
	arr[2] = b*c;
	arr[3] = b*d;
	sort(arr,arr+4);
	printf("%lld\n",arr[3]);
	return 0;
}


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

int main(void) {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector< int > A(Q);
    for (int i = 0; i < Q; i++) {
        cin >> A[i];
    }
    vector< int > correct(N);
    for (int i = 0; i < N; i++) {
        correct[i] = 0;
    }
    for (int i = 0; i < Q; i++) {
        correct[A[i] - 1] += 1;
    }
    for (int i = 0; i < N; i++) {
        if (Q - correct[i] < K) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
    return 0;
}


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

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;


int n, M[MAX][MAX];

int prim() {
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for(int i=0; i<n; i++) {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while(1) {
        minv = INFTY;
        u = -1;
        for(int i = 0; i < n; i++ ) {
            if(minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = BLACK;

        for(int v = 0; v < n; v++) {
            if(color[v] != BLACK && M[u][v] != INFTY) {
                if (d[v] > M[u][v] ) {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            } 
        }
    }
    int sum = 0;
    for (int i = 0; i < n; i++ ) {
        if(p[i] != -1 ) sum += M[i][p[i]];
    }

    return sum;
}

int main() {
    cin >> n;

    for (int i = 0; i < n; i++ ) {
        for (int j = 0; j < n; j++ ) {
            int e; cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }

    cout << prim() << endl;

    return 0;
}

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

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

const int N = 2010; 
vector<int> adj[N];
int n, k, dist[N]; 

int dfs(int u, int par) {
    for(int v : adj[u]) if(v - par) {
        dist[v] = min(dist[v], dist[u] + 1); 
        dfs(v, u); 
    }
}

vector<pair<int, int> > e; 

int main(int argc, char const *argv[]) {
    scanf("%d %d", &n, &k); 
    for(int i = 1; i < n; i++) {
        int u, v; scanf("%d %d", &u, &v); 
        adj[u].push_back(v);
        adj[v].push_back(u); 
        e.emplace_back(u, v); 
    }
    int ans = 1e9; 
    if(k & 1) {
        for(auto it : e) {
            int u = it.first, v = it.second; 
            memset(dist, 63, sizeof dist); 
            dist[u] = dist[v] = 0; 
            dfs(u, 0); dfs(v, 0); 
            int cnt = 0;
            for(int i = 1; i <= n; i++) 
                if(dist[i] * 2 + 1 > k) cnt++;
            ans = min(ans, cnt); 
        }
    } else {
        for(int i = 1; i <= n; i++) {
            memset(dist, 63, sizeof dist); 
            dist[i] = 0; dfs(i, 0); 
            int cnt = 0; 
            for(int j = 1; j <= n; j++) 
                if(dist[j] * 2 > k) cnt++; 
            ans = min(ans, cnt); 
        }
    }
    printf("%d\n", ans); 
}


Measured memory_bytes: 512
s = input()


value = 0

def compute(state,s):
	x = 0
	start_pos = 0
	end_pos = 0
	for i in range(len(s)-1):
		if state[i] == '0':
			continue
		else:
			end_pos = i+1
			x += int(s[start_pos:end_pos])
			start_pos = i+1
	if s[end_pos:] != '':
		x += int(s[end_pos:])
	return x


for i in range(2**(len(s)-1)):
	state = format(i,'0%ib'%(len(s)-1))
	value += compute(state,s)
print(value)

Measured memory_bytes: 3064
#include<cstdio>
#define del(x) ((x)>=TT?(x)-TT:(x))
using namespace std;
const int maxn=200005,TT=1e9+7;
int n,a[maxn],ans,sum[maxn];
inline int read(){
	int ret=0;bool f=0;char ch=getchar();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=getchar();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=getchar();
	return f?-ret:ret;
}
int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=ans=1;i<=n;i++)
	if(a[i]^a[i-1]) ans=sum[a[i]]=del(ans+sum[a[i]]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
    cin>>N;
    if ((N/1000 == N/100-N/1000*10)&&(N/100-N/1000*10==N/10-N/100*10)||(N/100-N/1000*10==N/10-N/100*10)&&(N/10-N/100*10==N-N/10*10) )
      cout <<"Yes" <<endl;
  else
    cout << "No" <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, K; cin >> N >> K;
    vec V(N); cin >> V;

    int ans = 0;
    REP(i, N + 1) REP(j, N + 1) if(i + j <= N && i + j <= K){
        vec v;
        REP(k, i) v.pb(V[k]);
        REP(k, j) v.pb(V[N - 1 - k]);
        Sort(v);
        REP(k, K - i - j) if(k < SZ(v) && v[k] < 0) v[k] = 0;
        int tmp = 0;
        REP(k, SZ(v)) tmp += v[k];
        Max(ans, tmp);
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, m, n) for(ll i = (ll)m; i < (ll)n; i++)
#define PER(i, m, n) for(ll i = (ll)m; i > (ll)n; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> v(n);
    REP(i, 0, n) cin >> v[i];
    ll ans = 1;
    bool up = false;
    bool down = false;

    REP(i, 0, n-1){
        if(v[i] < v[i+1]) up = true;
        if(v[i] > v[i+1]) down = true;
        if(up && down){
            ans++;
            up = false;
            down = false;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4000
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long MODPOW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll n,ans=0;
	string s;
	cin >> n >> s;
	ll left=0;
	for(ll i=n-1;i>=left;i--){
		if(s[i]=='R'){
			for(ll j=left;j<i;j++){
				left = j+1;
				if(s[j]=='W'){
					ans++;
					break;
				}

			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3684
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  ll N, C, K;
  cin >> N >> C >> K;
  vector<int> T(N);
  rep(i, N) cin >> T.at(i);

  sort(all(T));

  ll ans = 1, num = 1, timer = T.at(0);
  for (int i = 1; i < N ; i++) {
    if (num == C || timer + K < T.at(i)) {
      ans++;
      num = 1;
      timer = T.at(i);
    }
    else {
      num++;
    }
  }

  cout << ans << endl;

}




Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;
typedef pair<lli, int> p;

int main() {
    lli N, C;
    cin >> N >> C;
    vector<lli> x(N + 1, 0), v(N + 1, 0);
    REP(i, 1, N + 1) {
        cin >> x[i] >> v[i];
    }
    lli ans = 0;
    REP(_, 0, 2) {
        vector<p> mx(N + 1, {0LL, 0});
        lli m = 0;
        REP(i, 0, N) {
            mx[i + 1].first = mx[i].first - (x[i + 1] - x[i]) + v[i + 1];
            mx[i + 1].second = mx[i].second;
            if (mx[i + 1].first > m) {
                m = mx[i + 1].first;
                mx[i + 1].second = i + 1;
            }
        }
        lli cost = 0;
        lli dis = 0;
        for (int i = N + 1; i >= 1; i--) {
            int pos = i % (N + 1);
            int ed = (i + N) % (N + 1);
            lli foc = mx[mx[ed].second].first;
            lli tmp = min(dis, x[mx[ed].second]);
            ans = max(ans, cost + foc - tmp);
            cost += -((C + x[pos] - x[ed]) % C) + v[ed];
            dis += (C + x[pos] - x[ed]) % C;
        }
        reverse(begin(x) + 1, end(x));
        reverse(begin(v) + 1, end(v));
        REP(i, 1, N + 1) {
            x[i] = C - x[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if (((a==b) && (b!=c)) || ((b==c) && (a!=b)) || ((a==c) && (a!=b))) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

const int Mod = 1e9 + 7;
const int N = 2e6 + 5;

int n, k;
string s;
ll fact[N], inv[N], invFact[N];

ll mpow(ll a, ll b) {
  ll r = 1;
  while(b > 0) {
    if(b & 1) r = (r * a) % Mod;
    a = (a * a) % Mod;
    b >>= 1;
  }
  return r;
}

ll C(int n, int k) {
  return fact[n] * invFact[k] % Mod * invFact[n - k] % Mod;
}

int main()
{
  ios::sync_with_stdio(false);

  fact[0] = fact[1] = 1;
  inv[0] = inv[1] = 1;
  invFact[0] = invFact[1] = 1;
  for(int i = 2; i < N; i++) {
    fact[i] = (fact[i - 1] * i) % Mod;
    inv[i] = Mod - Mod / i * inv[Mod % i] % Mod;
    invFact[i] = (invFact[i - 1] * inv[i]) % Mod;
  }

  cin >> k >> s;
  n = sz(s);
  ll ans = 0;
  for(int i = n; i <= n + k; i++) {
    ans += C(i - 1, n - 1) * mpow(25, i - n) % Mod * mpow(26, n + k - i) % Mod;
    ans %= Mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 51128
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double[] x = new double[N];
		String[] u = new String[N];
		String empty = sc.nextLine();
		for (int i=0;i<N;i++) {
			String str = sc.nextLine();
			String[] str1 = str.split(" ");
			x[i]=Double.parseDouble(str1[0]);
			u[i]=str1[1];
		}

		double sum = 0;
		for (int i=0;i<N;i++) {
			if (u[i].equals("JPY")) {
				sum+=x[i];
			}else {
				sum+=x[i]*380000;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 22996
#include<stdio.h>
#include<string.h>
int main(void){
    char s[200];
    int i, j, n, key, NMax, NMin, SUM_Max, SUM_Min, S[100];
    scanf("%d", &n);
    while ( n-- ) {
        scanf("%s", s);
        for ( i = 0; i < 8; i ) {
            if ( s[i] == '1') S[++i] = 1;
            else if ( s[i] == '2') S[++i] = 2;
            else if ( s[i] == '3') S[++i] = 3;
            else if ( s[i] == '4') S[++i] = 4;
            else if ( s[i] == '5') S[++i] = 5;
            else if ( s[i] == '6') S[++i] = 6;
            else if ( s[i] == '7') S[++i] = 7;
            else if ( s[i] == '8') S[++i] = 8;
            else if ( s[i] == '9') S[++i] = 9;
            else if ( s[i] == '0') S[++i] = 0;
        }
        key = 1;
        /*for ( i = 1; i <= 8; i++ ) printf("%d ", S[i]);*/
        /*printf("\n");*/
        for ( i = 1; key; i++ ) {
            key = 0;
            for ( j = 8; j > i; j-- ) {
                if ( S[j] < S[j - 1]) {
                    key = S[j];
                    S[j] = S[j - 1];
                    S[j - 1] = key;
                    key = 1;
                }
            }
        }
        /*for ( i = 1; i <= 8; i++ ) printf("%d ", S[i]);*/
        NMax = 10000000;
        NMin = 1;
        SUM_Max = SUM_Min = 0;
        for ( i = 1; i <= 8; i++ ) {
            SUM_Max += S[i] * NMin;
            SUM_Min += S[i] * NMax;
            NMax /= 10;
            NMin *= 10;
        }
        printf("%d\n", SUM_Max - SUM_Min);
    }
   return 0;
}

Measured memory_bytes: 1740
#include<stdio.h>
int main(){
    int a;
    while(scanf("%d",&a),a){
        for(int i=0;i<a;i++){
            int b,c,d;
            scanf("%d%d%d",&b,&c,&d);
            if(b==100||c==100||d==100||b+c>=180||b+c+d>=240)printf("A\n");
            else if(b+c+d>=210||(b+c+d>=150&&(b>=80||c>=80)))printf("B\n");
            else printf("C\n");
        }
    }
}


Measured memory_bytes: 2548
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    string s; cin >> s;
    ll sl = s.length();
    
    ll goos = 0, pars = 0;
    ll ans = 0;
    REP(i, sl) {
        if (goos > pars) {
            pars++;
            if (s[i] == 'g') ans++;
        } else {
            goos++;
            if (s[i] == 'p') ans--;
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int, int>
#define ff first
#define ss second
#define md 1000000000000000000

int main() {
    int n;
    cin >> n;
    ll mult = 1;
    bool flag = true;
    while (n--) {
    ll x;
    cin >> x;
    if (x == 0) {
        cout << 0;
        return 0;
    }
    else if (x > md / mult) flag = false;
    else mult *= x;
    }
    if (flag) cout << mult;
    else cout << -1;
    return 0;
}

Measured memory_bytes: 3620
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N = I()
H = III()
H[0] -= 1
for i in range(1,N):
  if H[i]<H[i-1]:
    print('No')
    exit()
  if H[i]-1>=H[i-1]:
    H[i]-=1
print('Yes')

Measured memory_bytes: 63856
n = int(input())
a = sorted(list(map(int, input().split())))
max_a = a[-1]

q = [0] * (max_a + 1)
for i in a:
    if q[i] == 1 or q[i] == -1:
        q[i] = -1
        continue
    for j in range(2*i, max_a+1, i):
        q[j] = -1
    q[i] = 1

total = 0
for i in q:
    if i == 1:
        total += 1
print(total)

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  bool flag = true;
  FOR(i, 1, n) if(a[i-1] >= a[i]) flag = false;
  if(flag) {
    cout << 1 << endl;
    return 0;
  }

  auto check = [&](ll mid) -> bool {
    stack<PII> st; st.push({-1, -1});
    FOR(i, 1, n) {
      if(a[i-1] < a[i]) continue;
      while(a[i] <= st.top().first) st.pop();
      ll idx = a[i]-1;
      while(true) {
        if(st.top().first != idx) {
          st.push({idx, 1});
          break;
        } else if(st.top().second == mid-1) {
          if(idx == 0) return false;
          st.pop();
        } else {
          PII p = st.top(); st.pop();
          st.push({p.first, p.second+1});
          break;
        }
        idx--;
      }
//      stack<PII> d(st);
//      while(d.size()) {
//        cout << d.top() << " ";
//        d.pop();
//      }
//      cout << endl;
    }
    return true;
  };

  // (lb,ub]
  ll lb = 1, ub = 1000000000;
  while(ub-lb > 1) {
    ll mid = (lb+ub)/2;
//    cout << lb << " " << mid << " " << ub << endl;
    if(check(mid)) ub = mid;
    else lb = mid;
  }

  cout << ub << endl;

  return 0;
}

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

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var s = GetIntArray();
            string ans = s[0] + s[1] >= 10 ? "error" : (s[0] + s[1]).ToString();

            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int a,b;
    cin>>a>>b;
    if(a<=9&&b<=9){
        cout<<a*b<<endl;
    }else{
        cout<<-1<<endl;
    }

    return 0;
}


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

int main()
{
    ll A, B;
    cin >> A >> B;
    cout << ((A + B) % 2 == 0 ? to_string((A + B) / 2) : "IMPOSSIBLE") << endl;
    return 0;
}


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

struct Posi {
    ll x;
    ll y;
};

int main()
{
    ll N, M; cin >> N >> M;
    struct Posi P[N];
    struct Posi C[M];
 
    rep(i, N) {
        ll a, b; cin >> a >> b;
        P[i].x = a;
        P[i].y = b;
    }
    rep(i, M) {
        ll c, d; cin >> c >> d;
        C[i].x = c;
        C[i].y = d;
    }
    vector<ll> ans;
    rep(i, N) {
        ll min = -1;
        ll num = 0;
        rep(j, M) {
            ll tmp = abs(P[i].x - C[j].x) + abs(P[i].y - C[j].y);
            if (min == -1) {
                min = tmp; num = j; 
            }
            else if (min > tmp) {
                min = tmp; num = j;
            }
        }
        ans.push_back(num+1);
    }

    rep(i,N) {
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,c,k;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    int sum=0;
    if(k<=a)
    {
        sum=k;
    }
    else
    {
        sum+=a;
        k=k-a;
        if(k<=b)
        {
            sum=sum;
        }
        else
        {
            k=k-b;
            sum-=k;
        }
    }
    printf("%d",sum);
}


Measured memory_bytes: 1736
//
// Created on 2020/05/10.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans = 0;
    int a,b,c;
    int k;
    cin>>a>>b>>c>>k;
    while(k>0 && a >0){
        ans += min(a,k);
        if(a>k){a=a-k;k=0;}
        else {k=k-a;a=0;}
    }
    k=k-b;
    while(k>0 && c>0){
        ans -= min(c,k);
        if(c>k){c=c-k;k=0;}
        else {k=k-c;c=0;}
    }

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


Measured memory_bytes: 3592
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x);
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int x[300 * 300 + 1] = {};
int y[300 * 300 + 1] = {};

pll arr[200000] = {};

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

	ll answer = 0;

	for (int i = 0; i < n; i++) {
		cin >> arr[i].first;
		arr[i].second = i;
	}

	sort(arr,arr+n);

	map<ll, bool> m;
	m[-1] = true;
	m[n] = true;

	for (int i = 0; i < n; i++) {
		m[arr[i].second] = true;
		ll l = (--m.find(arr[i].second))->first;
		ll r = (++m.find(arr[i].second))->first;
		//cerr << l << " " << r << endl;
		answer += arr[i].first * (arr[i].second-l)  * (r-arr[i].second);
		//cerr << arr[i].first * (arr[i].second - l)  * (r - arr[i].second) << endl;
		assert((r - arr[i].second) > 0);
		assert((arr[i].second - l) > 0);
	}

	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 15872
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
  ll X,Y; cin >> X >> Y;
  
  ll A=X;
  ll count=1;
  for(int i=1; i<(2<<8); i++){
    A *= 2;
    if(A > Y){count=i; break;}
  }
  cout << count << "\n";
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int arr[]={9,900,90000,9000000};
	int n;
	cin>>n;
	int s=n;
	int count=0;
	while(s!=0)
	{
		s=s/10;
		count++;
	}
	int p=count/2-1;
	int sum=0,i;
	for(i=0; i<=p; i++)
	sum+=arr[i];
	if(count%2==0)
	cout<<sum;
	else {
		int x;
		x=pow(10, count-1);
		int res;
		res=sum+1+n-x;
		cout<<res;
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
//#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}





int main() {
	int n, m,a,b,ans=0;
	cin >> n >> m;
	vector<pair<int, int>>vec(n,m_p(1,0));
	vec[0].second = 1;
	rep(i, m) {
		cin >> a >> b;
		a--; b--;
		vec[b].first++;
		vec[a].first--;
		if (vec[a].second) {
			vec[b].second = 1;
		}
		if (vec[a].first == 0) {
			vec[a].second = 0;
		}
	}
	rep(i, n) {
		if (vec[i].second) {
			ans++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

//順列の全探索は、bitDP, 挿入DP, 箱根駅伝DP

void solve() {
	int n;
    while(cin >> n && n != 0) {
        vector<int> nont(n);
        vector<vector<int>> t(n, vector<int>(n));
        rep(i, n) {
            cin >> nont[i];
            rep(j, n) {
                cin >> t[i][j];
            }
        }
        int dp[1<<17];
        rep(i, 1<<17) dp[i] = inf;
        dp[0] = 0;
        //トポロジカル順序に最初からなっていてこの順でok
        for(int i = 1; i < (1<<n); ++i) {
            rep(j, n) if(i & (1<<j)) {
                chmin(dp[i], dp[i ^ (1<<j)] + nont[j]);
                rep(k, n) if((i & (1<<k)) && (j != k)) chmin(dp[i], dp[i ^ (1<<j)] + t[j][k]);
            }
        }
        cout << dp[(1<<n) - 1] << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}


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

int main()
{
	string s, temp1 = "", temp2 = "";
	cin >> s;
	int n = s.size();
	for(int i = 0; i < (n - 1) / 2; ++i)
	{
		temp1 += s[i];
		temp2 += s[i + (n + 1) / 2];
	}
	if(temp1 != temp2)
	{
		cout << "No" << endl;
		return 0;
	}
	for(int i = 0; i < temp1.size(); ++i)
	{
		if(temp1[i] != temp1[temp1.size() - 1 - i])
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

const int mxn = 2e5 + 100;
ll a[mxn], b[mxn];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	ll m, n, i, k, j, sum = 0, c = 0;
	cin >> n >> m >> k;
	rep(i, 0, n)
	{
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	rep(i, 0, m)
	{
		cin >> b[i + 1];
		b[i + 1] += b[i];
	}
	for(i = 0, j = m; i <= n; i++)
	{
		if(a[i] > k)
			break;
		while(a[i] + b[j] > k)
			j--;
		c = max(c, i + j);
	}
	cout << c << endl;
}

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

using namespace std;

#define ll       long long
#define PII      pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3010;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);

ll solve(ll n) {
    ll ans = 1e18, sq = sqrt(n);
    for (ll i = 1; i <= sq; i++) {
        if (n % i == 0) {
            ll x = n / i;
            ll cost = (x - 1) + (i - 1);
            ans = min(ans, cost);
        }
    }
    return ans;
}

int main() {
    ll n;
    cin >> n;
    cout << solve(n) << '\n';
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;



int main(void) {
  string s;
  cin >>s;
  ll sum = 0;
  int n = s.size();
  ll a = stoll(s);
  vi b(n);
  rep(i,n){
    b[n-i-1] = a%10;
    a/=10;
  }
  
  //int roop = 0;
  for(int bit = 0;bit< (1 << n-1);bit++){
    //roop++;
    stack<int> p;
    for(int i = 0;i<n;i++){
      if(bit & (1 << i)){
        sum+=b[i];
        //cout << b[i] << endl;
        int cnt =0;
        while(!p.empty()){
          sum+=pow(10,cnt+1)*p.top();
          //cout << "a" << pow(10,cnt+1)*p.top() << endl;
          p.pop();
          cnt++;
        }
      }
      else {
        p.push(b[i]);
        //cout << "c" << endl;
      }
    }
    int cn = 0;
    while(!p.empty()){
    	sum+=pow(10,cn)*p.top();
      //cout << "b" << pow(10,cn)*p.top() << endl;
        p.pop();
        cn++;
    }
  }
  //cout << roop << endl;
  cout << sum << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	cout<<min(read(),read())+min(read(),read())<<endl;
	return 0;
}



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

using namespace std;

int main() {
    int n, m;

    cin >> n >> m;

    vector <int> count(m);

    int k;
    int tmp;
    int id = 0;

    while(cin >> k) {
        for(int i = 0; i < k; i++) {
            cin >> tmp;

            count[tmp-1] ++;
        }

        id ++;
        if(id >= n) {
            break;
        }
    }

    int cnt = 0;

    for(int i = 0; i < m; i++) {
        if(count[i] == n) {
            cnt ++;
        }
    }

    cout << cnt << endl;

}

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

int fri[100010];

int find(int x){
  if( fri[x] == x ) return x;
  else return fri[x] = find(fri[x]);
}

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

void uf_union(int x, int y){
  x = find(x);
  y = find(y);
  
  fri[x] = y;

}

int main(){

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

  // init
  for(int i=0; i<n; i++) fri[i] = i;

  //
  for(int i=0; i<m; i++){
    int u,v; scanf("%d %d",&u,&v);
    uf_union(u,v);
  }

  cin >> q;
  for(int i=0; i<q; i++){
    int u,v; scanf("%d %d",&u,&v);
    if( find(u) == find(v) ) cout << "yes\n";
    else cout << "no\n";
  }


}

Measured memory_bytes: 2208
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n;cin >> n;
	int a[2][100];
	rep(i, 2) {
		rep(j, n) {
			cin >> a[i][j];
		}
	}
	vector<vector<int>> dp(2, vector<int>(110,0));
	dp[0][0] = 0;
	rep(i, 2) {
		rep(j, n) {
			if (i != 0) dp[i][j + 1] = max(dp[i][j], dp[i - 1][j + 1]) + a[i][j];
			else dp[i][j + 1] = dp[i][j] + a[i][j];
		}
	}
	cout << dp[1][n] << endl;
}

Measured memory_bytes: 256