akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rp(i,n) for(int i=1;i<=(int)n;i++)
int main(){
int n,m;cin>>n>>m;
vector<int>a(n);
int sum=0;
rep(i,n){
    cin>>a[i];
    sum+=a[i];
}
double vote=1.0/4/m;
vote*=sum;
int count=0;
rep(i,n){
    if(a[i]>=vote)count++;
}
if(count>=m)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

typedef long long llong;

int main() {
	int n; cin >> n;
	int A[10000];
	int maxv, minv;
	llong sum;

	cin >> A[0];
	maxv = minv = sum = A[0];

	for (int i = 1; i < n; i++) {
		scanf("%d", &A[i]);
		if (maxv < A[i]) maxv = A[i];
		else if (minv > A[i]) minv = A[i];
		sum += A[i];
	}

	cout << minv << " " << maxv << " " << sum << endl;

	return 0;
}


Measured memory_bytes: 3252
from collections import deque

H, W = map(int, input().split())
s = []
for _ in range(H):
    s.append(input())
dh = [0, 0, 1, -1]
dw = [1, -1, 0, 0]
ans = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == "#":
            continue
        dismax = 0
        dist = [[-1 for j in range(W)] for i in range(H)]
        queue = deque([[i, j]])
        dist[i][j] = 0
        while len(queue) != 0:
            now = queue.popleft()
            h = now[0]
            w = now[1]
            for k in range(4):
                nh = h + dh[k]
                nw = w + dw[k]
                if nh < 0 or nw < 0 or nh >= H or nw >= W:
                    continue
                if dist[nh][nw] != -1 or s[nh][nw] == "#":
                    continue
                else:
                    dist[nh][nw] = dist[h][w] + 1
                    dismax = max(dist[nh][nw], dismax)
                    queue.append([nh, nw])
        ans = max(ans, dismax)
print(ans)

Measured memory_bytes: 47068
import java.io.PrintWriter;
import java.util.* ;

class Main {


    public static void main(String[] args)  {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int A = in.nextInt();
        int B = in.nextInt();
        int max = Integer.MIN_VALUE;
        int sum = A + B;
        if(sum > max) {
            max = sum ;
        }
        int sub = A - B ;
        if(sub > max) {
            max = sub;
        }
        int mul = A * B ;
        if(mul > max) {
            max = mul ;
        }
        pw.println(max);
        pw.close();
        
    }
}

Measured memory_bytes: 22996
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    string ans;
    rep(i, N) {
        ans += "ACL";
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
N = int(input())
S = list(input())

num = len(set(S))

result = 0
for i in range(N-1):
  A = S[0:i+1]
  B = S[i+1:N]
  
  tmp = len(list(set(A) & set(B)))
  if tmp > result:
    result = tmp
  elif tmp == num:
    result = num
    break
  
print(result)

Measured memory_bytes: 3060
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    string s;
    cin >> s;
    if(s=="ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
    cin>>c;
    if((c=='a')||(c=='e')||(c=='i')||(c=='o')||(c=='u')){
      cout<<"vowel"<<endl;
    }
 
  else cout<<"consonant"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b) 
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;

lli mod197 = 1000000007LL;

lli x[1000000] = {};

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli N, X;
	cin >> N >> X;

	for (int i = 0; i < N; i++) {
		cin >> x[i];
		x[i] -= X;
		CHABS(x[i]);
	}

	lli D = x[0];

	for (int i = 0; i < N; i++) {
		lli a, b;
		::extgcd<lli>(D, (x[i]), a, b);
		D = D * a + x[i] * b;
	}

	COUT(D);

	return 0;
}

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

int main() {

    long long X;
    cin >> X;

    long long P = 100, step = 0;

    while (P < X) {
        P += P / 100;
        step++;
    }

    cout << step << endl;

    return 0;
}

Measured memory_bytes: 3600
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

# ax ≡ 1 (mod m)なるxを返す
def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m


MOD=10**9+7
n=int(input())
x=list(map(int,input().split()))

P=1
for i in range(1,n):
    P=(P*i)%MOD

s=0
ans=0
for i in range(1,n):
    l=x[i]-x[i-1]
    s=s+P*modinv(i,MOD)
    s%MOD
    ans+=l*s
    ans%=MOD

print(ans%MOD)


Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
const int MAX = 1000000000;

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
//------------------------------------------------------------------------------------------------------------------------------

int c, N;
vector<vector<int>> G;
vector<int> color;
void dfs(int v) {
    color[v] = c;
    for (auto nv : G[v]) {
        if (color[nv] >= 0) {
            continue;
        }
        dfs(nv);
    }
    return;
}

int main(void) {
    int M;
    cin >> N >> M;
    G.resize(N);
    color.resize(N, -1);
    c = 0;
    for (int i = 0; i < M; i++) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    for (int i = 0; i < N; i++) {
        if (color[i] >= 0) {
            continue;
        }
        dfs(i);
        c++;
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int s, t;
        cin >> s >> t;
        if (color[s] == color[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 11812
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){
  vector<int> A(3);
  for(int i = 0; i < 3; i++) cin >> A[i];
  cout << *max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end()) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, cnt = 0, ans = 0, tmp = 0;

int main(){
    char S[111000];
    cin >> S;
    bool app[26];
    rep(i, 26) app[i] = false;
    for(int i = 0 ; S[i] != '\0'; i++){
        //cout << S[i] - 'a' << endl;
        //cout <<S[i] - '0' << endl;
        app[S[i] - 'a'] = true;
    }
    rep(i, 26){
        if(!app[i]){
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n;  cin >> n;
    string s;
    cin >> s;

    long long r = 0, g = 0, b = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R')
            r++;
        if (s[i] == 'G')
            g++;
        if (s[i] == 'B')
            b++;
    }

    long long ans = r*g*b;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            if (s[i] != s[j]) {
                int k = 2*j-i;
                if (k < n) {
                    if (s[k] != s[j] && s[k] != s[i])
                        ans--;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 



int main(){
    int a;
    string s;cin >> a >> s;
    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

int N;

int main() {
    cin >> N;
    int ans = 0;
    int mx = 0;
    REP (i, N) {
        int h; cin >> h;
        if (h >= mx) ans++;
        mx = max(mx, h);
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
	int n,v; cin >> n >> v;
	int x = -1,y,z;
	bool flag = false;
	for(z = 0; z <= n; z++){
		for(y = 0; y + z <= n; y++){
			x = n - y - z;
			if((10000 * x + 5000 * y + 1000 * z) == v){
				flag = true;
				break;
			}
		}
		if(flag)break;
	}
	if(flag){
		printf("%d %d %d\n", x, y, z);
	}
	else{
		cout << "-1 -1 -1" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
import math

def main():
    a, b, x = list(map(int, input().split()))

    if (x / a) > (a * b) / 2:
        h = (2/a) * ((a*b) - (x/a))
        r = math.atan2(h, a)
    else:
        area = x / a
        h = (2 * area) / b
        r = math.atan2(b, h)

    ans = r * 180 / math.pi
    print(ans)



if __name__ == "__main__":
    main()

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

class dice{
public:
	int init_label[6];
    int label[6];
    int tmp1, tmp2;

	void setnumber(){
		for(int i=0; i<6; i++)
			cin >> init_label[i];
    }

    void check(int over, int front){
    	if(over == label[0]){
    		if(front == label[1]){
    			cout << label[2] << endl;
    		}
    		else if(front == label[2]){
    			cout << label[4] << endl;
    		}
    		else if(front == label[4]){
    			cout << label[3] << endl;
    		}
    		else if(front == label[3]){
    			cout << label[1] << endl;
    		}
    	}
    }

    void rotation(string sign){
            tmp1 = label[0];
            tmp2 = label[5];
            if(sign == "N"){
                label[0] = label[1];
                label[5] = label[4];
                label[1] = tmp2;
                label[4] = tmp1;
            }
            if(sign == "S"){
                label[0] = label[4];
                label[5] = label[1];
                label[4] = tmp2;
                label[1] = tmp1;
            }
            if(sign == "W"){
                label[0] = label[2];
                label[5] = label[3];
                label[2] = tmp2;
                label[3] = tmp1;
            }
            if(sign == "E"){
                label[0] = label[3];
                label[5] = label[2];
                label[3] = tmp2;
                label[2] = tmp1;
            }
            if(sign == "NN"){
            	label[0] = tmp2;
            	label[5] = tmp1;
            	int tmp3 = label[4];
            	label[4] = label[1];
            	label[1] = tmp3;
            }
        }

    void initialization(void){
    	for(int i=0; i<6; i++){
    		label[i] = init_label[i];
    	}
    }
};

int main(){
	dice d;
	d.setnumber();
	int n; cin >> n;
	string rot_info[6] = {"","N","W","E","S","NN"};

	for(int i=0; i<n; i++){
		int over,front; cin >> over >> front;
		for(int j=0; j<6; j++){
			d.initialization();
			d.rotation(rot_info[j]);
			d.check(over,front);
		}
	}
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max(a - 2 * b, 0) << "\n";
    return 0;
}

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

const int inf = 1<<20;
int Cost[100][100];
int Time[100][100];

int main()
{
	int n,m,k,a,b,c,t;
	while(cin >> n >> m, (n||m))
	{
		for(int i=0; i<m; i++)
		for(int j=0; j<m; j++)
		{
			Cost[i][j] = Time[i][j] = (i==j?0:inf);
		}

		while(n--)
		{
			cin >> a >> b >> c >> t;
			a--; b--;
			Cost[a][b] = Cost[b][a] = c;
			Time[a][b] = Time[b][a] = t;
		}
	
		for(int l=0; l<m; l++)
		for(int i=0; i<m; i++)
		for(int j=0; j<m; j++)
		{
			if(Time[i][j]>Time[i][l]+Time[l][j]) Time[i][j] = Time[i][l]+Time[l][j];
			if(Cost[i][j]>Cost[i][l]+Cost[l][j]) Cost[i][j] = Cost[i][l]+Cost[l][j];
		}

		cin >> k;
		while(k--)
		{
			cin >> a >> b >> t;
			a--; b--;
			if(t==0){ cout << Cost[a][b] << endl; }
			if(t==1){ cout << Time[a][b] << endl; }
		}
	}
}

Measured memory_bytes: 940
def ans(n, k, list_a):
    i=0
    dic={}
    dic[1]=1
    list_memo=[1]
    while i<k:
        next = list_a[list_memo[i]-1]
        if next not in dic:
            list_memo.append(next)
            dic[next]=1
        else:
            num=list_memo.index(next)
            len_list=len(list_memo)
            i+=1
            x = len_list-num
            k=k-num
            
            #print(k)
            k%=x
            return list_memo[num+k]
            #return 50000
            
        i+=1
    return list_memo[i]
        




n, k = (int(x) for x in input().split())
list_a = list(map(int, input().split()))
print(ans(n, k, list_a))

Measured memory_bytes: 114000
#include <bits/stdc++.h>
#define res register int
using namespace std;

inline long long read()
{
	char ch=getchar();
	long long x=0;int f=0;
	while(ch<'0'||ch>'9')
	{
		f|=ch=='-';
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return f?-x:x;
}
inline long long gcd(long long a,long long b)
{
	return b==0?a:gcd(b,a%b);
}
inline long long f(long long a,long long b)
{
	long long tmp=gcd(a,b);
	if(tmp==1)
	return max(a,b)*3-3;
	else
	return f(a/tmp,b/tmp)*tmp;
}
int main()
{
	long long a=read(),b=read();
	printf("%lld\n",f(a,b));
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <stack>
using namespace std;

int main(){
        string word;
        stack<int> num;
        int a=0, b=0;
        while(cin >> word) {
                if (word == "+") {
                        a = num.top();
                        num.pop();
                        b = num.top();
                        num.pop();
                        num.push(b + a);
                } else if (word == "-") {
                        a = num.top();
                        num.pop();
                        b = num.top();
                        num.pop();
                        num.push(b - a);
                } else if (word == "*") { 
                        a = num.top();
                        num.pop();
                        b = num.top();
                        num.pop();
                        num.push(b * a);
                } else {
                        num.push(atoi(word.c_str()));
                }
        }
        cout << num.top() << endl;

        return 0;
}

Measured memory_bytes: 1200
#include <stdio.h>

int main()
{
  int i,n;
  int a[100001];
  int b[100001];
  long score;
  scanf("%d", &n);
  for(i=0;i<n+1;i++){
    scanf("%d", &a[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d", &b[i]);
  }
  score=0;
  for(i=0;i<n;i++){
    if(a[i]<=b[i]){
      score+=a[i];
      b[i]-=a[i];
      a[i]=0;
      if(a[i+1]<=b[i]){
        score+=a[i+1];
        b[i]-=a[i+1];
        a[i+1]=0;
      }else{
        score+=b[i];
        a[i+1]-=b[i];
        b[i]=0;
      }
    }else{
      score+=b[i];
      a[i]-=b[i];
      b[i]=0;
    }
  }

  printf("%ld\n", score);
  return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<ctype.h>
#include<math.h>
#define PI 3.14159265359
#define N_MAX 10000
#define NUM 1000
#define min(x,y) ((x) < (y) ? (x) : (y))
#define max(x,y) ((x) > (y) ? (x) : (y))

bool prime(const int n)
{
  int i;
  if(n <= 1) return false;
  if(n == 2) return true;
  for(i = 2; i <= sqrt(n); i++)
    {
      if(n%i == 0) return false; 
    }
  return true;
}

int main()
{
  int i,n,count = 0,a[N_MAX];
  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&a[i]);
  for(i = 0; i < n; i++)
    {
      if(prime(a[i])) count++;
    }
  printf("%d\n",count);
  return 0;
}

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

int main(){
    int n, ans = 0;
    cin >> n;
    string s;
    cin >> s;
    for(int i=1;i<=n;i++) {
        int len = 0;
        for(int j=0;j+i<n;j++) {
            if(s[j] == s[j+i]) {
                if(len < i)
                    len++;
                ans = max(ans, len);
            }
            else
                len = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))
root = []
ans = 0

for i in range(0, n-1):
    x = a[i+1] - a[i]
    root.append(x)

y = a[0] + k - a[n-1]
root.append(y)

for i in root:
    ans += i

ans -= max(root)
print(ans)    

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, D,X[101][101];
ll i,j,k,ans;
int main(){
    scanf("%lld%lld", &N,&D);
    fornum(i,0,N){
        fornum(j,0,D){
            scanf("%lld", &X[i][j]);
        }
    }
    fornum(i,0,N){
        fornum(k,i+1,N){
            ll aa = 0;
            fornum(j,0,D){
                ll bb=X[i][j] - X[k][j];
                aa += bb * bb;
            }
            for (j = 0; j * j <= aa;j++){
                if(aa==j*j)
                    ans++;
            }
        }
    }
    printf("%lld", ans);

    return 0;
}

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

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

	int64_t ans = n * (n + 1) / 2;

	for (int64_t i = 2; i <= n; i++)
	{
		int64_t j = n / i;

		ans += i * (j * (j + 1) / 2);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3612
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define MOD 1000000007
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
int n;
int main(){
    read(n);
    ll x;read(x);
    ll ans=x;
    for (int i=1;i<n;i++){
        read(x);
        ans=ans/__gcd(ans,x)*x;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod7=1000000007LL;
inline LL get(){
    LL _x=0,_tmp=1; char _tc=getchar();
    while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
    if( _tc == '-' ) _tc=getchar() , _tmp = -1;
    while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
    return _x*_tmp;
}

const int INF = 2*1e9;
int main() {
    int N;
    cin >> N;
    int a[100005];
    int dp[100005];

    for (int i = 0; i<N; ++i)
        dp[i] = INF;
    dp[0] = 0;
    for (int i = 0; i<N; ++i) a[i] = get();
    dp[1] = abs(a[0] - a[1]);
for (int i= 2; i<N; ++i){
dp[i] = min(dp[i - 1] + abs(a[i - 1] - a[i]), dp[i - 2] + abs(a[i - 2] - a[i]));
}
    
cout << dp[N -1 ] << endl;
}


Measured memory_bytes: 1024
# coding:utf-8

import math

def main():
    n,a,b,c,d = map(int, raw_input().split())
    s = list(raw_input())
    chk = True
    cnt = 1
    hurdleA = 0
    hurdleB = 0
    three = 0
    threeChk = False
    for i in s:
        if cnt >= b-1 and cnt <= d+1:
            if i == '.':
                three += 1
            else:
                three = 0
            if three >= 3:
                threeChk = True
        if cnt > a and cnt < c:
            if i == '#':
                hurdleA += 1
            else:
                hurdleA = 0
            if hurdleA >= 2:
                chk = False
                break
        if cnt > b and cnt < d:
            if i == '#':
                hurdleB += 1
            else:
                hurdleB = 0
            if hurdleB >= 2:
                chk = False
                break
        cnt += 1
    if c > d and (s[d-2] == '#' or s[d] == '#') and threeChk == False:
        print "No"
    elif chk == False:
        print "No"
    else:
        print "Yes"

if __name__ == "__main__":
    main()



Measured memory_bytes: 4460
#include <stdio.h>
#define CARD 4
#define NUM 13
int cvt_char_to_num(char);
char cvt_num_to_char(int);
void Card();
void outputCard(int [4][13]);

int cvt_char_to_num(char card){
	switch (card){
	case'S':return 0;
	case'H':return 1;
	case'C':return 2;
	case'D':return 3;
	default:return -1;
	}
}
char cvt_num_to_char(int card){
	switch (card){
	case 0:return 'S';
	case 1:return 'H';
	case 2:return 'C';
	case 3:return 'D';
	default:return -1;
	}
}
void Card(){
	int card[4][13] = {0};
	int max_num, card_num;
	char card_char;
	scanf("%d", &max_num);
	while (max_num--){
		scanf(" %c %d", &card_char, &card_num);
		card[cvt_char_to_num(card_char)][--card_num] = 1;
	}
	outputCard(card);
}
void outputCard(int card[4][13]){
	int i, j;
	for (i = 0; i < CARD; i++){
		for (j = 0; j < NUM; j++){
			if (!card[i][j])printf("%c %d\n", cvt_num_to_char(i),j+1);
		}
	}
}

int main(void){
	Card();
	return 0;
}

Measured memory_bytes: 596
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

ll n;

int main(){
  cin >> n;
  vi v;
  ++n;
  int len = 63 - __builtin_clzll(n);
  per(i,0,len) {
    v.pb(sz(v) + 1);
    if(n >> i & 1)
      v.insert(v.begin() , sz(v) + 1);
  }
  vi nv;
  rep(i,0,sz(v)) nv.pb(i + 1);
  v.insert(v.end(),all(nv));
  cout << sz(v) << endl;
  rep(i,0,sz(v)) cout << v[i] << " \n"[i+1==sz(v)];
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  ll res = 1000000;
  for(int i = 1;i < n;i++){
    ll now = 0;
    string a = to_string(i);
    string b = to_string(n - i);
    for(int j = 0;j < (int)a.size();j++)now += a[j] - '0';
    for(int j = 0;j < (int)b.size();j++)now += b[j] - '0';
    res = min(res,now);
  }
  cout << res << endl;
}

Measured memory_bytes: 3664
N = int(input())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    return arr


res = factorization(N)
sum = 0

steps = [1]

for i in range(2, 300):
    steps.append(steps[-1] + i)

if len(res) == 0:
    print(0)
else:
    for fact in res:
        num = fact[-1]
        count = 0
        for s in steps:
            if s > num:
                break
            count += 1
            
        sum += count

    print(sum)


Measured memory_bytes: 63364
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int a[] = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = stdIn.nextInt();
        }

        for (int i = n - 1; i >= 0; i--) {
            if (i == 0)
                System.out.print(a[i]);
            else
                System.out.print(a[i] + " ");

        }

        System.out.println();
    }
}


Measured memory_bytes: 26328
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e16;
int n, W;
long long w[110];
int v[110];
long long dp[110][100010];

int main() {
    cin >> n >> W;
    for(int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
    }

    int maxV = n*1000;

    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= maxV; ++j) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= maxV; ++j) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j] + w[i]);
        }
    }

    long long ans = 0;
    for(int j = 0; j <= maxV; ++j) {
        if(dp[n][j] <= W) {
            ans = j;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 80128
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;


bool sankaku(int a, int b, int c) {
    int max_ = a;
    if (max_ < b) {
        max_ = b;
    }
    if (max_ < c) {
        max_ = c;
    }
    if (a + b + c - max_ > max_) {
        return true;
    }
    else {
        return false;
    }
}


int nani_sankaku(int a, int b, int c) {
    int hen[3] = {a, b, c};
    sort(hen, hen + 3);
    double ab = pow(hen[0], 2) + pow(hen[1], 2);
    double c_ = pow(hen[2], 2);
    if (ab > c_) {
        return 2;
    }
    if (ab == c_) {
        return 1;
    }
    if (ab < c_) {
        return 3;
    }

}


int main() {
    int ANS[4] = {0, 0, 0, 0};
    while (true) {
        int a;
        int b;
        int c;
        cin >> a >> b >> c;

        if (sankaku(a, b, c)) {
            ANS[nani_sankaku(a, b, c)]++;
            ANS[0]++;
        }
        else {
            cout << ANS[0] << ' ' << ANS[1] << ' ';
            cout << ANS[2] << ' ' << ANS[3] << '\n';
            return 0;
        }
    }
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
void dfs(vector<int> &c, vector<vector<pair<int, int>>> &E, int v = 0){
  int cnt = E[v].size();
  set<int> st;
  for (int i = 1; i <= cnt; i++){
    st.insert(i);
  }
  for (auto P : E[v]){
    int id = P.second;
    if (c[id] != -1){
      st.erase(c[id]);
    }
  }
  vector<int> color;
  for (int x : st){
    color.push_back(x);
  }
  for (auto P : E[v]){
    int w = P.first;
    int id = P.second;
    if (c[id] == -1){
      c[id] = color.back();
      color.pop_back();
      dfs(c, E, w);
    }
  }
}
int main(){
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> E(N);
  for (int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    E[a].push_back(make_pair(b, i));
    E[b].push_back(make_pair(a, i));
  }
  vector<int> c(N - 1, -1);
  dfs(c, E);
  int K = 0;
  for (int i = 0; i < N - 1; i++){
    K = max(K, c[i]);
  }
  cout << K << endl;
  for (int i = 0; i < N - 1; i++){
    cout << c[i] << endl;
  }
}

Measured memory_bytes: 23912
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        ta: [(usize, usize); n],
    }
    let mut t_cnt = 1;
    let mut a_cnt = 1;
    for i in 0..n {
        let n = max((t_cnt + ta[i].0 - 1) / ta[i].0, (a_cnt + ta[i].1 - 1) / ta[i].1);
        t_cnt = n * ta[i].0;
        a_cnt = n * ta[i].1;
    }

    println!("{}", t_cnt + a_cnt);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF (long long)1 << 61
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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

int main() {
	string S;cin >> S;
    int N = S.length();
    int inf = 1<<30;
    vector<vector<int>> dp(N+2,vector<int> (11,inf));
    reverse(S.begin(),S.end());
    dp[0][S[0]-'0']=0;
    REP(i,N+1){
        REP(j,11){
            if(dp[i][j]!=inf){
                // cout << "a:" << i << j << endl;
                int n = (i+1<N) ? S[i+1]-'0':0;
                // cout << n << endl;
                if(j==10){
                    // 繰り上がり，０
                    dp[i+1][n+1]=min(dp[i+1][n+1],dp[i][j]);
                }else{
                    // そのまま
                    dp[i+1][n]=min(dp[i+1][n],dp[i][j]+j);
                    // 繰り上がり
                    dp[i+1][n+1]=min(dp[i+1][n+1],dp[i][j]+10-j);                    
                }
            }
        }
    }
    int ans = min( dp[N][0], dp[N+1][0]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 87172
result = true

_n = gets
pn = gets.chomp.split.map(&:to_i)

sorted_pn = pn.sort

if pn == sorted_pn
  puts 'YES'
  exit
end

diff = []
sorted_pn.each_with_index do |n, i|
  diff.push(i) if n != pn[i]

  if diff.count > 2
    result = false
    break
  end
end

puts result ? 'YES' : 'NO'


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

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

  vector<bool> ok(m, true);

  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    vector<bool> a(m, false);
    for (int j = 0; j < k; ++j) {
      int idx;
      cin >> idx;
      a[idx - 1] = true;
    }
    for (int j = 0; j < m; ++j) {
      ok[j] = ok[j] && a[j];
      // cerr << ok[j] << " ";
    }
    // cerr << '\n';
  }

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

  cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 3628
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    int n; cin>>n;
    // n--;
    vi v;
    while(n>0){
        int c=n%26;
        if(c==0) {
            c=26;
            n=(n/26)-1;
        }
        else n=n/26;
         v.pb(c);
        // n=n/26;
    }
    reverse(all(v));
    fi(i,v.size()) cout<<char(v[i]+'a'-1);
    cout<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 15016
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int calck(int a, int b){
  if(a > b)swap(a,b);
  return b/(a+1) + (b % (a+1) != 0);
}

void solve(){
  Int a, b, c, d;
  cin >> a >> b >> c >> d;
  int k = calck(a, b);
  int bottom = 0, top = a+b;
  if((a+b)/(k+1) == a)top = 0;
  if((a+b)/(k+1) == b)bottom =a+b;
  while(top - bottom > 1){
    int mid = (top + bottom) / 2;
    int l = mid;
    while(l > 0 && l % (k+1) == k && (a+b-l) % (k+1) == 0 && (a+b-l) > 0 || l % (k+1) == 0 && l > 0 && (a+b-l) % (k+1) == k)l--;
    if(l / (k+1) * k + l % (k+1) + (a+b-l) / (k+1) >= a)top = mid;
    else bottom = mid;
  }
  int l = top;
  if(l % (k+1) == k && (a+b-l) % (k+1) == 0 && (a+b-l) > 0)l--;
  else if(l % (k+1) == 0 && l > 0 && (a+b-l) % (k+1) == k)l--;
  //  cout << l << endl;
  for(int i = c;i <= d;i++){
    if(i <= l){
      if(i % (k+1) == 0)cout << 'B';
      else cout << 'A';
    }
    else{
      if((a+b-i+1) % (k+1) == 0)cout << 'A';
      else cout << 'B';
    }
  }
  cout << endl;
}

int main(){
  Int q;
  cin >> q;
  while(q--)solve();
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
	ll X;
	cin >> X;
	X = abs(X);
	ll pos = 0;
	ll i = 1;
	while (1){
		pos += i;
		if (pos >= X){
			break;
		}
		i++;
	}
	cout << i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main() {
    int n, m;
    cin >> n >> m;
    vi pre(n+1,1);
    vvi py(m, vi(3));
    rep(i, m) {
        cin >> py[i][1];
        cin >> py[i][0];
        py[i][2] = i;
    }
    sort(py);
    vs rine(m);
    rep(i, m) {
        int x = pre[py[i][1]];
        pre[py[i][1]]++;
        string right = to_string(x);
        while (right.size() < 6) right = "0" + right;
        
        string left = to_string(py[i][1]);
        while (left.size() < 6) left = "0" + left;
        string ans = left + right;
        rine[py[i][2]] = ans;
    }
    for (string x : rine)cout << x << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  if ((N - N % 10) % 111 == 0) {
    cout << "Yes" << endl;
  }
  else if ((N % 1000) % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int a,b,c;
    cin>>a>>b>>c;
    if((a==b && b!=c) || (a==c && c!=b) || (b==c && c!=a)) cout<<"Yes";
    else cout<<"No";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll MOD=1000000007;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

int main(){
   
   string s;
   cin>>s;

   int x=s.size();

   int cnt=0;
   char c=s[0];

   rep(i,x){
      if(s[i]!=c){
         cnt++;
         c=s[i];
      }
   }

   cout<<cnt;
   return 0;
}


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

int Max(int a, int b) {
	if (a < b) return b; else return a;
}

int Min(int a, int b) {
	if (a < b) return a; else return b;
}

int main(void)
{
	int A, B, AB, X, Y;
	long int ans, min = -1;
	scanf("%d %d %d %d %d", &A, &B, &AB,&X,&Y);
	for (int i = 0; i <= 100000; i++) {
		ans = i * 2 * AB + Max(0, X - i)*A + Max(0, Y - i)*B;
		if (min < 0 || ans < min) {
			min = ans;
		}
	}
	printf("%ld\n", min);

	return 0;
}


Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(x: i64);
    let pw5 = |y: i64| y * y * y * y * y;
    for a in -200..200 {
        for b in -200..200 {
            let diff = pw5(a) - pw5(b);
            if diff == x {
                puts!("{} {}\n", a, b);
                return;
            }
        }
    }
    assert!(false);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main(void) {
    ll a,b;
    cin>>a>>b;
    if (a <= 0 && 0 <= b) cout << "Zero" << endl;
    else if (a > 0) cout << "Positive" << endl;
    else {
        if ((b - a) % 2 == 0) cout << "Negative" << endl;
        else cout << "Positive" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main(){
  int a,b;
  string s;
  cin >> a >> b;
  cin >> s;
  for(int i=0; i<a;i++){
        if(i==b-1) s[i]=tolower(s[i]);
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

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

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  int64_t res = numeric_limits<int64_t>::max();
  for (int t = 0; t < 2; ++t) {
    int64_t r = 0;
    int s = 0;
    for (int i = 0; i < n; ++i) {
      s += a[i];
      if (t != i % 2) s *= -1;
      if (s <= 0) {
        r += 1 - s;
        s = 1;
      }
      if (t != i % 2) s *= -1;
    }
    chmin(res, r);
  }
  cout << res << endl;
}



Measured memory_bytes: 640