akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


bool f(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second < b.second;
}


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    ll n;
    cin >> n;
    pair<ll, ll> a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }


    sort(a, a + n, f);

    ll time = 0;
    for (auto e : a) {
        if (time + e.first > e.second) {
            cout << "No";
            return 0;
        }

        time += e.first;
    }

    cout << "Yes";










}

Measured memory_bytes: 3328
#N=int(input())
#N,M=map(int, input().split())
#L=list(map(int, input().split()))
N,M=map(int, input().split())
ifACL=[0]*N
cWAL=[0]*N
psL=[]
AC=0
WA=0
p=0
s=0
for _ in range(M):
  p,s=map(str, input().split())
  p=int(p)
  if ifACL[p-1]==0 and s=="WA":
    cWAL[p-1]+=1
  elif ifACL[p-1]==0 and s=="AC":
    AC+=1
    WA+=cWAL[p-1]
    ifACL[p-1]=1

print(AC,WA)

Measured memory_bytes: 4596
import java.util.Scanner;

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

        int cnt = 0;
        for(char c: s) {
            if(c == 'R') cnt++;
        }
        if(cnt == 2 && s[1] == 'S') cnt = 1;
        System.out.println(cnt);
    }
}


Measured memory_bytes: 35708
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#define CO(a, b, c) ((a)?(b):(c))
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;

int main(void)
{
	
	string s, t;
	cin >> s >> t;
	cout << ((s==t.erase(t.size()-1))?("Yes"):("No")) << endl;
	
	return 0;
	
}

Measured memory_bytes: 3544
import java.util.*;

class Main{

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

		if(A <= 8 && B <= 8)
			System.out.println("Yay!");
		else
			System.out.println(":(");
	
	}


}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

struct ball
{
	ll x, y;
};

int main(){
	startTime=clock();
	int n;
	cin >> n;
	ball b[n];
	FOR(i,n){
		cin >>b[i].x >> b[i].y;

	}
	map<pair<ll,ll>,int> m;
	int maxi=0;
	pair<ll,ll> p;
	FOR(i,n){
		for(int j=0;j < n;j++){
			if(j!=i){
				m[MP(b[i].x-b[j].x,b[i].y-b[j].y)]++;
				if(m[MP(b[i].x-b[j].x,b[i].y-b[j].y)] > maxi) {
					p=MP(b[i].x-b[j].x,b[i].y-b[j].y);
					maxi=m[MP(b[i].x-b[j].x,b[i].y-b[j].y)];
				}
			}
		}
	}
		
	cout << n-maxi;	

	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if ((a1 + a2 + a3) >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ans+=a[i]*a[j];
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define maxn 1000010
int notp[maxn];
int vis[maxn];
int prm[maxn],tot;
int ai[maxn];

int gcd(int a,int b){
	return !b?a:gcd(b,a%b);
}

void sieve(int n){
	notp[1]=1;
	for(int i=2;i<=n;i++){
		if(!notp[i])
			prm[++tot]=i;
		for(int j=1;1ll*prm[j]*i<=n&&j<=tot;j++){
			notp[i*prm[j]]=1;
			if(i%prm[j]==0)
				break;
		}
	}
}

inline int readin(){
	int x=0,s=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')s=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*s;
}

int main(){
	int n,g;
	n=readin();
	sieve(1000001);
	for(int i=1;i<=n;i++)
		ai[i]=readin();
	g=ai[1];
	for(int i=2;i<=n;i++)
		g=gcd(g,ai[i]);
	if(g>1){
		puts("not coprime");
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(!notp[ai[i]])vis[ai[i]]++;
		else {
			for(int j=1;j<=100&&prm[j]<=ai[i];j++){
				if(ai[i]%prm[j]==0){
					vis[prm[j]]++;
				}
				while(ai[i]%prm[j]==0)
					ai[i]/=prm[j];
			}
			if(ai[i]>1)vis[ai[i]]++;
		}
	}
	for(int i=2;i<=1000000;i++)
		if(vis[i]>=2){
			puts("setwise coprime");
			return 0;
		}
	puts("pairwise coprime");
	return 0;
}

Measured memory_bytes: 15404
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(),
            B = sc.nextInt(),
            K = sc.nextInt();
        int n = gcd(A, B),
            count = 0,
            num = 0;
        while(count < K){
            if(n%++num == 0){
                count++;
            }
        }
        System.out.println(n/num);
    }
        public static int gcd(int a, int b){
        if(a > b){
            int c = a;
            a = b;
            b = c;
        }
        int r;
        while((r = b%a) > 0){
            b = a;
            a = r;
        }
        return a;            
    }
}

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

int main(){
    string forward;
    cin >> forward;
    int times;
    cin >> times;
    string back;
    for(int i=0; i<times; i++){
        int t_type;
        cin >> t_type;
        if(t_type==1){ // type=1なら前後反転
            swap(forward,back);
        }else{ // t_type=2なら
            int f_type; // f_type
            char c;
            cin >> f_type >> c;
            if(f_type==1){ //f_type=1ならsの先頭に+c，先頭用配列backに格納
                back+=c;
            }else{ //f_type=2ならsの末尾に+c，末尾用配列forwardに格納
                forward+=c;
            }
        }
    }
    reverse(back.begin(),back.end());//backは反対から読むので
    cout << back+forward << endl;
    return 0;
}




Measured memory_bytes: 1248
const MOD_N: u64 = 1000000007;

fn inv(mut a: u64) -> u64 {
    // a^(MOD_N-2)

    let mut n = MOD_N - 2;
    let mut x = 1;

    while n > 0 {
        if n % 2 == 1 {
            x = (x * a) % MOD_N;
        }

        a = (a * a) % MOD_N;

        n /= 2;
    }

    x
}

fn comb(n: usize, k: usize) -> usize {
    let n = n as u64;
    let k = k as u64;
    let mut v = 1u64;

    for i in 0..k {
        v = (v * (n-i)) % MOD_N;
    }

    for i in 1..k {
        v = (v *  inv(i+1)) % MOD_N;
    }

    v as usize
}

fn solve(x: usize, y: usize) -> usize {
    let xy_max = std::cmp::max(x, y);
    let xy_min = std::cmp::min(x, y);

    // 3n + 2m = xy_max
    // 3n +  m = xy_min

    let m = xy_max - xy_min;

    if xy_min * 2 < xy_max {
        return 0;
    }

    let t = 2 * xy_min - xy_max;
    if t % 3 != 0 {
        return 0;
    }

    let n = t / 3;

    let nr_moves_all = n * 2 + m;
    let nr_moves_min = n;

    comb(nr_moves_all, nr_moves_min)
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let x: usize = iter.next().unwrap().parse().unwrap();
    let y: usize = iter.next().unwrap().parse().unwrap();


    println!("{}", solve(x, y));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 5;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
char s[MAXN];
int n, m, dist[MAXN][MAXN];
deque <pair <int, int>> q;
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++)
		dist[i][j] = -1;
	for (int i = 1; i <= n; i++) {
		scanf("%s", s + 1);
		for (int j = 1; j <= m; j++)
			if (s[j] == '#') {
				dist[i][j] = 0;
				q.push_back(make_pair(i, j));
			}
	}
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop_front();
		for (int i = 0; i <= 3; i++)
			if (dist[x + dx[i]][y + dy[i]] == -1) {
				dist[x + dx[i]][y + dy[i]] = dist[x][y] + 1;
				q.push_back(make_pair(x + dx[i], y + dy[i]));
			}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++)
		chkmax(ans, dist[i][j]);
	writeln(ans);
	return 0;
}

Measured memory_bytes: 12304
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int max=0,ans=0;
	char s[101];
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	for(int i=0;i<n;i++){
		if(s[i]=='I')ans++;
		if(s[i]=='D')ans--;
		if(ans>max){
			max=ans;
		}
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class CTreeRestoring {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n;
        in>>n;
        vector<int> a(n);
        for(auto&i:a) in>>i;
        sort(a.rbegin(),a.rend());
        bool f=false;
        int c=a[0];
        vector<int> b(c+1);
        for(auto i:a) ++b[i];
        iFr(i,c){
            if(2*i-1==c){
                if(b[i]!=2) f=true;
            }
            else if(2*i==c){
                if(b[i]!=1) f=true;
            }
            else if(i>c/2){
                if(b[i]<2) f=true;
            }
            else if(b[i]) f=true;
        }
        out<<(f?"Impossible":"Possible")<<endl;
    }
};

int main() {
    CTreeRestoring solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;

//auto mod int

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){} //初期化指定子
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator++() {
      if ((x++) >= mod) x-= mod;
      return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator--() {
      if ((x += mod-1) >= mod) x-= mod;
      return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint dp[100010];
int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<int, vector<int>, greater<int>> pq;
    rep(i,m) {
        int a;
        cin >> a;
        pq.push(a);
    }

    rep(i,100010) dp[i] = 0;
    dp[0] = 1; //0段目
    int broken = -1;
    if(m>0) broken = pq.top(); pq.pop();
    for(int i=1; i<=n; i++){
        if(i==broken){
            if(!pq.empty()) broken = pq.top(); pq.pop();
            continue;
        }
        dp[i]+=dp[i-1];
        if(i>=2) dp[i]+=dp[i-2];
    }
    cout << dp[n].x << endl;
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

struct edge{
    int to,money,time;
};
struct state{
    int v,d;
    bool operator<(const state& rhs)const{
        return d>rhs.d;
    }
};

priority_queue<state> q;
vector<vector<edge>> G;
int d[101];

int main(){
    int n,m;
    while(cin>>n>>m,n|m){
        vector<vector<edge>>(m+1).swap(G);
        rep(i,n){
            int f,t,m,ti; cin>>f>>t>>m>>ti;
            G[f].push_back({t,m,ti});
            G[t].push_back({f,m,ti});
        }
        int k; cin>>k;
        rep(i,k){
            int a,b,c; cin>>a>>b>>c;
            priority_queue<state>().swap(q);
            for(int& i:d) i=1<<30;
            d[a]=0;
            q.push({a,0});
            while(q.size()){
                state sta=q.top(); q.pop();
                if(d[sta.v]<sta.d) continue;
                for(edge& e:G[sta.v]){
                    int cost=(c==0 ? e.money : e.time);
                    if(d[e.to]>d[sta.v]+cost){
                        d[e.to]=d[sta.v]+cost;
                        q.push({e.to,d[e.to]});
                    }
                }
            }
            cout<<d[b]<<endl;
        }
    }
}

Measured memory_bytes: 1332
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] nums = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		int j = nums[0];
		for (int i = 0; i <= nums[0]; i++) {
			if (2 * i + 4 * j == nums[1]) {
				System.out.println("Yes");
				break;
			}
			j--;
			if (i == nums[0]) {
				System.out.println("No");
			}
		}
	}




}


Measured memory_bytes: 36032
#include <iostream>
using namespace std;
 
int main(){
 
  int N;
  long long D,X,Y;
  int ans=0;

  cin >> N >> D;
  
  for(int i=1; i<=N; i++){
   
    cin >> X >> Y;
    
    if(D*D>=(X*X+Y*Y))ans++;
    
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S,T;
    cin>>S>>T;
    int i,j,count=0;
    for(i=0,j=0;i<S.length(),j<T.length();i++,j++)
    {
        if(S[i]==T[j])
        {
            count++;
        }
    }
    cout<<count;

}


Measured memory_bytes: 256
def myAnswer(N:int,D:list,M:int,T:list) -> str:
   dic = {key:0 for key in T}
   for d in D:
      if(d in dic.keys()):
         dic[d] += 1
   for t in T:
      if(dic[t] == 0):
         return "NO"
      else:
         dic[t] -= 1
   return "YES"

def modelAnswer():
   return
def main():
   N = int(input())
   D = list(map(int,input().split()))
   M = int(input())
   T = list(map(int,input().split()))
   print(myAnswer(N,D[:],M,T[:]))
if __name__ == '__main__':
   main()

Measured memory_bytes: 44516
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {

	nextReader = newScanner()

	x, y, z := nextInt(), nextInt(), nextInt()

	fmt.Println(z, x, y)
}

/* --------------------------------------------------------------------------
 *  std.io
 * ------------------------------------------------------------------------- */
var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func mins(t ...int) int {
	if len(t) == 0 {
		return 0
	}

	min := t[0]
	for i := 1; i < len(t); i++ {
		if min > t[i] {
			min = t[i]
		}
	}
	return min
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return 0 - a
	}
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100
void push(int );
int  pop(void );
int S[MAX];
int top = 0;

int main() {
  char kari[MAX];
  int i=0,a;
  while(scanf("%s",kari) != EOF) {
    if(kari[0] == '+') {
      push(pop() + pop());
  } else if ( kari[0] == '-' ){
    a = pop();
    push(pop() - a);
 } else if ( kari[0] == '*' ){
   push(pop() * pop());
 } else {
   push( atoi(kari));
 }
  }
   printf("%d\n",pop());
   return 0;
}

void  push(int n)
{
  //printf("pushbefore %d\n",n);
  if(top > MAX) printf("error(overfllow)\n");
  else {
    S[++top] = n;
  //  printf("push %d\n",S[top-1]);
  }
}

int pop(void)
{
  if(top < 0) {
    //printf("error(overfllow)\n");
    return 0;
  }
  else {
    top--;
    return S[top+1];
  }
}

Measured memory_bytes: 548
#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 N;
  int a[110000];
  int res=0;
  cin >> N;

  rep(i,N) cin >> a[i];

  rep(i,N){
    res += (a[i]-1);
  }

  cout << res << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define ll long long

int main() {
	int a, b,ans = 0;
	cin >> a >> b;
	FOR(i, a, b + 1) {
		string c = to_string(i), d = to_string(i);
		reverse(ALL(c));
		if (c == d)ans++;

	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
	int n;

	cin >> n;

	vector<int> a(n);

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

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

	int suma = 0, sumb = 0;

	for (int i = 0; i < n; i++){
		if (i % 2 == 0)
			suma += a[n-1-i];
		else
			sumb += a[n-1-i];
	}

	cout << suma - sumb << endl;

	
}

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

char S[27];
char B[27] = "zyxwvutsrqponmlkjihgfedcba";

int main() {
	scanf("%s", S);

	int len = strlen(S);

	if (len < 26) {
		printf("%s", S);
		for (char c = 'a'; c <= 'z'; ++c) {
			int i;
			for (i = 0; i < len; ++i) if (S[i] == c) break;
			if (i == len) {
				printf("%c\n", c);
				return 0;
			}
		}
	}

	if (strcmp(S, B) == 0) {
		printf("-1\n");
		return 0;
	}

	for (int i = len; i--; ) {
		while (S[i] < 'z') {
			S[i]++;
			int j;
			for (j = 0; j < i; ++j) if (S[j] == S[i]) break;
			if (j == i) {
				S[i+1] = 0;
				printf("%s\n", S);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 
void solve()
{
    int n,k;cin>>n>>k;
    vector<ll>a(n);ll sum=0;
    REP(i,n){cin>>a[i];sum+=a[i];}
    set<ll>key;
    for(int i=1;i*i<=sum;i++)if(sum%i==0){key.insert(i);key.insert(sum/i);}
    ll ans=0;
    for(ll itr:key)
    {
        vector<ll>r(n);ll suml=0;
        REP(i,n){r[i]=a[i]%itr;suml+=itr-r[i];}
        sort(ALL(r));
        ll sumr=0;
        ll summin=1e18;
        REP(i,n)
        {
            sumr+=r[i];
            suml-=itr-r[i];
            summin=min(summin,max(suml,sumr));
        }
        if(summin<=k)ans=max(ans,itr);
    }
    cout<<ans<<endl;
}

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

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

const ll INF = 1e17;


int main() {
    // input
    int a;
    string s;
    cin >> a;
    cin >> s;

    if ( 3200 <= a ) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T> 
void print(vector<T> &x) {
    int n = x.size();
    REP(i,n) {
        if (i != n-1) cout << x[i] << " ";
        else cout << x[i] << endl;
    }
}

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    ll ans = 0;
    int n = s.length();
    vector<int> su(n+1);
    su[n] = 0;
    for (int i = n-1; i >= 1; --i) {
        if (s[i] == 'C' and s[i-1] == 'B') {
            su[i] = su[i+1];
            su[i-1] = su[i]+1;
            if (i-2 >= 0) {
                if (s[i-2] == 'A') {
                    su[i-2] = su[i-1];
                }
            }
            --i;
        }
        else {
            if (s[i] == 'A') {
                su[i] = su[i+1];
                if (i-1 == 0) su[i-1] = su[i];
            }
        }
    }
    REP(i,n) {
        if (s[i] == 'A') {
            ans += (su[i]-su[n]);
        }
    }
    //print(su);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1412
// https://atcoder.jp/contests/abc165/tasks/abc165_e
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int,int> P;

#define MAX_N 100005


int main() {
	int n,m;
	cin >> n >> m;
	int a=1,b=1+m;
	for(int i=0;i<(m+1)/2;i++){
		cout << 1+i << " " << m+1-i << endl;
	}
	if(m==1)return 0;
	for(int i=0;i<m/2;i++){
		cout << m+2+i << " " << 2*m+1-i << endl;
	}
    return 0;
}



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


int main(void){

    int X; cin>>X;
    ll ans = 0;

    for (int i = X; i<X*2; ++i) {
        bool sosu = true;
        for (int j = 3; j*2 <= i; ++j) {
            if(i % j==0){
                sosu = false;
                break;
            }
        }
        if(sosu){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<X*2<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
            #include <ext/pb_ds/assoc_container.hpp>
            #include <ext/pb_ds/tree_policy.hpp>
            using namespace std;
            using namespace __gnu_pbds;
            #define rep(i,a,b) for(ll i =a; i<b;++i)
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define endl "\n"
            #define pb push_back
            #define F first
            #define S second
            #define print(a)       for(auto x : a) cout << x << " "; cout << endl
            #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
            #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
            #define mk(x,y)  make_pair(x,y)
            typedef  long long int ll;
            const ll N = ( 1e6+ 5 );
            const ll mod = 1e18 ;
            ll n ,a,b,c,d ,dp[N];
            map < ll , ll> mp;
    ll pow_mod_m(ll a , ll n)
    {
        if(!n)
            return 1;
        ll pt =  pow_mod_m(a,n/2);
        pt *= pt , pt %= mod;;
        if(n&1)
            pt *= a , pt %= mod;
        return pt;
    }

    ll solve(ll x)
    {
        ll ans  = LONG_LONG_MAX;
        if( x < ans / d)
        {
            ans  = x*d;
        }
        if(mp[x] > 0 )  return mp[x];
        if( x == 0 )
        {
            return 0;
        }
        if(x == 1)
        {
            return d;
        }
        if( x % 3 == 0 )
        {
             ans  = min(ans , b + solve(x/3));
        }
        else
        {
            ans = min(ans , d*(3 - x%3) + b + solve((x +3 - x%3)/3));
            ans = min(ans  ,d*(x%3) + b + solve( (x - x%3)/3 ) );
        }
        if(x %5 == 0)
        {
            ans  = min(ans , c + solve(x/5));
        }
        else
        {
            ans = min(ans , d*(5- x%5) + c + solve((x +5 - x%5)/5));
            ans = min(ans  ,d*(x%5) + c + solve( (x - x%5)/5 ) );
        }
        if(x %2 == 0)
        {
            ans  = min(ans , a + solve(x/2));
        }
        else
        {
            ans = min(ans , d*(2- x%2) + a + solve((x +2- x%2)/2));
            ans = min(ans  ,d*(x%2) + a + solve( (x - x%2)/2 ));
        }
        mp[x] = ans;
        return ans;
    }

    int main()
    {
         IOS;
         int ts =1;
         cin >> ts;
         rep(t,1,ts+1)
         {
             mp.clear();
             cin >> n >> a >> b >> c >> d;
             cout << solve(n) << endl;
         }
    }


Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  string s;
  cin >> s;
  int ans = 0;
  rep(i,3){
    if(s[i] == '1') ans ++;
  }
  cout << ans << endl;
}






Measured memory_bytes: 256
import sys
from io import StringIO
import unittest


def resolve():
    # s = input()
    # n = int(input())
    d, t, s = map(int, input().split())
    # l = [list(map(int, input().split())) for _ in range(n)]

    if t * s >= d:
        print('Yes')
    else:
        print('No')

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1000 15 80"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2000 20 100"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10000 1 1"""
        output = """No"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  string S;
  cin >> S;
  ll N = sz(S);
  string T = S;
  reverse(all(T));
  string U = S.substr(0, (N-1)/2);
  string V = S.substr((N+1)/2, (N-1)/2);
  string W = U;
  reverse(all(W));
  string X = V;
  reverse(all(X));
  if(S == T && U == W && V == X){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
  int n; cin >> n;
  set<int> reg;
  vector<int> a(n);
  for(int i=0; i<n; i++) {
    cin >> a[i];
    auto c = reg.erase(a[i]);
    if(c==0) reg.insert(a[i]);
  }
  cout << reg.size() << endl;
  return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 2003 , mo = 924844033;

inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

inline lint inva(lint a){return powa(a,mo-2);}

lint jc[_],rjc[_];

inline void fuck(int n=_-1)
{
	jc[0]=jc[1]=rjc[0]=1;
	for(int i=2;i<=n;i++)jc[i]=jc[i-1]*i%mo;
	rjc[n]=inva(jc[n]);
	for(int i=n-1;i>=1;i--)rjc[i]=rjc[i+1]*(1ll+i)%mo;
}

inline lint C(int n,int m)
{
	if(n<m || n<0 || m<0)return 0;
	return jc[n]*rjc[m]%mo*rjc[n-m]%mo;
}

int n,lim,llim;
lint f[_]={0};

int main()
{
	n=ty(),lim=ty(),llim=lim+lim;
	fuck();

	f[0]=1;
	for(int i=1;i<=llim && i<=n;i++)
	{
		int j=i;
		while(j+llim<=n)j+=llim;
		int cnt=(j-i)/lim+(i>lim)+(j+lim<=n);
		for(int k=n;k>=1;k--)
			for(int a=1;a<=k && a+a-1<=cnt;a++)
				f[k]=(f[k]+f[k-a]*C(cnt-a+1,a)%mo)%mo;
	}

	lint ans=0;
	for(int i=0;i<=n;i++)ans=(ans+f[i]*jc[n-i]%mo*(i&1?-1:1)+mo)%mo;
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  ll L,R;
  cin >> L >> R;
  ll N = 2019;
  if(L/N!=R/N){
    cout << 0 << endl;
  }else{
    ll MIN = 2018;
    FOR(i,L,R){
      FOR(j,i+1,R+1){
        MIN = min(MIN,(i%N)*(j%N)%N);
      }
    }
    cout << MIN << endl;
  }
}

Measured memory_bytes: 256
from collections import deque

n, m, k = map(int, input().split())
friend = [set() for _ in range(n)]
block = [set() for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    friend[a - 1].add(b - 1)
    friend[b - 1].add(a - 1)
for _ in range(k):
    a, b = map(int, input().split())
    block[a - 1].add(b - 1)
    block[b - 1].add(a - 1)
visited = [0 for _ in range(n)]
ans = [None for _ in range(n)]
for i in range(n):
    if visited[i]:
        continue
    prefriends = {i}
    check = deque([i])
    while check:
        now = check.pop()
        visited[now] = 1
        for next in friend[now]:
            if visited[next] == 0:
                check.append(next)
                prefriends.add(next)
    for j in prefriends:
        ans[j] = len(prefriends) - 1 - len(friend[j]) - len(prefriends & block[j])
print(' '.join(list(map(str, ans)))) 

Measured memory_bytes: 169100
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int temp = 0;
	int val =n;
	while(n>0)
	{
		temp = temp + n%10;
		n=n/10;
	}
	if (val%temp == 0)
	cout<<"Yes"<<endl;
	else
	{
		cout<<"No"<<endl;
	}
	
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int h,w;
bool f[20][20];
char c;
int a[20][20][20][20];
const int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++)
	for(int j=0;j<w;j++){
		cin>>c;
		if(c=='#')
		f[i][j]=1;
	}
	memset(a,-1,sizeof(a));
	rep(i,h)rep(j,w){
		if(f[i][j])
		continue;
		queue<pii> q;
		a[i][j][i][j]=0;
		q.push(m_p(i,j));
		while(!q.empty()){
			pii u=q.front();
			q.pop();
			int x=u.fr,y=u.se;
			rep(k,4){
				int xx=x+dx[k],yy=y+dy[k];
				if(xx<0||xx>=h||yy<0||yy>=w)
				continue;
				if(f[xx][yy])
				continue;
				if(a[i][j][xx][yy]<=a[i][j][x][y]+1&&a[i][j][xx][yy]!=-1)
				continue;
				a[i][j][xx][yy]=a[i][j][x][y]+1;
				q.push(m_p(xx,yy));
			}
		}
	}
	int ans=0;
	for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	for(int i1=0;i1<h;i1++)
	for(int j1=0;j1<w;j1++){
		if(f[i][j]||f[i1][j1])
		continue;
		ans=max(ans,a[i][j][i1][j1]);
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 998244353;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}


int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (s.size() % 2 != 0){
        cout << "No" << endl;
        return 0;
    }
    bool flag = true;
    REP(i, s.size() / 2)
    {
        if (s[i] != s[i + s.size()/2]){
            flag = false;
        }
    }
    if (flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (register int i = (a); i <= (b); ++i)
#define per(i, a, b) for (register int i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (register int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) ((x) & (-(x)))
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define sum(x) ((int)x.sume())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 2e6 + 100 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 1e9 + 7 ;
const double eps = 1e-7 ;
template <class T = int> T read()
{
	T f = 1, a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	return a * f ;
}

int n;

int a[maxn];

mii s;

bool check(int lim)
{
	s.clear();
	rep(i, 1, n)
	{
		if(a[i] > a[i - 1]) continue;
		while(!s.empty() && (-- s.end()) -> fi > a[i]) s.erase((-- s.end()));
		per(j, a[i], 0)
		{
			if(!j) return 0;
			++ s[j];
			if(s[j] < lim) break;
			s.erase(s.find(j));
		}
	}
	return 1;
}

signed main()
{
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d", &a[i]);
	rep(i, 2, n) if(a[i] <= a[i - 1]) goto binary;
	return puts("1"), 0;
	binary: ;
	int l = 2, r = n, ans;
	while(l <= r)
	{
		int mid = (l + r) >> 1;
		if(check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	Scanner scan = new Scanner(System.in);
	Comparator<Integer> comp = new LowerBoundComparator<>();
	
	void compute() {
		int n = scan.nextInt();
		
		ArrayList<Integer> list = new ArrayList<Integer>();
		
		for (int i=0;i<n;i++) {
			int num = scan.nextInt();
			boolean did = false;
			int p = Collections.binarySearch(list, num, comp);
			if (p < 0)
				p = ~p;
			if (p == 0) {
				list.add(0, num);
			} else {
				list.set(p-1, num);
			}
		}
		
		System.out.println(list.size());
	}
	
	class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T> {
	    public int compare(T x, T y) {
	        return (x.compareTo(y) >= 0) ? 1 : -1;
	    }
	}
	
	
	public static void main(String...arg) {
		new Main().compute();
	}
}


Measured memory_bytes: 50400
import java.util.*;

public class Main {

	static int N;
	static int M;
	static int Q;
	static int[][] a;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		Q = sc.nextInt();
		a = new int[Q][4];
		for (int i = 0; i < Q; i++) {
			a[i][0] = sc.nextInt() - 1;
			a[i][1] = sc.nextInt() - 1;
			a[i][2] = sc.nextInt();
			a[i][3] = sc.nextInt();
		}
		sc.close();

		int[] b = new int[N];
		long ans = dfs(0, 1, b);
		System.out.println(ans);
	}

	public static long dfs(int idx, int curmax, int[] b) {
		long ret = 0l;
		if (idx == N) {
			for (int i = 0; i < Q; i++) {
				int x = a[i][0], y = a[i][1], c = a[i][2], d = a[i][3];
				if (b[y] - b[x] == c) {
					ret += d;
				}
			}
			return ret;
		} else {
			for (int k = curmax; k <= M; k++) {
				b[idx] = k;
				long t = dfs(idx + 1, Math.max(k, curmax), b);
				ret = Math.max(ret, t);
			}
		}
		return ret;
	}
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int a;
    cin>>a;
    cout<<3*a*a;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)

int main ()
{
    string s; cin >> s;

    string sunny = "Sunny";
    string cloudy = "Cloudy";
    string rainy = "Rainy";

    if (s == sunny) {
        cout << cloudy << endl;
    } else if (s == cloudy) {
        cout << rainy << endl;
    } else if (s == rainy) {
        cout << sunny << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
number = [n for n in range(10)]
ans = 0
for i in number:
    try:
        j = s.index(str(i))
        for k in number:
            try:
                l = s[j+1:].index(str(k))
                exist = [0]*10
                for m in s[l+j+2:]:
                    exist[int(m)] = 1
                #print(exist)
                ans += sum(exist)
            except:
                continue
    except:
        continue
print(ans)

Measured memory_bytes: 3064
#include <iostream>


using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    cin >> n;
    for(int i=0;i<n;i++) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for(int i=1;i<n;i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3864
#coding: utf-8

count = 0
sum = 0
A = [int(i) for i in input().split()]
k = int(input())

max_idx = A.index(max(A))
for i in range(k):
    A[max_idx] = A[max_idx] * 2

for i in range(len(A)):
    sum += A[i]

print(sum)


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int[][] input = new int[n][2];
        for(int i = 0; i < n; i++){
            input[i][0] = scanner.nextInt();
            input[i][1] = scanner.nextInt();
        }
        long[][] knap = new long[n][w + 1];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < w + 1; j++){
                if(j == 0){
                    knap[i][j] = 0;
                }
                else {
                    if(j - input[i][0] >= 0){
                        if(i != 0){
                            knap[i][j] = Math.max(input[i][1] + knap[i - 1][j - input[i][0]], knap[i - 1][j]);
                        }
                        else {
                            knap[i][j] = input[i][1];
                        }
                    }
                    else if(i != 0) {
                        knap[i][j] = knap[i - 1][j];
                    }
                    else {
                        knap[i][j] = 0;
                    }
                }
            }
        }

        System.out.println(knap[n - 1][w]);

    }
}


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

int main() {
	int N;
	cin >> N;
	double ans = 0;
	rep(i, N) {
		double A;
		cin >> A;
		ans += 1 / A;
	}
	printf("%.5lf\n", 1 / ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  


int main(){
  int k;  cin >> k;
  queue<ll> que;
  for(int i=1; i<10; i++)  que.push(i);

  for(int i=0; i<k-1; i++){
    ll value = que.front(); que.pop();
    for(int j=-1; j<=1; j++){
      int nv = value%10+j;
      if(0<=nv && nv<=9) que.push(value*10+nv);
    }

  }
 
  cout << que.front() << endl;
  
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する


int main(){
    int n,x,y;
    cin>>n>>x>>y;
    vector<int> k(n,0);
    for(int i=1;i<=n-1;i++){
        for(int j=i+1;j<=n;j++){
            int dis;
            dis = min(j-i,abs(i-x)+abs(j-y)+1);
            k[dis]++;
        }
    }
    for(int i=1;i<=n-1;i++){
        cout<<k[i]<<endl;
    }
    
}

Measured memory_bytes: 256