akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
int n,m,ans;
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
int solve(int n,int x)
{
	while(n%x==0)
	{
		n=n/x;
	}
	if(n%x==1)return 1;
	return 0;
}
signed main()
{
	ans=1;
	n=read();
	for(int i=2;i*i<=n;i++)
		if(n%i==0)
		{
			if(solve(n,i))ans++;
			if(i*i==n)continue;
			if(solve(n,n/i))ans++;
		}
	m=n-1;
	if(m>1)ans++;
	for(int i=2;i*i<=m;i++)
		if(m%i==0&&n%i>0)
		{
			ans++;
			if(i*i==m)continue;
			ans++;
		}
	cout<<ans;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i = 0;i<n;i++) cin >> d[i];
  sort(d.begin(),d.end());
  int ans = d[n/2] - d[n/2-1];
  cout << ans << endl;
  return 0;
  }


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

int main() {
  int a;
  cin >> a;
  long long ret = 0;
  for(int i=3; i<=a; i++){
     for(int j=2; j<i; j++){
        for(int k=1; k<j; k++){
            long long gs = gcd<int, long long>(i, gcd<int, int>(k, j));
            ret += gs * 6;
  }}}
  for(int i=2; i<=a; i++){
     for(int j=1; j<i; j++){
        long long gs = gcd<int, int>(i, j);
        ret += gs * 6;
  }}

  for(int i=1; i<=a; i++){
      ret += i;
  }
  cout << ret <<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const vector<vector<string>> base {
    {"aabc",
     "ddbc",
     "bcaa",
     "bcdd"},
    {"aabba",
     "bcc.a",
     "b..cb",
     "a..cb",
     "abbaa"},
    {"aabc..",
     "ddbc..",
     "..aabc",
     "..ddbc",
     "bc..aa",
     "bc..dd"},
    {"aabbcc.",
	 "dd.dd.a",
	 "..d..da",
	 "..d..db",
	 "dd.dd.b",
	 "..d..dc",
	 "..d..dc"}
};

void merge_grids(vector<string> &a, const vector<string> &b) {
    int a_size = a.size();
    int b_size = b.size();
    int new_size = a_size + b_size;
    fori (i, 0, b_size) a.push_back("");
    fori (i, 0, new_size) a[i].resize(new_size, '.');
    fori (i, 0, b_size) {
        fori (j, 0, b_size) {
            a[a_size + i][a_size + j] = b[i][j];
        }
    }
}

vector<string> roll(int n) {
    int rest = n % 4;
    vector<string> result = base[rest];
    while ((int) result.size() < n) {
        merge_grids(result, base[0]);
    }
    return result;
}

void solve() {
    int n;
    cin >> n;
    if (n == 2) {
        cout << -1 << endl;
    }
    else if (n == 3) {
       cout << "aa." << endl << "..a" << endl << "..a" << endl; 
    }
    else {
        vector<string> ans = roll(n);
        fori (i, 0, n) {
            fori (j, 0, n) {
                cout << ans[i][j];
            }
            cout << endl;
        }
    }
}

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



Measured memory_bytes: 2816
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,a[K],m1,m2;
int main(){
	cin>>n;
	m1=m2=-999;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>m1)
			m2=m1,m1=a[i];
		else if(a[i]>=m2)
			m2=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==m1)
			cout<<m2<<'\n';
		else
			cout<<m1<<'\n';
	}
	return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    set<string> ss;
    rep(i, 0, n) {
        string s;
        cin >> s;
        ss.insert(s);
    }
    cout << ss.size() << endl;

    return 0;
}

Measured memory_bytes: 19248
MOD = 10 ** 9 + 7

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, A = Z(), ZZ()
    cnt = [0] * (N)
    ng, output = 0, 1

    for a in A:
        if a == 0:
            ng += 1
            cnt[a] += 1
            continue
        cnt[a] += 1
        output *= cnt[a-1]
        output %= MOD
        cnt[a-1] -= 1
    ng = 6 if 2 <= ng <= 3 else 3 if ng == 1 else 0
    output *= ng
    output %= MOD
    print(output)

    return

if __name__ == '__main__':
    main()


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



int main(){
int n,a[100],b[100],c[100],m=0;;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
cin>>b[i];
}
for(int i=1;i<n;i++){
cin>>c[i];
}
for(int i=1;i<=n;i++){
m+=b[a[i]];
if(a[i]-a[i-1]==1)m+=c[a[i-1]];
}
cout<<m;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<pair<long long, pair<int, int>>> ab(n);
  REP(i, n) {
    cin >> ab[i].second.first >> ab[i].second.second;
    ab[i].first = ab[i].second.first + ab[i].second.second;
  }
  sort(ALL(ab));
  reverse(ALL(ab));
  long long ans = 0;
  REP(i, n) {
    if (i & 1) ans -= ab[i].second.second;
    else ans += ab[i].second.first;
  }
  cout << ans << '\n';
  return 0;
}


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

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif

	string s,t;
	cin>>s>>t;
	//cout<<s<<" "<<t;

	int n = t.size();
	int m = s.size();
	int mn = INT_MAX;
	for(int i=0;i<=m-n;i++){
		int cnt =0;	
		for(int j=0;j<n;j++){
			if(t[j]!=s[j+i])
				cnt++;
		}
		mn = min(mn,cnt);
	}
	cout<<mn<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;

typedef pair<int,int> P;

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

struct edge {
  int from, to, cost;
};

const int INF = 10000000;
int n, d[10];

void solve() {
  vector<edge> es(2*n);
  
  int towns = 0;
  rep(i,n) {
    int f, t, c; cin>>f>>t>>c;
    es[i*2].from = f; es[i*2].to = t; es[i*2].cost = c;
    es[i*2+1].from = t; es[i*2+1].to = f; es[i*2+1].cost = c;
    towns = max(towns, max(f,t));
  }
    
  int town, mini = INF;
  rep(z,towns+1) {
    rep(i,10) d[i] = INF;
    priority_queue<P> que;
    que.push(P(0, z));
    while (!que.empty()) {
      P p = que.top(); que.pop();
      int cc = p.first, ii = p.second;
      if (cc > d[ii]) continue;
      d[ii] = cc;
      rep(i,n*2) {
        edge e = es[i];
        if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
          d[e.to] = d[e.from] + e.cost;
          que.push(P(d[e.to], e.to));
        }
      }
    }
    
    int sum = 0;
    rep(i,towns+1) sum += d[i];
    if (sum < mini) {
      town = z;
      mini = sum;
    }
  }
  cout<<town<<" "<<mini<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define N 100

int main(){
  int A[N],a,i,j,n,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<=n-1;i++){
    for(j=n-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	a=A[j];
	A[j]=A[j-1];
	A[j-1]=a;
	count++;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int x = Integer.parseInt(input[0]);
        int y = Integer.parseInt(input[1]);

        System.out.println(gcd(x, y));
    }

    public static int gcd(int a, int b){
        if(b == 0){
            return a;
        }else{
            return gcd(b, a % b);
        }
    }
}

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

int main() {
	// your code goes here
	int n,m,l;
	cin >> n >> m >> l;
	int ans=n*1+m*2+l*4;
	if(ans == 3 || ans ==4)
	cout << "Open" << endl;
	else 
	cout << "Close" << endl;
	return 0;
}

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

int main(){
    int n, a, i;
    int min = 1000000;
    int max = -1000000;
    long long sum = 0;
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> a;
        if (a < min) min = a;
        if (a > max) max = a;
        sum = sum + a;
    }
    cout << min << " " << max << " " << sum << endl;

    return 0;
}

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

int n,m;
vector<tuple<int,int,int>> dat;

int solve(){
    sort(dat.begin(), dat.end());
    vector<int> infected(n+1);
    infected[1] = true;
    for(auto &e : dat){
        infected[get<2>(e)] |= infected[get<1>(e)];
    }
    return count(infected.begin(), infected.end(), true);
}

int main(){
    while(cin >> n >> m && n){
        dat.resize(m);
        rep(i,m){
            int t,s,d;
            cin >> t >> s >> d;
            dat[i] = tie(t,s,d);
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 1524
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	string S;
	cin >> S;
	int N = S.size();

	int kotae = 0;
	rep(i, N / 2) {
		if (S[i] != S[N - 1 - i]) kotae++;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n; cin>>n;
    ll sum=0;
    RNG(i,1,n) {
        if(i%3 > 0 && i%5>0)
            sum += i;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int a = 0, b = 0, c = 0;
  rep(i, N){
    int p;
    cin >> p;
    if(p <= A)a++;
    else if(A + 1 <= p && p <= B)b++;
    else if(B + 1 <= p)c++;
  }
  cout << min(a, min(b, c)) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#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>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
  string S;
  cin >> S;
  if(S== "ABC"){
    cout << "ARC" << endl;
  }
  else{
    cout << "ABC" << endl;
  }
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a<=b){
    printf("%d\n",a);
  } else {
    printf("%d\n",a-1);
  }
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#pragma warning(disable:4996) 

#include <algorithm>
#include <bitset>
// #include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <chrono>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr ll LL2_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = { { typeid(int), "%d" },
{ typeid(ll), "%lld" },
{ typeid(double), "%lf" },
{ typeid(char), "%c" } };

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
// static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	 //INFILE();

	 int n, count = 0;
	ll h, w;
	cin >> n >> h >> w;

	for (int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;

		if (a >= h && b >= w)
		{
			count++;
		}
	}

	cout << count << endl;
	return 0;
}

template <class T> static void scan(vector<T> &v) {
	auto tFormat = scanType[typeid(T)];
	for (T &n : v) {
		scanf(tFormat, &n);
	}
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

	int i = 0, size = static_cast<int>(v.size());
	string s;
	getline(cin, s);

	if (s.size() != 0) {
		i++;
		v[0] = s;
	}

	for (; i < size; ++i) {
		getline(cin, v[i]);
	}
}

//static boost::dynamic_bitset<> scan(char trueValue) {
//	string s;
//	getline(cin, s);
//
//	if (s.size() == 0) {
//		getline(cin, s);
//	}
//
//	for_each(begin(s), end(s),
//		[trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
//	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
//}

Measured memory_bytes: 888
import math
n = int(input())
c = []
d = []
for i in range(n):#h:高さ
    c.append([int(m) for m in input().split()])
    d.append([])
d[0].append(c[0][0])
d[0].append(c[0][1])

def f(x,y):
    return x//y + (1 if x%y > 0 else 0)

for i in range(1, n):
    #zz = max(math.ceil(d[i - 1][0] / c[i][0]), math.ceil(d[i - 1][1] / c[i][1]))
    zz = max(f(d[i - 1][0], c[i][0]),f(d[i - 1][1], c[i][1]))
    d[i].append(c[i][0] * zz)
    d[i].append(c[i][1] * zz)

    #print(d[i][0], d[i][1])
print(d[n - 1][0] + d[n - 1][1])

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

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

const int modi = 1e9+7;

void solve(){
	int n,k;
	cin >> n >> k;
	int a[n];
	forn(i,0,n)
		cin >> a[i];
	int l=1,r=1e9+100;
	auto ok=[&](int ans, int ck){
		
		for(int i =0;i<n;i++){
			ck-=((a[i]+ans-1)/ans - 1);
		}
		// cout << ck << endl;
		// cout << ans << endl;
		return ck>=0;
	};
	while(l<=r){
		int mid = l+(r-l)/2;
		if(ok(mid,k)){
			r=mid-1;
		}
		else l= mid+1;
	}
	cout << l << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 4404
#include<iostream>
#include<algorithm>
using namespace std;
#define N 131072
int tree[N*2];
int getsum(int a,int b,int k,int l,int r){
  if(r<=a||b<=l)return 0;
  if(a<=l&&r<=b)return tree[k];
  int m=(l+r)/2;
  return getsum(a,b,k*2+1,l,m)+getsum(a,b,k*2+2,m,r);
}
void add(int a,int b){
  a+=N-1;
  tree[a]+=b;
  while(a){
    a=(a-1)/2;
    tree[a]+=b;
  }
}
int main(){
int n,q;
int c,a,b;
  cin>>n>>q;
  for(int i=0;i<q;i++){
    cin>>c>>a>>b;
    a--;
    if(c==1) cout<<getsum(a,b,0,0,N)<<endl;
    else add(a,b);
  }
  return 0;
} 

Measured memory_bytes: 1960
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[50000];
	int max=0;
	int t=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]>max)
	{
		
		max=a[i];
		t=i;
		}
	}
	int sum=0;
	for(int i=0;i<n;i++){
		if(i==t)
		sum=sum+a[i]/2;
		else
		sum=sum+a[i];
	}
	cout<<sum;
} 

Measured memory_bytes: 256
#define DEBUG 1
#include <bits/stdc++.h>
using namespace std;
typedef          char      s8;
typedef unsigned char      u8;
typedef          short    s16;
typedef unsigned short    u16;
typedef          int      s32;
typedef unsigned int      u32;
typedef          long int s64;
typedef unsigned long int u64;
typedef float             f32;
typedef double            f64;
#define rep(_i, _n)		for (int _i = 0; _i < (int)(_n); _i++)
#if DEBUG
#define PHERE()			{ cerr << "L" << setw(3) << __LINE__ << ": PHERE" << clock() << endl; }
#define PVAL( _var )	{ cerr << "L" << setw(3) << __LINE__ << ":" << #_var "=" << (_var) << endl; }
#else
#define PHERE()
#define PVAL( _var )
#endif


int main()
{
	//////// 入力 ////////
	int N,K;
	cin >> N >> K;
	vector<int> price;
	price.resize( N );
	rep( i, N ) {
		cin >> price[i];
	}
	/////////////////////
	
	sort( price.begin(), price.end() );
	int sum = 0;
	rep( i, K ) {
		sum += price[i];
	}
	
	//////// 出力 ////////
	cout << sum;
	/////////////////////
	
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int n, q;
string s;
char t[200000], d[200000];

int f(int x){
    int p=x;
    for(int i=0;i<q;i++){
        if(p<0||p>=n)break;
        if(s[p]==t[i]){
            if(d[i]=='L')p--;
            else p++;
        }
    }
    if(p<0)return -1;
    if(p>=n)return 1;
    return 0;
}


int main(void){
    cin>>n>>q>>s;
    for(int i=0;i<q;i++){
        cin>>t[i]>>d[i];
    }
    int a=n, l=-1, r=n;
    while(l+1<r){
        int m=(l+r)/2;
        if(f(m)==-1){
            l=m;
        }else{
            r=m;
        }
    }
    a-=l+1;
    l=-1, r=n;
    while(l+1<r){
        int m=(l+r)/2;
        if(f(m)==1){
            r=m;
        }else{
            l=m;
        }
    }
    a-=n-r;
    cout<<a<<endl;
}


Measured memory_bytes: 900
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int tt=0;
  int xx=0;
  int yy=0;
  int i;
  vector<int> t(n);
  vector<int> x(n);
  vector<int> y(n);
  for(i=0;i<n;i++) cin >> t[i] >> x[i] >> y[i];
  for(i=0;i<n;i++){
    if(((t[i]-tt)-(abs(x[i]-xx)+abs(y[i]-yy)))>=0 && (((t[i]-tt)-(abs(x[i]-xx)+abs(\
y[i]-yy)))%2)==0){
      tt = t[i];
      xx = x[i];
      yy = y[i];
    }
    else{
      cout << "No" << "\n";
      return 0;
    }
  }
  cout << "Yes" << "\n";
  return 0;
}

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

const int MAX_ITEM = 100;
const int MAX_WEIGHT_SUM = 100000;

int N, W;
int w[MAX_ITEM];
long long v[MAX_ITEM];

// dp[i][sum_w] := sum_wの重さをこえない範囲でi番目までの品物を選んだ場合の価値最大値
long long dp[MAX_ITEM + 1][MAX_WEIGHT_SUM + 1] = { 0 };

int main()
{
	cin >> N >> W;
	for ( int i = 0; i < N; ++i ) {
		cin >> w[i] >> v[i];
	}

	for ( int i = 0; i < N; ++i ) {
		for ( int sum_w = 0; sum_w <= W; ++sum_w ) {
			if ( sum_w < w[i] ) {
				dp[i + 1][sum_w] = dp[i][sum_w];
			}
			else {
				dp[i + 1][sum_w] = ::max( dp[i][sum_w],
										  dp[i][sum_w - w[i]] + v[i] );
			}
		}
	}

	cout << dp[N][W] << endl;
	return 0;
}

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

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

  int t = N;
  int s = 0;
  while (t > 0) {
    s += t % 10;
    t /= 10;
  }

  if (N % s == 0)
    puts("Yes");
  else
    puts("No");
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	p, q := make([]int, n), make([]int, n)

	for i := 0; i < n; i++ {
		p[i] = nextInt()
	}
	for i := 0; i < n; i++ {
		q[i] = nextInt()
	}

	nums := make([]int, n)
	for i := 0; i < n; i++ {
		nums[i] = i+1
	}

	ps, qs := -1, -1
	perm := permutations(nums, n)
	for i := 0; i < len(perm); i++ {
		if ps == -1 && reflect.DeepEqual(p, perm[i]) {
			ps = i
		}
		if qs == -1 && reflect.DeepEqual(q, perm[i]) {
			qs = i
		}
	}

	if ps > qs {
		fmt.Println(ps - qs)
	} else {
		fmt.Println(qs - ps)
	}
}

func permutations(iterable []int, r int) [][]int {
	pool := iterable
	n := len(pool)

	if r > n {
		return [][]int{}
	}

	indices := make([]int, n)
	for i := range indices {
		indices[i] = i
	}

	cycles := make([]int, r)
	for i := range cycles {
		cycles[i] = n - i
	}

	var res [][]int
	result := make([]int, r)
	for i, el := range indices[:r] {
		result[i] = pool[el]
	}

	res = append(res, result)

	for n > 0 {
		i := r - 1
		for ; i >= 0; i -= 1 {
			cycles[i] -= 1
			if cycles[i] == 0 {
				index := indices[i]
				for j := i; j < n-1; j += 1 {
					indices[j] = indices[j+1]
				}
				indices[n-1] = index
				cycles[i] = n - i
			} else {
				j := cycles[i]
				indices[i], indices[n-j] = indices[n-j], indices[i]

				result_ := make([]int, len(result))
				copy(result_, result)
				for k := i; k < r; k += 1 {
					result_[k] = pool[indices[k]]
				}

				res = append(res, result_)
				result = result_

				break
			}
		}

		if i < 0 {
			return res
		}

	}

	return res
}


Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;

typedef long long int ll;
typedef string str;

ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);
}

void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{
	ll t,n,m,k,i,a,b,j;
	str s;
	cin >> n;
	ll arr[n+2];
	m=0;
	for(i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	sort(arr,arr+n);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			for(k=j+1;k<n;k++)
			{
				if(arr[k]<arr[i]+arr[j] && arr[i]!=arr[j] && arr[j]!=arr[k])
					m++;
			}
		}
	}
	cout << m << "\n";
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int change(string s1,string s2){
	int n1=s1.length();
	int n2=s2.length();
	int count=0;
	for(int i=0;i<n1;i++){
		if(s1[i]!=s2[i]){
		count++;
	}
}
	return count;
}
int main()
{
	string s1;
	string s2;
	cin>>s1>>s2;
    int x=change(s1,s2);
    cout<<x;
}

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

using namespace std;

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

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

  if(N == "AAA" || N == "BBB")
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	long int total = 100000;
	scanf("%d", &n);
	
	for (; n > 0; n--){
		total *= 1.05;
		if( (total % 1000) > 0)
			total = (total / 1000 + 1) * 1000;
	}
	printf("%ld\n", total);
	
	return 0;
}

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

int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        if(n==2||m==2)
        {
            printf("No\n");
        }
        else if(n==1&&m==3)
        {
            printf("Yes\n");
        }
        else if(n==1&&m==5)
        {
            printf("Yes\n");
        }
        else if(n==1&&m==7)
        {
            printf("Yes\n");
        }
        else  if(n==1&&m==8)
        {
            printf("Yes\n");
        }
        else if(n==1&&m==10)
        {
            printf("Yes\n");
        }
        else if(n==1&&m==12)
        {
            printf("Yes\n");
        }
        else if(n==3&&m==5)
        {
            printf("Yes\n");
        }
        else  if(n==3&&m==7)
        {
            printf("Yes\n");
        }
        else  if(n==3&&m==8)
        {
            printf("Yes\n");
        }
        else  if(n==3&&m==10)
        {
            printf("Yes\n");
        }
        else  if(n==3&&m==12)
        {
            printf("Yes\n");
        }
        else  if(n==5&&m==7)
        {
            printf("Yes\n");
        }
        else  if(n==5&&m==8)
        {
            printf("Yes\n");
        }
        else  if(n==5&&m==10)
        {
            printf("Yes\n");
        }
        else if(n==5&&m==12)
        {
            printf("Yes\n");
        }
        else  if(n==7&&m==8)
        {
            printf("Yes\n");
        }
        else if(n==7&&m==10)
        {
            printf("Yes\n");
        }
        else if(n==7&&m==12)
        {
            printf("Yes\n");
        }
        else if(n==8&&m==10)
        {
            printf("Yes\n");
        }
        else if(n==8&&m==12)
        {
            printf("Yes\n");
        }
        else if(n==10&&m==12)
        {
            printf("Yes\n");
        }
        else if(n==4&&m==6)
        {
            printf("Yes\n");
        }
        else if(n==4&&m==9)
        {
            printf("Yes\n");
        }
        else if(n==4&&m==11)
        {
            printf("Yes\n");
        }
        else if(n==6&&m==9)
        {
            printf("Yes\n");
        }
        else if(n==6&&m==11)
        {
            printf("Yes\n");
        }
        else if(n==9&&m==11)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return 0;
}


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


using namespace std;

int main(){

	int n,q;

	while(cin>>n>>q){
		if(n==0 && q==0)break;
		string *str;
		int *eraY,*wesY;

		str = new string [n];
		eraY = new int [n];
		wesY = new int [n];

		for(int i=0;i<n;i++){
			cin>>str[i]>>eraY[i]>>wesY[i];
		}


		for(int i=0;i<q;i++){

			int query;
			cin>>query;

			int flag=0;
			for(int j=0;j<n;j++){
				if(query<=wesY[j] && query> wesY[j]-eraY[j]){
					cout<<str[j]<<" "<<eraY[j]-(wesY[j]-query)<<endl;
					flag=1;
					break;
				}
			}

			if(flag==0){
				cout<<"Unknown"<<endl;
			}

		}

	}

	return 0;
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main()
{
  const int m = 1000002;
  int n, t, ans = 0;
  cin >> n;
  vector<bool> a(m, false);
  vector<int> b(n);
  rep(i, n)
  {
    // cin >> t;
    // a[t] = true;
    // b[i] = t;
    cin >> b[i];
  }
  sort(b.begin(), b.end());
  rep(i, n - 1)
  {
    if (a[b[i]] == true)
      continue;
    if (b[i] == b[i + 1])
    {
      a[b[i]] = true;
    }
    for (int j = 2; j < b[n - 1] / b[i] + 1; j++)
    {
      a[j * b[i]] = true;
    }
  }
  rep(i, n)
  {
    if (a[b[i]] == false)
      ans++;
  }
  // ans = n;
  // vector<int> a(n);
  // rep(i, n) cin >> a[i];
  // sort(a.begin(), a.end(), greater<>());
  // if (a[n - 1] == a[n - 2])
  //   ans--;
  // rep(i, n - 1)
  // {
  //   for (int j = i + 1; j < n; j++)
  //   {
  //     if (a[i] % a[j] == 0)
  //     {
  //       ans--;
  //       break;
  //     }
  //   }
  // }
  cout << ans;
}


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

int main(){
	ll n,ma;
	
	cin>>n>>ma;
	ll ans=0;
	for(int i=1;i<n;i++){
		ll x;
		cin>>x;
		if(ma>x)ans+=ma-x;
		ma=max(ma,x);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;

	int a = 0;
	int z = min(n, m);
	rep(i, max(n,m)) {
		a += z;
		 z*= 10;
	}
	cout <<a;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod (1e9+7)
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
signed main()
{
    crap;
    int a,b;
    cin>>a>>b;
    if((a%2==0 && b%2==0) || (a&1 && b&1))
    cout<<(a+b)/2<<endl;
    else
    cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mem( f, x ) memset( f, x, sizeof( f ) )
#define INF 0x3f3f3f3f
#define pii pair<int, int>
#define mk( x, y ) make_pair(x, y)
#define pk push_back
#define fi first
#define se second
using namespace std;
const int N = 1e5 + 50;
const int M = 2e5 + 50;
int m, n;
int head[N], cnt;
ll dis[N];
int pre[N];

struct eg{
    int to, pre;
    eg():to(0), pre(0){}
    eg( int tt, int pp ):to(tt), pre(pp){}
}e[2*M];

struct node{
    int x, dis;
    node( ):x(0), dis(0){}
    node( int xx, int dd ): x(xx), dis(dd){}
    friend bool operator<( node p1, node p2 ){
        return p1.dis > p2.dis;
    }
};

void add( int x, int y ){
    e[++cnt] = eg( y, head[x] );
    head[x] = cnt;
}

void init( ){
    for( int i = 0; i <= n; i++ )
        head[i] = pre[i] = 0, dis[i] = INF;
    cnt = 0;
}

void BFS( ){
    dis[1] = 0;
    priority_queue<node> pq;
    node cur, nxt;
    cur = node( 1, 0 );
    pq.push(cur);
    while( !pq.empty()){
        cur = pq.top();
        pq.pop();
        int x = cur.x;
        for( int i = head[x]; i; i = e[i].pre ){
            int to = e[i].to;
            nxt = node( to, cur.dis+1 );
            if( nxt.dis < dis[to] ){
                pre[to] = x;
                dis[to] = nxt.dis;
                pq.push(nxt);
            }
        }
    }
}

int main( ){
    while( scanf( "%d %d", &n, &m ) != EOF ){
        init( );
        int x, y;
        for( int i = 0; i < m; i++ ){
            scanf( "%d %d", &x, &y );
            add( x, y );
            add( y, x );
        }
        BFS();
        bool flag = 0;
        for( int i = 1; i <= n; i++ ){
            if( dis[i] >= INF ){
                flag = 1;
                break;
            }
        }
        if( flag ){
            printf( "No\n" );
            continue;
        }
        printf( "Yes\n" );
        for( int i = 2; i <= n; i++ )
            printf( "%d\n", pre[i] );
    }
    return 0;
}


Measured memory_bytes: 8896
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]


    N = II()
    count = 0
    maxcount = 0
    H = LMIIS()
    pre = H[0]
    
    for h in H[1:]:
        if h <= pre :
            count += 1
        else:
            maxcount = max(maxcount,count)
            count = 0
        pre = h
    maxcount = max(maxcount,count)
    print(maxcount)


if __name__ == '__main__':
    main()

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

signed main(){
  int N,K; cin>>N>>K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    A[i]--;
  }
  vector<int> G(0);
  vector<int> kai(N,0);
  int now=0,fin=0,saki=0,sta=0;
  G.push_back(0);
  while(G.size()<=N){
    G.push_back(A[now]);
    if(kai[A[now]]==0){
      kai[A[now]]++;
      now=A[now];
      continue;
    }else{
      fin=G.size();
      saki=A[now];
      G.erase(G.end()-1);
      for(int i=0;i<fin-1;i++){
        if(G[i]==saki){
          sta=i;
          break;
        }
      }
      fin-=1;
      break;
    }
  }
  int ans;
  if(K<fin)ans=G[K];
  else {
    int mod=fin-sta;
    ans=G[sta+(K-sta)%mod];
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 8492
n,q=map(int,input().split())
s=input()

l1=[]
l2=[0]
for i in range(n-1):
  if i==0:
    if s[i]=="A" and s[i+1]=="C":
      l1+=[1]
      l2+=[1]
    else:
      l1+=[0]
      l2+=[0]
  else:
    if s[i]=="A" and s[i+1]=="C":
      l1+=[1+l1[i-1]]
      l2+=[1+l2[i]]
    else:
      l1+=[0+l1[i-1]]
      l2+=[0+l2[i]]
      
for i in range(q):
  l,r=map(int,input().split())
  print(l2[r-1]-l2[l-1])

    

Measured memory_bytes: 11688
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <math.h>
#include <iomanip>
using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;

vector<int> P;
int N;

void solve() {
	cin >> N;
	P.resize(N + 1);
	for (int n = 1; n <= N; n++)cin >> P[n];
	int count = 0;
	for (int n = 1; n <= N; n++) {
		if (P[n] != n)count++;
	}
	if (count == 0 || count == 2)cout << "YES" << endl;
	else cout << "NO" << endl;
	return;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}*/
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 
 














int main()
{
     ll a;
     long double b;
     cin>>a>>b;
     ll res=(a*(round(b*100)));
     cout<<res/100;
}
























 
 
 
 
 

















Measured memory_bytes: 3732
import java.util.LinkedList;
import java.util.Scanner;

class Graph {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int u, v;
		for(i = 0; i < totalVertex; i ++) {
			u = in.nextInt();
			int degree = in.nextInt();
			for(j = 0; j < degree; j ++) {
				v = in.nextInt(); 
				adjMatrix[u][v] = 1;
				adjWeight[u][v] = in.nextInt();
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int[] Dijkstra(int s) {
		LinkedList<Integer> S = new LinkedList<Integer>();
		int[] dist = new int[totalVertex];
		for (int i = 0; i < totalVertex; i++) {
			dist[i] = Integer.MAX_VALUE;
		}
		dist[s] = 0;
		while (S.size() < totalVertex) {
			int v = getUnsettledNearest(dist);
			S.add(v);
			LinkedList<Integer> neighbors = getUnsettledNeighbors(v);
			for (int x : neighbors) {
				dist[x] = Math.min(dist[v] + getWeight(v,x), dist[x]);
			}
			ifSettled[v] = true;
		}
		return dist;
	}
}

public class Main {
	public static void main(String[] argv) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			System.out.println(i + " " + dist[i]);
		}
	}
}


Measured memory_bytes: 40272
// i_am_arin

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<string> vs;


#define f(i, a, n) for(ll i=a; i<(ll)n; i++)
#define f2(i, a, b) for(ll i=a; i<=(ll)b; i++)
#define PB push_back
#define FF first
#define SS second
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;

void solve(){
ll h,w;
cin>>h>>w;
vector<string> s(h);
f(i,0,h) cin>>s[i];
ll dp[h][w]={0};
dp[0][0]=1;
f(i,0,h){
	f(j,0,w){
		if(i==0&&j==0) continue;
		else if(i==0){
			if(s[i][j]=='.') dp[i][j]=dp[i][j-1]%MOD;
			else dp[i][j]=0;
		} 
		else if(j==0){
			if(s[i][j]=='.') dp[i][j]=dp[i-1][j]%MOD;
			else dp[i][j]=0;
		}
		else{
			if(s[i][j]=='.') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
			else dp[i][j]=0;
		}
		
	}
}
cout<<dp[h-1][w-1]%MOD<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
int a[55], b[55], c[55], d[55];
int n, m, q;
int A[10];

bool next() {
    A[n - 1]++;
    for (int i = n - 1; i >= 0 && A[i] > m; --i) {
        if (i == 0)
            return false;
        A[i-1]++;
        for (int j = i; j < n; ++j) A[j]=A[j-1];
    }
    return true;
}

int calc() {
    int res = 0;
    for (int i = 0; i < q; ++i) {
        if(A[b[i]]-A[a[i]]==c[i]) res+=d[i];
    }
    return res;
}


int main() {
    int mx=0;
    cin >> n >> m >> q;
    for (int i = 0; i < q; ++i) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;b[i]--;
    }
    for (int i = 0; i < n; ++i) A[i] = 1;
    A[n - 1] = 0;
    while (next()) {
        mx=max(calc(),mx);
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define REP(i, M) for (int i = 0; i < M; i++)
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  REP(i, n) {
    cin >> h.at(i);
  }
  int res = 0;
  REP(i, n) {
    if (h.at(i) >= k) {
      res++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 640
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const A = parseInt(args[0][0], 10)
	const B = parseInt(args[0][1], 10)
	const C = parseInt(args[0][2], 10)
	console.log(Math.max(0, C - (A - B)))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

unordered_map<long, pair<long, long> > pos;
unordered_map<long, vector<long> > cost;

void solve() {
  long H, W, D;
  cin >> H >> W >> D;
  rep (i, H) rep (j, W) {
    long A;
    cin >> A;
    pos[A] = make_pair(i+1, j+1);
  }
  for (long i = 1; i <= D; i++) {
    long current = 0;
    cost[i].push_back(current);
    for (long j = i+D; j <= H*W; j+=D) {
      auto foo = pos[j-D];
      auto bar = pos[j];
      current += abs(foo.first - bar.first) + abs(foo.second - bar.second);
      cost[i].push_back(current);
    }
  }
  long Q;
  cin >> Q;
  rep (i, Q) {
    long L, R;
    cin >> L >> R;
    long foo = L % D;
    if (foo == 0) foo = D;

    long l = (L - foo) / D;
    long r = (R - foo) / D;

    cout << cost[foo][r] - cost[foo][l] << endl;
  }
}

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


Measured memory_bytes: 13732