akhauriyash/Code-Regression huggingface dataset:
#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
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#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 << endl; }
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__) << "] "

const int MOD = (int)1e9 + 7;
const int MX = (int)2e5 + 10;

void add_self(int &x, int y, int md = MOD){x += y; if(x >= md) x -= md;}
void sub_self(int &x, int y, int md = MOD){x -= y; if(x < 0) x += md;}
void mul_self(int &x, int y, int md = MOD){x = x * 1LL * y % md;}
inline int mul(int x, int y, int md = MOD){return x * 1LL * y % md;}
inline int add(int x, int y, int md = MOD){x += y; if(x >= md) x -= md; return x;}
inline int sub(int x, int y, int md = MOD){x -= y; if(x < 0) x += md; return x;}

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

vector<int> read(int n, int k){
	vector<int> vec(n);
	for(int i = 0; i < k; ++i) cin >> vec[i];
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for(int i = k; i < n; ++i)
		vec[i] = (a * 1ll * vec[i - 2] + b * 1ll * vec[i - 1] + c) % d;
	return vec;
}

void solve(){
	int n;
	cin >> n;
	vector<array<int, 2>> vec(n);
	for(auto &[x, y] : vec) cin >> x >> y;
	bool ok = false;
	for(int i = 0; i + 3 <= n; ++i){
		bool here = true;
		for(int j = 0; j < 3; ++j)
			here &= vec[i + j][0] == vec[i + j][1];
		ok |= here;
	}
	cout << (ok ? "Yes" : "No") << '\n';
	return;
}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	// freopen("input.in", "r", stdin);
	// freopen("output.out", "w", stdout);

	int t;
	t = 1;
	// cin >> t;
	// pre();
	for(int i = 1; i <= t; ++i){
		// cout << "Case #" << i << ": ";
		solve();
		// cout << '\n';
		// cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
using namespace std;
#define INF 1000000005
int main()
{
long long int n,h;
std::cin >> n >> h;
std::vector<long long int> a;
std::vector<long long int> b;
long long int sum = 0;


for(long long int i = 0; i < n; i++){
    long long int tempa;
    long long int tempb;
    std::cin >> tempa >> tempb;
    a.push_back(tempa);
    b.push_back(tempb);
}
long long int index = 0;
std::sort(a.begin(),a.end(),greater<long long int>());
std::sort(b.begin(),b.end(), greater<long long int>());
while(b[index] >= a[0] && h > 0 && index < n){
    h -= b[index];
    sum++;
    index++;
}
while(h > 0){
    h -= a[0];
    sum++;
}

std::cout << sum << std::endl;

return 0;
}

Measured memory_bytes: 2036
#include <iostream>
#include <list>
#include <vector>
using namespace std;

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

  vector<list<int>> ls(n);
  for (int i = 0; i < q; ++i) {
    int q, t;
    cin >> q >> t;

    if (q == 0) {
      int x;
      cin >> x;
      ls[t].push_back(x);
    }
    if (q == 1) {
      string spc = "";
      for (auto e : ls[t]) {
        cout << spc << e;
        spc = " ";
      }
      cout << endl;
    }
    if (q == 2) {
      int s;
      cin >> s;
      swap(s, t);
      ls[t].splice(ls[t].end(), ls[s]);
    }
  }
}


Measured memory_bytes: 18756
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#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 << endl; }
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__) << "] "

using ll = long long;

const int nax = 305;
double p[nax][nax][nax], ev[nax][nax][nax];
// ev[a][b][c] - the expected number of operations so far to get to state (a,b,c)
// easier: p-bility of getting to this state at all

int main() {
    int n;
    scanf("%d", &n);
    vector<int> cnt(4);
    for(int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        ++cnt[x];
    }
    p[cnt[1]][cnt[2]][cnt[3]] = 1;
    for(int c = n; c >= 0; --c) {
        for(int b = n; b >= 0; --b) {
            for(int a = n; a >= 0; --a) {
                if(a == 0 && b == 0 && c == 0) {
                    continue;
                }
                if(a + b + c > n) {
                    continue;
                }
                // dp[a][b][c]
                
                double p_waste = (double) (n - (a + b + c)) / n;
                // p_waste + p_waste^2 + ... = S
                // 1 + S = S / p_waste
                double ev_waste = p_waste / (1 - p_waste) + 1;
                debug() << imie(a) imie(b) imie(c) imie(ev_waste);
                ev[a][b][c] += ev_waste * p[a][b][c];
                
                // remove 1 -> dp[a-1][b][c]
                // we will eventually choose one of a+b+c
                if(a != 0) {
                    double p_go = (double) a / (a + b + c);
                    p[a-1][b][c] += p[a][b][c] * p_go;
                    ev[a-1][b][c] += ev[a][b][c] * p_go;
                }
                
                // remove 2 -> dp[a+1][b-1][c]
                if(b != 0) {
                    double p_go = (double) b / (a + b + c);
                    p[a+1][b-1][c] += p[a][b][c] * p_go;
                    ev[a+1][b-1][c] += ev[a][b][c] * p_go;
                }
                
                // remove 3
                if(c != 0) {
                    double p_go = (double) c / (a + b + c);
                    p[a][b+1][c-1] += p[a][b][c] * p_go;
                    ev[a][b+1][c-1] += ev[a][b][c] * p_go;
                }
            }
        }
    }
    printf("%.10lf\n", ev[0][0][0]); // + cnt[1] + 2 * cnt[2] + 3 * cnt[3]);
}

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

using namespace std;

typedef long long ll;
#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<(n); i++)

int main() {
    string s;
    cin >> s;
    int ans = INT_MAX;
    rep(i, s.size()-2) ans = min(ans, abs(atoi(s.substr(i, 3).c_str())-753));
    cout << ans << endl;
}


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

int main(){
    int A,B;
    cin>>A>>B;
    if(A==1) A=14;
    if(B==1) B=14;
    cout<<((A==B)? "Draw" : ((A>B)? "Alice" : "Bob" ) )<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(M)]
PY_org = PY[:]

PY.sort(key=lambda py: py[1])

p_to_c_list = {}
for i in range(M):
    if p_to_c_list.get(PY[i][0]) == None:
        p_to_c_list[(PY[i][0])] = {'count': 1, 'city': {PY[i][1]: 1}}
    else:
        p_to_c_list[(PY[i][0])]['count'] += 1
        current_i = p_to_c_list[(PY[i][0])]['count']
        p_to_c_list[(PY[i][0])]['city'][PY[i][1]] = current_i

for py in PY_org:
    print('{:06}{:06}'.format(py[0], p_to_c_list[py[0]]['city'][py[1]]))


Measured memory_bytes: 84252
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main() {
 
	string str,str2;
    string a,b,c,d,e,f;
    
    cin >>  str >> str2 ;
 
    a = str.front();
    b = str.substr(1,1);
    c = str.back();
    d = str2.front();
    e = str2.substr(1,1);
    f = str2.back();
    
    if(a==f && b==e && c==d){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
    
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 500;
const int M = 64;

int n;
int S[N], T[N];
ull U[N], V[N];
ull ans[N][N];

int mat[M][N][N];
int sr[N], sc[N];

int pt(int t, ull v, int k) {
    return (t << 1) | ((v & (1llu << k)) ? 1 : 0);
}

void fill(int k) {
    for (int r = 0; r < n; ++r) {
        if (pt(S[r], U[r], k) == 1) {
            for (int c = 0; c < n; ++c) {
                mat[k][r][c] = 1;
            }
        }
    }

    for (int c = 0; c < n; ++c) {
        if (pt(T[c], V[c], k) == 1) {
            for (int r = 0; r < n; ++r) {
                mat[k][r][c] = 1;
            }
        }
    }

    memset(sr, 0, sizeof(sr));
    memset(sc, 0, sizeof(sc));

    for (int r = 0; r < n; ++r) {
        for (int c = 0; c < n; ++c) {
            sr[r] += mat[k][r][c];
            sc[c] += mat[k][r][c];
        }
    }

    for (int r = 0; r < n; ++r) {
        for (int c = 0; c < n; ++c) {
            // OR1 OR1
            if (pt(S[r], U[r], k) == 3 && pt(T[c], V[c], k) == 3) {
                mat[k][r][c] = 1;
                ++sr[r]; ++sc[c];
            } else 
            // AND0 OR1
            if (pt(S[r], U[r], k) == 0 && pt(T[c], V[c], k) == 3) {
                if (mat[k][r][c] == 0 && sc[c] == 0 && sr[r] < n - 1) {
                    mat[k][r][c] = 1;
                    ++sr[r]; ++sc[c];
                }
            } else
            // OR1 AND0
            if (pt(S[r], U[r], k) == 3 && pt(T[c], V[c], k) == 0) {
                if (mat[k][r][c] == 0 && sr[r] == 0 && sc[c] < n - 1) {
                    mat[k][r][c] = 1;
                    ++sr[r]; ++sc[c];
                }
            }
        }
    }
}

void cal() {
    for (int r = 0; r < n; ++r) {
        for (int c = 0; c < n; ++c) {
            for (int k = M - 1; k >= 0; --k) {
                ans[r][c] = (ans[r][c] << 1) | mat[k][r][c];
            }
        }
    }
}

bool check() {
    for (int r = 0; r < n; ++r) {
        ull v = ans[r][0];
        for (int c = 1; c < n; ++c) {
            v = S[r] == 0 ? (v & ans[r][c]) : (v | ans[r][c]);
        }
        if (v != U[r]) {
            return false;
        }
    }

    for (int c = 0; c < n; ++c) {
        ull v = ans[0][c];
        for (int r = 1; r < n; ++r) {
            v = T[c] == 0 ? (v & ans[r][c]) : (v | ans[r][c]); 
        }
        if (v != V[c]) {
            return false;
        }
    }
    return true;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d", &S[i]);
    for (int i = 0; i < n; ++i) scanf("%d", &T[i]);
    for (int i = 0; i < n; ++i) scanf("%llu", &U[i]);
    for (int i = 0; i < n; ++i) scanf("%llu", &V[i]);

    for (int k = 0; k < M; ++k) {
        fill(k);
    }

    cal();

    if (check()) {
        for (int r = 0; r < n; ++r) {
            for (int c = 0; c < n; ++c) {
                printf("%llu%c", ans[r][c], c == n - 1 ? '\n' : ' ');
            }
        }
    } else {
        printf("-1");
    }

    return 0;
}

Measured memory_bytes: 65920
def gcd(a,b):
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)
  
  

n = int(input())
s = [int(x) for x in input().split()]
tmp= s[0]
for i in s[1:]:
  tmp = gcd(tmp,i)
 
print(tmp)


Measured memory_bytes: 14224
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

int n, m;

int eratos(int m, int n){
    const int maxnum = 8000000;
    int ret;
    vector<int> primeVec;
    vector<bool> isPrime(maxnum+1, true);
    REP(i, m) isPrime[i] = false;
    for(int p = m; p <= maxnum; p++){
        if(isPrime[p]){
            for(int i = p*2; i <= maxnum; i += p) isPrime[i] = false;
        }
    }
    for(int p = m; p <= maxnum; p++) if(isPrime[p]) primeVec.pb(p);
    
    return primeVec[n];
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        cin >> m >> n;
        if(n == 0 && m == 0) break;
        cout << eratos(m, n) << endl;
    }
}



Measured memory_bytes: 10036
S = input()

front = int(S[0:2])
back = int(S[2:4])
if 0 < front <= 12 and 0 < back <= 12:
    print('AMBIGUOUS')
elif (front == 0 or front > 12) and 0 < back <= 12:
    print('YYMM')
elif 0 < front <= 12 and (back == 0 or back > 12):
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  1000007
#define md 1000000007ll
///////////////////////////
///////////////////////////

int main(){
    string a, b;
    cin>>a>>b;
    string k;

    for(int i = 0; i < a.size(); i++) {
        string l;
        for(int j=i; j<a.size(); j++)l+=a[j];

        if(l+k ==b) {
            cout<<"Yes"<<endl;
            return 0;
        }
                k+= a[i];
    }

    cout<<"No"<<endl;
    return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    cout << max(0, A - 2 * B) << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if((b * 10 + c) % 4 == 0)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = INF;
	int tmp;
	string s;
	cin >> s;
	tmp = 0;
	REP(i, s.size()) if(i % 2 == s[i] - '0') tmp ++;
	ans = min(tmp, ans);
	tmp = 0;
	REP(i, s.size()) if(i % 2 != s[i] - '0') tmp ++;
	ans = min(tmp, ans);
	
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
	int N,x;
	get(N,x);
	if(N==2){
		if(x==2){
			print("Yes");
			print(1);
			print(2);
			print(3);
		}else{
			print("No");
		}
	}else{
		if(x==1||x==2*N-1){
			print("No");
		}else{
			print("Yes");
			vector<int> ans(2*N-1);
			unordered_set<int> used;
			FORIN(i,1,2*N)used.insert(i);
			if(x<N){
				ans[N-1]=x;
				ans[N-2]=x-1;
				ans[N-3]=x+1;
				ans[N]=x+2;
				used.erase(x);
				used.erase(x-1);
				used.erase(x+1);
				used.erase(x+2);
			}else{
				ans[N-1]=x;
				ans[N-2]=x+1;
				ans[N-3]=x-1;
				ans[N]=x-2;
				used.erase(x);
				used.erase(x+1);
				used.erase(x-1);
				used.erase(x-2);
			}
			int i=0;
			for(int v:used){
				while(ans[i]>0)i++;
				ans[i]=v;
			}
			FOR(i,2*N-1){
				print(ans[i]);
			}
		}
	}
  return 0;
}


Measured memory_bytes: 10568
x,y = map(int,input().split())
ans = 0
if x*y < 0:
    ans += 1
elif (x>0 and y==0) or (x==0 and y<0):
    ans += 1
elif y < x:
    ans += 2
ans += abs(abs(x)-abs(y))
print(ans)

Measured memory_bytes: 9092
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
 
ans = []
for i in range(50):
    if N%2==1:
        ans.append('1')
        if i%2==0:
            N -= 1
        else:
            N += 1
    else:
        ans.append('0')
    N //= 2
    if N==0:
        break
print(''.join(ans[::-1]))
    

Measured memory_bytes: 61520
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

ll N ;
ll start;
vector<ll> place;

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

    cin >> N >> start;
    rep(i,N){
        ll inp;
        cin >> inp;
        inp -= start;
        place.pb(abs(inp));
    }
    
    rmsame(place);
    ll ans = place[0];
    rep(i,N){
        ans = gcd(ans, place[i]);
    }
    cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <bitset>
#include <fstream>
#include <unordered_set>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
  
          
using namespace std;
using namespace __gnu_pbds;
 
  
 
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")*/
      
#define int long long
#define eb emplace_back
#define pb push_back
#define ld long double
#define mp make_pair
#define f first
#define s second
#define deb(a) cerr << #a << " = " << a << '\n';
#define fast() { \
    ios_base::sync_with_stdio(0); \
    cin.tie(0); \
    cout << fixed << setprecision(5); \
    cerr << fixed << setprecision(11); \
}
 
template < typename firstType, typename secondType = null_type, class compare = less < firstType > >
struct sett {
    typedef tree <
        firstType,
        secondType,
        compare,
        rb_tree_tag,
        tree_order_statistics_node_update
    > _ ;
};
 
  
const int INF = 1e9 + 7;
const ld EPS = 1e-10;
const int MAXI = 200000;
const int P = 223; 
const int MOD = 998244353; 
const int MAXST = 2000000;
const ld PI = 3.14159265358979323;
        
ostream &operator<<(ostream &stream, const pair <int, int> &p) {
    stream << p.first << ' ' << p.second << ' ';
    return stream;
}


signed main(){  
    fast();
    srand(time(0));
    #ifdef _LOCAL               
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
   	int k;
   	cin >> k;
   	int a, b;
   	cin >> a >> b;
   	bool ans  =false;
   	for (int i = a; i <= b; i++)
   		if (i % k == 0)
   			ans = true;
   	if (ans)
   		cout << "OK" << '\n';
   	else 
   		cout << "NG" << '\n';
    return 0;                   
}

Measured memory_bytes: 3668
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

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

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);
    StringTokenizer st;

    int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine(), " ");
        }
        return Integer.parseInt(st.nextToken());
    }

    String readLine() throws IOException {
        return in.readLine();
    }

    int W, H;
//    int[][] arr = new int[105][105];
    boolean[][] vis = new boolean[105][105];
    char[][] arr = new char[105][105];
    void solve() throws IOException {
        while (true) {
            H = readInt();
            W = readInt();
            if (W == 0 && H == 0) {
                break;
            }
            vis = new boolean[105][105];
            arr = new char[105][105];
            for (int i = 0; i < H; i++) {
                arr[i] = readLine().toCharArray();
            }

            int sum = 0;
            for(int i = 0; i< H;i++)
            {
                for(int j = 0; j< W;j++)
                {
                    if (!vis[i][j])
                    {
                        dist(i,j,arr[i][j]);
                        sum++;
                    }
                }
            }
            out.println(sum);
        }
        out.flush();
    }

//    int[] dx = {1, -1, 0, 0};
//    int[] dy = {0, 0, 1, -1};
//    private void dfs(int x, int y, char c) {
//        arr[x][y] = '.';
//        for (int i = 0; i < 4; i++) {
//            int nx = x + dx[i], ny = y + dy[i];
//            if (nx > 0 && nx <= H && ny > 0 && ny <= W && arr[nx][ny] == c) {
//                dfs(nx, ny, c);
//            }
//        }
//
//    }

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

    void dfs(int x,int y,char c)
    {
        vis[x][y] = true;
        for(int i = 0;i<4;i++)
        {
            int nx = x+dx[i], ny = y+dy[i];
            if(nx>=0 && nx<H && ny>=0 && ny<W  && vis[nx][ny] == false && arr[nx][ny] == c){

                dfs(nx,ny,c);
            }
        }
    }

    void dist(int x, int y, char c) {
        try {
            if (!vis[x][y] && arr[x][y] == c) {
                vis[x][y] = true; // 分配済みフラグを立てる
                for(int i = 0;i<4;i++)
                {
                    int nx = x+dx[i], ny = y+dy[i];
//                    if(nx>=0 && nx<H && ny>=0 && ny<W){
//
//                        dist(nx,ny,c);
//                    }
                    dist(nx, ny, c);
                }

            }
        } catch (ArrayIndexOutOfBoundsException e) {
            return;
        }
    }


}


Measured memory_bytes: 26892
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	s, t := next(), next()
	fmt.Printf("%s%s\n", t, s)
}


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

int main(){
  int N, M;
  cin >> N >> M;

  vector<pair<int, int>> stocks(N);
  for(int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    stocks[i] = make_pair(a, b);
  }
  sort(stocks.begin(), stocks.end());

  long long ans = 0;
  int cnt = 0;
  for(int i = 0; i < N; i++){
    if(cnt < M){
      int cnt_now = min(stocks[i].second, M - cnt);
      ans += static_cast<long long>(stocks[i].first) * cnt_now;
      cnt += cnt_now;
    }
  }
  cout << ans << endl;
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

char __buffer[100000];

#ifdef _DEBUG
#define LOCAL
#endif

void err(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);
	
	fprintf(stderr, "\t%s", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);
	
	fprintf(stderr, "\t%s\n", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln() {
#ifdef LOCAL	
	fprintf(stderr, "\n");
#endif	
}

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#define dbg1(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 1; ABC <= n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#define dbg1(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

const int MAX = 200 * 1000 + 41;

char s[MAX];
int n;
ll ans;

void solve() {
	int cnt = 0;
	fdi(n, 1) {
		if (s[i] == 'B') ans += cnt;
		else cnt++;
	}
	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif

  scanf("%s", s + 1);
  n = strlen(s + 1);
	solve();

	exit();
	return 0;
}





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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    int n,k;
    cin >> n >> k;
    double p[n];
    rep(i,0,n){
        cin >> p[i];
        p[i] = (p[i]+(double)1.0)/(double)2.0;
    }
    double m=0;
    double sha = 0;
    rep(i,0,k) sha += p[i];
    m = sha;
    rep(i,0,n-k){
        sha -= p[i];
        sha += p[i+k];
        m = max(m,sha);
    }
    //cout << setprecision(8) << m << endl;
    //cout  << m << endl;
    printf("%10.7lf\n",m);
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] arr = new int[n];
        
        for(int i = 0; i < n; i++)
            arr[i] = sc.nextInt();
            
        long cnt = 0;
        long diff = 0;

        for(int i = 0; i < n - 1; i++) {
            diff = arr[i] + arr[i+1] - x;
            if(diff > 0) {
                arr[i+1] -= Math.min(diff, arr[i+1]);
                cnt += diff;
            }
        }
        
        System.out.println(cnt);
    }
}


Measured memory_bytes: 51264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n;  string s,t;
    cin >> n >> s >> t;
    rep(i,n){
        cout << s[i] << t[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
s = list(input())
t = list(input())

def same(s1,s2):
    for i in range(len(s1)):
        if s1[i] != s2[i]:
            return False
    return True

for i in range(111):
    if same(s,t):
        print("Yes")
        exit()

    tmp = s.pop(0)
    s.append(tmp)

print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int X,Y,A,B,C;
ll P[101010],Q[101010],R[101010];
ll sumP[101010],sumQ[101010],sumR[101010];

bool solve(ll mid){
  int cntP=0,cntQ=0,cntR=0;
  int ind=lower_bound(P,P+A+1,mid)-P;
  cntP=A-ind;
  ind=lower_bound(Q,Q+B+1,mid)-Q;
  cntQ=B-ind;
  ind=lower_bound(R,R+C+1,mid)-R;
  cntR=C-ind;
  if(cntP<X) cntR-=X-cntP;
  if(cntQ<Y) cntR-=Y-cntQ;
  return (cntR>=0);
}

int main(){
  cin>>X>>Y>>A>>B>>C;
  rep(i,A) cin>>P[i];
  rep(i,B) cin>>Q[i];
  rep(i,C) cin>>R[i];
  sort(P,P+A); rep(i,A) sumP[i+1]=sumP[i]+P[i];
  sort(Q,Q+B); rep(i,B) sumQ[i+1]=sumQ[i]+Q[i];
  sort(R,R+C); rep(i,C) sumR[i+1]=sumR[i]+R[i];
  P[A]=Q[B]=R[C]=1e15;
  ll ok=0,ng=1e10;
  while(ng-ok>1){
    ll mid=(ok+ng)/2;
    if(solve(mid)) ok=mid;
    else ng=mid;
  }
  int cntP=0,cntQ=0;
  ll sum=0;
  for(int i=A-1;i>=0;i--){
    if(cntP<X&&ok<P[i]) sum+=P[i],cntP++;
  }
  for(int i=B-1;i>=0;i--){
    if(cntQ<Y&&ok<Q[i]) sum+=Q[i],cntQ++;
  }
  for(int i=C-1;i>=0;i--){
    if(cntP<X&&ok<R[i]) sum+=R[i],cntP++;
    else if(cntQ<Y&&ok<R[i]) sum+=R[i],cntQ++;
  }
  if(cntP<X) sum+=ok*(X-cntP);
  if(cntQ<Y) sum+=ok*(Y-cntQ);
  cout<<sum<<endl;
  return 0;
}

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

using namespace std;

typedef pair<char, int>Command;//first:方向,second:長さ

//見つかった宝石はmapをfalseにする。
bool solve(int n, bool map[21][21], int m, Command *comlist){
	int count = 0;//見つかった宝石の個数
	int posx = 10;
	int posy = 10;
	for(int i=0;i<m;i++){
		for(int j=0;j<comlist[i].second;j++){//移動する回数
			switch(comlist[i].first){
			case 'N':
				posy++;
				break;
			case 'E':
				posx++;
				break;
			case 'S':
				posy--;
				break;
			case 'W':
				posx--;
				break;
			}
			if(map[posy][posx]==true){//宝石がある
				count++;
				map[posy][posx] = false;//回収して、そこに宝石がなくなった
			}
		}
	}
	if(count == n){//すべて見つけた
		return true;
	}else{
		return false;
	}
}

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){
			break;
		}
		bool map[21][21];//x,yともに[0,20]。trueの場所に宝石がある。
		//boolの初期値はtrue?false?
		for(int i=0;i<21;i++){
			for(int j=0;j<21;j++){
				map[i][j] = false;
			}
		}
		for(int i=0;i<n;i++){
			int x,y;
			cin >> x >> y;
			map[y][x] = true;
		}
		int m;//命令回数
		cin >> m;
		Command *comlist = new Command[m];
		for(int i=0;i<m;i++){
			cin >> comlist[i].first >> comlist[i].second;
		}
		bool result = solve(n,map,m,comlist);
		if(result==true){
			cout << "Yes" << endl;
		}else {
			cout << "No" << endl;
		}
		delete[] comlist;
	}
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a * c <= b) {
    cout << c << endl;
  }else {
    cout << b / a << endl;
  }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	v := make([]int, n)
	for i := 0; i < n; i++ {
		v[i] = ri()
	}
	c := make([]int, n)
	for i := 0; i < n; i++ {
		c[i] = ri()
	}

	ans := 0
	for i := 0; i < n; i++ {
		if diff := v[i] - c[i]; diff > 0 {
			ans += diff
		}
	}
	fmt.Println(ans)
}


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

int main(){
  int N,M;
  cin>>N>>M;
  Graph G(N);
  for(int i=0;i<M;i++){
    int s,t;
    cin>>s>>t;
    s--;
    t--;
    G[s].push_back(t);
  }

  vector<double> expect(N,0.0);
  for(int v=N-2;v>=0;v--){
    double sum=0.0;
    for(auto nv:G[v]){
      sum+=expect[nv];
    }
    expect[v]=sum/(double)G[v].size()+1.0;
  }

  vector<double> contribute(N,0.0);
  contribute[0]=1.0;
  for(int v=0;v<N;v++){
    for(auto nv:G[v]){
      contribute[nv]+=contribute[v]/(double)G[v].size();
    }
  }

  double ans=expect[0];
  for(int v=0;v<N;v++){
    if(G[v].size()<2){
      continue;
    }
    double sum=0.0;
    for(auto nv:G[v]){
      sum+=expect[nv];
    }
    for(auto nv:G[v]){
      double x=(sum-expect[nv])/(double)((int)G[v].size()-1)+1.0;
      ans=min(ans,expect[0]+contribute[v]*(x-expect[v]));
    }
  }

  printf("%.6lf\n",ans);
}


Measured memory_bytes: 5008
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ans;
int mr_nece,mv_nece,mtr,mtv,aux;
vector<long long>vr,vv,vaux,s;
int main(){
	 

	cin>>mr_nece>>mv_nece>>mtr>>mtv>>aux;
	s.resize(mr_nece+mv_nece+aux);
	for(int i=0;i<mtr;i++){
		long long x;cin>>x;vr.push_back(x);
	}
	sort(vr.begin(),vr.end());
	
	for(int i=0;i<mtv;i++){
		long long x;cin>>x;vv.push_back(x);
	}
	sort(vv.begin(),vv.end());
	
	for(int i=0;i<aux;i++){
		long long x;cin>>x;vaux.push_back(x);
	}
	sort(vaux.begin(),vaux.end());	
	int lr=mr_nece;
	int lv=mv_nece;
	int j=0;
	for(int i=mtr-lr;i<mtr;i++){
			s[j]=vr[i];
			j++;
	}
	for(int i=mtv-lv;i<mtv;i++){
		s[j]=vv[i];
			j++;
	}
	for(int i=0;i<aux;i++){
		s[j]=vaux[i];
			j++;
	}
	sort(s.begin(),s.end());
	ll sum=0;
	for(int i=aux;i<mr_nece+mv_nece+aux;i++){
		sum+=s[i];
	}
	cout<<sum<<'\n';
}

Measured memory_bytes: 5492
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,mx,mn;
int p[200010];
bool vis[200010],cir[200010],_is[200010];
int mex[200010],cnt_tree=0;
struct node{int y,nxt;
}g[200010];int h[200010],tot=0;
void dfs(int x)
{
    for (int i=h[x];i;i=g[i].nxt) if (!cir[g[i].y]) dfs(g[i].y);
    for (int i=h[x];i;i=g[i].nxt) if (!cir[g[i].y]) _is[mex[g[i].y]]=1;
    for (mex[x]=0;_is[mex[x]];mex[x]++);
    for (int i=h[x];i;i=g[i].nxt) _is[mex[g[i].y]]=0;
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) 
    {
        scanf("%d",&p[i]);
        g[++tot]=node{i,h[p[i]]};h[p[i]]=i;
    }
    int x=1;
    while (!vis[x]) vis[x]=1,x=p[x];
    while (!cir[x]) cir[x]=1,x=p[x];
    mx=0;mn=2147483647;
    for (int i=1;i<=n;i++)
    if (cir[i])
    {
        dfs(i);cnt_tree++;
        mx=max(mx,mex[i]);mn=min(mn,mex[i]);
    }
    if (mx==mn&&(cnt_tree&1)) printf("IMPOSSIBLE");else printf("POSSIBLE");
}

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

int main()
{
	int l, r, d;
	int c = 0;
	scanf("%d%d%d", &l, &r, &d);
	for(int i = l; i <= r; i++) {
		if(i % d == 0) c++;
	}
	printf("%d", c);
}


Measured memory_bytes: 3824
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = ReadLine().Split().Select(int.Parse).ToArray();
        var a=N[0];
        var b=N[1];
        if(0<a&&a<10&&0<b&&b<10)WriteLine(a*b);
        else
        {
            WriteLine(-1);
        }

    }
}



Measured memory_bytes: 13268
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	string str, c;
	int q;
	cin >> str >> q;
	for (int i = 0; i < q; i++) {
		cin >> c;
		if (c == "replace") {
			int a, b;
			string p;
			cin >> a >> b >> p;
			str = str.substr(0, a) + p + str.substr(b + 1, str.size() - a - 1);
		}
		else if (c == "reverse") {
			int a, b;
			cin >> a >> b;
			string s = str.substr(a, b - a + 1);
			reverse(s.begin(), s.end());
			str = str.substr(0, a) + s + str.substr(b + 1, str.size() - a - 1);
		}
		else if (c == "print") {
			int a, b;
			cin >> a >> b;
			cout << str.substr(a, b - a + 1) << endl;
		}
	}
}


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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //ansを出力する時は (ans % mod + mod) % mod とする(負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int main()
{
    int n; cin >> n;
    int p = 0,w = 0,g = 0,y = 0;
    rep(i,n) {
        char c; cin >> c;
        if(c == 'P')p++;
        if(c=='W') w++;
        if(c=='G') g++;
        if(c=='Y')y++;
    }
    if(p*w*g*y) cout << "Four"<<endl;
    else cout << "Three" << endl;
}

Measured memory_bytes: 256
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
am=[]
ap=[]
zc=0
for i in a:
  if i<0:
    am.append(i)
  elif i>0:
    ap.append(i)
  else:
    zc+=1
am.sort()
ap.sort()
#print(am,ap)
def count(n,m,p,z):
  mx=-10**20
  lm=len(m)
  lp=len(p)
  if n==0:
    if z or (lm and lp):
      return (lm*lp+(lm+lp)*z+(z*(z-1))//2,0 if z else m[-1]*p[0])
    else:
      return (0,0)
  elif n<0:
    r=0
    j=0
    for i in m:
      while j<len(p) and i*p[j]>n:
        j+=1
      if j<len(p) and mx<i*p[j]:
         mx=i*p[j]
      r+=len(p)-j
    return (r,mx)
  else:
    if z or (lm and lp):
      mx=0 if z else m[-1]*p[0]
    r=lm*lp+(lm+lp)*z+(z*(z-1))//2
    j=lp-1
    for i in range(lp):
      while j>i and p[i]*p[j]>n:
        j-=1
      if j>i and p[i]*p[j]>mx:
        mx=p[i]*p[j]
      r+=j-i
      if i==j:
        break
    j=lm-1
    for i in range(lm):
      while j>i and m[i]*m[j]<=n:
        j-=1
      if i>j:
        j=i
      if j<lm-1 and m[i]*m[j+1]>mx:
        mx=m[i]*m[j+1]
      r+=lm-j-1
    return (r,mx)

r=10**18
t=0
s=set()

while True:
  ret=count(t,am,ap,zc)
  #if r<100:
  #  print(t,ret)
  if ret[0]<k:
    s.add(t)
    t+=r
    r=(r+1)//2
  elif ret[0]==k:
    print(ret[1])
    break
  else:
    if t in s:
      print(ret[1])
      break
    s.add(t)
    t-=r
    r=(r+1)//2
  
  
  
  

Measured memory_bytes: 99320
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    int s,u;
    char op = 'n';
    s = 0;
    u = 0;
    cin >> s;
    while(true){
	string str;
	cin >> str;
	if(str == "+"){
	    op = '+';
	}else if(str == "-"){
	    op = '-';
	}else if(str == "*"){
	    op = '*';
	}else if(str == "/"){
	    op = '/';
	}else if(str == "="){
	    break;
	}else{
	    u = stoi(str);
	    if(op == '+') s += u;
	    else if(op == '-') s -= u;
	    else if(op == '*') s *= u;
	    else if(op == '/') s /= u;
	}
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3156
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    string S; ll K =0;
    cin >> S;
    cin >> K;

    //vll X(N);
    //REP(i,N) cin >> X[i];


    //本文
        REP(i,K){
            if(S[i]=='1')continue;
            else{cout << S[i];return 0;}
        }
    
    //出力
    cout << 1;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;


int main(void) {
	string n; cin >> n;
	
	if (n[0] == n[1] && n[1] == n[2]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>

int main(){
    int n,tmp,count = 0,limit;
    scanf("%d",&n);

    for(int i = 0; i < n; i++)
    {
        scanf("%d",&tmp);
        limit = sqrt(tmp);
        if(tmp > 3){
           	if(tmp%2 == 0)	count++;
        	else{
				for(int j = 3; j <= limit; j+=2){
					if(tmp%j==0){
						count++;
						break;
					}
				}
        	}
        }
    }
    printf("%d\n",n-count);
}

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

int n,dp[2005][2005];

struct node
{
	int rt;
	int num;
}a[5005];

bool cmp(node a,node b)
{
	return a.num>b.num;
}

int work(int now,int l,int r)
{
	if (l>r)  return a[now].num;
	if (dp[l][r]!=-1)  return dp[l][r];
	
	int first=work(now+1,l+1,r)+a[now].num*abs(a[now].rt-l);
	int second=work(now+1,l,r-1)+a[now].num*abs(a[now].rt-r);
	dp[l][r]=max(dp[l][r],max(first,second));
	
	return dp[l][r];
}

signed main()
{
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for (int i=1;i<=n;i++)  cin>>a[i].num,a[i].rt=i;
	
	sort(a+1,a+n+1,cmp);
	cout<<work(1,1,n)<<endl;
	
	return 0;
}

Measured memory_bytes: 35120
import sys
sys.setrecursionlimit(10**6)

def fprint(a,b,c,d):
	s = str(a) + " " + str(b) + " " + str(c) + " " + str(d)
	return s

def main():
	h, w = map(int, input().split())
	n = 0
	a = [[int(i) for i in input().split()] for _ in range(h)]
	ans = []
	for i in range(h):
		if i % 2 == 0:
			for j in range(w):
				if a[i][j] % 2 != 0 and j != w-1:
					ans+=[fprint(i+1,j+1,i+1,j+2)]
					a[i][j+1] += 1
					n+=1
				elif a[i][j] % 2 != 0 and i != h-1:
					ans += [fprint(i+1,j+1,i+2,j+1)]
					a[i+1][j] += 1
					n+=1
		else:
			for j in range(w-1,-1,-1):
				if a[i][j] % 2 != 0 and j != 0:
					ans += [fprint(i+1,j+1,i+1,j)]
					a[i][j-1] += 1
					n+=1
				elif a[i][j] % 2 != 0 and i != h-1:
					ans += [fprint(i+1,j+1, i+2,j+1)]
					a[i+1][j] += 1
					n+=1
	print(n)
	print("\n".join(ans))
	return
	
main()
		

Measured memory_bytes: 20012
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val abc: Array[String] = sc.nextLine.split("")
    if (abc.contains("a") & abc.contains("b") & abc.contains("c")) println("Yes")
    else println("No")
  }

}


Measured memory_bytes: 27460