akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int A, B, C;;
    cin>>A>>B>>C;
    
    if(A==5 && B==5 && C==7){
        cout<<"YES"<<endl;
    }
    else if(A==5 && B==7 && C==5){
        cout<<"YES"<<endl;
    }
    else if(A==7 && B==5 && C==5){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define M 300004
#define endl "\n"
using namespace std;
int main()
{
   ll n;cin>>n;ll a[M],b[M],c[M];
   for(ll i=0;i<n;i++)
   {
       cin>>a[i]>>b[i]>>c[i];
   }
 ll aa[M],bb[M],cc[M];
 aa[0]=a[0];bb[0]=b[0];cc[0]=c[0];
 
 
  for(ll i=1;i<n;i++)
    {
        
        aa[i]=a[i]+max(bb[i-1],cc[i-1]);
          bb[i]=b[i]+max(aa[i-1],cc[i-1]);
            cc[i]=c[i]+max(bb[i-1],aa[i-1]);
        
        
        
    }
    cout<<max(aa[n-1],max(cc[n-1],bb[n-1]))<<endl;
    
    return 0;
}

Measured memory_bytes: 13312
n = int(input())
list_P = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if list_P[i] == i+1:
        a = list_P[i]
        b = list_P[i+1]
        list_P[i] = b
        list_P[i+1] = a
        ans += 1
if list_P[n-1] == n:
    ans += 1
print(ans)

Measured memory_bytes: 13880
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
void func(string s, char last){
    if(s.size()== n){
        cout << s << ln;
        return;
    }
    for(char c='a'; c <= last+1; c++){
        s.push_back(c);
        func(s, max(last, c));
        s.pop_back();
    }
}

int main() {
    cin >> n;
    func("a", 'a');
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int X; cin >> X;
    for (int i = 1; true; i++) {
        if (X * i % 360 == 0) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

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

        int n = sc.nextInt();
        int x = sc.nextInt();
        int donut = n;
        int min = 1000;
        int add = 0;

        int[] m = new int[n];
        for (int i = 0; i < n; i++) {
            m[i] = sc.nextInt();
            add += m[i];
            if (min > m[i]) {
                min = m[i];
            }
        }
        donut += (x - add) / min;

        System.out.println(donut);
    }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);


int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int main() {
	int n, r;
	cin >> n >> r;
	int ans = 0;
	if (n >= 10)ans = r;
	else ans = r + 100 * (10 - n);
	cout << ans << endl;
	return 0;
}


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

int main() {
    string S;
    cin >> S;
    for (int i=0; i<S.size()-1; i++) {
        if (S.at(i)==S.at(i+1)) {
            cout << "Bad\n";
            return 0;
        }
    }
    cout << "Good\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

// 四方向への移動ベクトル
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};

int main(){
  ll H , W , K; cin >> H >> W >> K;
  ll sx , sy , gx , gy; cin >> sx >> sy >> gx >> gy; sx--; sy--; gx--; gy--;
  vector<string> field(H);
  rep(i,H) cin >> field[i];

  // 各セルの最短距離 (訪れていないところは -1 としておく)
  vector<vector<int> > dist(H, vector<int>(W, INF));
  dist[sx][sy] = 0; // スタートを 0 に

  queue<P> que;
  que.pu(mp(sx, sy));
  while(!que.empty()){
    pair<ll, ll> current_pos = que.front(); // キューの先頭を見る (C++ ではこれをしても pop しない)
    ll x = current_pos.first;
    ll y = current_pos.second;
    que.pop(); // キューから pop を忘れずに

    // 隣接頂点を探索
    for (ll direction = 0; direction < 4; ++direction) {
      repn(j , K){
        ll next_x = x + j * dx[direction];
        ll next_y = y + j * dy[direction];
        if (next_x < 0 || next_x >= H || next_y < 0 || next_y >= W) break; // 場外アウトならダメ
        if (field[next_x][next_y] == '@') break; // 壁はダメ
        if(dist[next_x][next_y] <= dist[x][y]) break;

        // まだ見ていない頂点なら push
        if (dist[next_x][next_y] == INF){
            que.push(make_pair(next_x, next_y));
            dist[next_x][next_y] = dist[x][y] + 1; // (next_x, next_y) の距離も更新
        }
      }
    }
  }
  /*
  rep(i,H){
    rep(j,W){
      cout << dist[i][j] << " ";
    }
    cout << endl;
  }
  */
  if(dist[gx][gy] == INF) cout << -1 << endl;
  else cout << dist[gx][gy] << endl;
}


Measured memory_bytes: 12132
#include<bits/stdc++.h>
using namespace std;
const int N=100000+10;
const int M=100000+10;
typedef long long ll;
int n,m,T;
int x[M],y[M],pr[M];
void pri(){
	for(int i=1;i<=m;i++)
		cout<<(pr[i]?'^':'v');
}
namespace uni{
	bitset<N> b[N],f;
	int g[N];
	void work(){
		for(int i=1;i<=n;i++)
			b[i][i]=1;
		for(int i=m;i>=1;i--){
			f=(b[x[i]]|b[y[i]]);
			b[x[i]]=b[y[i]]=f;
		}
		f.set();
		for(int i=1;i<=n;i++)
			f&=b[i];
		int ans=0;
		for(int i=1;i<=n;i++)
			if(f[i]){
				ans=i;
				break;
			}
		if(!ans)
			puts("-1");
		else{
			g[ans]=1;
			for(int i=m;i>=1;i--){
				if(g[x[i]])
					g[y[i]]=1,pr[i]=1;
				else if(g[y[i]])
					g[x[i]]=1;
			}
			pri();
		}
	}
}
namespace nuni{
	int b[N],cnt[N];
	void work(){
		if(n==2)
			puts("-1");
		else{
			for(int i=1;i<=n;i++)
				b[i]=i,cnt[i]=1;
			for(int i=m;i>=1;i--){
				if(cnt[b[y[i]]]>1)
					pr[i]=1,cnt[b[y[i]]]--,cnt[b[x[i]]]++,b[y[i]]=b[x[i]];
				else
					cnt[b[y[i]]]++,cnt[b[x[i]]]--,b[x[i]]=b[y[i]];
			}
			pri();
		}
	}
}
int main(){
	cin>>n>>m>>T;
	for(int i=1;i<=m;i++)
		cin>>x[i]>>y[i];
	if(T==1)
		uni::work();
	else
		nuni::work();
	return 0;
}

Measured memory_bytes: 614656
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
aff = [0]*N

if sum(A) < sum(B):
    print(-1)
else:
    need = 0
    ans = 0
    for i in range(N):
        aff[i] = A[i] - B[i]
    
    aff = sorted(aff)
    affrev = aff[::-1]
    
    for i in range(N):
        if aff[i] < 0:
            ans += 1
            need -= aff[i]
        else:
            break
    
    j = 0
    while need > 0:
        need -= affrev[j]
        ans += 1
        j += 1
    
    print(ans)   

Measured memory_bytes: 19188
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    string s;
    cin >> s;
    int n = s.size();
    if (n == 1) {
        cout << "0" << endl;
        return 0;
    }
    
    int ans = 0;
    repeat_from(i, 1, n) {
        if( s[i-1] != s[i] ) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	var output = 0;
	for(var i = 0; i < N; i++){
		if(i % 2 == 0 && list[i] % 2 == 1){
			output++;
		}
	}
	myout(output);
}


Measured memory_bytes: 30292
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s[100];
  bool ans=true;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
    if(i>0){
      if(s[i-1][s[i-1].size()-1] != s[i][0]) ans=false;
      for(int j=0;j<i;j++){
	if(s[i]==s[j]) ans=false;
      }
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s == "SUN"){
    cout << "7" << endl;
  }else if(s == "MON"){
    cout << "6" << endl;
  }else if(s == "TUE"){
    cout << "5" << endl;
  }else if(s == "WED"){
    cout << "4" << endl;
  }else if(s == "THU"){
    cout << "3" << endl;
  }else if(s == "FRI"){
    cout << "2" << endl;
  }else{
    cout << "1" << endl;
  }
}
 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007


int main(){
    ll N, P; cin >> N >> P;
    if(N==1){
        cout << P << endl;
        return 0;
    }

    ll ans = 1;
    for(ll i=1; pow(i, N)<=P; i++){
        if(P%(ll)pow(i,N)==0) ans = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Int long long
#define N 102
#define N2 100100

Int a[N];
Int dp[N][N2];
Int sum[N];
Int w[N],v[N];

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,W;
    for(int i = 0;i<=n;i++)for(int j = 1;j<=100000;j++)dp[i][j]=(1<<30);
    cin>>n>>W;
    for(int i = 1;i<=n;i++)cin>>w[i]>>v[i];
    for(int i = 1;i<=n;i++)
    {
        for(int j = 1;j<=100000;j++)
        {
            if(j<=v[i]){dp[i][j]=min(w[i],dp[i-1][j]);continue;}
            dp[i][j]=min((dp[i-1][j-v[i]]+w[i]),dp[i-1][j]);

        }
    }
    Int t = 0;
    for(Int i = 1;i<=100000;i++)if(dp[n][i]<=W)t=max(t,i);
    cout<<t<<endl;
}


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

long long N, M;

// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
	  // 最初は全てのデータiがグループiに存在するものとして初期化
	  for(int i = 0; i < n; i++){
		  par[i] = i;
	  }
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};


int main(){
	cin >> N >> M;
	UnionFind uf(N);
	for(long long i = 0; i < M; i++){
		long long x, y, z;
		cin >> x >> y >> z; x--;y--;
		uf.unite(x, y);
	}
	set<long long> unionset;
	for(long long i = 0; i < N; i++){
		unionset.insert(uf.find(i));
	}
	cout << unionset.size() << endl;
}



Measured memory_bytes: 5760
#include <iostream>

int main()
{
    int a,b,c;
    std::cin>>a>>b>>c;
    if(a<=b&&b<=c)
    std::cout<<a<<" "<<b<<" "<<c<<std::endl;
    else if(a<=c&&c<=b)
    std::cout<<a<<" "<<c<<" "<<b<<std::endl;
    else if(a>=b&&a<=c)
    std::cout<<b<<" "<<a<<" "<<c<<std::endl;
    else if(a>=c&&b<=c)
    std::cout<<b<<" "<<c<<" "<<a<<std::endl;
    else if(c<=b&&b<=a)
    std::cout<<c<<" "<<b<<" "<<a<<std::endl;
    else std::cout<<c<<" "<<a<<" "<<b<<std::endl;
   return 0;
}


Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;


int main() {
    ll n, m; cin >> n >> m;
    vector<vector<ll>> g(n);
    vector<ll> dist(n);
    vector<ll> num(n);
    queue<ll> q;
    rep(i, m) {
        ll a, b; cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    q.push(0);
    while(!q.empty()) {
        ll now = q.front();
        q.pop();
        for(ll x : g[now]) {
            if(dist[x] != 0) continue;
            dist[x] = dist[now] + 1;
            num[x] = now;
            q.push(x);
        }
    }
    bool fl = 0;
    Rep(i, 1, n) if(dist[i] == 0) fl = 1;
    if(fl) {cout << "No" << endl; return 0;}
    cout << "Yes" << endl;
    Rep(i, 1, n) cout << num[i] + 1<< endl;
}


Measured memory_bytes: 13624
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>
#include <list>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using Graph = vector<vector<bool>>;
int N, M;
vector<bool> seen;
void dfs(const Graph &G, int v) {
	seen[v] = true;
	for (int next = 0; next < N; next++) {
		if (G[v][next] == false)continue;
		if (seen[next] == true)continue;
		dfs(G, next);
	}
}


int main(void)
{
	cin >> N >> M;
	Graph G(N, vector<bool>(N, false));
	vector<int> a(M), b(M);
	seen.resize(N);
	rep(i, 0, M) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		G[a[i]][b[i]] = true;
		G[b[i]][a[i]] = true;
	}
	int ans = 0;
	rep(i, 0, M) {
		G[a[i]][b[i]] = false;
		G[b[i]][a[i]] = false;
		seen.assign(N, false);
		dfs(G, 0);

		bool bridge = false;
		rep(v, 0, N) {
			if (seen[v] == false)bridge = true;
		}
		if (bridge)ans++;

		G[a[i]][b[i]] = true;
		G[b[i]][a[i]] = true;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from sys import stdin
input = stdin.readline

sx,sy,tx,ty=map(int,input().split())
a=["U"]*(ty-sy)+["R"]*(tx-sx)
b=["D"]*(ty-sy)+["L"]*(tx-sx)
c=["L"]+["U"]*(ty-sy+1)+["R"]*(tx-sx+1)+["D"]
d=["R"]+["D"]*(ty-sy+1)+["L"]*(tx-sx+1)+["U"]
ans=a+b+c+d
print("".join(ans))


Measured memory_bytes: 3444
import sys
import math
sys.setrecursionlimit(10**6)


def main(input, print):
    a, b, h, m = map(int, input().split())
    ar = (h*30+(m*0.5)) * (math.pi/180)
    ax = -a*math.sin(ar)
    ay = a*math.cos(ar)
    br = m*6 * (math.pi/180)
    bx = -b*math.sin(br)
    by = b*math.cos(br)
    print(math.sqrt((bx-ax)**2+(by-ay)**2))


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 62692
#include <iostream>
using namespace std;
typedef long long ll;

const ll INF = 100000000000000000;

ll dp[200005][3];

int main()
{
    int n;
    cin >> n;
    int a[200005];
    for(int i = 0; i < n; i++) cin >> a[i];
    if(n == 2){
        cout << max(a[0], a[1]) << endl;
        return 0;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < 3; j++) dp[i][j] = -INF;
    }
    dp[1][0] = a[0];
    dp[2][1] = a[1];
    dp[3][2] = a[2];
    for(int i = 1; i <= n; i++){
        if(i >= 2){
            for(int j = 0; j < 3; j++){
                dp[i][j] = max(dp[i][j], dp[i - 2][j] + a[i - 1]);
            }
        }
        if(i >= 3){
            for(int j = 1; j < 3; j++){
                dp[i][j] = max(dp[i][j], dp[i - 3][j - 1] + a[i - 1]);
            }
        }
        if(i >= 4) dp[i][2] = max(dp[i][2], dp[i - 4][0] + a[i - 1]);
    }
    if(n % 2) cout << max(dp[n - 2][0], max(dp[n - 1][1], dp[n][2])) << endl;
    else cout << max(dp[n - 1][0], dp[n][1]) << endl;
}


Measured memory_bytes: 9100
from bisect import bisect_left as bisect

a, b, q = [int(i) for i in input().split()]
S = [int(input()) for i in range(a)]
T = [int(input()) for i in range(b)]
X = [int(input()) for i in range(q)]

for x in X:
    s_i = bisect(S, x)
    t_i = bisect(T, x)
    min_s = min(abs(x - S[max(0, s_i - 1)]), abs(x - S[min(a - 1, s_i)]))
    min_t = min(abs(x - T[max(0, t_i - 1)]), abs(x - T[min(b - 1, t_i)]))
    ans = min_s + min_t + min(min_s, min_t)
    if s_i > 0 and t_i > 0:
        ans = min(ans, abs(x - min(S[s_i - 1], T[t_i - 1])))
    if s_i < a and t_i < b:
        ans = min(ans, abs(x - max(S[s_i], T[t_i])))
    
    print(ans)

Measured memory_bytes: 16156
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
map<int,int>mp;
main()
{
    int ans;
    for(int i=1;i<=5;i++)
    {
        int p;
        cin>>p;
        if(p==0)
            ans=i;
    }
    cout<<ans;
}



Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int dp[105][50005],add[50005],len[50005],t;
int k,mid,n,ans,mod=1e9+7;
void solve(){
    int g;
    FOR(i,2,n){
        g=0;
        FOR(j,1,t)g=(g+dp[i-1][j])%mod;
        FOR(j,1,t)dp[i][j]=g;
        FOR(j,1,mid)add[j]=(add[j-1]+dp[i-2][j])%mod;
        g=0;
        for(int j=mid;j>=1;j--){
            g=(g+add[j]*len[j])%mod;
            dp[i][j]=(dp[i][j]+g)%mod;
        }
    }
    FOR(i,1,t)ans=(ans+dp[n][i])%mod;
    FOR(i,1,mid){
        add[i]=(add[i-1]+dp[n-1][i])%mod;
        ans=(ans+add[i]*len[i])%mod;
    }
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>k>>n;
    int g;t=sqrt(k);
    mid=k/(t+1);
    int l,r;
    l=1;
    while(l<=k){
        r=k/(k/l);
        if(k/l<=mid){
            len[k/l]=r-l+1;
        }
        l=r+1;
    }
    FOR(i,1,t)dp[1][i]=1;
    solve();
    FILL(dp,0);
    g=0;n--;
    for(int i=mid;i>=1;i--){
        g=(g+len[i])%mod;
        dp[1][i]=g;
    }
    solve();
    cout<<ans;
	RE 0;
}



Measured memory_bytes: 41728
#include <stdio.h>

int n, l[200];

int main() {
	scanf("%d", &n);
	for(int i = 0; i < 2 * n; i++) { scanf("%d", &l[i]); }
	
	for(int i = 0; i < 2 * n; i++) { int min = 2 * n - 1;
	for(int j = 2 * n - 1; j >= i; j--) {
		if(l[j] < l[min]) { min = j; }
	} int temp = l[i]; l[i] = l[min]; l[min] = temp;
	}
	
	int ans = 0;
	for(int i = 0; i < n; i++) { ans += l[2 * i]; }
	
	printf("%d\n", ans);
	
	return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e3 + 5;

int v[MAXN];
pii sorted[MAXN];

vi tmp1, tmp2;

int used[MAXN];

vector<pii> segs;

void solve(){
	int n, k, q;
	scanf("%d%d%d", &n, &k, &q);
	REP(i, 0, n){
		scanf("%d", &v[i]);
		sorted[i] = mp(v[i], i);
	}
	sort(sorted, sorted + n);
	used[n] = 1;
	int ans = INF;
	REP(i, 0, n){
		tmp1.clear();
		tmp2.clear();
		REPN(j, 0, n){
			if (!used[j]){
				tmp1.pb(v[j]);
			} else {
				SORT(tmp1);
				int cnt = max(0, SZ(tmp1) - (k - 1));
				REP(k, 0, cnt){
					tmp2.pb(tmp1[k]);
				}
				tmp1.clear();
			}
		}
		if (SZ(tmp2) < q){
			break;
		}
		SORT(tmp2);
		ans = min(ans, tmp2[q - 1] - tmp2[0]);
		
		used[sorted[i]._2] = 1;
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ar := make([]int, n)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	t := ar[0] - 1
	for _, v := range ar {
		if t == v {
			continue
		}
		if t < v {
			t = v - 1
			continue
		}
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5504
#include<stdio.h>

int main() {
  int a,b;
  scanf("%d%d",&a,&b);
 
  int d = a/b;
  int r = a%b;
  double f = 1.0000*a/b;
  
  printf("%d %d %.5lf\n",d,r,f);
}


Measured memory_bytes: 2740
# -*- coding: utf-8 -*-

n = int(input())
s = str(input())
new = []

ntr = n % 26

for p in range(len(s)):
    k = ord(s[p]) + ntr
    if k > 90:
        k = k - 90 + 64
    new.append(chr(k))

x = "".join(new)
print(x)


Measured memory_bytes: 9216
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    int n, x[1000], y[1000];
    long double Manhattan = 0, Euclidean = 0, Minkowski_p3 = 0, Chebyshev = 0;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> x[i];
    for(int i = 0; i < n; i++) cin >> y[i];

    for(int i = 0; i < n; i++){
        Manhattan += abs(x[i] - y[i]);
        Euclidean += pow(x[i] - y[i], 2);
        Minkowski_p3 += pow(abs(x[i] - y[i]), 3);
        if(abs(x[i] - y[i]) > Chebyshev) Chebyshev = abs(x[i] - y[i]);
    }
    Euclidean = sqrt(Euclidean);
    Minkowski_p3 = pow(Minkowski_p3, 1.0/3.0);

    cout << fixed << setprecision(8);
    cout << Manhattan << endl << Euclidean << endl << Minkowski_p3 << endl << Chebyshev << endl;
    return 0;
}


Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
vector<long long> v;
int main(){
    string s; cin >> s;
    long long ans = 0, n = 1;
    for (int i = 0; i < s.size(); i++)
    {
        v.push_back(n);
        n *= 10;
        n %= 2019;
    }
    for (int i = 0; i < s.size(); i++){
        v[i] *= (s[s.size() - i - 1] - '0');
        v[i] %= 2019;
    }
    
    map<int, int> m;
    long long sum = 0;
    m[0]++;
    for (int i = 0; i < s.size(); i++)
    {
        sum += v[i];
        sum %= 2019;
        ans += m[sum];
        m[sum]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5508
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }

const int MAXN = 100005;

ll d[MAXN][3];
ll A[MAXN];

ll Ans;
int N;

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 1; i <= N; i++) cin >> A[i];
	N++;

	for(int i = 0; i <= N; i++)
		fill(d[i], d[i]+3, -INFLL);
	d[0][0] = 0;
	
	for(int i = 1; i <= N; i++) {
		d[i][0] = max({d[i-1][0], d[i-1][1], d[i-1][2] + 1}) + A[i]/2;
		if(A[i]&1) upmax(d[i][0], d[i-1][1] + 1 + A[i]/2);

		if(A[i] < 1) continue; A[i]--;
		d[i][1] = max({d[i-1][0], d[i-1][1], d[i-1][2] + 1}) + A[i]/2;
		if(A[i]&1) upmax(d[i][1], d[i-1][1] + 1 + A[i]/2);

		if(A[i] < 1) continue; A[i]--;
		d[i][2] = max({d[i-1][0], d[i-1][1], d[i-1][2] + 1}) + A[i]/2;
		if(A[i]&1) upmax(d[i][2], d[i-1][1] + 1 + A[i]/2);
	}

	cout << max({d[N][0], d[N][1], d[N][2] + 1}) << endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());

		String[] temp1 = scanner.nextLine().split(" ");
		int t = Integer.parseInt(temp1[0]);
		int a = Integer.parseInt(temp1[1]);

		String[] temp2 = scanner.nextLine().split(" ");
		double flag =  Math.abs(a - (t - Integer.parseInt(temp2[0]) * 0.006));
		double tmp = 0;
		int ans = 1;

		for(int i = 2; i < n + 1; i++) {

			tmp = Math.abs(a - (t - Integer.parseInt(temp2[i - 1]) * 0.006));


			if( flag > tmp) {
				flag = tmp;
				ans = i;
			}

		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	int n;
	cin>>n;
	bool flag=false;
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			if(i*j==n)
			{
				flag=true;
				break;
			}
		}
		if(flag)
		{
			break;
		}
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=1e9+7;
const ll ms=1e5+5;
const ll inf=1e9+9;


int main()
{
    idfc;

    string s;
    cin>>s;

    int a=0;

    for(char e:s)
    {
        a+=(e-48);
    }
    if(a%9)cout<<"No";
    else cout<<"Yes";

    return 0;
}

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

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if(a >= k) cout << a - k << " " << b << endl;
  else if(a + b >= k) cout << 0 << " " << a + b - k << endl;
  else cout << 0 << " " << 0 << endl;
} 

Measured memory_bytes: 256
import java.util.*; import java.io.*;
public class Main {
 public static void main(String[] args) throws Exception {
  Scanner file = new Scanner(System.in);
  int n = file.nextInt();
  char[] a = file.next().toCharArray();
  char[] b = file.next().toCharArray();
  char[] c = new char[n * 2];
  for (int i = 0; i < n; i++) {
   c[i * 2] = a[i];
   c[i * 2 + 1] = b[i];
  }
  System.out.println(c);
}
}


Measured memory_bytes: 22612
#include<stdio.h>
#include<math.h>
#define MAX 1000000
int main(){
int n;
int i,j,k,l;
int count;
int S[MAX];
int T[MAX];

for(i=0;i<MAX;i++){S[i]=1;}



S[0]=0;
S[1]=0;
for(i=2;i*i<MAX;i++){
 if(S[i]==1){ for(j=i*2;j<MAX;j+=i){S[j]=0;} }
}

T[0]=0;
T[1]=0;
for(i=2;i<MAX;i++){ T[i]=T[i-1]+S[i];}


while(scanf("%d",&n)!=EOF){
 printf("%d\n",T[n]);
}







return 0;
}

Measured memory_bytes: 9536
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll a=in(),b=in(),h=in()%12,m=in();
    cout<<fixed<<setprecision(20)<<sqrt(a*a+b*b-2*a*b*cos((60*h-11*m)*M_PI/360))<<endl;
}


Measured memory_bytes: 4228
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(;;) {
         int b=sc.nextInt()*5,r=sc.nextInt()*3,g=sc.nextInt(),c=sc.nextInt(),s=sc.nextInt(),t=sc.nextInt();
         if((b|r|g|c|s|t)==0) {
             break;
         }
         System.out.println(100+b+b*18+r+r*20+g*7+c*2-(t-s)*3);
        }
    }
}


Measured memory_bytes: 28520
import sys
input = sys.stdin.readline
def main():
    X = int(input())
    ans = [0] * 2

    for A in range(0, 1000):
        for B in range(0, 1000):
            if pow(A, 5) - pow(B, 5) == X:
                ans[0], ans[1] = A, B
                break
            if pow(A, 5) - pow(-B, 5) == X:
                ans[0], ans[1] = A, -B
                break
            if pow(-A, 5) - pow(B, 5) == X:
                ans[0], ans[1] = -A, B
                break
            if pow(-A, 5) - pow(-B, 5) == X:
                ans[0], ans[1] = -A, -B
                break
    print(ans[0], ans[1])
if __name__ == "__main__":
    main()

Measured memory_bytes: 67840
#include <iostream>
#include <string>
#include <numeric>


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

	int sum{};
	for(int i = 1; i <= N; ++i) {
		for(int j = 1; j <= N; ++j) {
			for(int k = 1; k <= N; ++k) {
				sum += std::gcd(std::gcd(i, j), k);
			}
		}
	}

	std::cout << sum << std::endl;
}

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

int main(){
  ll MOD=998244353;
  int n,s;
  cin>>n>>s;
  int vec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  ll dp[3050][3050]={};
  dp[0][0]=1;
  for(int i=0;i<n;i++){
    for(int j=0;j<=s;j++){
      dp[i+1][j]+=dp[i][j]*2;
      dp[i+1][j]%=MOD;
      if(j>=vec[i]){
        dp[i+1][j]+=dp[i][j-vec[i]];
        dp[i+1][j]%=MOD;
      }
    }
  }
  cout<<dp[n][s]<<endl;
}

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

int dp[110][10010];
int main(){
    int N, W; cin >> N >> W;
    vector<int> v(N);
    vector<int> w(N);
    rep(i,N) cin >> v[i] >> w[i];
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= W; j++){
            if(j < w[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 7032
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_s = sorted(a)
    cnt = 0
    for i in range(n):
        if a[i] != a_s[i]:
            cnt += 1
    if cnt == 2 or cnt == 0:
        print('YES')
    else:
        print('NO')
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import numpy as np

N, K, Q = map(int, input().split())
success_num = np.zeros(N)

for i in range(Q):
    success_num[int(input())-1] += 1
    
judge_score = success_num + K - Q
survive_list = []

for j in range(len(judge_score)):
    if judge_score[j] > 0:
        survive_list.append("Yes")
    else:
        survive_list.append("No")

for a in range(len(survive_list)):
    print(survive_list[a])


Measured memory_bytes: 15564
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            佛祖保佑       永无BUG
*/
#include<stdio.h>
#include<cstring>
#define re register
using namespace std;
const int maxn=5e5+5;
int nxt[maxn][27],ri[maxn][20];
char s[maxn];
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	int dlen=len+1,slen=len-1;
	for(re int i=0;i<=dlen;++i)
		for(re int j=0;j<=26;++j)
			nxt[i][j]=dlen;
	for(re int i=0;i<=dlen;++i)
		for(re int j=0;j<=19;++j)
			ri[i][j]=dlen;
	for(re int i=slen;i>=0;--i)
	{
		int x=s[i+1]-'a';
		nxt[i][x]=i+1;
		for(re int j=x+1;j<=26;++j)
			nxt[i][j]=nxt[nxt[i][j-1]][j-1];
		for(re int j=0;j<x;++j)
			nxt[i][j]=nxt[nxt[i][26]][j];	
	}
	for(re int j=0;j<=19;++j)
		for(re int i=slen;i>=0;--i)
			if(j==0) ri[i][j]=nxt[i][26];
			else ri[i][j]=ri[ri[i][j-1]][j-1];
	int q,l,r;
	scanf("%d",&q);
	while(q--)
	{
		scanf("%d%d",&l,&r);
		l--;
		for(re int j=19;j>=0;--j)
			if(ri[l][j]<=r) l=ri[l][j];
		if(l==r) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 92800
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 200000
#define VAL_MAX 1000000

int asc(const void *a1, const void *a2) {
    return *(int*)a1 - *(int*)a2;
}

int main(void) {
    int num = get_int();
    static int arr[NUM_MAX];
    fget_array(arr, num);
    qsort(arr, num, sizeof(int), asc);
    static char dp[VAL_MAX+1];
    memset(dp, 0x01, sizeof(char)*(VAL_MAX+1));
    int i, j;
    int prev = 0;
    for(i = 0; i < num; i++) {
        int val = arr[i];
        if(!dp[val]) continue;
        if(val == prev) {
            dp[val] = 0;
            continue;
        }
        prev = val;
        int ulimit = VAL_MAX/val;
        for(j = 2; j <= ulimit; j++) {
            dp[val*j] = 0;
        }
    }
    int cnt = 0;
    for(i = 0; i < num; i++) {
        cnt += dp[arr[i]];
    }
    printf("%d\n", cnt);
    return 0;
}

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

int main(){
  int n, story=1;
  cin >>n;
  vector<int> mochi(n);
  for(int i=0; i<n; i++)
    cin >>mochi[i];
  
  sort(mochi.begin(),mochi.end(),greater<int>());
  
  for(int i=0; i<n; i++){
    if(i && mochi[i]<mochi[i-1])
      story++;
  }
  cout<<story<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	if (N%2==1){
		cout<<"No"<<endl;
		return 0;
	}
	char s[100],s1[100],s2[100];
	cin>>s;
	memset(s1,'\0',100);
	memset(s2,'\0',100);
	memcpy(s1,s,N/2);
	memcpy(s2,s+N/2,N/2);
	if (!memcmp(s1,s2,N/2)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import copy
import math
from itertools import accumulate
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def floor(a, b): return -(-a // b)


def zz(): return list(map(int, sys.stdin.readline().split()))


def z(): return int(sys.stdin.readline())


def S(): return sys.stdin.readline()[:-1]


def C(line): return [sys.stdin.readline() for _ in range(line)]


def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True


N, M = zz()
next1, next2, next3, next4, next5, next6, next7, next8 = 0, 0, 0, 0, 0, 0, 0, 0
if (N == 1 and M == 1):
    print(1)
    exit()
elif (N == 1 or M == 1):
    next1 = 2
    next2 = (N*M)-2
elif (M == 2 or N == 2):
    next3 = 4
    next5 = (N*M)-4

else:
    next1 = 0
    next2 = 0
    next3 = 4
    next4 = 0
    next5 = (M-2)*2 + (N-2)*2
    next6 = 0
    next8 = (N-2)*(M-2)

# print(next1+next2 + next3 + next4 + next5 + next6 + next7+next8, N*M)
print(next2 + next4 + next6 + next8)


Measured memory_bytes: 67952
h, w = map(int, input().split())
m = [list(input()) for _ in range(h)]

row_idx = []
for idx, row in enumerate(m):
    if not row.count('#'):
        row_idx.append(idx)

col_idx = []
for idx, col in enumerate(zip(*m)):
    if not col.count('#'):
        col_idx.append(idx)

for i, row in enumerate(m):
    if i in row_idx:
        continue
    else:
        for idx in col_idx[::-1]:
            row.pop(idx)
        print(*row, sep='')


Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vll vector<ll>
#define M 200011
#define MOD 1000000007

ll h[M],a[M];
ll tr[4*M];
void update(ll n,ll s,ll e,ll idx,ll val){
	if(s>e)return ;
	if(s==e){
		tr[n]=val;return ;
	}ll m=(s+e)/2;
	if(idx<=m&&idx>=s)update(2*n,s,m,idx,val);
	else update(2*n+1,m+1,e,idx,val);
	tr[n]=max(tr[2*n],tr[2*n+1]);
}
ll query(ll n,ll s,ll e,ll l,ll r){
	if(s>e||l>e||s>r)return 0;
	if(s>=l&&e<=r)return tr[n];
	ll m=(s+e)/2;
	return max(query(2*n,s,m,l,r),query(2*n+1,m+1,e,l,r));
}

int main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t,i,j,m,x,y,n,z,p,k,T;string s2,s3;x=1;
	cin>>n;
	for(i=1;i<=n;++i)cin>>h[i];
	for(i=1;i<=n;++i)cin>>a[i];
	for(i=1;i<=n;++i){
		ll mx=query(1,1,M-1,1,h[i]-1);
		ll wo=query(1,1,M-1,h[i],h[i]);
		if(mx+a[i]>wo)update(1,1,M-1,h[i],mx+a[i]);
	}
	cout<<query(1,1,M-1,1,M-1);















	
	return 0;
}

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

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

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

#define mst(x, a) memset(x, a, sizeof(x))
#define all(a) begin(a), end(a)
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 1e9 + 7;

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

int N;
vector<int> A;
map<int, int> cnt;
int maxV = INT_MIN;
int minV = INT_MAX;

bool check() {
  if (minV != (maxV + 1) / 2) return false;
  if (minV * 2 == maxV) {
    if (cnt[minV] != 1) return false;
  } else {
    if (cnt[minV] != 2) return false;
  }
  rep(i, minV + 1, maxV + 1) {
    if (cnt[i] < 2) return false;
  }
  return true;
}

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

  cin >> N;
  A.resize(N);
  rep(i, 0, N) {
    cin >> A[i];
    cnt[A[i]]++;
    chmax(maxV, A[i]);
    chmin(minV, A[i]);
  }
  dbg(cnt);
  puts(check() ? "Possible" : "Impossible");
}

Measured memory_bytes: 256
import sys
S = list(input())
K = int(input())
S = [int(i) for i in S]
count = 0
for i in range(K):
    if S[i] is not 1:
        print(S[i])
        sys.exit()
    else:
        count+= 1
if count == K:
    print(1)

Measured memory_bytes: 3060
n = int(input())
ans = -(10**99)
l = []
for _ in range(n):
    x = int(input())
    l.append(x)
mini = l[0]
for i in range(1, n):
    t = l[i] - mini
    if t > ans:
        ans = t

    if mini > l[i]:
        mini = l[i]


print(ans)



Measured memory_bytes: 13596
#include<stdio.h>

int main(void){
    int a=0;
    int b=0;
    int sum=-999;
    int temp=0;
    scanf("%d %d",&a,&b);
    temp=a+b;
    if(temp>sum){
        sum=temp;
    }
     temp=a-b;
    if(temp>sum){
        sum=temp;
    }
    temp=a*b;
    if(temp>sum){
        sum=temp;
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
// デバッグ実行：Ctrl+F5

using System;

class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        String[] words = line.Split(' ');
        int N = int.Parse(line);

        if ( N == 1)
        {
            Console.WriteLine("Hello World");
        }
        else
        {
            line = Console.ReadLine();
            int A = int.Parse(line);
            line = Console.ReadLine();
            int B = int.Parse(line);
            Console.WriteLine(A+B);
        }
    }
}

Measured memory_bytes: 13140
import java.math.BigInteger;
import java.util.*;

public class Main {
	double EPS = 10.e-08;
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String s = sc.next();
			if(s.charAt(0) == s.charAt(1) || s.charAt(1) == s.charAt(2) || s.charAt(2) == s.charAt(3)){
				System.out.println("Bad");
			}
			else{
				System.out.println("Good");
			}
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 21844