akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main()
{
    int a,b ;
    scanf("%d %d",&a, &b);
    if(a<b)
        printf("a < b\n");
    else if(a>b)
        printf("a > b\n");
    else
        printf("a == b\n");
    return 0;
}



Measured memory_bytes: 2104
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000

int main(){
	long long x, y, z;
	long long s, ans;
	scanf("%lld %lld", &x, &y);
	if (x == 1){
		printf("%lld\n", y);
		return 0;
	}
	if (x > 50){
		printf("1\n");
		return 0;
	}
	f(i, 1000000){
		z = 1;
		f(j, x){
			z *= (i+1);
			if (z > y){
				z = -1;
				break;
			}
		}
		if (z > 0){
			if (y%z == 0)ans = i+1;
		}
	}

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


	return 0;
}


Measured memory_bytes: 128
let () =
  let rec make_list n = if n = 0 then [0] else n :: make_list (n-1) in
  let n,m = Scanf.scanf "%d %d\n" @@ fun a b -> a, b in
  let h = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let arr = Array.make n 0 in
  for i = 1 to m do
    Scanf.scanf "%d %d\n" @@ fun x y ->
    let a = x-1 in let b = y-1 in 
    arr.(a) <- (max h.(b) arr.(a)); arr.(b) <- (max h.(a) arr.(b))
  done;
  print_int (List.fold_left (fun i v -> if h.(v) > arr.(v) then i+1 else i) 0 (make_list (n-1)))

Measured memory_bytes: 11156
#include <stdio.h>
#include <stdlib.h>
#define N 100000

typedef struct {
  char suit;
  int num;
}CARD;

void quicksort(CARD *,int,int);
int partition(CARD *,int,int);
void merge(CARD *,int,int,int);
void mergeSort(CARD *,int,int);

int main()
{
  int n,i,num,flag=0;
  char suit;
  CARD *A,*B;

  scanf("%d",&n);
  if(n<1 || n>N) exit(1);
  
  A = (CARD *)malloc(sizeof(CARD)*n);
  B = (CARD *)malloc(sizeof(CARD)*n);
  
  for(i=0;i<n;i++){
    scanf(" %c %d",&suit,&num);
    if(num<1 || num>1000000000) exit(2);
    A[i].suit = suit;
    B[i].suit = suit;
    A[i].num = num;
    B[i].num = num; //mergesortとquicksort用に2つつくる
  }

  mergeSort(A,0,n);
  quicksort(B,0,n-1);

  /*for(i=0;i<n;i++)
    printf("%c,%c\n",A[i].suit,B[i].suit);*/

  for(i=0;i<n;i++){
    if(A[i].suit != B[i].suit) flag = 1; //mergesortは常に安定だから比較すれば安定かわかる
    //printf("%c,%c\n",A[i].suit,B[i].suit);
  }
  
  if(flag==1) printf("Not stable\n");
  else printf("Stable\n");

  for(i=0;i<n;i++)
    printf("%c %d\n",B[i].suit,B[i].num);

  /*printf("mergesort:\n");
    for(i=0;i<n;i++)
    printf("%c %d\n",A[i].suit,A[i].num);*/
  
  
  return 0;
}

void quicksort(CARD *A,int p,int r)
{
  int q;
  
  if(p<r){
    q = partition(A,p,r);
    //printf("%d\n",q);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }

}

int partition(CARD *A,int p,int r)
{
  int i,j;
  CARD x,tmp;
  
  x = A[r];
  i = p-1;

  for(j=p;j<r;j++){
    if(A[j].num <= x.num){
      i += 1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;

  return i+1;
}

void merge(CARD *S,int l,int m,int r)
{
  int n1,n2,i,j=0,k=0;
  CARD L[N],R[N];

  n1 = m-l;
  n2 = r-m;

  //printf("確認 n1:%d , n2:%d\n",n1,n2);

  for(i=0;i<n1;i++) L[i] = S[l+i];
  for(i=0;i<n2;i++) R[i] = S[m+i];
  L[n1].num = 999999999;
  R[n2].num = 999999999;

  for(i=l;i<r;i++){
    if(L[j].num<=R[k].num){
      S[i] = L[j];
      j += 1;
    }
    else{
      S[i] = R[k];
      k += 1;
    }
  }
}
void mergeSort(CARD *S,int l,int r)
{
  int m;
  
  if(l+1 < r){
    m = (l+r)/2;
    mergeSort(S,l,m);
    mergeSort(S,m,r);
    merge(S,l,m,r);
  }
}



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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;


// dp[i][j]: i文字目からの文字とj文字目からの文字の最長の重なり
lli dp[5001][5001];

int main() {
    lli n;
    string s;
    cin1(n);
    cin1(s);
    REPE(i,0,n-2) {
        if (s[n-1] == s[i]) {
            dp[n-1][i] = 1;
        }
    }
    for (lli i = n-2; i >= 0; i--) {
        for (lli j = i-1; j >= 0; j--) {
            if (s[i] == s[j]) {
                dp[i][j] = min(i - j, dp[i+1][j+1] + 1);

            }
        }
    }
    lli ans = 0;
    for (lli i = n-2; i >= 0; i--) {
        for (lli j = i-1; j >= 0; j--) {
            //cout2(i,j);
            //cout1(dp[i][j]);
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
}


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

using namespace std;
#define ll long long

int max(int a,int b){
  if(a>b){
    return a;
  }else{
    return b;
  }
}

int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(c -(a-b),0) << endl;
  return 0;
}

Measured memory_bytes: 3472
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	list<int>edge[100001];
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	cin >> Q;
	vector<vector<int>>num(N + 1, vector<int>(11, -1));
	int a[100001];
	int b[100001];
	int c[100001];
	for (int i = 0; i < Q; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	for(int i=Q-1;i>=0;i--){
		queue<pair<int, int>>QQ;
		QQ.push({ a[i],b[i] });
		while (!QQ.empty()) {
			int cc = QQ.front().second;
			int cn= QQ.front().first;
			QQ.pop();
			if (num[cn][cc] >= 0)continue;
			for (int j = 0; j <= cc; j++) {
				if (num[cn][j] == -1) {
					num[cn][j] = c[i];
				}
			}
			for (auto j : edge[cn]) {
				QQ.push({ j,cc - 1 });
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		if (num[i][0] >= 0)cout << num[i][0] << endl;
		else cout << "0\n";
	}
	return 0;
}



Measured memory_bytes: 18728
#include <iostream>
using namespace std;
int main()
{
    int a, b, temp, i;
    for(i=1; i<=3000; i++)
  { 
     cin >> a >> b;
    
    
    if(a==0 && b==0)
       break;
    
    
    if(a > b)
    {
    temp = a;
    a = b;
    b = temp;
    }
    
    cout << a << " " << b << endl;
  }
}


Measured memory_bytes: 2984
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
double A[10],B[10];
int main() {
double N,count=0;
cin >> N;
for (int i = 0; i < 5; ++i){
    cin >> A[i];
}
sort(A,A+5);
double ans;
ans = ceil(N/A[0]);
cout << (int long long)ans + 4 <<endl;

return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int, int> P;
typedef pair<P, int>PP;
const long long inf = 1ll << 61;
struct RMQ {
	int n; vector<int>node2;
	void init(int N) {
		n = 1;
		while (n < N)n *= 2;
		node2.resize(2 * n, inf);
	}

	void update(int x, int a) {
		x += n - 1;
		node2[x] = a;
		while (x > 0) {
			x = (x - 1) / 2;
			node2[x] = min(node2[x * 2 + 1], node2[x * 2 + 2]);
		}
	}
	int query2(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return inf;
		if (a <= l&&r <= b)return node2[k];
		int vl = query2(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query2(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
	int getmin(int a, int b) {
		return query2(a, b, 0, 0, n);
	}
};

const long long mod = 998244353;
int dp1[200006],dp2[200006];
int rmin[200006];
vector<int>ans[200006];
RMQ seg;
signed main() {
	int n, k, c; cin >> n >> k >> c;
	string s; cin >> s;
	int mx = 0;
	rep(i, c) {
		if (s[i] == 'o') {
			dp1[i] = 1;
		}
	}
	for (int i = c; i < n; i++) {
		if (s[i] == 'o') {
			dp1[i] = mx + 1;
		}
		mx = max(mx, dp1[i - c]);
	}
	int M = 0;
	rep(i, n)M = max(M, dp1[i]);
	if (M > k)return 0;
	mx = 0;
	rep(i, c) {
		int j = n - i - 1;
		if (s[j] == 'o') dp2[j] = 1;
	}
	for (int i = c; i < n; i++) {
		int j = n - i - 1;
		if (s[j] == 'o')dp2[j] = mx + 1;
		mx = max(mx, dp2[j + c]);
	}

//	rep(i, n)cout << dp1[i] << ' ' << dp2[i] << endl;
	mx = 0;
	rep(i, n)mx = max(mx, dp1[i] + dp2[i]);
	rep(i, n) {
		if (s[i] == 'o'&&dp1[i] + dp2[i] != mx) {
			dp1[i] = 0;
		}
	}

	rep(i, n) {
		ans[dp1[i]].push_back(i);
	}
	vector<int>res;
	for (int i = 1; i <= n; i++) {
		if (ans[i].size() == 1)res.push_back(ans[i][0]);
	}
	sort(res.begin(), res.end());
	for (int e : res)cout << e+1 << endl;
}

Measured memory_bytes: 19064
import java.util.*;
public class Main{
    public static void main(String args[]) {
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    
    for(int i =0; i<n;i++)
    arr[i] = sc.nextInt();
   
      System.out.println(dpc(arr,n));
      
      
    }
    
    static int min(int[] arr, int n)
    { 
        if(n==1) return 0;
        if(n==2) return Math.abs(arr[n-1]-arr[n-2]);
            int op1 = Math.abs(arr[n-1]-arr[n-2]) +min(arr,n-1);
            int op2 = Math.abs(arr[n-1]-arr[n-3]) +min(arr,n-2);
          int res = Math.min(op1, op2);
          
          return res;
    }
    
    static int dpc(int[] a, int n)
    {
        int[] dp = new int[n];
        
    dp[0]=0;
    dp[1]=Math.abs(a[0]-a[1]);
    for(int i =2;i<n;i++)
    {
             dp[i] = Math.min(Math.abs(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[i - 2]) + dp[i - 2]);

    }
        
        return dp[n-1];
    }
    
}

Measured memory_bytes: 59464
N, K = map(int, input().split())
p = list(map(int, input().split()))

ans, ai = 0, -1
sum = 0
for i in range(N-K+1):
  if i == 0:
    for k in range(K):
      sum += p[i+k]
  else:
    sum = sum - p[i-1] + p[i+k]
  ans = max(ans, sum)
  if ans == sum:
    ai = i

dp = [0]*1001
dp[0] = 0
for i in range(1000):
  dp[i+1] = i+1 + dp[i]

ans = 0.0
for i in range(ai, ai+K):
  ans += dp[p[i]]/p[i]

print(ans)

Measured memory_bytes: 24804
def C_Together():

    try:
        LOCAL_FLAG
        N = 3
        a = [6, 2, 6]
        # N = 4
        # numbers = [2, 5, 5, 2]
        N = 6
        a = [12, 22, 16, 22, 13, 12]

    except NameError:
        N = int(input())
        a = list(map(int, input().split()))

    counter = {}
    # for i in range(N):
    #     if a[i] in counter:
    #         counter[a[i]] += 1
    #     else:
    #         counter[a[i]] = 1
    #
    # print(counter)
    #
    # results = 0
    # key = -1
    #
    # for k, v in counter.items():
    #     temp = v
    #     if k-1 in counter:
    #         temp += counter[k-1]
    #     if k+1 in counter:
    #         temp += counter[k+1]
    #     if(temp > results):
    #         results = temp
    #         key = k
    for i in range(N):
        counter[a[i]] = counter.get(a[i], 0) + 1

    # print(counter)

    results = 0
    key = -1

    for k, v in counter.items():
        temp = v + counter.get(k-1, 0) + counter.get(k+1, 0)
        if(temp > results):
            results = temp
            key = k

    print(results)
    


C_Together()

Measured memory_bytes: 14300
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<bitset>
#include<deque>
#include<cstdlib>
#include<set>
#include<ctime>
#define ll long long
#define mp make_pair
using namespace std;
ll read()
{
	ll x=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return f*x;
}
int n,k,a[51],sum,st[51],top,num[51],as[5000],cnt,tt[51]; 
bool flag;
bool cmp(int x,int y)
{
	return num[x]>num[y];
}
int main()
{
	n=read(),k=read();
//	if(n==1) while(1);
	for(int i=1;i<=n;++i)
	{
		int x=a[i]=read();
		if(x<k+1)
		{
			int tmp=k+1-x;
			if(tmp*2>k+1) flag=1;
			sum+=tmp;
			st[++top]=i;
			num[i]=tmp;
		}
	}
///	flag=1;
	if(sum>k) flag=1;
	if(flag) cout<<-1;
	else 
	{
		int lst=0,end;
		for(int i=1;i<=k;++i)
		{
			sort(st+1,st+1+top,cmp);
			if(lst==st[1])
			{
				end=st[2];
				num[st[2]]--;
			 } 
			 else
			 {
			 	end=st[1],num[st[1]]--;
			 }
			 if(!end) end=lst%n+1;
			 if(i==1) lst=end%n+1,as[++cnt]=lst;
			 for(int j=1;j<=n;++j) if(j!=lst&&j!=end) as[++cnt]=j;
			 as[++cnt]=end;
			 if(lst>n||lst==end||lst<1||end>n||end<1) while(1);
			 lst=end;
		//	 cout<<i<<" "<<end<<'\n';
		}
		for(int i=1;i<=n;++i) if(i!=lst) as[++cnt]=i;
		cout<<cnt<<'\n';
		for(int i=1;i<=cnt;++i) cout<<as[i]<<" ",tt[as[i]]++;
		for(int i=1;i<=n;++i) if(tt[i]>a[i]) while(1);
	 } 
	return 0;
 }


Measured memory_bytes: 384
import sys
N = input()
if len(N) == 1:
    print(N)
    sys.exit()

s = 0
for x in N:
    s += int(x)

if N[0] != '9' and '9'*(len(N)-1) == N[1:]:
    print(s)
elif N[0] != '9':
    print((int(N[0])-1) + 9*(len(N)-1))
elif '9'*len(N) == N:
    print(s)
else:
    print((int(N[0])-1) + 9*(len(N)-1))

Measured memory_bytes: 3064
import math
import sys
#input = sys.stdin.readline
ac,wa,tle,re=0,0,0,0
for _ in range(int(input())):
  verd = input()
  if verd == 'AC':
    ac += 1
  elif verd == 'WA':
    wa += 1
  elif verd == 'RE':
    re += 1
  elif verd == 'TLE':
    tle += 1
print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int n, a, ans;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){scanf("%d",&a);ans += a - 1;}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	int N;
	int s[110];
	int dp[110][10010];//dp[i][j]でi回目の操作の時に和がjとなりえるか
	cin >> N;
	for (int i = 0; i < N; ++i)cin >> s[i];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= 10000; ++j) {
			if (dp[i][j] == 0)continue;
			dp[i + 1][j] = 1;
			dp[i + 1][j + s[i]] = 1;
		}
	}
	int ans = 0;
	for (int i = 0; i <= 10000; ++i) {
		if (dp[N][i] == 1) {
			if (i % 10 != 0) {
				ans = max(ans, i);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL N;
  cin >> N;
  LL lim = 100;
  VEC<LL> x(N), y(N), h(N);
  int base;
  REP(i, 0, N) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] > 0) base = i;
  }
  REPC(i, 0, lim) {
    REPC(j, 0, lim) {
      int height = abs(i - x[base]) + abs(j - y[base]) + h[base];
      bool ok = 1;
      REP(k, 0, N) {
        int sh = max(height - abs(i - x[k]) - abs(j - y[k]), 0LL);
        if (sh != h[k]) ok = 0;
      }
      if(ok){
          cout<<i<<" "<<j<<" "<<height<<endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>

using namespace std;

int main() {
	int n;
	string a, b, c;
	cin >> n;
	cin >> a >> b >> c;

	int ans = 0;
	set<char> check;
	for (int i = 0; i < n; i++) {
		check.clear();
		check.insert(a[i]);
		check.insert(b[i]);
		check.insert(c[i]);

		switch (check.size()) {
			case 1: break;
			case 2: ans += 1; break;
			case 3: ans += 2; break;
			default: break;
		}
	}

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int c=0;
	for(int i=0;i<n-2;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			c++;
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

int main(void){
  ll a1,a2,work;
  char work1[4];
  cin >> work >> work1;
  char work2[4] = {work1[0],work1[2],work1[3],'\0'};
  //cout << work2 << endl;
  a1 = work/10000;
  a2 = work%10000;
  ll b = atoi(work2);
  //cout << b << endl;
  a1 = a1*b*100;
  a2 = a2*b/100;
  ll ans = a1+a2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
import math
n,m = map(int,input().split())
num = 1
if n==m:
  for i in range(1,n+1):
    num *= i
    num = num%(10**9+7)
  print((num*num*2)%(10**9+7))
elif abs(n-m)==1:
  print(int(math.factorial(n)*math.factorial(m)%(10**9+7)))
else:
  print(0)

Measured memory_bytes: 5172
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    char[] c=sc.next().toCharArray();
    Arrays.sort(c);
    String s=String.valueOf(c);
    if(s.equals("abc")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22740
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
using namespace std;

int main() {
  int N;
  cin>>N;
  
  vector<int> w(N);
  for(int i=0;i<N;++i){
    cin>>w[i];
  }
  
  int ans=10000;
  
  for(int i=1;i<N;++i){
    int sum1=0;
    int sum2=0;
    
    for(int j=0;j<i;++j){
      sum1+=w[j];
    }
    
    for(int j=i;j<N;++j){
      sum2+=w[j];
    }
    
    int z=abs(sum1-sum2);
    ans=min(ans,z);
    
  }
  
  cout<<ans<<endl;
  
}


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

using namespace std;

int main(void)
{
	int n, r;
	while(cin >> n >> r && n > 0){
		vector<int> card(n);
		//cardを初期化
		for(int i=0;i<n;i++){
			card[i] = n-i;
		}
		for(int i=0;i<r;i++){
			int p, c;
			cin >> p >> c;
			rotate(card.begin(), card.begin()+p-1, card.begin()+p+c-1);
		}
		cout << card[0] << endl;
	}
	return 0;
}


Measured memory_bytes: 3112
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " << a << endl;
ll XORtill(ll n)
{
	if (n % 4 == 0)
	{
		return n;
	}
	else if (n % 4 == 1)
	{
		return 1;
	}
	else if (n % 4 == 2)
	{
		return n + 1;
	}
	else return 0;
}
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	ll l, r;
	cin >> l >> r;
	ll x = XORtill(l - 1);
	ll y = XORtill(r);
	ll z = x ^ y;
	cout << z;
	return 0;
}

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

int main(){
  ll a,b,x;
  cin>>a>>b>>x;
  if(a==0) cout<<b/x+1<<endl;
  else cout<<b/x-(a-1)/x<<endl;
  return 0;
}

Measured memory_bytes: 256
N, C = map(int, input().split())
items = []
for i in range(N):
    items.append(tuple(map(int, input().split())))

times = [0] * 2 * (10 ** 5 + 1)
channel = [[0] * 2 * (10 ** 5 + 1) for _ in range(C)]
for i in range(N):
    s, t, c = items[i]
    c -= 1
    channel[c][2 * s - 1] += 1
    channel[c][2 * t] -= 1

for c in range(C):
    for i in range(len(times) - 1):
        channel[c][i + 1] += channel[c][i]
        if channel[c][i + 1] >= 1:
            times[i + 1] += 1

print(max(times))


Measured memory_bytes: 110296
using System;
using System.IO;

class Solve
{
    static void Main(string[] args) {
        var M = int.Parse(Console.ReadLine().Split()[1]);
        var lMax = 0;
        var rMin = 100000;
        for (int i = 0; i < M; i++) {
            var L = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            lMax = Math.Max(lMax, L[0]);
            rMin = Math.Min(rMin, L[1]);
            if (lMax > rMin) break;
        }
        var answer = lMax <= rMin ? rMin - lMax + 1 : 0;
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

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

int main(){
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);
    int max = A.at(0) + (K - A.at(N-1));
    int t;
    for(int i=0; i<(N-1); i++){
        t = A.at(i+1) - A.at(i);
        if(t > max) max = t;
    }
    cout << (K - max) << endl;
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

int main(int argc, char *argv[]){
    int N;
    std::cin >> N;
    for(int i=1; i<10; ++i){
        if(N%i==0 && N/i < 10){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

    int Q;
    cin >> Q;

    deque<char> que;
    for (auto c : S) {
        que.push_back(c);
    }

    int dir = 1;

    for (int i = 0; i < Q; i++) {
        int q;
        cin >> q;
        if (q == 1) {
            dir *= -1;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                if (dir == 1) {
                    que.push_front(c);
                } else {
                    que.push_back(c);
                }
            } else {
                if (dir == 1) {
                    que.push_back(c);
                } else {
                    que.push_front(c);
                }
            }
        }
    }

    if (dir == -1) {
        reverse(que.begin(), que.end());
    }

    while (!que.empty()) {
        cout << que.front();
        que.pop_front();
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4036
def d_AnInvisibleHand(N, T, A):
    min_value = A[0]  # 高橋君はA[j]=min_valueとなる町でリンゴを仕入れる
    max_profit = 0  # 利益の最大値
    ans = 0  # 青木君が費やさねばならないコスト
    for i in range(1, N):
        profit = A[i] - min_value  # 町iでリンゴを売ったときの利益
        if profit > max_profit:
            # 利益が最大値を更新した。青木君はA[i]を1下げるかA[j]==min_valueとなる
            # 町jについてA[j]を1上げればいいので、ans=1とする
            max_profit = profit
            ans = 1
        elif profit == max_profit:
            # A[i]は相異なるので、コスト1で2対以上の売買する町のペアに影響を与えることができない
            # ex. 10,20,(11~19),20なら、20の町より10の町にコストを掛けるほうがよい
            ans += 1
        min_value = min(min_value, A[i])
    return ans

N,T = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(d_AnInvisibleHand(N, T, A))

Measured memory_bytes: 14252
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int N;
int a[100010];
int g[1000];
int w=0;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(){
    cin>>N;
    w=round(sqrt(N));
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    int c=0;
    int size=0;
    int nowGCD=a[0];
    for(int i=0;i<N;i++){
         if(c>=w){
            c=0;
            g[size++]=nowGCD;
            nowGCD=a[i];
        }
        nowGCD=gcd(a[i],nowGCD);
        c++;
    }
    g[size++]=nowGCD;
    for(int i=0;i<size;i++){
     //   cout<<g[i]<<" ";
    }//cout<<endl;
    int ans=0;
    for(int i=0;i<N;i++){
        int gc = i==0 ? a[1]:a[0];
        for(int j=0;j<i/w;j++){
            gc=gcd(g[j],gc);
        }
        for(int j=(i/w)*w;j<(i/w+1)*w;j++){
            if(j!=i){
                gc=gcd(gc,a[j]);
                //cout<<a[j]<<" ";
            }
        }//cout<<endl;
        for(int j=i/w+1;j<size;j++){
            gc=gcd(g[j],gc);
        }
        ans=max(ans,gc);
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

struct UnionFind{
    vector<int> par;
    int count;
    UnionFind(int n) : par(n, -1), count(0){}
    int Find(int x){return par[x] < 0 ? x : Find(par[x]);}
    int Size(int x){return par[x] < 0 ? -par[x] : Size(par[x]);}
    bool Unite(int x, int y){
        x = Find(x);
        y = Find(y);
        if(x == y)
            return false;
        if(par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return ++count;
    }
};



signed main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    vector<int> pos(n, -1);
    for(int i = 0; i < m; ++i){
        cin >> a[i] >> b[i];
        --a[i], --b[i];
        chmax(pos[b[i]], a[i]);
    }
    int ma = 0;
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        if(ma <= pos[i]){
            ma = i;
            ++cnt;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4580
#RGBboxes
R, G, B, N = map(int, input().split())
dp = [0] * (6001)
dp[R] = 1
for i in range(N+1):
    dp[i + R] += dp[i]
# print(dp[:5])
dp[G] += 1
for i in range(N+1):
    dp[i + G] += dp[i]
# print(dp[:5])
dp[B] += 1
for i in range(N+1):
    dp[i + B] += dp[i]
# print(dp[:5])
print(dp[N])

Measured memory_bytes: 39108
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main() {
int N;
cin>>N;
int A[N+1];
map<int,ll> map;
rep3(i,N){
  cin>>A[i];
  map[A[i]]++;
}
ll basesum=0;
rep3(i,N){
  basesum+=map[i]*(map[i]-1)/2;
}
ll ans[N+1];
rep3(i,N){
  ans[i]=basesum-map[A[i]]*(map[A[i]]-1)/2+(map[A[i]]-1)*(map[A[i]]-2)/2;
}
rep3(i,N){
  cout<<ans[i]<<endl;
}



return 0;
}

Measured memory_bytes: 18492
#include<iostream>
using namespace std;
#define inRange(x,a,b) (a <= x && x <= b)

void f(int &score, string &s, bool &eleven){
    int ace = 0;
    score = 0;
    eleven = false;
    for(char c : s){
        if(inRange(c, '2', '9'))    score += c-'0';
        else if(c == 'A')           ace++, score++;
        else                        score += 10;
    }
    while(ace--){
        if(score+10 <= 21)  eleven = true, score += 10;
    }
}

int main(){
    int q;
    cin >> q;
    while(q--){
        char a, b;
        cin >> a >> b;
        string s = "";
        s += a; s += b;
        int score;
        bool ele;
        f(score, s, ele);
        char c[8];
        for(int i = 0; i < 8; i++)  cin >> c[i];
        if(score == 21){
            cout << "blackjack" << endl;
            continue;
        }
        for(int i = 0; i < 8; i++){
            if(score <= 16 || (score==17 && ele)){
                s += c[i];
                f(score, s, ele);
            }else{
                break;
            }
        }
        if(score > 21)  cout << "bust" << endl;
        else            cout << score << endl;
    }
    return 0;
}


Measured memory_bytes: 3144
def itti(S, T):
    ans = 0
    for i in range(len(S)):
        if S[i] == T[i]:
            ans += 1
    return ans

# print('input >>')
S = input()
T = input()

ans = 0
for i in range(len(S)-len(T)+1):
    ans = max(ans, itti(S[i: i+len(T)], T))

# print('-----output-----')
print(len(T)-ans)

Measured memory_bytes: 9056
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

const INF = 0x7FFFFFFF

var pass [][]int

func main() {
	for scanner.Scan() {
		pass = make([][]int, 200)
		for i := range pass {
			pass[i] = make([]int, 200)
		}
		buf := strings.Split(scanner.Text(), " ")
		c, _ := strconv.Atoi(buf[0])
		n, _ := strconv.Atoi(buf[1])
		m, _ := strconv.Atoi(buf[2])
		s, _ := strconv.Atoi(buf[3])
		d, _ := strconv.Atoi(buf[4])
		if c == 0 && n == 0 && m == 0 && s == 0 && d == 0 {
			break
		}
		s--
		d--
		for i := 0; i < 200; i++ {
			for j := 0; j < 200; j++ {
				pass[i][j] = INF
			}
		}
		for i := 0; i < 200; i++ {
			pass[i][i] = 0
		}
		for i := 0; i < m; i++ {
			scanner.Scan()
			buf_ := strings.Split(scanner.Text(), " ")
			a, _ := strconv.Atoi(buf_[0])
			b, _ := strconv.Atoi(buf_[1])
			f, _ := strconv.Atoi(buf_[2])
			a--
			b--
			pass[a][b] = f
			pass[b][a] = f
		}
		fmt.Println(dijkstra(s, d, c, n))
	}
}

func dijkstra(s, g, c, n int) float64 {
	d := make([][]float64, 200)
	used := make([][]bool, 200)
	for i := 0; i < 200; i++ {
		d[i] = make([]float64, 20)
		used[i] = make([]bool, 20)
	}
	for i := range d {
		for j := range d[i] {
			d[i][j] = INF
		}
	}
	d[s][c] = 0
	for {
		v := -1
		w := -1
		for u := 0; u < n; u++ {
			for i := 0; i < c+1; i++ {
				if !used[u][i] && (v == -1 || d[u][i] < d[v][w]) {
					v = u
					w = i
				}
			}
		}
		if v == -1 {
			break
		}
		used[v][w] = true
		for u := 0; u < n; u++ {
			d[u][w] = math.Min(d[u][w], d[v][w]+float64(pass[v][u]))
			if w-1 >= 0 && pass[v][u] != INF {
				d[u][w-1] = math.Min(d[u][w-1], d[v][w]+(float64(pass[v][u]/2.0)))
			}
		}
	}
	ret := float64(INF)
	for i := 0; i < c+1; i++ {
		ret = math.Min(ret, d[g][i])
	}
	return ret
}



Measured memory_bytes: 6060
def gcd(a, b):
    if (a == 0):
        return b
    return gcd(b%a, a)

def lcm(a, b):
    return (a*b)//gcd(a, b)
    
n = int(input())

numbers = list(map(int, input().split()))

l = numbers[0]
for i in range(1, n):
    l = lcm(l, numbers[i])

ans = 0

for i in range(n):
    ans += l//numbers[i]

MOD = 1000000007
print(ans%MOD)


Measured memory_bytes: 10088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int q = Integer.parseInt(br.readLine());
      StringBuilder buf  = new StringBuilder();

      for(int i=0; i<q; i++) {
        buf.append( deriveLcs(br.readLine(), br.readLine()) )
           .append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }

  private int deriveLcs(String seqX, String seqY) {
    int m = seqX.length();
    int n = seqY.length();
    int[][] subSeq = new int[m+1][n+1];
    int maxSubSeq = 0;

    for(int i=1; i<=m; i++) subSeq[i][0] = 0;
    for(int j=1; j<=n; j++) subSeq[0][j] = 0;

    for(int i=1; i<=m; i++) {
      for(int j=1; j<=n; j++) {
        if(seqX.charAt(i-1) == seqY.charAt(j-1))
          subSeq[i][j] = subSeq[i-1][j-1] + 1;
        else
          subSeq[i][j] = Math.max(subSeq[i-1][j], subSeq[i][j-1]);

        maxSubSeq = Math.max(maxSubSeq, subSeq[i][j]);
      }
    }

    return maxSubSeq;
  }
}


Measured memory_bytes: 64308
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l;
ll num,ans,sum,ok,ng;
ll x[500005],y[500005],z[500005];
P table[500005];
char s[500005],t[500005],u[500005];
bool dame,flag;

int main(){
	cin >> n >> m;
	for(i=0;i<n-1+m;i++){
		cin >> a >> b;
		G[a].pb(b);
		x[b]++;
	}
	ll root = -1;
	for(i=1;i<=n;i++){
		if(x[i] == 0){
			root = i;
		}
	}
	queue <ll> q;
	q.push(root);
	z[root] = 0;
	ll v;
	while(1){
		if(q.empty())break;
		v = q.front();
		q.pop();
		for(i=0;i<G[v].size();i++){
			x[G[v][i]]--;
			if(x[G[v][i]] == 0){
				z[G[v][i]] = v;
				q.push(G[v][i]);
			}
		}
	}
	for(i=1;i<=n;i++){
		p(z[i]);
	}


	
	
	return 0;
}

Measured memory_bytes: 32000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
string s;
cin>>s;
for (ll i = 0; i < s.size();i+=2){
    cout << s[i];
}
cout << endl;
}

Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#define ll long long

using namespace std;

int main(){
  int N,W;
  int M1,D1;
  int M2,D2;
  cin >> M1 >> D1;
  cin >> M2 >> D2;
  if( M1 != M2 ) cout << "1" << endl;
  else cout << "0" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



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



Measured memory_bytes: 256
//	-*- mode: C++ -*-
//	Triangle
//
//		For given two sides of a triangle a and b and the angle C between them, calculate the following properties:
//
//		S: Area of the triangle
//		L: The length of the circumference of the triangle
//		h: The height of the triangle with side a as a bottom edge
//	Input
//		The length of a, the length of b and the angle C are given in integers.
//
//	Output
//		Print S, L and h in a line respectively. The output should not contain an absolute error greater than 10-4.
//
//	Sample Input
//		4 3 90
//	Sample Output
//		6.00000000
//		12.00000000
//		3.00000000

#include <iostream>
#include <iomanip>
#define	_USE_MATH_DEFINES
#include <cmath>

int	main(int	argc,
		 char*	argv[])
{
	unsigned int	a	{0};
	unsigned int	b	{0};
	unsigned int	C	{0};

	std::cin >> a >> b >> C;

	double	S	= static_cast<double>((a * b * sin(static_cast<double>((C * M_PI) / 180))) / 2);
	double	h	= static_cast<double>(static_cast<double>(b) * (sin(static_cast<double>((C * M_PI) / 180))));

	double	c	= sqrt((a * a) + (b * b) - ((2 * a * b) * cos(static_cast<double>((C * M_PI) / 180))));

	std::cout << std::fixed << std::setprecision(6) << S << '\n';
	std::cout << a + b + c << '\n';
	std::cout << h << '\n';
    return 0;
}



Measured memory_bytes: 3568
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        final List<Route> routes = new ArrayList<>();
        
        for(int i = 0; i < 3 ; i++) {
            final int a = sc.nextInt();
            final int b = sc.nextInt();
            routes.add(new Route(a, b));
        }
        Collections.sort(routes);
        
        boolean[] record = {false, false, false, false};
        
        int endpoint = routes.get(0).getA();
        
        while(0 < routes.size()) {
            for(int i = 0; i < routes.size() ; i++) {
                final Route route = routes.get(i);
                if (route.getA() == endpoint || route.getB() == endpoint) {
                    record[route.getA() - 1] = true;
                    record[route.getB() - 1] = true;
                    endpoint = (route.getB() + route.getA()) - endpoint;
                    routes.remove(i);
                    break;
                }
                if (routes.size() -1 == i) {
                    System.out.println("NO");
                    return;
                }
            }
        }
        
        for(boolean b : record) {
            if(!b) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
        
    }
    
    static class Route implements Comparable<Route> {
        private int a;
        private int b;
        
        public Route(final int a, final int b) {
            this.a = a < b ? a : b;
            this.b = (a + b) - this.a;
        }
        
        int getA() {
            return this.a;
        }
        
        int getB() {
            return this.b;
        }
        
        @Override
        public int compareTo(Route otherRoute) {
            return (this.getA() - otherRoute.getA());
        }
    }
}


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


int main() {
    string S;
    cin >> S;
    int A_num = 0;
    int BC_num = 0;
    int search_stat = 0;
    ll ans = 0;
    int i =0;
    while (i < S.size()) {
        if (search_stat == 0) {
            if (S[i] == 'A') {
                i++;
                A_num++;
            }
            else if (S[i] == 'B') {
                search_stat = 1;
            }
            else if (S[i] == 'C') {
                i++;
                A_num = 0;
            }
        }
        if (i >= S.size()) break;
        if (search_stat == 1) {
            if (S[i] == 'B'  && S[i+ 1] == 'C') {
                BC_num++;
                i += 2;
                if (i >= S.size()) {
                    ans += ll(A_num) * ll(BC_num);
                }
            }
            else {
                ans += ll(A_num) * ll(BC_num);
                search_stat = 0;
                BC_num = 0;
                if (S[i] == 'A') {
                    A_num++;
                }
                else {
                    A_num = 0;
                }
                i++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1001;
long long a[maxn];
long long n,m; 

int main(){
	while(scanf("%d%d",&n,&m)==2&&n!=0&&m!=0){
		for(int i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		long long tot=0,ans=-1;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j) continue;
				tot = a[i]+a[j];
				if(tot<=m&&tot>ans){
					ans=tot;
				}
			}
		}
		if(ans>=0)printf("%d\n",ans);
		else printf("NONE\n");
	}
} 

/*
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
*/


Measured memory_bytes: 3196