akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<string>;
using P =pair<int,int>;

int main(){
    int n,t;
    cin>>n>>t;
    int ans=10000;
    rep(i,n){
        int c,s;
        cin>>c>>s;
        if(s<=t){
            ans=min(c,ans);
        }
    }
    if(ans!=10000)cout<<ans<<endl;
    else cout<<"TLE"<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
using namespace std;
int main() {

    string S;
    cin >> S;

    string ret = "Yes";

    int itr = S.length() / 2;
    int is_odd = S.length() % 1;

    for(int i=0; i<itr; i++){
        if(S[i*2] == 'L' || S[i*2+1] == 'R') {
            ret = "No";
            break;
        }
    }
    if(S[itr*2-1] == 'R')
        ret = "No";
    if(S.length() == 1 && S[0] == 'L')
        ret = "No";


    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A += [a]
    B += [b]

A.sort()
B.sort()

if N % 2 == 1:
    index = int((N-1)/2)
    minX = A[index]
    maxX = B[index]
    ans = maxX - minX + 1
else:
    index = int(N/2)
    minX1 = A[index-1]
    minX2 = A[index]
    maxX1 = B[index-1]
    maxX2 = B[index]
    minX = minX1 + minX2
    maxX = maxX1 + maxX2
    ans = maxX - minX + 1

print(ans)


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

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


int main() {
int H,W,count=0;
cin>>H>>W;
int grid[H][W];
rep(i,H){
    rep(j,W){
        cin>>grid[i][j];
    }
}
vector<int> y,x,y_,x_;
rep(i,H-1){
    rep(j,W){
        if(grid[i][j]%2==1){
            count++;
            grid[i][j]--;
            grid[i+1][j]++;
            y.push_back(i+1);
            x.push_back(j+1);
            y_.push_back(i+2);
            x_.push_back(j+1);

        }
    }
}
rep(j,W-1){
    if(grid[H-1][j]%2==1){
        count++;
        grid[H-1][j]--;
        grid[H-1][j+1]++;
        y.push_back(H);
        x.push_back(j+1);
        y_.push_back(H);
        x_.push_back(j+2);
    }
}
cout<<count<<endl;
rep(i,count){
    cout<<y[i]<<" "<<x[i]<<" "<<y_[i]<<" "<<x_[i]<<endl;
}

return 0;
}

Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second
int main()
{
    ll n;cin >> n;
    map<ll,ll> m;
    ll sum = 0;
    for(ll i=0;i<n;i++)
    {
        ll x;cin >> x;
        m[x]++;
        sum = sum + x;
    }
    ll q;cin >> q;
    while(q--)
    {
        ll a1,a2;
        cin >> a1 >> a2;
        ll r1 = m[a1];
        m.erase(a1);
        sum = sum - a1*r1;
        m[a2] += r1;
        sum = sum + r1*a2;
        cout << sum << endl;
    }
}
    

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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e5 + 100;

int N, M; pi Nr[MAX_N];
int main() {
	cin >> N >> M;
	REP(i, N) scanf("%d%d", &Nr[i].one, &Nr[i].two);
	sort(Nr, Nr+N, [&](pi a, pi b) {
		if(a.one == b.one) return a.two > b.two;
		return a.one < b.one;
	});
	
	priority_queue<int, vector<int>, greater<int>> Q;
	priority_queue<int, vector<int>, greater<int>> R;
	for(int i=0, m=1; m<=M; m++) {
		while(i < N && Nr[i].one < m) R.push(Nr[i++].two);
		while(i < N && Nr[i].one == m) Q.push(Nr[i++].two);
		while(Q.size() > m) R.push(Q.top()), Q.pop();
	}
	int l = Q.size() + 1;
	for(int m=l; m<=M; m++) {
		if(!R.empty() && R.top() <= m) R.pop();
	}
	printf("%d\n", R.size());
	return 0;
}

Measured memory_bytes: 3320
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {
		
		int n = sc.nextInt();
		int[] count = new int['Z'+1];
		for(int i = 0 ; i < n ; i++){
			String b = sc.next();
			
			count[b.charAt(0)]++;
		}
		
		BigInteger mar = BigInteger.valueOf(count['M']).multiply(BigInteger.valueOf(count['A']).multiply(BigInteger.valueOf(count['R'])));
		BigInteger mac = BigInteger.valueOf(count['M']).multiply(BigInteger.valueOf(count['A']).multiply(BigInteger.valueOf(count['C'])));
		BigInteger mah = BigInteger.valueOf(count['M']).multiply(BigInteger.valueOf(count['A']).multiply(BigInteger.valueOf(count['H'])));
		BigInteger mrc = BigInteger.valueOf(count['M']).multiply(BigInteger.valueOf(count['R']).multiply(BigInteger.valueOf(count['C'])));
		BigInteger mrh = BigInteger.valueOf(count['M']).multiply(BigInteger.valueOf(count['R']).multiply(BigInteger.valueOf(count['H'])));
		BigInteger mch = BigInteger.valueOf(count['M']).multiply(BigInteger.valueOf(count['C']).multiply(BigInteger.valueOf(count['H'])));
		BigInteger arc = BigInteger.valueOf(count['A']).multiply(BigInteger.valueOf(count['R']).multiply(BigInteger.valueOf(count['C'])));
		BigInteger arh = BigInteger.valueOf(count['A']).multiply(BigInteger.valueOf(count['R']).multiply(BigInteger.valueOf(count['H'])));
		BigInteger ach = BigInteger.valueOf(count['A']).multiply(BigInteger.valueOf(count['C']).multiply(BigInteger.valueOf(count['H'])));
		BigInteger rch = BigInteger.valueOf(count['R']).multiply(BigInteger.valueOf(count['C']).multiply(BigInteger.valueOf(count['H'])));
		
		System.out.println(mar.add(mac).add(mah).add(mrc).add(mrh).add(mch).add(arc).add(arh).add(ach).add(rch));
	}
}


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

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


#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
char s[4];
char t[2];
int main() {
	rep(i, 4)cin >> s[i];

	sort(s, s+4);

	if(s[0]!=s[1]||s[2]!=s[3]||s[1]==s[2])cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define emp emplace
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n,a,b,c,d;
string A;
bool again(string A, ll a, ll b, ll c, ll d) {
	while(a!=c){
		if(A[a+1]=='#'&&A[a+2]=='#'){return 0;}
		if(A[a+1]=='.'&&a+1!=b)++a;
		else if(A[a+2]=='.'&&a+2!=b)a+=2;
		else {
			// move b
			if(A[b+1]=='.')++b;
			else if(A[b+2]=='.')b+=2;
			else {return 0;}
			if(A[a+1]=='.'&&a+1!=b)++a;
			else if(A[a+2]=='.'&&a+2!=b)a+=2;
			else assert(0);
		}
		if(a>c||b>d){return 0;}
	}
	// a==c
	A[c]='#';
	while(b!=d){
		if(A[b+1]=='.')++b;
		else if(A[b+2]=='.')b+=2;
		else return 0;
		if(b>d)return 0;
	}
	return 1;
}
int main()
{
	FAST
	cin>>n>>a>>b>>c>>d>>A;--a,--b,--c,--d;
	A.pb('#');
	A.pb('#');
	A.pb('#');
	bool lol=again(A,a,b,c,d);
	lol|=again(A,b,a,d,c);
	cout<<(lol?"Yes":"No");
}


Measured memory_bytes: 720
#include<stdio.h>
int main(){
    int n,x,t,ans;
    scanf("%d%d%d",&n,&x,&t);
    if(n%x == 0){
        ans = (n/x)*t;
    }else{
        ans = (n/x + 1)*t;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1712
#include <cstdio>
#include <queue>
#include <algorithm>
#include <map>
#include <tuple>
#include <set>

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

using namespace std;

typedef pair<int, int> P;
typedef tuple<P, int, set<P>> T;

int n, m, z;
char x[50][51];

int a;
map<T, int> b;

int main(){
	scanf("%d%d%d", &n, &m, &z);
	rep(i, n){
		scanf("%s", x[i]);
	}

	queue<T> q;
	q.push(T(P(0, 0), z, {}));
	while(!q.empty()){
		T t = q.front();
		q.pop();
		P p = get<0>(t);
		int z = get<1>(t);
		set<P> s = get<2>(t);
		if(p == P(n - 1, m - 1)){
			a = max(b[T(p, z, s)], a);
		}

		int dx[] = {0, 1, 0, -1};
		int dy[] = {1, 0, -1, 0};
		rep(i, 4){
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			int nz = i >= 2 ? z - 1 : z;

			if(!(0 <= nx && nx < n && 0 <= ny && ny < m && nz >= 0 && x[nx][ny] != '#')){
				continue;
			}

			int g = 0;
			set<P> ns;
			if('1' <= x[nx][ny] && x[nx][ny] <= '9' && s.find({nx, ny}) == s.end()){
				ns.insert({nx, ny});
				g = x[nx][ny] - '0';
			}
			for(auto it = s.begin(); it != s.end(); ++it){
				int u = max(nx - it->first, 0);
				int v = max(ny - it->second, 0);
				if(u + v <= nz){
					ns.insert(*it);
				}
			}

			T nk({nx, ny}, nz, ns);
			if(b.find(nk) == b.end() || b[nk] < b[T(p, z, s)] + g){
				b[nk] = b[T(p, z, s)] + g;
				q.push(T({nx, ny}, nz, ns));
			}
		}
	}
	printf("%d\n", a);
	return 0;
}

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

int ans[2003];

int main(void){
    int n,x,y,l;cin>>n>>x>>y;
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            l=min(j-i,min(abs(x-i)+abs(j-y)+1,abs(y-i)+abs(j-x)+1));
            ans[l]++;
        }
    }
    for(int i=1;i<n;i++)cout<<ans[i]<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

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

    int N;
    cin >> N;

    map<ll, int> m;

    ll ans = 0;
    REP(i, N) {
        ll a;
        cin >> a;
        if (m[a] > 0) {
            --m[a];
            --ans;
        } else {
            ++m[a];
            ++ans;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

const int MAX=4010000;
long long fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
long long COM(int n,int k){
    if(n<k) return 0;
    if(n<0 or k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
ll fact_mod(ll n) {
    ll ret=1; 
    for(ll i=2;i<=n;i++) ret=ret*(i%mod)%mod;
    return ret;
} 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}
//O(r)
ll combination_mod(ll n, ll r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    ll a=1;
    for(ll i=0;i<r;i++) a=a*((n-i)%mod)%mod;
    ll b=pow_mod(fact_mod(r), mod-2);
    return (a%mod)*(b%mod)%mod;
}
ll inv_mod(ll n){
    return pow_mod(n,mod-2);
}


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

    COMinit();

    ll n,m;cin>>n>>m;
    ll ans=0;

    for(int i=0;i<=n;i++){
        ll nai=m-i;
        ll res=fac[nai]*inv_mod(fac[m-n])%mod;
        res=res*res%mod;
        res=res*COM(n,i)%mod*fac[m]%mod*inv_mod(fac[m-i])%mod;

        // cout<<res<<endl;


        ans+=(i%2?mod-res:res);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 97616
#include <cstdio>
#include <algorithm>

int main()
{
  long long a, b, c;
  scanf("%lld%lld%lld", &a, &b, &c);
  
  if ((a & b & c & 1) == 0)
  {
    puts("0");
    return 0;
  }

  long long max = std::max(a, std::max(b, c));
  long long min = std::min(a, std::min(b, c));
  long long mid = a + b + c - max - min;
  printf("%lld\n", mid * min);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
#define X first
#define Y second
vector<int> B[100010];
P A[100010];
int main(){
	while(1){
		int an,bn,r,ans=0,n=0;
		int x,y;
		vector<int>::iterator it1;
		vector<int>::iterator it2;
		cin>>an>>bn>>r;
		if(an==0 && bn==0 && r==0)
		break;
		
		for(int i=0;i<an;i++){
			cin>>x>>y;
			A[i].X=x;
			A[i].Y=y;
		}
		for(int i=0;i<100010;i++)
		B[i].clear();
		for(int i=0;i<bn;i++){
			cin>>x>>y;
			B[x].push_back(y);
		}
		for(int i=0;i<100010;i++){
			if(B[i].size())
				sort(B[i].begin(),B[i].end());
			B[i].push_back(10000);
		}
		
		for(int i=0;i<an;i++){
			for(int j=-4*r;j<=4*r;j++){
				n=sqrt(4*r*4*r-j*j);
				if(A[i].X+j>=0 && A[i].X+j<=10000 && B[A[i].X+j].size()){
					it1=lower_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),A[i].Y-n);
					
					it2=upper_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),A[i].Y+n);
					
					if(B[A[i].X+j].begin()<=it1  && it1< B[A[i].X+j].end() && B[A[i].X+j].begin() <=it2 && it2 < B[A[i].X+j].end()){
						ans+=it2-it1;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 8736
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
constexpr int INF = 1 << 30;
constexpr int MOD = 1e9 + 7;

vector<int> g[101];
int deg[101];

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  int V, E, x , y; cin >> V >> E;

  REP(i, E) {
    cin >> x >> y;
    g[x].push_back(y);
    ++deg[y];
  }

  queue<int> q;
  REP(i, V) if(deg[i] == 0) q.push(i);
  vector<int> sorted;
  while(q.size()) {
    int v = q.front(); q.pop();
    sorted.push_back(v);
    for(int nv : g[v]) {
      --deg[nv];
      if(deg[nv] == 0) q.push(nv);
    }
  }
  cout << (sorted.size() != V) << endl;

  return 0;
}


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

int main(){
int c[6],s[6],ans=0;
string a[7];
a[0]="null";
a[1]="one pair";
a[2]="two pair";
a[3]="three card";
a[4]="straight";
a[5]="full house";
a[6]="four card";
while(scanf("%d,%d,%d,%d,%d",&c[0],&c[1],&c[2],&c[3],&c[4])!=EOF){
ans=0;
for(int i=0;i<5;i++)s[i]=100;
s[0]=c[0];
for(int i=1;i<5;i++){
for(int j=i-1;j>-1;j--){
if(s[j]<=c[i]){
for(int k=i;k>j+1;k--)s[k]=s[k-1];
s[j+1]=c[i];
break;}}
if(s[0]>c[i]){
for(int k=i;k>0;k--)s[k]=s[k-1];
s[0]=c[i];}}
if(s[0]==s[1]||s[1]==s[2]||s[3]==s[4]||s[2]==s[3])ans=1;
if((s[0]==s[1]||s[1]==s[2])&&(s[2]==s[3]||s[3]==s[4]))ans=2;
if(s[0]==s[2]||s[1]==s[3]||s[2]==s[4])ans=3;
if(s[2]+1==s[3]&&s[1]+1==s[2]&&s[3]+1==s[4]&&(s[0]+1==s[1]||(s[0]==1&&s

[4]==13)))ans=4;
if((s[0]==s[2]&&s[3]==s[4])||(s[0]==s[1]&&s[2]==s[4]))ans=5;
if(s[0]==s[3]||s[1]==s[4])ans=6;

for(int i=0;i<7;i++){if(ans==i)cout<<a[i]<<endl;}

}

}

Measured memory_bytes: 1216
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int[] nmm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[][] abcs = Enumerable.Repeat(0, nmm[0]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        //Cには混合比がM:M
        //Ag、Bg作るのに必要な最小価格
        //10gが40個→400g*400gのテーブル(160000)*40回
        int[][] dp = Enumerable.Repeat(0, 401).Select(x => Enumerable.Repeat(int.MaxValue / 2, 401).ToArray()).ToArray();
        dp[0][0] = 0;
        for (int p = 0; p < abcs.Length; p++)
        {
            int[] item = abcs[p];
            int[][] newdp = Enumerable.Repeat(0, 401).Select(x => Enumerable.Repeat(int.MaxValue / 2, 401).ToArray()).ToArray();
            for (int i = 0; i < 401; i++)
            {
                for (int j = 0; j < 401; j++)
                {
                    if (i < item[0] || j < item[1]) newdp[i][j] = dp[i][j];
                    else newdp[i][j] = Min(dp[i - item[0]][j - item[1]] + item[2], dp[i][j]);
                }
            }
            dp = newdp;
        }
        int min = int.MaxValue;
        int m1 = nmm[1];
        int m2 = nmm[2];
        for (int i = 1; m1 * i < 401 && m2 * i < 401; i++)
        {
            min = Min(min, dp[m1 * i][m2 * i]);
        }
        Debug.WriteLine(string.Join("\n", dp.Select(x => string.Join(" ", x.Select(y => y != int.MaxValue / 2 ? "o" : "x")))));
        if (min == int.MaxValue / 2) min = -1;
        Console.WriteLine(min);
    } 
}

Measured memory_bytes: 33556
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define MAXI (1<<32)
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define SIZ 1000005
#define SIZE 200005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

/*bool comp(const pair<ll,ll>&a,const pair<ll,ll>&b){
	return a.ff<b.ff || (a.ff==b.ff && a.ss<b.ss);
}*/

//ll p[20000005]={0};
//vector<ll>ans;
/*void sieve(){
    ll i,j;
    p[0]=p[1]=1;
    for(i=2;i*i<=20000005;i++){
        if(!p[i]){
            for(j=2*i;j<20000005;j+=i){
                p[j]=1;
            }
        }
    }
    fo(i,2,20000005){
        if(!p[i]){
            ans.pb(i);
        }
    }
}*/

signed main(){ 
    IOS
    //io_set();
    string s;
    ll  c = 0;
    cin >> s;
    rep(i, sz(s)){
        if(s[i] == '1'){
            c++;
        }
    }
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int>> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define ri(a) scanf("%d", &a)
#define rii(a,b) scanf("%d %d", &a, &b)
#define riii(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define rl(a) scanf("%lld", &a)
#define rll(a,b) scanf("%lld %lld", &a, &b)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second

const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int maxN = 1e5; // CAMBIAR ESTE

// GJNM

int main(){
	int s,w;
	rii(s,w);
	if ( w>=s )
		printf("unsafe\n");
	else
		printf("safe\n");
	return 0;
}

Measured memory_bytes: 3764
/*********************
*@Author:   CKang *
*@Language: C++11    *
*********************/
#include<bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
//#define DEBUG
#define RI register int
#define endl "\n"

using namespace std;

typedef long long ll;
//typedef __int128 lll;
//const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-9;
const int INF = 0x3fffffff;
const ll LINF = 0x3fffffffffffffff;

inline ll read(){
    long long x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

int main()
{
#ifdef DEBUG
    freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout)
#endif
    //cout.tie(0);
    //ll t = read() ;
    //while(t--){}
    ll n=read(),k=read();
    ll t=n/k;
    ll ans=min(abs(n-t*k),abs(n-k*(t+1)));
    cout<<ans;
#ifdef DEBUG
    printf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif
    //cout << "Fuck You !" << endl;
    return 0;
}


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

bool isprime(int x){
	if(x==2)
		return true;
	
	if(x<2 || x%2==0)
		return false;
	
	for(int i=3; i*i<=x; i+=2){
		if(x%i==0)
			return false;
	}
	
	return true;
}

int main(){
	int n;
	cin >> n;
	
	int cnt = 0;
	
	for(int i=0; i<n; i++){
		int x;
		cin >> x;
	
		if(isprime(x)){
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3084
fun main() {
    println(nextIntList().indexOfFirst { it == 0 } + 1)
}
// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)
// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 36340
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>
#include<queue>
#include <map>

using namespace std;

int main(){

	long long int n,a,b;
	cin>>n>>a>>b;
	long long int x,y;
	x=n/(a+b);
	y=n%(a+b);
	long long int ans;
	ans = x*a+min(y,a);

	cout<<ans;
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
<?php
error_reporting(0);
//$N = explode(" ",trim(fgets(STDIN)));
list($A,$B) = explode(" ",trim(fgets(STDIN)));
$ret=0;
for($i=$A;$i<=$B;$i++) {
  if (strrev($i)==$i) $ret++;
}
printf("%d\n",$ret);


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

typedef vector<int> vi;
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define all(a) (a).begin(), (a).end()
inline int in() {int x; cin >> x; return x;}

void solve(){
  int n = in(), m = in();
  vi A(n); for (auto &a:A) a = in();
  sort(all(A));

  int lo = 0, hi = 2e5+5;
  while (hi-lo>1) {
    int mid = (lo+hi)/2;
    int cnt = 0;
    for (int a:A) cnt += A.end() - lower_bound(all(A), mid-a);
    (cnt >= m ? lo : hi) = mid;
  }
  vi S(n+1); FOR (i,0,n) S[i+1] = S[i] + A[i];
  int ans = 0;
  int cnt = 0;
  for (auto a:A) {
    int pt = lower_bound(all(A), hi - a) - A.begin();
    cnt += n - pt;
    ans += S[n] - S[pt] + (n - pt) * a;
  }
  ans += lo * (m - cnt);
  cout << ans << endl;
}

#undef int
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 1792
require 'openssl'
n, a, b = gets.split(" ").map(&:to_i)
MOD = 10**9 + 7
def pow(base,b)
  ans=1
  while b>0 do
    d = b/10
    m = b%10
    ans*=(base**m)
    ans%=MOD
    base = (base**10)%MOD
    b=d
  end
  ans
end

def C(a,b)
  if b==0||a==b
    1
  else
    b=a-b if a/2<b
    x=(a-b+1..a).inject(1){|res,i|res*i%MOD}
    y=(1..b).inject(1){|res,i|res*i%MOD}
    yn=OpenSSL::BN.new(y).mod_inverse(MOD)
    x*yn
  end
end

puts (pow(2,n) - 1 - (C(n, a) + C(n, b))) % MOD


Measured memory_bytes: 5992
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;

long long n, m, a[1009][1009], sum, cnt;

long long solve(vector<long long>A, vector<long long>B) {
	if (A < B) {
		int cnts = 0;
		while (true) {
			for (int i = 1; i < A.size(); i++) { A[i] += A[i - 1]; A[i] = min(A[i], 1000000007LL); if (A[i] == 1000000007LL && cnts >= 1) break; }
			if (A >= B) return -cnts;
			if (A.size() == 2) return -cnts - (B[1] - A[1] + A[0] - 1) / A[0];
			if (A[2] == 1000000007LL) return -cnts - (B[1] - A[1] + A[0] - 1) / A[0];
			cnts++;
		}
	}
	if (A >= B) {
		int cnts = 0;
		while (true) {
			for (int i = 1; i < B.size(); i++) { B[i] += B[i - 1]; B[i] = min(B[i], 1000000007LL); if (B[i] == 1000000007LL && cnts >= 1) break; }
			cnts++;
			if (A < B) return cnts;
			if (B.size() == 2) return cnts + (A[1] - B[1] + 1 + B[0] - 1) / B[0];
			if (B[2] == 1000000007LL) return cnts + (A[1] - B[1] + B[0] - 1) / B[0];
		}
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	bool flag = false;
	for (int i = 0; i < n - 1; i++) {
		if (a[i][0] > a[i + 1][0]) flag = true;
	}
	if (m == 1) {
		for (int i = 0; i < n - 1; i++) {
			if (a[i][0] >= a[i + 1][0]) flag = true;
		}
	}
	if (flag == true) { cout << "-1" << endl; return 0; }
	if (m == 1) { cout << "0" << endl; return 0; }
	for (int i = 1; i < n; i++) {
		if (a[i - 1][0] < a[i][0]) { cnt = 0; sum += cnt; continue; }
		vector<long long>P, Q;
		for (int j = 0; j < m; j++) P.push_back(a[i - 1][j]);
		for (int j = 0; j < m; j++) Q.push_back(a[i][j]);
		cnt += solve(P, Q); cnt = max(0LL, cnt);
		sum += cnt;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 8192
import java.util.*;
public class Main {
	public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			while (true) {
				int n = sc.nextInt();
				int w = sc.nextInt();
				int d = sc.nextInt();
				if(n == 0 && w == 0 && d== 0) break;
				ArrayList<Data> list = new ArrayList<Data>();
				list.add(new Data(w, d, 0));
				for (int i = 1; i <= n; i++) {
					int p = sc.nextInt();
					int s = sc.nextInt();
					Data tmp = list.get(p - 1);
					int nw = 0;
					int nd = 0;
					int status = 0;
					for (int j = 0; j < s; j++) {
						if (status == 0) {
							if((s - j) >= tmp.w) {
								nw = tmp.w;
								status++;
								j += tmp.w-1;
							}
							else {
								nw = (s-j);
								break;
							}
						} else if (status == 1) {
							if((s - j) >= tmp.d) {
								nd = tmp.d;
								j += tmp.d-1;
								status++;
							}
							else {
								nd = (s-j);
								break;
							}
							
						} else if (status == 2) {
							if((s - j) >= tmp.w) {
								nw = 0;
								j += tmp.w-1;
								status++;
							}
							else {
								nw = nw - (s-j);
								break;
							}

						} else {
							if( (s - j) >= tmp.d) {
								nd = 0;
								j += tmp.d-1;
								status = 0;
							}
							else {
								nd = nd - (s-j);
								break;
							}

						}
					}

					if (status == 0 || status == 2) {
						Data p1 = new Data(nw, tmp.d, i);
						Data p2 = new Data(tmp.w - nw, tmp.d, i);
						if (p1.d * p1.w < p2.d * p2.w) {
							list.add(p1);
							list.add(p2);
						} else {
							list.add(p2);
							list.add(p1);
						}
					} else {
						Data p1 = new Data(tmp.w, nd, i);
						Data p2 = new Data(tmp.w, tmp.d - nd, i);
						if (p1.d * p1.w < p2.d * p2.w) {
							list.add(p1);
							list.add(p2);
						} else {
							list.add(p2);
							list.add(p1);
						}
					}
					list.remove(p - 1);

				}
				Collections.sort(list, new MyComp());
				System.out.print(list.get(0).d * list.get(0).w);
				for (int i = 1; i < list.size(); i++) {
					System.out.print(" ");
					System.out.print(list.get(i).d * list.get(i).w);
				}
				System.out.println();
			}
			
	}
	
	static class Data {
		int w;
		int d;
		int t;
		Data(int a, int b, int c) {
			w = a;
			d = b;
			t = c;
		}
	}
	
	static class MyComp implements Comparator<Data> {

		@Override
		public int compare(Data o1, Data o2) {
			return o1.d*o1.w - o2.d*o2.w;
		}
		
	}
}

Measured memory_bytes: 53828
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
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 main(){
    int n;cin>>n;
    int x =n%1000;
    if(x==0){
        cout<<0<<endl;
        return 0;
    }
    cout<<1000-x<<endl;


}

Measured memory_bytes: 3620
/*    FAILING IS AN ART
       AND 
     I HAVE MASTERED IT
*/
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 

    fast;

    ll n;
    cin>>n;

    ll x[n];
    for(ll i=0;i<n;i++)
        cin>>x[i];

    ll ans=inf;
    for(ll i=0;i<=101;i++)
    {
        ll z=0;
        for(ll j=0;j<n;j++)
        {
            ll add=abs(x[j]-i);
            add*=add;
            z+=add;
        }

        if(z<ans)
            ans=z;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
S = list(input())
n = len(S)

count = 0
if S[0] != "A" or not S[1].islower() or not S[-1].islower():
    print("WA")
else:
    count = 0
    for i in range(2, n-1):
        c = S[i]
        if c == "C":
            if count == 1:
                print("WA")
                break
            else:
                count = 1
        elif not c.islower():
            print("WA")
            break
    else:
        if count == 1:
            print("AC")
        else:
            print("WA")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pri 1000000000
using namespace std;

int main() {
	ll n,w;
    cin>>n>>w;
    ll dp[w+1]={0};
    for(ll i=1;i<=n;i++){
    	ll na,wa;
    	cin>>wa>>na;
    	for(ll j=w;j>=0;j--){
    	if(j-wa>=0)dp[j]=max(dp[j-wa]+na,dp[j]);
    	}
    }
    ll maxi=0;
    for(ll i=0;i<=w;i++){
    	maxi=max(maxi,dp[i]);
    }
    cout<<maxi<<endl;
    
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

vp prime_factorize(int n){
    vp ret;
    for(int p=2; p*p<=n; p++){
        if(n%p!=0) continue;
        int num=0;
        while(n%p==0){
            num++;
            n/=p;
        }
        ret.PB(MP(p,num));
    }
    if(n!=1) ret.PB(MP(n,1));
    return ret;
}

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

    int a,b; cin >> a >> b;
    int g=gcd(a,b);
    vp pf=prime_factorize(g);

    int res=1;
    for(auto p:pf){
        if(p.F>0) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3632
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

a = [0] + a
now = 1
cities = [now]
done = set()
done.add(now)
for i in range(n):
    now = a[now]
    if now in done:
        break
    done.add(now)
    cities.append(now)
idx_s = cities.index(now)
# print(idx_s)
f = (len(cities) - idx_s)
# print(f)
if k > idx_s:
    d = k - idx_s
    idx = d%f
    ans = cities[idx + idx_s]
    print(ans)
else:
    print(cities[k])

Measured memory_bytes: 126680
#include<iostream>
#include<string>
using namespace std;
int main(){
 string s,t;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <map>
using namespace std;
map<int, int> sticks;
int v, n;
int bes = 0;
int secondbes = 0;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v;
		sticks[v]++;
	}
	for (map<int, int>::reverse_iterator it = sticks.rbegin(); it != sticks.rend(); it++) {
		if (!bes && it->second >= 2) {
			bes = it->first;
			it->second -= 2;
		}
		if (!secondbes && it->second >= 2)
			secondbes = it->first;
		if (bes && secondbes)
			break;
	}
	if (!secondbes)
		cout << "0" << endl;
	else cout << bes * (long long int)secondbes << endl;
}

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

int main(){
    #define int long long int
    int n, k;
    cin >> n;
    cin >> k;
    int h[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    sort(h, h+n);
    int result = h[k-1] - h[0];
    for(int i=1;i<n-k+1;i++){
        if(h[i+k-1] - h[i] < result){
            result = h[i+k-1] - h[i];
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

typedef long long ll;
using namespace std;

int main(){
    int i,j;
    int n,a,b;
    cin>>n>>a>>b;
    int R=min(a,b);
    int L=max(0,a+b-n);

    cout<<R<<" "<<L<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int N;
  string s;
  cin>>N>>s;
  //vector<string> s1={"SS","WW","SW","WS"};
  string s1[4]={"SS","WW","SW","WS"};

  rep(x,4){
    reps(i,1,N-1){
      s1[x]+=( !(s1[x][i]==s1[x][i-1]) xor (s[i]=='o') ? 'S' : 'W' );
    }

    if( ( (s1[x][0]==s1[x][N-2]) xor (s[N-1]=='o') xor s1[x][N-1]=='S') and ( (s1[x][N-1]==s1[x][1]) xor (s[0]=='o') xor s1[x][0]=='S' ) ){
      cout << s1[x] <<"\n";
      return;
    }

  }

  cout << -1 <<"\n";
}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

int main() {
  int arr[3];
  for (int i = 0; i < 3; ++i) std::cin >> arr[i];

  std::sort(arr, arr+3);

  std::cout << arr[0] << " " << arr[1] << " " << arr[2] << std::endl;
  

  return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
#define y1 yyy1
#define y2 yyy2
int x1,y1,x2,y2,n;
pii ps[SZ];
ld pi=acos(-1);
int bs[SZ];
void upd(int x,int y)
{
	for(;x<=n;x+=x&-x) bs[x]=max(bs[x],y);
}
int qmax(int x)
{
	int ans=-1e9;
	for(;x>=1;x-=x&-x) ans=max(ans,bs[x]);
	return ans;
}
#define yn yyn
int ys[SZ],yn=0;
int lis[SZ];
int main()
{
	memset(bs,-127/3,sizeof bs);
	scanf("%d%d%d%d%d",&x1,&y1,&x2,&y2,&n);
	for(int i=1;i<=n;++i)
		scanf("%d%d",&ps[i].fi,&ps[i].se);
	if(x1>x2)
	{
		x1*=-1; x2*=-1;
		for(int i=1;i<=n;++i)
			ps[i].fi*=-1;
	}
	if(y1>y2)
	{
		y1*=-1; y2*=-1;
		for(int i=1;i<=n;++i)
			ps[i].se*=-1;
	}
	ps[++n]=pii(x1,y1);
	ps[++n]=pii(x2,y2);
	sort(ps+1,ps+1+n);
	for(int i=1;i<=n;++i)
		ys[++yn]=ps[i].se;
	sort(ys+1,ys+1+yn);
	int yy1=lower_bound(ys+1,ys+1+yn,y1)-ys;
	int yy2=lower_bound(ys+1,ys+1+yn,y2)-ys;
	for(int i=1;i<=n;++i)
		ps[i].se=lower_bound(ys+1,ys+1+yn,ps[i].se)-ys;
	int rr=0;
	for(int i=1;i<=n;++i)
	{
		lis[i]=qmax(ps[i].se)+1;
		if(ps[i]==pii(x1,yy1)) lis[i]=0;
		else if(ps[i]==pii(x2,yy2)) rr=lis[i]-1;
		upd(ps[i].se,lis[i]);
	}
	ld ans=(x2-x1)+(y2-y1);
	ans*=100.0;
	ans+=(pi-4)*5*rr;
	if(rr==min(x2-x1+1,y2-y1+1)&&rr)
		ans+=pi*5;
	printf("%.20lf\n",ans);
}


Measured memory_bytes: 9344
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var inputs = ReadLongs();

        var K = inputs[0];
        var A = inputs[1];
        var B = inputs[2];

        if (B - A < 3) { Console.WriteLine(K + 1L); return; }

        var change = (K - (A - 1L)) / 2L;
        var odd = (K - (A - 1L)) % 2L;

        Console.WriteLine(change * (B - A) + A + odd);
    }

    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}

Measured memory_bytes: 13396
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

int n, m, p[100005];
string s[100005];
map<int, vector<string>> memo;

int main() {
  cin >> n >> m;
  vector<string> emp;
  for (int i = 0; i < m; i++) {
    cin >> p[i] >> s[i];
    memo[p[i]].push_back(s[i]);
  }

  int ans = 0, pen = 0;

  for (int i = 1; i <= n; i++) {
    if (memo.count(i)) {
      int wa = 0;
      for (auto j = memo[i].begin(); j != memo[i].end(); j++) {
        if (*j == "AC") {
          ans++;
          pen += wa;
          break;
        }
        if (*j == "WA") {
          wa++;
        }
      }
    }
  }

  cout << ans << " " << pen << endl;
}

Measured memory_bytes: 19512
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;



int main (){
  int a,b,c,x,y;
  int sum = 0;

  cin >>a>>b>>c>>x>>y;

  if (x > y){
    if((a+b) > 2*c){
      sum += 2*c*y;
      if(a < c*2){
      sum += a*(x-y);
    }else{
      sum += c*2*(x-y);
    }
    }else{
      sum += a*x+b*y;
    }

  }else{
    if((a+b) > 2*c){
      sum += 2*c*x;
      if(b < c*2){
      sum += b*(y-x);
    }else{
      sum += c*2*(y-x);
    }
    }else{
      sum += a*x+b*y;
    }

  }


  std::cout << sum << '\n';


  return 0;


}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vl b(n);
    for (int i = 0; i < n - 1; ++i) {
        cin >> b[i];
    }
    ll ret = b[0] + b[n - 2];
    for (int i = 1; i < n - 1; ++i) {
        ret += min(b[i - 1], b[i]);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        Pattern p=Pattern.compile("the|this|that");
        String str;
        
            while((str=br.readLine())!=null){
                char[] ch=str.toCharArray();
                for(int j=0;!p.matcher(String.valueOf(ch)).find()&&j<26;j++){
                    for(int i=0;i<ch.length;i++){
                        if('a'<=ch[i]&&ch[i]<'z'){
                            ch[i]++;
                        }else if(ch[i]=='z'){
                            ch[i]='a';
                        }
                    }
                    if(p.matcher(String.valueOf(ch)).find()){
                        break;
                    }
                }
                System.out.println(ch);
            }
        
    }
}

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

int main(int argc, char const *argv[]) {
    string S;
    cin >> S;

    if (S == "SAT") cout << 1 << endl;
    else if (S == "FRI") cout << 2 << endl;
    else if (S == "THU") cout << 3 << endl;
    else if (S == "WED") cout << 4 << endl;
    else if (S == "TUE") cout << 5 << endl;
    else if (S == "MON") cout << 6 << endl;
    else cout << 7 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))

int main(void)
{
	int n;
	scanf("%d",&n);
	int i;
	for(i = 0;i < n;i++)
	{
		double xa,ya,ra,xb,yb,rb;
		scanf("%lf%lf%lf%lf%lf%lf",&xa,&ya,&ra,&xb,&yb,&rb);
		double dsq = (xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
		if(dsq > ((ra+rb)*(ra+rb)))
		{
			puts("0");
		}
		else if(((ra-rb)*(ra-rb)) <= dsq)
		{
			puts("1");
		}
		else if(ra > rb)
		{
			puts("2");
		}
		else
		{
			puts("-2");
		}
	}
	return 0;
}

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



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

int main() {
	string c[2];

	for (int i = 0; i < 2; i++) {
		cin>>c[i];
	}

	
	if (c[0][0] == c[1][2] && c[1][0] == c[0][2] && c[1][1] == c[0][1]) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> mp;
ll n,a,ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        mp[a]++;
    }
    for(auto x:mp){
        ans+=x.second-1;
    }
    if(ans%2==0)cout<<n-ans<<endl;
    else cout<<n-ans-1<<endl;
    
}


Measured memory_bytes: 6528