akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	ll K; cin >> K;
	vll arr (50);
	F0R(i, 50) {
		arr[i] = 50 - 1;
		arr[i] += K / 50;
		if (i < K % 50) ++arr[i];
		else arr[i] -= K % 50;
	}
	print(50);
	F0R(i, 50) cout << arr[i] << " ";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,ss;
int main()
{
	cin >>s>>ss;
	for (int i=s.size()-ss.size();i>=0;i--)
	{
		bool fl=1;
		for (int j=0;j<ss.size();j++)
		{
			if (s[i+j]=='?') continue;//跳过下面语句直接进入下一个循环 
			if (s[i+j]!=ss[j])         
			{
				fl=0;
				break;                //结束循环
			}
		}
		if (fl)                   //没有break，匹配成功 
		{
		    for (int j=0;j<ss.size();j++) if (s[i+j]=='?') s[i+j]=ss[j];
		    for (int j=0;j<s.size();j++) if (s[j]=='?') s[j]='a';
		    cout <<s;
		    return 0;
		}
	}
	cout <<"UNRESTORABLE";
	return 0;
}

Measured memory_bytes: 3560
N, *A = map(int, open(0).read().split())
B = [A[0]]
for i in range(1,N):
  B += [B[-1]+A[i]]
j = 1
a = A[0]
b = A[1]
c = A[2]
d = B[-1]-B[2]
j = 0
h = 2
while h<N:
  if abs(d-c)>abs(d-c-2*A[h+1]):
    h += 1
    c += A[h]
    d -= A[h]
    continue
  break
x = max(a,b,c,d)
y = min(a,b,c,d)
ans = x-y
for i in range(2,N-2):
  b += A[i]
  c -= A[i]
  while j<i:
    if abs(b-a)>abs(b-a-2*A[j+1]):
      j += 1
      a += A[j]
      b -= A[j]
      continue
    break
  while h<N:
    if abs(d-c)>abs(d-c-2*A[h+1]):
      h += 1
      c += A[h]
      d -= A[h]
      continue
    break
  x = max(a,b,c,d)
  y = min(a,b,c,d)
  ans = min(ans,x-y)
print(ans)

Measured memory_bytes: 105764
from collections import deque
k = int(input())
ans = 1
q = deque()
for i in range(1, 10):
    q.append(i)

for i in range(k):
    x = q.popleft()
    if x%10 != 0:
        q.append(10*x+(x%10)-1)
    q.append(10*x + x%10)

    if x%10!=9:
        q.append(10*x + (x%10)+1)
print(x)


Measured memory_bytes: 11908
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
    int h, n,a;
    int sum=0;

    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        sum += a;
    }

    if (h <= sum) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        double A = Double.parseDouble(sc.nextLine());
        double B = Double.parseDouble(sc.nextLine());

        System.out.println(A > B ? "GREATER" : A < B ? "LESS" : "EQUAL");

    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long dp[110][5][5][5],s,n;
map <int,string> m;
int ok(int a, int b, int c , int d)
{
    if(m[a]+m[b]+m[c]=="AGC") return 0;
    if(m[a]+m[c]+m[b]=="AGC") return 0;
    if(m[a]+m[b]+m[d]=="AGC") return 0;
    if(m[a]+m[c]+m[d]=="AGC") return 0;
    if(m[b]+m[a]+m[c]=="AGC") return 0;
    if(m[b]+m[c]+m[d]=="AGC") return 0;
    if(m[b]+m[d]+m[c]=="AGC") return 0;
    if(m[c]+m[b]+m[d]=="AGC") return 0;
    return 1;
}
int main()
{
    cin>>n;
    m[0]='W';
    m[1]='A';
    m[2]='C';
    m[3]='G';
    m[4]='T';
    dp[0][0][0][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=4;j++)
            for(int q=0;q<=4;q++)
                for(int p=0;p<=4;p++)
                    for(int l=0;l<=4;l++)
                        if(ok(l,p,q,j))
                            dp[i][j][q][p]=(dp[i][j][q][p]+dp[i-1][q][p][l])%mod;
    for(int i=1;i<=4;i++)
        for(int j=1;j<=4;j++)
            for(int q=1;q<=4;q++)
                s=(s+dp[n][i][j][q])%mod;
    cout<<s;
    return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N;
ll D[100010];
ll sz[100010];
vector<int> ord;
vector<int> g[100010];
vector<P> res;
map<ll,int> idx;

ll dfs(int v){
  ll sum=0;
  for(int nv : g[v]){
    sum+=dfs(nv)+sz[nv];
  }
  return sum;
}

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

  cin>>N;
  rep(i,N){
    cin>>D[i];
    ord.push_back(i);
    sz[i]=1;
    idx[D[i]]=i;
  }
  sort(all(ord),[=](const int& a,const int& b){ return D[a] > D[b];});
  rep(j,ord.size()-1){
    int i=ord[j];
    ll nsz=D[i]+2*sz[i]-N;
    if(idx.find(nsz)==idx.end()){
      cout<<-1<<endl;
      return 0;
    }
    int nxt=idx[nsz];
    sz[nxt]+=sz[i]; res.push_back(P(nxt,i)); g[nxt].push_back(i);
  }
  if(sz[ord.back()]!=N){
    cout<<-1<<endl;
    return 0;
  }
  if(dfs(ord.back())!=D[ord.back()]){
    cout<<-1<<endl;
    return 0;
  }
  rep(i,res.size())cout<<res[i].fi+1<<" "<<res[i].se+1<<endl;

  return 0;
}


Measured memory_bytes: 18928
object Main extends App {
  import scala.io.StdIn._


  val squares = List.tabulate(6){_ ⇒
    val Array(h, w) = readLine.trim.split(' ').map(_.toInt).sorted
    Square(h, w)
  }
  val filtered = takeThreePair(squares)
  filtered match {
    case None ⇒ println("no")
    case Some(l@_::_::_::Nil) ⇒ if (l.map(s ⇒ List(s, s.rotate)).foldLeft(Nil:: Nil: List[List[Square]]){
      (l, r) ⇒ l.flatMap(p ⇒ r.map(_::p))
    }.exists{
      case a::b::c::Nil => canMake(a, b, c)
      case _ ⇒ ???
    }) println("yes")
    else println("no")
    case _ ⇒ ???
  }
  def canMake(a: Square, b: Square, c: Square): Boolean = {
    a.height == b.height && a.width == c.height && b.width == c.width
  }
  def takeThreePair(squares: List[Square]): Option[List[Square]] = {
    def eraseOne(list: List[Square])(predicate: Square ⇒ Boolean): Option[List[Square]] = {
      list match {
        case Nil ⇒ None
        case h::t if predicate(h) ⇒ Some(t)
        case h::t ⇒ eraseOne(t)(predicate).map(h::_)
      }
    }
    squares match {
      case h::t ⇒ eraseOne(t)(_ == h).flatMap(takeThreePair(_).map(h::_))
      case Nil ⇒ Some(Nil)
    }
  }
  case class Square(height: Int, width: Int) {
    def rotate: Square = Square(width, height)
  }
}


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

int main(){
  int n;
  cin >> n;
  string a,b;
  cin >> a >> b;
  int len=0;
  for(int i=0;i<n;i++){
    bool ok=true;
    for(int j=0;j<n-i;j++)
      if(a.at(i+j)!=b.at(j))
        ok=false;
    if(ok)
      len=max(n-i,len);
  }
  cout << n*2-len << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, K, C; cin >> N >> K >> C;
  string S; cin >> S;
  vector<int> l(K,-1), r(K,-1);
  rep(i,K) {
    if (i==0) l[i] = 0;
    else {
      int now = l[i-1] + (C+1);
      while (now<N&&S[now]=='x') now++;
      if (now>=N) break;
      l[i] = now;
    }
  }
  per(i,K) {
    if (i==K-1) r[i] = N-1;
    else {
      int now = r[i+1] - (C+1);
      while (now>=0&&S[now]=='x') now--;
      if (now<0) break;
      r[i] = now;
    }
  }
  // debug(all(l)); debug(all(r));

  rep(i,K) if (l[i]==r[i]) cout << l[i]+1 << endl;
  return 0;
}

Measured memory_bytes: 3332
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)

int main(){
    string a,b;
    cin >> a >> b;
    string ans;
    int aint, bint;
    bool flag = true;
    int i = 0;
    if (a.length() < b.length()) ans = "LESS";
    else if (a.length() > b.length()) ans = "GREATER";
    else{
        while(flag){
            aint = a[i] - '0';
            bint = b[i] - '0';
            if (aint < bint){
                ans = "LESS";
                flag = false;
            }
            if (aint > bint){
                ans = "GREATER";
                flag = false;
            }
            if (i > a.length()-1) flag = false;
            i++;
        }
    }
    if (a == b) ans = "EQUAL";
    cout << ans << endl;
    return 0;
}






Measured memory_bytes: 256
N = int(input())
a = [int(input()) for i in range(N)]

num = 0
now = 0
been = set()
been.add(0)

while now != 1:
    now = a[now] - 1
    if now in been:
        num = -1
        break
    else:
        been.add(now)
        num += 1

print(num)

Measured memory_bytes: 15908
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

signed main(){
    int N,X; cin>>N>>X;
    vec A(N);
    vec B(N-1);
    REP(i,N){
        cin>>A[i];
      A[i] -= X;
      A[i] = abs(A[i]);
    }
  int P=A[0];
    REP(i,N){
        P = gcd(P,A[i]);
    }
    Out(P);
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;


public class Main {
  private static class Tuple {
    public final int a;
    public final int b;
    public Tuple(int a, int b) {
      this.a = a;
      this.b = b;
    }
  }
  public static void main(String[] args) throws Throwable {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    long K = scanner.nextLong();
    Tuple[] ab = new Tuple[N];
    for (int i = 0; i < N; i++) {
      int a = scanner.nextInt();
      int b = scanner.nextInt();
      ab[i] = new Tuple(a, b);
    }
    Arrays.sort(ab, (x, y) -> Integer.compare(x.a, y.a));

    int lastA = -1;
    long k = 0;
    for (int i = 0; k < K && i < N; i++) {
      k += ab[i].b;
      lastA = ab[i].a;
    }

    System.out.println(lastA);
  }
}

Measured memory_bytes: 90868
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll mx = 1;
  ll ans = 0;
  rep(i, N) {
    if(A[i] == mx) {
      mx++;
    } else {
      ans += A[i]/mx-(A[i]%mx==0);
      if(i == 0) mx++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  char a, b, c;
  cin >> a >> b >> c;
  if(a!=b&&b!=c&&c!=a)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
A,B=map(int,input().split())
S=input()

if len(S) != A+B+1:
  print(0)
  print('No')
  exit()
  
for i in range(A):
  if S[i] not in set(map(str,list(range(10)))):
    print('No')
    exit()
if S[A] != '-':
  print('No')
  exit()
for i in range(A+1,A+B+1):
  if S[i] not in set(map(str,list(range(10)))):
    print('No')
    exit()
print('Yes')

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)

#define int64 int64_t
#define uint64 uint64_t
#define uint unsigned

int main()
{
    array<int, 10> hei;
    REP(i, 10)
        cin >> hei[i];
    sort(hei.begin(), hei.end(), [](int a, int b){ return a > b;});
    REP(i, 3)
        cout << hei[i] << '\n';
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e3 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

struct DisjointSet {
	int* par;
	DisjointSet (int _n){
		par = new int[_n];
		iota(par, par + _n, 0);
	}
	int operator [](int u){
		return Find(u);
	}
	int Find(int u){
		return (par[u] == u ? u : par[u] = Find(par[u]));
	}
	bool Unite(int u, int v){
		u = Find(u); v = Find(v);
		if(u == v) return false;
		par[u] = v;
		return true;
	}
};
DisjointSet dsu(N);
vector<pll> G[N];
vector<pair<ll, pll>> E, E2;
ll n, m, X;

ll root;
ll dis[N][N];
void DFS(int u, int p){
	for(auto e : G[u]){
		if(e.F == p) continue;
		dis[root][e.F] = max(dis[root][u], e.S);
		DFS(e.F, u);
	}
}
vector<ll> V;
ll p2[N];
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	p2[0] = 1;
	for(int i = 1; i < N; i++) p2[i] = (2 * p2[i - 1]) % Mod;
	cin >> n >> m >> X;
	ll u, v, w;
	for(int i = 1; i <= m; i++){
		cin >> u >> v >> w;
		E.pb({w, {u, v}});
	}
	sort(all(E));
	ll M = 0;
	for(auto x : E){
		if(dsu.Unite(x.S.F, x.S.S)){
			G[x.S.F].pb({x.S.S, x.F});
			G[x.S.S].pb({x.S.F, x.F});
			M += x.F;
		} else E2.pb(x);
	}
	if(X < M) return cout << "0\n", 0;
	for(int i = 1; i <= n; i++){
		root = i;
		DFS(i, -1);
	}
	ll c0 = 0;
	for(auto x : E2){
		V.pb(x.F - dis[x.S.F][x.S.S]);
		if(V.back() == 0) c0 ++;
	}
	if(M == X){
		cout << (p2[m] - (2 * p2[m - ((n - 1) + c0)]) + Mod + Mod) % Mod << '\n'; 
		return 0;
	}
	ll Gd = X - M;
	ll cnt = 0;
	ll ans = 0;
	sort(all(V));
	for(auto val : V){
		if(val == Gd){
			ans += 2 * p2[V.size() - cnt - 1];
		}
		cnt ++;
	}
	cout << ans % Mod << '\n';
	return 0;
}


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

const int N = 200005;

int n, m;
int a[N];

int solve() {
  int n;
  scanf("%d", &n);

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);

    if (i % 2 == 0 && a[i] % 2 == 1) ++ans;
  }

  printf("%d\n", ans);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 3820
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();

        // ルートN * ルートNのときが最も最小
        long divide1 = (long) Math.sqrt(N);

        while(N % divide1 != 0) {
            divide1--;
        }
        long divide2 = N / divide1;

        int len1 = String.valueOf(divide1).length();
        int len2 = String.valueOf(divide2).length();

        out.println(Math.max(len1, len2));
    }
}

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

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

    vector<int> ans(N);
    using P = pair<int, int>;
    queue<P> q;
    q.push(P(0, -1));
    while (!q.empty()) {
        P p = q.front();  q.pop();
        if (ans[p.first] != 0) continue;
        ans[p.first] = p.second + 1;
        for (int nv : G[p.first]) {
            if (ans[nv] == 0) q.push(P(nv, p.first));
        }

    }
    // DUMP(ans);

    for (int i = 1; i < N; ++i) {
        if (ans[i] == 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < N; ++i) cout << ans[i] << endl;
}


Measured memory_bytes: 11304
import java.util.*;
import java.lang.Math;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        int i = b - a - 1;
        int x = 0;

        for (int ii = 1; ii <= i; ii++) {
            x += ii;
        }
        System.out.println(x - a);
    }
}

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

#include <utility>

using namespace std;

int N, Q;
pair<char, int> S[100000];
int parent[100001];
int mark[100001];
int set[100001];

int findRoot(int p) {
  int root = p;
  while (set[root] != -1) {
    root = set[root];
  }
  while (p != root) {
    int t = set[p];
    set[p] = root;
    p = t;
  }
  return root;
}

void unionSet(int p, int q) {
  int root1 = findRoot(p);
  int root2 = findRoot(q);
  if (root1 != root2) {
    set[root1] = root2;
  }
}

int main() {
  //freopen("MarkedAncestor.in", "r", stdin);
  //freopen("2170-input.txt", "r", stdin);
  while (scanf("%d%d", &N, &Q) == 2 && !(N == 0 && Q == 0)) {
    parent[1] = 1;
    for (int i = 2; i <= N; ++i) {
      scanf("%d", &parent[i]);
    }
    set[1] = -1;
    for (int i = 2; i <= N; ++i) {
      set[i] = parent[i];
    }
    memset(mark, 0, sizeof(mark));
    mark[1] = 1;
    for (int i = 0; i < Q; ++i) {
      char buf[10];
      scanf("%s%d", buf, &S[i].second);
      S[i].first = buf[0];
      if (S[i].first == 'M') {
        set[S[i].second] = -1;
        mark[S[i].second]++;
      }
    }
    long long sum = 0;
    // From back to front.
    for (int i = Q - 1; i >= 0; --i) {
      if (S[i].first == 'M') {
        if (--mark[S[i].second] == 0) {
          unionSet(S[i].second, parent[S[i].second]);
        }
      } else if (S[i].first == 'Q') {
        int v = findRoot(S[i].second);
        //printf("findRoot(%d) = %d\n", S[i].second, v);
        sum += v;
      }
    }
    printf("%lld\n", sum);
  }
  return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define eb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define output(x) cout<<x<<endl;
#define fre(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define frd(i, a, b) for (int i = (int)(a); i >= b; --i)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int> > vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

const int maxn = 310000;

int dp[maxn];

int main(){
	cin.tie(0);ios_base::sync_with_stdio(0);	
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i+1];
	}
	fre(i,2,n){
		dp[i]=2e9;
		fre(j,max(i-k,1),i-1){
			dp[i]=min(dp[i], dp[j]+abs(a[j]-a[i]));
		}
	}
	output(dp[n]);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long ulli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define epool(i, m, n) for (lli i = m; i >= n; i--)
#define maxe *max_element
#define mine *min_element
#define plli pair<lli, lli>
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x, 0;
#define all(v) v.begin(),v.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define pf push_front

#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
 
lli gcd(lli a, lli b){
    if(a==0) return b;
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
 
lli modi(lli n,lli m=mod){ 
    if(n==0) return 0;
    n%=m;
    n+=m;
    n%=m;
    return n;
}
 
lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}
const lli MIN=-1*1e18;
const lli INF=1e18+999999999999999999;
const lli N=2e5+5;
const ldb pi=4*atan(1);

lli n,m,k,t;
//lli a,b,c,d;
lli p,q,l,r;
lli arr[N];
//lli a[N],b[N],c[N],d[N];
lli a,b,c,d;
lli x[1000005],y[1000005];
//map<lli,lli> m1,m2;
vector<lli> v,v1,v2;
lli pre[N],suff[N];
//lli vis[N]={0};
char grid[100][100];
vector<pair<lli,lli>> pl;

int32_t main(){
    fast_io
    lli i = 0,j=0;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
   // cout << fixed << setprecision(14);
   
    map<string,lli> mp;
   
    v.clear();
    v1.clear();
    v2.clear();
    pl.clear();
    
    cin >> n;
    string t[n];
    loop(i,0,n){
        cin >> t[i];
        mp[t[i]]++;
    }

    cout << mp.size() << endl;


}

Measured memory_bytes: 25508
#include <iostream>

#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::min;

int
main()
{
  int N, X;
  cin >> N >> X;
  int min_m = X;
  int remaining_x = X;
  for (int n = 0; n < N; n++)
  {
    int m;
    cin >> m;
    min_m = min(min_m, m);
    remaining_x -= m;
  }
  cout << remaining_x / min_m + N << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a_inputs = sorted([int(i) for i in input().split()])

k_num = len(a_inputs)
#弱い順にソート,最初のk人を一番弱いメンバーとする。
#残りを(k+1,k+2),(k+3,k+4),...(n-1,n)と並べた時のk+1,k+3...n-1の値値を求める

print(sum([a_inputs[i] for i in range(n,k_num,2)]))

Measured memory_bytes: 37084
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int main() {
	string s;
	cin >> s;
	int K;
	cin >> K;
	int N = s.size();
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		a[i] = (26 - (int)(s[i] - 'a')) % 26;
	}
	int b = -1;
	for (int i = 0; i < N; i++) {
		
		if (K - a[i] < 0) {
			
			continue;
		}
		K -= a[i];
		s[i] = 'a';
	}

	s[N - 1] = (char)(((int)(s[N - 1] - 'a') + K) % 26) + 'a';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 896
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

#define MAX_VALUE 9223372036854775807

int solve() {
	//ll n, k;
	//cin >> n >> k;

	//vector<ll> as(n);
	//REPD(i, 0, n) cin >> as[i];

	ll n, d;
	cin >> n >> d;

	ll x, y;
	ll res = 0;
	REPD(i, 0, n) {
		cin >> x >> y;
		if (x * x + y * y <= d * d) ++res;
	}

	RET(res);

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 3652
k = int(input())
seen = set()
num = 7
while True:
  if num%k==0:
    print(len(seen)+1)
    exit()
  elif num%k in seen:
    print("-1")
    exit()
  else:
    seen.add(num%k)
    num = (num*10+7)%k
    

Measured memory_bytes: 78008
#include<bits/stdc++.h>
using namespace std;
int used[200010];
int main(){
  int n,m;
  cin>>n>>m;
  int d[100010];
  for(int i=0;i<m;i++)cin>>d[i];
  for(int i=0;i<m;i++){
    if(used[d[m-1-i]])continue;
    used[d[m-1-i]]=1;
    cout<<d[m-1-i]<<endl;
  }
  for(int i=1;i<=n;i++){
    if(used[i])continue;
    used[i]=1;
    cout<<i<<endl;
  }
  return 0;
}



Measured memory_bytes: 4264
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define print(x) cout << #x << " = " << x << endl;

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;


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

	ll ans = 0;

	for (int b = K + 1; b <= N; b++) {
		// a < b のとき
		ans += b - K;
		if (K == 0) ans--;

		// b < a のとき
		ll k_ = N % b;
		ll n_ = N / b;
		if (k_ < K) ans += (n_ - 1) * (b - K);
		else ans += n_ * (k_ - K + 1) + (n_ - 1) * (b - k_ - 1);
		
		// b < a のとき
		//cout << "b: " << b << "-----" << endl;
		//cout << "  if b > a:" << endl;
		//for (int a = K; a < b; a++) {
		//	if (a == 0) continue;
		//	//cout << "   k: " << a << endl;
		//	//cout << "     a: " << a << endl;
		//	//cout << "(" << a << ", " << b << ")" << endl;
		//	ans++;
		//}

		// a > b のとき
		//for (int k = K; k < b; k++) {
		//	////cout << "    k: " << k << endl;
		//	//int a = k;
		//	//while ((a += b) <= N) {
		//	//	//cout << "      a: " << a << endl;
		//	//	//cout << "(" << a << ", " << b << ")" << endl;
		//	//	ans++;
		//	//}

		//	ans += (N - k) / b;
		//}
	}


	cout << ans << endl;

	return 0;
}

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

int G[110][110];
int N,num,lines,tar;
int D[1000];
int ret[1000];

void bfs(int src);

int main() {
	for (int i=0;i<110;i++) {
		for(int j=0;j<110;j++) {
			G[i][j] = 0;
		}
	}
	for(int i=0;i<1000;i++) {
		D[i] = 100;
	}
	cin >> N;
	for(int i=0;i<N;i++) {
		cin >> num >> lines;
		for(int j=0;j<lines;j++) {
			cin >> tar;
			G[num][tar] = 1;
		}
	}
	/*
	for(int i=0;i<num+1;i++) {
		for(int j=0;j<num+1;j++) {
			cout << G[i][j] << " ";
		}
		cout << endl;
	}
	*/
	bfs(1);
	for(int i=1;i<num+1;i++) {
		if((ret[i] == 0) && (i>1)) ret[i] = -1;
		cout << i << " " << ret[i] << endl;
	}

}
void bfs(int src) {
	int cur,dst;
	//cerr << "bfs root = " << src << endl;
	queue<int> Q; // ??´??°????????????????????\????????????
	Q.push(src);
	D[src] = 0; // ?????????
	while (! Q.empty()) {
		int cur = Q.front(); // ??????????´????????????????
		Q.pop();
// ???????¢??????¨??¨???
		ret[cur] = D[cur];
		//cerr << cur << " " << D[cur] << endl;
		for (int dst=1;dst<N+1;dst++) { // ???????????? dst ????????????
			if ((G[cur][dst] == 1) && (D[dst] == 100)) { // cur ?????? dst ??????????????????dst ???????¨??????????
				D[dst] = D[cur]+1; //
				Q.push(dst); // dst ????¨???????????????????
			}
		}
	}
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N; cin >> N;
  ll a[N];
  map<ll,ll> count;
  set<ll> s;
  for (ll i = 0; i < N; i++) {
    cin >> a[i];
    count[a[i]]++;
    s.insert(a[i]);
  }
  ll tot = 0;
  for (auto it = s.begin(); it != s.end(); it++) {
    tot += (count[*it]*(count[*it]-1)/2);
  }
  for (ll i = 0; i < N; i++) {
    cout << tot - count[a[i]] + 1 << endl;
  }
}

Measured memory_bytes: 17024
inputs = Array.new
while line = $stdin.gets
  inputs << line.chomp
end

N, K = inputs[0].split(" ").map(&:to_i)
cnts = Hash.new

N.times do |i|
  x = i + 1
  cnt = Math.log2(K.to_f/x.to_f).ceil

  if cnt < 1
    cnts[0] ||= 0
    cnts[0] += 1
  else
    cnts[cnt] ||= 0
    cnts[cnt] += 1
  end
end

res = 0
cnts.each do |k, v|
  if k == 0
    res += v
  else
    res += (1.0/2)**k*v
  end
end

p res / N

Measured memory_bytes: 1788
#include<iostream>

using namespace std;
#define int long long

signed main(){

   int N;
   cin>> N;
   int a[N], b[N];
   for(int i=0; i<N; i++){
      cin>> a[i]>> b[i];
   }

   int s=0, t=0;
   for(int i=N-1; i>=0; i--){
      if(a[i]+s==0){
         
      }else if(a[i]+s<=b[i]){
         s+=b[i]-(a[i]+s);
      }else{
         if(b[i]==1){

         }else if((a[i]+s)%b[i]==0){

         }else{
            s+=b[i]-((a[i]+s)%b[i]);
         }
      }
   }

   cout<< s<< endl;

   return 0;
}


Measured memory_bytes: 1792
import numpy as np
temp = input().split()
s = [input().split() for i in range(int(temp[0]))]
cnt = 0
for i in range(int(temp[0])):
  if np.sqrt(int(s[i][0])*int(s[i][0]) + int(s[i][1])*int(s[i][1])) <= int(temp[1]):
    cnt += 1
print(cnt)

Measured memory_bytes: 85604
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
     ll A, B, C, K;
     cin >> A >> B >> C >> K;

     ll sum = 0;
     for(ll i=1; i<=K; i++){
         if(i <= A){
             sum += 1;
         }
         else if(i<= A+B){
             sum += 0;
         }
         else{
             sum += -1;
         }
     }
     cout << sum << endl;
}

Measured memory_bytes: 3192
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS
import Data.Bits

nfIntPair :: (Int,Int) -> (Int,Int)
nfIntPair x@(!_,!_) = x

f :: (Int,Int) -> (Int,Int) -> (Int,Int)
f (x,m) (y,n) = case (x + y) `quotRem` 10 of
          (a,b) -> (a + b, m + n + 1 + a)

gen :: Int -> U.Vector (Int,Int)
gen a = U.iterateN 64 (\x -> f x x) (a,0)

computed :: V.Vector (U.Vector (Int,Int))
computed = V.fromList $ map gen [0..9]

pow' :: Int -> Int -> (Int,Int)
pow' a n = foldr1 f [ computed V.! a U.! i | i <- [0..60], testBit n i ]

main = do
  m <- readLn
  xs <- U.replicateM m $ do
    [d,c] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    -- c should be Int64
    return (pow' d c)
  print $ snd $ U.foldr1 f xs


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

n = int(input())

g = [[] for _ in range(n)]

ans = [-1] * n
odd = []
even = []
nums = [[], [], []]
for i in range(1, n + 1):
    nums[i % 3].append(i)

def dfs(v, p = -1, d = 0):
    if d % 2:
        odd.append(v)
    else:
        even.append(v)

    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, d + 1)

for i in range(n - 1): 
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

dfs(0)

zerocnt = len(nums[0])

if len(even) <= zerocnt:
    for even_node in even:
        ans[even_node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for odd_node in odd:
        ans[odd_node] = rest.pop()
elif len(odd) <= zerocnt: 
    for odd_node in odd:
        ans[odd_node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for even_node in even:
        ans[even_node] = rest.pop()
else: 
    for odd_node in odd:
        if len(nums[1]) != 0:
            ans[odd_node] = nums[1].pop()
        else:
            ans[odd_node] = nums[0].pop()
    for even_node in even:
        if len(nums[2]) != 0:
            ans[even_node] = nums[2].pop()
        else:
            ans[even_node] = nums[0].pop()

print(*ans)


Measured memory_bytes: 208012
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%lf",&n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%lf ",n)
#define dprin(n) printf("%lf\n",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

int main()
{
    int x;
    cin>>x;
    if(x<=599&&x>=400)
    cout<<"8";
    if(x<=799&&x>=600)
    cout<<"7";
    if(x<=999&&x>=800)
    cout<<"6";
    if(x<=1199&&x>=1000)
    cout<<"5";
    if(x<=1399&&x>=1200)
    cout<<"4";
    if(x<=1599&&x>=1400)
    cout<<"3";
    if(x<=1799&&x>=1600)
    cout<<"2";
    if(x<=1999&&x>=1800)
    cout<<"1";
return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD = 1000000007;
#define INF (1e9)
#define print(x) cout << x << endl;

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; }
typedef pair <ll,ll> P;


int main()
{
    ll N;
    cin >> N;
    print(24+24-N);
    return 0;
}


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

int main()
{
    int n,m,sum=0;
    int arr[100000];

    cin>>n>>m;

    for(int j=0; j<m; j++)
    {
        cin>>arr[j];
        sum += arr[j];
    }

    n = n-sum;

    if(n<0)cout<<-1<<endl;

    else cout<<n<<endl;

    return 0;
}


Measured memory_bytes: 3640
S = input()
ans = 'keyence'

if S[0] == 'k':
    flag = True
    for i in range(1, 7):
        if S[i] != ans[i]:
            flag = False
            break
    if flag:
        print('YES')

    else:
        if ans[i:] == S[-len(ans[i:]):]:
            print('YES')
        else:
            print('NO')
else:
    if S[-7:] == ans:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset> 
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
//#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}
 
template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod 
	ll ans=1;
	while(n){
		if(n&1) ans=(ans*a)%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
const int maxn=2e5+10;
const int maxai=1e6+5;
int n,a[maxn];
map<int,int> mark;
map<int,int> repeat;
set<int> s;
int vis[maxai];
inline int solve(){
    sort(a+1,a+n+1);
    int ans=0;
    for(auto ai:s){
        if(vis[ai]) continue;
        if(!repeat[ai]) ans++;
        for(int j=1;j*ai<maxai;j++){
            vis[j*ai]=1;
        }
    }
    return ans;
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
	read(n);
    rep(i,1,n){
        read(a[i]);
        if(s.count(a[i])){
            repeat[a[i]]=1;
        }
        s.insert(a[i]);
    }
    write(solve());
	//===========================================================
	return 0;
}

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

#define int double
 
int32_t main()
{
    int n,d;
    cin>>n>>d;
    int count =0,x,y;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        int sum = sqrt(x*x + y*y);
        if(sum<=d){
            count++;
        }
    }
    cout<<count;
  
    return 0;
}

Measured memory_bytes: 3836
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str=scan.next();
		for(int i=1;!"0".equals(str);i++){
			System.out.println("Case "+i+": "+str);
			str = scan.next();
		}
		scan.close();
	}
}

Measured memory_bytes: 29592
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x,a;
    a=0;
    cin >>x;
    while(x>=500){
        x -=500;
        a+= 1000;
    }
    while(x>=5){
        x -=5;
        a+=5;
    }
    cout << a<<endl;
    
}

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

int main() {
	auto cswap = [](int& x, int& y) { if (x > y) { auto tmp = x; x = y; y = tmp; }};
	while(1) {
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0) break;
		cswap(a, b);
		cout << a << " " << b << endl;
	}
}

Measured memory_bytes: 1160
def inpl(): return list(map(int, input().split()))

N = int(input())
P = inpl()
Q = sorted(P)

for i in range(N):
    for j in range(i, N):
        R = [p for p in P]
        R[i], R[j] = R[j], R[i]
        for k in range(N):
            if R[k] != Q[k]:
                break
        else:
            print("YES")
            exit()
else:
    print("NO")

Measured memory_bytes: 9120
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define MAX ((ll)1<<(ll)31)-1


int main(void) {
	int n; cin >> n;
	vint a(n + 1);
	rep(i, n) {
		 cin >> a[i];
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == cnt+1) {
			cnt++;
		}
	}
	if (cnt == 0) {
		cout << -1 << endl;
	}
	else {
		cout << n-cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stack>
#include<string>
#include<sstream>
#include<cstdio>
using namespace std;

double to_num(const string& str) {
  double d;
  stringstream ss;
  ss << str;
  ss >> d;
  return d;
}

int main() {
  string str;

  while (getline(cin,str)) {
    stringstream ss(str);
    stack<double> st;
    string e;

    while (ss >> e) {
      if (e == "+") {
        double b = st.top();
        st.pop();
        double a = st.top();
        st.pop();
        st.push(a + b);

      } else if (e == "-") {
        double b = st.top();
        st.pop();
        double a = st.top();
        st.pop();
        st.push(a - b);

      } else if (e == "*") {
        double b = st.top();
        st.pop();
        double a = st.top();
        st.pop();
        st.push(a * b);

      } else if (e == "/") {
        double b = st.top();
        st.pop();
        double a = st.top();
        st.pop();
        st.push(a / b);

      } else {
        st.push( to_num(e) );
      }
    }
    printf("%6f\n",st.top());

  }
}

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

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

int main() {
    int N,K; cin >> N >> K;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        int h; cin >> h;
        if(h >= K) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int[][] x = new int[N][D];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < D; j++) {
				x[i][j] = sc.nextInt();
			}
		}
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				int sum = 0;
				for (int k = 0; k < D; k++) {
					sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]); 
				}
				for (int k = 0; k * k <= sum; k++) {
					if (k * k == sum) {
						cnt++;
					}
				}
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21716