akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//typedef
using ll = long long;

//Loop
#define REP(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define RREP(i,a,b) for(ll (i)=(a);(i)>=(b);(i)--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)

int main(void){
    string t;
    cin>>t;

    rep(i,t.length()){
        if(t[i]=='P'){
            if(i<t.length()&&t[i+1]=='?'){
                t[i+1]='D';
            }
        }
        if(t[i]=='?'){
            t[i]='D';
        }

    }

    cout<<t<<endl;
    
    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  long long n, a;
  cin >> n;
  a = 1;
  for (int i = 1; i <= n; i++) {
    a *= i;
    a = a % 1000000007;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
import math

n = int(input())
s = sorted(["".join(sorted(input())) for i in range(n)])
a = 0
b = []
for i in range(n-1):
  if s[i]==s[i+1]:
    a += 1
  else:
    a = 0
  b.append(a)
print(sum(b))

Measured memory_bytes: 14144
--https://www.lua.org/pil/11.4.html
local List = {}
function List.new ()
  return {first = 0, last = -1}
end

function List.pushleft (list, value)
  local first = list.first - 1
  list.first = first
  list[first] = value
end

function List.pushright (list, value)
  local last = list.last + 1
  list.last = last
  list[last] = value
end

function List.popleft (list)
  local first = list.first
  if first > list.last then return false end
  local value = list[first]
  list[first] = nil
  list.first = first + 1
  return value
end

function List.popright (list)
  local last = list.last
  if list.first > last then return false end
  local value = list[last]
  list[last] = nil
  list.last = last - 1
  return value
end

----------

local h,w=io.read("*n","*n","*l")
local maze={}
for i=1,h do
    local s=io.read()
    maze[i]={}
    for j=1,w do
        maze[i][j]=s:sub(j,j)
    end
end

local dx={1,0,-1,0}
local dy={0,1,0,-1}

local function bfs(x,y)
    local dist={}
    for i=1,h do
        dist[i]={}
        for j=1,w do
            dist[i][j]=-1
        end
    end
    local que=List.new()
    
    local result=0
    List.pushright(que,{x,y})
    dist[x][y]=0
    while true do
        local q=List.popleft(que)
        if not q then
            break
        end
        x,y=q[1],q[2]
        result=math.max(result,dist[x][y])
        for i=1,4 do
            local nx,ny=x+dx[i],y+dy[i]
            local checker=(nx<1 or nx>h or ny<1 or ny>w)
            if not checker and maze[nx][ny]~="#" and dist[nx][ny]==-1 then
                dist[nx][ny]=dist[x][y]+1
                List.pushright(que,{nx,ny})
            end
        end
    end

    return result
end

local result=0
for i=1,h do
    for j=1,w do
        if maze[i][j]~="#" then
            result=math.max(result,bfs(i,j))
        end
    end
end
print(result)

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\Users\Joeon\Desktop\IN.txt", "r", stdin);
//		freopen("C:\Users\Joeon\Desktop\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	cin>>n>>a>>b;
	hrp(i, a, b) if (!(i%n)) { cout<<"OK"<<endl; return 0;}
	cout<<"NG"<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

Measured memory_bytes: 3652
<?php
$ans = 0;

fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%d %d", $D, $X);
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d", $A[$i]);
    $num = floor(($D - 1) / $A[$i]) + 1;
    // echo $num . "\n";
    $ans += $num;
}
$ans += $X;

echo $ans . "\n";


Measured memory_bytes: 4728
n = gets.to_i
h = gets.split(' ').map(&:to_i)
count = 0
max_num = 0
(n-1).times do |a|
  	#一段目からの最大の高さの階段を取得する
    if h[a] > max_num
        max_num = h[a]
    end
    #次の階段の方が最大の高さの階段より二段以上低い場合、単調非減少はできない
    if h[a+1] - max_num <= -2
        puts 'No'   
        exit
    # 次の階段の方が一段低い場合、今の段差を一段下げれば単調非減少になる可能性はある。
    # 配列の中で2回以上一段低い場所がある場合は、単調非減少にならない。
    elsif h[a+1] - max_num >= -1 
        next
    end
end

puts 'Yes'

Measured memory_bytes: 10116
h, w = gets.chomp.split(' ').map { |e| e.to_i + 4 }
c = gets.chomp.split(' ').map { |e| e.to_i + 1 }
d = gets.chomp.split(' ').map { |e| e.to_i + 1 }
s = h.times.map { |i| 2 <= i && i < h - 2 ? "###{gets.chomp}##" : '#' * w }

DS = (-2..2).to_a.product((-2..2).to_a).select { |i, j| i.abs + j.abs >= 2 }

co = h.times.map { w.times.map { -1 } }
v = h.times.map { |i| w.times.map { |j| s[i][j] == '#' } }

qa = [c]
v[c[0]][c[1]] = true

b = 0
while !(qa.empty?)
  qb = []

  while !(qa.empty?)
    y, x = qa.shift

    co[y][x] = b
    qb.push([y, x])

    [[-1, 0], [0, 1], [1, 0], [0, -1]].each do |dy, dx|
      next if v[y + dy][x + dx]
      qa.push([y + dy, x + dx])
      qb.push([y + dy, x + dx])
      v[y + dy][x + dx] = true
    end
  end

  qb.each do |y, x|
    DS.each do |dy, dx|
      next if v[y + dy][x + dx]
      qa.push([y + dy, x + dx])
      v[y + dy][x + dx] = true
    end
  end

  b += 1
end

puts co[d[0]][d[1]]


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

using namespace std;

#define MAX_N 105
int N;
LL W;
LL w[MAX_N], v[MAX_N];

LL dp[MAX_N][MAX_N][MAX_N*5];

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

  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_N; j++) {
      for (int k = 0; k < MAX_N*5; k++) {
        dp[i][j][k] = -1;
      }
    }
  }

  dp[0][0][0] = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < MAX_N; j++) {
      for (int k = 0; k < MAX_N*5; k++) {
        if(dp[i][j][k] == -1){
          continue;
        }

        dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]);
        if(j*w[0] + k + w[i] <= W){
          dp[i+1][j+1][k + (w[i] - w[0])] = max(dp[i+1][j+1][k + (w[i] - w[0])], dp[i][j][k] + v[i]);
        }
      }
    }
  }

  LL ans = 0;
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_N*5; j++) {
      ans = max(ans, dp[N][i][j]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 45568
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=998244353;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

void solve(){
	int n;
	cin>>n;
	vi a(n),b(n);
	cin>>a>>b;
	vector<int>tmp;
	for(int i=0;i<n;i++){
		tmp.pb(i+1);
	}
	int cnt=0;
	int l=0,r=0;
	do{
		cnt++;
		if(tmp==a){
			l=cnt;
		}
		if(tmp==b){
			r=cnt;
		}
	}while(next_permutation(all(tmp)));
	cout<<abs(l-r);
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 256
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
# import math
# mod = 10**9 + 7

# n = int(input())
# a = list(map(int, input().split()))
# n = int(input())
a,b = map(int,input().split())
ans = -1
if 1<=a<=9 and 1<=b<=9:
    ans = a*b

print(ans)

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;


signed main() {
  i64 n;
  cin >> n;
  vector<i64> A(n);
  cin >> A;
  vector<i64> B(n);
  set<i64> C;
  for (i64 i = n; i >= 1; --i) {
    i64 t = 0;
    for (i64 j = 2; i * j <= n; ++j) {
      t ^= B[i * j - 1];
    }
    t ^= A[i - 1];
    B[i - 1] = t;
    if (t) {
      C.insert(i);
    }
  }
  cout << C.size() << endl;
  for (i64 c : C) {
    cout << c << " ";
  }
}


Measured memory_bytes: 9984
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>

using namespace std;

int N, M;
char a[50][50], b[50][50];

bool match(int x, int y) {
	for (int i = x; i < x + M; i++) {
		for (int j = y; j < y + M; j++) {
			if (b[i - x][j - y] != a[i][j])
				return false;
		}
	}
	return true;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < M; j++) {
			cin >> b[i][j];
		}
	}
	for (int i = 0; i <= N - M; i++) {
		for (int j = 0; j <= N - M; j++) {
			if (match(i, j)) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define N  99999
#define f first 
#define em emplace
#define s second
using lint=long long int;

typedef pair<lint, lint> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

 
#define fori(n) for(int i=0; i<int(n); i++)
 
#define cins(s) string s; cin>>s;
#define cini(i) lint i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }
#define z 1000000007 


void solve(){
  
   cini(n); cini(w);
   vector<lint> dp(w+1,0);
   

   fori(n){

       lint weight; cin>>weight; lint value; cin>>value;

      for(lint j=w;j>=weight;j--){

          dp[j]=max(dp[j],dp[j-weight]+value);
      }
   }
   cout<<*max_element(dp.begin(),dp.end()) <<endl;
 }


   
    

 
 
int main()
{ 
  fast;

  



  solve();
 }

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
int main(int argc,char** argv){
  std::string S;
  std::cin >> S;
  if(S=="ARC") std::cout << "ABC" << std::endl;
  else         std::cout << "ARC" << std::endl;
  return 0;
}


Measured memory_bytes: 3548
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),f=1;
    int[] a=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
      if(a[i]%2==0){
        if(a[i]%3==0||a[i]%5==0){
        }else{
          f=0;
          break;
        }
      }
    }
    if(f==0){
      System.out.print("DENIED");
    }else{
      System.out.print("APPROVED");
    }
  }
}

Measured memory_bytes: 21972
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vector<int > c(n - 1), s(n - 1), f(n - 1);
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}

	for (int i = 0; i < n; i++) {
		int timer = 0;
		for (int j = i; j < n - 1; j++) {
			if (timer < s[j]) {
				timer = s[j];
			} else if (timer % f[j] == 0) {
				timer = timer;
			} else {
				timer = timer + f[j] - (timer % f[j]);
			}
			timer += c[j];
		}

		cout << timer << endl;
	}
	return 0;
}


Measured memory_bytes: 256
s=raw_input()
k=int(raw_input())
news=""
for i in xrange(len(s)):
    if s[i]=='a':
        news+="a"
        continue
    tmp=ord('z')-ord(s[i])+1
    if k-tmp>=0:
        news+="a"
        k-=tmp
    else:
        news+=s[i]
if k>0:
    news=news[0:len(s)-1]+chr((k+ord(news[-1])-ord('a'))%26+ord('a'))
print(news)

Measured memory_bytes: 3076
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        if (b % a == 0)
            System.out.println(a + b);
        else
            System.out.println(b - a);
    }
}

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

int  main()
{
	int n; cin >> n;
	vector<string> s(n);
	rep(i, n)
	{
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	long cnt = 0;
	set<string> st;
	unordered_map<string, long> mp;
	rep(i, n)
	{
		if (!mp.count(s[i]))
		{
			mp[s[i]]++;
		}
		else
		{
			cnt += mp[s[i]];
			mp[s[i]]++;
		}
	}
	cout << cnt << endl;
	return (0);
}


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

int main()
{	
	int a,b,c,x=1;
			
	cin >> a >> b >> c ;
		
	if (a == 5) {
		if (b == 5) {
			if (c == 7) {
				x = 0;
			}
		}
	}
	if (a == 5) {
		if (b == 7) {
			if (c == 5) {
				x = 0;
			}
		}
	}
	if (a == 7) {
		if (b == 5) {
			if (c == 5) {
				x = 0;
			}
		}
	}
	if(x==0){
		cout << "YES" << endl;
	}
	if(x==1){
		cout << "NO" << endl;
	}
					
    return 0;
}



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

int main(){
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  char t[Q], d[Q];
  for(int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  int llb = -1, lub = N;
  while(lub - llb > 1){
    int mid = (llb + lub)/2;
    int pos = mid;
    bool can = false;
    for(int i = 0; i < Q; i++){
      if(s[pos] == t[i] && d[i] == 'R') pos++;
      else if(s[pos] == t[i] && d[i] == 'L') pos--;
      if(pos == -1){
        can = true;
        break;
      }
      if(pos == N) break;
    }
    if(can) llb = mid;
    else lub = mid;
  }
  int rlb = -1, rub = N;
  while(rub - rlb > 1){
    int mid = (rlb + rub)/2;
    int pos = mid;
    bool can = false;
    for(int i = 0; i < Q; i++){
      if(s[pos] == t[i] && d[i] == 'R') pos++;
      else if(s[pos] == t[i] && d[i] == 'L') pos--;
      if(pos == N){
        can = true;
        break;
      }
      if(pos == -1) break;
    }
    if(can) rub = mid;
    else rlb = mid;
  }
  cout << max(0, rub - llb -1) << endl;
  return 0;
}


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

using namespace std;

int64_t calc(int n, const std::vector<std::array<bool, 10>>& fss,
             const std::vector<std::array<int, 11>>& pss) {
  int64_t ret = INT64_MIN;
  for (int o = 1; o < 1024; o++) {
    int64_t candidate = 0;
    for (int i = 0; i < n; i++) {
      const auto& fs = fss[i];
      const auto& ps = pss[i];
      int count = 0;
      for (int bit = 0; bit < 10; bit++) {
        int const bits = 1 << bit;
        if (!(o & bits) || !fs[bit]) {
          continue;
        }
        count++;
      }
      candidate += ps[count];
    }
    ret = std::max(candidate, ret);
  }
  return ret;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<std::array<bool, 10>> fss(n);
  std::vector<std::array<int, 11>> pss(n);
  for (int i = 0; i < n; i++) {
    for (auto& f : fss[i]) {
      int open;
      std::cin >> open;
      f = open;
    }
  }
  for (int i = 0; i < n; i++) {
    for (auto& p : pss[i]) {
      std::cin >> p;
    }
  }
  std::cout << calc(n, fss, pss) << std::endl;
  return 0;
}


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

#define ll long long
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;

int res;
int a[N], u[N], d[N], used[N], q, cnt, x;
vector<int> b[N], v;
int req( int x ) {
	used[x] = 1;
	u[x] = cnt;
	cnt ++;
	v.push_back( x );
	for ( auto to:b[x] ) {
		d[to] = x;
        used[to] == 0 ? req( to ) : q = to;
	}
	return 0;
}
int main()
{
    ll n, m;
    cin >> n >> m;
    int a[n];
    for ( int i=1; i<=n; i++ ) {
    	cin >> a[i];
    	b[i].push_back( a[i] );
    }
    req( 1 );
   	if( m < cnt )
   		return cout << v[m], 0;
   	m -= u[q];
   	m %= ( u[ d[q] ] - u[q] ) + 1;
   	cout << v[m + u[q]];
}


Measured memory_bytes: 30452
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 18:24:06
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    map<int, int> cnt;
    for (int i = 0; i < n; i++)
        cnt[a[i]]++;

    int ans = 0;
    for (const auto &x : cnt) {
        if (x.second % 2 > 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	cin>>a>>b>>c;
	c-=a+b;
	a*=b;
	if(c<0){
		cout<<"No"<<endl;
		return 0;
	}
	c*=c;
	a*=4;
	if(a<c)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
/*..............................................*\
Author:Kishor Kumar Paroi
Dept:CSE-1703053
email.kishor.josephite@gmail.com
RUET,BANGLADESH
\*---------------------------*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include<bits/stdc++.h>
#include<iostream>
#include<iterator>

#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

//const int N=100*1000;
//const int mod=1e9+7;

//# define int min3(int a,int b,int c){return min(a,min(b,c));}
//#define int max3(int a,int b,int c){return max(a,max(b,c));}
//#define int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
//#define int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int n,i,v[20],s=0,c,d;
   cin>>n;
   for(i=0;i<n;i++)
    cin>>v[i];
   for(i=0;i<n;i++)
   {
       cin>>c;
       d=v[i]-c;
       if(d>0)
        s+=d;
   }
   cout<<s<<endl;

    return 0;
}



Measured memory_bytes: 256
module.exports=function(r){var t={};function e(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=r,e.c=t,e.d=function(r,t,n){e.o(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:n})},e.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},e.t=function(r,t){if(1&t&&(r=e(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var o in r)e.d(n,o,function(t){return r[t]}.bind(null,o));return n},e.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(t,"a",t),t},e.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},e.p="",e(e.s=0)}([function(r,t,e){e(1)(e(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(r,t,e){"use strict";function n(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){var e=[],n=!0,o=!1,u=void 0;try{for(var i,a=r[Symbol.iterator]();!(n=(i=a.next()).done)&&(e.push(i.value),!t||e.length!==t);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==a.return||a.return()}finally{if(o)throw u}}return e}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var t=parseInt(r[0],10),e=new Array(t),o=0;o<t;o++)e[o]=[];for(var u=n(r[t].split(" ").map(function(r){return parseInt(r,10)}),2),i=u[0],a=u[1],f=0;f<t-1;f++){var l=r[f+1].split(" ").map(function(r){return parseInt(r,10)});l[1]!=a&&e[l[0]-1].push([l[1]-1,l[2]]),l[0]!=a&&e[l[1]-1].push([l[0]-1,l[2]])}for(var c=new Array(t).fill(-1),p=[[a-1,0]];p.length>0;)for(var s=p.pop(),d=e[s[0]].length,v=0;v<d;v++){var y=e[s[0]][v];if(-1==c[y[0]]){var b=s[1]+y[1];c[y[0]]=b,p.push([y[0],b])}}for(var m=0;m<i;m++){var h=r[m+t+1].split(" ").map(function(r){return parseInt(r,10)-1}),g=c[h[0]]+c[h[1]];console.log(g)}}},function(r,t){r.exports=require("fs")}]);

Measured memory_bytes: 92644
# ABC099C - Strange Bank
def main():
    n = int(input())
    ans = n  # 1yen * n
    for i in range(n + 1):
        cnt, t = 0, i
        while t > 0:
            cnt += t % 6
            t //= 6
        t = n - i
        while t > 0:
            cnt += t % 9
            t //= 9
        ans = min(ans, cnt)
    print(ans)


if __name__ == "__main__":
    main()

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

int main() {
  int n;
  cin >> n;
  
  vector<vector<int> > A(n + 1, vector<int> (n + 1));
  
  int u, k;
  
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int adju;
      cin >> adju;
      A.at(u - 1).at(adju - 1) = 1;
    }
  }
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << A.at(i).at(j);
      if (j == n - 1) {
        cout << endl;
      }
      else {
        cout << " ";
      }
    }
  }
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
    
#define int long long
    
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
#define MOD (int)(1e9)+7
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};
    
int32_t main(){
    int n;
    cin >> n;
    vector<int> v;
    int sum=0;
    v.pb(0);
    REP(i, n){
        int a;
        cin >> a;
        v.pb(a);
    }
    v.pb(0);
    FOR(i, 1, n+2){
        sum+=abs(v[i]-v[i-1]);
    }
    
    FOR(i, 1, n+1){
        if((v[i-1]<=v[i] && v[i]<=v[i+1]) || (v[i+1]<=v[i] && v[i]<=v[i-1])){
            cout << sum << endl;
        }
        else if((v[i+1]<v[i] && v[i-1]<=v[i+1]) || (v[i+1]>v[i] && v[i+1]<=v[i-1])){
            cout << sum-2*(abs(v[i]-v[i+1])) << endl;
        }
        else{
            cout << sum-2*(abs(v[i-1]-v[i])) << endl;
        }
    }
}

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

char field[100][100];
int H,W;
int num;
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};

void dfs(int x,int y,char m)
{
	field[x][y]='.';
	for(int i=0;i<4;i++)
	{ 
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx>=0&&nx<H&&ny>=0&&ny<W&&field[nx][ny]==m)
		{
			dfs(nx,ny,m);
		}
	} 
}

void solve(char m)
{
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			if(field[i][j]==m)
			{
				dfs(i,j,m);
				num++;
			}
		}
	}
}

int main()
{
	while(1)
	{
		num=0;
		cin>>H>>W;
		if(H==0&&W==0)
			exit(0);
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				cin>>field[i][j];
			}
		}
		solve('@');
		solve('#');
		solve('*');
		cout<<num<<endl;
	}
	
	return 0;
}



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

using namespace std;

int main(void) {
	long long N;
	cin >> N;
	if(N == 0) {
		cout << "0\n";
		return 0;
	}
	string S;
	while(N != 0) {
		long long r = (N % 2 == 0) ? 0 : 1;
		long long q = (N - r) / (-2);
		N = q;
		S += r ? '1' : '0';
	}
	reverse(S.begin(), S.end());
	cout << S << '\n';
	return 0;
}



Measured memory_bytes: 256
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:input()

"""========main code==============="""
t=1
#t=ii()
for _ in range(t):
    n=ii()
    a=ll()
    ans=0
    for i in range(1,n):
        if(a[i]<a[i-1]):
            ans+=(a[i-1]-a[i])
            a[i]=a[i-1]
    print(ans)        

Measured memory_bytes: 93160
import heapq

n = int(input())
list = []

idx = 1
for count_str in input().split():
    count = int(count_str)
    heapq.heappush(list, (count, idx))
    
    idx += 1

print(" ".join([ str(heapq.heappop(list)[1]) for _ in range(n) ]))


Measured memory_bytes: 23480
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

cs = ([row[j:j+m] for row in a[i:i+m]] for i in range(n-m+1) for j in range(n-m+1))
print('Yes' if any(c==b for c in cs) else 'No')

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a+b==c || b+c==a || c+a==b)	{
	printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	int k;
	cin>>k>>s;
	if(s.length()>k){
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
	else cout<<s<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  lint N,K;
  cin>>N>>K;
  int max=100000;
  lint m[max+1]={0};
  REP(i,N){
    int a,b;
    cin>>a>>b;
    m[a]+=b;
  }
  lint k=0;
  int ans;
  REP(i,max+1){
    k+=m[i];
    if(k>=K){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define vstroku() to_string()
#define vchislo() to_ulong()
#define numberof1(x) __builtin_popcount(x)
#define povsemelementam(i,mnozh) for(auto i: mnozh)
#define podotrezok(i,j) substr(i-1,j) // like prefix sum, (i,j)=s[j]-s[i-1]
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back 
#define pii pair <int, int>
#define F first
#define S second
#define mipletsplay ios_base::sync_with_stdio(0); cin.tie(0); 


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 3e5;
const ll INF = 1e9;
const ll kek = 998244353;
int main() {
	mipletsplay;
int n;
cin>>n;
int k;
cin>>k;
if (k>((n-1)*(n-2)/2) ||(n==2&&k!=0))
cout<<-1;
else
{
if (k>=n-2){
int sum=n-2,j=0;
int f=n-1;
while (sum<k)
{
sum+=j+1;
j++;
}
//cout<<j<<endl;
cout<<f+sum-k<<endl;
for (int i=1;i<n-j;i++)
cout<<i<<" "<<i+1<<endl;
for (int i=n-j+1;i<=n;i++){
if (i!=2&&i!=3)
cout<<2 <<" "<<i<<endl;
}
int t=n-j;
if (sum-k>0){
cout<<1<<" "<<n<<endl;
sum--;
t++;
}
while (sum-k>0)
{
cout<<t<<" "<<n<<endl;
t++;
sum--;
}
}
else
{
cout<<n*(n-1)/2 - k<<endl;
for (int i=1;i<=n-1;i++)
{
for (int j=i+1;j<=n-1;j++)
{
cout<<i<<" "<<j<<endl;}
}
for (int i=1;i<=n-1-k;i++)
cout<<n<<" "<<i<<endl;
    
    
    
}



}
}


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



int main(){

	string s;


	while (cin >> s) {
		int cnt1 = 0;
		int cnt2 = 0;


		rep(i, s.size() - 2) {
			if (s[i] == 'J') {
				if (s[i + 1] == 'O') {
					if (s[i + 2] == 'I') cnt1++;
				}
			}
			if (s[i] == 'I') {
				if (s[i + 1] == 'O') {
					if (s[i + 2] == 'I') cnt2++;
				}
			}
		}

		cout << cnt1 << endl << cnt2 << endl;
	}

	return 0;
}


Measured memory_bytes: 3052
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x, y = list(map(int, readline().split()))

    ans = 0
    c = x

    while c <= y:
        ans += 1
        c <<= 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
a,b,c = map(int, input().split())
if a - c > 0:
  a -= c
  c = 0
else:
  c -= a
  a = 0
  if b - c > 0:
    b -= c
    c = 0
  else:
    c -= b
    b = 0
print(a,b)

Measured memory_bytes: 3060
import sys
N,M=map(int,input().split())
H=list(map(int,input().split()))

#print(N,M,H)

bad=set()
for ln in sys.stdin:
    A,B=map(int,ln.split())
    x,y=H[A-1],H[B-1]
    if x>y:
        bad.add(B)
    elif x<y:
        bad.add(A)
    else:
        bad.add(A)
        bad.add(B)

print(N-len(bad))


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

int main() {
  int N;
  cin >> N;
  
  int M = N;
  int DigitSum = 0;
  while (M > 0) {
    DigitSum += M % 10;
    M /= 10;
  }
  
  if (N % DigitSum) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3608
from collections import Counter
from scipy.misc import comb

n, p = map(int, input().split())
ac = Counter(int(x) & 1 for x in input().split())

ans = 0

for c in range(p, ac[1] + 1, 2):
    ans += comb(ac[1], c, exact=True)

ans <<= ac[0]

print(ans)


Measured memory_bytes: 24476
// Sasageyo! Sasageyo! Shinzou wo Sasageyo !
// https://goo.gl/IwJzbx

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

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

#define fast_io                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)

#define endl '\n'
int x[26];
int mi[26];
int main() {
  fast_io;
  int n;
  cin >> n;
  for (int i = 0; i < 26; i++) mi[i] = 999999999;
  for (int i = 0; i < n; i++) {
    SET(x, 0);
    string s;
    cin >> s;
    for (auto c : s) x[c - 'a']++;
    for (int i = 0; i < 26; i++) mi[i] = min(mi[i], x[i]);
  }
  for (int i = 0; i < 26; i++)
    while (mi[i]--) putchar(i + 'a');
  putchar('\n');
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <functional>

using namespace std;

int main()
{
	int num,i;
	cin >> num;
	long long ret = 1;
	for( i = 1; i <= num; i++ ) {
		ret *= i;
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
//using namespace atcoder;

const ll mod=1000000007;//998244353;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  string s;
  cin >> s;
  bool ok=0;
  if(s[0]==s[1] && s[1]==s[2])ok=1;
  if(s[1]==s[2] && s[2]==s[3])ok=1;

  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3596
#include<iostream>

int main(){
    
	size_t n, k, ans = 1;
    std::cin >> n >> k;

    for(size_t i = 0; i < n; i++){
        if(2 * ans < ans + k){
            ans *= 2;
        }else{
            ans += k;
        }
    }

    std::cout << ans << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

#define ll long long
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int k, x;
    cin >> k >> x;
    for(int i = x - (k - 1); i <= x + (k - 1); i++){
        cout << i << " ";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define iter vector<int>::iterator
#define mod 1000000007

int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int h,w;
    cin>>h>>w;

    char a[h][w];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>a[i][j];
        }
    }
    int dp[h][w];
   

    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(a[i][j]=='#')
                dp[i][j]=0;
        }
    }

     dp[0][0]=1;
    for(int i=1;i<w;i++)
    {
        if(a[0][i]!='#')
            dp[0][i]=dp[0][i-1];
    }
    for(int i=1;i<h;i++)
    {
        if(a[i][0]!='#')
            dp[i][0]=dp[i-1][0];
    }

    for(int i=1;i<h;i++)
    {
        for(int j=1;j<w;j++)
        {
            if(a[i][j]!='#')
            {
                dp[i][j]=((dp[i-1][j]%mod)+(dp[i][j-1]%mod))%mod;
            }
        }
    }
    cout<<dp[h-1][w-1]<<"\n";
}

Measured memory_bytes: 9088
N = int(input())
p = list(map(int, input().split()))

ans = 'NO'
p_sorted = sorted(p)

#print(p, p_sorted)
cnt = 0
for i in range(N):
    if p_sorted[i] != p[i]:
        cnt += 1

if cnt < 3:
    ans = 'YES'
print(ans)


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class UnionFindTree
{
private:
    const int n;
    int groupNum;       // グループの数
    vector<int> parent; // 親ノード
    vector<int> rank;   // 木の高さの上限
    vector<int> num;    // グループの要素数
    int find(int i){
        if(parent[i] == i)
            return i;
        else
            return parent[i] = find(parent[i]);
    }
public:
    UnionFindTree(int n) : n(n){ // コンストラクタ
        groupNum = n;
        parent.resize(n);
        for(int i=0; i<n; ++i)
            parent[i] = i;
        rank.assign(n, 0);
        num.assign(n, 1);
    }
    void unite(int a, int b){ // aとbのグループを併合
        if((a = find(a)) != (b = find(b))){
            if(rank[a] < rank[b]){
                parent[a] = b;
                num[b] += num[a];
            }
            else{
                parent[b] = a;
                if(rank[a] == rank[b])
                    ++ rank[a];
                num[a] += num[b];
            }
            -- groupNum;
        }
    }
    bool same(int a, int b){ // aとbのグループが同じかを調べる
        return find(a) == find(b);
    }
    int getNum(){ // グループの数を返す
        return groupNum;
    }
    int getNum(int a){ // aのグループの要素数を返す
        return num[find(a)];
    }
    void getGroup(vector<int>& index){ // グループ構成を返す
        index.resize(n);
        for(int i=0; i<n; ++i)
            index[i] = find(i);
    }
};

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

    vector<int> a(k), b(k);
    UnionFindTree uft1(n);
    for(int i=0; i<k; ++i){
        cin >> a[i] >> b[i];
        -- a[i];
        -- b[i];
        uft1.unite(a[i], b[i]);
    }

    vector<int> c(l), d(l);
    UnionFindTree uft2(n);
    for(int i=0; i<l; ++i){
        cin >> c[i] >> d[i];
        -- c[i];
        -- d[i];
        uft2.unite(c[i], d[i]);
    }

    vector<int> index1, index2;
    uft1.getGroup(index1);
    uft2.getGroup(index2);
    map<pair<int, int>, int> cnt;
    for(int i=0; i<n; ++i)
        ++ cnt[make_pair(index1[i], index2[i])];

    vector<int> ans(n);
    for(int i=0; i<n; ++i)
        ans[i] = cnt[make_pair(index1[i], index2[i])];

    cout << ans[0];
    for(int i=1; i<n; ++i)
        cout << ' ' << ans[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 20352
#include <iostream>
using namespace std;
int main()
{
    int n,k;
    
    cin >>n>>k;
    
    int ans=1,cnt=0;
    
    for(int i=0;i<n;i++)
    {
        if((ans*2)<=(ans+k))
        ans*=2;
        else
        ans+=k;
    }
    cout << ans<<endl;
}

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

/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

int mat[3][3];

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

	int N = 3;
	for(int i = 0;i < N;i++) for(int j = 0;j < N;j++) cin>>mat[i][j];
	bool can = false;
	for(int a1 = -100;a1 <= 100 && !can;a1++) {
		int b1 = mat[0][0] - a1;
		int b2 = mat[0][1] - a1;
		int b3 = mat[0][2] - a1;
		int a2 = mat[1][0] - b1;
		int a3 = mat[2][0] - b1;
		bool cur = true;
		cur &= b2 + a2 == mat[1][1];
		cur &= b3 + a2 == mat[1][2];
		cur &= b2 + a3 == mat[2][1];
		cur &= b3 + a3 == mat[2][2];
		can |= cur;
	}
	cout<<(can?"Yes":"No")<<'\n';
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {

        int bit = 0;
        int over = 0;
        int num;

        int buf;
        StringBuilder builder = new StringBuilder();
        while((buf = System.in.read()) != '\n') {}
        while (true) {
            builder.setLength(0);
            while((buf = System.in.read()) != ' ' && buf != '\n') {
                builder.appendCodePoint(buf);
            }

            num = Integer.parseInt(builder.toString()) / 400;
            if (num < 1) {
                bit |= 1;
            } else if (num < 2) {
                bit |= 2;
            } else if (num < 3) {
                bit |= 4;
            } else if (num < 4) {
                bit |= 8;
            } else if (num < 5) {
                bit |= 16;
            } else if (num < 6) {
                bit |= 32;
            } else if (num < 7) {
                bit |= 64;
            } else if (num < 8) {
                bit |= 128;
            } else {
                over++;
            }
            
            if (buf == '\n') break;
        }

        int count = Integer.bitCount(bit);
        int max = count + over;

        if (count == 0) count = 1;

        System.out.print(count + " " + max);
    }
}


Measured memory_bytes: 36432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int N,Q;
ll a[100000];

ll solve(ll S){
  ll sum=0,ans=0,k=0;
  for(int i=0;i<N;i++){
    sum+=a[i];
    //6
    while(sum>S){
      sum-=a[k];
      k++;
    }
    ans+=(i-k+1);
  }
  return ans;
}

int main(){

  scanf("%d %d",&N,&Q);
  for(int i=0;i<N;i++)scanf("%lld",&a[i]);
  for(int i=0;i<Q;i++){
    ll x;
    scanf("%lld",&x);
    printf("%lld\n",solve(x));
  }

  return 0;
}

Measured memory_bytes: 3976
def uf_find(n,p):

    ufl = []

    while p[n] != n:
        ufl.append(n)
        n = p[n]

    for i in ufl:
        p[i] = n

    return n


def uf_union(a,b,p,rank,num):

    ap = uf_find(a,p)
    bp = uf_find(b,p)

    if ap == bp:
        return True
    else:

        if rank[ap] > rank[bp]:
            p[bp] = ap
            num[ap] += num[bp]
        elif rank[ap] < rank[bp]:
            p[ap] = bp
            num[bp] += num[ap]
        else:
            p[bp] = ap
            num[ap] += num[bp]
            rank[ap] += 1

        return False


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

p = [i for i in range(N)]
rank = [1] * N
numlis = [1] * N #自分考慮
linknum = [0] * N

for i in range(M):

    A,B = map(int,input().split())
    A -= 1
    B -= 1

    uf_union(A,B,p,rank,numlis)
    linknum[A] += 1
    linknum[B] += 1

dis = [ [] for i in range(N) ]

for i in range(K):

    C,D = map(int,input().split())
    C -= 1
    D -= 1

    dis[C].append(D)
    dis[D].append(C)

al = []

for i in range(N):

    ans = numlis[uf_find(i,p)] - 1 - linknum[i]

    for j in dis[i]:

        if uf_find(i,p) == uf_find(j,p):
            ans -= 1

    al.append(ans)

print (" ".join(map(str,al)))



Measured memory_bytes: 99744