akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

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

template<typename T1, typename T2>
ostream& operator << (ostream& os, const map<T1, T2>& m){
  for (const auto [k, v] : m) os << "{" << k << "," << v << "} ";
  return os;
}

int main() {
  int N; cin >> N;
  LL sum = 0;
  map<LL, LL> m;
  for (int i = 0; i < N; ++i) {
    int a; cin >> a;
    m[a]++;
    sum += a;
  }

  int Q = 0; cin >> Q;
  for (int i = 0; i < Q; ++i) {
    LL b, c; cin >> b >> c;
    sum -= b * m[b];
    sum += c * m[b];
    m[c] += m[b];
    m[b] = 0;
    cout << sum << endl;
  }
}


Measured memory_bytes: 9440
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int a[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int k;
	scanf("%d",&k);
	printf("%d\n",a[k]);
	return 0;
}

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

using namespace std;

int main(){
    int a,z;
    string s;
    cin>>s;

    for(int i=0; i<s.length(); i++){
        if(s[i]=='A'){
            a=i;
            break;
        }
    }

    for(int i=s.length()-1; i>=0; i--){
        if(s[i]=='Z'){
            z=i;
            break;
        }
    }

    cout<<z-a+1<<endl;
    return 0;

}

Measured memory_bytes: 640
#include<stdio.h>
#define N 100
int main()
{
  int M[N][N];
  int n,u,v,k,i,j;


  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j] = 0;
    }
  }
  for(i=0;i<n;i++)
    {
      scanf("%d %d",&u,&k);
      u--;
      for(j=0;j<k;j++)
	{
	  scanf("%d",&v);
	  v--;
	  M[u][v] = 1;
	}
    }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j!=0)
	{
	  printf(" ");
	}
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2072
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;



int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a.begin(), a.end());

	vector<ll> sum(n+1);
	sum[0] = 0;
	for (int i = 1; i <= n; i++) {
		sum[i] = sum[i-1] + a[i - 1];
	}

	int ans = n;
	int mi = 0;

	for (int i = 1; i < n; i++) {
		if (2 * (sum[i] - sum[0]) < a[i]) {
			mi = max(mi, i);
		}
	}
	ans -= mi;

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(void){
  int D; scanf("%d",&D);
  switch (D) {
    case 22:printf("Christmas Eve Eve Eve\n"); break;
    case 23:printf("Christmas Eve Eve\n"); break;
    case 24:printf("Christmas Eve\n"); break;
    case 25:printf("Christmas\n"); break;
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n;
    cin >> n;
    ll m = n+1, no = n;

    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i==0) 
        { 
            if (n/i == i){
                if(i+i < m) {
                    m = i+i;
                    no = i;
                }
            }   
            else
            { 
                if(i + n/i < m) {
                    m = i + n/i;
                    no = i;
                }
            } 
        }
    }
    cout << m - 2<< endl;
}

Measured memory_bytes: 256
n=int(input())
list=[]
for i in range(n):
    l,r=map(int,input().split())
    list.append(l)
    list.append(r)
#print(list)
sum=0
for i in range(int(len(list)/2)):
    sum+=list[2*i+1]-list[2*i]+1
print(sum)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int M,ans=-1,g=0;
  cin>>M;
  vector<pair<int,int>> A(M);
  for(pair<int,int> &p:A){
    cin>>p.first>>p.second;
    ans+=p.second;
    g+=p.first*p.second;
  }
  cout<<ans+(g-1)/9<<endl;
}

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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}
//_____________________________________________________\\

map<ll,ll>m;

void findPrimeFactors(ll n)
{

    while (n%2== 0) m[2]++, n = n/2;

    for (ll i = 3; i*i <= n; i = i+2)
    {
        while (n%i == 0)
        {
            m[i]++;
            n = n/i;
        }
    }

    if (n > 2) m[n]++;
}


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        ll N; cin>>N;
        findPrimeFactors(N);
        vi v;
        int ans=0; bool brk=0;
        for(auto t: m){ //cout<<t.ff<<" "<<t.ss<<endl;
            ll p=t.ss; 
            ll n=t.ff;
            ll q=1;
            
            while(q<=p){
                if(N>1){
                    ll d=1;
                    for(int m=1;m<=q; m++) d*=n;
                    
                    if(N % d==0){ //cout<<d<<endl;
                        N /= d; ans++; q++;
                    }
                    else q++, v.pb(d);
                    
                }
                else {brk=1; break;}
            }
            
            if(brk) break;
        }
        
        
        sort(all(v));
        
        int x=0;
        while(N>1){
        	
            if(N%v[x]==0) N/=v[x], ans++, x++;
            if(N>1 or x == v.sz) break;
        }
        
        cout<<ans;
    }
}

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

int i,j,a[3]={},tmp;
int N=3;

int main(){
  cin >> a[0] >> a[1] >> a[2];
  for(i=0;i<N-1;i++){
    for(j=0;j<N-i;j++){
      if(a[j] > a[j+1]){
        tmp = a[j];
        a[j] = a[j+1];
        a[j+1] = tmp;
      }
    }
  }
  cout << a[0] << " " << a[1] << " " << a[2] << endl;
  return 0;
} 

Measured memory_bytes: 3100
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.concurrent.*;

class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	static ArrayList<Node>[] al;
	static long[] sum;
	
	static void dfs(int u,int p)
	{	
		for(Node x:al[u])	
		{
			if(x.val!=p)
			{
				sum[x.val]=sum[u]+x.cost;
				
				dfs(x.val,u);
			}
		}
	}
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt();al=new ArrayList[n];sum=new long[n];
		
		for(int i=0;i<n;i++)
		{
			al[i]=new ArrayList<>();
		}
		
		for(int i=1;i<n;i++)
		{
			int u=sc.nextInt()-1,v=sc.nextInt()-1,cost=sc.nextInt();
			
			al[u].add(new Node(v,cost));al[v].add(new Node(u,cost));
		}
		
		int q=sc.nextInt(),k=sc.nextInt()-1;dfs(k,-1);
		
		for(int i=0;i<q;i++)
		{
			out.println(sum[sc.nextInt()-1]+sum[sc.nextInt()-1]);
		}
		
		out.close();
    }
}

class Node
{
	int val;long cost;
	
	public Node(int val,long cost)
	{
		this.val=val;this.cost=cost;
	}
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 92168
#include<stdio.h>
int main(){
long long int a,b,n,i,c,d,max,e;
scanf("%lld%lld%lld", &a,&b,&n);

  e=n/b;

  if(e==0){
    c=a*n/b;
    d=n/b;
      max=c-a*d;
printf("%lld\n",max);
return 0;
  }
  c=a*(e*b-1)/b;
  d=(e*b-1)/b;
  max=c-a*d;
    c=a*n/b;
  d=n/b;
  if(max<c-a*d){
    max=c-a*d;
  }
  printf("%lld\n",max);
return 0;
}



Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
typedef long long ll;
 
int main() {
  ll a,b;cin>>a>>b;
  char s[60];
  rep(i,a) cin>>s[i];
  if (s[b-1]=='A') s[b-1]='a';
  else if (s[b-1]=='B') s[b-1]='b';
  else s[b-1]='c';
  rep(i,a) cout<<s[i];
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<math.h>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<unordered_map>
#include<set>
#include <algorithm>
#include <utility>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::set;
using std::vector;
using std::pair;
using std::make_pair;
using std::priority_queue;

typedef unsigned long long ull;
typedef long long ll;

#define Prime1 1000000007
#define Prime2 9999973

#define INF 0x7fffffffffffffff

ull i, j, k, l, m, n;
ull H, W, Q;
ull a, b, c, x, y;
ll K, L, N, M;
string str;

int main()
{
	vector<int> p(20);
	cin >> N;
	for (i = 0; i < N; ++i)
	{
		cin >> p[i];
	}
	int count = 0;
	for (i = 1; i < N - 1; ++i)
	{
		if ((p[i + 1] - p[i])*(p[i - 1] - p[i]) < 0)
		{
			++count;
		}
	}
	cout << count;
	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string x;
  cin >> x;
  
  int s = 0, t = 0;
  for(int i = 0; i < x.size(); i++){
    if(x.at(i) == 'T'){
      if(s > 0) s--;
      else t++;
    }
    else s++;
  }
  
  cout << 2 * t << '\n';
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define ll long long
#define M 3000010
#define N 7010
using namespace std;

int n, a[N];
ll m, q, ans, c[M];
bool vis[N];

vector < ll > g;

inline int read_int(){
	int s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline ll read_ll(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

void dfs(int x, ll y){
	if (vis[x]) return ;
	vis[x] = 1;
	y += c[x];
	g.push_back(y);
	dfs(a[x], y);
}

int main(){
	n = read_int(), m = read_ll();
	for (int i = 0; i < n; ++i) a[i] = read_int(), a[i]--;
	for (int i = 0; i < n; ++i) c[i] = read_ll();
	ans = LONG_LONG_MIN;
	for (int i = 0; i < n; ++i){
		memset(vis, 0, sizeof(vis));
		dfs(i, 0);
		if (g.back() > 0 && m >= int(g.size())){
			q = m / int(g.size());
			if (q >= 1){
				ll mx = LONG_LONG_MIN;
				if (q - 1 > 0) mx = 0;
				for (int i = 0; i < int(g.size()); ++i) mx = max(mx, g[i]);
				ans = max(ans, mx + (q - 1) * g.back());
			}
			int r = m % int(g.size());
			ll mx = 0;
			for (int i = 0; i < r; ++i) mx = max(mx, g[i]);
			ans = max(ans, mx + q * g.back());
		}
		else
			for (int j = 1; j <= m; ++j){
				if (j - 1 < g.size()) ans = max(ans, g[j - 1]);
				else break;
			}
		g.clear();
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=2000005,INF=1<<30;

vector<int> prime;//i番目の素数
bool is_prime[MAX+1];

void sieve(int n){
    for(int i=0;i<=n;i++){
        is_prime[i]=true;
    }
    
    is_prime[0]=is_prime[1]=false;
    
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;cin>>a>>b;
    cout<<a*b<<endl;
}




Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main(void){
  int A, B;
  cin >> A >> B;
  if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0){
    cout << "Possible";
  } else {
    cout << "Impossible";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
*/
int main()
{
    int N;
    map<string, int> mp;

    cin >> N;
    REP(i, N)
    {
        string s;
        cin >> s;
        mp[s] += 1;
    }
    int maxv = 0;
    for(auto& x: mp) {
        maxv = max(maxv, x.second);
    }
    for(auto& x: mp) {
        if (maxv == x.second) {
            cout << x.first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25216
#include <stdio.h>

int main () {
	char str[20];
	scanf("%s", str);
	
	for (int i = 0; str[i] != '\0'; i++) {
		if(i == 5 || i == 13) {
			printf(" ");
		}
		else {
			printf("%c", str[i]);
		}
	}
	
	
	
	return 0;
}

Measured memory_bytes: 1652
import math
N, K = map(int, input().split())
#S = list(input())
ans = []
for i in range(1, N+1):
    if i < K:
        ans.append(1/N * (0.5) ** (math.ceil(math.log2(K/i))))
    else:
        ans.append(1/N)
print(sum(ans))

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

using namespace std;

int main()
{
  int n,i=0,cnt=0;
  string s;
  cin>>n>>s;

  while(s[i]!='\0')
  {
      if(s[i]!=s[i+1])cnt++;
      i++;
  }
  cout<<cnt<<endl;

    return 0;
}


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

#define pii pair<int,int>
#define mp make_pair
#define F first
#define S second

using namespace std;

const int N = 3001;

string s, t, ans = "";

pii p[N][N];

int dp[N][N], n, m, ok[N][N];

int main () {
    cin >> s >> t;
    n = s.size ();
    m = t.size ();
    s = "#" + s;
    t = "#" + t;
    for (int i = 1;i <= n;i ++) {
        for (int j = 1;j <= m;j ++) {
            dp[i][j] = max (dp[i - 1][j - 1], max (dp[i - 1][j], dp[i][j - 1]));
            if (dp[i][j] == dp[i - 1][j])p[i][j] = mp (i - 1, j);
            else if (dp[i][j] == dp[i][j - 1])p[i][j] = mp (i, j - 1);
            if (s[i] == t[j] && dp[i][j] < dp[i - 1][j - 1] + 1) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                p[i][j] = mp (i - 1, j - 1);
				ok[i][j] = 1;
            }else {
                if (dp[i][j] == dp[i - 1][j - 1]) {
                    p[i][j] = mp (i - 1,j - 1);
                }
            }
        }
    }
	while (n != 0 && m != 0) {
		if (ok[n][m])ans = s[n] + ans;
		pii v = p[n][m];
		n = v.F;
		m = v.S;
	}
	cout << ans;
}


Measured memory_bytes: 140544
import itertools
import math

n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
    x[i],y[i]=map(int,input().split())

ans=0
for perm in itertools.permutations(range(n)):
    l=0
    for j in range(n-1):
        l+=((x[perm[j+1]]-x[perm[j]])**2+(y[perm[j+1]]-y[perm[j]])**2)**0.5
    ans+=l
print(ans/math.factorial(n))

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

    cin >> N;
    vector<pair<int, int> > r;
    vector<pair<int, int> > b;
    for (int i = 0; i < N; i++) {
        int ai, bi;
        cin >> ai >> bi;
        r.push_back(make_pair(-bi, ai));
    }
    for (int i = 0; i < N; i++) {
        int ci, di;
        cin >> ci >> di;
        b.push_back(make_pair(ci, di));
    }

    sort(r.begin(), r.end());
    sort(b.begin(), b.end());

    for (int i = 0; i < N; i++) {
        int tmp = -r[i].first;
        r[i].first = r[i].second;
        r[i].second = tmp;
    }

    bool rp[N];
    bool bp[N];
    for (int i = 0; i < N; i++) {
        rp[i] = false;
        bp[i] = false;
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (rp[j]) {
                continue;
            }
            if (bp[i]) {
                break;
            }
            if (b[i].first > r[j].first && b[i].second > r[j].second) {
                rp[j] = true;
                bp[i] = true;
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j;
    int a[5];
    for(i=0;i<5;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<5;i++)
    {
        if(a[i]==0)
            cout<<i+1<<endl;
    }
}


Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var a = input[0];
            var b = input[1];

            Console.WriteLine(a * b % 2 == 0 ? "Even" : "Odd");
        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


int main()
{
	int b1, b2, b3;
	
	cin >> b1 >> b2 >> b3;
	if (b1 && b2)
	{
		cout << "Open" << endl;
	} else if (b1) {
		cout << "Close" << endl;
	} else if (b2) {
		cout << "Close" << endl;
	} else if (b3) {
		cout << "Open" << endl;
	} else {
		cout << "Close" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d){
		cout<<"Left"<<endl;
	}else if(a+b<c+d){
		cout<<"Right"<<endl;
	}else{
		cout<<"Balanced"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int c=1;
    for(int i=0;i<4;i++)
    {
        if(i!=0&&s[i]==s[i-1])
            c=0;
    }
    if(c==1)
        cout<<"Good"<<endl;
    else
        cout<<"Bad"<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
ps = []
for i in range(N):
    ps.append(int(input()))
memo = {}
for i,p in enumerate(ps):
    memo[p] = 0
    if p-1 in memo:
        memo[p-1] = 1

dct = sorted(memo.items())
result = 0
c = 0
for k,v in dct:
    if v == 1:
        c += 1
    else:
        if c > result:
            result = c
        c = 0
print(N-result-1)

Measured memory_bytes: 37484
#include <iostream>
#include <algorithm>
using namespace std;
int a[100010];
int main()
{
	int n,m,p=0;
	cin>>n>>m;
	for (int i=1;i<=m;i++) 
	{
		cin>>a[i];
		if (a[i]%2==1) 
		{
			p++;
		}
	}
	if (p>2) 
	{
		cout<<"Impossible"<<endl;
		return 0;
	}
	p=0;
	for (int i=1;i<=m;i++)
	 if (a[i]%2==1) 
	 {
	 	p++;
	 	if (p==1) swap(a[i],a[1]);
	 	else swap(a[i],a[m]);
	 }
	for (int i=1;i<=m;i++) cout<<a[i]<<" ";
	cout<<endl;
	if (m==1) m++;
	a[1]--;a[m]++;
	if (a[1]==0)
	{
		cout<<m-1<<endl;
		for (int i=2;i<=m;i++) cout<<a[i]<<" ";
		cout<<endl;
	}
	else
	{
		cout<<m<<endl;
		for (int i=1;i<=m;i++) cout<<a[i]<<" ";
		cout<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;
 
int main(){
	string S;
	cin>>S;
	int N=sz(S);
	
	if(N<3){
		cout<<0<<endl;
		return 0;
	}
	
	ll ans=0;
	ll cta=0;
	int i=0;
	while(i<=N-2){
		if(S[i]=='A'){
			cta++;
			if(S[i+1]=='B' && S[i+2]=='C'){
				ans+=cta;
				i+=2;
              	cta--;
              	S[i]='A';
			}
			else{
				i++;
			}
		}
		else{
			cta=0;
			i++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 640
/**
 * author:    Ziel
 * created:   15.04.2020 14:38:24
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 2e18;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

#define int ll

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	ll n, k;
	cin >> n >> k;
	
	vector<ll> pos, neg;
	ll zero = 0;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		
		if (x > 0) pos.pb(x);
		else if (x == 0) zero++;
		else neg.pb(-x);
	}
	
	sort(all(pos));
	sort(all(neg));
	
	auto check = [&](ll x) {
		ll res = 0;
		if (x >= 0) res += (sz(pos) * sz(neg)) + ((sz(pos) + sz(neg)) * zero) + (zero * (zero - 1) / 2);
		else {
			for (ll i: neg) {
				ll id;
				if ((-x) % i == 0) id = lower_bound(all(pos), (-x) / i) - pos.begin();
				else id = upper_bound(all(pos), (-x) / i) - pos.begin();
				res += sz(pos) - id;
			}
			return res;
		}
		
		if (x == 0) return res;
		
		for (ll i = 0; i < sz(pos); i++) res += max(0ll, upper_bound(all(pos), x / pos[i]) - pos.begin() - i - 1);
		for (ll i = 0; i < sz(neg); i++) res += max(0ll, upper_bound(all(neg), x / neg[i]) - neg.begin() - i - 1);
		
		return res;
	};
	
	ll low = -INF, high = INF;
	while (high - low > 1) {
		ll middle = (low + high) / 2;
		
		if (check(middle) < k) low = middle;
		else high = middle;
	}
	
	cout << high;
	return 0;
}



Measured memory_bytes: 2420
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <unordered_map>

using namespace std;

typedef long long ll;

void solve() {
	int x, y;
	cin >> x >> y;
	for (int i = 0; i <= x; i++) {
		if (i * 2 + (x - i) * 4 == y) {
			cout << "Yes";
			return;
		}
	}
	cout << "No";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 3664
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define lowbit(n)  (n&-n)
int l,r,m,a[100005],b,c[100005];
void add(int pos,int val)
{
    while(pos<=r-l+1)  c[pos]=(c[pos]+val)%m,pos+=lowbit(pos);
}
int getsum(int pos)
{
    int ans=0;
    while(pos)  ans=(ans+c[pos])%m,pos-=lowbit(pos);
    return ans;
}
int cmp(int a,int b)
{
    char sa[15],sb[15];
    sprintf(sa,"%d",a);
    sprintf(sb,"%d",b);
    return strcmp(sa,sb)<0;
}
int main()
{
    int i;
    while(scanf("%d%d%d",&l,&r,&m)!=EOF&&(l+r+m))
	{
		int t=0;
        for(i=l;i<=r;i++)
            a[t++]=i;
        sort(a,a+t,cmp);
        memset(c,0,sizeof(c));
        int sum=0;
        for(i=0;i<t;i++)
		{
            b=getsum(a[i]-l+1)+1;
            add(a[i]-l+1,b);
            sum=(sum+b)%m;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 2004
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	ar := make([]bool, 3)
	for _, v := range s {
		ar[v-'a'] = true
	}
	if ar[0] && ar[1] && ar[2] {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n; cin >> n;
	int a = 0;

	
	for (int i = 0; i < n; i++) {
		cin >> a;

		if (a % 2 == 1) {
			cout << "first" << endl;
			return 0;
		}
	}

	cout << "second" << endl;

	return 0;
}

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

using namespace std;
typedef long long LL;


int main()
{
        LL n;
        cin >> n;
        string s;
        cin >> s;
        LL ans = 0;
        for(int i = 0 ; i < s.length()-1 ; i++)
        {
                if(s[i] == s[i+1]) continue;
                ans++;
        }
        cout << ans+1 << endl;
        return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};

signed main() {
  int n,m; cin >> n >> m;
  vector<pair<int,int>> edges(m);
  rep(i,m){
    cin >> edges[i].first >> edges[i].second;
    --edges[i].first, --edges[i].second;
  }

  int ans = 0;
  rep(i,m) {
    UnionFind uf(n);
    rep(j, m) {
      if(i==j) continue;
      auto [s,t] = edges[j];
      uf.unite(s,t);
    }
    if(uf.size(0)!=n) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(){
    int n,card[4][14],i,r,s,g,kazu;
    char gara;
    for(g=0; g<4; g++)
        for(r=1; r<=13; r++)
            card[g][r]=0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> gara >> kazu;
        if(gara=='S'){card[0][kazu]=1;}
        if(gara=='H'){card[1][kazu]=1;}
        if(gara=='C'){card[2][kazu]=1;}
        if(gara=='D'){card[3][kazu]=1;}
    }
    for(g=0; g<4; g++){
        for(r=1; r<=13; r++){
            if(card[g][r]){continue;}
            if(g==0){gara='S';}
            if(g==1){gara='H';}
            if(g==2){gara='C';}
            if(g==3){gara='D';}
            cout << gara << " " << r << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3092
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 998244353
 
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, S = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    dp=[0 for _ in range(S+1)]
    dp[0]=pow(2,N,mod)
    i2=pow(2,mod-2,mod)
    for i,a in enumerate(A):
        for s in range(S,a-1,-1):
                dp[s]+=(dp[s-a]*i2)%mod
                dp[s]%=mod
    print(dp[-1]%mod)






if __name__ == "__main__":
    main()

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

int start = 0;
int stone;

void odd(int n[50], int ppl){
//	cout<<n[0] << " " << n[1] << " " << n[2] << " " << stone << endl;
	if(stone == 0){
//		cout << "Yes" << start << endl;
		stone = n[start];
		n[start] = 0;
		start ++;
			if(start == ppl){
				//cout << "li" << endl;
				start = 0;
			}
	}else{
		int number;
		number = stone/ppl;
		//cout << "--" << number << endl;
		for(int i = 0; i < ppl; i++){
			n[i] += number;
		}
		number = stone % ppl;
		for(int i=0; i < number; i++){
			n[start] ++;
			start++;
			if(start == ppl){
	//			cout << "li" << endl;
				start = 0;
			}
		}
		stone=0;
	}
}


int main(){
	int ppl;
	int hantei = 1;
	int i;
	int original;

	while(cin >> ppl >> stone, ppl){
//	cout<<n[0] << " " << n[1] << " " << n[2] << " " << endl;
		hantei = 1;
	int n[50] = {0};
		start = 0;
		original = stone;
		while(hantei){
			odd(n, ppl);
			for(i = 0; i < ppl; i++){
				if(n[i] == original){
					 hantei = 0;
					 break;
				}

			}
		}
		cout << i << endl; 
	}

}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================


int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	cin >> n;
	int amari = n % 100;
	if (amari <= n / 100 * 5)
		cout << 1 << endl;
	else cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class S
{

    private const long DP_INIT_MINUS1 = -1;
    private const double DP_INIT_DOUBLE_MINUS1 = -1.0;
	private const long MOD = 1000000007;


    //s
    private const int FIRST_WIN = 1;
    private const int SECOND_WIN = 0;

    private static long[,,] dp;


    public static void Main()
	{
		/*
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];
        var M = input[1];
        */

        var input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        var N = input[0];

        solver(N, Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse));
    }

    public static void solver(int N, long[] stones){

        /*
            EDPC L Deque
            差を最小にする、つまり負になっても良い。差の絶対値ではない。
            したがってこの問題は、「どちらも点数を最大化するように動く」と言える。
            深く考える必要は無い。

            dp[N,N,2]を考える。
            dp[x,y,p]のとき、xからyまでの石が残っているとして、
            プレイヤーpにこれが与えられたときに発生する最大の値を持つ。

            xyの由来は、結局残されるのは常に連続した要素による部分列であるから。
            dp[x,x,0]の値は必ずinput[x]であり、（dp[x,x,1]は-input[x])
            dp[x,x+1,0]はMax(dp[x,x,0] + dp[x+1,x+1,1], dp[x+1,x+1,0] + dp[x,x,1])となる
            x=0,y=2（3個区間)では
            dp[x,y,0]はMax(dp[x,x,0] + dp[x+1,y,1], dp[y,y,0] + dp[x,y-1,1])になる

            dp[x,y,1]はMin(dp[x,y-1,0] + (dp[y,y,1])...
        
         */

        dp = new long[N,N,2];

        for(int i = 0; i < N; i++){
            for(int k = 0; k < N; k++){
                dp[i,k,0] = long.MinValue;
                dp[i,k,1] = long.MinValue;
            }
        }

        for(int i = 0; i < N; i++){
            dp[i,i,0] = stones[i];
            dp[i,i,1] = stones[i]*-1;

            
        }

        Console.WriteLine(calc(0,N-1,0));

        /*
        for(int i = 0; i < N; i++){
            for(int k = 0; k < N; k++){
                Console.Write(dp[i,k,0] + ",");
            }
            Console.WriteLine();
        }
        for(int i = 0; i < N; i++){
            for(int k = 0; k < N; k++){
                Console.Write(dp[i,k,1] + ",");
            }
            Console.WriteLine();
        }
        */
        


    }

    public static long calc(int left, int right, int player){

        if(dp[left,right,player] != long.MinValue){
            return dp[left,right,player];
        }


        if(player == 0){
            dp[left,right,player] = Math.Max((calc(left,left,player) + calc(left+1, right, 1)), (calc(right,right,player) + calc(left, right-1, 1)));
            return dp[left,right,player];
        } else if(player == 1){
            dp[left,right,player] = Math.Min((calc(left,left,player) + calc(left+1, right, 0)), (calc(right,right,player) + calc(left, right-1, 0)));
            return dp[left,right,player];
        }

        return -1; //通らないと思うけどね
    }

}

Measured memory_bytes: 154092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,t,a,h,ans;
  double temp,hikaku;
  hikaku=100000;
  ans=0;
  cin >>n>>t>>a;
  for(int i = 0; i < n; i++) {
    cin>>h;
    temp=t-h*0.006;
//    cout<<abs(a-temp)<<"<"<<abs(a-hikaku)<<endl;
    if(abs(a-temp)<abs(a-hikaku)){
      hikaku=temp;
      ans=i;
    }
  }
  cout<<ans+1;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <numeric>
#include <cstdint>

int main()
{
	typedef std::array<std::uint16_t, 12> NumDays;
	NumDays const num_days = {
		0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30
	};
	typedef std::array<std::string, 7> WeekDay;
	WeekDay const days = {
		"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"
	};

	std::uint16_t m, d;
	for (std::cin >> m >> d; !(m == 0 && d == 0); std::cin >> m >> d) {
		std::uint16_t const num_spanned_days =
			d + std::accumulate(num_days.begin(), num_days.begin() + m, 0);
		std::cout << days[num_spanned_days % days.size()] << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1192
from heapq import heapify, heappush, heappop
from collections import Counter, defaultdict, deque, OrderedDict
from sys import setrecursionlimit as setreclim
from sys import maxsize
from bisect import bisect_left, bisect, insort_left, insort
from math import ceil, log, factorial, hypot, pi
from fractions import gcd
from copy import deepcopy
from functools import reduce
from operator import mul
from itertools import product, permutations, combinations, accumulate, cycle
from string import ascii_uppercase, ascii_lowercase, ascii_letters, digits, hexdigits, octdigits

prod = lambda l: reduce(mul, l)
prodmod = lambda l, mod: reduce(lambda x, y: mul(x,y)%mod, l)

class WarshallFloyd():
    """Warshall-Floyd Algorithm: 
       find the lengths of the shortest paths between all pairs of vertices
    """

    def __init__(self, V, E, INF=10**9):
        """ V: the number of vertexes
            E: adjacency list
            start: start vertex
            INF: Infinity distance
        """
        self.V = V
        self.E = E
        self.warshall_floyd(INF)

    def warshall_floyd(self, INF):
        self.distance = [[INF] * self.V for _ in range(V)]
        for i in range(V): self.distance[i][i] = 0
        for fr in range(V):
            for to, cost in self.E[fr]:
                self.distance[fr][to] = cost
        for k in range(self.V):
            for i in range(self.V):
                for j in range(self.V):
                    if self.distance[i][k] != INF and self.distance[k][j] != INF:
                        self.distance[i][j] = min(self.distance[i][j], self.distance[i][k] + self.distance[k][j])

    def hasNegativeCycle(self):
        for i in range(V):
            if self.distance[i][i] < 0:
                return True
        else:
            return False
                
V, E = map(int, input().split())
INF = 10**10
edge = [[] for _ in range(V)]

for i in range(E):
    s, t, cost = map(int, input().split())
    edge[s].append((t, cost))

allsp = WarshallFloyd(V, edge, INF)
            
if allsp.hasNegativeCycle():
    print('NEGATIVE CYCLE')
else:
    for dist in allsp.distance:
        print(*[d if d != INF else 'INF' for d in dist])

Measured memory_bytes: 14788
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    s = input()

    if s.endswith("s"):
        s += "es"
    else:
        s += "s"
    
    print(s)

main()

Measured memory_bytes: 67528
#include<stdio.h>

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

long unsigned lcm(long unsigned a,long unsigned b)
{
  if(a==0||b==0) 
    return 0;
  return (a/gcd(a,b))*b;
}

swap(long unsigned *a,long unsigned *b)
{
  long unsigned tmp;
  tmp=*a;
  *a=*b;
  *b=tmp;
}

int main(void)
{
  long unsigned a,b;
  while(scanf("%lu%lu",&a,&b)!=EOF){
    if(a<b)
      swap(&a,&b);
    printf("%lu %lu\n",gcd(a,b),lcm(a,b));

  }

  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){

int i,N,rc=0,move=0;

cin >> N;
std::vector<char> c(N);

for(i=0;i<N;i++){
  cin >> c[i];
  if(c[i]=='R'){
    rc+=1;
  }
}

for(i=0;i<rc;i++){
  if(c[i]=='W'){
    move+=1;
  }

}
cout << move << endl;

}


Measured memory_bytes: 3636
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
struct UnionFind
{
    vector<int> data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k)
    {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k)
    {
        return (-data[find(k)]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    int n,q;
    cin>>n>>q;
    UnionFind uf(n);
    for (size_t i = 0; i < q; i++)
    {
        int t,u,v;
        cin>>t>>u>>v;
        if(t)
        {
            cout<<uf.same(u,v)<<"\n";
        }
        else
        {
            uf.unite(u,v);
        }
        
    }
    
    return 0;
}


Measured memory_bytes: 3988
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#define ll long long

using namespace std;

int main(){
  ll A, B, N, x, ans;
  cin >> A >> B >> N;

  if (N >= B) {
    ans = (A*(B-1))/B;
    cout << ans << endl;
  }else{
    ans = (A*N)/B;
    cout << ans << endl;
  }


  return 0;
}


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

typedef long long ll;
ll N;
ll dp[3010][3010];
constexpr ll INF = 1e15;
ll A[3010];
ll rec(ll i, ll j)
{   
    if(dp[i][j] != INF) return dp[i][j];
    int turn = N - (j - i);
    ll res;
    if(turn == N)
    {
        res = 0;
    }
    else if(turn % 2 == 0) // first
    {
        res = max(A[i] + rec(i + 1, j), A[j - 1] + rec(i, j - 1));
    }
    else // second
    {
        res = min(rec(i + 1, j) - A[i], rec(i, j - 1) - A[j - 1]);
    }
    return dp[i][j] = res;
}

int main()
{
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < 3010; i++)
    for(int j = 0; j < 3010; j++) dp[i][j] = INF;

    cout << rec(0, N) << endl;
}

Measured memory_bytes: 71168
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin >> n;
    ll k;
    cin >> k;
    vector<P> vv(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        vv[i] = P(a, b);
    }

    sort(all(vv));
    ll sum = 0;
    rep(i, n) {
        sum += vv[i].second;
        if(sum >= k) {
            cout << vv[i].first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000001;

int N;
int H[100001];
int ans = 0;

int main(){
  rep(i, 100001){
    H[i] = INF;
  }
  cin >> N;
  rep(i, N){
    cin >> H[i];
  }
  rep(i, N){
    int current = i;
    int tmp = 0;
    while(H[current] >= H[current + 1]){
      tmp++;
      current++;
    }
    if(tmp > ans) ans = tmp;
    i = current;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 640
n,k = map(int,input().split())
a = []
if n//k == 0:
  print(1)

else:
  while n//k != 0:
    a.append(n%k)
    n = n//k
  
    if n//k ==0:
      a.append(n%k)
  a.reverse()
  
  print(len(a))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;

vector<pair<int,long long>> map[100001];


long long *dist(int K){
    long long *d=new long long[100001];

    queue<pair<int,pair<int,long long>>> q; //現在位置, {前位置, 距離}
    for(pair<int,long long> x : map[K]){
        q.push(make_pair(x.first,make_pair(K,x.second)));
        d[x.first]=x.second;
    }
    while(!q.empty()){
        pair<int,pair<int,long long>> t=q.front();
        q.pop();

        for(pair<int,long long> x : map[t.first]){
            if(x.first==t.second.first) continue;
            q.push(make_pair(x.first,make_pair(t.first,t.second.second+x.second)));
            d[x.first]=t.second.second+x.second;
        }
    }

    return d;
}

int main(){
    int N;
    cin >> N;
    for(int i=0;i<N-1;i++){
        int a,b;
        long long c;
        cin >> a >> b >> c;
        map[a].push_back(make_pair(b,c));
        map[b].push_back(make_pair(a,c));
    }

    int Q,K;
    cin >> Q >> K;
    
    long long *d=dist(K);
    for(int i=0;i<Q;i++){
        int x,y;
        cin >> x >> y;
        cout << (d[x]+d[y]) << endl;
    }

    delete[] d;    
    return 0;
}

Measured memory_bytes: 10480