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

typedef vector<int> vi;
#define ll long long
#define loop(i,n) for(int i=0; i<n; i++)
#define loop1(i,n) for(int i=1; i<=n; i++)
#define loopi(i,s,e) for(int i=s; i < e; i++)
#define loopiRev(i,s,e) for(int i=s; i >= e; i--)
#define PI 3.14159265359
#define x first
#define y second
#define point pair<ll,ll>
#define len(s)   (int)s.length()
#define sz(v)    (int)v.size()
#define all(a)   a.begin(),a.end()
#define clr(x, val)	memset((x), (val), sizeof(x))

//you don't know math, unless you can do math!
queue<string> q;
int OO = 1e5;
int h,w;
char grid[100][100];
int dp[100][100][100];
bool valid(int r, int c){
    return (r >= 0 && r < h && c >= 0 && c < w);
}

int path(int r, int c, int cnt){
    int &ret = dp[r][c][cnt];
    if(ret != -1) return ret;

    if(r == h-1 && c == w-1) return cnt;

    int path1 = OO, path2 = OO;

    if(valid(r, c+1)) path1 = path(r, c+1, cnt + (grid[r][c] == '.' && grid[r][c+1] == '#'));
    if(valid(r+1, c)) path2 = path(r+1, c, cnt + (grid[r][c] == '.' && grid[r+1][c] == '#'));

    ret= min(path1, path2);
    return ret;

}
int main() {
    //freopen("input.txt" , "r" , stdin) ;
    //freopen("output.txt" , "w" , stdout) ;

    cin.tie(0);
    cin.sync_with_stdio(0);
    clr(dp, -1);

    cin>>h>>w;
    loop(i, h) loop(j, w) cin>>grid[i][j];

    cout<<path(0,0,grid[0][0] == '#');

}


Measured memory_bytes: 4224
#include<iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a <= 5) {
    cout << 0 << endl;
  }
  if (6 <= a && a <= 12) {
    cout << b/2 << endl;
  }
  if (13 <= a) {
    cout << b << endl;
  }
  return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}
const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<>
void add(int& a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<>
void sub(int& a,int b){
	a-=b;
	if(a<0)a+=mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

struct BIT{
	vi d;
	void Init(int n){
		d.assign(n,0);
	}
	void Add(int i,int v){
		while(i<(int)d.size()){
			d[i]+=v;
			i+=(i+1)&(-i-1);
		}
	}
	int Get(int i){
		int ret=0;
		while(i>=0){
			ret+=d[i];
			i-=(i+1)&(-i-1);
		}
		return ret;
	}
};

int main(){
	vector<ll> fact({1});
	FOR(i,1,1141919)
		fact.PB(fact.back()*i%mod);
	auto comb=[&](int a,int b){
		if(a<0||b<0||b>a)
			return 0LL;
		return fact[a]*modInv(fact[b])%mod*modInv(fact[a-b])%mod;
	};
	int n=read();
	vi p;
	vector<bool> canUse(n,true);
	REP(i,n){
		int x=read()-1;
		p.PB(x);
		if(x>=0)
			canUse[x]=false;
	}
	vi w;
	REP(i,n)if(canUse[i])
		w.PB(i);
	ll ans=0;
	BIT bit;
	bit.Init(n);
	ll q=0;
	int sel=0;
	for(int i=n-1;i>=0;i--){
		if(p[i]!=-1){
			int low=bit.Get(p[i]);
			int canSel=lower_bound(w.begin(),w.end(),p[i])-w.begin();
			add(ans,fact[n-1-i]*low%mod*
					comb((int)w.size(),sel)%mod*fact[sel]%mod*fact[(int)w.size()-sel]);
			add(ans,fact[n-1-i]*canSel%mod
					*comb((int)w.size()-1,sel-1)%mod*fact[sel]%mod*fact[(int)w.size()-sel]);
			bit.Add(p[i],1);
			q+=(int)w.size()-canSel;
			q%=mod;
		}else{
			add(ans,fact[n-1-i]*q%mod
					*comb((int)w.size()-1,sel)%mod*fact[sel]%mod*fact[(int)w.size()-1-sel]);
			add(ans,fact[n-1-i]*(((ll)w.size()*((int)w.size()-1)/2)%mod)%mod
					*comb((int)w.size()-1-1,sel-1)%mod*fact[sel]%mod*fact[(int)w.size()-1-sel]);
			sel++;
		}
	}
	cout<<(ans+fact[sel])%mod<<endl;
}


Measured memory_bytes: 16744
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#include <list>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
const int MAXN = 500001;

struct node {
	int next[26];
	int len;
	int sufflink;
	int num;

	int cou = 0;
	int kth = 1;
};

int len;
char s[MAXN];
node tree[MAXN];
int num;            // node 1 - root with len -1, node 2 - root with len 0
int suff;           // max suffix palindrome
long long ans;

bool addLetter(int pos) {
	int cur = suff, curlen = 0;
	int let = s[pos] - 'a';

	while (true) {
		curlen = tree[cur].len;
		if (pos - 1 - curlen >= 0 && s[pos - 1 - curlen] == s[pos])
			break;
		cur = tree[cur].sufflink;
	}
	if (tree[cur].next[let]) {
		suff = tree[cur].next[let];

		tree[suff].cou++;//
		return false;
	}

	num++;
	suff = num;
	tree[num].len = tree[cur].len + 2;
	tree[cur].next[let] = num;

	tree[num].cou++;//

	if (tree[num].len == 1) {
		tree[num].sufflink = 2;
		tree[num].num = 1;
		return true;
	}

	while (true) {
		cur = tree[cur].sufflink;
		curlen = tree[cur].len;
		if (pos - 1 - curlen >= 0 && s[pos - 1 - curlen] == s[pos]) {
			tree[num].sufflink = tree[cur].next[let];
			break;
		}
	}

	tree[num].num = 1 + tree[tree[num].sufflink].num;

	return true;
}

void initTree() {
	num = 2; suff = 2;
	tree[1].len = -1; tree[1].sufflink = 1;
	tree[2].len = 0; tree[2].sufflink = 1;
}

signed main() {
	scanf("%s", s);
	len = strlen(s);


	int cou[100] = {};
	ll ans = (1LL*(len-1) *(len-1) + len-1) / 2;
	REP(i, len) {
		cou[s[i] - 'a']++;
	}

	REP(i, 27) {

		ans -= 1LL*cou[i] * (cou[i] - 1) / 2;

	}
	printf("%lld\n", ans + 1);
	return 0;
}

Measured memory_bytes: 60928
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int main(){
//int ans=0,n=read(),k=read(),now=1;
//for (;now<n;++ans) now+=k-1;
//write(ans);
int n=read(),k=read();
write((n-2)/(k-1)+1); 
}

Measured memory_bytes: 256
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int x;

int main() {
  init_ios();
  cin >> x;
  if (x >= 30)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}

Measured memory_bytes: 3664
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
typedef pair<int, int> P;
int di[] = {-1, 0, 1, 0};
int dj[] = {0, -1, 0, 1};

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int h, w; cin >> h >> w;
		vector<string> s(h);
		rep (i, h) {
			cin >> s[i];
		}
		int ans = 0;
		rep (si, h) {
			rep (sj, w) {
				if (s[si][sj] == '#') continue;
				vector<vector<int>> dist(h, vector<int>(w, INF));
				queue<P> q;
				auto update = [&](int i, int j, int x) {
					if (dist[i][j] != INF) return;
					dist[i][j] = x;
					q.push(P(i, j));
				};
				update(si, sj, 0);
				while(!q.empty()) {
					int i = q.front().first;
					int j = q.front().second; q.pop();
					rep (dir, 4) {
						int ni = i + di[dir];
						int nj = j + dj[dir];
						if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
						if (s[ni][nj] == '#') continue;
						update(ni, nj, dist[i][j] + 1);
					}
				}
				rep (p, h) {
					rep (q, w) {
						if (dist[p][q] != INF) ans = max(ans, dist[p][q]);
					}
				}
			}
		}
		cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<set>
#include<vector>
using namespace std;
bool solve(int n){
    int aaa[3];
    aaa[0]=0;
    aaa[1]=0;
    aaa[2]=0;
    int s=n;
    while(n>0){
        int x=n%10;
        n=n/10;
        if(x==3){
            aaa[0]=1;
        }else if(x==7){
            aaa[1]=1;
        }else if(x==5){
            aaa[2]=1;
        }else{return false;}
    }
    if(aaa[0]==1&&aaa[1]==1&&aaa[2]==1){return true;}
    else{ return false;}
}
int cont(int n,int j){
    int u=1,s=1;
    for(int i=0;i<j;i++){
        u=u*(n-i);
    }
    for(int i=1;i<=j;i++){
        s=s*i;
    }
    return u/s;
}
int main(){
    int s;
   cin>>s;
    double a=s;
    int n=0;
    while(a>=1){
        a=a/10;
        n++;
    }
    if(n<3){cout<<0<<endl;
        return 0;}
    int preans=0;
    for(int i=3;i<=n-1;i++){
        double k=pow(3,i);
        k=k-3;
        int u=i/2;
        for(int j=1;j<=u;j++){
            int y=cont(i,j);
            if(i%2==0&&i/2==j){
                k=k-(y*3);
            }else{k=k-y*2*3;}
        }
        preans+=k;
    }
  //  cout<<preans<<endl;
    int j=pow(10,n-1);
    int nn=3*pow(10,n-1);
    int nnn=5*pow(10,n-1);
    int nnnn=7*pow(10,n-1);

    int cnt=0;
    for(int i=nn;i<=s&&i<j*4;i++){
        if(solve(i))cnt++;
    }
    for(int i=nnn;i<=s&&i<j*6;i++){
        if(solve(i))cnt++;
    }
    for(int i=nnnn;i<=s&&i<j*8;i++){
        if(solve(i))cnt++;
    }    int ans= preans+cnt;
    
    cout<<ans<<endl;


return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);    
    
       map<char, int> vals;
    vals.insert(mp('A', 3)); vals.insert(mp('C', 2)); vals.insert(mp('G', 1)); vals.insert(mp('T', 0));
    string S; cin >> S;
    int ans = 0;
    int best = 0;
    F0R(i, sz(S)) {
		if (vals.count(S[i])) {
			ans++; best = max(best, ans);
		} else ans = 0;
	}
	cout << best << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 256
using System;

class Pratice
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[,,] person = new int[4, 3, 10];
        for (int i = 0; i < n; ++i)
        {
            string[] str = Console.ReadLine().Split(' ');
            person[int.Parse(str[0]) - 1, int.Parse(str[1]) - 1, int.Parse(str[2]) - 1] += int.Parse(str[3]);
        }
        for (int b = 0; b < 4; ++b)
        {
            for (int f = 0; f < 3; ++f)
            {
                for (int r = 0; r < 10; ++r)
                {
                    Console.Write(" {0}", person[b, f, r]);
                }
                Console.WriteLine();
            }
            if (b != 3) Console.WriteLine("####################");
        }
    }
}


Measured memory_bytes: 18012
s = input()[::-1]
while s:
  start = len(s)
  for t in ['maerd', 'remaerd', 'esare', 'resare']:
    if t == s[:len(t)]:
      s = s[len(t):]
  if start == len(s):
    break
print("YNEOS"[len(s)>0::2])

Measured memory_bytes: 3188
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <cmath>

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100000;
const int INF = (1<<12);

int main() {
  int N, Q;
  ll ans = 0;
  cin >> N;
  vector<int> A(MAX + 1);
  rep(i,MAX + 1) A[i] = 0;
  rep(i,N){
    int a;
    cin >> a;
    A[a] += 1;
    ans += a;
  } 
  cin >> Q;
  rep(i,Q){
    int B, C;
    cin >> B >> C;
    if (A[B]){
      ans += (C - B) * A[B];
      A[C] += A[B];
      A[B] = 0;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3784
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<std::string> S(N);
  map<char, ll> mp;
  for (int i = 0; i < N; i++)
  {
    std::cin >> S[i];
    mp[S[i][0]]++;
  }
  vector<char> t = {'M', 'A', 'R', 'C', 'H'};
  ll ans = 0;
  for (int i = 0; i < t.size(); ++i)
  {
    for (int j = i + 1; j < t.size(); ++j)
    {
      for (int k = j + 1; k < t.size(); ++k)
        ans += mp[t[i]] * mp[t[j]] * mp[t[k]];
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    string s;
    cin >> s;

    int cum_right = 0, sum_left = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == ')') {
            ++cum_right;
            if (sum_left > 0) {
                --cum_right;
                --sum_left;
            }
        } else {
            ++sum_left;
        }
    }

    for (int i = 0; i < max(0, cum_right); ++i) {
        s = '(' + s;
    }
    n += max(0, cum_right);
    int cum_left = 0, sum_right;
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == '(') { 
            ++cum_left;
            if (sum_right > 0) {
                --cum_left;
                --sum_right;
            }
        } else {
            ++sum_right;
        }
    }

    for (int i = 0; i <  max(0, cum_left); ++i) {
            s = s + ')';
    }

    cout << s << endl;

    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define show(x) cerr << #x << " " << x << endl

typedef long long ll;
typedef unsigned long long ull;

constexpr const int INT_INF=0x3f3f3f3f; // 1061109567
constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f; // 4557430888798830399

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

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

// INT
#define GCD(a, b) __gcd(a, b)
template <typename T> T LCM(T a, T b) {return a / GCD(a, b) * b;}
template <typename T> T EXTGCD(T a, T b, T& x, T& y) {
    T d = a;
    if (b != 0) {d=EXTGCD(b,a%b,y,x);y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> bool is_prime(T a) {
    for(int i=2;i*i<=a;i++)if(a%i==0)return 1;
    return 0;
}

// MOD
const ll MOD = 1000000000 + 7;
#define add(a, b) ((a % MOD) + (b % MOD)) % MOD
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define sub(a, b) ((a % MOD) + MOD - (b % MOD)) % MOD
template <typename T> T mod_inverse(T a, T mod, bool prime){ // if mod is prime, "prime" is true.
    if(prime){
        T tmp=mod-2,now=a,res=1;while(tmp){if(tmp&1)res=mul(res,now);now=mul(now,now);tmp>>=1;}
        return res;
    }else{T x,y;EXTGCD(a,mod,x,y);return (mod+x%mod)%mod;}
}
#define divide(a, b) ((a % MOD) * (mod_inverse(b, MOD, true))) % MOD

//LLの数値をつかう時は最後にLをつける癖をつけよう
//
//  　　┓　　　┏
//  　＊┗┓　┏┛
//  　　　┫　┣　＊
//  　┏┳┻━┻┳┓
//  　┗┫　　　┣┛
//  ＊　┣　　━┃　＊        Merry Christmas!!
//  　┏┛　　〃┃
//  　┃●　　　┣━┳┓
//  　┗┻┳━━┛　┣┛
//  　＊　┃┏┓┣┓┃
//WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

const int maxn = 100001;
int n;
ll l;
int a[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1 = freopen("/Users/aim_cpo/CLionProjects/competitive/in.txt", "r", stdin);
    //stream2 = freopen("out.txt", "w", stdout);
    if (stream1 == nullptr) return 0;
    //if (stream2 == NULL) return 0;
#endif
    cin >> n >> l;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int res = -1;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] + a[i + 1] >= l) {
            res = i;
            break;
        }
    }
    if (res == -1) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    res++;
    for (int i = 1; i < res; i++) {
        cout << i << endl;
    }
    for (int i = n - 1; i > res; i--) {
        cout << i << endl;
    }
    cout << res << endl;
#ifdef  LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long int lli;
typedef long long ll;

int main(){
    string s,t; cin >> s >> t;
    int n = s.size();

    map<char,char> m;

    vector<string> out = {"Yes","No"};
    int ans = 0;
    rep(i,n){
        if(m[s[i]] == '\0') m[s[i]] = t[i];
        else if(m[s[i]] != t[i]){
            ans = 1;
            break;
        }
    }

    m.clear();
    rep(i,n){
        if(m[t[i]] == '\0') m[t[i]] = s[i];
        else if(m[t[i]] != s[i]){
            ans = 1;
            break;
        }
    }

    cout << out[ans] << endl;
    
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
#define max1 1000001

//long long int mod=1e18 ;


int main(){	
	int n;
	cin>>n;
	vector<int> h(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	//int dp[n+1]={0};
	int l2=0;
	int l1=abs(h[1]-h[0]);
	for (int i = 3; i <=n; ++i)
	{
		int l0=min(l1+abs(h[i-1]-h[i-2]),l2+abs(h[i-1]-h[i-3]));
		l2=l1;
		l1=l0;
	}
	cout<<l1<<endl;


}
	
	
	
	





Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int X;
    cin>>X;
    int keynum=X/50;
    int count=0;
    for (int p=0;p<=a;p++){
        for (int q=0; q<=b; q++){
            for(int r=0;r<=c; r++){
                int keynum1=keynum;
                keynum1-=10*p+2*q+r;
                if(keynum1==0) count++;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define ll long long
typedef pair<int, int> P;

int main(){
  int n[4];
  rep(i, 4) {
    cin >> n[i];
  }
  sort(n, n+4);
  if (n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9) {
    cout << "YES" <<endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int[] list = {13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
        int a = in.nextInt();
        int b = in.nextInt();
        if(a == b){
            System.out.println("Draw");
        }else{
            System.out.println(list[a - 1] > list[b - 1] ? "Alice" : "Bob");
        }
    }
}


Measured memory_bytes: 21972
a, b, c, d = list(map(int, list(input())))
if a + b + c + d == 7:
    print("{0}+{1}+{2}+{3}=7".format(a, b, c, d))
elif a + b + c - d == 7:
    print("{0}+{1}+{2}-{3}=7".format(a, b, c, d))
elif a + b - c + d == 7:
    print("{0}+{1}-{2}+{3}=7".format(a, b, c, d))
elif a - b + c + d == 7:
    print("{0}-{1}+{2}+{3}=7".format(a, b, c, d))
elif a - b - c + d == 7:
    print("{0}-{1}-{2}+{3}=7".format(a, b, c, d))
elif a - b + c - d == 7:
    print("{0}-{1}+{2}-{3}=7".format(a, b, c, d))
elif a + b - c - d == 7:
    print("{0}+{1}-{2}-{3}=7".format(a, b, c, d))
elif a - b - c - d == 7:
    print("{0}-{1}-{2}-{3}=7".format(a, b, c, d))

Measured memory_bytes: 3064
#editorial
#累積和と尺取り
n = int(input())
a = list(map(int, input().split( )))
asum = 0
a_sum = []
for i in range(n):
    asum += a[i]
    a_sum.append(asum)


j = 1
k = 3

b = a[0]
c = a[1]
d = a[2]
e = asum-b-c-d

ans = asum

for i in range(2,n):
    while abs(b+a[j] -(c-a[j]))<=abs(b-c) and j<i:
        #a>0なのでjがiを超えることはない
        b+=a[j]
        c-=a[j]
        j+=1
    while abs(d+a[k] -(e-a[k]))<=abs(d-e) and k<n-1:
        d += a[k]
        e -= a[k]
        k+=1
    #print(b,c,d,e,max(b,c,d,e),min(b,c,d,e),ans)
    ans = min(ans, max(b,c,d,e)-min(b,c,d,e))
    c += a[i]
    d -= a[i]
    
print(ans)
    


Measured memory_bytes: 118904
#include<stdio.h>
   
int main(){
  int x,y;

  while(1){
    scanf("%d%d",&x,&y);

    if(x==0 && y==0) {
      break;
    }else if(x<y){
      printf("%d %d\n",x,y);
    }else{
      printf("%d %d\n",y,x);
    }
  }

  return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <vector>
#include <algorithm>
     
using namespace std;
     
int main(void){
     
  int n;

  cin >> n;

  if(n == 1) cout << 1;
  else if(n%2 == 1) cout << n/2*(n+1)+n/2+1;
  else cout << n/2*(n+1);
  cout << endl;
     
  return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

void chmin(int &a, int b) {
	a = min(a, b);
}
void chmax(int &a, int b) {
	a = max(a, b);
}
ll mod_pow(ll a, ll n, ll m = mod) {
	a %= m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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


void solve() {
	int n; cin >> n;
	n %= 10;
	if (n == 3)cout << "bon\n";
	else if (n == 0 || n == 1 || n == 6 || n == 8)cout << "pon\n";
	else cout << "hon\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	solve();
	stop
		return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define REP(i,n) for(int i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")

using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;

const int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int dy[8] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1; 


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

  int n;
  cin >> n;
  vi a(n+2);
  a[0] = 0;
  a[n+1] = 0;
  for(int i = 1; i <= n; i++) cin >> a[i];
  ll sum = 0;
  for(int i = 1; i <= n+1; i++) sum += abs(a[i]-a[i-1]);
  //cout << sum << endl << endl;
  for(int i = 1; i <= n; i++){
    ll ans = sum;
    if((a[i]<a[i-1] && a[i]<a[i+1]) || (a[i]>a[i-1] && a[i]>a[i+1])){
      ans -= min(abs(a[i]-a[i-1]), abs(a[i]-a[i+1])) * 2;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
# define ll long long
# define mo 1000000009
using namespace std;
int main()
{
	ll n,mini,k;
	cin>>n>>k;
	ll a[n],dp[n];
	for(ll i=0;i<n;i++)
	cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(ll i=2;i<n;i++)
	{
		mini=10000000000;
		for(ll j=i-1;j>=i-k&&j>=0;j--)
		{
			if(abs(a[i]-a[j])+dp[j]<mini)
			mini=abs(a[i]-a[j])+dp[j];
		}
		dp[i]=mini;
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1792
import heapq

n, k = map(int, input().split())
h = [-1 * int(i) for i in input().split()]
heapq.heapify(h)

if n <= k:
    print(0)
    exit()

for i in range(k):
    heapq.heappop(h)

print(-1*sum(h))


Measured memory_bytes: 25896
<?php
fscanf(STDIN, "%d", $N);

$ansList = [];

for($i = 0; $i < $N; $i++) {
	fscanf(STDIN, "%d", $A);
	
	if(array_key_exists($A, $ansList) !== false) {
		unset($ansList[$A]);
	}
	else {
		$ansList[$A] = 1;
	}
}

$ans = count($ansList);


echo "{$ans}\n";


Measured memory_bytes: 13048
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    ll A,  B1, B2;
    char c;
    cin >> A >> B1 >> c >> B2;

    ll ans = A * (B1 * 100 + B2);
    ans /= 100;
    cout << ans << endl;

    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


int main() {
    ll n, m; cin >> n >> m;
    priority_queue<ll, V<ll>, less<ll>> que;
    for(int i = 0; i < n; i++){
        ll a; cin >> a;
        que.push(a);
    }

    while(m > 0){
        ll tmp = que.top();
        que.pop();
        tmp /= 2;
        m--;
        que.push(tmp);
    }

    ll sum = 0;
    while(!que.empty()){
        sum += que.top();
        que.pop();
    }
    cout << sum << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
int main() 
{

  fast();
  

    ll n;
    cin >> n;
    if(n==7||n==5||n==3)
    {
    	cout<<"YES";
    }
    else
    	cout<<"NO";
    

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

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

int main() {
    int N;
    cin >> N;
    int x[110000], y[110000], t[110000];
    x[0] = 0; y[0] = 0; y[0] = 0;
    
    for(int i = 0; i < N; i++) {
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }
    bool flag = true;
    for(int i = 0; i < N; i++) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if(dt < dist) {
            flag = false;
        }
        if(dist % 2 != dt % 2) {
            flag = false;
        }
    }
    string judge = flag? "Yes" : "No";
    cout <<  judge << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main()
{
	int N = 0;
	scanf("%d", &N);
    
    int i = 0;
    long long sum = 0;
	for(i = 1; i <= N; i++){
        if((0 != i%3) && (0 != i%5)){
            sum += i;
        }
    }

    printf("%lld\n", sum);

	return 0;
}

Measured memory_bytes: 1728
import Prelude

expire :: Int->Int->Int->String
expire x a b
	|b<=a 	= "delicious"
	|b>=a && b<=(a+x) = "safe"
	|otherwise = "dangerous"
 
main :: IO ()
main = do
    -- スペース区切り整数の入力
    [x, a, b] <- map read . words <$> getLine
    -- 出力
    putStrLn $ expire x a b

Measured memory_bytes: 508
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==0){
   out(b/c+1);
  }
  else
    out(b/c-(a-1)/c);
}


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

int main() {
    string word;
    int x;

    cin >> word;

    x = 0;
    
    for(int i = 0; i <= 2; i++){
       for(int k = i + 1; k <= 3; k++){
           if(word[i]==word[k]){
               x++;
           }
       }
    }
   
   if(x==2){
       cout << "Yes" << endl;
   }
    else{
       cout << "No" << endl;
       }
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    double l, r;
    int la = 0, ra = 0, lb = 0, rb = 0, lc = 0, rc = 0, ld = 0, rd = 0;
    while (cin >> l >> r) {
        if (l >= 1.1) la++;
        else if (l >= 0.6) lb++;
        else if (l >= 0.2) lc++;
        else ld++;
        if (r >= 1.1) ra++;
        else if (r >= 0.6) rb++;
        else if (r >= 0.2) rc++;
        else rd++;
    }
    cout << la << ' ' << ra << '\n' << lb << ' ' << rb << '\n' << lc << ' ' << rc << '\n' << ld << ' ' << rd << endl;
}


Measured memory_bytes: 3056
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




int main() {
    int n;
    cin >> n;
    vector<int> p(n) ;
    for (int i = 0; i < (int)(n); i++) cin >> p[i];
    int c = 0;
    for (int i = 1; i < (int)(n-1); i++) {
        if (p[i - 1] < p[i] && p[i] < p[i + 1])c++;
        if (p[i - 1] > p[i] && p[i] > p[i + 1])c++;
   }
    cout << c << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAX = 4001;

int dp[MAX][MAX];

int main(){
  string s1,s2;

  while(cin >> s1 >> s2){
    memset(dp,0,sizeof(dp));

    int n = s1.size() ,m = s2.size();
    int ans = -1; 
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < m ; j++){
	if(s1[i] == s2[j]){
	  dp[i+1][j+1] = dp[i][j] + 1;
	}
	ans = max(ans,dp[i+1][j+1]);
      }
    }

    cout << ans << endl;
  }


  return 0;
}

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    // const int n = 3;
    // int m = 3;
    // int x = 10;
    
    vector<int> bookdata(m+1,0); // 各本の価格及び各アルゴリズム理解度の期待上昇値を格納する配列
    vector<vector<int>> allbook(n,bookdata); // 全ての本のデータを格納する二次元配列
    // allbook = {
    //     {60,2,2,4},
    //     {70,8,7,9},
    //     {50,2,3,9},
    // };
    // allbook = {
    //     {100,3,7,5,3,1},
    //     {164,4,5,2,7,8},
    //     {334,7,2,7,2,9},
    //     {234,4,7,2,8,2},
    //     {541,5,4,3,3,6},
    //     {235,4,8,6,9,7},
    //     {394,3,6,1,6,2},
    //     {872,8,4,3,7,2}
    // };
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m+1; j++) {
            cin >> allbook.at(i).at(j);
        }
    }
    

    bitset<12> kumiawase; // n冊の本につきそれぞれ買うか買わないかを0と1で示すビット列
    int min = 1200001; // 達成可能な場合の最小金額を求めるための変数
    bool allimp = false; // 前通りで目標達成が不可能か判定するためのフラグ
    
    for (int i = 0; i < (1 << n); i++) { // n冊の本につきそれぞれ買うか買わないかを選択する組み合わせ2^n通りを全て試行
        kumiawase = i; // 整数を二進数に直す
        // cout << kumiawase << " "; // あとでコメントアウト

        int sum = 0; // 各組み合わせにおける買った本の合計金額を求めるための変数
        vector<int> rikaido(m,0); // 各組み合わせにおける各アルゴリズム理解度を記録するための配列
        bool imp = true; // 各組み合わせにおける目標達成の可能不可能を判定するためのフラグ
        
        for (int j = 0; j < n; j++) {
            if (kumiawase.test(j)) { // ビット列からどの本を買ったかを調べる
                sum += allbook.at(j).at(0); // 買った本の金額を計上
                for (int k = 0; k < m; k++) {
                    rikaido.at(k) += allbook.at(j).at(k+1); // 買った本による各理解度の上昇を計上
                }
            }
        }

        // cout << sum << " ";

        for (int r : rikaido) {
            // cout << r << " ";
            if (r < x) {
                imp = false; // 一つでも理解度がxに達しないならば目標達成不可能
            }
        }

        if (imp) {
            // cout << "達成可能" << endl;
            allimp = true;
            if (sum < min) { // 達成可能な組み合わせにおける合計金額が暫定の最小金額より小さければ最小金額を更新
                min = sum;
            }
        } else {
            // cout << "達成不可能" << endl;
        }
    }
    if (allimp) {
        cout << min << endl;
    } else {
        cout << -1 << endl;
    } 
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct CumulativeSum2D {
  vector< vector<int> > data;
  CumulativeSum2D(int H, int W):data(++H, vector<int>(++W)){}
  void add(int y, int x, int z) {
    data[++y][++x] += z;
  }
  void build() {
    for(int i = 1; i < (int)data.size(); i++)
      for(int j = 1; j < (int)data[i].size(); j++)
	data[i][j] += data[i][j-1] + data[i-1][j] - data[i-1][j-1];
  }
  int query(int sy, int sx, int gy, int gx) {
    ++gy, ++gx;
    return data[gy][gx] - data[gy][sx] - data[sy][gx] + data[sy][sx];
  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, m, q;
  cin >> n >> m >> q;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  CumulativeSum2D node(n, m), vedge(n, m), hedge(n, m);
  rep(i, n) rep(j, m) {
    if(s[i][j] == '1') {
      node.add(i, j, 1);
      if(i && s[i-1][j] == '1') vedge.add(i, j, 1);
      if(j && s[i][j-1] == '1') hedge.add(i, j, 1);
    }
  }
  node.build();
  vedge.build();
  hedge.build();
  rep(i, q) {
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    --sy, --sx, --gy, --gx;
    int n = node.query(sx, sy, gx, gy);
    int v = vedge.query(sx+1, sy, gx, gy);
    int h = hedge.query(sx, sy+1, gx, gy);
    //cout<<n<<" "<<v<<" "<<h<<endl;
    cout << n-v-h << endl;
  }


  return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}
int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}

ll solve(int N, vi& a){
    map<int,int> m;
    for(int ai:a) ++m[ai];
    vi edges;
    for (auto it=m.rbegin(); it!=m.rend(); ++it) {
        if (it->second >= 2) edges.pb(it->first);
        if (it->second >= 4) edges.pb(it->first);
        if (edges.size() >= 2) break;
    }

    if (edges.size() < 2) return 0;
    return (ll)edges[0] * edges[1];
}

int main() {
    vi a;
    int N = loadvec(a);
    cout << solve(N,a) << endl;
    return 0;
}


Measured memory_bytes: 6272
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  int m;
  cin >> m;
  while (m--) {
    string s;
    cin >> s;
    set<string> st;
    FOR(i, 1, (int)s.size()) {
      string p = s.substr(0, i);
      string b = s.substr(i, (int)s.size() - i);
      // cout << "p = " << p << "\n";
      // cout << "b = " << b << "\n";
      string rp = p, rb = b;
      reverse(all(rp));
      reverse(all(rb));
      st.insert(p + b);
      st.insert(p + rb);
      st.insert(rp + b);
      st.insert(rp + rb);
      st.insert(b + p);
      st.insert(rb + p);
      st.insert(b + rp);
      st.insert(rb + rp);
    }
    cout << st.size() << "\n";
  }

  return 0;
}


Measured memory_bytes: 3244