akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;

template <class S>
inline void read(S& arg) {
  cin >> arg;
}
template <class S>
inline void readA(S Lptr, S Rptr) {
  while (Lptr != Rptr) {
    read(*Lptr);
    Lptr++;
  }
}
template <class S, class... T>
inline void read(S& arg, T&... rest) {
  read(arg);
  read(rest...);
}

char delimiter = ' ';
template <class S>
inline void write(S arg) {
  cout << arg << '\n';
}
template <class S, class... T>
inline void write(S arg, T... rest) {
  cout << arg << delimiter;
  write(rest...);
}
template <class S>
inline void writeA(S Lptr, S Rptr) {
  while (Lptr != Rptr) {
    cout << *Lptr;
    Lptr++;
    if (Lptr != Rptr) cout << delimiter;
  }
  cout << '\n';
}

#define int long long
#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(), x.end()

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

template <class T, class S>
inline bool smin(T& a, S b) {
  return (T)b < a ? a = b, 1 : 0;
}
template <class T, class S>
inline bool smax(T& a, S b) {
  return a < (T)b ? a = b, 1 : 0;
}

constexpr int MOD = 1e9 + 7;
constexpr int N = 1e5 + 10;

template <typename T>
inline T mod(T& v) {
  return v = (v % MOD + MOD) % MOD;
}
template <typename S, typename T>
inline S add(S& l, T r) {
  return mod(l += r);
}

ll po(ll v, ll u) {
  return u ? po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD : 1;
}

int n;
string s;
vi adj[N];

ll sum[N], num[N], del[N];

void dfs(int v, int par = -1) {
  num[v] = sum[v] = del[v] = 0;
  if (s[v] == '1') num[v]++;
  int id = -1, mx = -1;
  for (auto e : adj[v])
    if (e ^ par) {
      dfs(e, v);
      sum[v] += sum[e] + num[e];
      num[v] += num[e];
      if (smax(mx, sum[e] + num[e])) id = e;
    }
  if (id == -1) return;
  if (2 * mx <= sum[v])
    del[v] = sum[v] >> 1;
  else {
    int sum2 = (sum[v] >> 1) << 1;
    int needed = (2 * mx - sum2) >> 1;
    if (del[id] >= needed)
      del[v] = sum[v] >> 1;
    else
      del[v] = sum[v] - mx + del[id];
  }
}

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

  read(n, s);
  rep(i, 1, n) {
    int a, b;
    read(a, b);
    a--, b--;
    adj[a].pb(b);
    adj[b].pb(a);
  }

  ll answer = 1e18;
  rep(i, 0, n) {
    dfs(i, -1);
    // cout << i << ' ' << sum[i] << endl;
    if (sum[i] & 1 || del[i] != sum[i] >> 1) continue;
    smin(answer, sum[i] >> 1);
  }

  if (answer == 1e18) answer = -1;
  write(answer);

  return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

int main() {
    int N, M ,X, Y;
    cin >> N>>M>>X>>Y;
    int x[N], y[M];
    rep(i, 0, N) cin >> x[i];
    rep (i, 0,M) cin >> y[i];
    sort(x, x+N); sort (y, y+M);
    if (x[N-1]<y[0] && x[N-1]<Y && y[0]>X) cout << "No War" << endl;
    else cout <<"War" << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, n;
  cin >> k >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  } 
  int x = a[n - 1] - a[0];
  if (x == k || n == 2) {
    cout << x << endl;
    return 0;
  }
  int acw = k - x, w = (int) 1e9;
  for (int i = 0; i < n - 1; i++) {
    w = min(w, acw + (a[i] - a[0]) + (a[n - 1] - a[i + 1]));
  }
  cout << min(w, x) << '\n';
  return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

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

    vector<int> H(N);
    rep(i,N) cin >> H[i];
    
    bool isOK=true;
    /*if(N==1){
        cout << "Yes" <<endl;
        return 0;
    }
    if(H[0]==H[1]-1)H[1]=H[0];
    else if(H[0]-1==H[1])H[0]=H[1];
    else if(H[0]>H[1]) isOK=false;
    repd(i,1,N-1){
        if(H[i-1]<=H[i] && H[i]<=H[i+1])continue;
        if(H[i-1]<=H[i]-1 && H[i]-1<=H[i+1]){
            H[i]--;
        }else{
            isOK=false;
            break;
        }
    }
    if(H[N-2]>H[N-1])isOK=false;
    cout << ((isOK) ? "Yes" : "No") <<endl;*/
    if(N==1){
        cout << "Yes" <<endl;
        return 0;
    }
    int m1;
    if(H[0]==H[1]-1){
        H[1]=H[0];
        m1=H[0];
    }else if(H[0]-1==H[1]){
        H[0]=H[1];
        m1=H[1];
    }else if(H[0]>H[1]){
        cout << "No" <<endl;
        return 0;
    }else{
        m1=H[1]-1;
    }
    int max=H[1];
    repd(i,2,N){
        if(max==H[i])continue;/* 地続き　保留 */
        if(max<H[i]){ /* 十分な単調増加 */
            max=H[i];
            m1=max-1;
        }else if(m1==H[i]){ /* 許容できそうな単調減少 */
            m1=max-1;
        }else{
            isOK=false;
            break;
        }
    }
    cout << ((isOK) ? "Yes" : "No") <<endl;

    return (0);
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    FOR(x,1,n/100){
        int r = n - 100 * x;
        if (r >= 0 && r <= 5 * x){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"
//----------------------------------------------------------------
ll gcd(ll a, ll b){ return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){ return a/gcd(a,b)*b;}

ll div2(ll x){
  ll num=0;
  while(x%2==0){
    x /= 2;
    num++;
  }
  return num;
}

int main(void) {
  ll n, m;
  cin >> n >> m;
  arrll(a,n);
  rep(i,n){
    a[i] /= 2;
  }

  ll k=div2(a[0]);
  rep(i,n){
    if(k!=div2(a[i])){
      prt(0); return 0;
    }
    a[i] >>= k;
  }
  m >>= k;

  ll l=1;
  rep(i,n){
    l = lcm(a[i], l);
    if(l > m){
      prt(0); return 0;
    }
  }
  prt(1+(m-l)/(2*l));
}


Measured memory_bytes: 3972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h> //works like magic, but at cost.
using namespace std;
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout<<x<<endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define fk(i, k, n) for(int i=k; i<=n; i++)
#define fn(i, n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<lli, lli>	pl;
typedef vector<int>		vi;
typedef vector<lli>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

int main() {
   string s,t;
   cin>>s;
   cin>>t;
   lli count=0, len=s.length();
   fo(i, len){
       if(s[i]!=t[i]){
           count++;
   }
   }cout<<count;
    
    return 0;
}

Measured memory_bytes: 3392
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i =a; i<n; i++) 
#define ll long long
#define MOD 1000000007
using namespace std;
  
int main() {
  string S; cin >> S;
  if (S[S.size()-1] != 's') cout << S << 's' << endl;
  else cout << S << "es" << endl;
}

Measured memory_bytes: 3592
#include<iostream>

using namespace std;

int main()
{
  int ab;
  cin>>ab;

  for(;ab--;)
    {
      string s;
      cin>>s;
      char x;
      int count=0;
      bool out=true;
      for(int i=0;i<s.size();i++)
	{
	  if(s[i]!='0')
	    count++;
	    
	  if(s[i]=='1')
	    {
	      string t=".,!? ";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='2')
	    {
	      string t="abc";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='3')
	    {
	      string t="def";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else

	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='4')
	    {
	      string t="ghi";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }

	  if(s[i]=='5')
	    {
	      string t="jkl";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='6')
	    {
	      string t="mno";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='7')
	    {
	      string t="pqrs";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='8')
	    {
	      string t="tuv";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='9')
	    {
	      string t="wxyz";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='0')
	    {
	      if(count!=0)
		{
		  cout<<x;
		  out=false;
		}
	      count=0;

	    }
	}
      if(!out)
      cout<<endl;
    } 

}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int A, B, C, K;
    cin >> A >> B >> C >> K;
    while (K > 0 && A >= B) {
        B *= 2;
        K--;
    }
    while (K > 0) {
        C *= 2;
        K--;
    }

    cout << (A < B && B < C ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3648
if __name__ == '__main__':
    n = int(input())
    a_list = list(map(int,input().split()))

    d = {}
    for i in range(n):
        d[str(a_list[i])] = i+1

    answer = ""
    for i in range(n):
        if i != 0:
            answer += " "
        answer += str(d[str(i+1)])

    print(answer)



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

using namespace std;

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

ll ans;
ll N, W;
ll bw;
vector<ll> V[4];

void dfs(int idx, ll ww, ll vv){
    if(idx == 4){
        if(W >= ww){
            ans = max(ans, vv);
        }
        return;
    }
    ll sum = 0;
    dfs(idx+1, ww, vv);
    for(int j = 0; j < V[idx].size(); j++) {
        sum += V[idx][j];
        dfs(idx+1, ww+(j+1)*(bw+idx), vv+sum);
    }
}

int main(){
    cin >> N >> W;
    REP(i,N){
        ll w, v;
        cin >> w >> v;
        if(i == 0) bw = w;
        w -= bw;
        V[w].push_back(v);
    }

    for(int i = 0; i < 4; i++){
        sort(V[i].begin(), V[i].end(), greater<ll>());
    }

    dfs(0,0LL,0LL);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    float R, G; cin >> R >> G;
    cout << 2*G - R << endl;
}

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

constexpr int len{4};

int main() {
  char op[len - 1];
  string abcd; cin >> abcd;

  for (int i{}; i < (1 << len - 1); ++i) {
    int sum{abcd[0] & 0xF};
    for (int j{}; j < len - 1; ++j) {
      op[j] = (i & (1 << j)) ? '+' : '-';
      if (op[j] == '+')
        sum += abcd[j + 1] & 0xF;
      else
        sum -= abcd[j + 1] & 0xF;
    }
    if (sum == 7) {
      int i{0};
      for (; i < len - 1; ++i) {
        cout << abcd[i] <<  op[i];
      }
      cout << abcd[i] << "=7" << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
//
// Created by yamunaku on 2020/03/28.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n;
    cin >> n;
    int ans = 0;
    ans = n/500*1000;
    ans += n%500/5*5;
    cout << ans << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;


int main() {
	int N, K; cin >> N >> K;
	cout << N - K + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define range(i,a,b) for(int i = (a);i <= (b);i++)
#define all(A) A.begin(),A.end()
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
#define vi vector<int>
#define vl vector<long long>
#define vd vector<double>
#define vp vector<pair<int,int> >
#define ll long long
#define pi pair<int,int>
#define popcnt(x) __builtin_popcountll(x)
#define LSOne(x) ((x) & (-(x)))
#define xx first
#define yy second
#define PQ priority_queue
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prp(p) cerr << "(" << (p).first << " ," << (p).second << ")";
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
#define what_is(x) cerr << #x << " is " << x << endl
#define bit_lg(x) (assert(x > 0),__builtin_ffsll(x) - 1)
const double PI = acos(-1);
using namespace std;

const int MAXN = 2000,MAXA = 2000,MAXS = MAXA*MAXN + 1;
bitset<MAXS> dp;
int A[MAXN + 1],n,sum ;

int main(){
	#ifdef HOME
		freopen("in.in", "r", stdin);
	#endif
	scanf("%d",&n);
	range(i,1,n){
		scanf("%d",A + i);
		sum += A[i];
	}
	sum = (sum + 1)/2;
	dp.set(0);
	for(int i = 1;i <= n;i++)
		dp |= dp << A[i];
	while(!dp.test(sum)) sum++;
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e16;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){
  ll N, K; cin >> N >> K;

  vector <ll> A(N), F(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++) cin >> F[i];
  sort(F.begin(), F.end(), greater<ll>());


  vector <ll> score(N);
  ll left = 0, right = 0;
  for (int i = 0; i < N; i++){
    score[i] = A[i] * F[i];
    if(right < score[i]) right = score[i];
  }

  vector < pair<ll, bool> > search;
  search.push_back(make_pair(right, true));

  bool flag = true;
  while (flag == true){
    ll cnt = 0, now = (left + right) / 2;

    for (int i = 0; i < N; i++){
      if (score[i] > now){
        cnt += (score[i] - now) / F[i];
        if ((score[i] - now) % F[i] != 0){
          cnt++;
        }
      }
    }
    
    if (cnt <= K){
      search.push_back(make_pair(now, true));
      right = now;
    }else{
      search.push_back(make_pair(now, false));
      left = now;
    }
    
    if (now == (left + right) / 2){
      break;
    }
  }
  
  int S = search.size();
  if (search[S - 1].second == true){
    cout << search[S - 1].first << endl;
  }else{
    cout << search[S - 1].first + 1 << endl;
  }
  

  return 0;
}


Measured memory_bytes: 4992
# include <bits/stdc++.h>
using namespace std;
 
# define ll long long
 
int countSteps(string s, char c){
  s = c + s + c;
  int prevPos = 0;
  int result = 0;
  for(int i=1; i<s.size(); i++){
    if(s[i] == c){
      result = max(result, i - prevPos - 1);
      prevPos = i; 
    }
  }
  return result;
}
 
int main(){
 
  string s;
  cin >> s;
  int ans = 1e9;
  for(char c : s){
    ans = min(ans, countSteps(s, c));
  }
  cout << ans << endl;
  
  return 0;
} 
 

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = (n + k - 3) / (k - 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3716
import math
n=int(input())
c={"R":0,"G":0,"B":0}
a=1
mod=998244353
for i in input():
	s=sorted((c["R"],c["G"],c["B"]))
	c[i]+=1
	if c[i]>s[2]:
		pass
	elif c[i]>s[1]:
		a*=s[2]-s[1]
	else:
		a*=s[1]-s[0]
	a%=mod
print(math.factorial(n)*a%mod)

Measured memory_bytes: 47192
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, k;
vector<p> x, y;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>k;
    for (int i = 0; i < n; i++)
    {
        ll tempx, tempy;
        cin >> tempx>>tempy;
        x.push_back(make_pair(tempx,tempy));
        y.push_back(make_pair(tempy,tempx));
    }
    sort(ALL(x));
    sort(ALL(y));
    ll ans=5000000000000000000;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            for(int l=0;l<n-1;l++){
                for(int s=l+1;s<n;s++){
                    int count=0;
                    for(int h=0;h<n;h++){
                        if(x[h].first<=x[j].first&&x[h].first>=x[i].first)
                        {
                            if(x[h].second<=y[s].first&&x[h].second>=y[l].first)
                            {
                            count++;
                            }     
                        }                    
                    }
            if(count>=k)
            ans=min(ans,1LL*(x[j].first-x[i].first)*(y[s].first-y[l].first));
                }
            }
        }
    }
    
    cout << ans << "\n";
}



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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e6, M = 1e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


ll power(ll b, ll e, ll mod){
    if(e == 1)  return b;
    ll ans = power(b, e / 2, mod);
    ans *= ans; ans %= mod;
    if(e & 1)   ans *= b;
    return ans % mod;
}

//iif p is prime, gcd(a, p) == 1;
ll modInv1(ll a, ll p){
    return power(a, p - 2, p);
}

ll fac[N], mod[N];

ll modInv(ll a, ll p){
    if(mod[a] != -1)    return mod[a];
    return mod[a] = modInv1(fac[a], p);
}

int main(){
    init();

    memset(mod, -1, sizeof mod);
    fac[0] = 1;
    for(int i = 1;i < N;i++){
        fac[i] = (i * fac[i - 1]) % modulo;
    }

    ll n, m, a, b; cin >> n >> m >> a >> b;

    ll ans = 0;
    for(int d = 0;d < n - a;d++){
        ll right = ((fac[d + b] * modInv(b, modulo)) % modulo) * modInv(d, modulo);

        ll down;
        if(d == n - a - 1)
            down = (fac[(n - d - 1) + m - b - 1] * modInv(n - d - 1, modulo) % modulo) * modInv(m - b - 1, modulo);
        else
            down = (fac[(n - d - 1) + m - b - 2] * modInv(n - d - 1, modulo) % modulo) * modInv(m - b - 2, modulo);

        right %= modulo;        down %= modulo;
        ans += (right * down);  ans %= modulo;
    }


    cout << ans;

}

Measured memory_bytes: 15872
//ΔARC086D
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
int a[55];
int b[111],c[111],ans;
void f(int bb,int cc){
	b[++ans]=bb;
	c[ans]=cc;
}
int main()
{
	int n,k,i,x,xx,y,yy;
	scanf("%d",&n);
	x=0,y=0,xx=1,yy=1;
	for(i=1;i<=n;i=i+1){
		scanf("%d",a+i);
		if(x<a[i])
			x=a[i],xx=i;
		if(y>a[i])
			y=a[i],yy=i;
	}
	if(x>=-y){
		for(i=1;i<=n;i=i+1)
			f(xx,i);
		for(i=1;i<n;i=i+1)
			f(i,i+1);
	}
	else{
		for(i=1;i<=n;i=i+1)
			f(yy,i);
		for(i=n;i>1;i=i-1)
			f(i,i-1);
	}
	cout<<ans<<endl;
	for(i=1;i<=ans;i=i+1)
		cout<<b[i]<<' '<<c[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
### main

while true
  n = gets.strip
  break if n.to_f < 0

  rs, fs = n.split('.')

  r = rs.to_i
  if r >= (1 << 8)
    puts 'NA'
    next
  end

  if fs.nil?
    fb = '0000'
  else
    f = fs.to_i
    f10 = 10 ** fs.length
    fb = ''
    4.times.each do
      f *= 2
      fb += (f / f10).to_s
      f %= f10
    end
    if f != 0
      puts 'NA'
      next
    end
  end

  puts sprintf("%08b.%s", r, fb)
end

Measured memory_bytes: 6168
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<sstream>
#include<map>
#include<queue>
using namespace std;
#define int long long
vector<vector<int> >g;
vector<int> v;
void dfs(int a) {
	v[a] = 1;
	for (int i = 0; i < g[a].size(); i++) {
		if (v[g[a][i]] == 0) {
			dfs(g[a][i]);
		}
	}
}
signed main() {
	int N;
	int M;
	cin >> N >> M;
	g.resize(N);
	v.resize(N, 0);
	vector<int> W(N);
	for (int i = 0; i < N; i++) {
		cin >> W[i];
	}
	int a, b;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0);
	vector<int> deg(N);
	int INF = (int)1 << 60;
	vector<int> dp(N, 0);
	for (int i = 0; i < N; i++) {
		deg[i] = g[i].size();
	}
	queue<int> qu;
	for (int i = 1; i < N; i++) {
		if (v[i] == 1) {
			if (deg[i] == 1) {
				qu.push(i);
				dp[i] = 0;
			}
		}
	}
	while (!qu.empty()) {
		int a = qu.front(); qu.pop();
		for (int i = 0; i < g[a].size(); i++) {

			deg[g[a][i]]--;
			if (g[a][i] != 0) {
				if (deg[g[a][i]] == 1) {
					qu.push(g[a][i]);
				}
			}
			dp[g[a][i]] = max(dp[g[a][i]], dp[a] + W[a]);
		}
	}

	int mx = 0;
	int res = 0;
	res = W[0];
	mx = dp[0];
	for (int i = 1; i < N; i++) {
		if (v[i] == 1) {
			if (deg[i] >= 2) {
				res += W[i];
				mx = max(mx, dp[i]);
			}
		}
	}
	res += mx;
	cout << res << endl;
}


Measured memory_bytes: 14392
#include <iostream>
using namespace std;
int main(){
  int n,s,j,k,a[11][46];
  for(int s=0;s<46;s++)for(int n=0;n<11;n++)a[n][s]=0;
  for(int i=0;i<1024;i++){
    for(j=i,n=0;j>0;j/=2)
      n += j%2;
    for(j=i,s=0,k=0;j>0;j/=2,k++)
      s += j%2*k;
    a[n][s]++;
  }
  for(cin>>n>>s;n||s;s<46?cout<<a[n][s]:cout<<0,cout<<endl,cin>>n>>s);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;


int main(void)
{
    int n,m;
    cin >> n >> m;

    vector<int> a(m);

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

    long long sum = accumulate(a.begin(), a.end(), 0);

    if (sum > n) cout << -1 << endl;
    else
    {
        cout << n - sum << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3660
while True:
    g = int(input())//100
    if g == 0:
        break
    p = 100000
    for a in range(g//2 + 1):
        for b in range(g//3 + 1):
            for c in range(g//5 + 1):
                if a*2 + b*3 + c*5 == g:
                    p = min(p, 1520*(a//5) + 380*(a%5) + 1870*(b//4) + 550*(b%4) + 2244*(c//3) + 850*(c%3))
    print(p)



Measured memory_bytes: 5588
import math
b = list(map(int,input().split()))
ans=0
check=0
if b[2]>b[1]-1:
    check = math.floor((b[0]*(b[1]-1))/b[1]) - b[0]*math.floor((b[1]-1)/b[1])
else:
    check = math.floor((b[0]*b[2])/b[1]) - b[0]*math.floor(b[2]/b[1])
if check>ans:
    ans=check
print(ans)

Measured memory_bytes: 62080
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

int main(){
    int N,L;
    cin >> N >> L;
    int aji[N],total=0,ans = 0;

    for(int i= 0;i<N;i++){
        aji[i] = L+i;
        total += L + i ;
        }
    int bordor = abs(aji[0]);
    for(int i=1;i<N;i++){
        if(abs(aji[i]) < bordor){
            bordor = abs(aji[i]);
            ans = i;
        }

    }

    cout << total - aji[ans] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int N=102;
int n,K,v[N];
int main() {
    scanf("%d%d",&n,&K);
    for(int i=1;i<=n;i++) scanf("%d",&v[i]);
    int ans=0;
    for(int i=0;i<=n;i++){
        for(int j=i+1;j<=n+1;j++){
            int x=i+n-j+1, score=0;
            if(x>K) continue;
            vector<int> vec;
            for(int k=1;k<=i;k++) vec.push_back(v[k]), score+=v[k];
            for(int k=j;k<=n;k++) vec.push_back(v[k]), score+=v[k];
            sort(vec.begin(),vec.end());
            for(int k=0;k<min(K-x,(int)vec.size());k++) {
                if(vec[k]<0) score-=vec[k];
            }
            ans=max(ans,score);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    vector<P> v;
    for(int i=0; i<3; i++){
        int x; cin>>x;
        v.push_back(P(x, i));
    }

    sort(v.begin(), v.end());
    cout << (char)('A'+v[2].sc) << endl;
}


Measured memory_bytes: 3112
#import numpy as np
#n = int(input())
ipt = [int(i) for i in input().split()]

a = ipt[0]
b = ipt[1]
c = ipt[2]
x = ipt[3]
y = ipt[4]

a_pizza = x
b_pizza = y
c_pizza = 0
if a+b > 2*c:
    c_pizza = 2*min(a_pizza, b_pizza)
    a_pizza -= c_pizza / 2
    b_pizza -= c_pizza / 2
if a_pizza > 0 and a > 2*c:
    c_pizza += 2*a_pizza
    a_pizza = 0
if b_pizza > 0 and b > 2*c:
    c_pizza += 2*b_pizza
    b_pizza = 0

print(int(a*a_pizza+b*b_pizza+c*c_pizza))

Measured memory_bytes: 3064
/*    Don’t Quit
    
    When things go wrong as they sometimes will;
        When the road you’re trudging seems all uphill;
            When the funds are low, and the debts are high;
                And you want to smile, but you have to sigh;
                    When care is pressing you down a bit
                        Rest if you must, but don’t you quit.
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int a[N];
int check[N];
int ans[N];
int32_t main()
{
    int n,m,d;
    cin>>n>>m>>d;
    map<int,pair<int,int> >mp;
    int x;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>x;
            mp[x]={i,j};
        }
    }
    for(int i=1;i<=n*m;i++)
    {
        if(check[i]==0)
        {
            ans[i]=0;
            for(int j=i+d;j<=n*m;j+=d)
            {
                ans[j]=ans[j-d]+abs(mp[j].ff-mp[j-d].ff)+abs(mp[j].ss-mp[j-d].ss);
                check[j]=1;
            }
        }
    }
    //cout<<ans[2]<<" "<<ans[4]<<" "<<ans[6]<<" "<<ans[8]<<endl;
    int q;
    cin>>q;
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        if(l==r)
        {
            cout<<"0"<<endl;

        }
        else
        {
            
            
            cout<<ans[r]-ans[l]<<endl;
        }
    }









}

Measured memory_bytes: 9472
#include <stdio.h>

int main (void) {
	int a;
	int b;
	int c;
	int k;
	
	while (scanf("%d%d", &a,&b) != EOF) {
		c = a + b;
		k = 1;
		while ((c / 10) != 0 ) {
			c = c / 10;
			k++;
		}
		printf("%d\n", k);
	}
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/


/*実行開始からの経過時間を表すよ。

while (clock() < 1900000) {  }

*/


/*まだ使えないテクニックのメモだよ。

for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ

*/


/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/

int main(){

	int n; cin >> n;

	string s;

	for (int ss = 0; ss < n; ss++) {
		cin >> s;

		int ans = 0;
		map<string, string> mp;

		for (int i = 1; i < s.size(); i++) {

			string x = s.substr(0, i);
			string y = s.substr(i, s.size() - i);
			string x_r = "";
			string y_r = "";

			for (int j = x.size() - 1; j >= 0; j--) { x_r += x[j]; }
			for (int j = y.size() - 1; j >= 0; j--) { y_r += y[j]; }

			mp[x + y];
			mp[y + x];
			mp[x + y_r];
			mp[y_r + x];
			mp[x_r + y];
			mp[y + x_r];

			mp[y_r + x_r];
			mp[x_r + y_r];

		}

		for (auto x : mp) {
			ans++;
		}

		cout << ans << endl;
	}


	return 0;
}



Measured memory_bytes: 3252
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
b = set(b)
g = [0]*9
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      g[i*3+j] = 1
for i,j,k in [[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6],[0,1,2],[3,4,5],[6,7,8]]:
  if g[i]==g[j]==g[k]==1:
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 3064
def resolve():
    import math
    n = int(input())
    while n != 0:
        sn = [int(i) for i in input().split()]
        m = sum(sn) / n
        sumA = 0
        for s in sn:
            sumA += ((s - m)**2) / n
        print(math.sqrt(sumA))
        n = int(input())


resolve()



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


int main(){
    string s;

    cin >> s;
    int num0=0;
    int num1=0;
    for (int i=0;i<s.size();i++){
        char c = s[i];
        if(c=='0') num0++;
        else num1++;
    }
    cout << min(num0,num1)*2 << endl;
}

Measured memory_bytes: 512
import sys
def main():
    input = sys.stdin.readline
    i,o,t,j,l,s,z = map(int, input().split())

    ans1 = o
    ans1 += i&(~1)
    ans1 += j&(~1)
    ans1 += l&(~1)

    ans2 = o
    if i and j and l:
        ans2 += 3
        ans2 += (i-1)&(~1)
        ans2 += (j-1)&(~1)
        ans2 += (l-1)&(~1)

    print(max(ans1, ans2))

if __name__ == '__main__':
    main()

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

char *enc[] = {
    "100101", "10011010", "0101", "0001",
    "110", "01001", "10011011", "010000",
    "0111", "10011000", "0110", "00100",
    "10011001", "10011110", "00101", "111",
    "10011111", "1000", "00110", "00111",
    "10011100", "10011101", "000010", "10010010",
    "10010011", "10010000", "101", "000000",
    "000011", "10010001", "010001", "000001",
};

char *dec[] = {
    "00000", "00001", "00010", "00011",
    "00100", "00101", "00110", "00111",
    "01000", "01001", "01010", "01011",
    "01100", "01101", "01110", "01111",
    "10000", "10001", "10010", "10011",
    "10100", "10101", "10110", "10111",
    "11000", "11001", "11010", "11011",
    "11100", "11101", "11110", "11111",
};

char str[128];
char changed[2048];

int check(char c)
{
    if ('A' <= c && c <= 'Z') return 0;
    if (c == '0' || c == '1') return 0;
    if (c == ' ' || c == '\'') return 0;
    if (c == ',' || c == '-') return 0;
    if (c == '.' || c == '?') return 0;
    return -1;
}

int main(void)
{
    while (fgets(str, 120, stdin) != NULL){
        int i, j;

        memset(changed, 0, sizeof(changed));
        for (i = j = 0; check(str[i]) == 0; i++){
            int e;

            switch (str[i]){
                case ' ': e = 26; break;
                case '\'': e = 27; break;
                case ',': e = 28; break;
                case '-': e = 29; break;
                case '.': e = 30; break;
                case '?': e = 31; break;
                default: e = str[i] - 'A'; break;
            }
            sprintf(changed + j, "%s", enc[e]);
            j += strlen(enc[e]);
        }
        while (j % 5 != 0) changed[j++] = '0';
        for (i = 0; check(changed[i]) == 0; i += 5){
            int d;

            for (j = d = 0; j < 5; j++){
                d *= 2;
                d += changed[i + j] - '0';
            }
            switch (d){
                case 26: putchar(' '); break;
                case 27: putchar('.'); break;
                case 28: putchar(','); break;
                case 29: putchar('-'); break;
                case 30: putchar('\''); break;
                case 31: putchar('?'); break;
                default: putchar('A' + d); break;
            }
        }
        puts("");
    }

    return 0;
}

Measured memory_bytes: 524
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
K = [A[i][0] for i in range(N)]
for i in range(N):
    del A[i][0]
counter = [[] for i in range(N)]
counter[0] = A[0]

for i in range(1, N):
    for j in range(K[i]):
        if A[i][j] in counter[i-1]:
            counter[i].append(A[i][j])

print(len(counter[N-1]))


Measured memory_bytes: 3064
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	if (X < 1200)
	{
		cout << "ABC" << endl;
	}
	else
	{
		cout << "ARC" << endl;
	}

	return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

struct TopologicalSort {
	int n;
	vector< vector<int> > G;
	vector<bool> used;
	vector<int> indeg,order;

	TopologicalSort() {}
	TopologicalSort(int sz):n(sz),G(sz),used(sz),indeg(sz) {};

	void add_edge(int u,int v) {
		G[u].push_back(v);
	}


	vector<int> topological_sort() {
		fill(indeg.begin(),indeg.end(),0);

		for(int v=0;v<n;v++) {
			for(auto u:G[v]) indeg[u]++;
		}
		queue<int> Q;
		for(int v=0;v<n;v++) {
			if(indeg[v]==0) Q.push(v);
		}
		while(!Q.empty()) {
			int v=Q.front();Q.pop();
			order.push_back(v);
			for(auto u:G[v]) {
				if(--indeg[u]==0) Q.push(u);
			}
		}

		return order;
	}
};


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

	int V,E;
	cin>>V>>E;
	TopologicalSort tsort(V);
	for(int i=0;i<E;i++) {
		int u,v;
		cin>>u>>v;
		tsort.add_edge(u,v);
	}
	auto order=tsort.topological_sort();
	for(auto v:order) cout<<v<<endl;

	return 0;
}



Measured memory_bytes: 3888
N, M = map(int, input().split())
l = []
for i in range(N):
    l.append(list(map(int, input().split())))

temp_l = [0]*M

for i in range(N):
    for j in range(1, l[i][0]+1):
        temp_l[l[i][j]-1] += 1

ans = 0
for i in range(M):
    if temp_l[i] == N:
        ans += 1

print(ans)

Measured memory_bytes: 3064
import itertools

A=list(map(int, input().split()))

p = list(itertools.permutations(range(3) ) )     

cst=sum(A)
for i in range(3):
  c=abs(A[p[i][1]]-A[p[i][0]])+abs(A[p[i][2]]-A[p[i][1]])
  if c<=cst:
    cst=c
print(cst)

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

int main() {
  string s;
  cin >> s;
  if (s[2]!=s[3]) {
    printf("No \n");
    return 0;
  }
  if (s[4]!=s[5]) {
    printf("No \n");
    return 0;
  }
  printf("Yes \n");
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {

        // string[] s = Console.ReadLine().Split(' ');

        int a = int.Parse(Console.ReadLine());

       // a = int.Parse(s[0]);
       // b = int.Parse(s[1]);
       

       Console.WriteLine("{0}:{1}:{2}",a/3600,(a%3600)/60,a%60);

    }

}

Measured memory_bytes: 9236
from fractions import gcd
from functools import reduce
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def lcm(a, b):
    return a // gcd(a, b) * b


def lcm_list(S):
    return reduce(lcm, S)


# mod m におけるaの逆元
def modinv(a, m):
    b = m
    u = 1
    v = 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= m

    # 負の場合は m を足して正の数にする
    if u < 0:
        u += m
    return u


def main():
    N = int(input())
    A = list(map(int, input().split()))
    L = lcm_list(A)
    L %= MOD
    ans = 0
    for a in A:
        a_ = modinv(a, MOD)
        ans += L * a_ % MOD
    ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14028
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<math.h>
using namespace std; 

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

typedef long long ll; 
typedef long double ld; 
#define prarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define prmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<"\t";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }
const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
const int mod=1000*1000*1000+7;  

// ----------------------------------------------------------------------------	-------------- 


void solve(){
	int n,k; cin>>n>>k; 
	vector<int> a,b; 
	for(int i=0;i<n;i++){
		int x; cin>>x; 
		if(x<=0){
			a.push_back(abs(x)); 
		}
		else {
			b.push_back(x); 
		}
	}
	sort(all(a)); sort(all(b)); 
	vector<ll> prea(sz(a)), preb(sz(b)); 
	for(int i=0;i<sz(a);i++){
		prea[i]=a[i]; 
		//if(i>0) prea[i]+=prea[i-1];
	}
	for(int i=0;i<sz(b);i++){
		preb[i]=b[i]; 
		//if(i>0) preb[i]+=preb[i-1]; 
	}
	ll ans=infl; 
	for(int i=0;i<=k;i++){
		if(sz(a)<i || sz(b) < k-i) continue; 
		ans=min(ans,(i>0?2*prea[i-1]:0)+(k-i>0? preb[k-i-1]:0)); 
		ans=min(ans,(i>0?prea[i-1]:0)+(k-i>0? 2*preb[k-i-1]:0)); 
	}
	cout<<ans<<endl; 
}


int main(){
	// clock_t beg=clock(); 
	fast_io; 
    cout << fixed << setprecision(13); 
	solve(); 	
	// clock_t end=clock(); 
	// fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}

Measured memory_bytes: 1656
#include <stdio.h>

int main()
{
  int A, B, T;
  scanf("%d%d%d", &A, &B, &T);

  int sum = 0;
  int temp = A;

  while ( A <= T + 0.5 ) {
    sum += B;
    A += temp;
  }
  printf("%d\n", sum);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int x[n];
    rep(i,n)cin >> x[i];

    int ans = 1001001001;

    rep(i,101){
        int tmp = 0;
        rep(j,n)tmp += (x[j] - i) * (x[j] - i);
        ans = min(ans, tmp);
    }

    cout << ans << endl;
    return 0;
}
 
 


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

int main (){
    vector<int> b(46298);
    for (int i = 0; i < 46298; i++)
    {
        b[i] = i*1.08;
    }
    int n;
    cin >> n;
    for (int i = 0; i<46298; i++)
    {
        if(b[i]  == n){
            cout << i <<endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))
r = [0]*(N+1)
#累積和
a = 0
for i in range(N):
  a += A[i]
  r[i+1] = a
minimum = 10**18
for i in range(1,N):
  snuke = r[i]
  arai = r[N]-r[i]
  if minimum > abs(snuke-arai):
    minimum = abs(snuke-arai)
print(minimum)

Measured memory_bytes: 24820
a,b,k = input().split(" ")
a = int(a)
b = int(b)
k = int(k)
c = a + b
if k >= a:
    b = c - k
    a =0
else:
    a = a - k
if b < 0:
    b = 0
print(str(a) + " "+ str(b))

Measured memory_bytes: 3060