akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

int N, M, A[1000], B[1000];
long long mod = 1e9 + 7;

int main(){
  cin >> N >> M;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A, A + N, greater<int>());
  for(int j = 0; j < M; j++){
    cin >> B[j];
  }
  sort(B, B + M, greater<int>());

  for(int i = 0; i < N - 1; i++){
    if(A[i] == A[i+1]){
      cout << 0 << endl;
      return 0;
    }
  }
  for(int j = 0; j < M - 1; j++){
    if(B[j] == B[j + 1]){
      cout << 0 << endl;
      return 0;
    }
  }
  /*
  for(int i = 0; i < N; i++){
    cout << A[i] << " ";
  }cout << endl;
  for(int j = 0; j < M; j++){
    cout << B[j] << " ";
  }cout << endl;
  */
  long long ans = 1;
  int occupied = 0, covered_i = 0, covered_j = 0;
  //int occupied_i[1000] = {}, occupied_j[1000] = {};
  int now = N * M;
  while(now >= 1){
    if((covered_i < N && A[covered_i] == now) || (covered_j < M && B[covered_j] == now)){
      if(covered_i < N && covered_j < M && A[covered_i] == B[covered_j]){
	covered_i++;
	covered_j++;
	ans *= 1;
	occupied++;
	// cout << "cross: " << now << endl;
	now--;
	continue;
      }else if(covered_i < N && (covered_j >= M || A[covered_i] > B[covered_j])){
	covered_i++;
	ans *= covered_j;
	ans %= mod;
	occupied++;
	now--;
      }else if(covered_j < M && (covered_i >= N || A[covered_i] < B[covered_j])){
	covered_j++;
	ans *= covered_i;
	ans %= mod;
	occupied++;
	// cout << "tate: " << now << endl;
	now--;
      }
    }else{
      if(covered_i * covered_j <= occupied){
	// cout << now << endl;
	// cout << occupied << endl;
	// cout << covered_i << ", " << covered_j << endl;
	cout << 0 << endl;
	return 0;
      }else{
	ans *= (covered_i * covered_j) - occupied;
	ans %= mod;
	occupied++;
      }
      now--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# F - Select Half

n = int(input())
a = list(map(int, input().split()))
assert len(a) == n

l = [0] * n # a[0]〜a[i]からfloor((i+1)/2)個選ぶときの最大値
u = [0] * n # a[0]〜a[i]からceil((i+1)/2)個選ぶときの最大値

l[0] = 0
u[0] = a[0]
u[1] = max(a[:2])
l[1] = u[1]

# 0 1 2 3 4 5 6 7 8 9 10 i
# . . . . . . . . . . .
# 1 1 2 2 3 3 4 4 5 5 6  u[i]
# 0   1   2   3   4   5  l[i]

for i in range(2, n):
    l[i] = max(u[i - 1], l[i - 2] + a[i])
    u[i] = u[i - 2] + a[i]
    if i % 2 != 0:
        u[i] = max(u[i - 1], u[i])

print(l[-1])


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	string str;
	cin >> str;
	set<char> s(begin(str), end(str));
	if (s.size() == 26) {
		cout << "None\n";
		return;
	}
	for (char c = 'a'; c <= 'z'; c++) {
		if (!s.count(c)) {
			cout << c << "\n";
			return;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	hawawa();
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define STR_MAX 100000
#define BUF_SIZE (STR_MAX+50)

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

int get_int3(int *a1, int *a2, int *a3) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d %d", a1, a2, a3);
#else
#error
#endif
  return 0;
}

enum {
    ENUM_ROCK,
    ENUM_SCISSORS,
    ENUM_PAPER,
};

int win_table[3] = {
    ENUM_PAPER,
    ENUM_ROCK,
    ENUM_SCISSORS
};

int table[256] = {
    ['r'] = ENUM_ROCK,
    ['s'] = ENUM_SCISSORS,
    ['p'] = ENUM_PAPER,
};

int main(void) {
    int num, kprev;
    get_int2(&num, &kprev);
    static int points[3];
    get_int3(&points[ENUM_ROCK], &points[ENUM_SCISSORS], &points[ENUM_PAPER]);

    static char str[BUF_SIZE];
    static char is_win[BUF_SIZE];
    int cnt;
    get_str(str, BUF_SIZE);
    int i, j;
    for(i = 0; i < kprev; i++) {
        int prev = str[i];
        is_win[i] = 1;
        cnt = 1;
        for(j = 1;; j++) {
            int idx = i + kprev*j;
            if(idx >= num) break;
            int cur = str[idx];
            if(prev==cur) {
                cnt++;
            } else {
                prev = cur;
                cnt = 1;
            }
            is_win[idx] = (cnt%2!=0);
            prev = cur;
        }
    }
#ifdef DEBUG
    for(i = 0; i < num; i++) {
        printf("%d ", is_win[i]);
    }
    putchar('\n');
#endif

    int ans = 0;
    for(i = 0; i < num; i++) {
        int type = table[str[i]];
        if(is_win[i]) ans += points[win_table[type]];
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
<?php

$input = fgets(STDIN);

$input_array = explode(" ", $input);

$input = $input_array[0] . $input_array[1];

if(!preg_match('/^([1-9]\d*|0)\.(\d+)?$/', sqrt($input))) {
    echo "Yes";
} else {
    echo "No";
}


Measured memory_bytes: 4604
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    auto dp = new Tuple!(long, long)[][](1<<N, 2);

    foreach (i; 0..(1<<N)) {
        if (A[i] >= dp[i][0][0]) {
            dp[i][1] = dp[i][0];
            dp[i][0] = tuple(A[i], i);
        } else if (A[i] >= dp[i][1][0]) {
            dp[i][1] = tuple(A[i], i);
        }
        foreach (j; 0..N) {
            if ((i >> j) & 1) continue;
            auto hoge = [dp[i][0], dp[i][1], dp[i|(1<<j)][0], dp[i|(1<<j)][1]];
            hoge = hoge.sort!"a > b".uniq().array;
            dp[i|(1<<j)][0] = hoge[0];
            dp[i|(1<<j)][1] = hoge[1];
        }
    }

    long ans = 0;
    foreach (i; 1..(1<<N)) {
        ans = max(ans, dp[i][0][0] + dp[i][1][0]);
        ans.writeln;
    }
}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;
#define pi 3.141

typedef long long int ll;

int main() {

	IOS

	int r;
	cin >> r;

	cout << 2 * M_PI * r << endl;
	return 0;
}

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

const ll INV = -1; //invalid number for lazy

struct Node {
	int s, e, m;
	//covers s,e;
	ll sum;
	ll lazy;
	Node *l, *r;
	
	Node(int a, int b) {
		s = a;
		e = b;
		sum = 0;
		lazy = INV;
		if (s != e) {
			m = (s+e)/2;
			l = new Node(s,m);
			r = new Node(m+1,e);
		}
		else {
			l = NULL;
			r = NULL;
		}
	}

	void push() {
		if (lazy == INV) return;
		if (s != e) {
			l->lazy = lazy;
			l->sum = (l->e - l->s + 1) * lazy;

			r->lazy = lazy;
			r->sum = (r->e - r->s + 1) * lazy;
		}
		lazy = INV;
	}

	void pull() {
		sum = l->sum + r->sum;
	}

	void add(int st, int en, ll x) {
		//lazy: already accounted for in your own node, not the childs nodes
		if (st <= s && e <= en) {
			lazy = x;
			sum = (e - s + 1) * x;
			return;
		}
		push();
		if (st <= m) {
			l->add(st,en,x);
		}
		if (en > m) {
			r->add(st,en,x);
		}
		pull();
	}

	ll getsum(int st, int en) {
		push();
		//if completely included
		if (st <= s && e <= en) {
			return sum;
		}
		ll ret = 0;
		if (st <= m) {
			ret += l->getsum(st,en);
		}
		if (en > m) {
			ret += r->getsum(st,en);
		}
		return ret;
	}
};

const int maxn = 2e5+5;
int c[maxn], par[maxn];
int n;
vector<int> adj[maxn];

int tin[maxn], tout[maxn], t = 1;
int depth[maxn];

void dfs(int i, int p) {
    par[i] = p;
    depth[i] = depth[p] + 1;
    tin[i] = t++;
    for (int j: adj[i]) if (j != p) {
        dfs(j,i);
    }
    tout[i] = t-1;
}

vector<int> nodes[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> c[i];
        nodes[c[i]].push_back(i);
    }
    for (int i = 0; i < n-1; i++) {
        int a, b; cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    adj[0].push_back(1);
    adj[1].push_back(0);
    dfs(0,0);
    Node *root = new Node(0,n+1);
    root->add(1,n+1,1);
    for (int i = 1; i <= n; i++) {
        nodes[i].push_back(0);
        sort(nodes[i].begin(),nodes[i].end(),[](int a, int b) {
            return depth[a] > depth[b];
                });
        ll ans = 0;
        for (int j: nodes[i]) {
            for (int u: adj[j]) if (u != par[j]) {
                int sz = root->getsum(tin[u],tout[u]);
                ans += 1LL*sz*(sz+1)/2;
                //cout << j << ' ' << u << ": " << sz << endl;
            }
            root->add(tin[j],tout[j],0);
        }

        for (int j: nodes[i]) {
            root->add(tin[j],tout[j],1);
        }

        ans = 1LL*n*(n+1)/2-ans;
        cout << ans << '\n';
    }
}


Measured memory_bytes: 63940
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl


/*--------------------template--------------------*/

int main()
{
	cin >> s;
	n = s.size();
	sort(ALL(s));
	ans = 1;
	vi v;
	sum = 1;
	REP(i, s.size()-1)
	{
		if (s[i] == s[i+1]) {
			sum++;
		} else {
			v.push_back(sum);
			sum = 1;
		}
	}

	ll kinds = v.size();

	REP(i, kinds)
	{
		n -= v[i];
		ans += v[i] * n;
	}
	cout << ans << endl;
}


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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;


int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    ll ans=1LL;

    for(int i=1 ; i<=n ; i++){
        ans = ((ans%MOD) * (i))%MOD;
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;

inline void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];

ll a[102];
bool dp[114514];
ll n ,k;

signed main(){
	IOS();
	cin >> n >> k;
	for (int i = 0;i < n;++i) {
		cin >> a[i];
	}
	for(int i = 0;i <= k;i++){
		dp[i] = false;
		for (int j = 0;j < n;++j) {
			dp[i] |= i >= a[j] && !dp[i - a[j]];
		}
	}
	
	cout << (dp[k] ? "First" : "Second") << endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		int[] arr = new int[N];
		for(int i = 0; i < N; i++){
			arr[i] = sc.nextInt() - 1;
		}
		
		long count = 0;
		for(int i = 0; i < N; i++){
			if(arr[arr[i]] == i){
				count++;
			}
		}
		
		System.out.println(count / 2);
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}	
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22232
/*   --------------------
    |       LOSER        |
    |     ~NOOBOSS~      |
     --------------------
*/
#include <bits/stdc++.h>
using namespace std;

#define      inl(x)              scanf("%lld",&x)
#define      in(x)               scanf("%d",&x)
#define      mxx                 10000000000000
#define      mnn                 -10000000000000
#define      Y()                 cout<< "YES" <<endl
#define      N()                 cout << "NO"<<endl
#define      endl                "\n"
#define      max_3(a,b,c)        max(a, max(b,c))
#define      max_4(a,b,c,d)      max(a,max(b,max(c,d)))
#define      min_3(a,b,c)        min(a, min(b,c))
#define      min_4(a,b,c,d)      min(a,min(b,min(c,d)))
#define      gcd(a,b)            __gcd(a,b)
#define      lcm(a,b)           (a*b)/gcd(a,b)
#define      loser               return 0
#define      ll                  long long
#define      PI                  acos(-1)
#define      mem(a,v)            memset(a,v,sizeof(a))
#define      SORT(v)             sort(v.begin(),v.end())
#define      REV(v)              reverse(v.begin(),v.end())
#define      O(x)                cout<<x<<endl
#define      B                   begin()
#define      E                   end()
#define      V                   vector
#define      F                   first
#define      S                   second
#define      PSB                 push_back
#define      EMB                 emplace_back
#define      MP                  make_pair
#define      PII                 pair<int,int>
#define      MII                 map<int,int>
#define      InTheNameOfGod      ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
const ll MOD = 998244353;
//auto it=std:: unique(v.B,v.E);
//v.resize(std::distance(v.B,it));
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
/*-----*/
#define bug1(a)  cout<<a<<endl;
#define bug2(a,b)  cout<<a<<" "<<b<<endl;
#define bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
/*----*/
ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
ll binpow(ll a, ll b){ll res = 1;while (b > 0) {if (b & 1)res*=a;a*=a;b>>=1;}return res;}
ll fact(ll num){ll fac=1;while(num!=1){fac=fac*num;num--;}return fac;}
string to_binary(int x) {string s;while(x > 0) {s += (x % 2 ? '1' : '0');x /= 2;}reverse(s.begin(), s.end());return s;}
ll nsum(ll num){return (num*(num+1))/2;}
/*-----*/
const int N=2e5+5;

/*-----*/
//vector<int> v[202];

/*-----*/
int main(){
   InTheNameOfGod

       ll test=1;
       //cin>>test;
       while(test--){
           ll n,i,ans=0;
           string s,t;
           cin>>s>>t;
           for(i=0;i<s.length();++i){
            if(s[i]!=t[i]) ans++;
           }
           cout<<ans<<endl;
        }
	loser;
}
///////LeArN MoRe AnD Wait FoR ThE Result///////


Measured memory_bytes: 3796
N,X,Y = gets.split.map(&:to_i)

P = lambda{|n|
	case n
	when 1..X; [[n,0]]
	when Y..N; [[n-Y+X+1,0]]
	else [[X,n-X],[X+1,n-Y]]
	end
}
D = lambda{|((x1,y1),(x2,y2))|
	(x1-x2).abs+(y1-y2).abs
}

K = [0]*N
(1..N).map(&P).combination(2).each{|ps1,ps2|
	K[ps1.product(ps2).map(&D).min]+=1
}

puts K.drop 1


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

int main()
{
    int n;

    cin >> n;

    int a[n];

    for( int i = 0; i < n; i++ )
        cin >> a[i];

    bool j1 = false, j2 = false, j3 = false;
    for( int i = 0; i < n; i++ )
    {
        j1 = i == 0 ? 0: 1;
        j2 = i * 2 + 1 < n ? 1: 0;
        j3 = i * 2 + 2 < n ? 1: 0;
        
        cout << "node " << i + 1 << ": key = " << a[i] << ", ";
        if(j1)
            cout << "parent key = " << a[(i-1)/2] << ", ";
        if(j2)
            cout << "left key = " << a[i*2+1] << ", ";
        if(j3)
            cout << "right key = " << a[i*2+2] << ", ";
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< double,double> dd;
#define pb push_back
#define eb emplace_back
#define sz(a) (int)a.size()
#define all(c) c.begin(),c.end()
#define FOR(i,a,b) for(i=a; i<b; i++)
#define FORR(i,a,b) for(i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define x first
#define y second
#define mp make_pair

const int INF = 1000000007;
const long long INFLL = (ll)INF * (ll)INF;

int32_t main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	vi price(n);
	for(int& x:price)
	{
		cin>>x;
	}
	sort(all(price));
	int sum = 0;
	sum =accumulate(price.begin(),price.begin()+k,0);
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<math.h>
using namespace std;

int main(void) {
	int long long N, D, Xi, Yi;
	int i;
	int count = 0;

	cin >> N;
	cin >> D;

	for (i = 0;i < N;i++) {
		cin >> Xi;
		cin >> Yi;

		if (sqrt(Xi * Xi + Yi * Yi) <= D) {
			count++;
		}
	}

	cout << count;

	return 0;

}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'

vector<vector<int>> G;
vector<int> S;
vector<int> A;

void dfs(int i, int p, int res){
    res += S[i];
    A[i] += res;
    for(auto x : G[i]){
        if(x == p) continue;
        dfs(x, i, res);
    }
}

signed main() {
    int n,q;
    cin >> n >> q;

    G.resize(n), S.resize(n), A.resize(n);
    rep(i,n - 1){
        int a,b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i,q){
        int p,x;
        cin >> p >> x;
        p--;
        S[p] += x;
    }

    dfs(0,-1,0);
    for(int i = 0; i < n; i++){
        cout << A[i] << " ";
    }
    cout << endl;

}


Measured memory_bytes: 25856
N = int(input())
H = list(map(int, input().split()))
tmp = 0
count = 0
output = 0

while tmp < N - 1:
    if H[tmp] >= H[tmp + 1]:
        count += 1

    if output < count:
        output = count

    if H[tmp] < H[tmp + 1]:
        count = 0

    tmp += 1

print(output)


Measured memory_bytes: 14252
a, b, c = map(int, input().split())
  
if a<b and a<c:
    if b<c :
        print(a, b, c)
    else :
        print(a, c, b)
elif b<a and b<c :
    if a<c :
        print(b, a, c)
    else :
        print(b, c, a)
else :
    if a<b :
        print(c, a, b)
    else :
        print(c, b, a)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll a, b;
  cin >> a >> b;
  if(a+b==15){
    print('+');
  }
  else if(a*b==15){
    print('*');
  }
  else{
    print('x');
  }
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;

int n,bt[(1<<17)+10];
int w[(1<<17)+10];
//int subw[(1<<17)+10][20];
//void printnum(int x)
//{
//	for (int i=9;~i;i--) putchar(((x>>i)&1)+48);
//}
void build(int l,int r,int a,int b,int dep)
{
//	if (a==b) puts("Error");
	if (l+1==r) return w[l]=a,w[r]=b,void();
	int bita=n-dep-1,bitb;
	for (int i=n-dep-1;~i;i--)
		if (((a>>i)&1)^((b>>i)&1))
		{
			bitb=i; break;
		}
	int tmp1=((a>>bita)&1),tmp2=((a>>bitb)&1);
	a-=tmp1*(1<<bita),a-=tmp2*(1<<bitb);
	a+=tmp1*(1<<bitb),a+=tmp2*(1<<bita);
	tmp1=((b>>bita)&1),tmp2=((b>>bitb)&1);
	b-=tmp1*(1<<bita),b-=tmp2*(1<<bitb);
	b+=tmp1*(1<<bitb),b+=tmp2*(1<<bita);
	tmp1=((a>>bita)&1),tmp2=((b>>bita)&1);
	a-=tmp1*(1<<bita),b-=tmp2*(1<<bita);
	int midval;
	for (int i=0;i<(1<<n-dep-1);i++)
		if ((bt[a]&1)^(bt[i]&1))
		{midval=i;break;}
	int mid=l+r>>1;
	build(l,mid,a,midval,dep+1);
	build(mid+1,r,midval,b,dep+1);
	for (int i=l;i<=mid;i++)
		w[i]+=tmp1*(1<<bita);
	for (int i=mid+1;i<=r;i++)
		w[i]+=tmp2*(1<<bita);
	for (int i=l;i<=r;i++)
	{
		tmp1=((w[i]>>bita)&1),tmp2=((w[i]>>bitb)&1);
		w[i]-=tmp1*(1<<bita),w[i]-=tmp2*(1<<bitb);
		w[i]+=tmp1*(1<<bitb),w[i]+=tmp2*(1<<bita);
	}
//	for (int i=l;i<=r;i++)
//	{
//		int tmp1=((w[i]>>bita)&1),tmp2=((w[i]>>bitb)&1);
//		w[i]-=tmp1*(1<<bita),w[i]-=tmp2*(1<<bitb);
//		w[i]+=tmp1*(1<<bitb),w[i]+=tmp2*(1<<bita);
//	}
//	int suba,subb;
//	for (int i=0;i<(1<<n-dep-1);i++)
//		if (((bt[a]&1)^(bt[i]&1)))
//		{
//			suba=i; break;
//		}
//	for (int i=(1<<n-dep-1);i<(1<<n-dep);i++)
//		if (((bt[b]&1)^(bt[i]&1)))
//		{
//			subb=i; break;
//		}
//	build(l,(l+r>>1),a,suba,dep+1); build((l+r>>1)+1,r,subb,b,dep+1);
//	for (int i=l;i<=r;i++)
//	{
//		int tmp1=((w[i]>>bita)&1),tmp2=((w[i]>>bitb)&1);
//		w[i]-=tmp1*(1<<bita),w[i]-=tmp2*(1<<bitb);
//		w[i]+=tmp1*(1<<bitb),w[i]+=tmp2*(1<<bita);
//		w[i]+=subw[i][dep];
//	}
}

int main()
{
//	printnum(1234);
	int a,b;
	scanf("%d%d%d",&n,&a,&b);
	for (int i=1;i<(1<<n);i++) bt[i]=bt[i>>1]+(i&1);
	if ((bt[a]&1)==(bt[b]&1)) return puts("NO"),/*puts("Accepted!"),*/0;
	build(1,(1<<n),a,b,0);
	puts("YES");
	for (int i=1;i<=(1<<n);i++)
		printf("%d",w[i]),putchar(i==(1<<n)?'\n':' ');
	
	
//	for (int i=2;i<=(1<<n);i++) if (bt[w[i]]!=bt[w[i-1]]-1&&bt[w[i]]!=bt[w[i-1]]+1) return puts("Error1!"),0;
//	sort(w+1,w+(1<<n)+1);
//	for (int i=1;i<=(1<<n);i++) if (w[i]!=i-1) return puts("Error2!"),0;
//	
//	puts("Accepted!");
	
//	sort(w+1,w+(1<<n)+1);
//	for (int i=1;i<=(1<<n);i++)
//		printf("%d",w[i]),putchar(i==(1<<n)?'\n':' ');
	return 0;
}

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

using namespace std;

typedef long long ll;

// Defines and one-liners
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
template <typename T> inline T& back(vector<T> &vec) { return *(vec.end() - 1); }
template <typename T> inline void pop(vector<T> &vec) { return vec.erase(vec.end() - 1); }

// Scan, Debug, and other nonsense
template <typename T> ostream& operator<<(ostream& out,vector<T> iter){out<<"[";for(auto t:iter){out<<t<<", ";}out<<"]";return out;}
template <typename T> void printArray(ostream& out,T* arr,int sz){out<<"[";for(int i=0;i<sz;i++){out<<arr[i]<<", "; } out<<"]";}
#define OUT_OPERATOR(type, propa, propb) ostream& operator<<(ostream& out,type obj){out<<"("<<#propa<<"="<<obj. propa<<", "<<#propb<<"="<<obj. propb<<")";return out;}

void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F f,R... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

const int MN = 1e5 + 10;
int n;
ll m[MN], h[MN];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    scan(n);

    ll mtot = 0;
    for (int i = 0; i <= n; i++) {
        scan(m[i]);
        mtot += m[i];
    }for (int i = 0; i < n; i++) {
        scan(h[i]);
    }

    for (int i = 0; i < n; i++) {
        int dif = h[i] - m[i];

        if (dif > 0) {
            m[i] = 0;
            m[i + 1] = max(0LL, m[i + 1] - dif);
        }
        else 
            m[i] -= h[i];
    }

    ll tot = 0;
    for (int i = 0; i <= n; i++)
        tot += m[i];
    cout << (mtot - tot) << "\n";

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MAXN 100010
#define ll long long
using namespace std;

int n;
ll a[MAXN];
ll b[MAXN];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n + 1; i++) {
		scanf("%d", &a[i]);
	}	
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b[i]);
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		if(a[i]>b[i]){
			ans += b[i];
			a[i] -= b[i];
		}
		else {
			if(a[i]==b[i]){
				ans += a[i];
				a[i] = 0;
			}
			else{
				if(b[i]-a[i]>a[i+1]){
					ans += a[i] + a[i+1];
					a[i] = 0;
					a[i + 1] = 0;
		//cout << ans << endl;
				}
				else {
					ans += b[i];
					a[i + 1] = a[i+1] - b[i] + a[i] ;
					a[i] = 0;
				}
			}
		}
	//	cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()
#define PI 3.141592653589793

int main() {
    ll N, M;
    cin >> N >> M;
    if (N >= 2 && M >= 2) {
        cout << (N - 2) * (M - 2) << endl;
        return 0;
    }

    else if (N >= 2 && M < 2) {
        cout << N - 2 << endl;
        return 0;
    }

    else if (N < 2 && M >= 2) {
        cout << M - 2 << endl;
        return 0;
    }

    else {
        cout << 1 << endl;
        return 0;
    }
}

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

using namespace std;

int main()
{
  int N;
  vector<int> H;
  int temp;
  int ans;
  cin >> N;
  for(size_t i = 0; i < N; ++i)
  {
    cin >> temp;
    H.push_back(temp); 
  }
  for (size_t i = 0; i < H.size(); ++i)
  {
    bool can = true;
    for (size_t j = 0; j < i; ++j) {
      if (H[j] > H[i]) {
        can = false;
        break;
      }
    }
    if(can)
      ans++;
  }
  std::cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * 16-7-23_ABC042_A.cpp
 *
 *  Created on: 2016/07/23
 *      Author: ryoma
 */

#include <iostream>

using namespace std;

int main() {
	int A, five = 0, seven = 0;
	for (int i = 0; i < 3; i++) {
		cin >> A;
		if (A == 5)
			five++;
		else if (A == 7)
			seven++;
	}
	cout << ((five == 2 && seven == 1) ? "YES" : "NO") << endl;

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch=='A') return 1;
  else if(ch=='C') return 2;
  else if(ch=='G') return 3;
  else if(ch=='T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum=0,p=1,i;
  for(i=0 ; i<strlen(str) ; i++){
    sum+=p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % M;
}
int h2(int key){
  return 1+(key%(M-1));
}
int find(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0 ; ; i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)
      return 1;
    else if(strlen(H[h])==0)
      return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0 ; ; i++){
    h=(h1(key) + i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0 ; i<M ; i++) H[i][0]='\0';
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%s %s",com,str);
    if(com[0]=='i')insert(str);
    else{
      if(find(str)) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}
  



Measured memory_bytes: 16040
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>
#include<atcoder/all>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



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

	ll ans = 0;
	vll a(n);
	vector<vll> t(n);
	rep(i, 0, n) {
		ll res = n - i-1;
		 
		cin >> a[i];
		ll cnt = 0;
		for (ll j = ans; j >= max(1LL, ans - res);j--) {
			for (auto x : t[j]) {
				if (abs(a[x] - a[i]) <= k) {
					cnt = j;
					break;
				}
			}
			if (cnt > 0) {
				break;
			}
		}
		cnt++;
		t[cnt].push_back(i);
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 22028
import java.util.*;

// CODEFES_B 2017-C
// http://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_c	

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

		int N = in.nextInt();
		int M = in.nextInt();
		int[][] map = new int[N][N];
		MyPair[] edges = new MyPair[M];
		
		for (int i = 0; i < M; i++) {
			int a = in.nextInt() - 1;
			int b = in.nextInt() - 1;
			
			map[a][b] = 1;
			map[b][a] = 1;
			edges[i] = new MyPair(a, b);
		}

		int answer = 0;
		for (int i = 0; i < M; i++) {
			MyPair p = edges[i];
			map[p.a][p.b] = 0;
			map[p.b][p.a] = 0;
			
			int numVisited = 0;
			int[] visited = new int[N];
			ArrayList<Integer> q = new ArrayList<Integer>();
			q.add(0);
			
			while (q.size() > 0) {
				int node = q.remove(0);
				visited[node] = 1;
				numVisited++;
				
				for (int j = 0; j < N; j++) {
					if (map[node][j] == 1 && visited[j] == 0 && !q.contains(j)) {
						q.add(j);
					}
				}
			}
			
			if (numVisited < N) {
				answer++;
			}
			
			map[p.a][p.b] = 1;
			map[p.b][p.a] = 1;
		}
		System.out.println(answer);
	}
	
}

class MyPair {
	
	int a;
	int b;
	
	public MyPair(int a, int b) {
		this.a = a;
		this.b = b;
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

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

	long long ans = 0;

	long long x = N / (A + B);

	ans += A * x;

	if (N % (A + B) <= A) {
		ans += N % (A + B);
	}
	else {
		ans += A;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))

for i in range(n):
    if l[i] % 2 == 0:
        if l[i] % 3 == 0 or l[i] % 5 == 0:
            pass
        else:
            print('DENIED')
            exit(0)

print('APPROVED')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define N 200100
int n,m,he[N],ne[N<<1],e[N<<1],cnt,fa[N],op[N],C[N][2],Q[N];
char s[N];
void add(int u,int v){ne[++cnt]=he[u];he[u]=cnt;e[cnt]=v;}
int main(){
	scanf("%d%d%s",&n,&m,s+1);
	for (int i=1;i<=m;i++){
		int u,v; scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
		C[u][s[v]-'A']++; C[v][s[u]-'A']++;
	}
	int h=0,t=0;
	for (int i=1;i<=n;i++) if (!C[i][0] || !C[i][1]) Q[++t]=i;
	while (h!=t){
		int x=Q[++h];
		for (int i=he[x];i;i=ne[i]) {
			C[e[i]][s[x]-'A']--;
			if (!C[e[i]][s[x]-'A'] && C[e[i]][(s[x]-'A')^1]) Q[++t]=e[i];
		}
	}
	if (t==n) puts("No"); else puts("Yes");
	return 0;
}


Measured memory_bytes: 8064
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>
//#include<unordered_set>

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> st;*/

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define int long long

mt19937 rnd(51);

bool prime(int v) {
	for (int i = 2; i <= sqrt(v); i++) {
		if (v % i == 0) {
			return 0;
		}
	}
	return 1;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, now = 2, ans = 0;
	map<int, int> mp;
	cin >> n;
	while (n > 1) {
		if (mp[n] == 0) {
			if (prime(n)) {
				ans++;
				break;
			}
			else {
				mp[n] = 1;
			}
		}
		int cnt = 0;
		while (n % now == 0) {
			n /= now;
			cnt++;
		}
		if (cnt != 0) {
			int l = 0, r = 1e7;
			while (r - l > 1) {
				int mid = (r + l) / 2, mud = (r + l) / 2;
				mid = (mid + 1) * mid / 2;
				if (mid <= cnt) {
					l = mud;
				}
				else {
					r = mud;
				}
			}
			ans += l;
		}
		now++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3676
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    int N; cin >> N;
    vector<int>A(N);
    int ans = 0;
    rep(i, N) {
        cin >> A[i];
        ans = ans ^ A[i];
    }
    rep(i, N) {
        int B = ans ^ A[i];
        cout << B << (i != N - 1 ? " ":"");
    }
    cout << endl;
}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
long long M  = 1e9+7;
 
 
signed main(){
    fast;
    string a,b; cin >> a >> b;
    int x,y; cin >> x >> y;
    int ans = x+y;
    string u ; cin >> u;
    if(a == u)
        x--;
    if(b == u)
        y--;
    cout << x << " " << y << endl;
}


Measured memory_bytes: 256
import sys

MOD = 10 ** 9 + 7
MOD = 10 ** 9 + 7
class ModInt:

	def __init__(self, x, inv=None):
		self.x = x.x if isinstance(x, ModInt) else x % MOD
		self.inv = inv

	__str__ = lambda self:str(self.x)
	__repr__ = __str__
	__int__ = lambda self: self.x
	__index__ = __int__

	__add__ = lambda self, other: ModInt(self.x + ModInt(other).x)
	__radd__ = lambda self, other: ModInt(other + self.x)
	__iadd__ = __add__

	__sub__ = lambda self, other: ModInt(self.x - ModInt(other).x)
	__rsub__ = lambda self, other: ModInt(other - self.x)
	__isub__ = __sub__

	__mul__ = lambda self, other: ModInt(self.x * ModInt(other).x)
	__rmul__ = lambda self, other: ModInt(other * self.x)
	__imul__ = __mul__

	__pow__ = lambda self, other: ModInt(pow(self.x, ModInt(other).x, MOD))
	__rpow__ = lambda self, other: ModInt(pow(other, self.x, MOD))
	__pow__ = __pow__

	def __truediv__(self, other):
		if isinstance(other, ModInt) and other.inv != None:
			return ModInt(self.x * other.inv)
		else:
			return ModInt(self.x * pow(ModInt(other).x, MOD - 2, MOD))
	
	def __rtruediv__(self, other):
		if not self.inv:
			return ModInt(other * pow(self.x, MOD - 2, MOD))
		else:
			return ModInt(other * self.inv)

	__itruediv__ = __truediv__

	__floordiv__ = lambda self, other: ModInt(self.x // ModInt(other).x)
	__rfloordiv__ = lambda self, other: ModInt(other // self.x)
	__ifloordiv__ = __floordiv__

	__mod__ = lambda self, other: ModInt(self.x % other)
	__rmod__ = lambda self, other: ModInt(other % self.x)
	__imod__ = __mod__

	__lt__ = lambda self, other: self.x < ModInt(other).x
	__gt__ = lambda self, other: self.x > ModInt(other).x
	__le__ = lambda self, other: self.x <= ModInt(other).x
	__ge__ = lambda self, other: self.x >= ModInt(other).x
	__eq__ = lambda self, other: self.x == ModInt(other).x
	__ne__ = lambda self, other: self.x != ModInt(other).x


class Fact:
	def __init__(self, MAX):
		MAX += 1
		self.fact = [0] * MAX
		finv = [0] * MAX
		inv = [0] * MAX
		self.fact[0] = 1
		self.fact[1] = 1
		finv[0] = 1
		finv[1] = 1
		inv[1] = 1
		for i in range(2, MAX):
			self.fact[i] = self.fact[i - 1] * i % MOD
			inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
			finv[i] = finv[i - 1] * inv[i] % MOD
		for i in range(MAX):
			self.fact[i] = ModInt(self.fact[i], inv=finv[i])
	def __call__(self, value):
		return self.fact[value]



def main():
	n, m = map(int, sys.stdin.readline().split())
	fact = Fact(10**5)
	if abs(n - m) > 1:
		print(0)
		exit()
	ans = fact(n) * fact(m)
	if (n + m) % 2 == 0:
		ans *= 2
	print(ans)

main()


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

  int N , M, L ;
  int ans = 0 ;
  cin >> N >> M >> L ;
  if(N == M || N == L || M == L ){
    if(N == M && N == L )cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine.toInt
  val s = StdIn.readLine
  val res = for {
    i <- 1 until n
  } yield {
    // val ar = s.toArray.splitAt(i)
    // (ar._1 intersect ar._2).distinct.length
    {
      s.substring(0,i).toCharArray intersect s.substring(i,n).toCharArray
    }.distinct.length
  }
  println(res.max)
}

Measured memory_bytes: 27340
import java.util.Scanner

object Main extends App  {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val s = sc.next

  val res =
    s.foldLeft((0,0)){case ((x, max), c)=>
      val newX = x + ( if(c == 'I') 1 else -1 )
      (newX, Math.max(max, newX))
    }._2

  println(res)
}

Measured memory_bytes: 25412
#include <iostream>
#include <map>
#include <cstring>
using namespace std;

const int size = 250;
int G[size][size];
int C[size];
map <int, int> M;
int M_index;
bool flag;

void set_index( int a ) 
{
  if ( M.find( a ) != M.end() ) return;
  M[a] = M_index; 
  M_index++;
}

void init()
{
  memset( G, 0, sizeof(G) );
  memset( C, 0, sizeof(C) );
  M.clear();
  flag = false;
}

int main( void ) 
{
  int a, b;
  flag = true;
  while ( cin >> a >> b ) {
    if ( a == 0 && b == 0 ) {
      for ( int i = 0; i < size; i++ ) {
        for ( int j = 0; j < size; j++ ) {
          if ( G[i][j] > 0 ) C[i] += G[i][j];
        }
      }
      bool ok = true;
      int start = M[1], goal = M[2];
      for ( int i = 0; i < size; i++ ) {
        if ( !C[i] ) continue;
        if ( i == start || i == goal ) {
          if ( C[i] % 2 == 0 ) ok = false;
        } else {
          if ( C[i] % 2 != 0 ) ok = false;
        }
      }
      // output
      cout << ( ok ? "OK" : "NG" ) << endl;
      flag = true;
    } else {
      if ( flag ) {
        init();
      }
      set_index( a );
      set_index( b );
      int index_a = M[a], index_b = M[b];
      G[index_a][index_b]++;
      G[index_b][index_a]++;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#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 REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  map<char, int> mpl, mpr;
  rep(i, N) {
    if(!mpr.count(S[i])) mpr[S[i]] = 0;
    mpr[S[i]]++;
  }
  set<string> se;
  rep(i, N) {
    char tmp = S[i];
    mpr[tmp]--;
    if(mpr[tmp] == 0) mpr.erase(tmp);
    for(auto ml: mpl) {
      for(auto mr: mpr) {
        string cand = "   ";
        cand[0] = ml.first;
        cand[1] = tmp;
        cand[2] = mr.first;
        se.insert(cand);
      }
    }
    if(!mpl.count(tmp)) mpl[tmp] = 0;
    mpl[tmp]++;
  }
  cout << se.size() << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")


// range query using fenwick tree
// note index starts at 1

class fenwick_tree {
	vector<long long> t;
	long long size;
public:
	fenwick_tree(long long n) {
		t.assign(n + 1, 0);
		size = n + 1;
	}

	long long LSOne(long long k) {	// least significant 1-bit
		return k & (-k);
	}

	void update(long long index, long long val) {	// can go up or go down
		for (; index < size; index += LSOne(index)) t[index] += val;
	}

	long long query_full(long long a, long long b) {		// range query
		return query(b) - ((a <= 1) ? 0 : query(a - 1));
	}

	long long query(long long b) {	// range query 1..b
		if (b < 1) return 0;

		long long sum = 0;
		for (; b; b -= LSOne(b)) sum += t[b];
		return sum;
	}
};



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

	long long n, q, id, x, t, l, r, ans, i, j, k;

	cin >> n >> q;
	fenwick_tree ft(n + 10);
	for (i = 0; i < n; i++) {
		cin >> x;
		ft.update(i + 1, x);
	}

	while (q--) {
		cin >> t;
		if (t == 0) {
			cin >> id >> x;
			ft.update(id + 1, x);
		}
		else {
			cin >> l >> r;
			ans = ft.query_full(l + 1, r);
			cout << ans << "\n";
		}
	}



	return 0;
}


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

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

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

Node *root, *NIL;

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 = x;
  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, x;
  string s;
  cin >> n;
  rep(i,n) {
    cin >> s;
    if (s == "insert") {
      cin >> x;
      insert(x);
    } else if (s == "print") {
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    } else {
      cout << "Invalid command: " << s << endl;
    }
  }
  return 0;
}



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

void output(int *A,int N,int count){
	for(int i = 0; i < N; i++){
		if(i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << count << endl;
}

int bubbleSort(int *A, int N){
	bool flag = 1;
	int count = 0;
	while(flag){
		flag = 0;
		for(int j = N - 1; j > 0; j--){
			if (A[j] < A[j-1]){
				int temp = A[j];
				A[j] = A[j-1];
				A[j-1] = temp;
				count++;
				flag = 1;
			}
		}
	}

	return count;
}

int main(){
	int N,A[101];
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	int count = bubbleSort(A,N);
	output(A,N,count);

	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<math.h>
#define M(a,b) (a<b?a:b)
int main(){
	for(int a,b,c,n,r;scanf("%d%d%d",&a,&b,&c),a|b|c;){
		for(scanf("%d",&n);n--;){
			scanf("%d",&r);
			puts(
				(2*r>M(M(sqrt(a*a+b*b),sqrt(b*b+c*c)),sqrt(c*c+a*a)))?
				"OK":"NA"
			);
		}
	}
}

Measured memory_bytes: 0