akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        
        int distance1 = Math.abs(a-b);
        int distance2 = Math.abs(b-c);
        int distance3 = Math.abs(a-c);

        if(distance1 <= d && distance2 <= d || distance3 <= d){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

typedef pair<int, int> pii;

int a, b, c, d, e, f;

bool cmp(pii a, pii b) {
    return a.first * b.second < b.first * a.second;
}

vector<vector<pii> > cc;
pii dp(int w, int s) {
    pii &ret = cc[w][s];
    if(ret != pii(-1, -1)) return ret;

    ret = pii(s, 100*w + s);
    if(100*w + s + 100*a <= f && cmp(ret, dp(w + a, s))) ret = dp(w + a, s);
    if(100*w + s + 100*b <= f && cmp(ret, dp(w + b, s))) ret = dp(w + b, s);
    if(100*w + s + c <= f && s + c <= e*w && cmp(ret, dp(w, s + c))) ret = dp(w, s + c);
    if(100*w + s + d <= f && s + d <= e*w && cmp(ret, dp(w, s + d))) ret = dp(w, s + d);
    return ret;
}

int main() {
    cin >> a >> b >> c >> d >> e >> f;

    cc = vector<vector<pii> >(32, vector<pii>(3010, pii(-1, -1)));
    pii ans = dp(a, 0);
    if(100*b <= f && cmp(ans, dp(b, 0))) ans = dp(b, 0);
    printf("%d %d", ans.second, ans.first);
}


Measured memory_bytes: 1024
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e7 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n , m ;
    cin >> n >> m ; 
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int N, Y;
	cin >> N >> Y;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N - i; j++) {
			int k = N - i - j;
			if (k < 0) continue;
			if (10000 * i + 5000 * j + 1000 * k == Y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string s;
  int a;
  size_t pos = 0;
  int cnt = 0;
  cin >> a >> s;
  while(1)
  {
    pos = s.find("ABC",pos);
    if(pos == -1)
    {
      break;
    }
    else
    {
      cnt++;
      pos++;
    }
  }

  cout << cnt;


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll gcd(ll x, ll y) {
    if(y == 0) {
        return x;
    }
    return gcd(y, x%y);
}

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

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

    vl L(n);  // L[i] : aの左からi個の数のgcd
    L[1] = a[0];
    exrep(i, 1, n-2) {
        L[i+1] = gcd(L[i], a[i]);
    }

    vl R(n);  // R[i] : aの右からi個の数のgcd
    R[1] = a[n-1];
    exrep(i, 1, n-2) {
        R[i+1] = gcd(R[i], a[(n-1) - i]);
    }

    ll ans = max(L[n-1], R[n-1]);
    exrep(i, 1, n-2) {
        chmax(ans, gcd(L[i], R[(n-1) - i]));
    }
    
    out(ans);
    re0;
}

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

int main()
{
  string s;
  cin >> s;
  for(int i = 0; i < 5; i++)
  {
    cout << s[i];
  }
  cout << " ";
  for(int i = 6; i < 13; i++)
  {
    cout << s[i];
  }
  cout << " ";
  for(int i = 14; i < 19; i++)
  {
    cout << s[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e2 + 5;

int n;
double x, a, b;
priority_queue<double, vt<double>, greater<double>> pq;

void solve() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> x;
        pq.push(x);
    }
    while(pq.size() > 1) {
        a = pq.top(); pq.pop();
        b = pq.top(); pq.pop();
        pq.push((a + b) / 2);
    }
    cout << setprecision(5) << pq.top() << "\n";
}

int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll ac, wa, tle, re, n;
    ac = 0;
    wa = 0;
    tle = 0;
    re = 0;
    string tmp;
    cin >> n;
    REP(i, n){
        cin >> tmp;
        if(tmp == "AC"){
            ac ++;
        }else if(tmp == "WA"){
            wa ++;
        }
        else if(tmp == "TLE"){
            tle ++;
        }
        else if(tmp == "RE"){
            re ++;
        }
    }

    cout << "AC x "  << ac <<"\n";
    cout << "WA x "  << wa <<"\n";
    cout << "TLE x "  << tle <<"\n";
    cout << "RE x "  << re <<"\n";
	return 0;
}

Measured memory_bytes: 3656
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
      
      int y = Math.abs(x-a);
      int z = Math.abs(x-b);
       
      if(y<z){
        System.out.print("A");
      }else{
        System.out.print("B");
      }

    }
}

Measured memory_bytes: 21844
import java.io.*;
import java.util.regex.*;
class Main{
	public static void main(String[]args){
		try{
			Pattern pat=Pattern.compile("A.*?Z");
			Matcher mat=pat.matcher(new BufferedReader(new InputStreamReader(System.in)).readLine());
			boolean f=false;
			for(;mat.find();){
				f=true;
				System.out.print("AZ");
			}
			System.out.println(f?"":"-1");
		}catch(IOException e){}
	}
}

Measured memory_bytes: 17088
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>

using namespace std;
using ll = long long;

const int N = 2e5 + 5;
const int M = 35;

ll dp[N][M];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    ll t;
    cin >> n >> t;
    vector<pair<ll, ll>> s(n);
    for (auto& p : s) {
        cin >> p.first >> p.second;
    }
    sort(s.begin(), s.end(), [](auto a, auto b) {
        return a.first * (b.second + 1) > b.first * (a.second + 1) ||
               (a.first * (b.second + 1) == b.first * (a.second + 1) && a.second < b.second);
    });
    for (int i = 0; i < n; i++) {
        fill(dp[i] + 1, dp[i] + M, t + 1);
    }
    dp[0][1] = min(t + 1, 1 + s[0].first + s[0].second);
    int last = 0;
    for (int i = 1; i < n; i++) {
        if (s[i].first == 0) {
            break;
        }
        last = i;
        copy(dp[i - 1], dp[i - 1] + M, dp[i]);
        for (int j = 1; j < M; j++) {
            dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + 1 + (dp[i - 1][j - 1] + 1) * s[i].first + s[i].second);
        }
    }
    int ans = 0;
    for (int j = 1; j < M; j++) {
        if (dp[last][j] <= t) {
            ans = j;
        }
    }
    ll acc = 0;
    for (int i = last + 1; i < n; i++) {
        acc += s[i].second + 1;
        for (int j = 0; j < M; j++) {
            if (dp[last][j] + acc <= t) {
                ans = max(ans, j + i - last);
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 58112
#include<iostream>
#include<algorithm>
using namespace std;
#include<cmath>
#define int long long int
#define mod 1000000007
int32_t main()
{
	int n;
	cin>>n;
	int j,arr[n];
	for(j=0;j<n;j++)
	   cin>>arr[j];
	for(j=0;j<n;j++)
	{
		arr[j]+=1;
	}
	int answer=1;
	int count[n+1]={3};
	count[0]=3;
	for(j=0;j<n;j++)
	{
		int val=arr[j];
		int available=count[val-1]-count[val];
		answer*=available;
		count[val]++;
		answer%=mod;
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 5236
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;
signed main(){
 
    int n,x;
    cin >> n >> x;
    int ans[2000011] = {0};
    if(x == 1 || x == 2*n-1){
        cout << "No" << endl;
        return 0;
    }
    if(x == 2){
        if(n == 2){
            cout << "Yes" << endl << 1 << endl << 2 << endl << 3 << endl;
            return 0; 
        }
        ans[n] = 4;
        ans[n-1] = 1;
        ans[n-2] = 2;
        ans[n-3] = 3;
        int j = 5;
        for(int i = 0;i < n-3;i++){
            ans[i] = j;
            j++;
        }
        for(int i = n+1;i < 2*n-1;i++){
            ans[i] = j;
            j++;
        }
    }else{
        ans[n] = x-2;
        ans[n-1] = x+1;
        ans[n-2] = x;
        ans[n-3] = x-1;
        int j = 1;
        for(int i = 0;i < n-3;i++){
            if(j == x-2)j = x+2;
            ans[i] = j;
            j++;
        }
        for(int i = n+1;i < 2*n-1;i++){
            if(j == x-2)j = x+2;
            ans[i] = j;
            j++;
        }
    }

    cout << "Yes" << endl;
    rep(i,2*n-1){
        cout << ans[i] << endl;
    }

    return 0;   
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://agc006.contest.atcoder.jp/tasks/agc006_b

Measured memory_bytes: 17152
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << 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; }

void solve() {
	int a, v, b, w, t; cin >> a >> v >> b >> w >> t;
	int dis = abs(a - b);
	if(w >= v) {
		cout << "NO" << endl;
		return;
	}
	if(dis <= (v - w) * t) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3656
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

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

int N;
queue<int> Q;
int edge[9][3] = { 0,4,8,1,5,6,2,3,7,2,3,7,0,4,8,1,5,6,1,5,6,2,3,7,0,4,8 };
string s, t;
int q;
int SA[100001];
int SB[100001];
int TA[100001];
int TB[100001];

int main(){
	cin >> s;
	cin >> t;
	cin >> q;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A')SA[i+1]++;
		else SB[i+1]++;
	}
	for (int i = 1; i <= s.size(); i++) {
		SA[i] += SA[i - 1];
		SB[i] += SB[i - 1];
	}
	for (int i = 0; i < t.size(); i++) {
		if (t[i] == 'A')TA[i+1]++;
		else TB[i+1]++;
	}
	for (int i = 1; i <= t.size(); i++) {
		TA[i] += TA[i - 1];
		TB[i] += TB[i - 1];
	}
	for (int i = 0; i < q; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int box, bag;
		box = (SA[b] - SA[a - 1])%3;
		box *= 3;
		box += (SB[b] - SB[a - 1])%3;
		bag = (TA[d] - TA[c - 1])%3;
		bag *= 3;
		bag += (TB[d] - TB[c - 1])%3;
		bool flag = true;
		for (int j = 0; j < 3; j++) {
			if (edge[box][j] == bag) {
				flag = false;
				cout << "YES\n";
			}
		}
		if (flag)cout << "NO\n";
	}
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define ull unsigned long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define ull unsigned long long 
#define sc second
#define pb push_back
#define mp make_pair
#define sp <<" "
#define all(a) (a).begin(),(a).end()
#define fi(i,a,n) for(int i=a ; i<n ; i++)
#define fd(i,n,a) for(int i=n-1 ; i>=a ; i--)
#define r0 return 0;
#define ln "\n"
#define INF (int)1e15
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);   
void solve(){
    
}
int main(){
	fast
    // ll t;cin>>t;
    // while(t--) solve();
    ll n;cin>>n;
    if(!n) cout<<1<<"\n";
    else if(n) cout<<0<<"\n";
	r0;
}


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

int main() {
	int n,a,b,now;
	cin>>n;
	now=0;
	int ans=10000000;
	for(int i=1;n-i>0;i++){
		a=i;
		b=n-i;
		while(a>0){
			now+=a%10;
			a/=10;
		}
		while(b>0){
			now+=b%10;
			b/=10;
		}
		ans=min(now,ans);
		now=0;
	}
	cout<<ans<<endl;
}


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

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define ff first
#define ss second

using ll = int64_t;
const ll inf = 2e18;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

struct Line {
	mutable ll k, m, p;
	bool operator<(const Line& o) const { return k < o.k; }
	bool operator<(ll x) const { return p < x; }
};
struct LineContainer : multiset<Line, less<>> {
	ll div(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); }
	bool isect(iterator x, iterator y) {
		if (y == end()) { x->p = inf; return false; }
		if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
		else x->p = div(y->m - x->m, x->k - y->k);
		return x->p >= y->p;
	}
	void add(ll k, ll m) {
		auto z = insert({k, m, 0}), y = z++, x = y;
		while (isect(y, z)) z = erase(z);
		if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
		while ((y = x) != begin() && (--x)->p >= y->p)
		isect(x, erase(y));
	}
	ll query(ll x) {
		assert(!empty());
		auto l = *lower_bound(x);
		return l.k * x + l.m;
	}
};

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

	int n; ll c; cin >> n >> c;
	ll h[n], f[n]; rep(i, 0, n) cin >> h[i];
	f[0] = 0;
	LineContainer L; L.add(2 * h[0], -f[0] - h[0] * h[0]);
	rep(j, 1, n) {
		f[j] = -L.query(h[j]);
		f[j] += c + h[j] * h[j];
		L.add(2 * h[j], -f[j] - h[j] * h[j]);
	}
	cout << f[n - 1];
}

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

int main() {
  vector<string> score;
  while (true) {
    int m, f, r;
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1)
      break;
    else if (m == -1 || f == -1)
      score.push_back("F");
    else if (m + f >= 80)
      score.push_back("A");
    else if (m + f >= 65)
      score.push_back("B");
    else if (m + f >= 50)
      score.push_back("C");
    else if (m + f >= 30)
      if (r >= 50)
        score.push_back("C");
      else
        score.push_back("D");
    else if (m + f < 30)
      score.push_back("F");
  }
  for (size_t i = 0; i < score.size(); i++) {
    cout << score.at(i) << endl;
  }
}


Measured memory_bytes: 3136
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            佛祖保佑       永无BUG
*/
#include<stdio.h>
#define re register
const int mod=1e9+7;
int x[100005],n;
int mul(int a,int b)
{
	return 1LL*a*b%mod;
}
int main()
{
	scanf("%d",&n);
	for(re int i=1;i<=n;++i) scanf("%d",&x[i]);
	int pre=0,cnt=0,ans=1;
	for(re int i=1;i<=n;++i)
		if(x[i]>pre) cnt++,pre+=2;
		else ans=mul(ans,cnt+1);
	for(re int i=1;i<=cnt;++i) ans=mul(ans,i);
	printf("%d",ans);
	return 0;
}

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

int gcd(int a, int b) {
	if (a < b) {
		swap(a, b);
	}
	if(a % b == 0){
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}

int main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}
	if (N == 2) {
		cout << max(vec.at(0), vec.at(1)) << endl;
	}
	else {
		int maxi = 1;
		vector<int> gcd_memorized_from_first(N - 1);
		int gcd_memorized_from_end = vec.at(N - 1);
		int G = vec.at(0);
		for (int i = 0; i < N - 1; i++) {
			G = gcd(G, vec.at(i));
			gcd_memorized_from_first.at(i) = G;
		}
        maxi = max(maxi, G);
		for (int i = 0; i < N - 2; i++) {
			gcd_memorized_from_end = gcd(vec.at(N - i - 1), gcd_memorized_from_end);
			G = gcd(gcd_memorized_from_first.at(N - i - 3), gcd_memorized_from_end);
			maxi = max(maxi, G);
		}
        G = gcd(vec.at(1), gcd_memorized_from_end);
        maxi = max(maxi, G);
		cout << maxi << endl;
	}
}


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

int main(){
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  if((A+B)==(C+D)){
    cout<<"Balanced"<<endl;
    return 0;
  }
  if((A+B)>=(C+D)){
    cout<<"Left"<<endl;
    return 0;
  }
  cout<<"Right"<<endl;
  return 0;
}


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

public class Main {

    long MOD = (long)1e9 + 7;

    void run() {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(), b = sc.nextLong();
        long c = sc.nextInt(), d = sc.nextInt();
        long m = lcm(c, d);
        long cntc = b / c - (a - 1) / c;
        long cntd = b / d - (a - 1) / d;
        long cntcd = b / m - (a - 1) / m;
        debug(cntc, cntd, cntcd);
        System.out.println(b - a + 1 - (cntc + cntd - cntcd));
    }

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

    long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(2e5 + 10), Mod(1e9 + 7);
int n, X, Y, p, q, S, c[N], w[N], min[N], cnt[N], fac[N], inv[N];
int fastpow(int x, int y)
{
	int ans = 1;
	for (; y; y >>= 1, x = 1ll * x * x % Mod)
		if (y & 1) ans = 1ll * ans * x % Mod;
	return ans;
}

int main()
{
	n = read(), X = read(), Y = read(), fac[0] = inv[0] = 1;
	for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % Mod;
	inv[n] = fastpow(fac[n], Mod - 2);
	for (int i = n - 1; i; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % Mod;
	memset(min, 0x3f, sizeof min);
	for (int i = 1; i <= n; i++)
		c[i] = read(), min[c[i]] = std::min(min[c[i]], w[i] = read());
	for (int i = 1; i <= n; i++)
		if (min[i] < min[p]) q = p, p = i;
		else if (min[i] < min[q]) q = i;
	for (int i = 1; i <= n; i++)
	{
		if (w[i] + min[c[i]] <= X) w[i] = min[c[i]];
		if (c[i] == p && w[i] + min[q] <= Y) ++S, ++cnt[c[i]];
		if (c[i] != p && w[i] + min[p] <= Y) ++S, ++cnt[c[i]];
	}
	int ans = fac[S];
	for (int i = 1; i <= n; i++) ans = 1ll * ans * inv[cnt[i]] % Mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4864
# Author: cr4zjh0bp
# Created: Sat Mar 14 11:34:11 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n, k = nin(2)

ans = 1
for i in range(n):
    ans = min(ans + k, ans * 2)

print(ans)

Measured memory_bytes: 3444
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=998244353;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
int main()
{
	int n, m; cin>>n>>m;
	set<P> st[2];
	int c[5][100001];
	int nuo[100001];
	for(int i=0; i<5; i++) fill(c[i], c[i]+n, -1);
	fill(nuo, nuo+n, -1);
	for(int i=0; i<m; i++){
		int a, b, c1;
		cin>>a>>b>>c1; a--; b--;
		if(abs(a-b)>2){
			if(st[1-c1].find(P(b, a))!=st[1-c1].end()){
				cout<<0<<endl;
				return 0;
			}
			st[c1].insert(P(a, b));
			st[c1].insert(P(b, a));
			continue;
		}
		c[2+b-a][a]=c1;
	}
	ll ans=powmod(2ll, ((ll)(n-2)*(ll)(n-3)-(ll)st[0].size()-(ll)st[1].size())/2);
	for(int i=2; i<n; i++){
		if(c[2][i-1]>=0){
			if(c[0][i]>=0 && c[4][i-2]>=0){
				if(c[2][i-1]!=(c[0][i]^c[4][i-2])){
					cout<<0<<endl;
					return 0;
				}
				continue;
			}else if(c[0][i]==-1 && c[4][i-2]==-1){
				ans*=2;
				ans%=MOD;
			}
		}else{
			if(c[0][i]>=0 && c[4][i-2]>=0){
				c[2][i-1]=(c[0][i]^c[4][i-2]);
			}else if(c[0][i]==-1 && c[4][i-2]==-1){
				ans*=2;
				ans%=MOD;
			}
		}
	}
	for(int i=1; i<n; i++){
		if(c[1][i]>=0 && c[3][i-1]>=0){
			nuo[i-1]=(c[1][i]^c[3][i-1]);
			if(c[2][i-1]>=0 && c[2][i]>=0 && nuo[i-1]!=(c[2][i-1]^c[2][i])){
				cout<<0<<endl;
				return 0;
			}
		}else if(c[1][i]==-1 && c[3][i-1]==-1){
			ans*=2;
			ans%=MOD;
		}
	}
	ll dp[4][100001]={};
	if(nuo[0]>=0){
		if(nuo[0]){
			if(c[2][0]==0) dp[2][1]=1;
			else if(c[2][0]==-1){
				if(c[2][1]==0) dp[1][1]=1;
				else if(c[2][1]==1) dp[2][1]=1;
				else dp[1][1]=dp[2][1]=1;
			}else dp[1][1]=1;
		}else{
			if(c[2][0]==0) dp[0][1]=1;
			else if(c[2][0]==-1){
				if(c[2][1]==0) dp[0][1]=1;
				else if(c[2][1]==1) dp[2][1]=1;
				else dp[0][1]=dp[3][1]=1;
			}else dp[3][1]=1;
		}
	}else{
		if(c[2][0]==-1){
			if(c[2][1]>=0) dp[(c[2][1]<<1)][1]=dp[(c[2][1]<<1)^1][1]=1;
			else dp[0][1]=dp[1][1]=dp[2][1]=dp[3][1]=1;
		}else{
			if(c[2][1]==-1) dp[2^c[2][0]][1]=dp[c[2][0]][1]=1;
			else dp[(c[2][1]<<1)^c[2][0]][1]=1;
		}
	}
	for(int i=1; i<n-1; i++){
		for(int j=0; j<4; j++){
			if(dp[j][i]==0) continue;
			for(int k=0; k<2; k++){
				if(c[2][i+1]>=0 && c[2][i+1]!=k) continue;
				if(nuo[i]>=0 && nuo[i]!=((j>>1)^k)) continue;
				dp[(k<<1)^(j>>1)][i+1]+=dp[j][i];
				dp[(k<<1)^(j>>1)][i+1]%=MOD;
			}
		}
	}
	ll ans1=(dp[0][n-1]+dp[1][n-1]+dp[2][n-1]+dp[3][n-1])%MOD;
	ans=ans*ans1%MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>

int solve(int, int);
int n, q, A[2000];

int main(){
  int i, m[2000];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &m[i]);
  }

  for(i = 0; i < q; i++){
    if(solve(0, m[i]) == 0){
      printf("yes\n");
    }
    else if(solve(0, m[i]) == 1){
      printf("no\n");
    }
  }
  
  return 0;
}

int solve(int i, int m){
  if(m == 0) return 0;

  if(i >= n) return 1;

  if(solve(i+1, m) == 0) return 0;

  return solve(i+1, m - A[i]);
}



Measured memory_bytes: 2052
N=int(input())
numlist=list(map(int,(input() for _ in range(N))))
numdict={y:x for x,y in enumerate(numlist)}
sorted_list=sorted(numdict.items(),reverse=True)

nextS=lambda Snow,child : Snow+2*child-N

amount_of_child=[1]*N
sum_of_distance_of_child=[0]*N
branch_list=[]

for S,num in sorted_list:
  nS=nextS(S,amount_of_child[num])
  if nS in numdict:
    nextnum=numdict[nS]
    branch_list.append([num+1,nextnum+1])
    amount_of_child[nextnum]+=amount_of_child[num]
    sum_of_distance_of_child[nextnum]+=(sum_of_distance_of_child[num]+amount_of_child[num])
    if amount_of_child[nextnum]==N:
      break
  else:
    print (-1)
    exit()

if sorted_list[-1][0]==sum_of_distance_of_child[sorted_list[-1][1]]:
  for _ in range(N-1):
    x,y=branch_list.pop()
    print(x,y)
else:
  print (-1)
exit()


Measured memory_bytes: 49548
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

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

int my_abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int my_abs_B(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}



const long long INF = 1LL << 60;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> syurui(200001);
    vector<int> retu(N);
    for (int i = 0; i < N; i++) {
        cin >> retu.at(i);
        syurui.at(retu.at(i))++;
    }
    int count = 0;
    int ans = 0;
    sort(syurui.begin(), syurui.end());

    for (int i = 0; i < 200001; i++) {
        if (syurui.at(i) > 0) {
            count++;
        }
    }
    int j = 200001-count;
    while (count > K) {
        count--;
        ans = ans + syurui.at(j);
        j++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import sys

class alphabet: #Trueなら大文字
    def __init__(self, capitalize):
        self.num = dict()
        self.index = dict()
        self.abc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n"\
            ,"o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
        if capitalize: 
            for i in range(26): self.abc[i] = self.abc[i].upper()
        for i, a in enumerate(self.abc):
            self.num[a] = i
            self.index[i] = a

def solve():
    input = sys.stdin.readline
    longest = 0
    AB = alphabet(False)
    ans = ""
    N = int(input())
    S = [input().strip("\n") for _ in range(N)]
    ABcount = [0] * 26
    for i in range(26):
        w = AB.index[i]
        M = 50
        for s in S:
            count = 0
            for j in range(len(s)):
                if s[j] == w: count += 1
            M = min(count, M)
        ABcount[i] = M
    Ans = ""
    for i, a in enumerate(ABcount): Ans += AB.index[i] * a
    print(Ans)
                          
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n); //各スイッチがつながってる電球
    int p;
    rep(i, m) { //各電球について
        int k; cin >> k;
        rep(j, k) {
            int s; cin >> s;
            s--;
            a[s] |= 1<<i;
        }
    }
    rep(i, m) {
        int x; cin >> x;
        p |= x<<i;
    }
    int ans = 0;
    rep(s, 1<<n) {
        int t = 0;
        rep(i, n) {
            if (s>>i & 1) {
                t ^= a[i]; //i番目のスイッチを押すとどの電球がカウントされるか
            }
        }
        if (t == p) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>

int main(){
    std::string str1;
    std::string str2;

    std::cin >> str1 >> str2;

    if(str1 == str2.erase(str2.size() - 1)){
        std::cout << "Yes";
    }
    else{
        std:: cout << "No";
    }

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll a[2],b[2],ret;
    cin>>a[0]>>a[1]>>b[0]>>b[1];
    ret = -(1LL*1e18);
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            ret=max(ret,1LL*a[i]*b[j]);
        }
    }
    if(a[0]*a[1]<0 || b[0]*b[1]<0)ret=max(ret,0LL);
    cout<<ret<<endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
#define fr(i,x) for( int i=0;i<(x);i++)
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int main() 
{ 
    int a,b,c,temp=0;
    cin>>a>>b>>c;
	temp=c;
	c=b;
	b=a;
	a=temp;
	cout<<a<<" "<<b<<" "<<c;
	return 0; 
} 


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=n1;i<(int)(n2);i++)
using namespace std;

signed main()
{
	int A;
	cin >> A;
	int B;
	cin >> B;

	int N = 0;
	int count = 1;
	while(count < B){
		count += A-1;
		N++;
	}

	cout << N;
	return 0;
}


Measured memory_bytes: 256
n = int(input())

if n <= 104:
    print(0)
    exit()
else:
    res = 0
    for i in range(105,n+1,2):
        temp = 0
        for j in range(1,i+1):
            if i %j ==0:
                temp+=1
        if temp==8:
            res+=1
print(res)

Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct UnionFind
{
  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    for(int i=0;i<n;i++) par[i] = i;
  }

  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]); 
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (sizes[x] < sizes[y]) swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return sizes[find(x)];
  }
};
int main(){
  int n,k,l;
  cin >> n >> k >> l;
  UnionFind road(n),train(n);
  for(int i=0;i<k;i++){
    int p,q;
    cin >> p >> q;
    road.unite(--p,--q);
  }
  for(int i=0;i<l;i++){
    int p,q;
    cin >> p >> q;
    train.unite(--p,--q);
  }
  map<pair<int,int>,int> mp;
  for(int i=0;i<n;i++) mp[{train.find(i),road.find(i)}]++;
  for(int i=0;i<n;i++) cout << mp[{train.find(i),road.find(i)}] << "\n";
}

Measured memory_bytes: 17524
#include <stdio.h>
#include <string.h>

int H, W, K;
char c[8][8];

int mareitaso(int hayamin) {
	int i, j;
	char tomatu[8][8];
	int sintasu = 0;
	memcpy(tomatu, c, sizeof(tomatu));
	for (i = 0; i < H; i++) {
		if ((hayamin >> i) & 1) {
			for (j = 0; j < W; j++) tomatu[i][j] = '*';
		}
	}
	for (j = 0; j < W; j++) {
		if ((hayamin >> (H + j)) & 1) {
			for (i = 0; i < H; i++) tomatu[i][j] = '*';
		}
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (tomatu[i][j] == '#') sintasu++;
		}
	}
	return sintasu == K;
}

int main(void) {
	int i;
	int asumisu;
	int kitaeri = 0;
	if (scanf("%d%d%d", &H, &W, &K) != 3) return 1;
	for (i = 0; i < H; i++) {
		if (scanf("%7s", c[i]) != 1) return 1;
	}
	asumisu = 1 << (H + W);
	for (i = 0; i < asumisu; i++) {
		if (mareitaso(i)) kitaeri++;
	}
	printf("%d\n", kitaeri);
	return 0;
}


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

int main()
{
  int n,k;
  cin >> n >> k;
  int a[n],s[2100000]={};
  for(int i=0;i<n;i++)
  {
    cin >> a[i];
    s[a[i]]++;
  }
  sort(s,s+2100000,greater<int>());
  int count=0;
  for(int i=k;i<n;i++)
  {
    count += s[i];
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 9216
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 200010
int p[N],n;
bool vis[N];
int nz[N],g[N];
vector<int> ch[N];
bool Solve(int val,int t){
    //cout<<"$"<<val<<" "<<t<<endl;
    int x=p[t],y=val;
    while(1){
	unordered_set<int> st;
	st.insert(y);
	for(auto i:ch[x])st.insert(g[i]);
	y=0;
	while(1){
	    if(st.find(y)==st.end())break;
	    y++;
	}
	if(x==t)break;
	x=p[x];
    }
    return val==y;
}
int main(){
    cin>>n;
    lol(i,n)nz[i]=0,vis[i]=0;
    lol(i,n){
	cin>>p[i];p[i]--;
	nz[p[i]]++;
	ch[p[i]].push_back(i);
    }
    int x=0,t;
    while(1){
	if(vis[x]){
	    t=x;break;
	}
	vis[x]=1;
	x=p[x];
    }
    x=t;
    lol(i,n)vis[i]=0,g[i]=-1;
    while(1){
	vis[x]=1;
	x=p[x];
	if(x==t)break;
    }
    queue<int> Q;
    lol(i,n)if(nz[i]==0)Q.push(i);
    while(!Q.empty()){
	x=Q.front();Q.pop();
	if(vis[x])continue;
	unordered_set<int> st;
	for(auto y:ch[x])st.insert(g[y]);
	g[x]=0;
	while(1){
	    if(st.find(g[x])==st.end())break;
	    g[x]++;
	}
	nz[p[x]]--;
	if(nz[p[x]]==0)Q.push(p[x]);
    }
    //lol(i,n)cout<<vis[i]<<" "<<g[i]<<endl;
    unordered_set<int> st;
    for(auto y:ch[t])st.insert(g[y]);
    bool ans=false;
    x=0;
    int cnt=0;
    while(cnt<2){
	if(st.find(x)==st.end()){
	    ans|=Solve(x,t);
	    cnt++;
	}
	x++;
    }
    cout<<(ans?"POSSIBLE":"IMPOSSIBLE")<<endl;
    return 0;
}


Measured memory_bytes: 12800
#include <stdio.h>

int ans = 700;
char S[3];

int main(void)
{
  scanf("%s", S);
  for(int i = 0; i < 3; ++i){
    if(S[i] == 'o') ans += 100;
  }
  
  printf("%d", ans);
  
  return 0;
}

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

int main() {
  string s;
  cin >> s;

  int ans = 0;
  for (int i = 1; 2 * i < s.size(); ++i) {
    if (s.substr(0, i) == s.substr(i, i)) ans = 2 * i;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

N = int(input())
tree = [[] for i in range(N)]
color = [-1] * N
for i in range(N-1):
  u, v, w = map(int, input().split())
  tree[u-1].append((v-1, w))
  tree[v-1].append((u-1, w))


def dfs(u):
  for v, w in tree[u]:
    if color[v] == -1:
      color[v] = color[u] ^ (w % 2)
      dfs(v)


color[0] = 0
dfs(0)
print('\n'.join(map(str, color)))

Measured memory_bytes: 79408
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         int k = int.Parse(ReadLine());
         int[] a = ReadLine().Split(' ').Select(int.Parse).ToArray();
         for(int i = a[0]; i <= a[1]; i++){
             if(i % k == 0){
                 WriteLine("OK");
                 return;
             }
         }
         WriteLine("NG");
      }
   }
}

Measured memory_bytes: 28288
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
s = [1 if x == 'o' else 0 for x in input()]

MAP = ['W', 'S']
def dump(res):
  return "".join(MAP[x] for x in res)

for p0, p1 in product(range(2), range(2)):
  res = [p0, p1] + [0] * (N - 2)
  for i in range(2, N):
    res[i] = res[i-2] ^ res[i-1] ^ s[i-1]
  if res[0] == res[-2] ^ res[-1] ^ s[-1] and res[1] == res[-1] ^ res[0] ^ s[0]:
    print(dump(res)); exit()

print(-1)

Measured memory_bytes: 6760
import java.util.*;
// import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    // System.out.println(main.solve());
    main.solve();
  }

  int n;
  Map<String, Integer> map;

  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      n = sc.nextInt();
      map = new HashMap<String, Integer>();
      for (int i = 0; i < n; i++) {
        String s = sc.next();
        if (map.containsKey(s)) {
          map.put(s, map.get(s) + 1);
        } else {
          map.put(s, 0);
        }
      }
    } finally {
      sc.close();
    }
  }

  void solve() {
    int v = maxi();
    List<String> list = new ArrayList<String>();
    for (String s: map.keySet()) {
      if (map.get(s) == v) list.add(s);
    }
    Collections.sort(list);
    for (String s: list) {
      System.out.println(s);
    }
  }

  int maxi() {
    int ans = 0;
    for (String s: map.keySet()) {
      if (ans < map.get(s)) ans = map.get(s);
    }
    return ans;
  }
}


Measured memory_bytes: 82448
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod=1000000007;
ll N;string s;
ll dp[2][10010];
int main(){
  cin>>N>>s;
  ll M=s.size();
  dp[0][0]=1;
  for(int i=1;i<=N;i++){
    for(int j=0;j<=10005;j++)
      if(j==0){
      dp[1][0]=(dp[0][0]+2*dp[0][1])%mod;
      }else{
      dp[1][j]=(dp[0][j-1]+2*dp[0][j+1])%mod;
      } for(int j=0;j<=10005;j++)
          dp[0][j]=dp[1][j];
  }
    cout<<dp[1][M]<<endl;
  return 0;
}

Measured memory_bytes: 3768
a, b, k = map(int, input().split())

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n // i)
  divisors.sort()
  return divisors

a_divs = make_divisors(a)
b_divs = make_divisors(b)

common_divs = []
for i in range(len(a_divs)):
  a_div = a_divs[i]
  if a_div in b_divs:
    common_divs.append(a_div)
print(common_divs[-k])

Measured memory_bytes: 38384
import math
 
N, D = map(int, input().split())
X, Y = [], []
for i in range(N):
  li = list(map(int,input().split()))
  X.append(li[0])
  Y.append(li[1])

ans = 0
 
for i in range(N):
  if X[i] ** 2 + Y[i] ** 2<=D ** 2:
    ans += 1

print(ans)

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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0;i < N;++i){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    auto itr = d.begin() + N/2;
    cout << *itr - *--itr << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define int long long
using namespace std;
signed main() {
	int n, m = 0, a = 0, sum = 0; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (m <= a) {
			sum++;
			m = a;
		}
	}cout << sum << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>

using namespace std;

int main(){
	map<string,int> words;
	string most,max;
	char wd[33];
	while(cin>>wd){
		string temp(wd);
		if(words.count(temp)==0)
		words[temp]=1;
		else
		words[temp]++;
		if(words[most]<words[temp])
		most=temp;
		if(max.size()<temp.size())
		max=temp;
	}
	printf("%s %s\n",most.c_str(),max.c_str());
}

Measured memory_bytes: 3184
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#define RG register
using namespace std;
const int N=1e6+10;
int n,ans;
char st[N],ed[N];
queue<int> pn;
inline int mi(int a,int b){return a<b ? a : b;}
inline int mx(int a,int b){return a>b ? a : b;}
int main()
{
//	freopen("Shik and Copying String.in","r",stdin);
	scanf("%d%s%s",&n,st+1,ed+1);
	if(!strcmp(st+1,ed+1)) return printf("0\n"), 0;
	for(int i=n,j=n;i;i--)
	{
		if(ed[i]==ed[i-1]) continue;
		j=mi(i,j);
		while(ed[i]!=st[j] && j) j--;
		if(!j) return printf("-1\n"), 0;
		while(!pn.empty())
		 if((int)pn.front()-(int)pn.size()>=i) pn.pop();
		 else break;
		pn.push(j);
		if(i!=j) ans=mx(ans,(int)pn.size());
	}
	printf("%d\n",ans+1);
	return 0;
}

Measured memory_bytes: 6272
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<Int> a(n + 1), b(n);
    for (int i = 0; i < n + 1; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    Int ans = min(a[n], b[n - 1]);
    b[n - 1] = max(b[n - 1] - a[n], (Int)0);
    for (int i = n - 1; i >= 1; i--) {
        Int killed1 = min(a[i], b[i]);
        b[i] = max(b[i] - killed1, (Int)0);
        a[i] = max(a[i] - killed1, (Int)0);

        Int killed2 = min(a[i], b[i - 1]);
        b[i - 1] = max(b[i - 1] - killed2, (Int)0);
        a[i] = max(a[i] - killed2, (Int)0);

        ans += killed1 + killed2;
    }
    ans += min(a[0], b[0]);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int H = int.Parse(str[0]);
		int W = int.Parse(str[1]);
		int N = int.Parse(str[2]);
		int[]Hm = new int[H];
		int[]Wm = new int[W];
		List<int>[]Wlist = new List<int>[W];
		Dictionary<int,int>[]WDic = new Dictionary<int,int>[W];
		for(var i=0;i<W;i++){
			Wlist[i] = new List<int>();
			WDic[i] = new Dictionary<int,int>();
		}
		for(var i=0;i<N;i++){
			string[] str2 = Console.ReadLine().Split();
			int h1 = int.Parse(str2[0]);
			int w1 = int.Parse(str2[1]);
			Wlist[w1-1].Add(h1-1);
			WDic[w1-1][h1-1] = 1;
		}
		int ha = 0;
		int wa = 0;
		Hm[0] = 0;
		Wm[0] = 0;
		while(true){
			ha += 1;
			if(wa==W){
				break;
			}
			if(ha==H){
				for(var i=wa+1;i<W;i++){
					Wm[i] = H;
				}
				break;
			}
			if(wa+1 < W && !WDic[wa+1].ContainsKey(ha)){
				wa += 1;
				Wm[wa] = ha;
			}
			Hm[ha] = wa;
		}
		//for(var i=0;i<W;i++){
		//	Console.WriteLine(Wm[i]);
		//}
		//for(var i=0;i<W;i++){
		//	for(var j=0;j<Wlist[i].Count;j++){
		//		Console.Write(Wlist[i][j]+" ");
		//	}
		//	Console.WriteLine();
		//}
		int ans = H;
		for(var i=0;i<W;i++){
			Wlist[i].Sort();
			int min = 0;
			int max = Wlist[i].Count;
			while(min<max){
				int na = (min+max)/2;
				if(Wlist[i][na] < Wm[i]){
					min = na + 1;
				} else {
					max = na;
				}
			}
			if(min < Wlist[i].Count){
				ans = Math.Min(ans,Wlist[i][min]);
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 67948