akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	bool f = false;
	if (abs(a - c) <= d) f = true;
	if (abs(a - b) <= d && abs(b - c) <= d) {
		f = true;
	}
	if (f) cout << "Yes" << endl;
	else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int ar[20][30];
    int n, d;
    cin >> n >> d;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++) cin >> ar[i][j];
    }
    int cnt=0;
    for(int i=0;i<n-1;i++) {
        for(int j=i+1;j<n;j++) {
            int ans=0;
            for(int k=0;k<d;k++) {
                int t = ar[i][k] - ar[j][k];
        
                ans+=(t*t);
            }
            double sq = sqrt(double(ans));
            int cm = sqrt(ans);
            if(cm == sq) cnt++;
        }
    }
    cout << cnt << endl;
}

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

using namespace std;

const int N = 1e5 + 5;

int n, m, h[N];
long long a[N];
long long low = -2e15, high = 2e15, ans;
vector <pair <int, int> > g[N];
bool ok = false;

void dfs (int u) {
    if (h[u] & 1) low = max(low, -a[u]);
    else high = min(high, a[u]);

    for (auto i: g[u]) {
        int v = i.first;
        int w = i.second;

        if (!h[v]) {
            h[v] = h[u] + 1;
            a[v] = w - a[u];
            dfs(v);
        }

        if ((h[u] + h[v]) & 1) {
            if (a[u] + a[v] != w) {
                printf("%d", 0);
                exit(0);
            }

            continue;
        }

        int val = (w - a[u] - a[v]) * (h[u] & 1 ? 1 : -1);
        if (!ok) {
            ans = val;
            ok = true;
        }

        if (ans != val) {
            printf("%d", 0);
            exit(0);
        }
    }
}

int main(){
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; i++) {
        int u, v, w;
        scanf("%d %d %d", &u, &v, &w);
        g[u].push_back(make_pair(v, w));
        g[v].push_back(make_pair(u, w));
    }

    h[1] = 1;
    dfs(1);

    if (ok) {
        if (ans & 1 || ans <= 2 * low || ans >= 2 * high) printf("%d", 0);
        else printf("%d", 1);

        return 0;
    }

    printf("%lld", max(0LL, high - low - 1));
    return 0;
}


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

int main(void){
  int i,j,flag;
  char s[100];
  char str[200];
  char t[100];
  char u[100];
  scanf("%s",s);
  scanf("%s",t);
  snprintf(str,200,"%s%s",s,s);
  for(i=0;i<strlen(s);i++){
    flag=1;
    strncpy(u,str+i,strlen(s));
    u[i+strlen(s)]='\0';
    //printf("%s\n",u);
    if(strcmp(u,t)!=0) flag=0;
    if(flag==1){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
int h,w,n;
bool check(vector<string> grid){
  bool update = true;
  while(update){
    update = false;
    REP(x,w){
      REP(k,h)REP(y,h-1)if(grid[y+1][x]=='.')swap(grid[y+1][x],grid[y][x]);
    }

    bool del[31][31]={};
    REP(y,h){
      int c = 1;
      FOR(x,1,w+1){
        if(x<w && grid[y][x]==grid[y][x-1] && grid[y][x]!='.') c++;
        else{
          if(c >= n)REP(i,c)del[y][x-1-i] = true;
          c = 1;
        }
      }
    }
    REP(x,w){
      int c = 1;
      FOR(y,1,h+1){
        if(y<h && grid[y][x]==grid[y-1][x] && grid[y][x]!='.') c++;
        else{
          if(c >= n)REP(i,c)del[y-1-i][x] = true;
          c = 1;
        }
      }
    }
    REP(y,h)REP(x,w)if(del[y][x]){
      grid[y][x] = '.';
      update = true;
    }
    bool ok = true;
    REP(y,h)REP(x,w)if(grid[y][x]!='.')ok = false;
    if(ok) return true;
  }
  return false;
}
int main(){
  cin>>h>>w>>n;
  vector<string> grid(h);
  REP(i,h)cin>>grid[i];
  REP(y,h)REP(x,w-1){
    vector<string> tmp = grid;
    swap(tmp[y][x],tmp[y][x+1]);
    if(check(tmp)){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 896
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int nums = sc.nextInt();
        int[] ary = new int[nums];
        boolean flg = true;
        int cnt = 0;
        for(int i = 0; i < nums; i++){
            ary[i] = sc.nextInt();
        }
        while(flg){
            for(int i : ary){
                if(i % 2 == 1){
                    flg = false;
                }
            }
            if(flg == false) break;
            for(int i = 0; i < nums; i++){
                ary[i] /= 2;
            }
            cnt++;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define N 3333
#define mod 1000000007

int n,m,f[N][N][2],ans;

void pls(int &x,int y) {x=(x+y)%mod;}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();m=read();
	f[0][0][1]=1;
	for (int i=1;i<=n;i++) f[0][i][0]=1;
	for (int i=0;i<m;i++)
		for (int j=0;j<=n;j++)
			for (int k=0;k<=1;k++){
				if (j) pls(f[i+1][j-1][k|(j==1)],f[i][j][k]);
				if (j) pls(f[i+1][j][k|(j==1)],f[i][j][k]);
				if (n-j) pls(f[i+1][j][k],f[i][j][k]);
				if (n-j) pls(f[i+1][j+1][k],f[i][j][k]);
			}
	for (int i=0;i<=n;i++) pls(ans,f[m][i][1]);
	printf("%d\n",ans);return 0;
}

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

public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null; }
        String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try { tokenizer = new StringTokenizer(reader.readLine()); } 
                catch (IOException e) { throw new RuntimeException(e);} }
            return tokenizer.nextToken(); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        
        int n = r.nextInt();
        if(n % 2 == 0){
            pw.println(0.5);
        } else {
            pw.println(1.0 * (1 + (n/2)) / n);
        }

        pw.close();
    }
}

/**
                _        _                 _                                                
               | |      | |               | |                                               
   ___ ___   __| | ___  | |__  _   _    __| | __ _ _ __ _ __ ___ _ __     _   _  __ _  ___  
  / __/ _ \ / _` |/ _ \ | '_ \| | | |  / _` |/ _` | '__| '__/ _ \ '_ \   | | | |/ _` |/ _ \ 
 | (_| (_) | (_| |  __/ | |_) | |_| | | (_| | (_| | |  | | |  __/ | | |  | |_| | (_| | (_) |
  \___\___/ \__,_|\___| |_.__/ \__, |  \__,_|\__,_|_|  |_|  \___|_| |_|   \__, |\__,_|\___/ 
                                __/ |                               ______ __/ |            
                               |___/                               |______|___/             
 */

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n,l,a[100010],p=-1;
  cin>>n>>l;
  bool ans=0;
  priority_queue<P> q;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i&&a[i]+a[i-1]>=l)ans=1,p=i;
  }
  if(ans){
    cout<<"Possible"<<endl;
    for(int i=1;i<p;i++)cout<<i<<endl;
    for(int i=n-1;i>p;i--)cout<<i<<endl;
    cout<<p<<endl;
  }
  else cout<<"Impossible"<<endl;
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    bool frag = 0;
    for(int i = 0;i < 20;i++){
        for(int j = 0;j < 50;j++){
            if(7*i+4*j == N)frag = 1;
        }
    }
    if(frag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}

// ***<ここから>****************************************************************



int main(void) {

	int R;
	cin >> R;

	if (R < 1200) cout << "ABC" << endl;
	else if (R < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;




	return 0;
}


Measured memory_bytes: 256
// abc134_b

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


#define rep(i,n) for(int i = 1; i < (int)n+1; i++)

 int main(){ 

 int n, d, s, ans;
 cin >> n >> d;

 s =  d*2+1;
 ans = n / s;

 if (n%s !=0) ans++;
 cout << ans << endl;

 return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main() {

    val scanner = Scanner(System.`in`)

    val inputNum = scanner.nextInt()
    val inputString = scanner.next()

    if(inputString.length > inputNum) {
        val cutString = inputString.substring(0, inputNum)
        println("$cutString...")
    } else {
        println(inputString)
    }
}

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

int main(){
  int n,k;
  cin >> n >> k;
  double p[n],ans=0;
  for(int i=0;i<n;i++){
    double a;
    cin >> a;
    p[i]=(a+1)/2;
  }
  double q[n+1];
  q[0]=0;
  for(int i=0;i<n;i++) q[i+1]=q[i]+p[i];
  for(int i=0;i+k<=n;i++){
    ans = max(q[i+k]-q[i],ans);
  }
  cout <<fixed << setprecision(10)<< ans << endl;
}


Measured memory_bytes: 3328
import java.util.Scanner;

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

		int n = sc.nextInt();
		int ans = 999;
		for (int i = n; i < 1000; i++) {
			int a = i / 100;
			int b = i / 10 % 10;
			int c = i % 10;
			if (a == b && b == c && c == a) {
				ans = i;
				break;
			}
		}

		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 22996
#include <iostream>
#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 <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {
    int x;
    cin >> x;
    string s = "NO";
    if (x == 3 || x == 5 || x == 7) s = "YES";
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
from itertools import*
from operator import mul
from functools import reduce
from collections import*

n,*a=map(int,open(0).read().split())

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

b=list(accumulate(a))
print(sum(cmb(v,2)for k,v in Counter(b).items()if v>1)+b.count(0))

Measured memory_bytes: 41568
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;

fn main() {
    input! {
        n: u64,
    }

    //tabで移動
    if n % 2 == 1 {
        println!("{}", n / 2 + 1);
    } else {
        println!("{}", n / 2);
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <iterator>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef long long LL;
const int maxn = 1000020;
const LL INF = 100000000000000LL;
const LL mod = 998244353;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define For(i,a,b) for(int i=a;i<=b;++i)

double n, m, d;

void solve() {
    if(d != 0)
        printf("%.10lf\n", (n * 2 - 2 * d) * (m - 1) / n / n);
    else
        printf("%.10lf\n", (n) * (m - 1) / n / n);
    cout << endl;
}

int main() {
    while(cin >> n >> m >> d) {
        solve();
    }
    return 0;
}


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

int main()
{
    int n;
    int coin[] = {500, 100, 50, 10, 5, 1};

    while (scanf("%d", &n)) {
      if (!n) return 0;
      int sum = 0;
      n = 1000 - n;
      for (int i = 0; i < 6; i++) {
        sum += (n / coin[i]);
        n %= coin[i];
        if (!n) break;
      }
      cout << sum << endl;
    }
}



Measured memory_bytes: 3140
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n),b(n);
  rep(i,0,n)cin>>a[i];
  rep(i,0,n)cin>>b[i];
  vector<ll>cc(n+1);
  rep(i,0,n){
    cc[a[i]]++;
    cc[b[i]]++;
  }
  if(*max_element(ALL(cc))>n){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  sort(ALLR(b));
  ll idx=-1;
  rep(i,0,n)if(a[i]==b[i])idx=a[i];
  vector<ll>v;
  rep(i,0,n)if(idx!=a[i]&&idx!=b[i])v.PB(i);
  //debug(v,v.size());
  ll cnt=0;
  //debug(v,n);
  rep(i,0,n){
    if(a[i]==b[i]){
      swap(b[i],b[v[cnt++]]);
    }
  }
  debug(b,n);
  return 0;
}

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

#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;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;


int main() {
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b){
        cout<<0<<endl;
        return 0;
    }
    if(n==1){
        if(a==b)cout<<1<<endl;
        else cout<<0<<endl;
        return 0;
    }
    ll ans;
    ans=(b-a)*(n-2)+1;
    cout<<ans<<endl;
    
    

    
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
    int n,x,d,a,b,m;
    cin>>n>>x;
    int city[n];
    for(int i=0;i<n;i++){
        cin>>city[i];
    }
    d=abs(x-city[0]);
    for(int j=1;j<n;j++){
        a=d; b=abs(city[j]-city[j-1]);
        while(a*b!=0){
            if(a>b)m=b;
            else m=a;
            if(a>b)a=a%b;
            else b=b%a;
        }
        d=m;
    }
    cout<<d;
    return 0;
}


Measured memory_bytes: 640
from sys import stdin
from fractions import gcd

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

# 左からN番目までの最大公約数
L = []
# 右からN番目までの最大公約数
R = []

for i in range(N):
    if i == 0:
        gl = A[i]
        gr = A[N - 1 - i]
    else:
        gl = gcd(gl, A[i])
        gr = gcd(gr, A[N - 1 - i])
    L.append(gl)
    R.append(gr)

ans = 0

for i in range(N):
    if i == 0:
        ans = max(ans, R[N - 1 - i - 1])
    elif i == N - 1:
        ans = max(ans, L[i - 1])
    else:
        ans = max(ans, gcd(R[N - 1 - i - 1], L[i - 1]))

print(ans)


Measured memory_bytes: 16112
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int n,k,q;
    cin>>n>>k>>q;
    vector<long int >l(k);
    vector<long int>r(k);
    vector<long int>pre(n+2,0);
    long int mat[501][501]={0};
    for(long int i=0;i<k;i++)
        {
            cin>>l[i]>>r[i];
            mat[l[i]][r[i]]++;
        }
    for(int i=1;i<=n;i++)
    {
        for(int j=n-1;j>=1;j--)
        {
            mat[j][i]+=mat[j+1][i];
        }
    }
    for(long int i=1;i<=n;i++)
    {
        for(long int j=1;j<=n;j++)
            mat[i][j]+=mat[i][j-1];
    }
    for(long int i=0;i<q;i++)
    {

        long int p,q;
        cin>>p>>q;
        long int ans=0;

        cout<<mat[p][q]<<endl;
    }


}


Measured memory_bytes: 6016
n = int(input())
a = [0] * n
ok = False
for i in range(n):
    a[i] = int(input())
    if a[i] % 10 != 0:
        ok = True
a.sort()
s = sum(a)
if s % 10 != 0: print(s)
elif not ok: print(0)
else:
    for x in a:
        if x % 10 != 0:
            print(s - x)
            break


Measured memory_bytes: 3060
let a, b, x = Scanf.scanf " %f %f %f" @@ fun a b c -> a, b, c
let f r = 180. *. r /. acos (-1.) |> Printf.printf "%.10f\n"
let _ = f @@ if x <= b *. a *. a /. 2. then let d = 2. *. x /. (a *. b) in let k = sqrt (b *. b +. d *. d) in acos @@ 2. *. x /. (a *. k) /. b
  else let s = a *. b -. x /. a in atan2 (2. *. s /. a) a

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	int n, k,h,cnt=0;
	cin >> n >> k;
	FOR(i, 1, n) {
		cin >> h;
		if (h >= k) {
			cnt++;
		}
	}
	pv(cnt)
	return(0);
}

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

using namespace std;

long long mem[105][105*1005];
int n,ww;
int w[105],v[105];

long long can(int i,int vv)
{
	if(vv==0) return 0;
	if(vv<0) return (1LL<<50);
	if(i>=n) return (1LL<<50);
	if(mem[i][vv]!=-1) return mem[i][vv];
	return mem[i][vv]=min(can(i+1,vv),can(i+1,vv-v[i])+w[i]);
}

int main()
{
	cin >> n >> ww;
	for(int i=0;i<n;i++)
		cin >> w[i] >> v[i];
	memset(mem,-1,sizeof mem);
	for(int i=n*1000;i>=0;i--)
	{
		if(can(0,i)<=ww)
		{
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 86784
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int field[21][21];
int dp[2][1<<20];
int h,w;

			int tf[21][21];
int main(){

	int t;
	cin>>t;
	int cnt=0;
	while(cnt<t){
		cnt++;
		cin>>w>>h;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>field[i][j];
		if(w>h){
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)tf[w-1-j][i]=field[i][j];
			swap(h,w);
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)field[i][j]=tf[i][j];
		}
		memset(dp,0,sizeof(dp));
		for(int i=h*w-1;i>=0;i--){
			for(int j=0;j<(1<<w);j++){
				int s=j;
				int nxt=i%2;
				int cur=(i+1)%2;
				int curh=i/w;
				int curw=i%w;
				dp[nxt][s]=0;
				// ツ置ツつゥツづ按つ「
				{
					int ns=s;
					ns&=~(1<<curw);
					dp[nxt][s]=max(dp[nxt][s],dp[cur][ns]);
				}
				// ツ置ツつッツづゥツづ按づァツ置ツつュ
				if((curw==0||!((s>>(curw-1))&1))&&(curh==0||!((s>>(curw))&1))){
					int ns=s;
					ns|=(1<<curw);
					dp[nxt][s]=max(dp[nxt][s],dp[cur][ns]+field[curh][curw]);
				}
			}
		}
		int res=dp[0][0];
		cout<<"Case "<<cnt<<": "<<res<<endl;
	}

	return 0;
}

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

int32_t main()
{
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;

	vector <int> v,cnt;

	for(int i=0;i<a;i++)
	{
		int x;
		cin >> x;

		v.push_back(x);
	}

	sort(v.begin(),v.end());

	int temp = x;

	while(temp--)
	{
		cnt.push_back(v.back());
		v.pop_back();
	}

	v.clear();

	for(int i=0;i<b;i++)
	{
		int x;
		cin >> x;

		v.push_back(x);
	}

	sort(v.begin(),v.end());

	temp = y;

	while(temp--)
	{
		cnt.push_back(v.back());
		v.pop_back();
	}

	for(int i=0;i<c;i++)
	{
		int x;
		cin >> x;

		cnt.push_back(x);
	}

	sort(cnt.begin(),cnt.end());

	temp = x+y;
	int ans = 0;

	while(temp--)
	{
		ans += cnt.back();
		cnt.pop_back();
	}

	cout << ans << endl;
}

Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
      char s;
      cin >> s;
      if(s=='Y'){
        cout << "Four" << endl;
        return 0;
      }
  }
  cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 3600
//  [amitdu6ey]
// g++ -std=c++11 -o2 -Wall filename.cpp -o filename
#include <bits/stdc++.h>
#define hell 1000000009
#define bug1(x) cout<<"$ "<<x<<" $"<<endl
#define bug2(x) cout<<"% "<<x<<" %"<<endl
#define bug3(x) cout<<"# "<<x<<" #"<<endl
#define ll long long
#define pb push_back
#define mp make_pair
#define tr(z) for(auto it=z.begin(); it!=z.end(); it++)
#define rloop(i,a,b) for(long long i=a; i>=b;i--)
#define loop(i,a,b) for(long long i=a; i<b; i++)
#define vbool vector< bool >
#define vvbool  vector< vector<bool> >
#define vchar vector<char>
#define vi vector<int>
#define vvi vector< vector<int> >
#define pll pair<long long, long long>
#define vll vector<long long>
#define vvl vector< vector<long long> >
#define ninf numeric_limits<long long>::min()
#define pinf numeric_limits<long long>::max()
#define comp(a,b) (abs(a-b)<1e-9) // to compare doubles
using namespace std;

void solve(){
    ll n,w;
    cin>>n>>w;
    ll wt[n+1];
    ll val[n+1];
    loop(i,1,n+1)   cin>>wt[i]>>val[i];
    ll dp[n+1][w+1];
    loop(i,0,n+1){
        loop(j,0,w+1){
            if(i==0 or j==0)    dp[i][j]=0;
            else if(j-wt[i]>=0) dp[i][j]=max(dp[i-1][j], val[i] + dp[i-1][j-wt[i]]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w];
    return;
}

int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int test_cases=1;
    //cin>>test_cases;
    while(test_cases--){
      solve();
    }
    return 0;
}


Measured memory_bytes: 79104
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

#define V vector<int>
#define P pair<int,int>

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

	V s(M), c(M);
	for (int i = 0; i < M; i++) cin >> s[i] >> c[i];//s->左からの桁

	for (int i = ((N == 1) ? 0 : pow(10, N - 1)); i < pow(10, N); i++) {//3桁->10^2　すべての数を調べる
		V digits(N);
		fill(digits.begin(),digits.end(),0);//指定された範囲を埋める
		int tmp = i;
		for (int j = 0; j < N; j++) {
			digits[j] = tmp % 10;//右の桁から配列に格納
			tmp /= 10;
		}

		bool flag = true;
		for (int j = 0; j < M; j++)
			if (digits[N - s[j]] != c[j]) flag = false;//一つの桁に二回代入されても片方でfalseになるのでok

		if (flag) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

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

if A+2 >= B:
    print(K+1)
elif A+1 > K:
    print(K+1)
else:
    P = K - A + 1
    change = P // 2
    amari = P % 2
    
    print(A+amari+change*(B-A))

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef long long ll;
typedef long double ld;

#define rep(i,x) for(int i = 0 ; i < x ; i ++)
#define rep1(i,x) for(int i = 1 ; i <= x ; i ++)
#define rrep(i,x) for(int i = x-1 ; i >= 0 ; i --)
#define rrep1(i,x) for(int i = x ; i > 0 ; i --)
#define fr first
#define sc second
#define pb push_back

const int INF = 1000000000;

int cal(int bm,int bw){
	int d = abs(bm-bw);
	return d*(d-30)*(d-30);
}

int main(){
	while(1){
		int m,w;
		int bm[15],bw[15];
		scanf("%d%d",&m,&w);
		if(m == 0 && w == 0)break;
		rep(i,m)scanf("%d",&bm[i]);
		rep(i,w)scanf("%d",&bw[i]);
		static int dp[15][1 << 12] = {};
		rep(i,15)rep(j,(1<<12)){
			dp[i][j] = 0;
		}
		int ret = 0;
		rep(i,m){
			rep(j,(1<<w)){
				dp[i+1][j] = max ( dp[i+1][j] , dp[i][j] );
				rep(k,w){
					if((j>>k)&1)continue;
					dp[i+1][j|(1<<k)] = max ( dp[i+1][j|(1<<k)] , dp[i][j] + cal(bm[i],bw[k]) );
				}
				ret = max ( ret , dp[i][j] );
			}
		}
		rep(j,(1<<w))ret = max ( ret , dp[m][j] );
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1428
/*
设 f[i] 表示按 ai 排序的某个前缀 i 个球，是否合法
显然 f[i + num[j]] 在 i + num[j] = j 的时候也是合法的
到这里就不会了
题解巧妙的转化成了线段覆盖，i 号球的是 [i - num[i], i] 这一段，答案就是 [0, n] 间没被覆盖的线段数
为什么？首先所有线段被覆盖次数之和为 n，那么没被覆盖的线段需要从 重复覆盖的线段 移过去，正确性显然。
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 2e5 + 10;
int n, m, ans;
int a[N], f[N], num[N];

int main() {
    cin >> n >> m;
    rep(i, 1, n) scanf("%d", &a[i]), ++num[a[i]];
    rep(i, 1, n) if (num[i]) {
        rep(j, max(0, i - num[i]), i - 1) f[j]++;
    }
    rep(i, 0, n - 1) if (!f[i]) ++ans;
    while (m--) {
        int x, y; scanf("%d%d", &x, &y);
        if (a[x] - num[a[x]] >= 0) {
            f[a[x] - num[a[x]]]--;
            if (!f[a[x] - num[a[x]]]) ++ans;
        }
        num[a[x]]--;
        a[x] = y;
        num[a[x]]++;
        if (a[x] - num[a[x]] >= 0) {
            if (!f[a[x] - num[a[x]]]) --ans;
            f[a[x] - num[a[x]]]++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


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

int a=0;
int gcd(int a, int b){
    while(b){
        int tmp = a;
        a = b;
        b = tmp%b;
    }
    return a;
}

int main(){
    int x,y;
    cin >> x >> y;
 
    if(x<y){
        int t = x;
        x = y;
        y=t;
    }
        
    cout << gcd(x,y) << endl;
 
    return 0;
    }
 

Measured memory_bytes: 3108
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

N, K = map(int, input().split())
S = input()

hoge = N*3 + 3

imos = [0]*(hoge)
imosInd = 2
cnt = 1
ind = 1
while ind < N:
    if S[ind] == S[ind-1]:
        cnt += 1
    else:
        imos[imosInd] = cnt
        cnt = 1
        imosInd += 1

    ind += 1
imos[imosInd] = cnt

for i in range(2, hoge):
    imos[i] += imos[i-1]


if S[0] == '1':
    ind = 2
else:
    ind = 1

ans = 0

while ind + K*2 < hoge:
    ans = max(ans, imos[ind + K*2] - imos[ind-1])
    ind += 2

print(ans)


Measured memory_bytes: 42224
import java.util.Scanner;

public class Main
{

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

		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		String s = sc.next();
		StringBuilder sb = new StringBuilder(s);

		sb.setCharAt(k-1, Character.toLowerCase(s.charAt(k-1)));

		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 21204
import java.util.Scanner;
import java.util.ArrayList;
import java.util.InputMismatchException;

public class Main{

public static void main(String[] args){

Scanner sc = new Scanner(System.in);
int total = sc.nextInt();
int Sarr[] = new int [14];
int Harr[] = new int [14];
int Carr[] = new int [14];
int Darr[] = new int [14];

String str;
int input;

for(int i = 0; i< total ; i++){
try{
str = sc.next();
//System.out.println("str: "+str+"<--str");
//System.out.println("total: "+total+"<--total");

switch (str){
  case "S":
  input = sc.nextInt();
  Sarr[input] = 1;
  break;
//System.out.println("check S "+i);
  case "H":
  input = sc.nextInt();
  Harr[input] = 1;
  break;
  case "C":
  input = sc.nextInt();
  Carr[input] = 1;
  break;
  case "D":
  input = sc.nextInt();
  Darr[input] = 1;
  break;
  default:
  System.out.println("default");
  break;
}
}catch(InputMismatchException e){
  System.out.println("mismatch");
//  System.out.println("check i"+i);
  break;
}



}
//int cnt =0;
for(int i = 0;i<4; i++){
  for(int l = 1;l < 14; l++){
  switch (i){
    case 0:
    if( Sarr[l] != 1 ) System.out.println("S "+l);
    break;
    case 1:
    if( Harr[l] != 1 ) System.out.println("H "+l);
    break;
    case 2:
    if( Carr[l] != 1 ) System.out.println("C "+l);
    break;
    case 3:
    if( Darr[l] != 1 ) System.out.println("D "+l);
    break;
  }

  }

}//1

}//main

}//class


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

int main(){
  int A[251],n;
  cin>>n;
  for(int i=1;i<=n;i++) cin>>A[i];
  for(int i=1;i<=n;i++){
    cout<<"node "<<i<<": key = "<<A[i]<<", ";
    if(i/2>0 &&i/2<=n)cout<<"parent key = "<<A[i/2]<<", ";
    if(2*i<=n)cout<<"left key = "<<A[2*i]<<", ";
    if(2*i+1<=n)cout<<"right key = "<<A[2*i+1]<<", ";
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    x = ""
    y = ""
    for i in range(0, w):
        if i % 2 == 0:
            x += "#"
            y += "."
        else:
            x += "."
            y += "#"
    for i in range(0, h):
        if i % 2 == 0: print(x)
        else: print(y)
    print()


Measured memory_bytes: 5612
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793



int main(){
  int H, W, A, B; cin >> H >> W >> A >> B;
  rep(i, B){
    rep(j, A){
      cout << 0;
    }
    rep(j, W-A){
      cout << 1;
    }
    cout << endl;
  }
  rep(i, H-B){
    rep(j, A){
      cout << 1;
    }
    rep(j, W-A){
      cout << 0;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>

using namespace std;

const int MX=100111;
int n,m;
vector<int>q[MX];
vector<int>r[MX];
int ans[MX];
int c[MX];

#define lbt(x) ((x)&(-(x)))
inline void add(int x,int v){for(int i=x;i<=m;i+=lbt(i))c[i]+=v;}
inline int que(int x){int r=0;for(int i=x;i;i^=lbt(i))r+=c[i];return r;}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=2;i<=m;i++)
		for(int j=0;j<m;j+=i)
			q[j+1].push_back(j+i-1);
	for(int i=1;i<=m;i++)ans[i]=n;
	for(int i=1;i<=n;i++){
		static int L,R;
		scanf("%d%d",&L,&R);
		r[L].push_back(R);
	}
	for(int i=m;i;i--){
		for(vector<int>::iterator it=r[i].begin();it!=r[i].end();it++)
			add(*it,1);
		for(vector<int>::iterator it=q[i].begin();it!=q[i].end();it++)
			ans[(*it)-i+2]-=que(min(m,*it));
	}
	for(int i=1;i<=m;i++)
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 16888
import numpy as np
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
ans = []

for i in range(N):
  for j in range(a[i]):
    ans.append(i+1)

n = np.array(ans).reshape(H, W)
for i in range(H):
  if i % 2 == 0:
    p = n[i]
    print(*p)
  else:
    p = n[i][::-1]
    print(*p)

Measured memory_bytes: 27532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9+7;

int n;
vector<vector<int> > node;
vector<bool> done;
map<pair<int,int>,int> color;

void bfs(int now, int allSum, int before) {
	if(node[now].size() <= 1) {
		return;
	}
	int c = 0;
	// if(before != -1) cout << "before color: " << color[before][now] << endl;
	for(int i=0;i<node[now].size();i++) {
		int to = node[now][i];
		if(before != -1 && color.count(make_pair(before,now)) && c ==color[make_pair(before,now)]) {
			c++;
		}

		if(color.count(make_pair(now,to)) == 0) {
			color[make_pair(to,now)] = c;
			color[make_pair(now,to)] = c;
			c++;
			bfs(to, allSum, now);
		}
	}
}

int main(){
	cin >> n;
	node = vector<vector<int> >(n);
	done = vector<bool>(n,false);
	vector<int> x(n-1), y(n-1);
	for(int i=0;i<n-1;i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		x[i] = a, y[i] = b;
		node[a].push_back(b);
		node[b].push_back(a);
	}
	int fund = 0;
	for(int i=1;i<n;i++) {
		if(node[fund].size() < node[i].size()) {
			fund = i;
		}
	}
	cout << (int)node[fund].size() << endl;
	bfs(fund, (int)node[fund].size(),-1);
	for(int i=0;i<n-1;i++) {
		cout << color[make_pair(x[i],y[i])]+1 << endl;
	}
}

Measured memory_bytes: 19456
program tiles
  implicit none
  integer :: i,j,k,N,dif
  character(len=100000) :: S,Sp
  character :: ss

  read(*,*) S
  N=len_trim(S)

  dif=0
  ! comp with                                                                   
  do i=1,N
     j=mod(i,2)
     !write(*,*) j                                                              
     Sp=trim(S)
     ss=Sp(i:i)
     read(ss,*) k
     if(j.eq.k) then
!        write(*,*) "onaji"                                                     
     else
!        write(*,*) "dif"                                                       
        dif=dif+1
     endif
  enddo
  if((N-dif).lt.dif) then
     dif=N-dif
  endif
  write(*,'(i0)') dif

end program tiles



Measured memory_bytes: 700
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int n;
	cin >> n;

	vector<pair<int, int>>p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i].second >> p[i].first;
	}
	sort(p.begin(), p.end());
	long long int r = 0;
	for (int i = 0; i < n; i++) {
		r += p[i].second;
		if (r > p[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N=(int)1e6+5;
int c[N],dp[N],dv[N];
int main()
{
  int  n,i,j,x,y,ans=0;
  cin>>n;
   int a[n+2];
   for(i=0;i<n;i++)
   {
    cin>>a[i];
    c[a[i]]++;
    dp[a[i]]=1;
   }
   for(i=1;i<=N;i++)
   {
     if(dp[i]==1)
     {
      for(j=i+i;j<=N;j+=i)
      {
        dv[j]++;
      }
     }
   }
   for(i=0;i<n;i++)
   {
    if(c[a[i]]==1&&dv[a[i]]==0)
    {
      ans++;
    }
   }
   cout<<ans<<endl;

  
}

Measured memory_bytes: 16068
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n;
	cin >> n;
	ll sum = 0;
	map<ll, ll> cnt;
	for(ll i = 0; i < n; i++){
		ll x;
		cin >> x;
		cnt[x]++;
		sum += x;
	}
	ll q;
	cin >> q;
	while(q--){
		ll b, c;
		cin >> b >> c;
		if(cnt[b]){
			sum -= cnt[b] * b;
			cnt[c] += cnt[b];
			sum += cnt[b] * c;
			cnt[b] = 0;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 9324
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e5 +7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L



int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int s = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s ^= a[i];
    }
    vector<int> ans(n);
    for (int i = 0; i < n; i++) 
        cout << (s^a[i]) << " ";

    

    return 0;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 100001;
int n, m, v[N]; 

int main(){
    scanf("%d%d", &n, &m);
    priority_queue<int>q;
    for(int i = 0; i<n; ++i){
        scanf("%d", v+i);
        q.push(v[i]);
    }
    while(m--){
        int x = q.top();
        q.pop();
        x = (x/pow(2,1));
        q.push(x);
    }
    ll an = 0;
    while(!q.empty()){
      an += q.top();
      q.pop();
    }
    printf("%lld\n",an);
} 


Measured memory_bytes: 1148
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N, K;
	cin >> N >> K;
	vector<pll> V;
	V.reserve(N + 2);
	V.push_back(pll(0, 0));
	for (ll n = 0; n < N; n++) {
		ll a;
		cin >> a;
		V.push_back(pll(a-1, n + 1));
	}
	for (ll n = 1; n <= N; n++) {
		V[n].first += V[n - 1].first;
		V[n].first %= K;
	}
	sort(V.begin(), V.end(), [](pll a, pll b) {
		if (a.first != b.first)return a.first < b.first;
		else return a.second < b.second;
	});
	V.push_back(pll(K, 0));
	ll ans = 0;
	deque<ll> deq;
	deq.push_back(0);
	for (ll n = 1; n <= N + 1; n++) {
		if (V[n].first == V[n - 1].first) {
			while (!deq.empty()) {
				if (deq.front() <= V[n].second - K)deq.pop_front();
				else break;
			}
			ans += (ll)deq.size();
			deq.push_back(V[n].second);
		}
		else {
			deq.clear();
			deq.push_back(V[n].second);
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;

int main(){
  string s;
  cin >> s;
  int ans = INF;
  for(int i = 0; i < int(s.size() - 2); i++){
    int a = s[i]-48, b = s[i+1]-48, c = s[i+2]-48;
    int k = 100 * a + 10 * b + c;
    ans = min(ans, abs(k - 753));
  }
  cout << ans << endl;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  int A=0, W=0;
  vector<int> vec(N,0); //それぞれの問題についてWAのでた回数
  vector<bool> X(N,false); //それぞれの問題について正解したかどうか
  if (M > 0) {
    for (int i=0; i < M; i++) {
      int p;
      string S;
      cin >> p >> S;
      p--;
      if (X.at(p) == false) {
        if (S == "WA") {
          vec.at(p)++;
        } if (S == "AC") {
          A++;
          W += vec.at(p);
          X.at(p) = true;
        }
      }
    }
  }
  cout << A << " " << W << endl;
}



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

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

    if(a < b) cout << "a < b" << endl;
    else if (a > b) cout << "a > b" << endl;
    else if (a == b) cout << "a == b" << endl;

    return 0;
}


Measured memory_bytes: 3084
M=10**9+7
n,k,*a=map(int,open(y:=0).read().split())
a.sort()
s=1
a=a[-k*(a[-1]<0<k%2):]
while k-y>1:
 if(t:=a[y]*a[y+1])>a[-1]*a[-2]:s=s*t%M;y+=2
 else:s=s*a.pop()%M;k-=1
if k-y:s*=a[-1]
print(s%M)

Measured memory_bytes: 31576
N = int(input())
len = 0

for i in range(12):
  if (26**i - 1)//25 <= N and (26**(i+1) - 1)//25 > N:
    len = i
    
ans = ["a" for _ in range(len)]
k = N - (26**len - 1)//25 + 1
x = k-1

for j in range(len):
  ans[j] = chr(ord("a") + x%26)
  x = x // 26

print("".join(ans[::-1]))

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

using ll=long long;

int main(){
    int n;
    ll l,t;
    cin>>n>>l>>t;
    vector<ll> x(n);
    vector<int> w(n);
    for(int i=0;i<n;i++) cin>>x[i]>>w[i];
    vector<ll> loc(n);
    for(int i=0;i<n;i++){
        loc[i]=x[i]+(w[i]==1 ? t : -t);
        loc[i]=(loc[i]%l+l)%l;
    }
    sort(loc.begin(),loc.end());

    auto calc=[&](int id){
        ll cnt=0;
        for(int i=0;i<n;i++){
            if(w[id]!=w[i]){
                ll d;
                if(w[id]==1 && w[i]==2) d=(x[i]+l-x[id])%l;
                else d=(x[id]+l-x[i])%l;
                if(t*2>=d) cnt+=(t*2-d)/l+(ll)(d<=t*2);
            }
        }
        int exid=(w[id]==1 ? (id+cnt)%n : (id+n-cnt%n)%n);
        ll d=(x[id]+(w[id]==1 ? t : -t));
        d=(d%l+l)%l;
        return make_pair(exid,d);
    };
    vector<pair<ll,ll>> pats;
    for(int i=0;i<min(n,5);i++){
        pats.push_back(calc(i));
    }
    
    // for(int i=0;i<n;i++){
    //     cerr<<loc[i]<<" ";
    // }
    // cerr<<endl;
    // cerr<<pat0.first<<" "<<pat1.first<<" "<<pat2.first<<endl;
    // cerr<<pat0.second<<" "<<pat1.second<<" "<<pat2.second<<endl;
    for(int i=0;i<n;i++){
        bool isok=true;
        for(int j=0;j<pats.size();j++){
            int id=(i+pats[j].first)%n;
            isok = isok && pats[j].second==loc[id];
        }
        if(isok){            
            for(int j=0;j<n;j++){
                cout<<loc[(i+j)%n]<<endl;
            }
            return 0;
        }
    }
    assert(false);
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    double N;
    cin >> N;
    
    int num = 0;
    rep(i,N)
    {
        if( (i+3)%2 != 0 )num++;
    }
    cout << (double)num/N << endl;

}


Measured memory_bytes: 256