akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    int n; cin >> n;
    vector<pair<int, int>> a(n), b(n);
    int m = 0;
    pair<int, int> m_p;
    REP(i, n) {
        cin >> a[i].first >> a[i].second;
        b[i].first = a[i].second;
        b[i].second = a[i].first;
        if (m < a[i].second - a[i].first + 1) {
            m = a[i].second - a[i].first + 1;
            m_p = a[i];
        }
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    REP(i, n) swap(b[i].first, b[i].second);
    int ans = 0;
    // R[i] : i~n-1
    vector<pair<int, int>> L(n), R(n);
    L[0] = a[0];
    FOR(i, 1, n) {
        L[i].first = a[i].first;
        L[i].second = min(L[i - 1].second, a[i].second);
    }
    R[n - 1] = a[n - 1];
    for (int i = n - 1; i > 0; i--) {
        R[i - 1].first = a[n - 1].first;
        R[i - 1].second = min(R[i].second, a[i - 1].second);
    }
    REP(i, n - 1) {
        ans = max(ans, L[i].second - L[i].first + 1 + R[i + 1].second - R[i + 1].first + 1);
    }
    ////
    pair<int, int> x = {0,INF};
    REP(i, n) {
        if (a[i] == m_p) continue;
        x.first = max(x.first, a[i].first);
        x.second = min(x.second, a[i].second);
    }
    if (x.second != INF) {
        ans = max(ans, m + max(0,x.second - x.first + 1));
    }
    ////
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;cin>>n;
    int a;
    string ans="APPROVED";
    for(int i=0;i<n;i++){
        cin>>a;
        if(a%2==0&&a%3!=0&&a%5!=0){
            ans="DENIED";
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int maxN = 100;
	static String WHITE = ".";
	static String BLACK = "#";

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int white = in.nextInt();
			int black = in.nextInt();

			String[][] map = new String[maxN][maxN];
			for (int i = 0; i < maxN; i++) {
				for (int j = 0; j < maxN; j++) {
					if (j <= 49) {
						map[i][j] = WHITE;
					} else {
						map[i][j] = BLACK;
					}
				}
			}

			white--;
			black--;

			for (int i = 1; i <= 99; i+=2) {
				for (int j = 1; j <= 48; j+=2) {
					if (black > 0) {
						map[i][j] = BLACK;
						black--;
					}
				}
			}

			for (int i = 1; i <= 99; i+=2) {
				for (int j = 51; j <= 98; j+=2) {
					if (white > 0) {
						map[i][j] = WHITE;
						white--;
					}
				}
			}

			StringBuffer sb = new StringBuffer();
			sb.append("100 100\n");
			for (int i = 0; i < map.length; i++) {
				for (int j = 0; j < map[i].length; j++) {
					sb.append(map[i][j]);
				}
				sb.append("\n");
			}
			out.print(sb.toString());
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

const long long INF = 1LL << 60;
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; }

typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define vi vector<int>

int N, M, U, V;
vi edge[110000];

int memo[110000];
bool done[110000];

int dp(int v) {
	if (done[v]) return memo[v];
	else{
		int a = 0;
		for (int to : edge[v]) chmax(a, dp(to) + 1);
		done[v] = true;
		memo[v] = a;
		return a;
	}
}


int main() {

	cin >> N >> M;
	rep(i, M) {
		cin >> U >> V;
		edge[U].push_back(V);
	}

	int ans = 0;
	rep1(v, N + 1) chmax(ans, dp(v));
	
	cout << ans << endl;
}



Measured memory_bytes: 8448
#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-10)
#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<string> > vvs;
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;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;


int main() {
	int H, W, N;
	cin >> H >> W >> N;
	vi a(N);
	rep(i, N) {
		cin >> a[i];
	}

	int now = 0, cnt = 0;
	while (a[now] == 0)now++;

	vvi ans(H, vi(W));

	rep(i, H) {
		if (i % 2 == 0) {
			rep(j, W) {
				ans[i][j] = now + 1;
				if (i == H - 1 && j == W - 1)break;
				if (cnt == a[now] - 1) {
					now++;
					while (a[now] == 0)now++;
					cnt = 0;
				}
				else {
					cnt++;
				}
			}
		}
		else {
			reprev(j, W) {
				ans[i][j] = now + 1;
				if (i == H - 1 && j == 0)break;
				if (cnt == a[now] - 1) {
					now++;
					while (a[now] == 0)now++;
					cnt = 0;
				}
				else {
					cnt++;
				}
			}
		}
	}
	rep(i, H) {
		rep(j, W) {
			cout << ans[i][j];
			if (j < W - 1)cout << " ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 384
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

#print((-3)&3)
'''for i in range(10):
    j=i-(i&(-i))
    print(j)
    k=j-(j&(-j))
    print(k)
    print()'''
import copy
H,W,K=map(int,input().split())
L=[[x for x in input().rstrip()] for i in range(H)]
ans=0
#print(L[:])
for i in range(2**H):
    for j in range(2**W):
        C=copy.deepcopy(L)
        #print(C)
        for k in range(H):
            if (i>>k&1):
                C[k]=["r"]*W
        for l in range(W):
            if (j>>l&1):
                for m in range(H):
                    C[m][l]="r"
        count=0
        for p in range(H):
            for q in range(W):
                if C[p][q]=="#":
                    count+=1
        if count==K:
            ans+=1
print(ans)
        

Measured memory_bytes: 77316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    cout << (n - 1) / min({ a, b, c, d, e }) + 5 << endl;
    return 0;
}

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

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

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



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

	int h, w, d ,q;
	cin >>h >>w >>d;
	vector<int> ps(h*w+1, -1);
	rep(i, h) rep(j, w){
		int a; cin >>a;
		ps[a] = i*w +j;
	}
	VI sm(h*w+5, 0);
	rep(i, h*w+1-d){
		sm[i+d] = sm[i] + abs(ps[i+d]/w - ps[i]/w) + abs(ps[i+d]%w - ps[i]%w);
	}
	cin >>q;
	rep(i,q){
		int l, r;
		cin >>l >>r;
		cout<< sm[r] - sm[l] <<"\n";
	
	}
	
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

class Dice4{
public:
	int number[6];

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	bool isSameDice(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < 24; i++){
			roll(order[i]);
			for(int j = 0; j < 6; j++){
				if(inputed[j] != number[j])
					break;
				if(j == 5)
					return true;
			}
		}
		return false;
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

};

int main(){
	int n,k,j;
	scanf("%d",&n);
	Dice4 array[n];
	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d %d %d",&array[i].number[0],&array[i].number[1],&array[i].number[2],
				&array[i].number[3],&array[i].number[4],&array[i].number[5]);
	}
	for(k = 0; k < n-1; k++){
		for(j = k+1; j < n; j++){
			if(array[k].isSameDice(array[j].number))
				break;
		}
		if(j < n) break;
	}
	if(k == n-1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}



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

void merge(int [],int,int,int);
void mergesort(int [],int,int);

#define na 500000
#define INFTY 1000000000

int change = 0;

int L[na],R[na];

int main()
{
  int i = 0,A[na],n = 0;

  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",change);

      return 0;
}
void merge(int A[],int left,int mid,int right)
{
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  for(i = 0;i < n1;i++)
    {
      L[i] = A[left + i];
    }
  for(i = 0;i < n2;i++)
    {
      R[i] = A[mid + i];
    }
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for(k = left;k < right;k++)
    {
      change++;
      if(L[i] <= R[j])
	{
	  A[k] = L[i];
	  i += 1;
	}
      else
	{
	  A[k] = R[j];
	  j += 1;
	}
    }
}
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);
    }
}



Measured memory_bytes: 5608
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int n;
cin>>n;
string s;
cin>>s;
for(int i=0;i<n-1;i++)
   {
    if(s[i]==s[i+1])
    s[i]='0';
    }
int ans=0;
for(int i=0;i<n;i++)
{
    if(s[i]!='0')
        ans++;
}
cout<<ans;
return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, i, j, k, x, ct;
	cin >> n;
	vector<int> h(n);
	for (i = 0; i < n; i++) cin >> h[i];
	x = h[0];
	ct = 1;
	for (i = 1; (i < n); i++) {
		if (h[i] >= x) ct++;
		x = max(x, h[i]);
	}
	cout << ct << "\n";

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  for (int i = 0;i < n;i++){
    cin >> v[i];
  }
  
  sort(v.begin(), v.end());
  
  for (int i = 1;i < n;i++){
    v[i] = (v[i-1] + v[i])/2;
  }
  
  cout << fixed << setprecision(10);
  cout << v[n-1] << endl;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll m, d;
    cin>>m>>d;
    ll ans = 0;
    for(ll i=1;i<=m;++i){
        for(ll j=1;j<=d;++j){
            ll a = j / 10;
            ll b = j % 10;
            if(a >= 2 and b >= 2 and a*b == i){
                ans++;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int K = scan.nextInt();
        int h[] = new int[N];
        for (int i = 0; i < N ; i++) {
            h[i] = scan.nextInt();
        }

        int answer = 0;
        for (int i = 0; i < N ; i++) {
            if(h[i] >= K)
                answer++;

        }

        os.println(answer);

    }
}

Measured memory_bytes: 49356
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"strconv"
)

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		// if !r.Scan() {
		// 	panic("failed scan")
		// }
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func readInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}
// ---------------------------------------------------------


func main() {
  	nextReader = NewScanner()
	N := readInt()
	M := readInt()
	Q := readInt()
	var data [510][510]int
	for i := 0; i < M; i++ {
		l, r := readInt(), readInt()
		data[l][r]++
	}

	for i := N; i >= 1; i-- {
		for j := 1; j <= N; j++ {
			data[i][j] += data[i+1][j]
			data[i][j] += data[i][j-1]
			data[i][j] -= data[i+1][j-1]
		}
	}
	var buf bytes.Buffer
	for i := 0; i < Q; i++ {
		p, q := readInt(), readInt()
		buf.WriteString(strconv.Itoa(data[p][q]))
		buf.WriteString("\n")
	}
	fmt.Println(buf.String())
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int sum = 0;
  int max = 0;
  for(int i = 0;i < n;i++) {
    if(s.at(i) == 'I') {
      sum++;
    }else {
      sum--;
    }
    if(max < sum) {
      max = sum;
    }
  }
  cout << max << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int a[5], k;
	REP(i, 5){
		cin>>a[i];
	}
	cin>>k;
	cout<<(a[4]-a[0]>k ? ":(" : "Yay!")<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int Size = 105;
int Arr1 [Size],Arr2[Size];
int main()
{
    int N,c1=0,c2=0,c3=0,c4=0;
    cin >> N;
    for (int i=0;i<N;i++){
        string S;
        cin >> S;
        if (S == "AC") c1++;
        else if (S=="WA") c2++;
        else if (S=="TLE") c3++;
        else c4++;
    }
    cout << "AC x " << c1 << endl;
    cout << "WA x " << c2 << endl;
    cout << "TLE x " << c3 << endl;
    cout << "RE x " << c4 << endl;
}


Measured memory_bytes: 3584
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

string s;
char a,b,c;
int sz;

int main(){
    cin >> s;
    sz = s.size();
    a = s[0];
    b = s[1];
    if (a==b){
        cout << "1 2" << endl;
        return 0;
    }
    REP(i,sz-2){
        c = s[i+2];
        if (a==c){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
        a = b;
        b = c;
        if (a==b){
            cout << i+2 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

string s;
int n, k;
vector<char> ch;
vector<int> val, val2, val3;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    cin >> s;
    s = " " + s + " ";
    int cnt = 1;
    FOR(i,2,n+1)
        if (s[i] == s[i-1]) {
            cnt++;
        }
        else {
            ch.emplace_back(s[i-1]);
            val.emplace_back(cnt);
            cnt = 1;
        }
    FOR(i,0,SZ(ch)-1)
        if (ch[i] == '0') val2.emplace_back(i);
    FOR(i,0,SZ(ch)-1)
        if (i == 0) val3.emplace_back(val[i]);
        else val3.emplace_back(val3[SZ(val3)-1] + val[i]);

    if (SZ(val2) <= k) {
        cout << n;
        return 0;
    }
    int res = 0;
    FOR(i,k-1,SZ(val2)-1) {
        int l = i - k + 1;
        int vtL = val2[l];
        int vtR = val2[i];
        if (vtL > 0) vtL--;
        if (vtR < SZ(val)-1) vtR++;

        //cout << vtL << ' ' << vtR << endl;

        res = max(res, val3[vtR] - (vtL == 0 ? 0 : val3[vtL-1]));
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 2024
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
const int MAX_W = 100;
int H, W;
char as[MAX_W][MAX_W];
bool has_sharp_row[MAX_W];
bool has_sharp_column[MAX_W];


void solve() {
    for (int h = 0; h < H; ++h) {
        bool printed = false;
        for (int w = 0; w < W; ++w) {
            if (has_sharp_column[w] && has_sharp_row[h]) {
                printed = true;
                printf("%c", as[h][w]);
            }
        }
        if (printed) printf("\n");
    }
}

int main() {
    cin >> H >> W;
    for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W; ++w) {
            cin >> as[h][w];
            if (as[h][w] == '#') has_sharp_column[w] = has_sharp_row[h] = true;
        }
    }
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-2*powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans;
}


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

int main(){


  int N,K, num=1;
  cin >> N >> K;

  for(int i = 0; i < N; i++){
    if(num*2 <= num + K ){
      num *= 2;
    }else{
      num += K;
    }
    }
    cout << num << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int n,m;
vector<P> g[610];
vector<P> ps;
vector<int> mxe;
double dp[610];

void solve(int dame){
  rep(i,n)dp[i]=INF;
  dp[n-1]=0;
  for(int v=n-2;v>=0;v--){
    double mxd=-1;
    double cnt=0;
    double sum=0;
    for(P e : g[v]){
      if(e.se==dame&&g[v].size()>1)continue;
      if(mxd<dp[e.fi]){
        mxd=dp[e.fi];
        mxe[v]=e.se;
      }
      cnt++;
      sum+=dp[e.fi]+1.0;
    }
    dp[v]=sum/cnt;
  }
}

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

  cin>>n>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    ps.push_back(P(a,b));
    g[a].push_back(P(b,i));
  }
  mxe.resize(n-1,-1);
  solve(-1);
  vector<int> eidx=mxe;
  double res=INF;
  rep(i,n-1){
    solve(eidx[i]);
    minch(res,dp[0]);
  }
  printf("%.10f\n", res);

  return 0;
}


Measured memory_bytes: 9456
// Copyright (C) 2018 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int n = input<int>();

    vector<int64_t> psums(n + 1);
    for (int i = 1; i <= n; ++i)
        psums[i] = psums[i - 1] + input<int>();

    std::map<int64_t, int> cnt;
    for (int i = 0; i <= n; ++i)
        cnt[psums[i]] += 1;

    int64_t ans = 0;
    for (auto elem: cnt)
        ans += elem.second * int64_t(elem.second - 1);

    cout << ans / 2 << "\n";
    
    return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#define all(x) x.begin(), x.end()
using namespace std;

int main(){
    string s, t; cin >> s >> t;
    int n = s.size();
    int m = t.size();
    s = ' ' + s;
    t = ' ' + t;
    int dp[n+1][m+1];
    memset(dp, 0, sizeof(dp));
    loop(i, 1, n+1){
        loop(j, 1, m+1){
            if(s[i] == t[j]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = (dp[i-1][j] >= dp[i][j-1]) ? dp[i-1][j] : dp[i][j-1];
        }
    }

    int alen = dp[n][m];
    string ans = "";
    while(alen > 0){
        if(s[n] == t[m]){
            ans += s[n];
            n--; m--; alen--;
        } else if(dp[n][m] == dp[n-1][m]) n--;
        else m--;
    }
    reverse(all(ans));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35456
<?PHP
fscanf(STDIN, "%d %d", $N, $K);
While ($line = fgets(STDIN) ) {
    $stdin[] = trim($line);
}
$v2 = explode(" ", $stdin[0] );
$cnt=0;
foreach($v2 as $v){
  if ($K <= $v){
    $cnt++;
  }
}
echo $cnt;


Measured memory_bytes: 21372
r, c = map(int, input().split())
sheet = [list(map(int, input().split())) for _ in range(r)]

for i in range(r):
    sheet[i].append(sum(sheet[i]))
new_row = []
for j in range(c+1):
    sum_col = 0
    for i in range(r):
        sum_col += sheet[i][j]
    new_row.append(sum_col)
sheet.append(new_row)

for i in range(r+1):
    print(' '.join(str(x) for x in sheet[i]))

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

int main() {
  string S;
  cin >> S;
  set<char> st(S.begin(), S.end());
  if (S.size() == st.size()) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long lli;
 
int main() {
	lli n, t, p=p, q;
    cin >> n;
    if(360%n==0) cout << 360/n << endl;
    else{
      p+=n;
      q=1;
      while(p!=0){
      p=(p+n)%360;
      q++;
      }
      cout << q << endl;
    }
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>

const int MAX = 1000000;

using namespace std;

int count_exchange = 0;
int count_g = 0;

int each_g[500000];

void insertion(int a[], int n, int g) {
    for (int i = g; i < n; ++i) {
        int v = a[i];
        int j = i - g;
        while (j >= 0 && a[j] > v) {
            a[j+g] = a[j];
            j -= g;
            ++count_exchange;
        }
        a[j+g] = v;
    }
}

void shell_sort(int a[], int n) {
    int g = n;
    do {
        g = g / 3 + 1; 
        each_g[count_g++] = g;
        insertion(a, n, g);
    } while (g > 1);
}

void print(int a[], int n) {
    for (int i = 0; i < n; ++i)
        cout << a[i] << endl;
}

int
main(int argc, const char *argv[])
{
    int N;
    int a[MAX];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];
    shell_sort(a, N);
    cout << count_g << endl;
    for (int i = 0; i < count_g; ++i) {
        if (i) cout << " ";
        cout << each_g[i];
    }
    cout << endl << count_exchange << endl;
    print(a, N);

    return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N;
    cin >> N;
    for (int n = 1; n <= 3500; n++) {
        for (int w = 1; w <= 3500; w++) {
            lint a = 4 * n * w - (w + n) * N;
            if (a <= 0) continue;

            lint b = n * w * N;
            if (b % a != 0) continue;
            cout << n << ' ' << w << ' ' << (b / a) << endl;
            return 0;
        }
    }

    return 0;
}

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

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    long long A, B;
    cin >> A >> B;
    cout << lcm(A, B) << endl;
    return 0;
}

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

int main() {
  int N,X,T;
  cin >> N >> X>>T;

  if(N%X!=0){
    N = N/X+1;
  }else{
    N = N/X;
  }
  T=N*T;
  cout << T <<endl;

}


Measured memory_bytes: 3592
N=int(input())
S=input()
p_sum=[0]*N
max_sum=0
leader=0
count = 0

for i in range(N):
	if i==0:
		if S[i]=="W":
			max_sum=-1
			p_sum[i]=-1
		else:
			max_sum=1
			p_sum[i]=1
	else:
		if S[i]=="W":
			p_sum[i]=p_sum[i-1]-1
		else:
			p_sum[i]=p_sum[i-1]+1

	if max_sum < p_sum[i]:
		max_sum=p_sum[i]
		leader=i

for i in range(N):
	if i<leader:
		if S[i]=="W":
			count += 1
	elif i>leader:
		if S[i]=="E":
			count += 1

print(count)

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli n;
mat xy,yx;
lli max_elm = 0;
lli min_elm = LONG_MAX;
lli min_range = LONG_MAX;

int main(){
  cin >> n;
  xy = mat(n,vll(2));
  yx = mat(n,vll(2));
  for(lli i = 0;i < n;i++) cin >> xy[i][0] >> xy[i][1];
  for(lli i = 0;i < n;i++) if(xy[i][0] > xy[i][1]) swap(xy[i][0],xy[i][1]);
  for(lli i = 0;i < n;i++) yx[i][0] = xy[i][1],yx[i][1] = xy[i][0];
  sort(xy.begin(),xy.end());
  sort(yx.begin(),yx.end());
  min_elm = min(xy[0][1],yx[n-1][1]);
  max_elm = max(xy[0][1],yx[n-1][1]);
  for(lli i = 1;i < n;i++){
    min_range = min(min_range,max(xy[n-1][0],max_elm)-min(xy[i][0],min_elm));
    max_elm = max(max_elm,xy[i][1]);
    min_elm = min(min_elm,xy[i][1]);
  }

  cout << min(min_range*(yx[n-1][0]-xy[0][0]),(xy[n-1][0]-xy[0][0])*(yx[n-1][0]-yx[0][0])) << endl;


  return 0;
}


Measured memory_bytes: 24192
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>> v;
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		v.push_back({ b, a });
	}
	sort(v.begin(), v.end());
	rep(i, M) {
		// cout << v[i].first << " " << v[i].second << endl;
	}
	int ans = 0;
	int x = -1000000;
	rep(i, M) {
		if (x >= v[i].second) continue;
		else {
			x = v[i].first - 1;
			ans++;
			// cout << v[i].first << " " << v[i].second << endl;
		}
	}
	cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1400
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function main(input) {
  var lines = input.split('\n');

  var _splitNum = splitNum(lines[0]),
      _splitNum2 = _slicedToArray(_splitNum, 2),
      N = _splitNum2[0],
      K = _splitNum2[1];

  var as = splitNum(lines[1]).slice(0, N);

  if (as.indexOf(1) >= as.length / 2) {
    as.reverse();
  }

  var one = as.indexOf(1);
  var min = Infinity;

  for (var o = 0; o < K; o++) {
    var left = one - o;
    var right = one + K - 1 - o;

    if (left < 0 || right >= N) {
      continue;
    }

    var res = 1 + Math.ceil(left / (K - 1)) + Math.ceil((N - right - 1) / (K - 1));

    if (min > res) {
      min = res;
    }
  }

  console.log(min);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


Measured memory_bytes: 26432
#include "bits/stdc++.h"
using namespace std;
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
#define fore(i, a) for(auto &i:a)
#define print(x) cout << x << "\n"
#define SORT(a, n) sort(a, a+n);
#define REVERSE(a,n) reverse(a,a+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VREVERSE(v) reverse(v.begin(), v.end());
#define MOD 1000000007
#define yes "YES"
#define no "NO"
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;

int main() {
    fastcin;
    ll n;
    string ans = "ABC";
    cin >> n;
    if(n>999) ans = "ABD";
    print(ans);
    return 0;
}

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

using prime_factors_t = std::multiset<int64_t>;

int digitCount(int64_t n) {
  int ret = 1;
  while (n >= 10) {
    n /= 10;
    ret++;
  }
  return ret;
}

template <size_t N, size_t MaxPrimeSize>
struct primes_t {
  constexpr static size_t maxPrimeSize = MaxPrimeSize;
  constexpr primes_t() : primes(), count(), notSieves() {
    primes[count++] = 2;
    notSieves[0] = notSieves[1] = true;
    for (int i = 2; i < N; i++) {
      if (notSieves[i]) {
        continue;
      }
      primes[count++] = i;
      for (int64_t j = 2; i * j < N; j++) {
        notSieves[i * j] = true;
      }
    }
  }
  int64_t primes[MaxPrimeSize];
  int count;

 private:
  bool notSieves[N];
};

static constexpr auto primes = primes_t<100001, 9593>{};

prime_factors_t primeFactors(int64_t n) {
  prime_factors_t ret;
  int const maxPrimeCandidate = static_cast<int>(ceil(sqrt(n * 1.0)));
  for (int i = 0; n > 1 && i < primes.count; i++) {
    auto const prime = primes.primes[i];
    if (prime > maxPrimeCandidate) {
      break;
    }
    while (n % prime == 0) {
      ret.insert(prime);
      n /= prime;
    }
  }
  if (n > 1) {
    ret.insert(n);
  }
  return ret;
}

int solve(int64_t n) {
  if (n == 1) {
    return 1;
  }
  prime_factors_t factorsOfN = primeFactors(n);
  if (factorsOfN.size() == 1) {
    return std::max(digitCount(n), digitCount(1));
  }
  for (int i = static_cast<int>(ceil(sqrt(n * 1.0)));; i--) {
    prime_factors_t const factors = primeFactors(i);
    bool intersects = true;
    for (auto const factor : factors) {
      if (factorsOfN.count(factor) < factors.count(factor)) {
        intersects = false;
        break;
      }
    }
    if (intersects) {
      return std::max(digitCount(i), digitCount(n / i));
    }
  }
}

int main() {
  int64_t n;
  std::cin >> n;
  std::cout << solve(n) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int i,j;
	string s;
	cin>>s;
	int cnt=0;
	for(i=0;i<s.size();++i) if(s[i]=='o') ++cnt;
	cnt+=(15-s.size());
	if(cnt>7) cout<<"YES\n";
	else cout<<"NO\n";
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

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

signed main() {
  int n, m;
  cin >> n >> m;
  if(n <= m / 2) {
    m -= n * 2;
    cout << n + m / 4 << endl;
  }else {
    cout << m / 2 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int s;
  cin>>s;
  int a=s,count=1;
  set<int> S;
  S.insert(a);
  while(true){
    count++;
    if(a%2==0){
      a=a/2;
    }
    else{
      a=3*a+1;
    }
    int si=S.size();
    S.insert(a);
    int si2=S.size();
    if(si==si2){
      cout<<count<<'\n';
      break;
    }
  }
  return(0);
}


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

bool prime_checker(int x){
  if (x <= 1 ) return false;
  for (int i = 2; i * i <= x; i++)
  if (x % i == 0) return false;
  return true;
}

int main() {
  int N, M;
  cin >> N;
  M = N;
  while (!prime_checker(M)) M++;
  cout << M << endl;  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define REP(i, N) for (int (i) = 0; i < N; ++(i))

int main()
{
    int M, D;
    cin >> M >> D;
    if (M > D) cout << M - 1 << endl;
    else cout << M << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  ll N;

  cin >> N;

  cout << (N-1)*N / 2 << endl;

  return 0;
}


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

int main(){
  string s,t,u,v,w,ans;
  ll m,n,i;
  ans="Yes";
  cin >> s;
  n=s.length();
  m=n;
  n=(n-1)/2;
  t=s.substr(0,n);
  for(i=1;i<=n;i++){
    u+=s.substr(m-i,1);
  }
  for(i=1;i<=n;i++){
    v=t.substr(i-1,1);
    w=t.substr(n-i,1);
    if(v!=w){
      ans="No";
    }
  }
  if(t!=u){
    ans="No";
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long ans[10000];
int n;
int k;
long long dp[3000][3000];
int main(){
    cin >> n;
    cin >> k;
   for(int i=0;i<2001;i++){
       dp[i][0] = 1;
       dp[i][i] = 1;
       for(int j=1;j<i;j++){
           dp[i][j] = (dp[i-1][j] + dp[i-1][j-1])%1000000007;
       }
   }
    for(int i=1;i<=k;i++){
        cout << (dp[n-k+1][i]*dp[k-1][i-1])%1000000007 << endl;
    }
    return 0;
}

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

char ch;

void init(){
	
	scanf("%c", &ch);
	if(ch == 'a' or ch == 'e' or ch == 'i' or ch == 'o' or ch == 'u') {
		printf("vowel\n");
	}
	else {
		printf("consonant\n");
	}
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,K;
  vector<long long> v[11];
  cin>>n>>K;
  for(int i=0,c,g;i<n;i++){
    cin>>c>>g;
    v[g-1].push_back(c);
  }
  for(int i=0;i<10;i++){
    sort(v[i].begin(),v[i].end());
    reverse(v[i].begin(),v[i].end());
    for(int j=1;j<v[i].size();j++)
      v[i][j]+=v[i][j-1]+j*2;
  }
  long long dp[11][2001]={};
  for(int i=0;i<10;i++)
    for(int j=0;j<=K;j++){
      for(int k=0;k+j+1<=K&&k<v[i].size();k++){
    dp[i+1][k+j+1]=max(dp[i+1][k+j+1],dp[i][j]+v[i][k]);
      }
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    }
  cout<<dp[10][K]<<endl;
  return 0;
}

Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if (A+B == C+D) {
    cout << "Balanced" << endl;
  }else if(A+B > C+D){
    cout << "Left" << endl;
  }else{
    cout << "Right" << endl;
  }
}

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

using namespace std;
using lint = long long;

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

lint n, x, m, w, cnt1, cnt2;
vector<lint>vec;
bool used[100010];
int main() {
	cin >> n >> x >> m;

	lint a1 = x;
	while (true) {
		used[a1] = true;
		vec.push_back(a1);
		a1 = a1 * a1 % m;
		if (used[a1]) {
			w = a1;
			break;
		}
	}

	rep(i, vec.size()) {
		if (w == vec[i]) {
			cnt1 = i;
			break;
		}
	}

	cnt2 = vec.size() - cnt1;

	if (n <= cnt1 + 1) {
		cout << accumulate(vec.begin(), vec.begin() + n, 0LL) << endl;
	}
	else {
		lint res = accumulate(vec.begin(), vec.begin() + cnt1, 0LL);
		n -= cnt1;
		lint sum1 = accumulate(vec.begin() + cnt1, vec.end(), 0LL);
		res += n / cnt2 * sum1;
		n %= cnt2;
		res += accumulate(vec.begin() + cnt1, vec.begin() + cnt1 + n, 0LL);
		cout << res << endl;
	}
}


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

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

// Returns LCM of array elements


long long int  findlcm(int arr[], int n)
{
    // Initialize result
    long long int  ans = arr[0];

    // ans contains LCM of arr[0], ..arr[i]
    // after i'th iteration,
    for (int i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
int main()
{

    int n;
    cin>>n;

    int array[n];

    for(int i=0;i<n;i++){
        cin>>array[i];

    }

  long long a=findlcm(array,n);
  double sum=0;

  for(int i=0;i<n;i++){
    sum+=a/array[i];
  }

  double ans=0;
  ans=a/sum;
  cout<<ans<<endl;


    return 0;
}


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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
//using u64 = long long;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;
#define mod 1000000007
u64 modinv(u64 a, u64 m) {
    u64 b = m, u = 1, v = 0;
    while (b) {
        u64 t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
u64 F[1000007], FInv[1000007];

void generate(){
    FInv[0] = F[0] = 1;
    
    for (int i = 1; i < 1000007; i++) {
        F[i] = (F[i - 1]*i) % mod;
        FInv[i] = (FInv[i - 1] * modinv(i, mod)) % mod;
    }
}

int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    u64 X, Y;
    cin >> X >> Y;
    u64 W, H;
    W = 2* X - Y, H = 2*Y - X;
    if (W < 0 || H < 0 || W % 3 || H % 3) {
        cout << 0 << endl;
        return 0;
    }
    generate();
    u64 ans = 1;
    W /= 3, H /= 3;
    ans = (ans * F[W+H]) % mod;
    ans = (ans * FInv[W]) % mod;
    ans = (ans * FInv[H]) % mod;
    cout << ans << endl;
    
    return 0;
    
}


Measured memory_bytes: 19248
arr = list(map(int, input().split()))
arr.sort()

count = 0
while(True):
    if arr[1] < arr[2]:
        arr[1] += 1
        arr[0] += 1
        count += 1
    else:
        break

while(True):
    if arr[0] < arr[2]:
        arr[0] += 2
        count += 1
    else:
        break

if arr[0] == arr[1] == arr[2]:
    print(count)
else:
    print(count+1)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void){
  string S;
  cin >> S;

  int count_A = 0, count_B = 0;
  for(int i=0; i<3; i++){
    if(S[i] == 'A')
      count_A++;
    else if(S[i] == 'B')
      count_B++;
  }

  if(count_A>0 && count_B>0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    
  return 0;
}


Measured memory_bytes: 256