akhauriyash/Code-Regression huggingface dataset:
#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>;
#define chmax(x,y) x = max(x,y);

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        if (a > m) continue;
        jobs[m-a].push_back(b);
    }
    priority_queue<int> q;
    ll ans = 0;
    for (int i = m-1; i >= 0; i--) {
        for (int b : jobs[i]) {
            q.push(b);
        }
        if (!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8368
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    int n = s.length();

    const long long MOD = 1000000007;

    long long res = 0;
    vector<long long> dp(5, 0);
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {

        if (s[i] != '?') {
            int x = s[i] == 'A' ? 1 : s[i] == 'B' ? 2 : 3;
            for (int j = 2; j >= 0; --j) {
                if (x == j + 1) {
                    (dp[x] += dp[j]) %= MOD;
                }
            }
        } else {
            for (int j = 3; j >= 0; --j) {
                (dp[j + 1] += dp[j]) %= MOD; 
                (dp[j] *= 3) %= MOD;
            }
        }
    }

    cout << dp[3] << '\n';

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,k;
    ci(n>>k);
  st s;
    ci(s);

  ll count=1;
  FOR(i,1,n){
    if(s[i]!=s[i-1]){
      count++;
    }
  }

  ll ans=n-count+2*k;

  co(min(n-1,ans))
  }


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int pA;
    int pB;
    int pC;
    int pD;
    int ans;
    int ans2;


    pA = sc.nextInt();
    pB = sc.nextInt();
    pC = sc.nextInt();
    //許容距離
    pD = sc.nextInt();

    ans = pA - pC;
    ans2 = pC - pA;

    for(;;){
      //AさんとCさんが直接更新可能な場合
      if(ans <= pD && ans >= 0){
        System.out.println("Yes");
        break;
      }else if(ans2 <= pD && ans2 >= 0){
        System.out.println("Yes");
        break;
      }

      ans = pA - pB;
      if(ans < 0){
        ans = pB - pA;
      }

      ans2 = pC - pB;
      if(ans2 < 0){
        ans2 = pB - pC;
      }

      if(ans <= pD && ans2 <= pD){
        System.out.println("Yes");
        break;
      }

      System.out.println("No");
      break;
    }
  }
}


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

void sort(int *p, int N);

int main(){
    int N,M,A[101];
    int total_vote=0;
    cin >> N >> M;

    for(int i=0; i<N; i++){
        cin >> A[i];
        total_vote += A[i];
    }

    sort(A, N);

    int choice = 0;
    for(int i=0; i<M; i++){
        if( A[i] * 4 * M >= total_vote){
            choice++;
        }
    }

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

void sort(int *p, int N){
    for(int i=0; i<N; i++){
        for(int j=i; j<N; j++){
            if( p[i] < p[j]){
                int tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
            }
        }
    }
}

Measured memory_bytes: 256
class in{struct myIterator{int it;const bool rev;explicit constexpr myIterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(myIterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const myIterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const myIterator& begin(){return i;}const myIterator& end(){return n;}};

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

int dp[2001][2001]; //I
int dp2[2001][2001]; //OI
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
//    n = s.size(); m = t.size();
    reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());
    for(int i : in(n + 1)) for(int j : in(m + 1)) {
        if(i < n) {
            if(s[i] == 'I')
              dp[i + 1][j] = max(dp[i + 1][j], dp2[i][j] + 1);
            else if(dp[i][j] > 0)
              dp2[i + 1][j] = max(dp2[i + 1][j], dp[i][j] + 1);
        }
        if(j < m) {
            if(t[j] == 'I')
              dp[i][j + 1] = max(dp[i][j + 1], dp2[i][j] + 1);
            else if(dp[i][j] > 0)
              dp2[i][j + 1] = max(dp2[i][j + 1], dp[i][j] + 1);
        }
    }
    int ans = 0;
    for(int i : in(n + 1)) for(int j : in(m + 1)) {
        ans = max(ans, dp[i][j]);
    //    cout << i << ' ' << j << ' ' << dp[i][j] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 34508
#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main(void) {
  int i, n, A[10000+1], q, key, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d", &key);
    if(search(A, n, key))sum++;
  }
  printf("%d\n", sum);
  return 0;
}


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

using namespace std;

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

int n, m, p;

int main() {
	cin >> n >> m >> p;
	
	int stat[10000];
	REP(i, m) {
		scanf("%d", &stat[i]);
		stat[i] = (stat[i] + n - p) % n;
	}
	sort(stat, stat + m);
	
	int ans = INF;
	REP(i, m) {
		if (i == 0) ans = min(ans, n - stat[i]);
		else ans = min(ans, n - stat[i] + (n - stat[i] + stat[i - 1]));
		
		if (i == m - 1) ans = min(ans, stat[i]);
		else ans = min(ans, stat[i] + (stat[i] + n - stat[i + 1]));
	}
	
		
	cout << ans * 100 << endl;
	return 0;
}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	vector<int> a(3);
	cin>>n;
	rep(i,3) cin>>a[i];
	vector<int> l(n);
	rep(i,n) cin>>l[i];
	int ans=INF;
	rep(S,1<<n)rep(T,1<<n){//4^n全探索
		vector<int> cnt(3,0),sum(3,0);
		rep(i,n){
			if(S & 1<<i){
				if(T & 1<<i) cnt[2]+=l[i],sum[2]++;
				else cnt[1]+=l[i],sum[1]++;
			}else{
				if(T & 1<<i) cnt[0]+=l[i],sum[0]++;
			}
		}
		bool flag=false;
		int now=0;
		rep(i,3){
			if(!cnt[i]) flag=true;
			else now+=abs(a[i]-cnt[i])+10*(sum[i]-1);
		}
		if(flag) continue;
		chmin(ans,now);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  ll H;
  cin >> H;
  ll res = 0;
  ll ans = 1;
  while(H > 0){
    H = H / 2;
    // res++;
    ans *= 2;
  }
  cout << ans - 1 << endl;
  
}


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

int main() {
	int N, a[100], A = 0, B = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a, a + N, greater<int>());
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) A += a[i];
		else B += a[i];
	}
	cout << A - B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<ll,pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n)cin >> a[i];
	ll ans = 0, sum = a[0];
	REP(i, n-1){
		ans = (ans + (sum * a[i]) % mod) % mod;
		sum = (sum + a[i]) % mod;
	}
	cout << ans << endl;
} 


Measured memory_bytes: 4784
#include<stdio.h>
int main(void)
{
  int A,B,C,D,a,b;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  scanf("%d",&D);
  if(A<=B)a=A;
  else a=B;
  if(C<=D)b=C;
  else b=D;
  printf("%d\n",a+b);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val a, b, h, m = sc.nextDouble()
    val hh = (h % 12) * 30 + m / 2
    debug(hh)
    val mm = m * 6
    debug(mm)
    val diff = {
      val ss = math.abs(mm - hh)
      math.min(ss, 360 - ss)
    }
    debug(diff)
    val ans = math.sqrt(
      a * a + b * b - 2 * a * b * math
        .cos(math.toRadians(diff))
    )
    debug(a * a, b * b, -2 * a * b, math.cos(diff))
    println(ans)
  }

  //region

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
    Console.err.flush()
  }

  def printExecTime(process: => Unit): Unit = {
    val start = System.currentTimeMillis
    process
    debug("処理時間： " + (System.currentTimeMillis - start) + " ミリ秒")
  }

  def bitSearch[T](n: Int, choice: Vector[T]): Vector[Vector[T]] = {
    @tailrec
    def bitSearchLogic(n: Int,
                       choice: Vector[T],
                       acc: Vector[Vector[T]]): Vector[Vector[T]] = {
      if (n == 0) acc
      else {
        val newAcc =
          acc.flatMap(vec => {
            choice.map(c => vec :+ c)
          })
        bitSearchLogic(n - 1, choice, newAcc)
      }
    }

    val firstAcc = choice.map(i => Vector(i))
    bitSearchLogic(n - 1, choice, firstAcc)
  }
  //endregion
}


Measured memory_bytes: 55444
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	int a, b;
	string op;
	cin >> a >> op >> b;
	if (op[0] == '+') cout << a + b << endl;
	else cout << a - b << endl;
}


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

signed main(){

  int n; cin >> n;
  if(n == 1){
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  for(int i = 1; i*i <= n; i++){
    if(n%i == 0){
      int t = n/i - 1;
      if(n/t == n%t) ans += t;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//  ⚫⚫ | ⚫➖➖ ⚫⚫ ⚫➖⚫⚫ ⚫➖⚫⚫ | ➖⚫⚫⚫ ⚫ | ⚫➖ | ⚫➖⚫ ⚫ ➖⚫⚫ | ➖⚫➖⚫ ➖➖➖ ➖⚫⚫ ⚫ ⚫➖⚫
#include<bits/stdc++.h>
#define n0_nnE int main(){
using namespace std;
typedef long long ll;
n0_nnE
	ll mx=0,n,an=0;cin>>n;
	vector<ll> ls(n);
	for(ll &x:ls) cin>>x;
	for(ll x:ls){
	mx=max(mx,x);an+=mx-x;
	}
cout<<an;

}

Measured memory_bytes: 4812
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();

        if (K < S.length()) {
            System.out.println(S.substring(0, K) + "...");
        } else {
            System.out.println(S);
        }
    }
}

Measured memory_bytes: 38572
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int N,M,ans=0,i;
	scanf("%d%d",&N,&M);
	for(i=1;i*i<=M;i++){
		if(M%i==0){
			int x=i,y=M/x;
			if(y >= N)ans = ans<x?x:ans;
			if(x >= N)ans = ans<y?y:ans;
		}
	}
	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <climits>
#include <algorithm>

using namespace std;

const int len = 100010;
int n,a[len];

int main() {
    //freopen("test.in","r",stdin);
    cin >> n;
    long long sum = 0;
     for (int i=1;i<=n;i++) {
         cin >> a[i];
         sum += a[i];
     }
     if (sum%10 != 0) cout << sum << endl;
     else {
    sort(a+1,a+n+1);
    for (int i=1;i<=n;i++) {
        if (a[i] % 10) sum -= a[i];
        if (sum%10!=0) break;
      }
     if (sum % 10 == 0) cout << 0 << endl;
     else cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
 
public class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt(); //モンスターの数
    int K = scan.nextInt(); //必殺技の回数
    long[] H = new long[N+1];
    long MaxH = 0;

    for(int i=1; i<=N; i++) {
    	H[i] = scan.nextLong();
    }
    
    Arrays.sort(H);
    
    for(int i =1; i<=N-K; i++) {
    MaxH = MaxH + H[i];
    }
    System.out.println(MaxH);
  }
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a = 0;
	REP(i, 4) {
		char c;
		cin >> c;
		if (c == '+')a++;
		else a--;
	}
	cout << a << endl;
}

Measured memory_bytes: 256
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

string yes="YES",no="NO";


int N;
VI Cs,Ss,Fs;

LL solve(int s){

    if(s==N-1){return 0LL;}

    LL ans=0LL;

    FOR(i,s,N){
        //cerr<<"index"<<i<<endl;
        if(i==s){ans+=Ss[i];ans+=Cs[i];}
        else if (i == N-1) { return ans; }
        else{
            //for(;Ss[i]>ans||ans%Fs[i]!=0;ans++){}
            // for(int vv=0;vv<200;vv++){
            //     if(Ss[i]<=ans&&ans%Fs[i]==0){break;}
            //     ans++;
            //     //cerr<<"ans:"<<ans<<endl;
            // }
            LL a=Ss[i];
            while(true){
                //cerr<<"a:"<<a<<"ans:"<<ans<<endl;
                if(a>=ans){   break;}
                a+=Fs[i];
            }
            ans=a;
            ans+=Cs[i];
        }
       //cerr<<"toutyaku time"<<ans<<endl;
    }

    return ans;

}


int main(){
 
    cin>>N;
    Cs.resize(N);
    Ss.resize(N);
    Fs.resize(N);

    REP(i,N-1){
        cin>>Cs[i]>>Ss[i]>>Fs[i];
    }

    REP(start,N){
        //cerr<<"start:"<<start<<endl;
        cout<<solve(start)<<endl;

    }



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, S=0;
  cin >> N;
  for(int i = 0; i < 9; i++){
    S = S + (N % int(std::pow(10, i+1)) / int(std::pow(10, i)));
  }
  if(N % S == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
using namespace std;

int main() {
	long long S;
	cin >> S;

	long long x2 = 1000000000, x3, y3;
	y3 = (S + (x2 - 1)) / x2;
	x3 = x2 * y3 - S;

	cout << 0 << " " << 0 << " " << x2 << " " << 1 << " " << x3 << " " << y3 << " " << endl;
}


Measured memory_bytes: 256
from itertools import accumulate
n=int(input())
A=list(map(int,input().split()))
S=list(accumulate(A))
left=0
right=2
ans=float('inf')
for i in range(1,n-2):
    while abs(S[left]-(S[i]-S[left]))>abs(S[left+1]-(S[i]-S[left+1])):
        left+=1
    while abs(S[right]-S[i]-(S[n-1]-S[right]))>abs(S[right+1]-S[i]-(S[n-1]-S[right+1])):
        right+=1
    minL,maxL=min(S[left],S[i]-S[left]),max(S[left],S[i]-S[left])
    minR,maxR=min(S[right]-S[i],S[n-1]-S[right]),max(S[right]-S[i],S[n-1]-S[right])
    ans=min(ans,max(maxL,maxR)-min(minL,minR))
print(ans)

Measured memory_bytes: 24176
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        //int[] p = new int[n];
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (sc.nextInt() != i + 1) {
                cnt++;
            }
            if (cnt > 2) {
                break;
            }
        }
        if (cnt > 2) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }

    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
 #define ll long long
#define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define test int t; cin >> t; while(t--)
 #define inp(n) int n;cin >> n;
 #define mp make_pair
 #define pb push_back
 #define forl(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second

using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)   return a;  return gcd(b, a % b);
}
void add(int &x, int &y)
{
    if(x!=0)x--,y++;
}
 int32_t main()
{
     fast;
    
//    test
//    {
//       
//    }
    // a b c bc=6,ac=5,ab=4;
    ll n;cin>>n;string a;cin>>a;ll arr[10]={0};ll ans=1;ll m=998244353;
    for(ll i=0;i<a.length();i++)
    {
        int ch = a[i]=='R'?1:a[i]=='G'?2:3;
        if(arr[7-ch])ans=((arr[7-ch])*ans)%m,arr[7-ch]--;
        else if( ch ==1 && (arr[2]+arr[3])) ans = (ans*(arr[2]+arr[3]))%m,add(arr[2],arr[4]),add(arr[3],arr[5]);
        
        else if( ch ==2 && (arr[1]+arr[3])) ans = (ans*(arr[1]+arr[3]))%m,add(arr[1],arr[4]),add(arr[3],arr[6]);
        
        else if( ch ==3 && (arr[2]+arr[1])) ans = (ans*(arr[2]+arr[1]))%m,add(arr[2],arr[6]),add(arr[1],arr[5]);
                                                                            
        else arr[ch]++;
    }
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%m;
    }

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














Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    string n; cin >> n;
    result = n.length();
    if(n[result-1] == '3')
        cout << "bon" << endl;
    else if(n[result-1] == '0' || n[result-1] == '1' || n[result-1] == '6' || n[result-1] == '8')
        cout << "pon" << endl;
    else
    {
        cout << "hon" << endl;
    }
    
    //int k; cin >> k;
    /*
    vector<int> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    */

    //cout << result << endl;
    return 0;
}

Measured memory_bytes: 3608
#!/usr/bin/env python3


def main():
    a, b, c, k = map(int, input().split())

    ans = a
    num = a + b

    if k <= a:
        print(int(k))
        return
    elif num < k:
        ans -= k - num
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
import math
def ccw(p1,p2,p3):
    return (p2[0]-p1[0])*(p3[1]-p2[1])-(p2[1]-p1[1])*(p3[0]-p2[0])
while True:
    n=input()
    if n==0:
        break
    p=[0]*n
    for i in xrange(n):
        p[i]=map(float,raw_input().split(","))
    P=min(p,key=lambda a:(a[1],a[0]))
    p.sort(key=lambda x:math.atan2(x[1]-P[1],x[0]-P[0]))
    M,ans=0,0
    for i in xrange(1,n-1):
        if all([ccw(p[M],p[i],p[j])>=0 for j in xrange(i+1,n)]):
            M=i
        else:
            ans+=1
    print ans

Measured memory_bytes: 4488
N = int(input())
S = input()
#左から数える
W=[0]*N
w = 0
for i in range(N):
    if S[i] == "W":
        w += 1
    W[i] = w
#右から数える
E = [0]*N
e = 0
for i in range(N):
    if S[N-1-i] == "E":
        e += 1
    E[N-1-i] = e
ans = 10**9
for i in range(N):
    count = W[i] + E[i]
    ans = min(ans,count)

print(ans-1)

Measured memory_bytes: 17644
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	ll n;
	ll a[200002];
	ll d[200002]={};

	cin>>n;

	ll total=0;
	rep(i,n){
		cin>>a[i];
		d[a[i]]++;
		total+=d[a[i]]-1;
	}
	rep(i,n){
		cout<<total-d[a[i]]+1<<endl;
	}

	return 0;
}


Measured memory_bytes: 5760
H,W,K=map(int,input().split())
S=[[int(x) for x in list(str(input()))] for _ in range(H)]
T=[[0]*(W+1) for x in range(H+1)]

def main():
  for h in range(H):
    for w in range(W):
      T[h][w]=T[h][w-1]+S[h][w]

  for h in range(1,H):
    for w in range(W):
      T[h][w]=T[h][w]+T[h-1][w]

  m=(H-1)*(W-1)
  for p in range(2**(H-1)):
    D=[x for x in range(H-1) if p&(2**x)!=0]+[H-1]
    c,b=0,-1
    f=False
    for w in range(W):
      u=-1
      for d in D:
        if T[d][w]-T[u][w]-T[d][b]+T[u][b]>K:
          if b==w-1:
            f=True
          c,b=c+1,w-1
          break
        u=d
      if f==True:
        break
    else:
      m=min(m,c+len(D)-1)
  print(m)
main()



Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int a, b;
	cin >> a >> b;
	
	cout << (a / __gcd(a,b) * b);

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int dfs(ll a, ll b, ll c) {
  if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
    return 0;
  }
  if (a == b && b == c) {
    return -1;
  }
  return 1 + dfs((b+c)/2, (a+c)/2, (a+b)/2);
}

void solve() {
  ll a, b, c;
  cin >> a >> b >> c;
  cout << dfs(a, b, c) << endl;
}

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

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <bitset>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;


int main(){
    string s[]={"mon","tue","wed","thu","fri","sat","sun"};
    int x;cin>>x;
    int t=1;
    int ans=4;
    while(t!=x){
        t++;
        ans++;
        if(ans==7)ans=0;
    }
    cout<<s[ans]<<endl;
    
    return 0;
}




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

const ll INF = 1LL<<60;

int v[105];
int w[105];
ll dp[105][100005];

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

    rep(i,n) cin >> w[i] >> v[i];

    rep(i,n+1) rep(sum_v, 100001) dp[i][sum_v] = INF;
    dp[0][0] = 0;

    rep(i,n )rep(sum_v,100001) {
        if (sum_v >= v[i]) dp[i+1][sum_v] = min(dp[i][sum_v - v[i]] + w[i], dp[i][sum_v]);
        else dp[i+1][sum_v] = dp[i][sum_v];
    }
    
    ll maxv = 0;
    rep(sum_v,100001) {
        if (dp[n][sum_v] <= k) maxv = sum_v;
    }

    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 80128
N=int(input())
say="No"
if(N<3):
    print("No")
else:
    D1=input()
    D2=input()
    t1=(D1[0]==D1[2])
    t2=(D2[0]==D2[2])
    for i in range(N-2):
        Dn=input()
        if(D1[0]==D1[2] and D2[0]==D2[2] and Dn[0]==Dn[2]):
            say="Yes"
        D1,D2=D2,Dn
print(say)

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

#define speed 			    ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n)		    for(ll i=a;i<n;i++)
#define even(x) 	            (((x)%(2))==(0))
#define odd(x) 			    (((x)%(2))==(1))
#define meme(x) 		    memset(x, 0, sizeof(x))
#define mod       		    1000000007

#define pb              	    push_back
#define mp                          make_pair
#define ff 			    first
#define ss 			    second
#define all(x)                      (x).begin(),(x).end()

typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;

int main()
{
    speed
    string s;cin>>s;
    int cnt=0;

    for(int i=0;i<s.length();i++)
    {
	    if(s[i]=='R')
	    cnt++;
    }

    if(cnt==0)
    cout<<0;
    else if(cnt==1)
    cout<<1;
    else if(cnt==2 && s.length()==2)
    cout<<2;
    else if(cnt==2 && s=="RSR")
    cout<<1;
    else if(cnt==2)
    cout<<2;
    else
    {
	    cout<<3;
    }
    
}



Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;

int main() {
    char A, B;
    cin >> A >> B;

    if (A < B) {
        cout << "<" << endl;
    }
    else if (A > B) {
        cout << ">" << endl;
    }
    else {
        cout << "=" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::base_sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define M 1000000000+7
using namespace std;

signed main(){
    map<string,int> m;
    //set<string> s;
    int t;cin>>t;
    int p=0;
    int c=0;
    while(t--){
        string x;cin>>x;
        sort(x.begin(),x.end());
        if(m.find(x) == m.end())
            m[x]=1;
        else
            m[x]++;
    }
    for(auto it=m.begin();it!=m.end();it++){
        int x=((it->second)*(it->second - 1))/2;
        c+=x;
    }
    cout<<c;
    return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;
ll n,x,d;
ll dp[55*55*55];
vector<vector<ll>> v(55);
vector<ll> m(55);
vector<ll> g(55);

pair<ll,ll> seica(ll num){
	ll kazu = 1;
	ll ryou = m[num];
	REP(i,v[num].size()){
		auto now = seica(v[num][i]);
		kazu += now.FI;
		ryou += now.SE;
	}
	m[num] = ryou;
	g[num] = kazu;
	return MP(kazu,ryou);
}

int main(){
	cin >> n >> x >> d;
	REP(i,n){
		cin >> m[i];
		if(i != 0){
			ll tmp;cin >> tmp;v[tmp-1].PB(i);
		}
	}
	seica(0);
	REP(i,55*55*55)dp[i] = INF;
	dp[0] = 0;
	
	REP(i,n){
		ll w = min(50LL,d);
		if(i == 0)w = 50;
		for(ll k = 1;w > 0;k <<= 1){
			ll mul = min(k,w);
			for(ll j = 55*55*50;j >= g[i] * mul;j--){
				dp[j] = min(dp[j],dp[j-g[i]*mul]+m[i]*mul);
			}
			w -= mul;
		}
	}
	
	
	DBG(cout << "HOGE" << endl;);
	vector<pair<double,ll>> donatu;
	REP(i,n){
		donatu.PB(MP((double)m[i]/(double)g[i],i));
	}
	sort(ALL(donatu));
	ll ans = 0;
	d = max(0LL,d-50);
	DBG(cout << "d " << d << endl;);
	DBG(cout << "DP " << endl;SHOW1d(dp,55*55));
	DBG(cout << "m " << endl;SHOW1d(m,n));
	DBG(cout << "g " << endl;SHOW1d(g,n));
	REP(i,55*55*50){
		if(dp[i] <= x){
			ll hoge = i;
			ll hogehoge;
			ll tmp = x - dp[i];
			REP(i,n){
				ll w = d;
				if(donatu[i].SE == 0)w = 1000000000000LL;
				hogehoge = min((tmp/m[donatu[i].SE]),w);
				hoge += hogehoge*g[donatu[i].SE];
				tmp = max(0LL,tmp-hogehoge*m[donatu[i].SE]);
			}
			ans = max(ans,hoge);
		}
	}
	
	cout << ans << endl;

	return 0;
}


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

int main(){
  string s, t;
  cin >> s;
  cin >> t;
  for(int i=0;i<s.length();i++){
    if(s[i] != t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  if(s.length()+1 == t.length()){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <math.h>
int main(void){
	double x1,y1,x2,y2;
	double L;
	
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	
	L = sqrt(pow((x1-x2),2)+pow((y1-y2),2));
	
	printf("%6.8lf\n",L);
	
	return 0;
}

Measured memory_bytes: 656
n,x = map(int, input().split())
town = list(map(int, input().split()))

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

base = abs(town[0]-x)
for i in range(0,n):
    if (base >= abs(town[i]-x)):
        base = gcd(base, abs(town[i]-x))
        
    else:
        base = gcd(abs(town[i]-x), base)
print(base)

Measured memory_bytes: 14228
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n'&&c!=EOF;)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	for (string s, t; scan(s, t);) {
		vector<vector<int>> d(s.size() + 1, vector<int>(t.size() + 1));
		int l {};
		for (int i: range(1, s.size() + 1))
			for (int j: range(1, t.size() + 1))
				l = max(l, d[i][j] = s[i - 1] == t[j - 1] ? d[i - 1][j - 1] + 1: 0);
		outl(l);
	}
}


Measured memory_bytes: 64952
#include<bits/stdc++.h>
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
#define sz(x) (int)x.size()
#warning Remeber to change t
using namespace std;
typedef long long ll;
inline void debug() {
	#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("output.txt", "w", stdout);
	#endif
	}

int main(){
	Speed_UP
	ll t;
	//cin>>t;
	t=1;
	while(t--){
		ll n,d;
		cin>>n>>d;
		ll ans=0;
		for(int i=0;i<n;i++){
			double x,y;
			cin>>x>>y;
			if(sqrt(x*x+y*y)<=d)
				ans++;
			
		}
		
		cout<<ans;
		
		
		
	}





}


Measured memory_bytes: 3860
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}
long long t[200005];

int main(void){
    long long ans = 0;
    long long N, T;
    scanf("%lld %lld", &N, &T);
    int i;
    for (i = 0; i < N; i++){
        scanf("%lld", &t[i]);
    }
    t[N] = t[N-1]+T;
    for (i = 1; i <= N; i++){
        if (t[i-1]+T >= t[i]){
            ans += t[i]-t[i-1];
        }else{
            ans += T;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    Int res = 0;
    s.pop_back();
    while (not s.empty()) {
        if (s.size() % 2 == 1) {
            s.pop_back();
            continue;
        }
        string a = s.substr(0, s.size() / 2);
        string b = s.substr(s.size() / 2);
        if (a == b) {
            res = s.size();
            break;
        }
        s.pop_back();
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 256
def io_tmp():
    global input
    import io
    f = io.StringIO(open(0).read())
    input = f.readline

io_tmp()


from scipy.sparse.csgraph import floyd_warshall
import numpy as np

N, M, L = map(int, input().split())
graph = np.zeros((N, N), dtype=np.int64)
for _ in range(M):
    s, t, w = map(int, input().split())
    if w <= L:
        graph[s-1, t-1] = graph[t-1, s-1] = w
dist = floyd_warshall(graph, directed=False)
dist = floyd_warshall(dist <= L, directed=False)
dist[np.isinf(dist)] = 0.0

Q = int(input())
ans = []
for _ in range(Q):
    s, t = map(int, input().split())
    ans.append(int(dist[s-1][t-1]) - 1)
print(*ans, sep='\n')


Measured memory_bytes: 23856
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main()
{
    large k;
    cin >> k;

    int found = -1;
    large sevens = 0;
    for (auto i = 1; i <= 1'000'000 && found < 0; ++i) {
        sevens = (sevens * 10 + 7);
        auto x = sevens / k;
        sevens -= k * x;
        if (sevens == 0) {
            found = i;
        }
    }

    cout << found << endl;
    return 0;
}


Measured memory_bytes: 3632
// AOJ 2930 Information Search
// 2018.3.12 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in() {  // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n) { // 非負整数の表示（出力）
	int i;
	char ob[20];

	if (!n) pc('0');
	else {
		i = 0; while (n) ob[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(ob[i]);
	}
}

#define INF 1000000001
int n, m;
int a[200005], b[200005];
int A[200005], B[400005];

int main()
{
	int i, j, SA, SB;

	n = in(), m = in();
	for (i = 0; i < n; i++) a[i] = in();
	for (j = 0; j < m; j++) b[j] = in();
	a[n] = b[m] = INF;
	SA = SB = 0, i = j = 0;	while (1) {
		while (a[i] < b[j]) B[SB++] = a[i++];
		while (b[j] < a[i]) B[SB++] = b[j++];
		if (a[i] == INF) break;
		if (a[i] == b[j]) A[SA++] = a[i++], B[SB++] = b[j++];
	}
	out(SA), pc(' '), out(SB), pc('\n');
	for (i = 0; i < SA; i++) out(A[i]), pc('\n');
	for (i = 0; i < SB; i++) out(B[i]), pc('\n');
	return 0;
}




Measured memory_bytes: 3476
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

x, a, b = na()
if a >= b:
    print("delicious")
elif (a+x) >= b:
    print("safe")
else:
    print("dangerous")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;

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

int main()
{
    int h, w, sy, sx, gy, gx;
    cin >> h >> w >> sy >> sx >> gy >> gx;
    sy--; sx--; gy--; gx--;
    vector<string> field(h);
    rep(i,h) cin >> field[i];
    auto flatten = [&] (int y, int x) { return y * w + x; };

    //グラフ生成
    int n = h*w;
    vector<vector<P>> G(n, vector<P>(0));
    rep(y,h) rep(x,w) rep2(dy,-2,3) rep2(dx,-2,3)
    {
        int ny = y + dy;
        int nx = x + dx;
        if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
        if(field[y][x] == '#' || field[ny][nx] == '#') continue;
        int u = flatten(y, x);
        int v = flatten(ny, nx);
        if(abs(dy) + abs(dx) <= 1)
        {
            G[u].emplace_back(v, 0);
            G[v].emplace_back(u, 0);
        }
        else
        {
            G[u].emplace_back(v, 1);
            G[v].emplace_back(u, 1);
        }
    }
    rep(i,n)
    {
        sort(G[i].begin(), G[i].end());
        G[i].erase(unique(G[i].begin(), G[i].end()), G[i].end());
    }
    
    V dist(n, INF);
    int s = flatten(sy, sx);
    int g = flatten(gy, gx);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    while(!que.empty())
    {
        auto [d, v] = que.top();
        que.pop();
        if(dist[v] < d) continue;
        for(auto [to, cost]:G[v])
        {
            if(chmin(dist[to], dist[v] + cost))
            {
                que.emplace(dist[to], to);
            }
        }
    }

    int ans = dist[g];
    if(ans == INF) ans = -1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 172016
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<Pll> T(N);
    ll x, l;
    rep(0, i, N)
    {
        cin >> x >> l;
        T.at(i).first = x + l;
        T.at(i).second = x - l;
    }
    sort(all(T));
    int ans = 0;
    ll left = -1000000000;
    rep(0, i, N)
    {
        if (T.at(i).second < left)
        {
            continue;
        }
        else
        {
            left = T.at(i).first;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = (int)2e5 + 10;
vector<int> T[N];
int c[N][2];
int col[N];
bool delt[N];

int main(){
  fastIO;
  int n, m;
  cin >> n >> m;
  char q;
  for(int i = 1; i <= n; i ++ ){
    cin >> q;
    col[i]=q-'A';
  }
  int u, v;
  for(int i = 1; i <= m; i ++ ){
    cin >> u >> v;
    T[u].push_back(v);
    T[v].push_back(u);
    c[u][col[v]]++;
    c[v][col[u]]++;
  }
  queue<int> sh;
  for(int i = 1; i <= n; i ++ ){
    if(c[i][0] == 0 || c[i][1] == 0){
      sh.push(i);
      delt[i]=true;
    }
  }
  int node;
  while(!sh.empty()){
    node = sh.front();
    sh.pop();
    for(auto x : T[node]){
      c[x][col[node]]--;
      if((c[x][0] == 0 || c[x][1] == 0) && !delt[x]){
        sh.push(x);
        delt[x]=true;
      }
    }
  }
  bool ans = false;
  for(int i = 1; i <= n; i ++ ) ans |= !delt[i];
  if(ans)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}


Measured memory_bytes: 13184