akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni(),h = ni(), w = ni();
        pn((n-h+1)*(n-w+1));
    }
    //SOLUTION END
    void hold()throws Exception{throw new Exception("Hold right there, Sparky!");}
    long mod = (long)1e9+7, IINF = (long)4e18;
    final int INF = (int)2e9, MX = (int)1e6+1;
    DecimalFormat df = new DecimalFormat("0.000000000000000");
    double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        pre();for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }  
            return str;
        }
    }
}    

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

ll gcd(ll c,ll d){
c=c%d;
  if(c==0)return d;
  gcd(d,c);
}
ll lcm(ll c,ll d){
return c/gcd(c,d)*d;
}

int main(){
ll a,b,c,d,p,q,r,s,al,bl,asum,bsum,cnt;
  cin>>a>>b>>c>>d;
  p=(a-1)/c;q=(a-1)/d;al=(a-1)/lcm(c,d);
  r=b/c;s=b/d;bl=b/lcm(c,d);
  asum=a-1-p-q+al;
  bsum=b-r-s+bl;
  cout<<bsum-asum<<endl;
return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
ns = []
i = 0
while i < N:
  j = S.find(".", i)
  if j < 0: j = N
  k = S.find("#", j)
  if k < 0: k = N
  ns.append((j-i, k-j))
  i = k
#print(ns)
rs = []
r = sum([w for b, w in ns])
rs.append(r)
for b, w in ns:
  r += b-w
  rs.append(r)
#print(rs)
r = min(rs)
print(r)


Measured memory_bytes: 14424
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        int A[] = new int[N];
        for(int i = 0; i < N; i++){
        	A[i] = sc.nextInt();
        }
        int count = 0;
        for(int i = 0; i < N; i++){
        	if(i + 1 == A[A[i]-1]){
            	count += 1;
            }
        }
        System.out.println(count / 2);
     }
}

Measured memory_bytes: 59564
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int A,B,C;
  cin >> A >> B >> C;
  int five=0;
  int seven=0;

  if(A==7) seven++;
  if(A==5) five++;
  if(B==7) seven++;
  if(B==5) five++;
  if(C==7) seven++;
  if(C==5) five++;

  if(seven==1 && five==2) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var n,cnt int
	fmt.Scan(&n)
	var a []int = make([]int,n)
	for i :=0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	flag := true
	for flag {
		for i := 0; i < n; i++ {
			if a[i] % 2 == 0 {
				a[i] /= 2
			} else {
				flag = false
			}
		}
		if flag {
			cnt ++
		}
	}
	fmt.Print(cnt)
}


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

using namespace std;

int main(){
    int n, diff = 0;
    cin >> n;
    int a[n];

    for(int i=0;i<n;i++)cin >> a[i];
    sort(a, a+n);
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            diff += 2;
            i++;
        }
    }
    cout << n-diff << endl;
}


Measured memory_bytes: 768
#!/usr/bin/env python3
import sys, math, fractions, itertools

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, a: "List[int]"):
    four = len([aa for aa in a if aa % 4 == 0])
    two = len([aa for aa in a if (aa % 4 != 0 and aa % 2 == 0)])
    if two < 2:
        ex = four * 2 + 1
    else:
        ex = two + four * 2
    if ex >= N:
        print('Yes')
    else:
        print('No')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18260
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto N = readln.chomp.to!long;
    long r;
    foreach (a; 1..N) {
        auto b = N/a;
        r += b - (N%a == 0 ? 1 : 0);
    }
    writeln(r);
}

Measured memory_bytes: 2744
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;
	int A[N];
	int ans = 1;
	rep(i,N){
		cin >> A[i];
	}
	set<int> st;
	rep(i,K){
		st.insert(A[i]);
	}
	for(int i=K;i<N;i++){
		int Q = *st.begin();
		int W = *(--st.end());
		if(Q == A[i-K] && W < A[i]) ans += 0;
		else ++ans;
		st.erase(A[i-K]);
		st.insert(A[i]);
		// cout << W << endl;
	}

	int cnt = 1, wer = 0;
	for(int i=1;i<N;i++){
		if(A[i-1] < A[i]){
			cnt++;
		}
		else{
			cnt = 1;
		}
		if(cnt == K) wer++;
	}
	if(wer >= 1) ans -= wer-1; 
	// cout << ans << endl;
	// cout << *st.begin() << endl;
	cout << ans << endl;
}

Measured memory_bytes: 11264
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstdlib>
#include<cctype>
using namespace std;
#define ll long long
typedef pair<string,int>P;
const int len=2e5+5;
int arr[len];
int main()
{
	int u,n;
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&u);
		arr[i]=u-i;
	}
	sort(arr+1,arr+1+n);
	ll ans=0;
	for(int i=1;i<=n;++i)
		ans+=llabs(arr[(n+1)/2]-arr[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int t,n;
    while (cin>>t>>n) {
        if (t==0&&n==0) {
            break;
        }
        int x,y;
        std::map<pair<int,int>, bool> seen;
        for (int i=0;i<50;i++) {
            for (int j=0;j<50;j++) {
                seen[make_pair(i,j)]=false;
            }
        }
        for (int i=0;i<n;i++) {
            cin>>x>>y;
            seen[make_pair(x,y)]=true;
        }
        int sx,sy;
        cin>>sx>>sy;
        seen[make_pair(sx,sy)]=true;
        std::deque<pair<int,int>> deq;
        deq.emplace_back(make_pair(sx,sy));
        std::map<pair<int,int>, int> node_check;
        int count=1,node=0;
        while (deq.size()!=0) {
            int tmpx=deq.front().first;
            int tmpy=deq.front().second;
            node=node_check[make_pair(tmpx,tmpy)];
            if (node_check[make_pair(tmpx,tmpy)]<t&&seen[make_pair(tmpx+1,tmpy)]==false) {
                deq.emplace_back(make_pair(tmpx+1,tmpy));
                seen[make_pair(tmpx+1,tmpy)]=true;
                node_check[make_pair(tmpx+1,tmpy)]=node+1;
                //cout<<tmpx+1<<" "<<tmpy<<" node="<<node+1<<endl;
                count++;
            } else if (node_check[make_pair(tmpx,tmpy)]<t&&seen[make_pair(tmpx-1,tmpy)]==false) {
                deq.emplace_back(make_pair(tmpx-1,tmpy));
                seen[make_pair(tmpx-1,tmpy)]=true;
                node_check[make_pair(tmpx-1,tmpy)]=node+1;
                //cout<<tmpx-1<<" "<<tmpy<<" node="<<node+1<<endl;
                count++;
            } else if (node_check[make_pair(tmpx,tmpy)]<t&&seen[make_pair(tmpx,tmpy+1)]==false) {
                deq.emplace_back(make_pair(tmpx,tmpy+1));
                seen[make_pair(tmpx,tmpy+1)]=true;
                node_check[make_pair(tmpx,tmpy+1)]=node+1;
                //cout<<tmpx<<" "<<tmpy+1<<" node="<<node+1<<endl;
                count++;
            } else if (node_check[make_pair(tmpx,tmpy)]<t&&seen[make_pair(tmpx,tmpy-1)]==false) {
                deq.emplace_back(make_pair(tmpx,tmpy-1));
                seen[make_pair(tmpx,tmpy-1)]=true;
                node_check[make_pair(tmpx,tmpy-1)]=node+1;
                //cout<<tmpx<<" "<<tmpy-1<<" node="<<node+1<<endl;
                count++;
            } else if (node_check[make_pair(tmpx,tmpy)]<t&&seen[make_pair(tmpx+1,tmpy+1)]==false) {
                deq.emplace_back(make_pair(tmpx+1,tmpy+1));
                seen[make_pair(tmpx+1,tmpy+1)]=true;
                node_check[make_pair(tmpx+1,tmpy+1)]=node+1;
                //cout<<tmpx+1<<" "<<tmpy+1<<" node="<<node+1<<endl;
                count++;
            } else if (node_check[make_pair(tmpx,tmpy)]<t&&seen[make_pair(tmpx-1,tmpy-1)]==false) {
                deq.emplace_back(make_pair(tmpx-1,tmpy-1));
                seen[make_pair(tmpx-1,tmpy-1)]=true;
                node_check[make_pair(tmpx-1,tmpy-1)]=node+1;
                //cout<<tmpx-1<<" "<<tmpy-1<<" node="<<node+1<<endl;
                count++;
            } else {
                deq.pop_front();
            }
        }
        cout<<count<<endl;
    }
}


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

#define MAX 100000

int N;
vector<int> v[MAX];

int d[2][MAX];

void dfs( int s, int idx, int l )
{
	d[idx][s] = l;
	for( int i = 0; i < v[s].size(); i++ ) {
		int n = v[s][i];
		if( d[idx][n] != INT32_MAX ) {
			continue;
		}
		dfs( n, idx, l + 1 );
	}
}

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

	fill( d[0], d[0] + N, INT32_MAX );
	fill( d[1], d[1] + N, INT32_MAX );
	dfs( 0, 0, 1 );
	dfs( N - 1, 1, 1 );
	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		if( d[0][i] <= d[1][i] ) {
			ans++;
		}
		else {
			ans--;
		}
	}

	if( ans > 0 ) {
		cout << "Fennec" << endl;
	}
	else {
		cout << "Snuke" << endl;
	}

	return 0;
}


Measured memory_bytes: 12800
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

const int INF = 0x7fffffff;
const int N = 2005;
int n, a[N<<1], t, dp[N][N], g[N<<1][N<<1];
char c;

int cal(int x, int b, int w){
    return g[x][b] - g[x-1][b] + g[x][w] - g[x][n] - g[x-1][w] + g[x-1][n];
}

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n << 1; i++){
        scanf("%s%d", &c, &a[i]);
        if(c == 'W')    a[i] += n;
        for(int j = 1; j < i; j++)
            g[a[j]][a[i]] = 1;
    }
    for(int i = 1; i <= n << 1; i++)
        for(int j = 1; j <= n << 1; j++)
            g[i][j] += g[i-1][j] + g[i][j-1] - g[i-1][j-1];
    memset(dp, 0x7f, sizeof dp);
    dp[0][0] = 0;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            if(!i && !j)    continue;
            dp[i][j] = min(i ? dp[i-1][j] + cal(i, i, j+n) : INF, j ? dp[i][j-1] + cal(j+n, i, j+n) : INF);
        }
    }
    printf("%d\n", dp[n][n]);
    return 0;
}

Measured memory_bytes: 78720
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var whxyr = lines[0].split(' ');
 var whxyr = whxyr.map(function(str) { return Number(str)});
 var w = whxyr[0];
 var h = whxyr[1];
 var x = whxyr[2];
 var y = whxyr[3];
 var r = whxyr[4];


 

 if((w < x+r || x-r < 0) || (h < y+r || y-r < 0)){
   console.log("No");
 }else{
   console.log("Yes");
 }

 
});


Measured memory_bytes: 18268
#include <bits/stdc++.h>
using namespace std;
bool vist[1000001];
int dp[1000001];
 
void dfs(int s, vector<vector<int>> &g)
{
    vist[s]=true;
    for(auto v : g[s])
        {
            if(!vist[v])
                dfs(v,g);
            dp[s]=max(dp[s],1+dp[v]);
        }
    return;
}
int main() {
	// your code goes here
	int n,m,x,y;
	cin>>n>>m;
	vector<vector<int>> g(n+1);
	for(int i=1;i<=m;++i)
	    { cin>>x>>y; g[x].push_back(y);}
	memset(vist,false,sizeof(vist));
	for(int i=1;i<=n;++i){if(!vist[i]) dfs(i,g);}
	int ans=dp[1];
	for(int i=2;i<=n;++i) ans=max(ans,dp[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 11008
#include <iostream>
using namespace std;
int main(){
    int a,b;
    while(a!=0 || b!=0){
        cin >> a;
        cin >> b;
        for(int c=1; c<=a; c++){
            if(c==1 || c==a){
                for(int e=1; e<=b; e++){
                    cout << "#";
                }
            }
            else{
                for(int g=1; g<=b; g++){
                    if(g==1 || g==b){
                        cout << "#";
                    }
                    else{
                        cout << ".";
                    }
                }
            }
            cout << "\n";
        }
        if(a!=0 || b!=0){
            cout << "\n";
        }
    }
    return 0;
}


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

int main( ) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,i,x;
    t = 1;
    while(t--) {
     cin >> n;
     vector< pair<int, int> > v;
     for(i = 0; i <n; i++) {
      cin >> x;
      v.push_back(make_pair(x, i + 1));
	 }
	 sort(v.begin( ), v.end( ));
	 for(auto x : v)
	  cout << x.second << " ";
	 cout << "\n";
    }
    return 0;
}



Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double eps = 1e-9;
const double PI = acos(-1);
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
int a,b,c,x,y;

int main(){
	cin>>a>>b>>c>>x>>y;
	int ans=2*oo;
	for(int i=0; i<=2*max(x,y); i+=2){
		int la=max(0,x-i/2), lb=max(0,y-i/2);
		int cur=la*a+lb*b+i*c;
		ans=min(ans, cur);
	}
	cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
static const int dx[4] = {1,0,0,-1};
static const int dy[4] = {0,1,-1,0};

int main(void){
  int n;
  cin>>n;
  REP(a,n){
    printf("Data %d:\n",a+1);
    string line;
    vector<string> grid;
    REP(i,8){
      cin>>line;
      grid.push_back(line);
    }
    queue<P> p;
    int x,y;
    cin>>x>>y;
    p.push(P(x,y));
    while(!p.empty()){
      P tmp = p.front(); p.pop();
      int px = tmp.first; int py = tmp.second;
      grid[py-1][px-1] = '0';
      for(int k = 1; k<=3; k++){
       for(int r=0; r<4; r++){
        int ddx = dx[r]*k + (px-1);
        int ddy = dy[r]*k + (py-1);
        if(ddx>=0&&ddx<8&&ddy>=0&&ddy<8){
         if(grid[ddy][ddx]=='1'){
          p.push(P(ddx+1,ddy+1));
         }
        }
       }
      }
    }
    REP(y,8){
      REP(x,8){
        cout<<grid[y][x];
      }
      cout<<endl;
    }
  } 
  return 0;
}

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

using namespace std;

long long n,m;
long long p[100005],a[100005],b[100005],c[100005],d[100005];
long long kq;
priority_queue <pair<long,long> > pq;


main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    for (long long i=1;i<=m;i++)
        cin>>p[i];
    for (long long i=1;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    for (long long i=1;i<m;i++)
    {
        if (p[i+1]>p[i])
        {
            d[p[i]]++;
            d[p[i+1]]--;
        }
        else
        {
           d[p[i+1]]++;
           d[p[i]]--;
        }
    }
    for (long i=2;i<=n;i++)
    {
        d[i]+=d[i-1];
    }
    for (long long i=1;i<=n;i++)
        kq+=min(c[i]+b[i]*d[i],a[i]*d[i]);
    cout<<kq<<"\n";



}

Measured memory_bytes: 7068
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()]
    A.sort()
    B.sort()
    C.sort()
    # print(A, B, C, sep="\n")
    from bisect import bisect
    ans = []
    ans2 = []
    for a in A:
        b = bisect(B, a)
        ans.append(N-b)
    for b in B:
        c = bisect(C, b)
        ans2.append(N-c)
    from itertools import accumulate
    ans2 = list(accumulate([0] + ans2[::-1]))
    answer = 0
    for a in ans:
        answer += ans2[a]
    print(answer)
    # print(ans)
    # print(ans2)


if __name__ == '__main__':
    main()


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define pb push_back

template<typename T> T DUP(T x, T y) { return (x + y - 1) / y; };
template <typename A, size_t N, typename T>
void arrayFill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1;
    int dy = y1 - y2;

    int x3 = x2 + dy;
    int y3 = y2 + dx;
    int x4 = x1 + dy;
    int y4 = y1 + dx;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << "\n";

}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n; cin >>n;
  vector<pii>a(n); ll fr=0,sc=0; bool shit=1;
  for(int i=0; i<n; i++) cin >>a[i].second>>a[i].first;
  sort(a.begin(),a.end());
  for(int i=0; i<n; i++){
    fr=a[i].first; sc+=a[i].second;
    if(sc>fr){shit=0; break;}
  }
  if(shit) cout <<"Yes";
  else cout <<"No";
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  solve();
return 0;}

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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPS(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;

const ll INF = 1e18;
const ll MOD = 1e9+7;

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    string S; cin >> S;
    string a = "CODEFESTIVAL2016";
    int ans = 0;
    REP(i, a.length()) if(a[i] != S[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
///答え見ました
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  int n,m;
  cin >> n >> m;
  
  vector<ll>all(n+1);
  for(int i=0; i<n+1; i++){
    all[i]=1;
  }
  
  vector<int>a(m);
  for(int i=0; i<m; i++){
    cin >> a[i];
    all[a[i]]=0;
  }
  
  if(all[0]==0){
    cout << 0 << endl;
    return 0;
  }
  
  for(int i=n-2; i>=0; i--){
    if(all[i]==0) continue;
    all[i]=all[i+1]+all[i+2];
    if(all[i]==0){
      cout << 0 << endl;
      return 0;
    }
    else if(all[i]>=1000000007) all[i]%=1000000007;
  }
  cout << all[0] << endl;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int INF = 1001001001;

int main() {
    int A, B;

    cin >> A >> B;

    cout << A*B << endl;
}


Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	
      	if (a > 8 || b > 8) {
      		System.out.println(":(");
      	} else {
      		System.out.println("Yay!");
      	}
	}
	
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 20692
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int n;
  cin >> n;
  const int MAX = 60;
  vector<vector<int>> cnt(MAX, vector<int>(MAX));
  for (int i = 0; i < n; i++) {
    long double x;
    cin >> x;
    long long y = (long long) (x * 1e9 + 0.1);
    int a = 0, b = 0;
    while (y % 2 == 0) {
      y /= 2;
      a += 1;
    }
    while (y % 5 == 0) {
      y /= 5;
      b += 1;
    }
    cnt[a][b] += 1;
  }
  long long ans = 0;
  for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX; j++) {
      for (int ii = 0; ii < MAX; ii++) {
        for (int jj = 0; jj < MAX; jj++) {
          if (i + ii >= 18 && j + jj >= 18) {
            if (i == ii && j == jj) {
              ans += (long long) cnt[i][j] * (cnt[i][j] - 1);
            } else {
              ans += (long long) cnt[i][j] * cnt[ii][jj];
            }
          }
        }
      }
    }
  }
  cout << ans/2 << '\n';
  return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  int n, t, x;
  cin >> n >> x >> t;
  int ans = t * (n / x);
  if(n % x != 0)ans += t;
  cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

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

  vi a(n);
  rep(i, n) cin >> a[i];

  vl s(n+1, 0), ss(n+1, 0);
  rep(i, n){
    s[i+1] = s[i] + a[i];
    ss[i+1] = ss[i] + max(0, a[i]);
  }

  ll ans = 0;
  repi(i, 1, n-k+2){
    ll tmp = max(0LL, s[i+k-1] - s[i-1]);
//    printf("%d %lld\n", i, tmp);
    tmp += ss[n] - ss[i+k-1];
    tmp += ss[i-1] - ss[0];
    ans = max(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


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

struct task {
    int a;
    int b;
};

bool my_cmp(const task &t1, const task &t2) {
    return t1.b < t2.b;
    /*
    if (t1.b == t2.b) {
        return 0;
    } else {
        return (t1.b > t2.b) ? 1 : -1;
    }
    */
}

int main() {
    int n;
    cin >> n;
    task ts[n];
    for (int i = 0; i < n; ++i) {
        cin >> ts[i].a;
        cin >> ts[i].b;
    }
    sort(ts, ts + n, my_cmp);
    int cur_t = 0;
    for (int i = 0; i < n; ++i) {
        task &t = ts[i];
        if (cur_t + t.a > t.b) {
            cout << "No" << "\n";
            return 0;
        }
        cur_t += t.a;
    }
    cout << "Yes" << "\n";
    return 0;
}


Measured memory_bytes: 1792
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B = map(int, readline().split())
S = readline().decode('utf8').rstrip()

print('Yes' if S[A] == '-' and (S[:A] + S[A + 1:]).isdigit() else 'No')


Measured memory_bytes: 3064
N=int(input())
A = list(map(int, input().split()))
count=0
flag=True

while flag==True:
  for i in range(0,N):
    if A[i]%2==0:
      A[i]=A[i]/2
    else:
      flag=False
      break
  else:
    count=count+1
    
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};


const ll MaxN=2001001;

ll f[MaxN], rf[MaxN];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    REP(i, 1, MaxN) f[i] = (f[i - 1] * i) % mod;
    REP(i, 0, MaxN) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(ll n, ll k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

int main(){
    init();
    ll R1,C1,R2,C2; cin>>R1>>C1>>R2>>C2;
    R2++; C2++;
    ll ans=0;
    ans=(C(C2+R2,C2)+C(C1+R1,C1))%mod;
    ans=(ans+2*mod-C(C2+R1,C2)-C(C1+R2,C1))%mod;
    cout<<ans<<endl;
    
}

Measured memory_bytes: 31488
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  int sx, sy, tx, ty;
  readf("%s %s %s %s\n", &sx, &sy, &tx, &ty);
  string f1_res, f2_res, r1_res, r2_res;
  f1_res = f2_res = r1_res, r2_res = "";

  string x1, x2, y1, y2;

  x1 = "R";
  x2 = "L";

  y1 = "U";
  y2 = "D";

  f2_res ~= y2 ~ x1;
  r2_res ~= y1 ~ x2;

  foreach (i; 0..tx-sx) {
    f1_res ~= x1;
    r1_res ~= x2;
  }

  foreach (i; 0..ty-sy) {
    f1_res ~= y1;
    r1_res ~= y2;
  }

  f2_res ~= f1_res ~ y1 ~ x2;
  r2_res ~= r1_res ~ y2 ~ x1;

  writeln(f1_res ~ r1_res ~ f2_res ~ r2_res);
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
   
using namespace std;
     
#define PB(x) push_back(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x) make_pair(x);
    
#define debug(x) cerr << #x << '=' << x << endl;
#define debug2(x, y) cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a) for (int x: a) cerr << x << ' '; cerr << endl;
     
#define int long long
     
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;

const int INF = 1e9;


int32_t main()
{
	int n, k;
	cin >> n >> k;
	int h[n+1];
	h[0] = INF;
	for (int i = 1; i <= n; i++)
		cin >> h[i];
		
	int dp[n+1];
	dp[1] = 0;
	for (int i = 2; i <= n; i++) {
		dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
		for (int j = 2; i-j > 0 && j <= k; j++) {
			dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
		}
	}
	cout << dp[n] << endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

int main(){
    string s, t;
    cin >> s >> t;
    long int num = s.size();
    vector<int> a[26];
    rep(i, s.size()){
        int idx = s[i] - 'a';
        a[idx].push_back(i);
    }
    long int ans = -1;
    long int sm = 0;
    rep(i, t.size()){
        long int idx = t[i] - 'a';
        if (a[idx].size() == 0){
            cout << -1 << endl;
            return 0;
        }
        long int n = ans;
        long int idx2 = upper_bound(a[idx].begin(), a[idx].end(), n) - a[idx].begin();
        if (idx2 >= a[idx].size()){
            ans = a[idx][0];
            sm++;
        }else{
            ans = a[idx][idx2];
        }
    }
    cout << sm * num + ans + 1 << endl;
}


Measured memory_bytes: 1216
#include <stdio.h>
 
int main() {
  int i,n,j,k;
  int b,f,r,v;
  int p[4][3][10]={0};
 
 
 
  scanf("%d",&n);
 
  for(i =0; i <n; i++) {
    scanf("%d %d %d %d",&b,&f,&r,&v);
    p[b-1][f-1][r-1] += v;
  }
 
  for(k=0; k<4; k++) {
    for(j=0; j<3; j++) {
      for(i=0; i<10;i++) {
    printf(" %d",p[k][j][i]);
      }
      printf("\n");
    }
    if(k == 3){
      break;
    }
    printf("####################\n");
 
  }
  return 0;
}


Measured memory_bytes: 2060
#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>;

const int A = 1000005;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A);
  rep(i, n) {
    cin >> a[i];
    c[a[i]]++;
  }

  bool pairwise = true;
  for (int i = 2; i < A; i++) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) pairwise = false;
  }

  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = 0;
  rep(i, n) g = gcd(g, a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }

  cout << "not coprime" << endl;
  return 0;
}

Measured memory_bytes: 11188
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}



vector<ll> g[111];
ll N, K;

void printRes() {
  ll i, j;
  ll c=0;
  for(i=0; i<N; i++) {
    for(j=0; j<g[i].size(); j++) {
      if(i<g[i][j]) c++;
    }
  }
  
  pt(c);
  for(i=0; i<N; i++) {
    for(j=0; j<g[i].size(); j++) {
      if(i<g[i][j]) {
        pt(i+1<<" "<<g[i][j]+1);
      }
    }
  }
}

int main(void) {
  cin >> N >> K;
  ll i, j;
  
  if(K>(N-1)*(N-2)/2) {
    pt(-1);
    return 0;
  }
  
  for(i=0; i<N-1; i++) {
    g[i].pb(N-1);
    g[N-1].pb(i);
  }
  
  ll cnt=(N-1)*(N-2)/2;
  
  for(i=0; i<N-1; i++) {
    for(j=i+1; j<N-1; j++) {
      if(cnt==K) {
        printRes();
        return 0;
      }
      g[i].pb(j);
      cnt--;
    }
  }
  
  printRes();
}












Measured memory_bytes: 384
/*
    Created by Tejas Chaudhari
    link:
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef double lf;
typedef bool bl;
typedef vector<ll> vl;
typedef vector<lf> vd;
typedef vector<bl> vb;
typedef string st;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

#define INF (LONG_LONG_MAX / 4)
#define SORT(x) sort(x.begin(), x.end())
#define Mod % 1000000007

void re_curse() {
    ll h, w, K;
    cin>>h>>w>>K;
    vector <vl> arr(h, vl(w,0));
    vector <vl> brr;
    for (int i = 0; i < h; ++i) {
        string s;
        cin>>s;
        for (int j = 0; j < w; ++j) {
            arr[i][j] = s[j];
        }
    }
    ll ans = 0;
    for (int i = 0; i < (1<<h); ++i) {
        for (int j = 0; j < (1<<w); ++j) {
            brr = arr;
            for (int r = 0; r < h; ++r) {
                if (i & (1<<r)) {
                    for (int k = 0; k < w; ++k) {
                        brr[r][k] = 0;
                    }
                }
            }
            for (int c = 0; c < w; ++c) {
                if (j & (1<<c)) {
                    for (int k = 0; k < h; ++k) {
                        brr[k][c] = 0;
                    }
                }
            }
            ll c = 0;
            for (int k = 0; k < h; ++k) {
                for (int l = 0; l < w; ++l) {
                    if (brr[k][l] == '#') {
                        ++c;
                    }
                }
            }
            if (c == K) {
                ++ans;
            }
        }
    }
    cout<<ans<<endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    for (int i = 1; i <= t; ++i) {
        re_curse();
    }
    return 0;
}


Measured memory_bytes: 3592
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(' ').joinToString("").toInt()
    val q = readLine()!!.split(' ').joinToString("").toInt()

    val list = mutableListOf<Int>()

    fun f(x: Int, used: Set<Int>) {
        if (used.size == n) {
            list.add(x)
            return
        }

        for (i in 1..n) {
            if (!used.contains(i)) {
                f(x * 10 + i, used.plus(i))
            }
        }
    }

    f(0, emptySet())

    var a = 0
    var b = 0

    for (i in list.indices) {
        if (list[i] == p) {
            a = i
        }
        if (list[i] == q) {
            b = i
        }
    }

    println(Math.abs(a - b))
}


Measured memory_bytes: 52468
#include <bits/stdc++.h>
using namespace std;
typedef long long Long;
const Long INF = 1000000000000000000LL;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	Long n, W;
	cin >> n >> W;
	Long w[n], v[n];
	Long sum = 0LL;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
		sum += v[i];
	}
	Long dp[sum + 1];
	for (int i = 0; i <= sum; i++) dp[i] = INF;
	dp[0] = 0LL;
	for (int i = 0; i < n; i++) {
		for (int j = sum - v[i]; j >= 0; j--) {
			dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
		}
	}
	Long answer = 0LL;
	for (Long i = 0; i <= sum; i++) {
		if (dp[i] > 0 and dp[i] <= W) {
			answer = max(answer, i);
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define PI acos(-1)

using namespace std;

constexpr double EPS = 1e-8;
constexpr int MAXN = 1e5 + 5;
constexpr int INF = 0x3f3f3f3f;

array<int, MAXN> a;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    if (n >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3644
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String[] str = S.split("");
		int num = str.length / 2;
		int count = 0;
		
		for(int i = 0; i < num; i++){
			if(str[i].equals(str[str.length - (i+1)])){
				continue;
			}
			else{
				str[i] = str[str.length - (i+1)];
				count++;
			}
		}
		System.out.println(count);
	}
}

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

typedef unsigned char bool;
int main(){
  int n;
  scanf("%d",&n);
  int a[n+1],b[n+1],i;
  bool flag=1;
  for(i=1;i<=n;i++)
    {
      scanf("%d",&a[i]);
      if(a[i]>i)flag=0;
      b[i]=0;
    }
  if(flag==0)
    {
      printf("-1\n");
      return 0;
    }
  //  printf("1\n");
  int j,temp,count;
  for(i=n;i>0;i--)
    {
      count=0;
      for(j=i+1;j<=n;j++)
	{
	  if(a[i]>=a[j]) count++;
	}
      //      printf("%2d ",count);
      for(j=0;j<count;j++)
	{
	  if(b[a[i]+j]>a[i])
	    count++;
	  //	  printf("%d:%d:%d ",b[i+j],a[i],count);
	}
      j=a[i]+count;
      //      printf("%2d\n",j);
      while(b[j]!=0)j++;
      b[j]=a[i];
    }
  //  printf("\n",j);
  for(i=1;i<=n;i++)
    printf("%d\n",b[i]);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    int A, B;
    cin >> A >> B;
    vector<int> divisor;
    for (int i = 1; i < sqrt(A) + 100; i++) {
        if (A % i == 0 && B % i == 0) {
            divisor.push_back(i);
        }
        if (A % i == 0) {
            int divA = A / i;
            if (A % divA == 0 && B % divA == 0) divisor.push_back(divA);
        }
    }
    for (int i = 1; i < sqrt(B) + 100; i++) {
        if (A % i == 0 && B % i == 0) {
            divisor.push_back(i);
        }
        if (B % i == 0) {
            int divA = B / i;
            if (A % divA == 0 && B % divA == 0) divisor.push_back(divA);
        }
    }
    sort(divisor.begin(), divisor.end());
    divisor.erase(unique(divisor.begin(), divisor.end()), divisor.end());
    int ans = 0;
    vector<int> check;
    for (int a = 0; a < divisor.size(); a++){
        bool ok = true;
        int temp = divisor[a];
        // cout << temp << endl;
        for (int i = 1; i < check.size(); i++) {
            if (temp % check[i] == 0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            // cout << temp << endl;
            check.push_back(temp);
            ++ans;
        }
    }
    cout << ans << endl;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;


int main(int argc, const char* argv[]) {
	ll n, k;
	cin >> n >> k;
	ll r = min(n, k);

	vector<ll> v1(n), v2(n);
	rep(i, n) {
		cin >> v1[i];
	}

	v2 = v1;
	reverse(v2.begin(), v2.end());

	/*
	 *  a: 左から a 個手に入れる
	 *  b: 右から b 個手に入れる
	 *  c: c 回まで捨てる
	 *  d: 実際に d 回捨てる
	 */
	ll ret = 0;
	for(ll a = 0; a <= r; ++a) {
		for(ll b = 0; b <= r - a; ++b) {
			vector<ll> v3(a + b);
			rep(i, a) v3[i]     = v1[i];
			rep(i, b) v3[i + a] = v2[i];
			sort(v3.begin(), v3.end());

			ll c = min(static_cast<ll>(v3.size()), k - a - b);
			ll d = 0;
			while(d < c) {
				if(v3[d] >= 0) break;
				++d;
			}

			ll tmp = 0;
			repd(i, d, v3.size()) tmp += v3[i];
			if(tmp > ret) ret = tmp;
		}
	}

	cout << ret << endl;

	return 0;
}


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

vector<long> div(long n) {
  vector<long> v;
  for (long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      v.push_back(i);
      if (i * i != n) v.push_back(n / i);
    }
  }
  sort(begin(v), end(v));
  return v;
}

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 2 == 0) continue;
    int tmp = div(i).size();
    if (tmp == 8) cnt++;
  }
  cout << cnt << "\n";
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	words := []string{"dream", "dreamer", "erase", "eraser"}
	for i := len(s); i > 0; {
		found := false
		for _, w := range words {
			if ni := i - len(w); ni >= 0 && w == s[ni:i] {
				found = true
				i = ni
				break
			}
		}
		if !found {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 1280
N=int(input())
A = list(map(int, input().split()))

if N==2:
    print(1)
    print(0)
else:
    from collections import deque
    da=deque(A)
    
    import numpy as np
    ansl=np.array([0]*N)
    
    for i in range(N-1):
        ansl[da.pop()-1]+=1
    
    for i in ansl:
        print(i)

Measured memory_bytes: 39592
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx-sx, ty-sy
S = 'U'*dy + 'R'*dx + 'D'*dy + 'L'*dx + 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D' + 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'
print(S)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;


int main(){
    int n, a, cnt = 0;
    int color[8] = {0};
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        for (int j = 0; j < 8; j++) {
            if(400*j <= a && a < 400*(j+1)){
                color[j] = 1;
            }
        }
        if(a>=3200)cnt++;
    }
    int ans = 0;
    for (int i = 0; i < 8; i++) {
        if(color[i]) ans++;
    }
    if(ans)cout << ans << " " << ans + cnt << endl;
    else cout << 1 << " " << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
def cmb(n,r,mod):
    if r<0 or r>n:return 0
    return g1[r]*g2[r]%mod


mod=10**9+7
n,a,b=map(int,input().split())
k=max(a,b)
g1=[1,n]
g2=[1,1]
inverse=[0,1]

for i,j in enumerate(range(n-1,((n-k+1)-1),-1)):
    i=i+2
    g1.append((g1[-1]*j)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1]%mod))

N=pow(2,n,mod)-1
print((N-cmb(n,b,mod)-cmb(n,a,mod))%mod)

Measured memory_bytes: 72940
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
INF = 10 ** 9
ans = INF

for i in range(N-(K-1)):
  tmp = h[i+(K-1)] - h[i]
  ans = min(tmp, ans)
print(ans)

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

typedef long long ll;
typedef long double ld;
using namespace std;
//mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

int a[200005];
int main() {
    int n;
    cin>>n;
    ii cin>>a[i];
    int x=0;
    ii x^=a[i];
    ii cout<<(x^a[i])<<" ";
    cout<<endl;
}

Measured memory_bytes: 4324
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, k = map(int, input().split())
a = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

ord_ = [-1] * (n + 1) # 何回目に訪れたか
homon = [] # 訪問した順番のリスト
current = 0
while ord_[current] == -1:
    ord_[current] = len(homon)
    homon.append(current)
    current = a[current] - 1

freq = len(homon) - ord_[current] # ループする都市数
n_before_loop = ord_[current] # ループするまでの都市数

if k < n_before_loop:
    print(homon[k] + 1)
else:
    k -= n_before_loop
    k %= freq
    print(homon[n_before_loop+k] + 1)



Measured memory_bytes: 33724