akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

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

Node *root;
Node *NIL;

Node * treeMinimum(Node *x)
{
  while (x->left != NIL) x = x->left;
  return x;
}

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;
}

Node * treeSuccessor(Node *x)
{
  if (x->right != NIL)
    return treeMinimum(x->right);
  Node *y = x->parent;
  while (y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z)
{
  Node *y; //削除の対象
  Node *x; //yの子
  
  //削除する節点を決める
  if (z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  
  //yの子xを決める
  if (y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }
  
  if ( x != NIL) {
    x->parent = y->parent;
  }
  
  if (y->parent == NIL) {
    root = x;
  } else {
    if (y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }
  
  if (y != z) {
    z->key = y->key;
  }
  
  free(y);
}

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, k;
  char com[10];
  
  scanf("%d", &n);
  
  while (n--) {
    scanf("%s", com);
    if (com[0] == 'i') {
      scanf("%d", &k);
      insert(k);
    }
    if (com[0] == 'f') {
      scanf("%d", &k);
      if (find(root, k) != NIL)
        puts("yes");
      else puts("no");
    }
    if (com[0] == 'd') {
      scanf("%d", &k);
      treeDelete(find(root, k));
    }
    if (com[0] == 'p') {
      inorder(root);
      putchar('\n');
      preorder(root);
      putchar('\n');
    }
  }
  
  return 0;
}


Measured memory_bytes: 20536
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	cin>>a>>b;
	c=a*b;
	c=(c+1)/2;
	if(a==1 || b==1)c=1;
	cout<<c<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int a[4][3][10] = {0};
	int n, b, f, r, v;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		a[b-1][f-1][r-1] += v;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << a[i][j][k];
			}
			cout << "\n";
		}
		if(!(i == 3))
		cout << "####################\n";
	}
}

Measured memory_bytes: 1164
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N;
    cin >> N;
    ll out = 0;
    ll t = 0;
    rep(i,N){
        cin >> t;
        if(i==0) out = t;
        else out = out/__gcd(out,t)*t;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs';

const main = (inp: string) => {

    const [a, b]: number[] = inp.split(' ').map(Number);

    // 13才以上B円
    // 6才以上12才以下半額
    // 5才以下無料
    if (a >= 13) {
        console.log(b);
    } else if(a >=6 && a <=12 ) {
        console.log(b/2);
    } else {
        console.log(0);
    }

};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());

Measured memory_bytes: 7500
import sys
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def input():
    return next(args)
def parse(*params):
    if len(params) == 1:
        return params[0](next(args))
    return tuple(p(v) for p, v in zip(params, next(args).split()))
def debug(*v):
    if __debug__:
        print(*v, file=sys.stderr)

# エントリーポイント
def main():
    N, Q = parse(int, int)
    edges = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = parse(int1, int1)
        edges[a] += [b]
        edges[b] += [a]
    vals = [0] * N
    for _ in range(Q):
        p, x = parse(int1, int)
        vals[p] += x

    counter = [0] * N
    que = deque()
    que.append((0, 0))
    alr = [False] * N
    while que:
        v, x = que.pop()
        alr[v] = True
        counter[v] += x + vals[v]
        for n in edges[v]:
            if not alr[n]:
                que.append((n, counter[v]))

    for v in counter:
        print(v)

if __name__ == '__main__':
    args = iter(sys.stdin.read().split("\n"))
    main()


Measured memory_bytes: 92104
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
vvi in;
int main(){
	int n,m,r;
	while(cin>>n>>m>>r,n){
		vi x(n),y(n);
		rep(i,n)cin>>x[i]>>y[i];
		in=vvi(10010);
		rep(i,m){
			int a,b;
			cin>>a>>b;
			in[a].pb(b);
		}
		rep(i,10010)sort(all(in[i]));
		int out=0;
		rep(i,n){
			loop(j,max(0,x[i]-4*r),min(x[i]+4*r,10010)+1){
				int s=lower_bound(all(in[j]),y[i]-4*r)-in[j].begin();
				int t=upper_bound(all(in[j]),y[i]+4*r)-in[j].begin();
				loop(k,s,t)if((j-x[i])*(j-x[i])+(y[i]-in[j][k])*(y[i]-in[j][k])<=16*r*r)out++;
			}
		}
		cout<<out<<endl;
	}
}
 

Measured memory_bytes: 3476
#include <bits/stdc++.h>
#define FOR(i,a) for(int i=0;i<a;i++)
#define boost ios::sync_with_stdio(0); cin.tie(0);
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	boost;
	long long n, d, x, y, count = 0;
	cin >> n >> d;
	while (n--) {
		cin >> x >> y;
		if (((x * x) + (y * y)) <= d * d) {
			count += 1;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 3608
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    LL N, M;
    cin >> N >> M;
    if (N >= M / 2)
    {
        cout << M / 2 << endl;
    }
    else
    {
        cout << (N * 2 + M) / 4 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

cd = Counter(D)
ct = Counter(T)

ans = True
for i in ct.keys():
    if cd[i] < ct[i]:
        ans = False
        break
print('YES' if ans else 'NO')


Measured memory_bytes: 57056
// #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>
using namespace std;
const long long mod=998244353;
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;
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;
}
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 p[110000];
int UF[119000];
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 main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);p[i]--;
	}
	for(int i=0;i<a;i++)UF[i]=-1;
	for(int i=0;i<b;i++){
		int x,y;scanf("%d%d",&x,&y);x--;y--;
		UNION(x,y);
	}
	int ret=0;
	for(int i=0;i<a;i++){
		if(FIND(i)==FIND(p[i]))ret++;
	}
	printf("%d\n",ret);
}

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

using namespace std;
#define BUF (100005)
#define ll long long 

ll n,c;

ll dp_r[BUF];
ll dp_l[BUF];

ll x[BUF];
ll v[BUF];

ll ans = 0;

int main(void){
	cin >> n >> c;
	int i;
//	for(i = 1; i<=n; ++i){
//		cin >> x[i] >> v[i];
//	}

	//rotate tokei
	ll sum=0;
//	dp_r[0] = 0;
	for(i=1; i<=n;++i){
		cin >> x[i] >> v[i];
		sum+=v[i];
		dp_r[i] = max( dp_r[i-1] , sum - x[i]);
	}

	//rotate han-tokei
	sum=0;
//	dp_l[n+1]=0;
	for(i=n;i>0;--i){
		sum+=v[i];
		dp_l[i] = max(dp_l[i+1], sum - (c-x[i]));
	}
	ans = max(dp_r[n], dp_l[1]);

	//rotate tokei to i and reverse.
	sum = 0;
	ll tmp = 0;
	for(i=1;i<n;++i){
		sum+=v[i];
		tmp = sum-2*x[i] + dp_l[i+1];
		ans = max(tmp,ans);
	}

	//rotate han-tokei to i and reverse.
	sum = 0;
	for(i=n;i>1;--i){
		sum+=v[i];
		tmp = sum-2*(c-x[i]) + dp_r[i - 1];
		ans = max(tmp,ans);
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main()
{
    std::string S;
    cin >> S;
    if (S == "RRR") {
        std::cout << 3 << std::endl;
    } else if (S == "SSS") {
        std::cout << 0 << std::endl;
    } else if (S == "RRS" || S == "SRR") {
        std::cout << 2 << std::endl;
    } else {
        std::cout << 1 << std::endl;
    }
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

//累乗(繰り返し二乗法)
long long power(long long b,long long e){
  long long r=1;
  while(e){
      if(e&1){
          r=(r*b)%MOD;
      }
      b=(b*b)%MOD;
      e >>=1;
  }
  return r;
}

vector<ll> fact,factIE;
void facter(ll n){
    fact.resize(n+1);
    factIE.resize(n+1);
    
    fact[0]=1;
    for(ll i=1;i<=n;i++){
        fact[i]=(fact[i-1]*i)%MOD;
    }
    factIE[n] = power(fact[n],MOD-2);
    for(ll i=n-1;i>=0;i--){
        factIE[i]=(factIE[i+1]*(i+1))%MOD;
    }
}

ll nCr(ll n,ll r){
    if(n<r){
        return 0;
    }
    ll R = fact[n];
    R=(R*factIE[r])%MOD;
    R=(R*factIE[n-r])%MOD;
    return R;
}

ll T(ll n,ll k){
    ll R = 0;
    if(n<k)return 0;
    
    REP(j,k+1){
        ll num = nCr(k,j);
        num *= fact[n-j];num%=MOD;
        if(j%2==1){
            num = MOD-num;
        }
        R+=num;
        R%=MOD;
    }
    
    R *= factIE[n-k];R%=MOD;
    return R;
}

int main(void){
    ll N,M;
    cin >> N >> M;
    facter(max(M,N));
    ll R = T(M,N);
    R*=fact[M];R%=MOD;
    R*=factIE[M-N];R%=MOD;
    
    cout << R << endl;
    
    
    return 0;
}



Measured memory_bytes: 11084
#include <iostream>
#include <set>
using namespace std;
int main(void){
    int n;
    cin >> n;
    set<string> s;
    for(int i=0;i<n;i++){
        string si;
        cin >> si;
        s.insert(si);
    }
    cout << s.size() << endl;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
	cin>>n>>k;
	int d[10]={0};
	for(int i=0;i<k;i++)
	{
		int a;
		cin>>a;
		d[a]=1;
	}
	int t=n;
	while(true)
	{
		int temp=t,flag=0;
		while(temp!=0)
		{
			int di=temp%10;
			for(int i=0;i<10;i++)
			{
				if(d[di]==1)
				{flag=1;
					break;}
			}
			if(flag==1)
			{break;}
			temp=temp/10;
		}
		if(flag==0)
		{break;}
		t++;
	}
	cout<<t;
	return 0;
}


Measured memory_bytes: 3536
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n;
  double v[55]={},ans;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> v[i];
  }
  sort(v,v+n);
  ans=v[0];
  for(int i=1; i<n; i++) {
    ans=(ans+v[i])/2;
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=2e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int x;
  cin>>x;
  if(x>=400 && x<=599) cout<<8<<endl;
  else if(x>=600 && x<=799) cout<<7<<endl;
  else if(x>=800 && x<=999) cout<<6<<endl;
  else if(x>=1000 && x<=1199) cout<<5<<endl;
  else if(x>=1200 && x<=1399) cout<<4<<endl;
  else if(x>=1400 && x<=1599) cout<<3<<endl;
  else if(x>=1600 && x<=1799) cout<<2<<endl;
  else if(x>=1800 && x<=1999) cout<<1<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define X first 
#define Y second
using namespace std;
typedef pair<int, int> pii;
const int N = 222222;
vector<pii> a;
int x, n, ac[N], res[N], q;
int main() {
	scanf("%d", &x);
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		int t;
		scanf("%d", &t);
		a.pb(mp(t, -1));
	}
	scanf("%d", &q);
	for (int i = 1; i <= q; ++i) {
		int t;
		scanf("%d%d", &t, &ac[i]);
		a.pb(mp(t, i));
	}
	sort(a.begin(), a.end());
	int i = 0, j = x, yi = 0, yj = x, dir = 0, t0 = 0;
	for (int _ = 0; _ < a.size(); ++_) {
		int t = a[_].X;
		if (t != t0) {
			int dt = t - t0;
			if (dir == 0) {
				if (yi >= dt) {
					yi -= dt;
					yj -= dt;
				} else if (yj < dt) {
					yj = yi = 0;
					i = j = 0;
				} else {
					i += dt - yi;
					yi = 0;
					yj -= dt;
				}
			} else {
				if (yj + dt <= x) {
					yi += dt;
					yj += dt;
				} else if (yi + dt > x) {
					i = j = 0;
					yi = yj = x;
				} else {
					j -= yj + dt - x;
					yi += dt;
					yj = x;
				}
			}
		}
		t0 = t;
		int id = a[_].Y;
		if (~id) {
			if (ac[id] <= i) res[id] = yi;
			else if (ac[id] >= j) res[id] = yj;
			else res[id] = yi + ac[id] - i;
		}
		else dir ^= 1;
	}
	for (int i = 1; i <= q; ++i) printf("%d\n", res[i]);
	return 0;
} 

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
*/
int main()
{
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    U == S ? A-- : B--;
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    if b >= a {
        a.to_string()
    } else {
        (a - 1).to_string()
    }
}


Measured memory_bytes: 2112
#include<stdio.h>
int a[10001];
main(){
  int i,j,n,flg;
  for(i=2;i<10001;i++){
    if(a[i]==0){
      for(j=2;i*j<10001;j++){
	a[i*j]=1;
      }
    }
  }
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=n,flg=0;i>=2&&flg==0;i--){
      if(a[i]==0&&a[i-2]==0){
	printf("%d %d\n",i-2,i);
	flg++;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 636
s = input()
f = True

if s.find("S") != -1 and s.find("N") == -1:
    f = False
if s.find("S") == -1 and s.find("N") != -1:
    f = False
if s.find("E") != -1 and s.find("W") == -1:
    f = False
if s.find("E") == -1 and s.find("W") != -1:
    f = False
print("Yes" if f else "No")

Measured memory_bytes: 38256
export class Main {
  static main(input: string): string {
    const [tmp, ...likes] = input.split("\n");
    const [n, m] = tmp.split(" ").map(Number);
    const [k0, ...foods0] = likes[0].split(" ").map(Number);
    let foodResult = {};
    foods0.slice(0, k0).forEach(food => {
      foodResult[food] = true;
    });
    for (let i = 1; i < n; i++) {
      const [k, ...foods] = likes[i].split(" ").map(Number);
      let tmp ={};
      let isEmpty = true;
      foods.slice(0, k).forEach(food => {
        if (foodResult[food]) {
          tmp[food] = true;
          isEmpty = false
        }
      });
      foodResult = tmp;
      if (isEmpty) {
        break;
      }
    }
    return `${Object.keys(foodResult).length}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

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


signed main() {
  int N, M;
  cin >> N >> M;
  
  vector<vector<int>> A(30, vector<int>(31, 0));
  vector<int> count(M, 0);
  int K;
  for( int i = 0; i < N; i++ ){
    cin >> K;
    for( int j = 0; j < K; j++ ){
      cin >> A.at(i).at(j);
      count.at(A.at(i).at(j)-1)++;
    }
  }
  
  int ans = 0;
  for( int i = 0; i < M; i++ ){
    if( count.at(i) == N ){
      ans++;
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int	H, W;
	
	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0)break;
		int i, j;
		for(i = 0; i < H; ++i){
			for(j = 0; j < W; ++j){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

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

ll dp[202][100010];

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,x;
    cin>>n>>x;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll mod = 1e9+7;
    dp[0][x]=1;
    sort(a,a+n,greater<ll>());

    for(int i=0;i<n;i++){
        for(int j=0;j<=x;j++){
            dp[i+1][j%a[i]] += dp[i][j];
            dp[i+1][j%a[i]] %= mod;
            dp[i + 1][j] += dp[i][j] * (n - i - 1); dp[i + 1][j] %= mod;
        }
    }
    ll ans = 0;
    for(int i=0;i<=x;i++){
        ans += i*dp[n][i];
        ans %= mod;
        //cerr<<i<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 157184
#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 ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << 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;

int main() {
    lli n, k;
    cin2(n, k);
    lli x[n], y[n];
    ncin2(n, x, y);
    lli ans = LLONG_MAX;
    REP(l_i, 0, n) {
        REP(r_i, 0, n) {
            REP(d_i, 0, n) {
                REP(u_i, 0, n) {
                    lli l = x[l_i];
                    lli r = x[r_i];
                    lli d = y[d_i];
                    lli u = y[u_i];
                    if (l > r || d > u)
                        continue;

                    lli in_bbox_count = 0;
                    REP(i, 0, n) {
                        // この i は bbox に含まれている？
                        if (x[i] >= l && x[i] <= r && y[i] >= d && y[i] <= u)
                            in_bbox_count++;
                    }
                    if (in_bbox_count >= k)
                        ans = min(ans, (r-l)*(u-d));
                }
            }
        }
    }
    cout << ans << endl;
}


//4o
//3  o
//2     o
//1       o
//x12345678
//
//4  o
//3 o
//2       o
//1     o
//x12345678
//
//
//3 => 5*2
//4 => 7*3


Measured memory_bytes: 764
/*
    author: blue_matrix
*/
#include <bits/stdc++.h>
using namespace std;

#define n_l '\n'
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
#define ll long long
// ll c;
long long bi(long long a) {
    ll res=100;
    ll c=0;
    while(res<a)
    {
        res+=(res*1)/100;
        c++;
    }
    return c;
}
int main()
{
    
    // c=0;
    ll a;
    cin>>a;
    ll b=bi(a);
    cout<<b<<endl;
    return 0;
}

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

using namespace std;

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

    // 1回の操作でa, b, cの合計が２ずつ増える。
    // a, b, cの最大値*3からa, b, cの合計を引いて2で割れば操作回数がわかる。
    int x = max({a, b, c});
    int y = 3 * x - (a + b + c);
    if (y % 2 == 0) {
        cout << y / 2 << endl;
    } else { // 奇数だった場合はa, b, cの最大値に１を足す。
        y = 3 * (x + 1) - (a + b + c);
        cout << y / 2 << endl;
    }
}

Measured memory_bytes: 256
// C.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char *argv[])
{
	int X;
	cin >> X;
	int ans = 0, tot = 0;
	for (int t = 1; tot < X; ++t) {
		++ans;
		tot += t;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
	int N;
	cin >> N;
	int t[100001], x[100001], y[100001];
	for (int i = 1;i <= N;i++) cin >> t[i] >> x[i] >> y[i];
	t[0] = x[0] = y[0] = 0;

	bool trv = true;
	//i番目からi+1番目まで行けるかチェック
	//行けなければfalse
	for (int i = 0;i<N;i++) {
		int dist = abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1]);
		int td = t[i + 1] - t[i];
		if (dist > td) { trv = false; }
		if ((td - dist) % 2 == 1) { trv = false; }
	}
	if (trv) { cout << "Yes"; }
	else { cout << "No"; }
}

Measured memory_bytes: 1408
import bisect
N = int(input())
c_list = list(input())

R_list = list()
W_list = list()

for i in range(N):
    if c_list[i] == "R":
        R_list.append(i)
    else:
        W_list.append(i)
        
if len(W_list) == 0 or len(R_list) == 0:
    print(0)
else:
    #print(R_list)
    #print(len(R_list))
    #Rを左に揃えればよい
    ans = len(R_list) - bisect.bisect_left(R_list,len(R_list))
    print(ans)

Measured memory_bytes: 18800
x1,y1,x2,y2 = map(int,input().split())
tate = abs(y1-y2)
yoko = abs(x1-x2)

print("U"*tate+"R"*yoko+"D"*tate+"L"*yoko,end="")
print("L"+"U"*(tate+1)+"R"*(yoko+1)+"D"+"R"+"D"*(tate+1)+"L"*(yoko+1)+"U")

Measured memory_bytes: 3060
while (n = gets.to_i) > 0
  dp = Array.new(n+1,0)
  dp[0] = 1
  
  for i in 0..(n-1)
    for j in 0..2
      if i+j+1 <= n
        dp[i+j+1] += dp[i]
      end
    end
  end
  
  puts ((dp[n]+9)/10 + 364) / 365
end


Measured memory_bytes: 6844
#include <iostream>
using namespace std;
#include <string>
int abs(int n) {
	if(n < 0) n=n*-1;
	return n;
}

int main() {
	string S; cin >> S;
	int sz = S.size();
	
	int min = 99999;
	for(int i=0; i<= sz-3; i++){
		string sbstr;
		sbstr = S.substr(i, 3);
		
		int num = atoi(sbstr.c_str());
		num = abs(753 - num);
		if(num < min) min = num;
		
	}
	
	cout << min;
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) = p34()

fun p34() {
    val n = readLine()!!.toInt()

    val dp = LongArray(45)
    dp[0] = 1
    dp[1] = 1

    for (i in 2..n) dp[i] = dp[i - 1] + dp[i - 2]

    val answer = dp[n]

    println(answer)
}



Measured memory_bytes: 25288
import numpy as np
from copy import deepcopy

n=int(input())
a=list(map(int,input().split()))
c=0
j=0
for i in range(0,n-1):
    if(j>=n-1):break
    if(a[j]==a[j+1]):
        c+=1
        j+=2
        continue
    j+=1
print(c)

Measured memory_bytes: 21672
n,q =map(int,input().split())
S = input()
LR = [list(map(int,input().split())) for _ in range(q)]
temp = ""
S2 = []

for s,i in zip(S,range(n)):
    if temp == "A" and s == "C":
        S2.append(i)
    temp = s

import bisect as bi

for l,r in LR:
    ans = - bi.bisect_right(S2,l-1) + bi.bisect_right(S2,r-1)
    print(ans)

Measured memory_bytes: 30272
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

string s;
int k;
vector<string> vec;

//DFS
int main(){
    cin >> s >> k;
    for(int i = 0; i < s.size(); i++){
        for(int j = 1; j <= k; j++){
            vec.push_back(s.substr(i, j));
        }
    }
    sort(vec.begin(), vec.end());
    decltype(vec)::iterator result = unique(vec.begin(), vec.end());
    vec.erase(result, vec.end());
    //for (int t = 0; t < vec.size(); t++) cout << vec[t] << endl;
    cout << vec[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 1660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Map<String, Integer> card = new HashMap<>();
        try {
            int count = Integer.parseInt(br.readLine());
            for (int i = 0; i < count; i++) {
                card.put(br.readLine(), 1);
            }
        } finally {
            br.close();
        }
        String[] suitArr = {"S", "H", "C", "D"};
        for (String suit : suitArr) {
            for (int i = 1; i <= 13; i++) {
                String temp = suit+" "+i;
                if (card.get(temp) == null) {
                    System.out.println(suit+" "+i);
                }
            }
        }
    }
}

Measured memory_bytes: 24352
#include<stdio.h>
int main(void){
    int N, K, i, ans;
    scanf("%d %d", &N, &K);
    ans = 1;
    for(i = 0; i < N; i++){
        if(ans * 2 < ans + K) ans *= 2;
        else ans += K;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  ld N, T, A;
  ci(N, T, A);
  ve<ld> H(N);
  rep(i, N){
    ci(H.at(i));
  }
  ld a = 0, c = 1000; 
  rep(i, N){
    ld x = abs(A - (T - H.at(i) * 0.006));
    if(min(c, x) == x){
      a = i + 1;
      c = min(c, x);
    }
  }
  co(a);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    vector<vector<ll> > v(n);
    for (ll i = 0; i < m; i++)
    {
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    for (auto e : v[n-1])
    {
        if (find(v[e].begin(), v[e].end(), 0) != v[e].end())
        {
            cout << "POSSIBLE" << endl;
            exit(0);
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 12776
#include<stdio.h>
#include<stdlib.h>

struct Node {
  Node* prev;
  Node* next;
  int key;
};

Node* sentinel;

void init() {
  sentinel = (Node *)malloc(sizeof(Node));
  sentinel->prev = sentinel;
  sentinel->next = sentinel;
}

void insert(int k) {
  Node* node = (Node *)malloc(sizeof(Node));
  node->key = k;
  sentinel->next->prev = node;
  node->next = sentinel->next;
  node->prev = sentinel;
  sentinel->next = node;
}

void deleteNode(Node* node) {
  if(node != sentinel) {
    node->next->prev = node->prev;
    node->prev->next = node->next;
    free(node);
  }
}

void deleteFirst() {
  Node* node = sentinel->next;
  deleteNode(node);
}

void deleteLast() {
  Node* node = sentinel->prev;
  deleteNode(node);
}

void deleteKey(int k) {
  Node* node = sentinel->next;
  while( node != sentinel ) {
    if(node->key == k) {
      deleteNode(node);
      return;
    } else node = node->next;
  }
}

int main() {
  int n, k;
  char o[12];
  init();
  scanf("%d", &n);

  while( scanf("%s %d", o, &k) != EOF ) {
    if ( o[0] == 'i' ) insert(k);
    else if( o[0] == 'd' ) {
      if ( o[6] == 'F' ) deleteFirst();
      else if ( o[6] == 'L' ) deleteLast();
      else deleteKey(k);
    }
  }

  Node* node = sentinel->next;
  for ( int i = 0; node != sentinel; i++ ) {
    if ( i != 0 ) printf(" ");
    printf("%d", node->key);
    node = node->next;
  }
  
  printf("\n");
  return 0;
}


Measured memory_bytes: 33844
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

def com(k, r):
    return factorial(k) // (factorial(k - r) * factorial(r))

n,k = mii()
bl=k
re=n-k

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
N=4000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for j in range( 2, N + 1 ):
    g1.append( ( g1[-1] * j ) % mod )
    inverse.append( ( -inverse[mod % j] * (mod//j) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


for i in range(1,k+1):
    ans = (cmb(re+1,i,mod)*cmb(bl-1,i-1,mod))%mod

    print(ans)

Measured memory_bytes: 68204
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  vi t(100002);
  while (n--) {
    int a, b;
    cin >> a >> b;
    t[a]++;
    t[b + 1]--;
  }
  loop(i, 1, t.size()) t[i] += t[i - 1];
  int c = 0;
  loop(i, 1, t.size()) if (t[i] >= i - 1) c = i - 1;
  cout << c << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
long n,i,s,t[10000];
while(cin>>n,n){
for(i=0;i<n;i++)cin>>t[i];
sort(t,t+n);
for(s=i=0;i<n;i++)s+=t[i]*(n-1-i);
cout<<s<<endl;
}
return 0;
}

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

int main(void) {
    int N, M; cin >> N >> M;
    vector<pair<int, int>> jobs(N);
    for (int i = 0; i < N; i++) {
        int a, b; cin >> a >> b;
        jobs[i] = {b, -a};
    }
    sort(jobs.begin(), jobs.end(), greater<pair<int, int>>());
    set<int> sche;
    for (int i = 0; i <= M; i++) {
        sche.insert(i);
    }
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        pair<int, int> crt_job = jobs[i];
        int money = crt_job.first;
        int day = crt_job.second * -1;
        if (0 <= M - day) {
            auto itr = sche.upper_bound(M-day);
            if (itr == sche.begin()) continue;
            itr--;
            sche.erase(itr);
            ans += money;
        }
    }
    cout << ans << endl;
    
}


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

int main(){
    int N,K,Q;
    cin >> N >> K >> Q;
    int A[N];
    int index;
    for(int i = 0; i < N; i++){
        A[i] = 0;
    }
    for(int i = 0; i < Q; i++){
        cin >> index;
        A[index-1] += 1;
    }

    for(int i = 0; i < N;i++){
        if(K - (Q-A[i]) > 0) cout << "Yes"<< endl;
        else cout << "No"<< endl;
    }

    
}

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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int count = 0;

  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (500 * i + 100 * j + 50 * k == x) {
          count++;
        }
      }
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
long long dpmax[3005][3005],dpmin[3005][3005];
int n,a[3005];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++){
		dpmax[i][i]=a[i],dpmin[i][i]=-a[i];
		for (int j=i+1;j<=n;j++) dpmax[i][j]=-100000000000,dpmin[i][j]=10000000000;
	}
	
	for (int i=2;i<=n;i++)
		for (int l=1,r=i;r<=n;l++,r++){
			dpmax[l][r]=std::max(dpmin[l+1][r]+a[l],dpmin[l][r-1]+a[r]);
			dpmin[l][r]=std::min(dpmax[l+1][r]-a[l],dpmax[l][r-1]-a[r]);
		}
	printf("%lld\n",dpmax[1][n]);
}

Measured memory_bytes: 139776
#include <bits/stdc++.h>
 
using namespace std;
 
#define BOOST        std::ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define sp           <<" "<<
#define ll           long long
#define ld           long double
#define AZI(i,x)     for(auto i=x.begin();i!=x.end();i++)
#define AZ(x)        x.begin(),x.end()
#define P(x,y)       pair < x,y >
#define V(x)         vector < x >
#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define PI           3.14159265358979323846264338327950288419716939937510

// find_by_order(int k) - returns k'th smallest element (0-indexed)
// order_of_key(int k) - returns number of elements strictly smaller than k.
// using namespace __gnu_pbds;
// #define ordered_set tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>

const ll mod=1e9+7,N=1e5+5,INF = 1e18;

ll power(ll a,ll b)
{
    a = a%mod;
    ll result = 1;

    while(b)
    {
        if(b&1)
            result = (result*a)%mod;
        b >>= 1, a = (a*a)%mod;
    }
    return result;
}


/*

1. Make sure you're taking all the inputs.
2. In case of nested loops, remember to use different variables.
3. If in doubt, do int -> ll
4. Don't fight the question, try solving the next one.

*/



//  Don't code anything above this //




int main() 
{ 
    BOOST

    string s;

    cin>>s;

    int len = s.length();

    for(int i=1;i<len;i++)
        if(s[i]==s[i-1])
            return cout<<"Bad\n",0;
    cout<<"Good\n";        
    return 0;    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i,n,c;
	
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		if(i!=100000){
			if(!(1000<=i&&i<10000)){
				if(!(10<=i&&i<100))c++;
			}
		}
	}
	
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
W = [input() for _ in range(N)]

for i in range(N):
    if W[i] in W[i+1:]:
        print('No')
        #print(W[i])
        exit()
    elif i > 0 and W[i-1][-1] != W[i][0]:
        # print(W[i-1], W[i])
        print('No')
        exit()

print('Yes')


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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int cnt[2019];

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);

	string s; cin >> s;
	reverse(all(s));
	int acc = 0, v = 1; cnt[acc]++;
	for (char c : s) {
		acc = (acc + (c - '0') * v) % 2019;
		v = v * 10 % 2019;
		cnt[acc]++;
	}
	ll ans = 0;
	for (int i = 0; i < 2019; i++) {
		ans += (cnt[i] * (cnt[i] - 1) / 2);
	}
	cout << ans << endl;
}


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

typedef long long ll;
typedef pair<ll, ll> P;
struct edge { ll to; double cost; };

const int MAX_V =100000;
const ll INF = 1LL<<60;

int V;
vector<edge> G[MAX_V];
double d[MAX_V];

void dijkstra(ll s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep(i,G[v].size()) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    double xs, ys, xt,yt;
    int N;
    cin >> xs >> ys >> xt >> yt >> N;
    vector<double> x(N + 2) , y(N + 2), r(N + 2);
    rep(i, N) cin >> x[i] >> y[i] >> r[i];
    x[N] = xs;
    y[N] = ys;
    r[N] = 0;
    x[N + 1] = xt;
    y[N + 1] = yt;
    r[N + 1] = 0;
    V = N + 2;
    rep(i, N + 2) {
        rep(j, N + 2) {
            double dx = x[i] - x[j], dy = y[i] - y[j];
            double dist = sqrt(dx * dx + dy * dy) - r[i] - r[j];
            if (dist < 0) dist = 0;
            G[i].push_back({j, dist});
        }
    }
    dijkstra(N);
    cout << setprecision(20) << d[N + 1] << endl;
}

Measured memory_bytes: 24944
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

b = sys.stdin.buffer.readline().decode().rstrip()
if b == 'A':
    print('T')
if b == 'T':
    print('A')
if b == 'C':
    print('G')
if b == 'G':
    print('C')


Measured memory_bytes: 13356
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
const double pi = 3.1415926535897932384626;
const double hp = pi/2.0;
const double eps = 1e-9;
#define N (110)
int n, x[N], y[N];
double al, ar;
double bl, br;
void intser(double l, double r){
    if (l < -pi-eps){
        l += 2*pi;
        if (bl > r+eps){
            bl = r;
        }
        if (br < l-eps){
            br = l;
        }
    }
    else if (r > pi+eps){
        r -= 2*pi;
        if (bl > r+eps){
            bl = r;
        }
        if (br < l-eps){
            br = l;
        }
    }
    else {
        if (al < l-eps){
            al = l;
        }
        if (ar > r+eps){
            ar = r;
        }
    }
}
int main(){
    scanf("%d", &n);
    for (int i = 0; i < n; ++i){
        scanf("%d%d", x+i, y+i);
    }
    for (int i = 0; i < n; ++i){
        al = -pi, ar = +pi;
        bl = br = 0;
        for (int j = 0; j < n; ++j){
            if (i != j){
                double th = atan2(y[i]-y[j], x[i]-x[j]);
                // printf("%lf %lf\n", l , r);
                intser(th-hp, th+hp);
            }
        }
        printf("%0.15lf\n", (max(bl-al,0.0)+max(ar-br, 0.0))/2/pi);
    }
}

Measured memory_bytes: 128