akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 3e2 + 5;
const ll LINF = 1e18 + 5;
int h, w, k, sum[N], id[N][N];
char a[N][N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> h >> w >> k;
 	for(int i=1;i<=h;i++)
 	{
 		for(int j=1;j<=w;j++)
 		{
 			cin >> a[i][j];
 			sum[i] += (a[i][j]=='#');
 		}
 	}
 	int cur = 0;
 	int st = 1;
 	while(!sum[st]) st++;
 	for(int i=st;i<=h;i++)
 	{
 		if(!sum[i])
 		{
 			for(int j=1;j<=w;j++) id[i][j] = id[i-1][j];
 		}
 		else
 		{
 			for(int j=1;j<=w;j++)
 			{
 				if(a[i][j]=='#')
 				{
 					id[i][j] = ++cur;
 					int k;
 					for(k=j-1;k>=1&&!id[i][k];k--) id[i][k] = id[i][j];
 					for(k=j+1;k<=w&&a[i][k]!='#';k++) id[i][k] = id[i][j];
 					j = k - 1;
 				}
 			}
 		}
 	}
 	for(int i=st-1;i>=1;i--)
 	{
 		for(int j=1;j<=w;j++)
 		{
 			id[i][j] = id[i+1][j];
 		}
 	}
 	for(int i=1;i<=h;i++)
 	{
 		for(int j=1;j<=w;j++)
 		{
 			cout << id[i][j] << " \n"[j==w];
 		}
 	}
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>      // std::setprecision
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;
using namespace boost::math;

int main() {
	long long N, K;

	cin >> N >> K;
  
    vector<int> A(N);
  
    for (auto& i : A)
      cin >> i;
  
    long long appear[2001] = {0}, added[2001] = {0};
    long long koke = 0;
  
    REP(i, N) {
      appear[A[i]]++;
      for (int j : boost::irange(A[i] + 1, 2001)) {
        koke = (koke + appear[j]) % 1000000007LL;
        added[j]++;
      }
    }

    auto kdan = K * (K-1LL) / 2LL % 1000000007LL;
  long long hoge = 0;
    REP(i, 2001) {
      appear[i] = appear[i] * added[i];
      appear[i] = appear[i] * kdan % 1000000007LL;
      hoge += appear[i] % 1000000007LL;
    }
    
	cout << (hoge + (koke * K) % 1000000007LL) % 1000000007LL << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <complex>
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

typedef complex<double> coor;

#define EPS 1e-5

double in_cir(coor o, coor x)
{
  return abs(x - o);
}

int search(vector<coor> P)
{
  int mx = 1;
  /*for (int i = 0; i < P.size(); i++) {
    printf("%lf, %lf\n", P[i].real(), P[i].imag());
    }*/
  for (int i = 0; i < P.size(); i++) {
    for (int j = i + 1; j < P.size(); j++) {
      for (int k = 0; k < 2; k++) {
	if (abs(P[i] - P[j]) - 2.0 > -EPS) {continue;}
	coor d = coor(P[i].imag() - P[j].imag(),
		      -(P[i].real() - P[j].real()));
	if (k == 1) {d = -d;}
	d /= abs(d);
	d *= sqrt(1 - norm(P[i] - P[j]) / 4);
	//printf("abs(d) = %lf\n", abs(d));
	d += (P[i] + P[j]) / 2.0;
	//printf("%lf, %lf\n", d.real(), d.imag());
	int ctr = 2;
	for (int l = 0; l < P.size(); l++) {
	  //printf("%lf\n", in_cir(d, P[l]));
	  if (l == i || l == j) {continue;}
	  if (in_cir(d, P[l]) - 1.0 < -EPS) {
	    ctr++;
	  }
	}
	//printf("_%d\n", ctr);
	mx = max(ctr, mx);
	
      }
    }
  }
  return mx;
}

int main()
{
  int N;
  while (scanf("%d ", &N) == 1) {
    if (N == 0) {
      break;
    }
    vector<coor> P(N);
    for (int i = 0; i < N; i++) {
      double x, y;
      scanf("%lf %lf ", &x, &y);
      P[i] = coor(x, y);
    }
    printf("%d\n", search(P));
  }
  return 0;
}

Measured memory_bytes: 984
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define cs const 
#define fr first 
#define se second
#define ls (now<<1)
#define rs (now<<1|1)
#define mid ((l+r)>>1)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define low(i) (i&(-i))
#define par pair<int,int>
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define sep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
 
cs int G = 3;
cs int ff = 2e6 + 1;
cs int inf = 1e18 + 1;
cs int base = 2333;
cs int M = 1e9 + 7;

int n, m;
struct Node {int x, y, z;} a[ff];
bool cmp(Node A, Node B) { return A.z < B.z;
}
void init()
{
	int a, b, c, d;
	cin >> a;
	puts(a == 1 ? "0" : "1");
}
signed main()
{
	int Ts = 1;
	while(Ts--)
		init();
}

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

int main(){
	// sengen
	string s;
	// nyuryoku
	cin >> s;
	int n = s.size();
	// keisan
	for(int i=0;i<n;i++){
		s[i] = 'x';
	}
	// syutsuryoku
	cout << s;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main() {
    int N, M, i, A, B, ans = 0;
    scanf("%d %d", &N, &M);
    long *H = malloc(sizeof(long) * N);
    int *count = malloc(sizeof(int) * N);
    /*int *A = malloc(sizeof(int) * M);
    int *B = malloc(sizeof(int) * M);*/
    for (i = 0; i < N; i++) {
        scanf("%ld", H + i);
        count[i] = 0;
    }
    for (i = 0; i < M; i++) {
        scanf("%d %d", &A, &B);
        if (H[A - 1] >= H[B - 1]) count[B - 1]++;
        if (H[A - 1] <= H[B - 1]) count[A - 1]++;
    }
    for (i = 0; i < N; i++)
        if (!count[i]) ans++;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2908
s=input()
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    print(*(i+1,i+2))
    break
else:
  for i in range(len(s)-2):
    if s[i]==s[i+2]:
      print(*(i+1,i+3))
      break
  else:
    print('-1 -1')

Measured memory_bytes: 3188
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);	
			
			int n = sc.nextInt();
			int t = sc.nextInt();
			int[] tim = new int[n];
			int ans = 0;
			for (int i = 0; i < n; i++) {
				tim[i] = sc.nextInt();
			}

			for (int i = 0; i < n; i++) {
				if(i > 0){
					if (tim[i]-tim[i-1] <= t) {
						ans += (tim[i] - tim[i-1]);
					}else{
						ans += t;
					}
				}
			}
			ans += t;

			System.out.println(ans);

		    sc.close(); }
}


Measured memory_bytes: 63360
#include<stdio.h>
int main(){
    int a,b,p1,q1;
    scanf("%d%d",&a,&b);
    for(int i=1;i<=1000;i++){
        p1=i*2/25;
        q1=i/10;
        if(p1==a&&q1==b){
            printf("%d\n",i);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

ll f ( ll h )
{
    if ( h == 1 )
        return 1LL ;

    h >>= 1 ;
    return 2LL * f ( h ) + 1LL ;
}

void solve ( int test_case )
{
    ll h ;
    cin >> h ;

    ll ans = f ( h ) ;
    cout << ans ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define INF 1000000001

int count;

void merge(int A[], int left, int mid, int right){
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1 + 1];
  int R[n2 + 1];
  for(i=0; i<n1; i++){
    L[i] = A[left + i];
  }
  for(i=0; i<n2; i++){
    R[i] = A[mid + i];
  }
  L[n1] = INF;
  R[n2] = INF;

  i=0;
  j=0;

  for(k=left; k<right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
    count ++;
  }
  
}

void mergeSort(int A[], int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

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

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

  mergeSort(A, 0, n);

  for(i=0; i<n; i++){
    printf("%d",A[i]);
    if(i < n - 1){
      printf(" ");
    }
  }

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

  return 0;
}



Measured memory_bytes: 5688
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, K;
        cin >> N >> K;
        vll A(N);
        rep(i, 0, N) cin >> A[i];

        rep(i, 0, N-K) {
                if (A[i+K] > A[i]) {
                        cout << "Yes" << endl;
                } else {
                        cout << "No" << endl;
                }
        }
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int w, h;
	while (cin >> w >> h, w | h) {
		vector<vector<int>> b(h, vector<int>(w));
		int si = -1, sj = -1, ti = -1, tj = -1;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> b[i][j];
				if (b[i][j] == 2) {
					si = i;
					sj = j;
					b[i][j] = 0;
				}
				if (b[i][j] == 3) {
					ti = i;
					tj = j;
					b[i][j] = 0;
				}
			}
		}
		int res = -1;
		vector<int> can(1 << 20);
		for (int i = 0; i < (1 << 20); i++) {
			if (can[i]) continue;
			int ni = si, nj = sj;
			vector<int> ci, cj;
			int out = -1;
			for (int j = 0; j < 10; j++) {
				int to = (i >> (j * 2)) & 3;
				bool ok = false, ng = false;
				ni += dx[to];
				nj += dy[to];
				if (ni < 0 || h <= ni || nj < 0 || w <= nj || b[ni][nj] != 0) {
					out = j + 1;
					break;
				}
				if (ni == ti && nj == tj) {
					res = res == -1 ? j + 1 : min(res, j + 1);
					break;
				}
				while (b[ni][nj] == 0) {
					ni += dx[to];
					nj += dy[to];
					if (ni < 0 || h <= ni || nj < 0 || w <= nj) {
						ng = true;
						break;
					}
					if (ni == ti && nj == tj) {
						ok = true;
						break;
					}
				}
				if (ok) {
					res = res == -1 ? j + 1 : min(res, j + 1);
					out = j + 1;
					break;
				}
				if (ng) {
					out = j + 1;
					break;
				}
				b[ni][nj] = 0;
				ci.push_back(ni);
				cj.push_back(nj);
				ni -= dx[to];
				nj -= dy[to];
			}
			for (int j = 0; j < (int)ci.size(); j++) {
				b[ci[j]][cj[j]] = 1;
			}
			if (out != -1) {
				for (int x = 0; x < (1 << (20 - out * 2)); x++) {
					can[(x << (out * 2)) + i] = 1;
				}
			}
		}
		printf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 7284
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (s.toUpperCase().equals(s)) {
			System.out.println("A");
		} else {
			System.out.println("a");
		}
	}

}


Measured memory_bytes: 35692
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
using namespace std;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// C - Train Ticket
int main(){
    string S;
    cin >> S;

    int num[4];
    rep(i, 0, 4){
        num[i] = stoi(S.substr(i, 1));
    }
    int L = 3;
    char op[3];
    for(int i=0;i<1<<L;++i){
        int r;
        int tmp = num[0];
        int ans_b;
        for(r=0;r<L;++r){
            // Bitが立っているときの処理
            if((i & (1 << r)) != 0){
                tmp = tmp + num[r+1];
            }else{
                tmp = tmp - num[r+1];
            }
        }
        if(tmp == 7){
            rep(j, 0, L){
                op[j] = ((i & (1 << j)) != 0) ? '+' : '-';
            }
            break;
        }
    }
    
    int ans = 0;
    printf("%d%c%d%c%d%c%d=7\n", num[0], op[0], num[1], op[1], num[2], op[2], num[3]);
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



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

#define MAX_N 200005//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
int par[MAX_N],dep[MAX_N];//depはrankのこと
//n要素で初期化//忘れないように！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
void init(int n){
    for(int i=0;i<=n-1;i++){//頂点番号は0~n-1
        par[i]=i;
        dep[i]=0;
    }
}
//木の根を求める
int find(int x){
    return par[x]==x?x:par[x]=find(par[x]);
}
//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(dep[x]<dep[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(dep[x]==dep[y])dep[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
    return find(x)==find(y);
}

//////////////////////////////////////
int parb[MAX_N],depb[MAX_N];//depはrankのこと
//n要素で初期化//忘れないように！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
void initb(int n){
    for(int i=0;i<=n-1;i++){//頂点番号は0~n-1
        parb[i]=i;
        depb[i]=0;
    }
}
//木の根を求める
int findb(int x){
    return parb[x]==x?x:parb[x]=findb(parb[x]);
}
//xとyの属する集合を併合
void uniteb(int x,int y){
    x=findb(x);
    y=findb(y);
    if(x==y)return;
    if(depb[x]<depb[y]){
        parb[x]=y;
    }else{
        parb[y]=x;
        if(depb[x]==depb[y])depb[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool sameb(int x,int y){
    return findb(x)==findb(y);
}
struct v{
    int rood;
    int train;
    int num;
};

bool asc(const v a,const v b){
    return a.rood==b.rood? a.train<b.train:a.rood<b.rood;
}

int main(){
    int n,k,l;cin>>n>>k>>l;
    init(n);initb(n);
    for(int i=1;i<=k;i++){
        int p,q;cin>>p>>q;p--;q--;
        unite(p,q);
    }
    for(int i=1;i<=l;i++){
        int p,q;cin>>p>>q;p--;q--;
        uniteb(p,q);
    }
    int ans[n];memset(ans,0,sizeof(ans));
    v p[n];
    for(int i=0;i<=n-1;i++){
        p[i].rood=find(i);
        p[i].train=findb(i);
        p[i].num=i;
    }
    sort(p,p+n,asc);
    int pos=0;
    while(pos<=n-1){
        int count=1;vector <int>c;c.push_back(p[pos].num);
        while(pos+1<=n-1&&p[pos].rood==p[pos+1].rood&&p[pos].train==p[pos+1].train){
            c.push_back(p[pos+1].num);
            pos++;
            count++;
        }
        for(auto x:c){
            ans[x]=count;
        }
        pos++;
    }
    
    for(int i=0;i<=n-1;i++)cout<<ans[i]<<" ";
    return 0;
}

Measured memory_bytes: 7048
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
lli kp(lli w[],lli v[],int n,lli wt)
{   
    lli dp[n+1][wt+1]; 
    memset(dp,-1,sizeof(dp)); 
    
    for(lli i=0;i<n+1;i++)
    dp[i][0]=0;

    for(lli i=0;i<wt+1;i++)
    dp[0][i]=0;
   
    for(lli i=1;i<n+1;i++)
    {  for(lli j=1;j<wt+1;j++)
       {
            if(w[i-1]>j)
            dp[i][j]=dp[i-1][j];
            else
            dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
       }
    } 
    return dp[n][wt];
}
int main() 
{ 
  int n; lli wt;
  cin>>n; cin>>wt;
  lli w[n];
  lli v[n];
  for(lli i=0;i<n;i++)
  {
      cin>>w[i];  cin>>v[i]; 
  }
  cout<<kp(w,v,n,wt);
}
  


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

using namespace std;

int main() {
  int N, M;
  int cnts[51] = {0};
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    cnts[a - 1]++;
    cnts[b - 1]++;
  }
  for (int i = 0; i < N; i++) {
    cout << cnts[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from math import floor, ceil
v, h = list(map(int, input().split()))
if v == 1 or h == 1:
    print(1)
else:
    vc = ceil(v/2)
    vf = floor(v/2)
    hc = ceil(h/2)
    hf = floor(h/2)
    print(vc*hc+vf*hf)

Measured memory_bytes: 3060
N = int(input())
L = list(map(int, input().split()))
L.sort()

count = 0
for i in L:
    for j in L:
        for k in L:
            if i < j < k:
                if i != j != k:
                    if (i + j > k) and (j + k > i) and (i + k > j):
                        count+=1

print(count)

Measured memory_bytes: 9116
def read_input():
    n, m = map(int, input().split())
    return n, m


def submit():
    n, m = read_input()

    if n > m // 2:
        print(m // 2)
    else:
        rest_m = m - n * 2
        print(n + rest_m // 4)

if __name__ == '__main__':
    submit()


Measured memory_bytes: 38256
N,M = map(int,input().split())
A = set(int(input()) for _ in [0]*M)
mod = 10**9 + 7
dp = [0]*(N+1)
dp[0] = 1
for i in range(1,N+1):
    dp[i] = (dp[i-1]+dp[i-2]) % mod
    if i in A:
        dp[i] = 0
print(dp[N])



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    cin >> n;
    int t = n / 3;
    cout << t << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,x,a[21234],b[21234],s[21234];
int main(){
	scanf("%d",&n);
	for (int i = 1; i <= n; i++){
		scanf("%d",&x);
		s[x] = i;
	}
	a[1] = s[1];
	b[1] = 0;
	for (int i = 2; i <= n; i++)
		if (s[i] > s[i - 1]){
			a[i] = a[i - 1] + s[i] - s[i - 1] + 1;
			b[i] = b[i - 1] - 1;
		}else{
			a[i] = a[i - 1] + 1;
			b[i] = b[i - 1] + s[i] - s[i - 1] - 1;
		}
	for (int i = 1; i <= n; i++)
		b[i] = b[i] - b[n] + 1;
	for (int i = 1; i <= n; i++)
		printf("%d ",a[i]);
	printf("\n");
	for (int i = 1; i <= n; i++)
		printf("%d ",b[i]);
	printf("\n");
}

Measured memory_bytes: 896
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N, i=1, ans;

    cin >> N;

    while(true) {
        int k = 1000 * i;
        if(k>=N) {
            ans = k - N;
            break;
        }
        i++;
    }

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int n,m,v,u,p[1<<17];
vector<int>G[1<<17];
queue<int>q;
int main(){
	cin>>n>>m;
	rep(i,m){
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	q.push(1);
	p[1]=1;
	while(!q.empty()){
		u=q.front();q.pop();
		for(int e:G[u]){
			if(!p[e]){
				q.push(e);
				p[e]=u;
			}
		}
	}
	puts("Yes");
	rep(i,n-1)cout<<p[i+2]<<endl;
}


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

//#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")

#define int long long
typedef pair <int, int> pii;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector <pii> A;
	for (int i = 0; i < m; i++) {
		int p;
		string s;
		cin >> p >> s;
		if (s == "WA")
			A.push_back(pii(p, 0));
		else
			A.push_back(pii(p, 1));
	}
	bool b[n + 2];
	fill(b, b + n + 2, 0);
	int t[n + 2];
	fill(t, t + n + 2, 0);
	int q = 0, o = 0;
	for (auto P: A) {
		if (P.second) {
			if (!b[P.first]) {
				o += t[P.first];
				b[P.first] = 1;
				q++;
			}
		}
		else {
			t[P.first] ++;
		}
	}
	cout << q << ' ' << o;
}


Measured memory_bytes: 2800
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	vector<int> a(3);
	cin>>a[0]>>a[1]>>a[2];
	sort(a.begin(), a.end());
	// if(a[0] == a[1] || a[1] == a[2]){
	// 	cout<<"Yes"<<endl;
	// 	return;
	// }
	if(a[0] + a[1] == a[2]){
		cout<<"Yes"<<endl;
		return;
	}
	cout<<"No"<<endl;

}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_



int main(void) {
	map<ULONG, int> memo;
	ULONG N,Q;
	cin >> N;

	ULONG sum = 0;
	for (ULONG i = 0; i < N; i++) {	
		ULONG tmpi;
		cin >> tmpi;
		sum += tmpi;
		memo[tmpi]++;
	}

	cin >> Q;
	vector<ULONG> B(Q);
	vector<ULONG> C(Q);
	for (ULONG i = 0; i < Q; i++) {
		cin >> B[i];
		cin >> C[i];
	}

	for (ULONG i = 0; i < Q; i++) {
		long long tmpsum = 0;
		int num = memo[B[i]];
		if (num > 0) {
			memo[B[i]] = 0;
			memo[C[i]] += num;
		}
		tmpsum = (C[i] - B[i]) * num;
		sum += tmpsum;

		cout << sum << endl;
	}



	return 0;
}


Measured memory_bytes: 10420
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }

void solve() {
  string s = "aeiuo";
  char c;
  cin >> c;
  auto it = find(s.begin(), s.end(), c);
  if (it == s.end()) cout << "consonant" << endl;
  else cout << "vowel" << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<long long> a(N);
  long long B = 0;
  for(int i = 0; i < N; i++) cin >> a[i], B ^= a[i];
  for(int i = 0; i < N; i++) cout << (a[i]^B) << " ";
  cout << "" << endl;
}


Measured memory_bytes: 4732
def main():
    a, b = map(int, input().split())
    ans = -1
    for i in range(100000):
        x = int(i*0.08)
        y = int(i*0.10)
        if x == a and y == b:
            ans = i
            break
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

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

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < b; i++) {
            sb.append(String.valueOf(a));
        }

        String A = sb.toString();
        sb.setLength(0);

        for (int i = 0; i < a; i++) {
            sb.append(String.valueOf(b));
        }
        String B = sb.toString();

        if (a >= b) {
            System.out.println(B);
        } else {
            System.out.println(A);
        }

    }

}

Measured memory_bytes: 21716
#if defined(LOCAL)
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <iostream>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <limits>
#include <numeric>
#include <queue>
#include <memory>

using namespace std;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ii = pair<int,int>; using lu = unsigned long long; using l = long long;
using vs = vector<string>; using vii = vector<ii>;
using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>; using sl = unordered_set<l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; const double PI = M_PI;
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

void solve(istream& in, ostream& out);
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  tst::test_init(argc, argv);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  tst::maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}
const l MOD = e9 + 7; // end of template

void solve(istream& in, ostream& out) {
  l sum = 999 + 111;
  l n; in >> n;
  out << sum - n << lf;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int a[100050];
int main(){
	int n,i,p=0,ans;
	scanf("%d",&n);
	for(i=0;i<n;++i)scanf("%d",a+i);
	sort(a,a+n);
	while(p<n&&a[p]<0)++p;
	if(!p){
		ans=-a[0];
		for(i=1;i<n;++i)ans+=a[i];
		printf("%d\n",ans);
		for(i=1;i<n-1;++i){
			printf("%d %d\n",a[0],a[i]);
			a[0]-=a[i];
		}
		printf("%d %d\n",a[n-1],a[0]);
	}else if(p<n){
		ans=0;
		for(i=0;i<n;++i)ans+=abs(a[i]);
		printf("%d\n",ans);
		for(i=p;i<n-1;++i){
			printf("%d %d\n",a[0],a[i]);
			a[0]-=a[i];
		}
		for(i=0;i<p;++i){
			printf("%d %d\n",a[n-1],a[i]);
			a[n-1]-=a[i];
		}
	}else{
		ans=a[n-1];
		for(i=0;i<n-1;++i)ans-=a[i];
		printf("%d\n",ans);
		for(i=0;i<n-1;++i){
			printf("%d %d\n",a[n-1],a[i]);
			a[n-1]-=a[i];
		}
	}
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	int N;
	int H[100000];
	cin >> N;
	for (int i = 0; i < N; i++)cin >> H[i];
	int ans = 0;
	int cnt = 0;
	for (int i = 1; i < N; i++) {
		if (H[i] <= H[i - 1]) {
			if (cnt >= 0)cnt++;
			else {
				cnt = 1;
			}
		}
		else {
			ans = max(ans, cnt);
			cnt = -1;
		}
	}
	ans = max(ans, cnt);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
{-# LANGUAGE ScopedTypeVariables #-}
module Main where

import qualified Data.ByteString.Char8         as BS
import qualified Data.ByteString.Lazy.Char8    as BSL
import qualified Data.ByteString.Builder       as BSB
import           Data.Char                      ( isSpace )
import           Data.List                      ( unfoldr )
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import qualified Data.Vector.Generic           as VG
import qualified Data.Vector.Generic.Mutable   as VGM
import           Control.Monad                  ( replicateM )

main :: IO ()
main = do
  [h, w, k] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  mat <- replicateM h BS.getLine :: IO [BS.ByteString]
  let pats = brutes [True, False] (h+w)
  print $ length $ filter id $ map (query mat h w k) pats 
 where
  query :: [BS.ByteString] -> Int -> Int -> Int -> [Bool] -> Bool
  query mat h w k pat = let
    hs = take h pat
    ws = drop h pat
    trows = zip hs mat
    cols = BS.transpose $ [ snd x | x <- trows, fst x ]
    tcols = zip ws cols
    remains = [ snd x | x <- tcols, fst x ]
    in (==k) $ BS.count '#' $ BS.concat remains

brutes :: [a] -> Int -> [[a]]
brutes x n = replicateM n x



Measured memory_bytes: 4912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
using Card = vector<vector<int>>;

bool tate(Card card, int line) {
  int hit = 0;
  rep(i, 3) if (card.at(i).at(line) == 0) hit++;
  return hit == 3;
}

bool yoko(Card card, int line) {
  int hit = 0;
  rep(i, 3) if (card.at(line).at(i) == 0) hit++;
  return hit == 3;
}

bool naname1(Card card) {
  int hit = 0;
  rep(i, 3) if (card.at(i).at(i) == 0) hit++;
  return hit == 3;
}

bool naname2(Card card) {
  int hit = 0;
  rep(i, 3) if (card.at(i).at(2 - i) == 0) hit++;
  return hit == 3;
}

bool bingo(Card card) {
  rep(i, 3) if (tate(card, i)) return true;
  rep(i, 3) if (yoko(card, i)) return true;
  if (naname1(card)) return true;
  if (naname2(card)) return true;
  return false;
}

int main() {
  Card A;
  A.assign(3, vector<int>(3, 0));
  rep(i, 3) rep(j, 3) cin >> A.at(i).at(j);

  int N;
  cin >> N;

  rep(i, N) {
    int b;
    cin >> b;
    rep(i, 3) rep(j, 3) if (A.at(i).at(j) == b) A.at(i).at(j) = 0;
  }

  cout << (bingo(A) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
 
public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
        int n=Integer.parseInt(br.readLine());
        String s=br.readLine();
        String[] a=s.split(" ");
        for(int i=a.length;i>0;i--){
            System.out.print(a[i-1]);
            if(i!=1)System.out.print(" ");
        }br.close();System.out.println();
}}

Measured memory_bytes: 24240
#include<stdio.h>

int main(){
  int a,b;
  char op;
  while(1){
  scanf("%d %c %d",&a,&op,&b);
    if ( op == '+' )printf("%d\n",a+b);
    else if ( op == '-')printf("%d\n",a-b);
    else if ( op == '*')printf("%d\n",a*b);
    else if ( op == '/')printf("%d\n",a/b);
    else break;
  }
  return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 INF=1001001001;

int main() {
  int N;
  cin>>N;
  vector<int>B(N-1);
  vector<int>A(N,INF);
  for(int i=0;i<N-1;i++){
    cin>>B[i];
  }
  int sum=0;
  
  for(int i=0;i<N-1;i++){
    A[i]=min(A[i],B[i]);
    A[i+1]=min(A[i+1],B[i]);
  }
   for(int i=0;i<N;i++){
    sum+=A[i];
  }
  
  cout<<sum<<endl;
  

  return 0;}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int C[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> C[i][j];
    }
  }

  for (int a1 = 0; a1 <= 100; a1++) {
    int b1 = C[0][0] - a1;
    int b2 = C[0][1] - a1;
    int b3 = C[0][2] - a1;
    int a2 = C[1][0] - b1;
    int a3 = C[2][0] - b1;
    if (a2 != C[1][1] - b2 || a2 != C[1][2] - b3) continue;
    if (a3 != C[2][1] - b2 || a3 != C[2][2] - b3) continue;
    cout << "Yes" << '\n';
    return 0;
  }
  cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

template<typename T>
using v = vector<T>;



int main() {
	int R, C, N;
	cin >> R >> C >> N;
	vP a;
	rep(i, N) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if ((x1 == 0 || x1 == R || y1 == 0 || y1 == C) && (x2 == 0 || x2 == R || y2 == 0 || y2 == C)) {
			//cout << i << endl;
			int n = 0;
			if (y1 == 0) {
				n = x1;
			}
			else if (y1 == C) {
				n = R + C + R - x1;
			}
			else if (x1 == 0) {
				n = 2 * R + C + (C - y1);
			}
			else {
				n = R + y1;
			}
			a.push_back(mp(n, i));

			if (y2 == 0) {
				n = x2;
			}
			else if (y2 == C) {
				n = R + C + R - x2;
			}
			else if (x2 == 0) {
				n = 2 * R + C + (C - y2);
			}
			else {
				n = R + y2;
			}
			a.push_back(mp(n, i));
		}
	}
	sort(all(a));
	/*
	rep(i, a.size()) {
		cout << a[i].second << " ";
	}
	cout << endl;
	*/
	stack<int> st;
	st.push(-1);
	rep(i, a.size()) {
		if (a[i].second == st.top()) {
			st.pop();
		}
		else {
			st.push(a[i].second);
		}
	}
	//cout << st.size() << endl;

	if (st.size() == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

int main() {
  string N,A,B,C;
  cin >>A;
    if(A[0]=='7'||A[1]=='7'||A[2]=='7'){
     cout<<"Yes"<<endl;
      return 0;
    }
  cout <<"No"<< endl;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

/*
	入力例：
	3
	1 1 3
*/

int main(){
	char sS[200001];
	char sT[200001];
	scanf("%s", &sS);
	scanf("%s", &sT);

	long idx;
	long sDiff=0;
	for (idx=0;idx< strlen(sS);idx++){
		if(sS[idx]!=sT[idx]) {
			sDiff++;
		}
	}
	printf("%d\n",sDiff);
 return 0;
}

Measured memory_bytes: 2072
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
using namespace std;

int main(){

    string str;
    int q;

    cin >> str;
    cin >> q;
    int a, b;
    rep(i,0,q){
        string order;
        cin >> order >> a >> b;
        string temp;
        if(order == "replace"){
            cin >>  temp;
            auto it = str.begin()+a;
            for(int j=0; j<= b-a; j++){
                *it++ = temp[j];
            }
        }else if(order == "reverse"){
            string str2 = str;
            auto it = str.begin()+a;
            auto it2 = str2.begin()+b;
            for(int j=0; j<=b-a; j++){
                *it++ = *it2--;
            }
        }else if(order == "print"){
            cout << str.substr(a, b-a+1) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}
template<class T>istream&operator>(istream&i,T&t){return i>>t;}
#ifndef LOCAL
struct ostdmy{
template<class T>ostdmy&operator<<(const T&t){return*this;}
template<class T>ostdmy&operator<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int x,y,z,k;
    cin>x>y>z>k;
    vl a(x),b(y),c(z);
    cin>a>b>c;
    sort(all(c), greater<ll>());
    vl su(x*y);
    REP(i,x)REP(j,y){
        su[i*y+j]=a[i]+b[j];
    }
    sort(all(su), greater<ll>());
    cerr<su<endl;
    int I=min(k,x*y),J=min(k,z);
    vl ans(I*J);
    REP(i,I)REP(j,J){
        ans[i*J+j]=su[i]+c[j];
    }
    cerr<ans<endl;
    sort(all(ans), greater<ll>());
    REP(i,k){
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;

using namespace std;

int h, w;
char a[100][100];

bool check (int i, int j){
    if(a[i - 1][j] == '#' || a[i + 1][j] == '#' || a[i][j - 1] == '#' || a[i][j + 1] == '#') return true;
    return false;
}

void solve(){
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for (int j = 0; j < w; j++) {
            cin >> a[i + 1][j + 1];
        }
    }
    
    for(int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++) {
            if(a[i][j] == '#'){
                if(!check(i, j)){
                    cout << "No";
                    return;
                }
            }
        }
    }
    cout << "Yes";
}

int main(){
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}



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<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
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++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<ll,P> PP;
int main() {
	string s; cin >> s;
	int x, y; cin >> x >> y;
	int len = s.length();
	bool f = true;
	vector<int> odd, even;
	int sta = 0;
	rep(i, len) {
		if (s[i] == 'F') {
			int chk = i;
			while (i + 1 < len&&s[i + 1] == 'F')i++;
			if (chk == 0) {
				sta= i - chk + 1; continue;
			}
			if (f)odd.push_back(i - chk + 1);
			else even.push_back(i - chk + 1);
		}
		else f = !f;
	}
	bitset<24001> exi1, exi2;
	exi1[8000+sta] = exi2[8000] = 1;
	int len1 = odd.size();
	int len2 = even.size();
	rep(i, len1) {
		exi1 = (exi1 << odd[i]) | (exi1 >> odd[i]);
	}
	rep(i, len2) {
		exi2 = (exi2 << even[i]) | (exi2 >> even[i]);
	}
	if (exi1[x + 8000] && exi2[y + 8000])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

constexpr double ra = (180.0/M_PI);

int main(int argc, char **argv)
{
	double a, b, x; cin >> a >> b >> x;
	double PI = acos(-1.0);
	x /= a;
	std::cout << fixed << setprecision(10);
	if (2*x >= a*b)
		std::cout << atan2(2*(a*b-x), pow(a, 2)) * ra<< std::endl;
	else
		std::cout << atan2(pow(b, 2), 2*x) * ra<< std::endl;
}

Measured memory_bytes: 512
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

typedef long long ll;

const ll INF = 1e18;
const int BIG = 1e9;
const int maxN = 100 * 1000 + 9;
const string FILENAME = "sample";

int n, L;

void read(){
	cin >> n >> L;
}

void solv(){
	int mnDiff = BIG, ans = 0;
	for(int i = 1; i <= n; i++){
		int flavor = 0;
		for(int j = 1; j <= n; j++){
			flavor += L + j - 1;
		}

		int newFlavor = flavor - (L + i - 1);
		if(abs(flavor - newFlavor) < mnDiff){
			mnDiff = abs(flavor - newFlavor);
			ans = newFlavor;
		}
	}

	cout << ans << '\n';
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
#ifdef h4h4
	freopen((FILENAME + ".inp").c_str(), "r", stdin);
	freopen((FILENAME + ".out").c_str(), "w", stdout);
#endif

	read();
	solv();

	return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int a, b;
vector<int> h;

bool check(int t) {
  vector<int> v;
  LL cnt = 0;
  for (auto x : h) {
    if (x - (LL)b * (LL)t > 0)
      v.push_back(x - b * t);
  }
  for (auto x : v) {
    cnt += x % (a - b) == 0 ? x / (a - b) : x / (a - b) + 1;
  }
  return cnt <= t;
}

int main(){
  int n;
  scanf("%d %d %d", &n, &a, &b);

  h.resize(n);

  REP (i, n) {
    scanf("%d", &h[i]);
  }

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

  int mx = h[0] / b + 2;
  int mn = 1;
  int now = (mx + mn) / 2;
  while (mx - mn > 1) {
    if (check(now)) {
      mx = now + 1;
      now = (now + mn) / 2;
    } else {
      mn = now + 1;
      now = (now + mx) / 2;
    }
  }
  cout << now << endl;
}


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

using namespace std;
#define INF 100001;

int main()
{
    int n; cin >> n;
    int a[n][3];
    for(int i=0; i<n; i++)
    {
        for (int j = 0; j < 3; ++j)
        {
            cin >> a[i][j];
        }
    }

    int dp[n][3] = {};

    //setting the base case since this is top down
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

    //loop starts from one because base case is set
    for (int i = 1; i < n; ++i)
    {
        //traversing through diff activities
        for(int j=0; j<3; ++j)
        {
            //dp[i][k] is the score for kth activity on ith day
            //%3 is taken to avoid repetition of activity as specified in the question
            int x = dp[i-1][(j+1)%3];
            int y = dp[i-1][(j+2)%3];
            //adding max of previous rewards
            dp[i][j] = a[i][j] + max(x,y);
        }
    }

    cout << *max_element(dp[n-1], dp[n-1]+3) <<endl;
}

Measured memory_bytes: 5968