akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

char a[11], b[11], c[11];
bool flag = true;

int main(){
	cin >> a >> b >> c;

	for (int i = 0; i < 10; i++){
		if (a[i + 1] == 0){
			if (a[i] != b[0]){
				flag = false;
			}
			break;
		}
	}

	for (int i = 0; i < 10; i++){
		if (b[i + 1] == 0){
			if (b[i] != c[0]){
				flag = false;
			}
			break;
		}
	}

	if (flag){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}

	return 0;
}

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

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)
#define scin(a) scanf("%d",&a);
#define scdo(a) scanf("%lf",&a);
#define scch(a) scanf("%s",a);
#define anin(a) printf("%d\n",a);
#define ando(a) printf("%lf\n",a);
#define anch(a) printf("%s\n",a);

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(void){
	int N,ans;
	scin(N)
	int d[N];
	rep(i,0,N){
		scin(d[i])
	}
	qsort(d,N,sizeof(int),asc);
	if(N % 2) ans = 0 ; else ans = d[N / 2] - d[N / 2 - 1];
	anin(ans)
	return 0;
}

Measured memory_bytes: 892
def score(c):
    if c == "r":
        return R
    if c == "s":
        return S
    if c == "p":
        return P
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

new_T = [""] * N
for i in range(N):
    if T[i] == "r":
        new_T[i] = "p"
    if T[i] == "s":
        new_T[i] = "r"
    if T[i] == "p":
        new_T[i] = "s"

ans = 0
for i in range(N):
    if i < K:
       ans += score(new_T[i]) 
    else:
        if new_T[i] == new_T[i-K]:
            new_T[i] = "x"
        else:
            ans += score(new_T[i])

print(ans)

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int a, b;
    cin >> a >> b;
    vector<int> nums;
    nums.push_back(a + b);
    nums.push_back(a - b);
    nums.push_back(a * b);
    sort(nums.begin(), nums.end());
    cout << nums[nums.size() - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np

def solve(num, div):
    if num < 2:
        return 0
    if num == 2:
        return 2
    ans = 10 ** num - 2 * 9 ** num + 8 ** num
    return ans % div

num = int(input())
div = 10 ** 9 + 7
print(solve(num, div))

Measured memory_bytes: 28936
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int n, a;

int main(int argc, char **argv) {
	cin >> n;
	int res = 0;
	REP(i, n) {
		cin >> a;
		res += a % 2;
	}
	cout << (res % 2 == 0 ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int makeelem(int suit, int number) { return suit * 256 + number; }
int getsuit(int elem) { return elem >> 8; }
int getvalue(int elem) { return elem & 255; }

int n;
int a[36];
int b[36];
int index[36];

void swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

void bubblesort() {
	for (int i = 0; i < n; i ++) {
		for (int j = n - 1; j >= i + 1; j --) {
			if (getvalue(a[j]) < getvalue(a[j-1])) {
				swap(&a[j], &a[j-1]);
			}
		}
	}
}

void selectionsort() {
	for (int i = 0; i < n; i ++) {
		int mini = i;
		for (int j = i; j < n; j ++) {
			if (getvalue(b[j]) < getvalue(b[mini])) {
				mini = j;
			}
		}
		swap(&b[i], &b[mini]);
		swap(&index[i], &index[mini]);
	}
}

int isstable() {
	int i = 0;
	while (i < n) {
		int val = getvalue(b[i]);
		int prev = index[i];
		i ++;
		while (i < n) {
			if (getvalue(b[i]) != val) { i ++; break; }
			if (prev > index[i]) return 0;
			i ++;
		}
	}
	return 1;
}

void print(int *a) {
	for (int i = 0; i < n; i ++) {
		if (i > 0) printf(" ");
		printf("%c%d", getsuit(a[i]), getvalue(a[i]));
	}
	printf("\n");
}

int main(void) {
	char line[1000];
	scanf("%d\n", &n);
	gets(line);
	for (int i = 0; i < n; i ++) {
		int suit = line[3 * i];
		int value = line[3 * i + 1] - '0';
		a[i] = makeelem(suit, value);
		b[i] = makeelem(suit, value);
	}
	for (int i = 0; i < n; i ++) {
		index[i] = i;
	}
	bubblesort();
	print(a);
	printf("Stable\n");
	selectionsort();
	print(b);
	if (isstable()) { printf("Stable\n"); } else { printf("Not stable\n"); }
	return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
ll mod=1000000007;
using namespace std;


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

	ll arr[n][2];

	for(ll i=0;i<n;i++){
		cin>>arr[i][0]>>arr[i][1];
	}

	ll c=0;

	for(ll i=0;i<n;i++){
		if(arr[i][0]==arr[i][1]){
			c++;
		}else{
			c=0;
		}

		if(c==3){
			cout<<"Yes"<<endl;
			break;
		}
	}

	if(c!=3){
		cout<<"No"<<endl;
	}
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll a,b;
  cin >> a >> b;
  ll ans;
  rep(i,3){
    if(i+1 != a && i+1 != b){
      ans = i+1;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

const int inf = 1e9 + 7;
const int mod = 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}

inline int mul(int a, int b) {
  return (a * (ll) b) % mod;
}

inline int pw(int x, int n) {
  int res = 1;
  while (n > 0) {
    if (n % 2) {
      res = mul(res, x);
      n--; 
    } else {
      x = mul(x, x);
      n /= 2;
    }
  }
  return res;
}

const int N = 3e3 + 7;

int dp[N][N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = (int) s.size();
  int m = (int) t.size();
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (i == n && j == m) {
        continue;
      }
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + (s[i] == t[j]));
    }
  }
  string ans;
  int need = dp[n][m];
  int lst = m;
  for (int i = n; i >= 1; i--) {
    for (int j = lst; j >= 1; j--) {
      if (dp[i][j] == need && dp[i][j] == dp[i - 1][j - 1] + 1 && dp[i][j] != dp[i - 1][j] && dp[i][j] != dp[i][j - 1]) {
        ans += s[i - 1];
        need--;
        lst = j - 1;
        break;
      }
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35584
#include<stdio.h>

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

  if(a==b || a==c || b==c){
    if(a==b && b==c){
      printf("1");
    }
    else{
      printf("2");
    }
  }
  else
    printf("3");
  
  return 0;
}

Measured memory_bytes: 128
import java.awt.geom.*;
import java.util.*;
public class Main{
	double EPS = 1.0e-08;
	
	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			Point2D a = new Point2D.Double(sc.nextDouble(), sc.nextDouble());
			Point2D b = new Point2D.Double(sc.nextDouble(), sc.nextDouble());
			Point2D c = new Point2D.Double(sc.nextDouble(), sc.nextDouble());
			Point2D d = new Point2D.Double(sc.nextDouble(), sc.nextDouble());
			Point2D ab = sub(a, b);
			Point2D cd = sub(c,d);
			double res = dot(ab, cd);
			if(Math.abs(res) < EPS){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}
	}
	
	private double dot(Point2D p1, Point2D p2){
		return p1.getX() * p2.getX() + p1.getY() * p2.getY();
	}

	private Point2D sub(Point2D a, Point2D b) {
		double x = a.getX() - b.getX();
		double y = a.getY() - b.getY();
		return new Point2D.Double(x,y);
	}

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

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


int main(){
	int m,n;
	cin>>m>>n;
	int flg[21]={0};
	int mita[21][21]={0};
	int mirareta[21]={0};
	
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		if(mita[a][b]==0){
			mita[a][b]=1;
			mirareta[b]++;
		}
	}
	int cnt=m;
	while(cnt){
		int yougisha=0;
		int 	tmp=9999;
		for(int i=1;i<=m;i++){
			if((i==2 && flg[i]==0 && tmp>mirareta[i])||(i!=2 && flg[i]==0 && tmp>=mirareta[i])){
				tmp=mirareta[i];
				yougisha=i;
			}
		}
		cout<<yougisha<<endl;
		flg[yougisha]=1;
		for(int i=1;i<=m;i++){
			mirareta[i]-=mita[yougisha][i];
		}
		cnt--;
		
	}
	
	return 0;
}


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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  while (cin >> N, N) {
    string s;
    cin >> s;
    int a[110], b[110];
    for (int i = 0; i < N; i++) {
      cin >> a[N - 1 - i] >> b[N - 1 - i];
    }
    for (int i = 0; i < N; i++) {
      a[i]--, b[i]--;
      s[a[i]] = (s[a[i]] - 'a' + b[i] - a[i]) % 26 + 'a';
      s[b[i]] = (s[b[i]] - 'a' + b[i] - a[i]) % 26 + 'a';
      swap(s[a[i]], s[b[i]]);
    }
    cout << s << endl;
  }

  return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> v(n, 0);

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

    int len = 0;
    int ans = 0;
    for(int i = 0; i < n; i += 1) {
        if(i >= 1 and v[i] == v[i - 1]) {
            len += 1;
        } else {
            ans += len / 2;
            len = 1;
        }
    }

    ans += len / 2;

    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define INF 1e16
#define N (1000000000+7)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;


ll gcd(ll a, ll b) {
    if(b==0) return abs(a);
	else return gcd(b, a%b);
}

ll kaijo[200010];
void init() {
	kaijo[0] = 1;
	for (ll i = 1;i <= 200000;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}
 
ll inv(ll x,ll power) {
	ll res = 1;
	ll k = power;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}
 
ll Comb(ll n, ll k) {
	if (n < 0 || k < 0 || (n - k) < 0)return 0;
	ll b = kaijo[n];
	ll c = kaijo[n - k];
	ll d = kaijo[k];
	ll cd = (c*d) % N;
	return ((b%N)*(inv(cd,N-2)) % N) % N;
}

int main(void){
    init();
    ll n,a,b;
    cin>>n>>a>>b;
    ll now = inv(2LL,n);
    ll tmp1=1,tmp2=1;
    for(ll i=1;i<=a;i++)tmp1 = (tmp1*inv(i,N-2))%N;
    for(ll i=n;i>n-a;i--){
        tmp1 = (tmp1*i)%N;
    }
    for(ll i=1;i<=b;i++)tmp2 = (tmp2*inv(i,N-2))%N;
    for(ll i=n;i>n-b;i--){
        tmp2 = (tmp2*i)%N;
    }
    now = (now-tmp1+N)%N;
    now = (now-tmp2+N)%N;
    now = (now-1+N)%N;
    cout<<(now+N)%N<<endl;
    return 0;
}

Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
template <typename T = int>
T in() {
    T temp; cin >> temp; return temp;
}

template <typename VType = int>
list<VType> const LR(VType start, VType end) {
    list<VType> ret; for (VType i = start; i < end; i++) ret.push_back(i); return move(ret);
}

int main() {
    int diff = 0;
    int x(in());
    int temp;
    for (int i = 0; i < 4; i++) {
        temp = in();
    }

    cout << (((temp - x) <= in()) ? "Yay!" : ":(") << endl;
        return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ff first
#define ss second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define forn(i, n) for (int i = 0; i < n; i++)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;



int32_t main()
{
    fast

   int test=1;
    //cin>>test;
  
   

  while(test--)
  {
    string s;
    cin>>s;
    int ans=0;
    int c=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='R')
        {
            c++;
        }
        else 
        {
            c=0;
        }
        ans=max(ans,c);
    }
    cout<<ans;

// while ending
   }
  

return 0;
}

Measured memory_bytes: 3636
A,B=map(int,input().split())

import math

def tn(n):
  m=n
  factor=[]
  tmp=int(math.sqrt(n))+1
  for num in range(2,tmp):
    t=0
    while n%num==0:
      n//=num
      if t==0:
        factor.append(num)
        t=1
  if factor==[]:
    factor.append(m)
  factor.append(1)
  factor.append(n)
  return factor

listA=tn(A)
listB=tn(B)
anslist=set(listA) & set(listB)
ans=len(anslist)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int search(int *, int, int);

int main(){
  int i, n, A[10000+1], q, key, sum = 0;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d", &key);
    if(search(A, n, key)) sum++;
  }

  printf("%d\n",sum);
  
  return 0;
}

int search(int A[], int n, int key){
  int i=0;
  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}



Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
ll f[200005][19],g[200005][19];
int n;ll a[200005],pow1[17];
const ll inf=1000000000000000000LL;
int main()
{
	//freopen("1.in","r",stdin);
	memset(f,0x3f3f3f3f,sizeof(f));
	memset(g,0x3f3f3f3f,sizeof(g));
	for(int i=0;i<=n+1;i++)
	{
		for(int j=0;j<=15;j++)
		f[i][j]=g[i][j]=inf;
	}
	n=read();
	pow1[0]=1;
	for(int i=1;i<=15;i++) pow1[i]=pow1[i-1]*4;
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
	}
	for(int i=0;i<=15;i++) f[1][i]=i;
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=15;j++)
		{
			for(int k=15;k>=0;k--)
			{
				if(a[i-1]*pow1[k]>=a[i]*pow1[j])
				{
					f[i][j]=min(f[i][j],f[i-1][k]+j);
					//cout<<k<<endl;
				}
				//else break;
			}
			if(f[i][j]==4557430888798830399LL) f[i][j]=f[i][j-1]+i;
			//cout<<f[i][j]<<' ';
		}
		//cout<<endl;
	}
	for(int i=0;i<=15;i++) g[n][i]=i;
	for(int i=n-1;i;i--)
	{
		for(int j=0;j<=15;j++)
		{
			for(int k=15;k>=0;k--)
			{
				if(a[i+1]*pow1[k]>=a[i]*pow1[j])
				{
					g[i][j]=min(g[i][j],g[i+1][k]+j);
				}
				//else break;
			}
			if(g[i][j]==4557430888798830399LL) g[i][j]=g[i][j-1]+(n-i+1);
		}
	}
	ll ans=inf;
	f[0][0]=g[0][0]=f[n+1][0]=g[n+1][0]=0;
	for(int i=0;i<=n;i++)
	{
		//cout<<f[i][0]<<" "<<g[i][0]<<endl;
		ll num1,num2;num1=num2=inf;
		for(int j=0;j<=15;j++)
		{
			num1=min(num1,f[i][j]);
			num2=min(num2,g[i+1][j]);
		}
		ans=min(ans,1LL*num1*2+1LL*num2*2+1LL*i);
		//cout<<i<<" "<<num1<<" "<<num2<<endl;
	}
	cout<<ans;
}

Measured memory_bytes: 61184
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

int main() {
	int n, q, t; //プロセス数、クォンタム、時間(nameとセットで使う)
	string name;

	queue<pair<string, int> > Q;

	cin >> n >> q;

	for (int i = 0; i < n; i++) {
		cin >> name >> t;
		Q.push(make_pair(name, t));
	}

	pair<string, int> u;
	int elaps = 0, a;

	while (!Q.empty()) {
		u = Q.front(); Q.pop();
		a = min(u.second, q);
		u.second -= a;
		elaps += a;

		if (u.second > 0) {
			Q.push(u);
		}
		else {
			cout << u.first << " " << elaps << endl;
		}

	}

	return 0;

}


Measured memory_bytes: 6328
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	String s = scan.next();

	int oddZero = 0;
	int oddOne = 0;
	int evenZero = 0;
	int evenOne = 0;
	for(int i = 0; i < s.length(); i++){
	    if(i % 2 == 0){  //1,3,5など奇数番目
		if(s.charAt(i) == '0'){
		    oddZero++;
		}else{
		    oddOne++;
		}
	    }else{  //2,4,6など偶数番目
		if(s.charAt(i) == '0'){
		    evenZero++;
		}else{
		    evenOne++;
		}
	    }
	}

	/*
	System.out.println("EZ : "+evenZero);
	System.out.println("EO : "+evenOne);
	System.out.println("OZ : "+oddZero);
	System.out.println("OO : "+oddOne);
	*/

	if(evenZero + oddOne > evenOne + oddZero){
	    System.out.println(evenOne+oddZero);
	}else if(evenOne + oddZero > evenZero + oddOne){
	    System.out.println(evenZero+oddOne);
	}else{
	    System.out.println(s.length()/2);
	}
    }
}
	


Measured memory_bytes: 26756
#include<iostream>
#include<cstring>
#include<cstdio>

long long int dp[50];

int fib(int n) {
	if (n == 0 || n == 1)return dp[n] = 1;
	if (dp[n] != -1)return dp[n];
	return dp[n] = fib(n - 1) + fib(n - 2);
}


int main(void){
	int n, i;
	long long int m;
	for (i = 0; i <= 50; i++) {
		dp[i] = -1;
	}

	scanf("%d", &n);
	m = fib(n);
	printf("%lld\n", m);

	return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    map<string, int> mp;
    rep(i, N) {
        string S;
        cin >> S;
        mp[S]++;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl; 
    cout << "TLE x " << mp["TLE"] << endl; 
    cout << "RE x " << mp["RE"] << endl; 
    return 0;
}

Measured memory_bytes: 3628
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let t: usize = itr.next().unwrap().parse().unwrap();
    let wv: Vec<(usize, usize)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();

    // t - 1までのナップサック
    // t - 1秒に残りの1こを注文したとする。
    let mut dp1 = vec![vec![0; t + 1]; n + 1];
    let mut dp2 = vec![vec![0; t + 1]; n + 1];
    for i in 0..n {
        for j in 0..t {
            dp1[i + 1][j] = max(dp1[i + 1][j], dp1[i][j]);
            if j + wv[i].0 <= t - 1 {
                dp1[i + 1][j + wv[i].0] = max(dp1[i + 1][j + wv[i].0], dp1[i][j] + wv[i].1);
            }
        }
    }
    for i in (0..n).rev() {
        for j in 0..t {
            dp2[i][j] = max(dp2[i][j], dp2[i + 1][j]);
            if j + wv[i].0 <= t - 1 {
                dp2[i][j + wv[i].0] = max(dp2[i][j + wv[i].0], dp2[i + 1][j] + wv[i].1);
            }
        }
    }

    let mut ans = 0;
    for i in 0..n {
        for j in 0..t {
            ans = max(ans, dp1[i][t - 1 - j] + dp2[i + 1][j] + wv[i].1);
        }
    }
    println!("{}", ans);
}


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

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void solve(){
    int32_t N, K ;
    cin >> N >> K;
    std::vector<int32_t> A;
    A.reserve(N);
    std::vector<int32_t> B (N + 1, 0);
    for(int32_t i = 0 ; i < N ; i++){
        uint32_t a;
        cin >> a;
        A.push_back(a);
    }
    K = std::min(K, 100);
    for(int32_t l = 0 ; l < K ; l++){
        //usig accumlate technique
        std::fill(B.begin(), B.end(), 0);
        for(int32_t i = 0 ; i < N ; i++){
            int left, right;
            if( A[i] > 0){
                left = std::max(0 , i - A[i]);
                right = std::min(i + A[i], N - 1);
            }else{
                left = i;
                right = i;
            }
            B[left] = B[left] + 1;
            B[right + 1] = B[right + 1] - 1;
        }
        int32_t accumulate = 0;
        for(int32_t i = 0 ; i < N ; i++){
            accumulate += B[i];
            A[i] = accumulate;
        }
    }
    print_vect(A);
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int a,b;

    Scd2(a,b);

    int ans = b;
    if( a < 6 ) ans = 0;
    else if( a < 13 ) ans = b/2;

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

    return 0;
}

// SaturDay NightLive
// 嵐にしやがれ



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

    int main(int argc, char* argv[])
    {
        int n;
        string s;
        cin >> n >> s;
        int ans = 0;
        for (int i = 0; i <= n-3; ++i)
        {
            if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
            {
                ans++;
            }
        }
        std::cout << ans << "\n";
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
	
int main(){
	string A, B, C;
	cin >> A >> B >> C;
	int a = A.size(), b = B.size();
	if(A[a - 1] == B[0] && B[b - 1] == C[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
import re

n, k = map(int, input().split())
str = input()

pattern = re.compile("RL")
X = len(pattern.findall(str))
result = n - X * 2

if str[0] == 'L' and str[-1] == 'R':
    result -= 2
    Y = 1
elif str[0] == 'L' or str[-1] == 'R':
    result -= 1
    Y = 0
else:
    Y = -1
    
if k <= X:
    result += 2 * k
else:
    result += 2 * X + Y

print(result)





Measured memory_bytes: 6516
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,l;
	cin>>s;
	cin>>l;
   for(int i=0;i<l.length();i++){
   	cout<<l[i];
   }
   for(int i=0;i<s.length();i++){
   	cout<<s[i];
   }
}

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



void print(vector<int> v){
	
	for(int i=0;i<v.size();i++){
		cout<<v[i];
	}
	//cout<<endl;
}
int jud(int x){
	
	if(x%2==0)return x/2;
	else return (3*x)+1;
}
int A,B;
int m[10000001]={0};
string S;
long long minS=100000000000;
void solve(){
	cin>>A>>B;
	cout<<A+(B/2)<<endl;


}


int main(){

    solve();
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using namespace std;
using namespace __gnu_pbds;
#define  st first
#define  nd second



void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define maxn  1000001
#define M   1000000007
#define int long long
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef cc_hash_table<int, int, hash<int > > ht;
int cei(int x,int y){
if(x%y==0)
    return x/y;
else
    return (x/y)+1;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int l[n];
    int r[n];
    int ans[n];
    l[0]=a[0];
    r[n-1]=a[n-1];
    for(int i=1;i<n;i++){
        l[i]=max(l[i-1],a[i]);
    }
    for(int i=n-2;i>=0;i--){
        r[i]=max(r[i+1],a[i]);
    }
    ans[0]=r[1];
    ans[n-1]=l[n-2];
    for(int i=1;i<=n-2;i++){
        ans[i]=max(l[i-1],r[i+1]);
    }
    for(int i=0;i<n;i++)
        cout<<ans[i]<<"\n";


}


Measured memory_bytes: 7936
#include <stdio.h>
#include <ctype.h>
#include <string.h>

typedef enum { false, true } bool;

int main(void)
{
    char S[11];
    int len;
    int i;
    int ctr = 0;
    bool flag = false;
    
    scanf("%s", S);
    
    
    len = strlen(S);
    
    if(S[0] == 'A')
    {
        if(!isupper(S[1]))
        {
            for(i=2; i<len-1; i++)
            {
                if(S[i] == 'C')
                    ctr++;
                else if(isupper(S[i]))
                    break;
            }
            if(!isupper(S[i]) && ctr == 1)
                flag = true;
        }
    }
    
    if(flag)
        printf("AC\n");
    else
        printf("WA\n");
        

    //system("pause");
    
    return 0;
}

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

const ll maxs = 1e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

void solve(){
    ll x;
    cin >> x;
    ll pt=100;
    ll i=0;
    while(1){
        if(pt >= x)
            break;
        pt += pt/100;
        i++;
    }
    cout << i ;
}

int main(){
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int p[100000];
int dist[100000];

int main() {
  int n;
  cin >> n;
  REP(i,n) cin >> p[i];
  priority_queue<pii> Q;
  Q.push(pii(0,0));
  REP(i,n)dist[i]=INF;
  dist[0] = 0;
  while(!Q.empty()) {
    pii q = Q.top(); Q.pop();
    int d = -q.first;
    int now = q.second;

    //cout << now << " " << d << endl;
    
    if (p[now]) {
      int nn = now+p[now];
      if (dist[nn] > d) {
        dist[nn] = d;
        Q.push(pii(-d, nn));
      }
    } else {
      for (int i=1; i<=6; ++i) {
        int nn = now+i;
        if (nn>n) break;
        if (dist[nn] > d+1) {
          //cout << now << " ; " << i << endl;
          dist[nn] = d+1;
          Q.push(pii(-(d+1),now+i));
        }
      }
    }
  }
  cout << dist[n-1] << endl;
}

Measured memory_bytes: 1996
H,W=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(H)]
ans=[]
for i in range(H-1):
    for j in range(W):
        if a[i][j]%2==1:
            ans.append((i,j,i+1,j))
            a[i][j]-=1
            a[i+1][j]+=1
for j in range(W-1):
    if a[H-1][j]%2==1:
        ans.append((H-1,j,H-1,j+1))
        a[H-1][j]-=1
        a[H-1][j+1]+=1

print(len(ans))
for i in ans:
    print(i[0]+1,i[1]+1,i[2]+1,i[3]+1)


Measured memory_bytes: 22696
#include <stdio.h>

int main(void){
	int num[101] = {0};
	int i, n, value = 0;
	while(scanf("%d", &n) != EOF){
		num[n]++;
	}
	
	for(i = 1; i <= 100; i++){
		if(num[i] >= value)
			value = num[i];
	}
	
	for(i = 1; i <= 100; i++){
		if(num[i] == value)
			printf("%d\n", i);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N, H[100005];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}

	bool ans = true;

	for (int i = N-2; i >= 0; i--)
	{
		if (H[i] > H[i + 1] + 1)
		{
			ans = false;
			break;
		}
		else if (H[i] == H[i + 1] + 1)
		{
			H[i]--;
		}
	}

	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

Int n;

#define MAX_V 100001
vector<Int> G[MAX_V], vs(MAX_V * 2 - 1), depth(MAX_V * 2 - 1), id(MAX_V);

// セグメントツリー
class SegmentTree {
private:
    Int n;
    vector<pair<Int, Int>> node;
    pair<Int, Int> ident = {INF, -1};
    pair<Int, Int> f(pair<Int, Int> x, pair<Int, Int> y) {
        return x.fi < y.fi ? x : y;
    }
public:
    // SegmentTree(vector<Int> v) {
    //     Int v_size = v.size();
    //     n = 1;
    //     while (n < v_size) {
    //         n *= 2;
    //     }
    //     node.resize(2 * n, ident);
    //     for (Int i = 0; i < v_size; i++) {
    //         node[n + i] = v[i];
    //     }
    //     for (Int i = n - 1; i >= 1; i--) {
    //         node[i] = f(node[i * 2], node[i * 2 + 1]);
    //     }
    // }
    SegmentTree(vector<pair<Int, Int>> v) {
        Int v_size = v.size();
        n = 1;
        while (n < v_size) {
            n *= 2;
        }
        node.resize(2 * n, ident);
        for (Int i = 0; i < v_size; i++) {
            node[n + i] = v[i];
        }
        for (Int i = n - 1; i >= 1; i--) {
            node[i] = f(node[i * 2], node[i * 2 + 1]);
        }
    }
    // void update(Int x, Int val) {
    //     x += n;
    //     node[x] = val;
    //     while (x > 1) {
    //         x /= 2;
    //         node[x] = f(node[x * 2], node[x * 2 + 1]);
    //     }
    // }
    // [a, b) での答え
    pair<Int, Int> query(Int a, Int b, Int k = 1, Int l = 0, Int r = -1) {
        //cout << l << " " << r << endl;
        if (r < 0) {
            r = n;
        }
        if (r <= a or b <= l) {
            return ident;
        }
        if (a <= l and r <= b) {
            return node[k];
        }
        pair<Int, Int> vl = query(a, b, 2 * k, l, (l + r) / 2);
        pair<Int, Int> vr = query(a, b, 2 * k + 1, (l + r) / 2, r);
        return f(vl, vr);
    }
};



void dfs(Int v, Int d, Int &k) {
    vs[k] = v;
    depth[k] = d;
    id[v] = k;
    k++;
    for (Int i = 0; i < (Int)G[v].size(); i++) {
        dfs(G[v][i], d + 1, k);
        vs[k] = v;
        depth[k] = d;
        k++;
    }
}

int main() {
    cin >> n;
    for (Int i = 0; i < n; i++) {
        Int k;
        cin >> k;
        for (Int j = 0; j < k; j++) {
            Int c;
            cin >> c;
            G[i].push_back(c);
        }
    }
    Int x = 0;
    dfs(0, 0, x);
    vector<pair<Int, Int>> arg(depth.size());
    for (Int i = 0; i < (Int)depth.size(); i++) {
        arg[i] = {depth[i], i};
    }
    SegmentTree seg(arg);
    Int q;
    cin >> q;
    vector<Int> res(q);
    for (Int i = 0; i < q; i++) {
        Int u, v;
        cin >> u >> v;
        res[i] = vs[seg.query(min(id[u], id[v]), max(id[u], id[v]) + 1).se];
    }
    for (Int i = 0; i < q; i++) {
        dump(res[i]);
    }
    return 0;
}


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

int main()
{
    int n;
    cin>>n;
    int arr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    int counter=0,sum=0;
    for(int i=0;i<n;i++)
    {
        if(arr[i]>=sum)counter++;
        sum=max(arr[i],sum);
    }
    cout<<counter<<endl;
}


Measured memory_bytes: 256
import sys
s = sys.stdin.readline().strip()
flag = True
i = 0
while i < len(s):
  if i % 2:
    if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
      flag = False
      break
  else:
    if s[i] != 'R' and s[i] != 'U' and s[i] != 'D':
      flag = False
      break
  i += 1
if flag:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		sc.close();

		int x = 0;

		if(a == b) {
			x = c;
		}
		if(a == c) {
			x = b;
		}
		if(b == c) {
			x = a;
		}

		System.out.println(x);


	}


}


Measured memory_bytes: 21712
n = int(input())
A = list(map(int, input().split()))
sumA = sum(A)
B = list(map(int, input().split()))
sumB = sum(B)

if sumA < sumB:
    print(-1)
    exit(0)

# 条件確認する
flag = True
ok = []
not_ok = []
not_ok_sum = 0
for i in range(n):
    if A[i] < B[i]:
        not_ok.append(i)
        not_ok_sum += A[i]
        flag = False
    else:
        ok.append(A[i] - B[i])

if flag:
    print(0)
    exit(0)

ok.sort()
ok.reverse()

# print(n)
# print(A)
# print(B)
# print(not_ok)
# print(not_ok_sum)
# print(sumA - not_ok_sum)
# print(ok)

# 残っている余力の大きい方から順番に使って，足りていない分を埋めていく
count = 0
current = 0
now_prev = 0
rem = 0
while True:
    now = now_prev + ok[current]
    count += 1
    # print(current, now)
    while rem < len(not_ok):
        j = not_ok[rem]
        # print("  ", j, B[j] - A[j])
        if B[j] - A[j] < now:
            rem += 1
            now -= (B[j] - A[j])
            # print(now)
            count += 1
        else:
            break
    if rem == len(not_ok):
        break
    else:
        now_prev = now
        current += 1
print(count)

Measured memory_bytes: 80944
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=3e5+10;
const int LOG=25;
int w,h,n,ans,top1,top2,stan,rt,tot;
struct node{
	int x,y;
	node(int xx=0,int yy=0){x=xx;y=yy;}
	bool operator <(const node&e)const{return y<e.y;}
}a[N],s1[N],s2[N];
bool operator !=(const node&a,const node&b){return a.x!=b.x&&a.y!=b.y;}
struct DynamicSegmentTree{int lc,rc,val,tag;}t[N*LOG];
inline void clear(int o){t[o].lc=t[o].rc=t[o].val=t[o].tag=0;}
inline int newnode(){++tot;clear(tot);return tot;}
inline void pushdown(int o,int L,int R){
	if(t[o].tag){
		int &lc=t[o].lc,&rc=t[o].rc;
		if(!lc)lc=newnode();if(!rc)rc=newnode();
		t[lc].val+=t[o].tag;t[lc].tag+=t[o].tag;
		t[rc].val+=t[o].tag;t[rc].tag+=t[o].tag;
		t[o].tag=0;
	}
}
inline void update(int &o,int L,int R,int l,int r,int v){
	if(l>r||L>R)return;if(!o)o=newnode();
	if(l<=L&&R<=r){t[o].val+=v;t[o].tag+=v;return;}
	int M=(L+R)>>1;pushdown(o,L,R);
	if(l<=M)update(t[o].lc,L,M,l,r,v);
	if(r>M)update(t[o].rc,M+1,R,l,r,v);
	t[o].val=max(t[t[o].lc].val,t[t[o].rc].val);
}
inline int query(int o,int L,int R,int l,int r){
	if(l>r||L>R||!o)return 0;
	if(l<=L&&R<=r)return t[o].val;
	int M=(L+R)>>1,sum=0;pushdown(o,L,R);
	if(l<=M)sum=max(sum,query(t[o].lc,L,M,l,r));
	if(r>M)sum=max(sum,query(t[o].rc,M+1,R,l,r));
	return sum;
}
inline int Solve(){
	sort(a+1,a+n+1);
	rt=0;tot=0;top1=top2=0;stan=w/2;
	s1[0]=node(stan,0);s2[0]=node(stan,0);int res=0;
	update(rt,1,h,1,h,w);
	for(register int i=1;i<=n;i++){
		update(rt,1,h,1,a[i].y,a[i].y-a[i-1].y);
		res=max(res,query(rt,1,h,1,a[i].y));
		if(a[i].x<=stan){
			update(rt,1,h,s1[top1].y+1,a[i].y,-a[i].x);
			while(top1&&s1[top1].x<=a[i].x)
				update(rt,1,h,s1[top1-1].y+1,s1[top1].y,-(a[i].x-s1[top1].x)),top1--;	
			s1[++top1]=a[i];
		}
		if(a[i].x>=stan){
			update(rt,1,h,s2[top2].y+1,a[i].y,-(w-a[i].x));
			while(top2&&s2[top2].x>=a[i].x)
				update(rt,1,h,s2[top2-1].y+1,s2[top2].y,-(s2[top2].x-a[i].x)),top2--;
			s2[++top2]=a[i];
		}
	}
	return res<<1;
}
int main(){
	scanf("%d%d%d",&w,&h,&n);
	for(register int i=1;i<=n;i++)
		scanf("%d%d",&a[i].x,&a[i].y);
	a[++n]=node(0,0);a[++n]=node(0,h);a[++n]=node(w,0);a[++n]=node(w,h);
	ans=(max(w,h)+1)<<1;
	ans=max(ans,Solve());
	for(register int i=1;i<=n;i++)swap(a[i].x,a[i].y);swap(w,h);
	ans=max(ans,Solve());
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h> 
using namespace std; 
int comp(const void* a, const void* b) 
{ return *(int*)a > *(int*)b ; } 
int findNumberOfTriangles(int arr[], int n) 
{ 
	qsort(arr, n, sizeof( arr[0] ), comp); 
	int count = 0; 
	for (int i = 0; i < n - 2; ++i) 
	{ 
		int k = i + 2; 
		for (int j = i + 1; j < n; ++j) 
		{ 
			while (k < n && arr[i] + arr[j] > arr[k]) 
			++k;
			if(k > j) 
			count += k - j - 1; 
		} 
	} 

	return count; 
} 
 
int main() 
{ 
	int n;
	int i;
	cin>>n;
	int a[n+5];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cout<<findNumberOfTriangles(a,n); 
} 
 


Measured memory_bytes: 256
#include <iostream>

#define OK 0;
#define START 0;
using namespace std;


int main(void) {
    unsigned int a = START;
    unsigned int b = START;

    //scanf
    cin >> a >> b;

    if (a < b) {
        cout << "a < b" << endl;
    }
    else if (a > b) {
        cout << "a > b" << endl;

    }
    else {
        cout << "a == b" << endl;
    }

    return OK;
}

Measured memory_bytes: 1152
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()
n = len(s)

ans = 0
l, r = 0, n - 1
while r - l >= 1:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        l += 1
        ans += 1
    elif s[r] == 'x':
        r -= 1
        ans += 1
    else:
        ans = -1
        break

print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	int SIZE = 600;

	void run() {
		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			int d = sc.nextInt();

			int ans = 0;

			for (int i = d; i < SIZE; i += d) {
				ans += i * i * d;
			}

			System.out.println(ans);
		}
		sc.close();
	}

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

}

Measured memory_bytes: 17180
#include<iostream>
#include<vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;

int N,K;

int main(){
    cin >> N >> K;
    ll a[N];
    REP(i,N){
        cin >> a[i];
    }

    ll sum[N];
    sum[0] = a[0];
    FOR(i,1,N){
        sum[i] = sum[i-1] + a[i];
    }
    // REP(i,N){
    //     cout << sum[i] << endl;
    // }

    vector<ll> b;
    REP(i,N){
        b.push_back(sum[i]);
    }

    REP(i,N)FOR(j,i+1,N){
        b.push_back(sum[j]-sum[i]);
    }
    // REP(i,b.size()){
    //     cout << b[i] << endl;
    // }

    ll ans = 0;
    for(int i = 50; i >= 0; i--){
        ll m = (1LL << i);
  //      cout << m << endl;
        int cnt = 0;
        vector<ll> c;
        REP(i,b.size()){
            if(b[i] / m > 0){
                cnt++;
                c.push_back(b[i] % m);
            }
        }
        if(cnt >= K){
            ans += m;
            b = c;
        }else{
            REP(i,b.size()){
                b[i] = b[i] % m;
            }
        }
//        cout << m << " " << cnt << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<Int> a(n,0);
    rep(i,n) cin>>a[i];
    int q; cin>>q;
    for(int i=0; i<q; i++){
        Int k ; cin>>k;
        auto dl=lower_bound(a.begin(),a.end(),k);
        auto ul = upper_bound(a.begin(),a.end(),k);
        cout<<distance(a.begin(),dl)<<" "<<distance(a.begin(),ul)<<endl;
            }
    return 0;
}


Measured memory_bytes: 3560
K, N = gets.split(" ").map(&:to_i)
A = gets.split(" ").map(&:to_i)
t = 0
max = 0
A.each_with_index{|v,i|
  if i == 0
    r = K - A[N-1] + v
  else
    r = v - t
  end
  t = v
  if max < r
    max = r
  end
}
puts K - max

Measured memory_bytes: 15368
#include <stdio.h>
 
int main(){
	char S[11];
	char A[11]={};
	int x=0;
 
	scanf("%s",&S);
	for(int i=0;i<11;i++){
		if(S[i]=='0'){
			A[x]='0';
			x++;
		}
		else if(S[i]=='1'){
			A[x]='1';
			x++;
		}
		else if(S[i]=='B'){
			if(x!=0)
				x--;
		}
 
	}
	for(int i=0;i<x;i++){
		printf("%c",A[i]);
	}
	printf("\n");\
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll= long long;
using ld= long double;
using vl= vector<ll>;
using vd= vector<ld>;
using vs= vector<string>;
using vb= vector<bool>;
using vvl= vector<vector<ll>>;
using vvd= vector<vector<ld>>;
using vvs= vector<vector<string>>;
using vvb= vector<vector<bool>>;
using pll= pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

template <class T>
inline void chmin(T &a, T b) {
    if(a > b) { a= b; }
}

template <class T>
inline void chmax(T &a, T b) {
    if(a < b) { a= b; }
}

ll op(ll a, ll b) { return max(a, b); }
ll e() { return -1; }
ll target;
bool f(ll x) { return (x < target); }
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll N, Q;
    cin >> N >> Q;
    segtree<ll, op, e> seg(N);
    REP(i, N) {
        ll x;
        cin >> x;
        seg.set(i, x);
    }
    REP(i, Q) {
        ll T;
        cin >> T;
        if(T == 1) {
            ll x, v;
            cin >> x >> v;
            x--;
            seg.set(x, v);
        } else if(T == 2) {
            ll L, R;
            cin >> L >> R;
            L--;
            cout << seg.prod(L, R) << "\n";
        } else {
            ll x, v;
            cin >> x >> v;
            target= v;
            x--;
            cout << seg.max_right<f>(x) + 1 << "\n";
        }
    }
}

Measured memory_bytes: 9028
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7

def sol():
    S = input().strip()
    T = input().strip()

    lenS = len(S)
    lenT = len(T)

    dp = [[0] * (lenT + 1) for _ in range(lenS + 1)]

    for i, s in enumerate(S):
        for j, t in enumerate(T):
            if s == t:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

    ans = []
    now = dp[lenS][lenT]
    i = lenS
    j = lenT
    while now > 0:
        if dp[i - 1][j] == now:
            i -= 1
        elif dp[i][j - 1] == now:
            j -= 1
        else:
            ans.append(S[i - 1])
            i -= 1
            j -= 1
            now -= 1

    print(''.join(ans[:: -1]))

sol()

Measured memory_bytes: 112860
#include<stdio.h>

int main(void){

int W, H, x , y, r ;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

if(x-r>=0 && x+r<=W){

    if(y-r>=0 && y+r<=H){

     printf("Yes\n");

}else{

printf("No\n");

}

}else{

printf("No\n");

}

return 0;

}

Measured memory_bytes: 584