akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  inl(n,a,b);
  out(a>b||(n==1&&a!=b) ? 0 : (n-2) * (b-a) + 1 );
}

Measured memory_bytes: 256
main = putStrLn . solve . map read . words =<< getContents

solve :: [Int] -> String
solve [sx, sy, tx, ty] =
    let
        x = tx - sx
        y = ty - sy
    in (replicate x 'R') ++ (replicate y 'U') ++ (replicate x 'L') ++ (replicate (y+1) 'D')
        ++ (replicate (x+1) 'R') ++ (replicate (y+1) 'U') ++ "LU" ++ (replicate (x+1) 'L') ++ (replicate (y+1) 'D') ++ "R"


Measured memory_bytes: 1020
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
point = 0

for i, eat in enumerate(a):
    point += b[eat - 1]
    if i == n - 1:
        print(point)
        exit()
    if a[i + 1] == eat + 1:
        point += c[eat - 1]

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

using namespace std;

#define lli long long
#define ld long double
#define mod 1000000007 
#define set(n) cout << fixed << setprecision(n)    
#define fi first
#define se second
#define mp make_pair
#define pll pair<lli, lli>
#define endl '\n'

const double PI = acos(-1);
const double epsilon = 1e-7;  // floating point precision

signed main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int i = 0, j = n - 1;
    int ans = 0;
    while(i < j) {
        if(s[i] == 'W' and s[j] == 'W') {
            j--;
        } 
        else if(s[i] == 'W' and s[j] == 'R') {
            ans++;
            i++;
            j--;
        }
        else if(s[i] == 'R' and s[j] == 'R') {
            i++;
        }
        else {
            i++;
            j--;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int64_t>a(n); for(auto&&i:a)cin>>i;
	vector<int64_t>b(n); b.front()=0;
	for(int i=1;i<n;++i)b.at(i)=a.at(i-1)*2-b.at(i-1);
	if(b.back()/2!=a.back()){
		int64_t diff=(a.back()*2-b.back())/2;
		for(int i=1;i<n;i+=2)b.at(i-1)+=diff,b.at(i)-=diff;
		b.back()+=diff;
	}
	cout<<b.front();
	for(int i=1;i<n;++i)cout<<" "s<<b.at(i);
	cout<<"\n"s;
}

Measured memory_bytes: 2944
#pragma GCC optimize(2)
#include<iostream> 
#include<cstdio> 
#include<cstring> 
#include<algorithm> 
#include<map> 
#define File(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
#define re register
#define ri re int
#define gtch() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#define For(i,a,b) for(ri i=a;i<=b;++i) 
#define iFor(i,a,b) for(ri i=a;i>=b;--i) 
using namespace std;
typedef long long ll;
char buf[1<<21],*p1=buf,*p2=buf;
inline ll fr()
{
	re char ch=getchar();re ll res=0;int bl=0;
	while(!isdigit(ch)) bl=(ch=='-'),ch=getchar();
	while(isdigit(ch)) res=(res<<1)+(res<<3)+ch-'0',ch=getchar();
	return bl?-res:res;
}
const int MAXN=100;
const int INF=9e8+5;
int n; 
signed main()
{
//	File("temp")
	n=fr();
	ri cnt=0,mx=0;
	For(i,1,n)
	{
		ri t1=fr(),t2=fr();
		if(t1==t2) ++cnt;
		else mx=max(mx,cnt),cnt=0;
	}
	mx=max(mx,cnt);
	if(mx>=3)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll  long long 
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define all(a) a.begin(),a.end()
#define int ll
using namespace std;
using namespace __gnu_pbds;
typedef tree <int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll const mod=1e9+7;
int powi(int i,int b){
    int res=1;
    while(b){
        if(b&1)res*=i,res%=mod;
        b>>=1;
        i*=i;
        i%=mod;
    }
    return res;
}
//map<int,int> m;
ll fact(int n){
	//if(n==0)return 0;
	if(n<=1)return 1;
	//if(m[n]!=0)return m[n];
	return (n*fact(n-1))%mod;
}
// int ncr(int n,int r){
//     int h=fact(n);
//     int v=fact(r);
//     int j=fact(n-r);
//     v*=j;
//     v%=mod;
//     v=powi(v,mod-2);
//     return (h*v)%mod;
// }
// vi ar(2000000);
// vi sz(2000000);
// int root(int a){
//     if(ar[a]==a)return a;
//     return ar[a]=root(ar[a]);
// }
// int merge(int a,int b){
//     int h=root(a),j=root(b);
//     int ans=sz[h]*sz[j];
//     sz[j]+=sz[h];
//     if(h!=j){
//         ar[h]=j;
//     }
//     return ans;
// } 
void solve(){
    int n,a,b;
    cin>>n>>a>>b;
    int ans=powi(2,n)-1;
    //debug("lol");
    int val=1;
    for(int i=n;i>n-a&&i>0;i--){
        val*=i;
        val%=mod;
    }
    int g=1;
    for(int i=a;i>=1;i--){
        g*=i;
        g%=mod;
    }
    val*=powi(g,mod-2);
    val%=mod;
    //debug(val);
    ans-=val;
    ans+=mod;
    ans%=mod;
    val=1;
    for(int i=n;i>n-b&&i>0;i--){
        val*=i;
        val%=mod;
    }
    g=1;
    for(int i=b;i>=1;i--){
        g*=i;
        g%=mod;
    }
    val*=powi(g,mod-2);
    val%=mod;
    ans-=val;
    ans+=mod;
    ans%=mod;
    cout<<ans;
}
signed main(){
    //boost;
    int t=1;
    //cin>>t;
    for(int _=1;_<=t;_++){
        //cout<<"Case #"<<_<<": ";
        solve();
        cout<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
// ABC077_C
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

#define ALL(obj) (obj).begin(), (obj).end()
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1


int main() {
  // input
  ll N;
  cin >> N;
  vector<ll> A(N), B(N), C(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  rep(i, N) cin >> C[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  // calculation
  ll now_B, num_A, num_C, res = 0;
  ll idx_bound_A, idx_bound_C;

  for (ll i = 0; i < N; ++i) {
    now_B = B[i];
    num_A = 0;
    num_C = 0;

    // 1 段目: now_B 未満の数を求める
    auto iter_A = lower_bound(A.begin(), A.end(), now_B);
    auto iter_C = upper_bound(C.begin(), C.end(), now_B);
    ll num_A = iter_A - A.begin();
    ll num_C = C.end() - iter_C;

    res += num_A*num_C;
  }

  cout << res << "\n";

  return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int x,co=1;
        while(true){
            x = s.nextInt();
            if(x==0)break;
            else System.out.println("Case "+co+": "+x);
            co++;
        }
    }
}



Measured memory_bytes: 40880
void main()
{
    string s = rdStr;

    string f(string x, dchar y)
    {
        string t;
        long len = x.length.to!long - 1;
        foreach (i; 0 .. len)
        {
            if (x[i] == y || x[i+1] == y) t ~= y;
            else t ~= s[i];
        }

        return t;
    }

    long result = inf;
    foreach (c; lowercase)
    {
        string u = s;
        long cnt;
        while (u.any!(x => x != c))
        {
            u = f(u, c);
            ++cnt;
        }
        result = min(result, cnt);
    }

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 7/30/2018
 
 25:40-
 
 
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
LL H[MAX_N];
int N;
LL A,B;

bool ok(LL t) {
  LL HH[MAX_N]={};
  LL cnt=0;
  REP(i,N) {
    HH[i]=H[i]-B*t;
    if(HH[i]>0) cnt+=(HH[i]+A-B-1)/(A-B);
  }
  return cnt<=t;
}

LL solve() {
  LL good=1e9,bad=0;
  while(abs(good-bad)>1) {
    LL mid=(good+bad)/2;
    (ok(mid)?good:bad)=mid;
  }
  return good;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>A>>B;
  REP(i,N) cin>>H[i];
  
  cout<<solve()<<endl;
  
  return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vll = vector<vector<ll> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;
using lthe = pair<ll, ll>;

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; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


priority_queue<the> p[200000];
const int MAXP = 2 * 1e5;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b))  cout << "A" << endl;
	else  cout << "B" << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define REP(i, t) for(int i = 0; i < t; i++)
#define INF (1 << 30)

int main()
{
    int db[2];
    cin >> db[0] >> db[1];
    cout << (db[0] - 1) * (db[1] - 1) << endl;
    return 0;
}


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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for(ll i = 0 ; i<n ; i++) 
#define rep2(n) for(ll j=0 ; j<n ; ++j )
#define repd(n) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007
#define pii pair<ll,ll>
#define vll vector<ll>
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) a.size() 
#define all(a) a.begin(),a.end()
#define M 998244353
#define limit 100000000
void solve() {
	ll a,b; cin >> a >> b ;
	for(int i=0;i<=1000000;++i) {
		if(i*8/100 == a && i*10/100 == b) { cout << i ; return ; }
	}
	cout << -1 ;
}

int main() {

    fast;
	ll t=1;
	// cin>>t;
	rep(t) {
		solve() ;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main() {
    int n,m;
    cin>>n>>m;
    int d[101][101];
    for(int i=0;i<101;i++){
        for(int j=0;j<101;j++){
            if(i==j){
                d[i][j]=0;
            }else{
                d[i][j]=114514;
            }
        }
    }
    int a[1001]={};
    int b[1001]={};
    int c[1001]={};
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;
        b[i]--;
        d[a[i]][b[i]]=min(d[a[i]][b[i]],c[i]);
        d[b[i]][a[i]]=min(d[b[i]][a[i]],c[i]);
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int ans=m;
    for(int i=0;i<m;i++){
        bool sai=false;
        for(int j=0;j<n;j++){
            if(d[j][a[i]]+c[i]==d[j][b[i]]){             
                sai=true;
            }
        }
        if(sai==true){
            ans--;
        }
    }
    cout<<ans<<endl;
}   




Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        // 文字列の入力
		String[] s = sc.next().split("");
        StringBuilder buff = new StringBuilder();
        for (int i = 0; i < s.length; i++) {
          if (i % 2 == 0) {
            buff.append(s[i]);
          }
        }
    
		// 出力
		System.out.println(buff.toString());
	}
}


Measured memory_bytes: 30144
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int x = N * 800;
		int y = (N / 15) * 200;
		int sum = x-y;
		System.out.print(sum);
		sc.close();
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int a,b,c,d; cin  >> a >> b >>c >>d;
    int x = c - a; int y = d- b;
    cout << c-y << " " << d + x << " " << a-y << " " << b + x << endl;
}



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

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

using namespace std;

int main() {
	while (1) {
		int a, b, tmp;
		cin >> a >> b;
		if (a == 0 and b == 0) {
			break;
		}
		if (a > b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		cout << a << " " << b << endl;
	}
	return 0;
}



Measured memory_bytes: 3076
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int min_depth = 0;
  int ini_depth = 0;
  rep (i, n) {
    if (s[i] == '(') {
      ini_depth += 1;
    } else {
      ini_depth -= 1;
    }
    min_depth = min(min_depth, ini_depth);
  }

  string ans;
  rep (i, -min_depth) {
    ans += '(';
  }
  ans += s;
  rep (i, ini_depth - min_depth) {
    ans += ')';
  }

  /*
  rep (i, n) {
    if (s[i] == '(') {
      depth += 1;
      ans += '(';
    } else {
      if (depth > 0) {
        depth -= 1;
        ans += ')';
      } else {
        ans += "()";
      } 
    }
  }
  if (depth > 0) {
    rep (i, depth) {
      ans += ')';
    }
  }
  */

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{
	int to,cap,cost,rev;
};
typedef vector<edge> ve;
typedef vector<ve> vve;
class MCF{	//Minimum Cost Flow
	public:
	int n;
	vve G;
	vi h,dist,prev,pree;
	MCF(int size){
		n=size;
		G=vve(n);
		h=dist=prev=pree=vi(n);
	}
	void add_edge(int s,int t,int ca,int co){
		edge e={t,ca,co,G[t].size()};
		G[s].pb(e);
		edge ee={s,0,-co,G[s].size()-1};
		G[t].pb(ee);
	}
	int mcf(int s,int t,int f){
		int out=0;
		h=vi(n);
		while(f>0){			
			priority_queue<pii,vector<pii> >q;
			dist=vi(n,inf);
			dist[s]=0;
			q.push(pii(0,s));
			while(!q.empty()){
				pii p=q.top();q.pop();
				int v=p.second;
				if(dist[v]<-p.first)continue;
				rep(i,G[v].size()){
					edge &e=G[v][i];
					if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
						dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
						prev[e.to]=v;
						pree[e.to]=i;
						q.push(pii(-dist[e.to],e.to));
					}
				}
			}
			if(dist[t]==inf)return -1;
			rep(i,n)h[i]+=dist[i];
			int d=f;
			for(int v=t;v!=s;v=prev[v])d=min(d,G[prev[v]][pree[v]].cap);
			f-=d;
			out+=d*h[t];
			for(int v=t;v!=s;v=prev[v]){
				edge &e=G[prev[v]][pree[v]];
				e.cap-=d;
				G[v][e.rev].cap+=d;
			}
		}
		return out;	
	}
};
int main(){
	int n;
	cin>>n;
	map<int,int>ma;
	int co=0;
	int sum=0;
	vp in;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		sum+=a+b;
		in.pb({a,b});
		if(ma[a]==0)ma[a]=++co;
		if(ma[b]==0)ma[b]=++co;
	}
	MCF mcf(2+n+co);
	int s=n+co,t=s+1;
	rep(i,n)mcf.add_edge(s,i,1,0);
	rep(i,co)mcf.add_edge(n+i,t,1,0);
	rep(i,n){
		mcf.add_edge(i,n+ma[in[i].first]-1,1,in[i].first);
		mcf.add_edge(i,n+ma[in[i].second]-1,1,in[i].second);
		mcf.add_edge(i,t,1,in[i].first+in[i].second);
	}
	int flow=mcf.mcf(s,t,n);
	cout<<sum-flow<<endl;
}

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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXSIZE 

LL n,m;
string t1,t2;

int main(){	
		//wynika nam ze nadal pod te same wartosci zachodzimy
		//i poplatanie z gcd
		
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>m;
	cin>>t1>>t2;
	
	if(n<m){
		swap(n,m);
		swap(t1,t2);
	}
	
	LL wyn=__gcd(n,m);
	
	LL par=(n*m)/wyn;
	
//	if(par==1){
//		cout<<wyn;
//		return 0;
//	}
	
	int mozna=1;
	LL par_1=par/n;
	LL par_2=par/m;
	
	for(LL i=0;i*par_1<m;i++){
		if(t1[par_2*i]!=t2[par_1*i])
			mozna=0;
	}
	
	if(mozna)
		cout<<par;
	else
		cout<<-1;
	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();

        List<int> exist = new List<int>();
        int now = a;
        while (true)
        {
            int mod = now % b;
            if (mod == c)
            {
                Console.WriteLine("YES");
                return;
            }
            if (exist.Contains(mod))
            {
                break;
            }
            exist.Add(mod);
            now += a;
        }

        Console.WriteLine("NO");
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

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

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

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = m; i >= l; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define u_map           unordered_map
#define fi              first
#define se              second
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             INT_MAX
#define ool             LLONG_MAX
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define vi              vector<int>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(int x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
const int base = 311;


const int N = 2e5 + 10;


ll n, m, k, ans, a[N], f[N];

void Solve(){
    cin >> n;
    cout << n * (n - 1) / 2;
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    Solve();
    return 0;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(100005);

vector<int> t[100005];
int k;
mint ans;

mint f(int n, int k){
  if (n<0)return 0;
  mint res=comb(n,k);
  res*=comb.fact[k];
  return res;
}



void dfs(int v, int p=-1){
  for(int to:t[v]){
    if (to==p)continue;
    dfs(to,v);
  }
  int nnow,know;
  if (p==-1)know=t[v].size()+1;
  if (p!=-1)know=t[v].size()-1;
  if (p==-1)nnow=k;
  if (p!=-1)nnow=k-2;
  ans*=f(nnow,know);


}



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

  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  ans=1;
  dfs(0);
cout<<ans.x<<endl;





  }


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

int main()
{
	char S[4], T[4];
	int count = 0;

	scanf("%s%s", S, T);

	for (int i = 0; i < 3; i++)
	{
		if (S[i] == T[i])
			count++;
	}

	printf("%d\n", count);
}

Measured memory_bytes: 128
#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()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  int64_t N, M;
  cin >> N >> M;
  vector<int64_t> a(N);
  rep(i, N){
    cin >> a.at(i);
  }
  sort(all(a));
  int64_t g = a.at(N-1) / 2;
  bool fnd = false;
  while(g <= M){
    rep(i, N){
      if(g % a.at(i) != a.at(i) / 2){
        break;
      }
      if(i == N-1){
        fnd = true;
      }
    }
    if(fnd){
      break;
    }
    g += a.at(N-1);
  }
  if(g <= M){
    cout << (M - g) / (2 * g) + 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 1024
### constant

MAX_D = 30

### main

loop do
  n = gets.to_i
  break if n == 0

  chrs = []
  diss = []
  dcounts = MAX_D.times.map{0}

  n.times do
    chr, m, *ds = gets.strip.split
    dis = ds.map{|d| d.to_i}

    chrs << [0, chr]
    diss << dis

    for d in dis
      dcounts[d] += 1
    end
  end
  #p dcounts

  for i in (0...n)
    for d in diss[i]
      chrs[i][0] += (n + 1 - dcounts[d])
    end
  end

  puts chrs.sort[0].join(' ')
end

Measured memory_bytes: 6132
#include <stdio.h>

int main(void) {
	int n,i;
	int maxa,maxv;
	int a,v;
	maxa=1000000;maxv=0;
	scanf("%d",&n);
	for(i=0;i<n;i++) {
		scanf("%d%d",&a,&v);
		if(v>maxv || (v==maxv && a<maxa)) {
			maxa=a;maxv=v;
		}
	}
	printf("%d %d\n",maxa,maxv);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    string snum;
    int num, d;
    int min = 1000;
    for (int i = 0; i + 2 <= S.size(); i++)
    {
        snum = S.substr(i, 3);
        num = stoi(snum);
        d = abs(753 - num);
        if (d < min) min = d;
    }

    cout << min << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	ll ans = 1;
	rep(i,n){
		ans *= i + 1;
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))

ma = a[0]
ans = 0
for i in range(1,n):
    if ma > a[i]:
        ans+= ma-a[i]
    else:
        ma = a[i]

print(ans)

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

const int MAX_N = 100000;

class UnionFind {
private:
  int N;
  int par[MAX_N];
  int rank[MAX_N];

public:
  UnionFind(int size) : N(size) {
    for (int i=0; i<N; i++) {
      par[i] = i;
      rank[i] = 0;
    }
  }

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

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

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

int main() {
  int n, m, q;
  cin >> n >> m;
  UnionFind uf(n);

  for (int i=0; i<m; i++) {
    int s, t;
    cin >> s >> t;
    uf.unite(s, t);
  }
  cin >> q;
  for (int i=0; i<q; i++) {
    int s, t;
    cin >> s >> t;
    cout << (uf.same(s, t)?"yes":"no") << endl;
  }
  return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n+1,0);
    rep(i,n)cin >> a[i+1];
    vector<vector<ll>> dp(n+2,vector<ll>(2,0));
    dp[0][1] = -INF;
    repp(i,1,n+1){
        dp[i][0] = max(dp[i-1][0] + a[i], dp[i-1][1] - a[i]);
        dp[i][1] = max(dp[i-1][0] - a[i], dp[i-1][1] + a[i]);
    }
    cout << dp[n][0] << endl;
    return 0;
}

Measured memory_bytes: 9576
N, M, X = map(int, input().split())
li_a = []
li_c = []
for _ in range(N):
    temp = list(map(int, input().split()))
    li_temp = []
    for i in range(len(temp)):
        if i == 0:
            li_c.append(temp[i])
        else:
            li_temp.append(temp[i])
    li_a.append(li_temp)
min_ = 10**15
for s in range(1<<N):
    money = 0
    dic = {}
    for i in range(M):
        dic[i] = 0
    for j in range(N):
        if (1<<j) & s:
            money += li_c[j]
            for k in range(len(li_a[j])):
                dic[k] += li_a[j][k]
    b = True
    for i in range(M):
        if dic[i] < X:
            b = False
            break
    if b:
        min_ = min(min_, money)
    
if min_ == 10**15:
  print(-1)
else:
    print(min_)


Measured memory_bytes: 68692
h, w, k = map(int, input().split())
m = [input() for _ in range(h)]
crows = [line.count('#') for line in m]
ccols = [0] * w
for j in range(w):
    for i in range(h):
        ccols[j] += (m[i][j] == '#')
sharps = sum(crows)

from itertools import combinations
if sharps < k:
    print(0)
else:
    ans = 0
    for hi in range(2**h):
        for wi in range(2**w):
            combs = sharps
            remh = []
            for hj in range(h):
                if (hi>>hj)&1:
                    remh.append(hj)
                    combs -= crows[hj]
            remw = []
            for wj in range(w):
                if (wi>>wj)&1:
                    remw.append(wj)
                    combs -= ccols[wj]
            
            for hh in remh:
                for ww in remw:
                    if m[hh][ww] == '#':
                        combs += 1
            
            if combs == k:
                ans += 1
    print(ans)


Measured memory_bytes: 74196
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=305;
int mod;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int C[MAXN][MAXN],f[MAXN][MAXN],h[MAXN][MAXN],pre[MAXN][MAXN],n,K;
int main()
{
	n=read();K=read();mod=read();
	for(int i=0;i<MAXN;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)C[i][j]=C[i-1][j],ad(C[i][j],C[i-1][j-1]);
	}
	for(int i=0;i<=K;i++)f[1][i]=1;
	for(int i=2;i<=n+1;i++)
	{
		for(int j=1;j<i;j++)for(int k=K,sum=0;k>=0;k--)
		{
			ad(sum,f[j][k+1]);
			ad(f[i][k],1LL*sum*f[i-j][k]%mod*C[i-2][j-1]%mod);
		}
	}pr2(f[n+1][0]);
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
ll st[4*300000+2];
void solve()
{
  
       // GENERAL PURPOSE SEGMENT TREE FOR RMQ
       
   
       ll n,k;
       
       cin>>n>>k;
       
        ll a[n];
       
       
       for(ll i=0;i<n;i++)
       cin>>a[i];
       
 
    function<void(ll,ll,ll,ll,ll)>update=[&](ll ss,ll se,ll si,ll id,ll val){
      if(ss==se&&ss==id){
          st[si]=val;
          return;
      }
      
      if(id>se||id<ss)
      return;
      
      ll mid=(ss+se)/2;
      
      update(ss,mid,2*si+1,id,val);
      update(mid+1,se,2*si+2,id,val);
      
      st[si]=max(st[2*si+1],st[2*si+2]);
    };
    
    
    function<ll(ll,ll,ll,ll,ll)>get_min=[&](ll ss,ll se,ll si,ll l,ll r){
        
        if(l>r)
        
        return 0LL;
        
        
        if(r<ss||se<l)
        return 0LL;
        
        if(ss>=l&&se<=r)
        return st[si];
        
        ll mid=(ss+se)/2;
        
        
        return max(get_min(ss,mid,2*si+1,l,r),get_min(mid+1,se,2*si+2,l,r));
        
    };
    
   // build_sgt(0,30000,0);
    
    ll dp[300000+1];
    
    
    for(ll i=0;i<300000LL+1LL;i++){
         update(0LL,300000LL,0LL,i,0LL);
         
         dp[i]=0;
    }
    
    
    ll ans=0LL;
    
   
    for(ll i=0;i<n;i++){
        ll l=max(0LL,a[i]-k);
        ll r=min(300000LL,a[i]+k);
        
        
         
        ll res=get_min(0LL,300000LL,0LL,l,r);
        
         update(0LL,300000LL,0LL,a[i],1LL);
        
        dp[a[i]]=max(dp[a[i]],1+res);
        
        update(0LL,300000LL,0LL,a[i],dp[a[i]]);
    }
    
    
    for(ll i=0;i<n;i++)
    ans=max(ans,dp[a[i]]);
    
    cout<<ans<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

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

int main(){
    ll N,K,Q;
    cin >> N >> K >> Q;
    vector<ll> score(N,0);
    rep(i,Q){
        ll ans;
        cin >> ans;
        ans--;
        score[ans]++;
    }

    rep(i,N){
        if((Q-score[i])<K) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
n, k = map(int, input().split())
s = input()

right = 0
res = 0
zero_area = 1 if s[0] == '0' else 0
for left in range(n):
    if left > 0:
        if s[left-1] == '0' and s[left] == '1':
            zero_area -= 1
    while right < n-1:
        if s[right] == '1' and s[right+1] == '0':
            if zero_area + 1 > k:
                break
            zero_area += 1
        right += 1
    res = max(res, right - left + 1)

print(res)

Measured memory_bytes: 3316
n=input()
while n:
  s=raw_input()
  A=s[0]
  for i in range(0,len(s),3):
    if s[i:i+3]==(A[-1]+"->"): A+=s[i+3]
    elif s[i:i+3]==(A[0]+"<-"): A=s[i+3]+A
  print "".join(A)
  n-=1

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
#define INF pow(10, 9)

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> candles(n);
    for(int i=0; i<n; i++) cin >> candles[i];

    vector<int>answers(n, INF);
        
    for(int i=0; i<=n-k; i++) {
        int position = 0; 
        answers[i] = 0;

        if(abs(candles[i]) < abs(candles[i+k-1])) {
            answers[i] += abs(position - candles[i]); 
        } else {
            answers[i] += abs(position - candles[i+k-1]); 
        }
        answers[i] += abs(candles[i+k-1] - candles[i]);
    }
    
    cout << *min_element(answers.begin(), answers.end()) << endl;
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

// integerの各桁を足す
int sum_digits(int num) {
    int rtn = 0;
    string num_str = to_string(num);
    for(int i=0; i<num_str.size(); i++) {
        rtn += num_str[i] - '0';
    }   
    return rtn;
}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}

Measured memory_bytes: 1024
//#include <ext/pb_ds/assoc_container.hpp> 
     //#include <ext/pb_ds/tree_policy.hpp> 
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    #include <cstring>
    #include <vector>
    #include <deque>
    #include <queue>
    #include <set>
    #include <map>
    #include <valarray>
    #include <iterator>
    #include <functional>
    #include <limits>
    #include <algorithm>
    #include <numeric>
    #include <cmath>
    #include <cassert>
    #include <unordered_map>
    #include <unordered_set>
    #include <stack>
    using namespace std;
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define trace(x) cerr << #x << ": " << x << " " << endl;
     
    typedef int64_t ll;
     
    #define endl '\n'
    #define int ll
    ll mod=1e18;
    ll mod1=1e9+5;
     
    ll power(ll a,ll b)
    {
        if(b==0) return 1;
        else if(b%2==0)
            return power((((a%mod)*(a%mod))%mod),b/2)%mod;
        else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
    }
     
   //  using namespace __gnu_pbds;
     //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
    //find_by_order(k)  returns iterator to kth element starting from 0;
    //order_of_key(k) returns count of elements strictly smaller than k;
    //erase,insert same as normal set
  

    int32_t main()
    {
        IOS
   
        int n;
        cin>>n;
        int a[n+1];
        for(int i=1;i<=n;++i)
            cin>>a[i];
        int ans=1e18;
        for(int i=-1;i<=101;i++)
        {
            int sum=0;
            for(int j=1;j<=n;++j)
                sum+=power(abs(a[j]-i),2);
            ans=min(ans,sum);
        }
        cout<<ans;



    }       

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

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

  if (N % 2 == 1) {
    cout << "No" << endl;
  } else {
    string h = S.substr(0, N / 2);
    if ((h + h) == S) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
if n>=m:
  print(0)
else:
  dif_l=[]
  for i in range(m-1):
    dif_l.append(l[i+1]-l[i])
  dif_l.sort()
  sum=0
  for j in range(m-n):
    sum+=dif_l[j]
  print(sum)

Measured memory_bytes: 13960
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

int K, X;

int main() {
    cin >> K >> X;

    if (500 * K >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256