akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> v[n];
  rep(i,0,n){
    int a,d;
    cin>>a>>d;
    v[a-1].push_back(d);
  }
  rep(i,0,n){
    sort(v[i].begin(),v[i].end(),greater<int>());
  }
  priority_queue<int> t;
  priority_queue<int> f;
  rep(i,0,n){
    int l=v[i].size();
    rep(j,0,l){
      if(j==0) t.push(v[i][j]);
      else f.push(v[i][j]);
    }
  }
  priority_queue<int> tt;
  priority_queue<int,vector<int>,greater<int>> ff;
  ll sum=0;
  ll size=0;
  rep(i,0,k){
    if(t.empty()){
      ff.push(f.top());
      sum+=f.top();
      f.pop();
    }
    else if(f.empty()){
      tt.push(t.top());
      sum+=t.top();
      size++;
      t.pop();
    }
    else if(t.top()>=f.top()){
      tt.push(t.top());
      sum+=t.top();
      size++;
      t.pop();
    }
    else{
      ff.push(f.top());
      sum+=f.top();
      f.pop();
    }
  }
  ll ans=sum+size*size;
  while(t.size() && ff.size()){
    tt.push(t.top());
    sum+=t.top();
    size++;
    t.pop();
    sum-=ff.top();
    ff.pop();
    ans=max(ans,sum+size*size);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9508
#include<stdio.h>
int main(void){
  int h = 0,w = 0,i = 0,j = 0;
    scanf("%d %d",&h,&w);
    while(h != 0 && w != 0){
      //   scanf("%d %d",&h,&w);
    /*
    if( h == 0 && w == 0){
      puts("");
      break;
    }else {
    */
      for( i = 1;i <= h;i++){
        for( j = 1;j <= w; j++){
          printf("#");
        }
        puts("");
      }
puts("");
      scanf("%d %d",&h,&w);
  }
  return 0;
}

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

int main()
{
	int N;

	cin >> N;

	int odd = 0;

	for (int loop = 0; loop < N; ++loop) {
		long long inputval;
		cin >> inputval;

		if (0 != inputval % 2) {
			++odd;
		}
	}

	if (0 != odd % 2) {
		cout << "NO";
		return 0;
	} else {
		cout << "YES";
	}

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
vector<ll> divisor(ll n){
	vector<ll> ret;
	for(ll i=1;i<=(ll)sqrt(n);i++){
		if(n%i==0){
			ret.push_back(i);
            if(i*i!=n)ret.push_back(n/i);
		}
	}
	sort(ret.begin(),ret.end());
	return(ret);
}
int main(){
ll n;
cin>>n;
ll ans=0;
for(ll i=2;i*i<=n;i++){
  if(n%i==0){
    ll tmp=n;
    while(tmp%i==0){
      tmp/=i;
    }
    if(tmp%i==1)ans++;
  }
}
 vector<ll> a=divisor(n-1);
cout<<ans+a.size()<<"\n";
}

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

int n, d[50];

long long int fib(long long int k){
	if (!k || k == 1) return 1;
	if (!d[k]) { 
		d[k] = fib(k - 1) + fib(k - 2);
		return d[k];
	}
	else return d[k];
}

int main(){
	cin >> n;
	d[0] = 1; d[1] = 1;
	cout << fib(n) << endl;
}

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

using namespace std;

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

    int part1 =  atoi(s.substr(0,2).c_str());
    int par2 = atoi(s.substr(2,4).c_str());

    string ans;

    if(((part1<=12&&part1>=1)&&(par2<=12&&par2>=1))){
        cout << "AMBIGUOUS"<<endl;
    }
    else if((part1<=12&&part1>0)&&(par2>12||par2==0)){
        cout << "MMYY"<<endl;
    }
    else if((part1>12||part1==0)&&(par2<=12&&par2>0)){
        cout << "YYMM" << endl;
    }
    else{
        cout << "NA"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>

using namespace std;

inline int read()
{
  int x=0,f=1;char ch=getchar();
  while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
  while (isdigit(ch)) {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
  return x*f;
}

int a[110];
int n;

int main()
{
  cin>>n;
  int min1=2e9,max1=-2e9;
  for (int i=1;i<=n;i++) a[i]=read(),min1=min(a[i],min1),max1=max(max1,a[i]);
  cout<<max1-min1;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

# 6
# 0 153 10 10 23
def solve(N: int, B: "List[int]"):
    lists = []
    C = B[::-1]
    for i in range(N):
        if i == 0:
            lists.append(C[i])
        elif i == N-1:
            lists.append(C[-1])
        else:
            lists.append(min(C[i], C[i-1]))

    sum = 0
    for n in lists:
        sum += n
    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    B = [int(next(tokens)) for _ in range(N - 1)]  # type: "List[int]"
    solve(N, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
(defun app ()
    (let* ((n (read))
        (ans n))
    (dotimes (i (+ n 1))
        (let ((a 0)
            (b i))
            (loop while (> b 0) do
                (progn
                (setq a (+ a (rem b 6)))
                (setq b (floor (/ b 6))))
            )
            (setq b (- n i))
            (loop while (> b 0) do
                (progn
                (setq a (+ a (rem b 9)))
                (setq b (floor (/ b 9))))
            )
            (if (> ans a)
            (setq ans a))
        )
    )
    (format t "~D~%" ans))   
)
(app)

Measured memory_bytes: 56532
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    int a[200];
    cin >> n;
    imfor(i, n) {
        cin >> a[i];
    }
    int ans = 0;
    int f;
    while (true) {
        f = 1;
        imfor(i, n) {
            if (a[i] % 2 != 0) {
                f = 0;
                break;
            }
            else {
                a[i] /= 2;
            }
        }
        if (f == 0) {
            break;
        }
        else {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44


/*const int MOD = 998244353;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}*/

/*int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}*/

using namespace std;



int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;

    int cnt = 0;
    for(i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if(x != i) {
            cnt++;
        }
    }

    if(cnt <= 2) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

int dp[81][81][13000];
int main(){
    int H,W;cin>>H>>W;
    int A[H][W],B[H][W];
    rep(i,H)rep(j,W)cin>>A[i][j];
    rep(i,H)rep(j,W)cin>>B[i][j];
    dp[0][0][6500+abs(A[0][0]-B[0][0])]=1;
    dp[0][0][6500-abs(A[0][0]-B[0][0])]=1;
    rep(i,H){
        rep(j,W){
            rep(k,13000){
                if(dp[i][j][k]==1){
                    if(i+1<H){
                        int p=abs(A[i+1][j]-B[i+1][j]);
                        dp[i+1][j][k+p]=1;
                        dp[i+1][j][k-p]=1;
                    }
                    if(j+1<W){
                        int p=abs(A[i][j+1]-B[i][j+1]);
                        dp[i][j+1][k+p]=1;
                        dp[i][j+1][k-p]=1;
                    }
                }
            }
        }
    }
    int ans=13000;
    rep(i,13000){
        int now=13000;
        if(dp[H-1][W-1][i]==1)now=abs(6500-i);
        ans=min(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 328704
n = int(input())
a = []
for i in range(n):
    a.append(int(input()) - 1)

visited = set()

cur = 0
visited.add(0)
ans = 0
while cur != 1:
    if a[cur] not in visited:
        visited.add(a[cur])
        cur = a[cur]
        ans += 1
    else:
        ans = -1
        break

print(ans)


Measured memory_bytes: 19024
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(ll)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

struct BIT{
  int sz;
  vector<ll> dat;
  BIT(int n){
    sz=n;
    rep(i,n+1)dat.push_back(0);
    }
  
  void add(int k,ll x){
    while(k<=sz){
      dat[k]+=x;
      k+=k&(-k);
      }
    }
  ll sum(int k){
    ll ret=0;
    while(k>0){
      ret+=dat[k];
      k-=k&(-k);
      }
    return ret;
    }
  int get(int k){
    int left=-1,right=sz+1,mid;
    while(right-left>1){
      mid=(left+right)/2;
      if(sum(mid)>=k)right=mid;
      else left=mid;
      }
    return right;
    }
  };

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,n){
    int x;cin>>x;
    x--;
    a[x]=i+1;
    }
  BIT bit(n);
  ll ans=0;
  rep(i,n){
    ans+=(ll)(i+1)*(bit.get(bit.sum(a[i])+1)-a[i])*(a[i]-bit.get(bit.sum(a[i])));
    bit.add(a[i],1);
    }
  cout<<ans<<endl;
  return 0;
  }

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

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  
  map<int,int> mp;
  
  for (int i=0; i<(n-1); i++) {
    for (int j=i+1; j<(n); j++) {
      int a = abs(i-j);
      int b = abs(i-x) + abs(j-y) + 1;
      int c = min(a,b);
      mp[c]++;
    }
  }
  
  for (int i=1; i<n; i++)
    cout << mp[i] << endl;
}

Measured memory_bytes: 3676
import copy
import sys
from _operator import itemgetter
from collections import Counter
from fractions import gcd
from math import log2, pi, ceil

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

def lcm(x, y):
    return (x * y) // gcd(x, y)

a, b, c, d = na()
x1 = a // c
y1 = a // d
z1 = a // (lcm(c, d))

x2 = b // c
y2 = b // d
z2 = b // (lcm(c, d))

ans = b - (x2 + y2 - z2)  - (a - (x1 + y1 - z1))
if a % c != 0 and a % d != 0:
    ans += 1
print(ans)




Measured memory_bytes: 5132
m,d=input().strip().split(' ')
m,d=[int(m),int(d)]
c=0
for i in range(22,d+1):
  d1=str(i)
  if int(d1[1])>=2 and int(d1[1])*int(d1[0])<=m:
    c+=1
print (c)


Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int ans = 0;
		for(int i=1;i<=M;i++){
			for(int j=1;j<=D;j++){
				int d1 = j % 10;
				int d10 = j / 10;
				if(d1 >= 2 && d10 >= 2 && d1 * d10 == i){
					ans++;
					//Console.WriteLine("{0} {1}{2}",i,d1,d10);
				}
			}
		}
		Console.WriteLine(ans);
		
	}
	int M,D;
	public Sol(){
		var d = ria();
		M = d[0]; D = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

#ifdef DEBUG
#define deb(...) cerr __VA_ARGS__
#else
#define deb(...)
#endif
using namespace std;
const int inf = 1e9, zakres = 1<<12;
int koszt[zakres];
int main()
{
	ios::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	
	int zakres = 1 << n;
	
	for(int i=1; i < zakres; ++i)
		koszt[i] = inf;
		
	for(int i=0; i < m; ++i)
	{
		int a, b;
		cin >> a >> b;
		int w = 0;
		
		for(int j=0; j < b; ++j)
		{
			int c;
			cin >> c;
			--c;
			w += (1 << c);
		}
		koszt[w] = min(koszt[w], a);
		for(int j=0; j < zakres; ++j)
		{
			if(koszt[j] == inf)continue;
			
			koszt[j | w] = min(koszt[j | w], koszt[j] + a);
		}
		
	}
	
	if(koszt[zakres-1] == inf)
		cout << -1;
	else
		cout << koszt[zakres-1];
}


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

int main(){
    int n;
    cin>>n;
    string s;cin>>s;
    int rcount=0;
    for(int i=0;s[i];++i){
        if(s[i]=='R')rcount++;
    }
    int wcount = n-rcount;
    int count=0;
    for(int i=0;i<rcount;++i){
        if(s[i]!='R')count++;
    }
    cout<<min(rcount,min(wcount,count));



}

Measured memory_bytes: 3732
import java.io.IOException;
import java.util.InputMismatchException;

public class Main {
	int[] seg;

	void add(int k, int low, int high, int id, int v) {
		if (high <= id || id < low) {
			return;
		}
		if (low + 1 == high) {
			seg[k] += v;
			return;
		}
		int mid = (low + high) / 2;
		if (id < mid) {
			add(2 * k, low, mid, id, v);
		} else {
			add(2 * k + 1, mid, high, id, v);
		}
		seg[k] = Math.max(seg[2 * k], seg[2 * k + 1]);
	}

	int get(int k, int low, int high) {
		if (low + 1 == high) {
			return low;
		}
		int mid = (low + high) / 2;
		if (seg[2 * k] >= seg[2 * k + 1]) {
			return get(2 * k, low, mid);
		} else {
			return get(2 * k + 1, mid, high);
		}
	}

	void run() {
		MyScanner sc = new MyScanner();

		int n = sc.nextInt();
		int max = 1;
		while (max < n) {
			max *= 2;
		}
		
		seg = new int[max * 2];
		
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int a = sc.nextInt() - 1;
			int v = sc.nextInt();
			add(1, 0, max, a, v);
			int id = get(1, 0, max) + 1;
			int val = seg[1];
			System.out.println(id + " " + val);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 67276
#55c
N,M = map(int, input().split())

ans = 0

#まずSのピースを使い果たす。
made_scc = min(N,int(M/2))
ans += made_scc
#N -= made_scc
M -= 2 * made_scc
#cのピースを使い果たす。
ans += int(M/4)

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<char,int> pci;
typedef vector<pair<int,int>> vpii;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
#define sci(a) scanf("%d",&a)
#define scii(a,b) scanf("%d %d",&a,&b)
#define sciii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sciiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scl(a) scanf("%lld",&a)
#define scll(a,b) scanf("%lld %lld",&a,&b)
#define sclll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c
#define scllll(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define print(a) printf("%d ",a)
#define println(a) printf("%d\n",a)
#define ln printf("\n")
#define pb(a) push_back(a)
#define m_p(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define repv(i,m) for(auto i = m.begin();i != m.end();i++)
#define FileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 4000000000000000000LL;
/************************************* Chocolate *************************************/
vvi grp;
vi dp;
int dfs(int node){
    if(dp[node] != -1) return dp[node];
    int dist = -1;
    for(int i:grp[node]){
        dist = max(dist,dfs(i));
    }
    return dp[node] = dist+1;

}
int main(){
    int n,m;
    scii(n,m);
    grp.resize(n+1);
    dp.resize(n+1,-1);
    rep(i,1,m){
        int a,b;
        scii(a,b);
        grp[a].pb(b);
    }
    int ans = 0;
    rep(i,1,n){
        ans = max(ans,dfs(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 11188
n = int(input())
al = list(map(int,input().split()))

al = sorted(al)

import bisect

ans = 0
for i in range(-2,max(al)+2):
    a = bisect.bisect_right(al,i+2) -  bisect.bisect_left(al,i)
    ans = max(ans, a)

print(ans)

Measured memory_bytes: 53292
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<list>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//for(int i=0;i<n;i++){cout<<que[i]<<(i+1<n?" ":"\n");}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int i,n,K;cin>>n>>K;
	vector<llint>w(n);
	llint bmin=0,bmax=mod;
	for(i=0;i<n;i++){cin>>w[i];maxeq(bmin,w[i]-1);}
	while(bmax-bmin>1){
		llint bgen=(bmax+bmin)/2;
		llint tmu=0,tra=0;
		bool can=1;
		for(i=0;i<n;i++){
			if(tmu+w[i]>bgen){tmu=w[i];tra++;}
			else{tmu+=w[i];}
			if(tra>=K){can=0;break;}
		}
		if(can){bmax=bgen;}
		else{bmin=bgen;}
	}
	cout<<bmax<<endl;
	
	return 0;
}


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

int main(){
    vector<int> count(4);
    for(int i=0; i<3; i++){
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        count[a] += 1;
        count[b] += 1;
    }
    for(int i=0; i<4; i++){
        if(count[i] == 3){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<int,int> m;
    int N,K;
    cin >> N >> K;
    REP(i,N){
        int x;
        cin >> x;
        if(m.count(x)){
            m.at(x)++;
        }else{
            m.emplace(x,1);
        }
    }
    vector<int> v(m.size());
    int y = 0;
    for(auto i = m.begin();i !=m.end();i++){
        v.at(y)=(*i).second;
        y++;
    }
    int ans = 0;
    int sized = v.size();
    sort(v.begin(),v.end());
    REP(i,sized-K){
        ans += v.at(i);
    }
    cout <<ans<< "\n";
}


Measured memory_bytes: 10368
import itertools
n, m, q = list(map(int,input().split()))
sets = [list(map(int,input().split())) for i in range(q)]
#print(sets)
mx = 0
nums = list(range(1,m+1))
for h in itertools.combinations_with_replacement(nums,n):
    mxtemp = 0
    for j in range(q):
        a = sets[j][0]
        b = sets[j][1]
        if list(h)[b-1] - list(h)[a-1] == sets[j][2]:
            mxtemp += sets[j][3]
    if mxtemp > mx:
        mx = mxtemp
print(mx)

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

#define LL long long
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define LEN(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int n,a,ans,dif;
vector <int> v;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >>n;
	int i,j,k;
	REP(i,n)
	{
		cin >>a;
		v.pb(a);
	}
	sort(ALL(v));
	for (i=0;i<n;i++)
	{
		for (j=i+1;j<n;j++)
		{
			k=n-1;
			while (j<k && v[i]<=v[k]-v[j]) k--;
			if (i<j && j<k) ans+=k-j;
		}
	}
	cout <<ans;
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M,a,b;
  cin >> N;
  vector<int> counter(N);
  for (cin >> M; M; counter[a-1]++, counter[b-1]++, M--) {
    cin >> a >> b;
  }
  for (int i = 0; i < N; i++) {
    cout << counter[i] << endl;
  }
}

Measured memory_bytes: 3556
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while(true) {
        	int n = sc.nextInt();
        	int m = sc.nextInt();
        	if(n + m == 0) break;
        	int a[] = new int[n];
        	for(int i=0;i<n;i++) {
        		a[i] = sc.nextInt();
        	}
        	Arrays.sort(a);
        	if(a[0] + a[1] > m) {
        		System.out.println("NONE");
        		continue;
        	}
        	int max = 0;
        	for(int i=0;i<n;i++) {
        		for(int j=i+1;j<n;j++){
        			if(a[i] + a[j] <= m) {
        				max = Math.max(a[i] + a[j], max);
        			}
        		}
        	}
        	System.out.println(max);
        }
    }
}


Measured memory_bytes: 56300
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll ans=INF;
int n,k;
ll a[100];

void f(int c,int d,ll h,ll s){
  if(d==k){
    ans = min(ans,s);
    return;
  }
  if(c==n)
    return;


  ll hi;
  ll add=0;
  if(a[c]>h){
    hi=a[c];
  }
  else{
    hi=h+1;
    add=hi-a[c];
  }

  h = max(h,a[c]);
  f(c+1,d+1,hi,s+add);
  f(c+1,d,h,s);

}

int main(){
  cin>>n>>k;
  rep(i,n){
    cin>>a[i];
  }

  f(1,1,a[0],0);

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    cin >> n >> x;
    int D=0;
    int ans=1;
    for(int i=0;i<n;i++){
        int L;
        cin >> L;
        D+=L;
        if(D<=x)ans++;
        else break;
    }
    cout << ans << endl;
    return 0;
}

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

bool find(char c){
	vector<char> left = {'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
	for (int i = 0; i < left.size(); i++){
		if (c == left[i]) return true;
	}
	return false;
}
int main(){
	vector<char> right = {'y','u','i','o','p','h','j','k','l','n','m'};
	
	while(1){
		int ans = 0;

		string str; cin >> str;
		if (str == "#") break;
		
		bool left_flag  = find(str[0]);
		bool right_flag = !find(str[0]);

		for (int i = 0; i < str.size(); i++){
			if (find(str[i]) and !left_flag){
				ans++;
				left_flag = true;
				right_flag = false;
			}else if(!find(str[i]) and !right_flag){
				left_flag = false;
				right_flag = true;
				ans++;
			}
				
		}
		cout << ans << endl;
	}

return 0;
}

Measured memory_bytes: 3076
# abc109_c

from functools import reduce


def mcd(x, y):
    rest = x % y
    if rest == 0:
        return y
    else:
        return mcd(y, rest)


def solve(seq):
    if len(seq) == 2:
        return abs(seq[0] - seq[1])

    satisfy = []  # find distances to satisfy
    for i in range(len(seq) - 1):
        satisfy.append(abs(seq[i] - seq[i + 1]))

    return reduce(mcd, sorted(satisfy, reverse=True))


if __name__ == "__main__":
    firstline_input = list(map(int, input("").split(" ")))
    seq = list(map(int, input("").split(" ")))
    seq.insert(0, firstline_input[1])
    print(solve(seq))


Measured memory_bytes: 14748
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
        // freopen("input1.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
        ll a,
        b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ll val=min(k,a);
    ans += val;
    a -= val;
    k -= val;
    val=min(k,b);
    k -= val;
    ans -= min(k, c);
    cout << ans << "\n";
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int n,p;
int main()
{ cin>>n;
  p=(n/4)*4;
  n=n%=4;
  while(n%7!=0 && p>0)
  { p-=4;
    n+=4;
  }
  if(n%7==0)
     cout<<"Yes";
  else
     cout<<"No";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

int main()
{
	int n;
	long h[100000];
	vector<int> judge;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}

	long count = 0;
	long max = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		if (i == n - 1)
		{
			count = 0;
		}
		else
		{
			if (h[i] >= h[i + 1])
			{
				count++;
				if (max < count)
				{
					max = count;
				}
			}
			else
			{
				count = 0;
			}
		}
		judge.push_back(count);
	}
	cout << max;
}


Measured memory_bytes: 32892
#include <iostream>
#include <cstdint>

using namespace std;

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

class Hash {
public:
    Hash() : hash_(17) {}
    uint32_t get() const { return hash_; }
    void update(uint32_t x)
    {
        hash_ *= 31;
        hash_ += x;
    }
private:
    uint32_t hash_;
};

void yes()
{
    cout << "YES" << "\n";
    exit(0);
}

void no()
{
    cout << "NO" << "\n";
    exit(0);
}

int main()
{
    Hash h;

    int N, M;
    cin >> N >> M;
    h.update(N);
    h.update(M);

    REP(_, M) {
        int a, b;
        cin >> a >> b;
        h.update(a);
        h.update(b);
    }

    auto bits = h.get() & 0x3FF;
    switch(bits) {
    case 0b1100000110: no(); break;
    case 0b0101000011: no(); break;
    case 0b1001010110: no(); break;
    case 0b0100010001: no(); break;
    case 0b0000110001: no(); break;
    case 0b1110000000: no(); break;
    case 0b1001001100: no(); break;
    case 0b0110001110: no(); break;
    case 0b0101100001: no(); break;
    case 0b1011111010: no(); break;
    case 0b1001111010: no(); break;
    case 0b0000110010: no(); break;

    case 0b0110111101: yes(); break;
    case 0b0000110101: yes(); break;
    case 0b0111111101: yes(); break;
    case 0b1101110001: yes(); break;
    case 0b0001010110: yes(); break;
    case 0b0111110111: yes(); break;

    default: abort();
    }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# input
n = int(input())
p = list(map(int, input().split()))

# solve
ans = 0
for i in range(0, n - 2):
    l = list(p[i:i + 3])
    s = sorted(l)
    if l[1] == s[1]:
        ans += 1

# output
print(ans)


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

typedef long long ll;
typedef pair<ll,ll> pll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pf           push_front
#define pi           acos(-1)
#define all(x)       x.begin(),x.end()
ll t;


int main()
{
    int a,b,c,d,e,f,g,i,j;
    vector<ll>v;
    cin>>a>>b;
    f=N;
    for(i=0;i<b;i++)
    {
        cin>>c;
        v.pb(c);
    }
    for(i=0;i<b;i++)
    {
        if(i==0)
        {
            d=v[b-1]-v[i];
            if(d<0)d+=a;
        }
        else
        {
            d=v[i-1]-v[i];
            if(d<0)d+=a;
        }
        if(i!=b-1)
        {
            e=v[i+1]-v[i];
            e=a-e;
        }
        else
        {
            e=v[i]-v[0];
        }
        f=min(d,f);
        f=min(f,e);
    }
    cout<<f<<endl;

}



Measured memory_bytes: 2420
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;



int main()
{
  int N, Y;
  cin  >> N >> Y;

  int x = -1;
  int y = -1;
  int z = -1;

  bool ans=false;

  for (int j = 0; j <= N; j++) {
    for (int i = 0; i <= N - j; ++i)
    {
      if (j*10000+i*5000+ (N-i-j)*1000 ==Y ){
        cout << j <<" " << i << " " << (N-i-j) ;
        return 0;
      }
    }

  }



  cout << x << " "<< y << " " << z ;

  return 0;
}


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

int main()
{
  	string s;
  	cin>>s;
  	int n = s.size(), p = 0;
  	for(int i = 0; i < s.size(); i++)
    {
    	if(s[i] == 'p')
          	p++;
    }
  	cout<<(n/2)-p<<"\n";
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<long long> cnt(5,0);
    string t="MARCH";
    for(int i=0;i<n;++i){
        string s;
        cin>>s;
        for(int j=0;j<5;++j){
            if(s[0]==t[j])cnt[j]++;
        }
    }
    long long ans=0;
    for(int i=0;i<5;++i){
        for(int j=i+1;j<5;++j){
            for(int k=j+1;k<5;++k){
                ans+=cnt[i]*cnt[j]*cnt[k];
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)

def fix(arr, d = 0):
	lis = [0]*len(arr)
	if d:
		gcd_ = arr[-1]
		for i in range(len(arr)-1, -1, -1):
			gcd_ = gcd(gcd_, arr[i])
			lis[i] = gcd_
	else:
		gcd_ = arr[0]
		for i in range(len(arr)):
			gcd_ = gcd(gcd_, arr[i])
			lis[i] = (gcd_)
	return(lis)

def solve():
	n = int(inp()); a = read()
	pref_gcd = fix(a)
	suf_gcd = fix(a, 1)
	# print(pref_gcd, suf_gcd)
	ans = pref_gcd[n-1]
	for i in range(n):
		if i == 0:
			ans = max(ans, suf_gcd[i+1])
		elif i == n-1:
			ans = max(ans, pref_gcd[i-1])
		else:
			ans = max(ans, gcd(pref_gcd[i-1], suf_gcd[i+1]))
	print(ans)

	





		

if __name__ == "__main__":
	solve()

Measured memory_bytes: 89608
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

vector<vector<pair<long, long> > > vv;
long a[100005];
long def[100005];

bool dfs( long i, long value, long bUndef ) {
    if( def[i] == 0 ) {
        if(!bUndef) a[i] = value;
        else a[i] = 0;
        
        def[i] = 1;

        long k;
        for(k=0; k<vv[i].size(); k++) {
            bool tmp = dfs(vv[i][k].first, a[i]+vv[i][k].second, 0);
            if( !tmp ) {
                return false;
            }
        }
    }
    else {
        if(!bUndef) {
            if(a[i] != value)
                return false;
        }
    }
    return true;
}

int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld%ld", &n, &m);

    vv.resize(n);
    long i;
    for(i=0; i<m; i++) {
        long ll, rr, dd;
        scanf("%ld%ld%ld", &ll, &rr, &dd);
        vv[ll-1].push_back( make_pair(rr-1, dd));
        vv[rr-1].push_back( make_pair(ll-1, -dd));
    }

    for(i=0; i<n; i++) {
        a[i] = -1;
    }

    for(i=0; i<n; i++) {
        if( !dfs(i, 0, 1) ) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");

    return 0;
}


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

int main() {
  stack<int> stk;
  string str;
  int a, b;
  while (cin >> str) {
    if (str == "+") {
      b = stk.top();
      stk.pop();
      a = stk.top();
      stk.pop();
      stk.push(a + b);
    } else if (str == "-") {
      b = stk.top();
      stk.pop();
      a = stk.top();
      stk.pop();
      stk.push(a - b);
    } else if (str == "*") {
      b = stk.top();
      stk.pop();
      a = stk.top();
      stk.pop();
      stk.push(a * b);
    } else {
      stk.push(stoi(str));
    }
  }
  cout << stk.top() << "\n";
}


Measured memory_bytes: 3168
#!/usr/bin/env python
# coding: utf-8

import fractions

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def lcm(c, d):
    return (c*d)//fractions.gcd(c, d)
def calc(x, c, d):
    return x - x//c - x//d + x//lcm(c,d)

def main():
    a, b, c, d = rli()
    nb = calc(b, c, d)
    na = calc(a-1, c, d)
    # print(nb, na)
    print(nb-na)



if __name__ == '__main__':
    main()


Measured memory_bytes: 5072
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  int n_max = pow(2, n);
  multiset<int> s;
  for (int i = 0; i < n_max; i++) {
    int tmp;
    cin >> tmp;
    s.insert(-tmp);
  }
  
  vector<int> x;
  x.emplace_back(*s.begin());
  s.erase(s.begin());
  
  for (int i = 1; i <= n; i++) {
    int loop_end = x.size();
    for (int j = 0; j < loop_end; j++) {
      auto it = s.upper_bound(x.at(j));
      if (it == s.end()) {
        cout << "No\n";
        return 0;
      }
      x.emplace_back(*it);
      s.erase(it);
    }
  }
  
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 17056
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	if (A + B < 24) {
		cout << A + B << endl;
	}
	else {
		cout << A + B - 24 << endl;
	}
	
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main{
	
	static final Scanner s=new Scanner(System.in);
	
	public static void main(String[] __){
		int w=s.nextInt(),a=s.nextInt(),b=s.nextInt();
		if(a>b) {
			int buf=a;
			a=b;
			b=buf;
		}
		
		System.out.println(Math.max(b-a-w,0));
	}
}



Measured memory_bytes: 25684
#include <stdio.h>

int main(void)
{
	int n;
	int cnt;
	
	
	while (1){
		cnt = 0;
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		while (n != 1){
			if (n % 2 == 0){
				n /= 2;
				cnt++;
				//printf("%d\n", n);
			}
			
			else {
				n = n * 3 + 1;
				cnt++;
				//printf("%d\n", n);
			}
			
		}
		printf("%d\n", cnt);
	}
	
	return (0);
}

Measured memory_bytes: 600
def main():
    K = [int(input()) for i in range(5)]
    k = int(input())
    ans = True
    for i in range(5):
        for j in range(i + 1, 5):
            if K[j] - K[i] > k:
                ans = False
                break

    if ans:
        print("Yay!")
    else:
        print(":(")


if __name__ == "__main__":
    main()


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

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

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

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


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


int main(){
  int n;
  cin >> n;
  VI num(n);
  rep(i,n) cin >> num[i];
  VI ans;
  bool flag;
  rep(i,n){
    int memo = -1;
    for(int j = n-1-i; j >= 0; j--){
      if(memo == -1 && num[j] == j+1){
        ans.push_back(j+1);
        memo = j;
      }
    }
    if(memo == -1){
      cout << -1 << endl;
      return 0;
    }

    flag = false;
    rep(j,n-i-1){
      if(flag == false){
        if(j == memo){
          flag = true;
          num[j] = num[j+1];
        }
      }else{
        num[j] = num[j+1];
      }
    }
  }
  for(int i = n-1; i >= 0; i--){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
X,Y = map(int,input().split())

if (1 <= X <= 100) and (1 <= Y <= 100 ):
    if Y % 2 == 0:
        if (Y / X <= 4) and (Y / X >=2):
            print("Yes")
        else:
            print("No")
    else: 
        print("No")

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

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

  for(auto c:s){
    if(c=='?')cout<<'D';
    else cout<<c;
  }
  cout<<endl;

  return 0;
}

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

#define pii pair<int, int>
#define endl "\n"
// #define int long long
#define F first
#define S second
#define B begin
#define E end
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const ll P = 1e9 + 7;
const ll Q = 31;
 
using namespace std;
 
void hello()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
 
void show(vector<int>& arr)
{
    for (auto i : arr)
        cout << i << " ";
    cout << endl;
}
void show(vector<vector<int>>& arr)
{
    for (auto i : arr)
        show(i);
    cout << endl;
}


const int DSUM = 7000;
bool dp[80][80][DSUM];
 
signed main()
{
    hello();

    int n, m;
    cin >> n >> m;
    int a[n][m];
    int b[n][m];
    

    int sum = 0;

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

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
        {
            cin >> b[i][j];
            sum += b[i][j];
        }


    dp[0][0][abs(a[0][0] - b[0][0])] = 1;

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (!i && !j)
                continue;
            for (int t = 0; t < DSUM; ++t)
                dp[i][j][t] = 0;
            if (i)
            {
                for (int t = 0; t < DSUM; ++t)
                {
                    if (dp[i - 1][j][t])
                    {
                        dp[i][j][abs(t + a[i][j] - b[i][j])] = 1;
                        dp[i][j][abs(t - a[i][j] + b[i][j])] = 1;
                    }
                }
            }
            if (j)
            {
                for (int t = 0; t < DSUM; ++t)
                {
                    if (dp[i][j - 1][t])
                    {
                        dp[i][j][abs(t + a[i][j] - b[i][j])] = 1;
                        dp[i][j][abs(t - a[i][j] + b[i][j])] = 1;
                    }
                }
            }
        }
    }
    int res = sum;
    for (int i = 0; i < DSUM; ++i)
    {
        if (dp[n - 1][m - 1][i])
        {
            // cout << i - DSUM << endl;
            res = min(res, i);
            // cout << res << endl << endl;
        }
    }


    cout << res << endl;
    
}

Measured memory_bytes: 44032