akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
int INF = 100000;
int main(){
  int N;
  cin >> N;
  int s[N];
  int ans = 0;
  int minpoint = INF;
  for(int i=0;i<N;i++){
    cin >> s[i];
    ans += s[i];
    if(s[i]%10!=0) minpoint = min(minpoint,s[i]);
  }

  if(ans%10==0){
    if(minpoint!=INF){
      ans -= minpoint;  
    }else{
      ans = 0;
    }  
  }

  cout << ans <<endl;

  return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
   unordered_set <string> s;
   string s1;
   int n;
   cin>>n;
   for(int i=0;i<n;++i)
   {
       cin>>s1;
       s.insert(s1);
   }
   cout<<s.size();
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		Arrays.sort(a);
		reverse(a);

		long ans = a[0];
		int n2 = n / 2;
		for (int i = 1; i < n2; i++) {
			ans += a[i] * 2;
		}
		if (n % 2 == 1) {
			ans += a[n2];
		}
		System.out.println(ans);
	}

	static void reverse(int[] a) {
		for (int i = 0; i < a.length / 2; i++) {
			int tmp = a[i];
			a[i] = a[a.length - 1 - i];
			a[a.length - 1 - i] = tmp;
		}
	}
}


Measured memory_bytes: 59960
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[101],flag,ans;
int main()
{
	cin>>n>>a[1];
	flag=1;
	for (int i=2;i<=n;i++)
	{
		cin>>a[i];
		if (a[i]==a[i-1]) flag++;
		    else
			{
				ans+=flag/2;
				flag=1;
			}
	}
	ans+=flag/2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
# A: 0.08 tax, B: 0.10 tax
A, B = list(map(int, input().split()))

# find candidate prices
candidate_prices = [(B * 10) + i for i in range(0, 9)]

# find minimum possible price
min_price = -1
for p in candidate_prices:
    if int(p * (0.08)) == A:
        min_price = p
        break

print(min_price)

Measured memory_bytes: 3060
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long

using namespace std;

int main(void)
{
    char a[200010];
    int n,i,j;
    while(scanf("%s",a)==1)
    {
        n = strlen(a);
        int s,e;
        for(i=0;i<n;i++)
        {
            if(a[i] == 'A')
            {
                s = i;
                break;
            }
        }
        for(i=n-1;i>=0;i--)
        {
            if(a[i] == 'Z')
            {
                e = i;
                break;
            }
        }
        printf("%d\n",e-s+1);
    }
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

struct Node
{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node *find(Node *u, int k)
{
    while (u != NIL && k != u->key)
    {
        if (k < u->key)
            u = u->left;
        else
            u = u->right;
    }
    return u;
}

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL)
    {
        root = z;
    }
    else
    {
        if (z->key < y->key)
        {
            y->left = z;
        }
        else
        {
            y->right = z;
        }
    }
}

void inorder(Node *u)
{
    if (u == NIL)
        return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u)
{
    if (u == NIL)
        return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}
int main()
{
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        cin >> com;
        if (com[0] == 'f')
        {
            scanf("%d", &x);
            Node *t = find(root, x);
            if (t != NIL)
                printf("yes\n");
            else
                printf("no\n");
        }
        else if (com == "insert")
        {
            scanf("%d", &x);
            insert(x);
        }
        else if (com == "print")
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 22088
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
int cmp(const void *a,const void *b){
	return *(int*)a-*(int*)b;
}
int main(void){
	int n,i,p[10],b;
	char c[101];
	while(scanf("%d",&n),n){
		scanf("%s",c);
		b=0;
		memset(p,0,sizeof(p));
		for(i=0;i<100;i++){
			p[i%n]++;
			if(c[i]=='L'){
				p[i%n]+=b;
				b=0;
			}
			else if(c[i]=='S'){
				b+=p[i%n];
				p[i%n]=0;
			}
		}
		qsort(p,n,sizeof(int),cmp);
		for(i=0;i<n;i++){
			printf("%d ",p[i]);
		}
		printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 608
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int UF[110000];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;
	UF[a]+=UF[b];UF[b]=a;
}
int p[110000];
int q[110000];
int r[110000];

int main(){
	int a;
	scanf("%d",&a);
	long long b;scanf("%lld",&b);
	int c;scanf("%d",&c);
	for(int i=0;i<a;i++)UF[i]=-1;
	for(int i=0;i<c;i++){
		scanf("%d%d%d",p+i,q+i,r+i);
		if(p[i]>q[i])swap(p[i],q[i]);
		if(r[i]==0)UNION(p[i],q[i]);
	}
	int fl=0;
	for(int i=0;i<c;i++){
		if(r[i])fl=1;
		if(r[i]==1&&FIND(p[i])==FIND(q[i])){
			printf("No\n");return 0;
		}
	}
	int sz=0;
	for(int i=0;i<a;i++)if(UF[i]<0)sz++;
	long long L=a-1;
	if(fl){
		L++;
		if(sz<=2){
			printf("No\n");return 0;
		}
	}
	long long R=0;
	if(sz<=2){
		R=a-1;
	}else{
		R=a-sz+(long long)sz*(sz-1)/2;
	}
	if(b<L||R<b)printf("No\n");else printf("Yes\n");
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9+7;
#define PI 3.1415926535
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
const int siz = 2*(1e6 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
vector<int> vt;
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}


void sieve()
{
	int cnt = 0;
	prime[1] = prime[0] = 1;

	for(int i = 2 ; i < siz ; i++)
	{
		if(prime[i] != 1)
		{
			cnt++;
			for(int j = 2*i ; j < siz ; j+= i)
			{
				prime[j] = 1;
			}
		}
	}

	cout<<cnt<<"\n";
	
	


}



signed main()
{
	
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{
		int x,y,z;
		cin>>x>>y>>z;
		swap(x,y);
		swap(x,z);
		cout<<x<<" "<<y<<" "<<z<<"\n";
	}
}

Measured memory_bytes: 256
#coding:UTF8
count = int(input())
s = input()
num_list = s.split(" ")
new_num_list = []
for i in range(count):
  work = int(num_list[i])
  work_count = 0
  while work%2 == 0:
    work_count = work_count+1
    work = work//2
  new_num_list.append(work_count)
new_num_list.sort()
print(new_num_list[0])

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

using namespace std;

char s[200000][11];
int ix[200000];

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

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

    for (int gap = n/2; gap > 0; gap /= 2)
    {
        for (int i = gap; i < n; ++i)
        {
            for (int j = i -gap; j >= 0 && strcmp(s[ix[j]], s[ix[j+gap]]) < 0; j -= gap)
            {
                swap(ix[j], ix[j+gap]);
            }
        }
    }

    int ans = 1;
    for (int i = 1; i < n; ++i)
    {
        if (strcmp(s[ix[i]], s[ix[i-1]]) != 0)
        {
            ans++;
        }
    }

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


Measured memory_bytes: 6560
void main(){
	int d = _scan();
	switch(d){
		case 22: writeln("Christmas Eve Eve Eve"); break;
		case 23: writeln("Christmas Eve Eve"); break;
		case 24: writeln("Christmas Eve"); break;
		default:writeln("Christmas"); break;
	}
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2636
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC optimize("Ofast","-funroll-loops","-fdelete-null-pointer-checks")
#pragma GCC target("ssse3","sse3","sse2","sse","avx2","avx")
using namespace std;
#define ll long long
//#define fo(i,n) for(int i=(b);i<n;i++)
#define pii pair<int,int>
#define mci map<char,int>
#define mii map<int,int>
#define vi vector<int>
const ll INF=1e9+7;
double PI=acos(-1);
ll get_ans(ll n){
	ll ans=1;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			ans+=2;
			if(n/i==i)ans--;	
		}
	}
	return ans;
}
ll another(ll n){
	ll ans=1,tmp2;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			ll tmp=n/i;
			tmp2=n;
			while(tmp2%i==0)tmp2/=i;
			if(tmp2>i)tmp2%=i;
			ans+=(tmp2==1);
			if(tmp!=i){
				tmp2=n;
				while(tmp2%tmp==0)tmp2/=tmp;
				if(tmp2>i)tmp2%=tmp;
				ans+=(tmp2==1);
			} 
		}
		
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll n;
	cin>>n;
	if(n==2){
		cout<<1;
		return 0;
	}
	cout<<another(n)+get_ans(n-1);
	return 0;
}
 

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

//int AtCoderAGC012A( int argc, char *argv[] )
int main( int argc, char *argv[] )
{
int i;
int N;
int iVal;
long long iSum;
vector<int> V;

	// N を取得
	scanf( "%d", &N );

	// 参加者の強さを取得
	for( i = 0; i < N * 3; i++ )
	{
		scanf( "%d", &iVal );
		V.push_back( iVal );
	}

	// ソート
	sort( V.begin(), V.end() );

	// N 組のチームの強さの和としてありうる値のうち、
	// 最大の値を求める
	iSum = 0;
	for( i = 0; i < N; i++ ) iSum += V[ i * 2 + N ];

	// 出力
	cout << iSum << endl;

	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
	
ll mod = 1e9 + 7;
 
int main(){
	ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    string s; cin >> s;
    s.push_back('.');
    a--;b--;c--;d--;
    for(ll i = a; i < c; ++i){
        if(s[i] == '#' && s[i + 1] == '#'){
            cout << "No";
            return 0;
        }
    }
    for(ll i = b; i < d; ++i){
        if(s[i] == '#' && s[i + 1] == '#'){
            cout << "No";
            return 0;
        }
    }
    if(c == d){
        cout << "No";
        return 0;
    }
    if(d > c){
        cout << "Yes";
    }else{
        for(ll i = b; i <= d; ++i){
            if(s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.'){
                cout << "Yes";
                return 0;
            }
        }
        cout <<"No";
    }
    return 0;
}


Measured memory_bytes: 3768
#include <stdio.h>
 
int main(void) {
	int a,b,c;
	scanf("%d" "%d" "%d",&a,&b,&c);
	if(a<b){
		if(b<c){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, q;
    cin >> n >> q;
    fenwick_tree<ll> ft(n);
    rep(i, n) {
        ll a;
        cin >> a;
        ft.add(i, a);
    }
    rep(i, q) {
        ll t, a, b;
        cin >> t >> a >> b;
        if (t == 0) {
            ft.add(a, b);
        }
        else {
            cout << ft.sum(a, b) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8256
# 解説見た
n = int(input())
a = [int(x) for x in input().split()]

ans = []

max_ = max(a)
min_ = min(a)
if max_ * min_ < 0:
    if abs(max_) >= abs(min_):
        ind = a.index(max_)
        for i in range(n):
            if i == ind:
                continue
            ans.append((ind, i))
        a = [a_ + max_ for a_ in a]

    else:
        ind = a.index(min_)
        for i in range(n):
            if i == ind:
                continue
            ans.append((ind, i))
        a = [a_ + min_ for a_ in a]

max_ = max(a)
min_ = min(a)
if min_ >= 0:
    for i in range(n - 1):
        ans.append((i, i + 1))
        a[i + 1] += a[i]
elif max_ <= 0:
    for i in range(n - 1, 0, -1):
        ans.append((i, i - 1))
        a[i - 1] += a[i]

print(len(ans))
for op in ans:
    print(*map(lambda x: x + 1, op))


Measured memory_bytes: 3188
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<string> v(8);
	REP(i, 8)cin >> v[i];
	
	
	REP(t, 10000) {
		int p = -1, q = -1, cmax = -1;
		if (t % 2 == 0) {
			vi m;
			REP(i, 8) {
				REP(j, 8) {
					if (v[i][j] == '.') {
						int c = 0;
						vi s;
						REP(k, 8) {
							int ni = i, nj = j;
							int tmp = 0;

							REP(l, INF) {
								ni += dx[k], nj += dy[k];
								if (ni < 0 || nj < 0 || ni >= 8 || nj >= 8)break;
								if (v[ni][nj] == 'x')tmp++;
								else if (v[ni][nj] == 'o') {
									if (tmp != 0)s.push_back(k);
									c += tmp;
									break;
								}
								else break;

							}
						}
						if (cmax < c) {
							cmax = c, p = i, q = j;
							m = s;
						}
					}
				}
			}
			if (cmax <= 0)continue;
			else {

				v[p][q] = 'o';
				REP(j, m.size()) {
					int ni = p, nj = q;
					REP(i, INF) {
						ni += dx[m[j]], nj += dy[m[j]];
						if (ni >= 0 && nj >= 0 && ni < 8 && nj < 8 && v[ni][nj] == 'x')v[ni][nj] = 'o';
						else break;
					}
				}


			}
		}

		else {
			vi m;
			REP(i, 8) {
				REP(j, 8) {
					if (v[i][j] == '.') {
						int c = 0;
						vi s;
						REP(k, 8) {
							int ni = i, nj = j;
							int tmp = 0;

							REP(l, INF) {
								ni += dx[k], nj += dy[k];
								if (ni < 0 || nj < 0 || ni >= 8 || nj >= 8)break;
								if (v[ni][nj] == 'o')tmp++;
								else if (v[ni][nj] == 'x') {
									if (tmp != 0)s.push_back(k);
									c += tmp;
									break;
								}
								else break;
							}
						}
						if (cmax <= c) {
							cmax = c, p = i, q = j;
							m = s;
						}
					}
				}
			}
			if (cmax <= 0)continue;
			else {

				v[p][q] = 'x';
				REP(j, m.size()) {
					int ni = p, nj = q;
					REP(i, INF) {
						ni += dx[m[j]], nj += dy[m[j]];
						if (ni >= 0 && nj >= 0 && ni < 8 && nj < 8 && v[ni][nj] == 'o')v[ni][nj] = 'x';
						else break;
					}
				}


			}
		}
	}
	REP(i, 8) {
		REP(j, 8) {
			cout << v[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
signed main(){
  long M;
  cin>>M;
  long a[M],b[M];
  for(long i = 0;i<M;i++){
    cin>>a[i]>>b[i];
  }
  long A = 1,B=1;
  long p,q,r;
  for(long i = 0;i<M;i++){
    p = (((A%a[i]) != 0) ? ((A/a[i])+1) : (A/a[i]));
    q = (((B%b[i]) != 0) ? ((B/b[i])+1) : (B/b[i])); 
    r = max(p,q);
    A = a[i]*r;
    B = b[i]*r;
  }
  cout << A+B << endl;
  return 0;
}

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

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;

        char[] input = new char[10];
        int[] number = new int[10];
        while ((line = br.readLine()) != null) {
            input = line.toCharArray();
            for (int i = 0; i < 10; i++) {
                number[i] = (int) (input[i] - '0');
            }

            for (int i = 0; i < 9; i++) {
                for (int j = 1; j < 10 - i; j++) {
                    number[j - 1] = (number[j - 1] + number[j]) % 10;
                }
            }

            System.out.println(number[0]);
        }
    }
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  string S,T;
  cin >> S >> T;
    
  int ans = 0;
  rep(i,3){
    if(S.at(i) == T.at(i)) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MAX 100
int data[MAX];

int main(){
  int n, m, q, d, res, mx;
  while(cin>> n >> q && n && q){
    for(int i=0;i<MAX;i++){
       data[i] = 0;
    }
    for(int i=0;i<n;i++){
      cin>> m;
      for(int j=0;j<m;j++){
        cin >> d;
        data[d]++;
      }
    }
    res = mx = 0;
    for(int i=0;i < MAX;i++){
      if( res < data[i]){
        res = data[i];
        mx = i;
      }
    }
    if(res < q){
      cout << 0 << endl;
    }else{
      cout << mx << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
N,A,B = list(map(int,input().split()))
S = list(input())
listB = []
cnt = 0
for s in S:
    if s == 'a':
        if cnt < A+B:
            print('Yes')
            cnt += 1
        else:
            print('No')
    elif s == 'b':
        if cnt < A+B and len(listB)+1 <= B:
            print('Yes')
            cnt += 1
            listB.append('b')
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 5224
//2017-12-23
//miaomiao
//
#include <bits/stdc++.h>
using namespace std;
 
#define LL long long
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
 
#define M 30
#define N (200000+5)
 
const int oo = 0x3f3f3f3f;
 
struct node{
	int pn, pos[N], l, r;
}ch[M];
 
char s[N];
int n, tot[M];
bool del[N];
 
LL c1[N], c2[N];
 
int lowbit(int x){
    return x & (-x);
}
 
void Add(int x, int ad){
    if(x) for(int i = x; i <= n; i += lowbit(i)){
            c1[i]+=ad, c2[i]+=1ll*ad*x;
    }
}
 
LL Sum(int x){
    LL ret = 0;
    for(int i = x; i; i -= lowbit(i))
        ret += 1ll*(x+1)*c1[i] - c2[i];
    return ret;
}
 
void Put(int nl, int nr, int ad){
    Add(nl, ad); Add(nr+1, -ad);
}
 
LL Work(int ql, int qr){
	if(ql > qr) swap(ql, qr);
	return Sum(qr) - Sum(ql-1);
}
 
LL Calc(int o, int lr, int aim){
	if(ch[o].l >= ch[o].r) return oo;
	
	int l = ch[o].l, r = ch[o].r;
	int np = lr? ch[o].pos[r]: ch[o].pos[l];

//	printf("o = %c aim = %d np = %d\n", o+'a', aim, np);
	return 1ll*abs(aim - np) - Work(np+(lr? 1: -1), aim);	
}
 
void Work(int o){
	int p1 = ch[o].pos[ch[o].l], p2 = ch[o].pos[ch[o].r];
	del[p1] = del[p2] = true;
	Put(p1, p1, 1); Put(p2, p2, 1);
//	printf("Del p1 = %d p2 = %d\n", p1, p2);
	++ch[o].l; --ch[o].r;
}
 
int main(){
	scanf("%s", s+1);
	n = strlen(s+1);
 
	For(i, 1, n) ++tot[s[i]-'a'];
 
	int ttt = 0;
	For(i, 0, 25) if(tot[i] & 1){
		++ttt;
		if(ttt == 1) continue;
		puts("-1"); return 0;
	}
 
	int nc;
	For(i, 1, n){
		nc = s[i] - 'a';
		ch[nc].pos[++ch[nc].pn] = i;
	}
	For(i, 0, 25) ch[i].l = 1, ch[i].r = ch[i].pn;
	
	int L = 1, R = n, cc1, cc2;
	LL ans = 0;

	while(true){
		while(L <= n && del[L]) ++L;
		while(R >= 1 && del[R]) --R;
		if(L >= R) break;
	
		if(s[L] == s[R]){
			del[L] = del[R] = true;
			Put(L, L, 1); Put(R, R, 1);
			ch[s[L]-'a'].l++; ch[s[R]-'a'].r--;
			continue;
		}
  
		cc1 = s[L]-'a', cc2 = s[R]-'a';
		LL a1 = Calc(cc1, 1, R), a2 = Calc(cc2, 0, L);
	//	printf("(%c) a1 = %d (%c) a2 = %d\n", cc1+'a', a1, cc2+'a', a2);
 
		ans += min(a1, a2);
		if(a1 < a2) Work(cc1); else Work(cc2);

	//	puts("");
	}
 
	printf("%lld\n", ans);
 
	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    string s; cin >> s;
    int n = s.length();

    ll ans = 0;
    ll cnt = 0;
    for (int i = 0; i < n - 2; ++i) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            s[i + 2] = 'A';

            ans += cnt + 1;
            i++;
        } else if (s[i] == 'A') {
            cnt++;
        } else {
            cnt = 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3756
(let ((n (read))
      (m (read)))
  (loop :for i :from 1 :to m
        :for a := (read)
        :for b := (setf n (- n a))
        :while (>= n 0))
  (if (>= n 0)
      (format t "~A~%" n)
      (format t "-1~%")))


Measured memory_bytes: 29520
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;

int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
 	return 0;
}



Measured memory_bytes: 3620
#include <stdio.h> 
int main(void)
{
	int a[3],N,i,w;
	
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	
	for (N=3;N>0;N--)
	{
		for(i=0;i<N-1;i++)
		{
			if(a[i]>a[i+1])
			{
				w=a[i];
				a[i]=a[i+1];
				a[i+1]=w;
			}
		}
	}
	printf("%d %d %d\n",a[0],a[1],a[2]);
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807/2;
const int MOD = 1000000007;
const int N_MAX = pow(10,2);
const int W_MAX = pow(10,5);

int main() {
  string s, t; cin >> s >> t;
  int sl = s.length(), tl = t.length();

  int dp[sl+1][tl+1] = {};
  rep(i, sl) rep(j, tl) {
    if (s[i]==t[j]) dp[i+1][j+1] = dp[i][j] + 1;
    else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
  }


  // rep(i, sl+1) { rep(j, tl+1) { cout << dp[i][j] << " "; } cout << endl; }
  string result = "";
  while (sl!=0&&tl!=0) {
    if (dp[sl][tl] == dp[sl][tl-1]) tl--;
    else if (dp[sl][tl] == dp[sl-1][tl]) sl--; 
    else { result += s[sl-1]; sl--; tl--; }
  }
  reverse(result.begin(), result.end());
  cout << result << endl;
  return 0;
}

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

using namespace std;

class S{
public:
  string s;
  int t;
  S(){}
  S(string s, int t): s(s), t(t) {}
  bool operator < (const S a) const {
    if(s.length() == a.s.length()) return s < a.s;
    return s.length() < a.s.length();
  }
};

main(){
  map<string, int> tmp;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    string s;
    int t;
    cin >> s >> t;
    tmp[s] += t;
  }
  vector<S> ans;
  map<string, int>::iterator ite = tmp.begin();
  while(ite != tmp.end()){
    ans.push_back(S(ite->first, ite->second));
    ite++;
  }
  sort(ans.begin(), ans.end());
  for(int i=0;i<ans.size();i++) cout << ans[i].s << ' ' << ans[i].t << endl;
}

Measured memory_bytes: 1236
import java.util.*;

public class Main {
	
	public static void main(String... args) {
		System.out.println(canTalk(scanInt(), scanInt(), scanInt(), scanInt()) ? "Yes" : "No");
	}
	
	private static boolean canTalk(int a, int b, int c, int d) {
		if (Math.abs(c - a) <= d) {
			return true;
		}
		if (Math.abs(b - a) <= d && Math.abs(c - b) <= d) {
			return true;
		}
		return false;
	}

	
	private static final Scanner SC = new Scanner(System.in);

	private static int scanInt() {
		return SC.nextInt();
	}

	private static  String scanString() {
		return SC.next();
	}
}


Measured memory_bytes: 22868
import java.io.*;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {

        int N = nextInt();
        int C = nextInt();
        int K = nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; ++i) arr[i] = nextInt();

        Arrays.sort(arr);

        int res = 1;
        int first = arr[0];
        int taken = 1;
        for(int i = 1; i < N; ++i) {
            if(arr[i] - first > K  || ((taken + 1 > C))) {
                ++res;
                taken = 1;
                first = arr[i];
            } else {
                ++taken;
            }
        }
        writer.println(res);


    }

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

    BufferedReader reader;
    //    BufferedReader reader2;
    StringTokenizer tokenizer;
    PrintWriter writer;
    //    BufferedWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//            reader = new BufferedReader(new FileReader("highcard.in"));
            //            reader2 = new BufferedReader(new FileReader("1.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
//            writer = new     PrintWriter("output.txt");
//                                                    writer = new BufferedWriter(System.out);
            //                        writer = new BufferedWriter(new OutputStreamWriter(System.out));
            solve();
            reader.close();
            //            reader2.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

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

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

    short nextShort() throws IOException {
        return Short.parseShort(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }

}

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

using namespace std;

int main()
{
  int k;
  string s;
  
  cin >> k;
  cin >> s;
  
  if(k < s.size())
  {
    for(int i = 0; i < k; i++)
    {
      cout << s[i];
    }
    cout << "...";
  }
  else
  {
    cout << s;
  }
  
  return 0;
}

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

int main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    if(d==1)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
long long fact(int x)
{
    if(x==0)
        return 1;
    else
        return x*fact(x-1);
}
long long permu(int x,int r)
{
    return (fact(x)/((fact(x-r))*fact(r)));
}
int main()
{
    fast;
    int n,m;
    long long p,q;
    cin>>n>>m;
    cout<<((n-1)*n)/2+(m*(m-1))/2;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

typedef complex<double> P;
typedef vector<P> G;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-10;
const double INF = 1e12;

// bool cmp_x(const P& p, const P& q) {
//     if (p.real() != q.real()) return p.real() < q.real();
//     return p.imag() < q.imag();
// }

bool cmp_y(const P& p, const P& q) {
    if (p.imag() != q.imag()) return p.imag() < q.imag();
    return p.real() < q.real();
}

double cross(P a, P b) {
    return imag(conj(a) * b);
}

// ????????????????????????????????´???????????????????????¨?????????
G convex_hull(vector<P> ps) {
    int n = ps.size();
    // sort(all(ps), cmp_x);
    sort(all(ps), cmp_y);
    G qs(n * 2);
    int k = 0;
    rep(i, n) {
        while (k > 1 && cross(qs[k - 1] - qs[k - 2], ps[i] - qs[k - 1]) < 0) k--;
        qs[k++] = ps[i];
    }
    for (int i = n - 2, t = k; i >= 0; i--) {
        while (k > t && cross(qs[k - 1] - qs[k - 2], ps[i] - qs[k - 1]) < 0) k--;
        qs[k++] = ps[i];
    }
    qs.resize(k - 1);
    return qs;
}

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

    int n;
    cin >> n;
    vector<P> ps;
    rep(i, n) {
        double x, y;
        cin >> x >> y;
        ps.emplace_back(x, y);
    }

    G h = convex_hull(ps);
    cout << h.size() << endl;
    for (auto p : h) {
        cout << p.real() << " " << p.imag() << endl;
    }

}

Measured memory_bytes: 9248
#include <stdio.h>

int main (){
	int input[100];
	for (int a=0;a<2;a++){
		scanf ("%d",&input[a]);
	}
	if (input[0]>input[1]){
		printf ("%d\n",input[0]-input[1]);
	}
	else printf ("0\n");

}

Measured memory_bytes: 128
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =998244353;
const int maxn = 200005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()


int32_t main()
{ 
  IOS

  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for(int i = 0, j  = 0;i<n;i = j){
    while(j<n and s[i] == s[j]) j++;
    if(s[i] == 'R') ans = max(ans,j-i);
  }
  cout << ans << endl;
  

  

  










  
    
} 



Measured memory_bytes: 3636
#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;
    int res = 0;
    int diff = N - res;
    while (1) {
        if (diff <= 0) break;
        res += 1000;
        diff = N - res;
    }

    cout << res - N << endl;
    return 0;
}

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

const int INF = 1e9;

int main(void){
    int n, m;
    std::cin >> n >> m;
    std::vector<std::pair<int, int>> key;
    for(int i = 0; i < m; i++){
        int a, b;
        std::cin >> a >> b;
        int s = 0;
        for(int j = 0; j < b; j++){
            int c;
            std::cin >> c;
            c--;
            s |= 1 << c;
        }
        key.push_back(std::make_pair(a,s));
    }

    std::vector<int> dp(1<<n, INF);
    dp[0] = 0;
    for(int i = 0; i < 1<<n; i++){
        for(int j = 0; j < key.size(); j++){
            int s = i | key[j].second;
            dp[s] = std::min(dp[s], dp[i] + key[j].first);
        }
    }
    int ans = dp.back();
    if(ans == INF) ans = -1;
    std::cout << ans << std::endl;
    return 0;
}


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

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C, K; cin >> A >> B >> C >> K;
    int res = 0;
    res += min(K, A);
    K -= min(K, A);
    K -= min(K, B);
    res -= min(K, C);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3664
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;

#define INF (1e9)

ll N;

int main() {
    cin >> N;

    vi A(N);
    ll S = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        S += A[i];
    }

    ll ans = 1e11, R = 0;
    for (int i = 0; i < N - 1; i++) {
        R += A[i];
        ans = min(ans, abs(S - R * 2));
    }

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


Measured memory_bytes: 1792
/*Lower_Rating*/
/*AGC040 A*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;

#define LL long long
#define MAXN 800000
#define MOD 998244353
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 2000000000
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}
int add(int x,int y){return (x+y>=MOD)?x+y-MOD:x+y;}
int dec(int x,int y){return (x-y<0)?x-y+MOD:x-y;}
int mul(int x,int y){return 1LL*x*y%MOD;}

int n,a[MAXN+5],dep;
LL ans;
char s[MAXN+5];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1)+1;
	for(int i=2;i<=n;i++){
		if(s[i-1]=='<')dep++;
		else dep=0;
		a[i]=dep;
	}
	for(int i=n-1;i>=1;i--){
		if(s[i]=='<')dep=0;
		else dep++;
		a[i]=max(a[i],dep);
	}
	for(int i=1;i<=n;i++)
	ans+=a[i];
	printf("%lld",ans);
}

Measured memory_bytes: 2560
n=int(input())
k=n%15
l=n//15
m=l*l*60
if k==1:
    print(m+1+15*l)
if k==2 or k==3:
    print(m+3+30*l)
if k==4 or k==5 or k==6:
    print(m+7+45*l)
if k==7:
    print(m+14+60*l)
if k==8 or k==9 or k==10:
    print(m+22+75*l)
if k==11 or k==12:
    print(m+33+90*l)
if k==13:
    print(m+46+105*l)
if k==14:
    print(m+60+120*l)
if k==0:
    print(m)

Measured memory_bytes: 9224
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

int main(void){
    int r,g;
    cin>>r>>g;
    cout<<g+(g-r)<<endl;
	
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (1002)
ll n,m,ans=1,mod=1e9+7,t,fr,fc;
pi A[MAXN*MAXN];
int main(){
	FAST
	cin>>n>>m;
	FOR(i,1,n){
		ll r;
		cin>>r;
		if(A[r].f){cout<<"0\n";return 0;}
		A[r].f=i;
	}
	FOR(i,1,m){
		ll c;
		cin>>c;
		if(A[c].s){cout<<"0\n";return 0;}
		A[c].s=i;
	}
	DEC(i,n*m,1){
		if(A[i].f && A[i].s){
			t += fc + fr, ++fr, ++ fc;
		}else if(A[i].f){
			ans *= fc, ans %= mod;
			t += fc-1, ++fr;
		}else if(A[i].s){
			ans *= fr, ans %= mod;
			t += fr-1, ++fc;
		}else{
			ans *= t, ans %= mod;
			--t;
		}
		// cerr<<r<<' '<<c<<' '<<t<<' '<<fr<<' '<<fc<<'\n';
		// cerr<<ans<<'\n';
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 3744
[a,v] = map(int, input().split())
[b,w] = map(int, input().split())  
t = int(input())
if a < b:
    if a+t*v >= b+t*w:
        print("YES")
    else:
        print("NO")
else:
    if a-t*v <= b-t*w:
        print("YES")
    else:
        print("NO")


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

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

    int sum = 0;
    int num = n;
    
    while(num > 0){
        sum += num % 10;
        num /= 10;
    }
    cout << (n % sum == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n,x=map(int,input().split())
A=list(map(int,input().split()))
T=A[:]
ans=sum(T)
for j in range(1,n):
    T=[min(T[i],A[i-j]) for i in range(n)]
    ans=min(ans,sum(T)+x*j)
print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p[] = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 1; i < n - 1; i++) {
            int a = p[i - 1];
            int b = p[i];
            int c = p[i + 1];
            if (a < b) {
                if (b <= c) {
                    ans++;
                }
            }
            if (c < b) {
                if (b <= a) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
        sc.close();
    }
}


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i32 n, k;
  cin >> n >> k;
  vector<i32> p(n);

  rep(i, n) { cin >> p[i]; }

  sort(p.begin(), p.end());

  u64 ans = 0;
  rep(i, k) { ans += p[i]; }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int m,d;
    cin >> m >> d;
    int ans=0;
    if(m==1||d<22) cout << 0 << endl;
    else{
        for(int i=2;i<=m;i++){
            for(int j=22;j<=d;j++){
                int j1=j%10;
                int j10=j/10;
                if(j1==1)continue;
                if(j1*j10==i) ans++;
            }
        }  
        cout << ans << endl;      
    }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  multiset<ll> st;
  rep(i, n) {
    auto itr = st.upper_bound(A[i]-1);
    if(itr == st.begin()) {
      st.insert(A[i]);
    } else {
      st.erase(--itr);
      st.insert(A[i]);
    }
  }
  cout << st.size() << endk;
  return 0;
}


Measured memory_bytes: 8696
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
path = {i:A[i]-1 for i in range(N)}
flags = [-1] * N
before = 0
flags[0] = 0
for i in range(N):
  after = path[before]
  if flags[after] > -1:
    loop = i - flags[after] + 1
    first = flags[after]
    break
  before = after
  flags[after] = i+1

if first < K:
  print(flags.index(first + (K-first) % loop) + 1)
else:
  print(flags.index(K) + 1)

Measured memory_bytes: 47496
using System;

namespace ALDS1_1_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str);
            int[] A = new int[n];
            for (int i = 0; i < n; ++i)
            {
                string str1 = Console.ReadLine();
                A[i] = int.Parse(str1);

            }

            bool[] prime = new bool[100000001];
            prime[0] = false;
            prime[1] = false;
            for(int i = 2;i<100000001;++i)
            {
                prime[i] = true;
            }
            
            for(int i=2;i<100000001;++i)
            {
                if (prime[i])
                {
                    int notPrimeNum = i * 2;
                    while (notPrimeNum < 100000001)
                    {
                        prime[notPrimeNum] = false;
                        notPrimeNum += i;
                    }
                }
            }

            int Ans = 0;
            for (int i = 0; i < n; ++i)
            {
                if (prime[A[i]])
                {
                    Ans += 1;
                }
            }

            Console.WriteLine("{0}", Ans);
 //           string pause = Console.ReadLine();

        }
    }
}

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


int main() {
   
   	long long int n,i,k,l=0,d;
   	cin>>n>>d;
   	long long int a[n],b[n];
   	for(i=0;i<n;i++)
   	{
   		cin>>a[i]>>b[i];
	   if(d*d>=(a[i]*a[i]+b[i]*b[i]))
	   {
	   	l++;
	   }
   	
   }
   cout<<l;
}

Measured memory_bytes: 6756
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const int INF = INT_MAX;


int main() {
  int a,b;
  cin >> a >> b;
  if(a+b==15){
    cout << "+" << endl;
  }else if(a*b==15){
    cout << "*" << endl;
  }else{
    cout << "x" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

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

int main()
{
    int n, m;
    cin >> n >> m;

    int ans = 1;
    int i = m / n;
    for (int i = 1; i < sqrt(m); i++)
    {
        if (m % i == 0)
        {
            if (m / i >= n)
                ans = max(ans, i);

            if (i >= n)
                ans = max(ans, m / i);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<climits>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<unordered_map>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int k=n%10;
    if(k==2 || k==4 || k==5 || k==7 || k==9) {
        cout<<"hon";
    }
    else if(k==0 || k==1 || k==6 || k==8) {
        cout<<"pon";
    }
    else {
        cout<<"bon";
    }
 
 
}

Measured memory_bytes: 3588