akhauriyash/Code-Regression huggingface dataset:
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))
P=[i-1 for i in P]
idle_max=-10**27



for s in range(0,N):
    k=K-1
    score=0
    s=P[s]
    score+=C[s]
    count=1
    idle_max=max(idle_max,score)
    visited={s:[count,score]}
    while k and not P[s] in visited:

        k-=1
        count+=1
        s=P[s]
        score+=C[s]
        visited[s]=[count,score]

        idle_max=max(idle_max,score)
    #print(visited)
    if k:
        c1,score1=visited[s]
        c2,score2=visited[P[s]]
        c1+=1
        s=P[s]
        score1+=C[s]
        score+=C[s]
        k-=1


        n=c1-c2
        score+=(score1-score2)*(k//n)
        k%=n
        idle_max=max(idle_max,score)
    while k:
        k-=1
        s=P[s]
        score+=C[s]
        idle_max=max(idle_max,score)


print(idle_max)


Measured memory_bytes: 171196
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100000;

vvl G;
vl visited;
ll cntX, cntY;

void dfs(ll v) {
    // 行きの処理はこのへんに書く
    visited[v] = 1;
    if(v < MAX_N) {
        cntX++;
    }
    else {
        cntY++;
    }
    for(auto u : G[v]) { 
        if(visited[u]) {
            continue;
        }
        dfs(u);
        // 帰りの処理はこのへんに書く
    }
}

int main() {
    ll n;
    cin >> n;    
    
    G.resize(2*MAX_N);
    visited.resize(2*MAX_N);
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        x--;  y--;
        y += MAX_N;
        G[x].pb(y);
        G[y].pb(x);
    }

    if(n < 3) {
        out(0);
        re0;
    }

    ll ans = 0;
    rep(v, 2*MAX_N) {
        if(visited[v]) {
            continue;
        } 
        cntX = 0, cntY = 0;
        dfs(v);
        ans += cntX*cntY;
    }
    ans -= n;
    
    out(ans);
    re0;
}

Measured memory_bytes: 11520
# include<iostream>
# include<vector>
# include<time.h>
# include<random>
using namespace std;
using vector1 = vector<int>;
using vector2 = vector<vector1>;
int last(int d, int j, vector1 t){ //d日目から数えてタイプjのコンテストが最後に開催された日を計算
  for(int i=d; i>=1; i--){
    if(t[i] == j) return i;
  }
  return 0;
}
int penalty(vector1 c, int d, vector1 t){ //ペナルティの合計を計算
  int m = 0;
  for(int i=1; i<=26; i++){
    m += c[i] * (d - last(d, i, t));
  }
  return m;
}
int calc_score(int d, int j, int c, vector1 t){ //開催されるコンテストが変更された場合のスコア差を算出
  int s = 1;
  if(d > 1) s = d - last(d-1, j, t);

  int r = s * c; //1日分のスコア差
  int sum = 0;  //スコア差の合計
  int i = d;
  do{
    sum += r;
    i++;
    if((int)t.size() < i) break;
  }while(t[i] != j);
  return sum;
}
void swap_(int d1, int d2, vector1& t){
  int tmp = t[d1]; t[d1] = t[d2]; t[d2] = tmp;
  return;
}
int main(){
  clock_t start = clock();
  int D; cin >> D; //日数d
  vector1 c(26+1, 0); for(int i=1; i<=26; i++) cin >> c[i]; //ペナルティc
  vector2 s(D+1, vector1(26+1)); //あるコンテストが開催された場合の満足度s
  for(int i=1; i<=D; i++){
    for(int j=1; j<=26; j++){
      cin >> s[i][j];
    }
  }
  vector1 t(D+1, 0); for(int i=1; i<=D; i++) t[i] = (i % 26) + 1;
/*  vector1 v(D+1, 0); //スコアv
  for(int i=1; i<=D; i++){
    v[i] = s[i][t[i]];
    v[i] -= penalty(c, i, t);
  }*/
  int score = 0;
  for(int i=1; i<=D; i++){
    score += s[i][t[i]];
    score -= penalty(c, i, t);
  }
  clock_t end = clock();
  //cout << score <<"\n";
  random_device random_a;
  auto num = random_a();
  mt19937 random_b;
  //num = 3180901575;
  random_b.seed(num);
//  cout <<"num: "<< num <<"\n";

  while((double)(end - start) / CLOCKS_PER_SEC < 1.9){
    int r = (int)random_b();
    if(r > 0){
      int p = ((int)random_b() * random_b() % 26) + 1;
      int d = ((int)random_b() * random_b() % D) + 1;
      int old = t[d];
      t[d] = p;
      int up = calc_score(d, p, c[p], t); //増えるスコア
      int down = calc_score(d, old, c[old], t); //減るスコア
      int l = up - down;
      if(l > 0){
        score += l;
      }else{
        t[d] = old;
      }
    }else{
      int d1 = ((int)random_b() * random_b() % D) + 1;
      int d2 = ((int)random_b() * random_b() % D) + 1;
      int l_old_d1 = calc_score(d1, t[d1], c[t[d1]], t);
      int l_old_d2 = calc_score(d2, t[d2], c[t[d2]], t);
      //cout << t[d1] <<"  "<< t[d2] <<"\n";
      swap_(d1, d2, t);
      //cout << t[d1] <<"  "<<t[d2] <<"\n";
     // break;
      int l_d1 = calc_score(d1, t[d1], c[t[d1]], t);
      int l_d2 = calc_score(d2, t[d2], c[t[d2]], t);
      int l = l_d1 + l_d2 - l_old_d1 - l_old_d2;
      if(l >0){
        score += l;
      }else{
        swap_(d1, d2, t);
      }
    }
    end = clock();
  }
  for(int i=1; i<=D; i++){
    cout << t[i] <<"\n";
  }
/*  cout << score <<"\n";
  int score2=0;
  for(int i=1; i<=D; i++){
    score2 += s[i][t[i]];
    score2 -= penalty(c, i, t);
  }
  cout <<score2 <<"\n";*/
  return 0;
}


Measured memory_bytes: 3268
#include <iostream>
// #include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cassert>
#include <ctime>
// #include <unordered_map>
#include <map>
#include <queue>
#include <set>
#include <cmath>
using namespace std;

int n;

int main() {
    scanf("%d", &n);
    int m = n;
    int t = 0;
    while (m > 0) {
        t += m % 10;
        m /= 10;
    }
    m = n;
    while (m % 10 == 0) {
        m /= 10;
    }
    if (m != 1) {
        printf("%d\n", t);
    }else {
        printf("10\n");
    }
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int maxn=2e5+10;
const int N=1e6+10;
typedef long long ll;
const ll mod=1e9+7;
#define per(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define inf 0x3f3f3f3f
#define qwq puts("QWQ");
#define qaq puts("QAQ");
#define mem(a,b) memset(a,b,sizeof(a))
#define mid ((l+r)>>1)
#define l(x) x<<1
#define r(x) x<<1|1
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
void read(int &x)
{
	int f=1;x=0;
	char s=getchar();
	while(s<'0'||s>'9')
    {
    	if(s=='-')f=-1;
    	s=getchar();
	}
	while(s>='0'&&s<='9')x=x*10+s-'0',s=getchar();
	x*=f;
}
int main()
{
	int x,n;
	int a,sum=0,num=0;
	read(n),read(x);
	per(i,0,n)
	{
		read(a);sum+=a;
		if(sum>x)break;
		num++;
	}
	printf("%d\n",num+1);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  string s;
  cin >> s;
  char tmp[2] = {'0', '1'};
  int now = 0;
  int ans = 0;
  int count = 0;
  rep (i, s.size()) {
    if (s[i] != tmp[now]) {
      count++;
    }
    now = (now + 1) % 2;
  }

  ans = count;
  count = 0;
  now = 1;
  rep (i, s.size()) {
    if (s[i] != tmp[now]) {
      count++;
    }
    now = (now + 1) % 2;
  }
  P(min(ans, count));



  return 0;

}

Measured memory_bytes: 512
n = int(input())
s = []
for _ in range(n):
    s.append(input())

march=[0]*5
string="MARCH"

for i in range(n):
    for j in range(5):
        if s[i][0]==string[j]:
            march[j] +=1

if march.count(0)>=3:
    print(0)
    exit()

while march.count(0):
    march.remove(0)

ans=0
for i_0 in range(len(march)):
    for i_1 in range(i_0+1,len(march)):
        for i_2 in range(i_1+1,len(march)):
            ans = ans + march[i_0]*march[i_1]*march[i_2]
print(ans)


Measured memory_bytes: 16252
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();
        int s = a * 100 / 8, t = b * 10;
        if((double)a * 100 / 8 % 1 > 0) s++;
        if(s >= t && (s / 10) == b){
            System.out.println(s);
        }else if(t >= s && (t * 8 /100) == a){
            System.out.println(t);
        }else{
            System.out.println(-1);
        }
    }
}


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

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = A*C;
    ans = max(ans, A*D);
    ans = max(ans, B*C);
    ans = max(ans, B*D);
    cout << ans << endl;
}


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

int dr[] = {0, 0, 1, -1};
int dc[] = {1, -1, 0, 0};

void dfs(vector<string>& garden, int r, int c) {
    char color = garden[r][c];
    garden[r][c] = '.';
    for (int i = 0; i < 4; i++) {
        int nr = r + dr[i];
        int nc = c + dc[i];
        if (nr >= 0 && nr < garden.size() && nc >= 0 && nc < garden[nr].size()) {
            if (garden[nr][nc] == color) dfs(garden, nr, nc);
        }
    }
}

int solve(vector<string>& garden) {
    int res = 0;
    for (int i = 0; i < garden.size(); i++) {
        for (int j = 0; j < garden[i].size(); j++) {
            if (garden[i][j] != '.') {
                res ++ ;
                dfs(garden, i, j);
            }
        }
    }
    return res;
}

int main() {
    int H, W;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        vector<string> garden;
        for (int i = 0; i < H; i++) {
            string s; cin >> s;
            garden.push_back(s);
        }
        int answer = solve(garden);
        cout << answer << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

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

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    int a;
    cin >> a;
    cout << n * n - a << endl;
    
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
//input
int N,K;


//processing



//dpTable
//int dp[100050];

int main(){
    cin >> N >> K;
    vector<int> p(N);
    rep (i,N){
        cin >> p.at(i);
    }
    sort(p.begin(),p.end());
    int ans = 0;
    rep (i,K){
        ans += p.at(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
from collections import deque

def main():
  N, K = map(int, input().split())
  arr = list(map(int, input().split()))
  dp = [False for _ in range(K + 1)]

  for i in range(1, K + 1):
    for k in range(N):
      if i - arr[k] >= 0:
        if not(dp[i - arr[k]]):
          dp[i] = True

  print("First") if(dp[K]) else print("Second")


if __name__ == "__main__":
  main()

Measured memory_bytes: 9924
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int T = sc.nextInt();
		
		int time = 0;
		
		for(int i = 1; i <= 1000; i++) {
			time += T;
			N -= X;

			if(N <= 0) {
				System.out.println(time);
				break;
			}
		}
		
	}
}

Measured memory_bytes: 35716
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, D;
    cin >> N >> D;
    vector<vector<int> > X(10);
    int tmp;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < D; j++)
        {
            cin >> tmp;
            X[i].emplace_back(tmp);
        }
        
    }

    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            double sqsum = 0;
            for (int k = 0; k < D; k++)
            {
                sqsum += pow((X[i][k] - X[j][k]), 2);
            }
            double sum = pow(sqsum, 0.5);
            if (floor(sum) == ceil(sum)) cnt++;
            
        }
        
    }
    
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 888
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

x,y,z=get_i
x,y=y,x
x,z=z,x
puts [x,y,z].join(" ")

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    int t1 = 0;
    int t2 = 0;
    for (int i = 1; i <= n; i++){
        int x;
        cin >> x;
        if (x % 4 == 0) t1++; else
        if (x % 2 == 0) t2++;
    }
    n -= 2 * t1;
    if (n <= 1){
        cout << "Yes";
        return 0;
    }
    if (t2 >= n) cout << "Yes"; else cout << "No";
}


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

int main() {
  int N; cin >> N;
  map<int, int> A;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (A.count(a)) A[a]++;
    else A[a] = 1;
  }
  int cnt = 0;
  for (auto p : A) {
    if (p.second % 2 == 0) cnt++;
  }
  if (cnt % 2 == 0) cout << A.size() << endl;
  else cout << A.size() - 1 << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(0);
  for(ll i=0;i<a;i++){
    ll b,c;
    cin>>b>>c;
    if(b==c){
      vec.push_back(i);
    }
  }
  if(vec.size()<3){
    cout<<"No"<<endl;
    return 0;
  }
  for(ll i=2;i<vec.size();i++){
    if(vec.at(i)-vec.at(i-2)==2){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
    
    
    
  
  return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	long long x,y;
	scanf("%lld%lld",&x,&y);
	if(x>y){
		printf("0\n");
		return 0;
	}
	long long t=2,ans=1,f=x;
	while(x<=y){
		if(y/t<f)
			break;
		ans++;
		t*=2;
	}
	printf("%lld\n",ans);
} 

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

using namespace std;
using ll = long long int;

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

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

    int ans = 0;
    for (int a = 0; a < n; a++)
    {
        for (int b = a + 1; b < n; b++)
        {
            auto lower = lower_bound(L.begin() + b + 1, L.end(), L[b]);
            auto upper = lower_bound(L.begin() + b + 1, L.end(), L[a] + L[b]);

            /*for (auto it = lower; it < upper; it++)
                cout << L[a] << " " << L[b] << " " << *it << endl;*/

            int count = distance(lower, upper);
            ans += count;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
INF = 100000

h, w = map(int, input().split())
S = [list(input()) for i in range(h)]

D = [[INF for i in range(w)] for j in range(h)]

if S[0][0] == '.':
    D[0][0] = 0
else:
    D[0][0] = 1

for i in range(1, h):
    if S[i][0] == '#' and S[i-1][0] == '.':
        D[i][0] = D[i-1][0] + 1
    else:
        D[i][0] = D[i-1][0]

for j in range(1, w):
    if S[0][j] == '#' and S[0][j-1] == '.':
        D[0][j] = D[0][j-1] + 1
    else:
        D[0][j] = D[0][j-1]

for i in range(1, h):
    for j in range(1, w):
        s = S[i][j]
        su = S[i-1][j]
        sl = S[i][j-1]
        if s == '.' or (s == su and s == sl):
            D[i][j] = min(D[i-1][j], D[i][j-1])
        elif s == su:
            D[i][j] = min(D[i-1][j], D[i][j-1]+1)
        elif s == sl:
            D[i][j] = min(D[i-1][j]+1, D[i][j-1])
        else:
            D[i][j] = min(D[i-1][j]+1, D[i][j-1]+1)

print(D[h-1][w-1])


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if (s < t) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B_Postdocs solver = new B_Postdocs();
        solver.solve(1, in, out);
        out.close();
    }

    static class B_Postdocs {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            out.println(in.next().replaceAll("\\?", "D"));
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 50044
N,M = map(int, raw_input().split())
C = map(int, raw_input().split())

INF = 10**9
DP = [INF]*(N+1)
DP[0] = 0

for i in range(1, N+1):
    for c in C:
        if c <= i:
            DP[i] = min(DP[i], DP[i-c]+1)

print DP[N]


Measured memory_bytes: 7456
#include <bits/stdc++.h>
using namespace std;
int alphabet[26];

int main(){

    // 1. 入力情報.
    int H, W;
    scanf("%d %d", &H, &W);
    char c[111];
    for(int i = 0; i < H; i++){
        scanf("%s", c);
        for(int j = 0; j < W; j++) alphabet[c[j] - 'a']++;
    }
    
    // 2. 条件を満たす回文が存在するかチェック.
    // ex.
    // 基本的には, a[i][j] が, 'x' だったとすると, 
    // a[H - 1 - i][j], a[i][W - 1 - j], a[H - 1 - i][W - 1 - j] も 'x' となる必要があるはず.
    bool ok = true;
    if(H % 2 == 0){
        // 2-1. (H, W) = (偶数, 偶数).
        if(W % 2 == 0){
            for(int i = 0; i < 26; i++) if(alphabet[i] % 4 != 0) ok = false;
        }
        // 2-2. (H, W) = (偶数, 奇数).
        if(W % 2 != 0){
            int rem0 = 0, rem1 = 0, rem2 = 0, rem3 = 0; // 4 で 割った余りを集計.
            for(int i = 0; i < 26; i++){
                if(alphabet[i] % 4 == 0) rem0++;
                if(alphabet[i] % 4 == 1) rem1++;
                if(alphabet[i] % 4 == 2) rem2++;
                if(alphabet[i] % 4 == 3) rem3++;
            }
            // 中央列は, 上半分, 下半分とで, 回文になっている必要がある点に注意.
            if(rem1 > 0 || rem3 > 0) ok = false;
            // 4 の 倍数が少なすぎる場合は, 回文に出来ない.
            if(2 * rem2 > H) ok = false;
        }
    }
    if(H % 2 != 0){
        // 2-3. (H, W) = (奇数, 偶数).
        if(W % 2 == 0){
            int rem0 = 0, rem1 = 0, rem2 = 0, rem3 = 0; // 4 で 割った余りを集計.
            for(int i = 0; i < 26; i++){
                if(alphabet[i] % 4 == 0) rem0++;
                if(alphabet[i] % 4 == 1) rem1++;
                if(alphabet[i] % 4 == 2) rem2++;
                if(alphabet[i] % 4 == 3) rem3++;
            }
            // 中央行は, 左半分, 右半分とで, 回文になっている必要がある点に注意.
            if(rem1 > 0 || rem3 > 0) ok = false;
            // 4 の 倍数が少なすぎる場合は, 回文に出来ない.
            if(2 * rem2 > W) ok = false;
        }
        // 2-4. (H, W) = (奇数, 奇数).
        if(W % 2 != 0){
            int rem0 = 0, rem1 = 0, rem2 = 0, rem3 = 0; // 4 で 割った余りを集計.
            for(int i = 0; i < 26; i++){
                if(alphabet[i] % 4 == 0) rem0++;
                if(alphabet[i] % 4 == 1) rem1++;
                if(alphabet[i] % 4 == 2) rem2++;
                if(alphabet[i] % 4 == 3) rem3++;
            }
            // 中央行, 中央列が, 回文になるために, rem1, rem3 に 制約あることに注意.
            if(rem1 + rem3 > 1) ok = false;
            // 4 の 倍数が少なすぎる場合は, 回文に出来ない.
            if(2 * rem2 > H + W - 2) ok = false;
        }
    }
    
    // 3. 出力
    if(ok) printf("%s\n", "Yes");
    else   printf("%s\n", "No");
    return 0;
    
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod = 1e9 + 7;
const int MX = 1e5+10;
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   
   int n;
   cin>>n;
   vi a(n+1);
   int ans=0;
   for(int i=1;i<=n;i++){
	   cin>>a[i];
	   if(i&1 and a[i]&1)ans++;
   }
   cout<<ans<<endl;
   
   return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

enum Type{
	Current,
	Next,
};

struct Info{
	Info(){
		x = y = 0;
	}
	double x,y;
};


double calc_dist(Info left,Info right){
	return sqrt((left.x-right.x)*(left.x-right.x)+(left.y-right.y)*(left.y-right.y));
}

double calc_naiseki(Info left,Info right){
	return left.x*right.x+left.y*right.y;
}

int main(){

	int N;
	double Limit,Angle;
	scanf("%d",&N);
	scanf("%lf %lf",&Limit,&Angle);

	Info info[N];

	double dp[N][N][2],dist[N][N];
	bool check[N][N][N];

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){
			for(int p = 0; p < N; p++)check[i][k][p] = false;
		}
	}

	for(int i = 0; i < N; i++){
		scanf("%lf %lf",&info[i].x,&info[i].y);
	}

	double tmp;
	for(int i = 0; i < N-1; i++){
		for(int k = i+1; k < N;k++){
			tmp = calc_dist(info[i],info[k]);
			dist[i][k] = tmp;
			dist[k][i] = tmp;
		}
	}

	Info vector_1,vector_2;
	double len_1,len_2,naiseki,cos_value,kakudo;

	for(int start = 0; start < N; start++){
		for(int mid = 0; mid < N; mid++){
			if(start == mid)continue;
			for(int goal = 0; goal < N; goal++){
				if(start != goal && mid != goal){

					len_1 = calc_dist(info[goal],info[mid]);
					len_2 = calc_dist(info[mid],info[start]);

					vector_1.x = info[goal].x - info[mid].x;
					vector_1.y = info[goal].y - info[mid].y;

					vector_2.x = info[mid].x - info[start].x;
					vector_2.y = info[mid].y - info[start].y;

					naiseki = calc_naiseki(vector_1,vector_2);

					cos_value = naiseki/(len_1*len_2);

					kakudo = acos(cos_value)*180.0/M_PI;

					if(kakudo <= Angle){
						check[start][mid][goal] = true;
					}
				}
			}
		}
	}

	int maximum = 0;
	bool FLG = false;;

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++)dp[i][k][Current] = DBL_MAX;
	}

	for(int first = 1; first < N; first++){
		if(dist[0][first] <= Limit){
			dp[first][0][Current] = dist[0][first];
			FLG = true;
		}
	}

	if(FLG)maximum++;

	while(true){

		FLG = false;

		for(int i = 0; i < N; i++){
			for(int k = 0; k < N; k++)dp[i][k][Next] = DBL_MAX;
		}

		for(int start = 0; start < N; start++){
			for(int pre = 0; pre < N; pre++){
				if(dp[start][pre][Current] == DBL_MAX)continue;
				for(int to = 0; to < N; to++){
					if(start != to && pre != to){
						if(check[pre][start][to] == true && dp[to][start][Next] > dp[start][pre][Current]+dist[start][to] && dp[start][pre][Current]+dist[start][to] <= Limit){
							dp[to][start][Next] = dp[start][pre][Current]+dist[start][to];
							FLG = true;
						}
					}
				}
			}
		}


		if(!FLG)break;
		else{
			for(int i = 0; i < N; i++){
				for(int k = 0; k < N; k++)dp[i][k][Current] = dp[i][k][Next];
			}
			maximum++;
		}
	}


	printf("%d\n",maximum);

	return 0;
}

Measured memory_bytes: 3060
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
int a[10000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;

    for (int i = 1; i <= 50000; i++)
    {
        if(int(i*1.08)==n){
            return cout<<i<<"\n",0;
        }
    }
    cout <<":(" << "\n";
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

long long gcd ( long long a, long long b) {
  while(1) {
    if(a < b) std::swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main (void) {

  long long A, B, C, D; std::cin >> A >> B >> C >> D;

  long long c_div = (B/C) - ((A-1)/C);
  long long d_div = (B/D) - ((A-1)/D);
  long long cd_div = (B/(C*D/gcd(C,D))) - ((A-1)/(C*D/gcd(C,D)));

  long long ans = (B-A)+1 - c_div - d_div + cd_div;
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
  char s[100001];
  int k;
  scanf("%s%d", s, &k);
  char *p;
  for (p = s; *p; ++p)
  {
    if (*p == 'a') continue;
    if ('a' + 26 - *p <= k)
    {
      k -= 'a' + 26 - *p;
      *p = 'a';
    }
  }
  --p;
  *p = (*p - 'a' + k) % 26 + 'a';
  puts(s);
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int pos=10000;
	bool ok=true;
	for(int i=0;i<a.length();i++)
		if(a[i]=='C')
			pos=i;
	for(int i=pos+1;i<a.length();i++)
	{
		if(a[i]=='F')
		{
			cout<<"Yes"<<endl;
			ok=false;
			break;
		}
	}
	if(ok)
		cout<<"No"<<endl;
	return 0;
}

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

const int MAX_Q = 100009;

int Q, l[MAX_Q], r[MAX_Q];

int s[MAX_Q];

int is_prime(int n) {
    if (n <= 1) return 0;
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) return 0;
    }
    return 1;
}

int main() {
    s[0] = 0;
    for (int i = 0; i+1 < MAX_Q; i++) {
        if (i % 2 == 0) s[i+1] = s[i];
        else if (is_prime(i) && is_prime((i+1)/2)) s[i+1] = s[i] + 1;
        else s[i+1] = s[i];
    }

    cin >> Q;
    for (int i = 0; i < Q; i++) {
        cin >> l[i] >> r[i];
        cout << s[r[i] + 1] - s[l[i]] << endl; 
    }
    return 0;
}

Measured memory_bytes: 1920
#include<stdio.h>

 int A[100001];

 int part(int p,int n){
       int i,j,key,tmp,k;
       key=A[n];
       i=p-1;
       for(j=p;j<n;j++){
               if(A[j]<=key){
                     i++;
                     tmp=A[j];A[j]=A[i];A[i]=tmp;
                     }
                }
       i++;
       tmp=A[n];A[n]=A[i];A[i]=tmp;

       return i;
       }
       
                

 int main(){
       int i,n,key,k;
       scanf("%d",&n);
       for(i=0;i<n;i++){
                 scanf("%d",&A[i]);
                 }
       key=part(0,n-1);
       for(k=0;k<n;k++){
                if(k)printf(" ");
                if(k==key)printf("[");
                printf("%d",A[k]);
                if(k==key)printf("]");
               }
       printf("\n");

       return 0;
       }




Measured memory_bytes: 2200
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    S = input()
    print(S.count("+") - S.count("-"))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
ll a,b;
string op;
cin>>a>>op>>b;
if (op=="+")
{
    cout<<a+b<<endl;
}
else cout<<a-b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main() {
	int hp, t, atk,tatk=0;
	scanf("%d %d", &hp, &t);
	for (int i = 0; i < t; i++) {
		scanf("%d", &atk);
		tatk = tatk + atk;
	}
	if (tatk >= hp) {
		printf("Yes");
	}
	else {
		printf("No");
	}
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
public class Main
{
	public static void main(String args[]) throws IOException
	{
		
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String n="";
		n=br.readLine();
		long ans=0;
		for(int i=0;i<n.length();i++)
		{
			ans+=Long.parseLong(""+n.charAt(i));
		}
		if(ans%9==0)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}		

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

#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)

#define INT(n) int n;scanf("%d",&n)
#define VI(v,n) vector<int> v(n);REP(i,n){scanf("%d",&v[i]);}
#define MSET(arr,val)  memset(arr,val,sizeof(arr))

int main(){
  INT(n); VI(ps, n);
  int cnt = 1;
  vector<int> as = ps, bs = ps;
  REP(i, n){
    as[ps[i] - 1] = i;
    bs[ps[i] - 1] = i;
  }
  REP(i, n){
    as[ps[i] - 1] += n * (n + 1) + 1;
    bs[ps[i] - 1] += n * (n + 1) + 1;
  }
  REP(i, 1, n){
    if (as[i - 1] >= as[i] || bs[i - 1] <= bs[i]){
      as[i] = as[i] + cnt * n;
      bs[i] = bs[i] - cnt * n;
      cnt++;
    }
  }
  auto printarr = [](vector<int> arr){
    REP(i, SZ(arr)){
      printf("%d", arr[i]);
      if(i == SZ(arr) - 1){
        printf("\n");
      }
      else {
        printf(" ");
      }
    }
  };
  printarr(as); printarr(bs);
  return 0;
}


Measured memory_bytes: 1024
a, *as = $<.each_line.map {|l| l.split(?,).map(&:to_f) }
p as.each_cons(2).map {|b, c| (a[0] * b[1] + b[0] * c[1] + c[0] * a[1] - a[0] * c[1] - b[0] * a[1] - c[0] * b[1]).abs }.reduce(0, :+) / 2

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

int main(){
  int N;
  cin >> N;
  string P="", Q="";
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    P.append(to_string(x));
  }
  for(int i=0; i<N; i++){
    int y;
    cin >> y;
    Q.append(to_string(y));
  }
  string s="";
  for(int i=1; i<=N; i++){
    s.append(to_string(i));
  }
  int counter=1;
  int place1=-1;
  int place2=-1;
  do{
    if(place1 == -1){
      if(P==s)place1 = counter;
    }
    if(place2 == -1){
      if(Q==s)place2 = counter;
    }
    counter++;
  }while(next_permutation(s.begin(), s.end()));
  int ans = place1 > place2 ? place1-place2: place2-place1;
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N, D;
  cin >> N >> D;
  vector<long long> X(N), Y(N);
  for (int i = 0; i < N; ++i) {
    cin >> X[i] >> Y[i];
  }

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (sqrt(X[i] * X[i] + Y[i] * Y[i]) <= D) {
      ++ans;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6424
fun main(args: Array<String>) {
    val input = readLine()!!
    val t0 = "01".repeat(input.length/2) + if (input.length%2 == 1) "0" else ""
    val t1 = "10".repeat(input.length/2) + if (input.length%2 == 1) "1" else ""

    var a = difCount(input, t0)
    var b = difCount(input, t1)
    print(if(a > b)b else a)
}

fun difCount(input: String, t0: String): Int {
    var count = 0
    for(i in 0 until input.length){
        if(input[i] == t0[i])count++
    }
    return count
}


Measured memory_bytes: 36584
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use proconio::{marker::*, *};
#[fastout]
fn main() {
    input! {
        n:i64,
    }
    let mut ans = 99999999i64;
    for a in 1..n {
        let b = n - a;
        ans.chmin(digsum(b) + digsum(a));
    }
    println!("{}", ans);
}
trait ChMinMax {
    fn chmin(&mut self, x: Self) -> bool;
    fn chmax(&mut self, x: Self) -> bool;
}
impl<T: PartialOrd> ChMinMax for T {
    fn chmin(&mut self, x: Self) -> bool {
        *self > x && {
            *self = x;
            true
        }
    }
    fn chmax(&mut self, x: Self) -> bool {
        *self < x && {
            *self = x;
            true
        }
    }
}
fn digsum(x: i64) -> i64 {
    let mut x = x;
    let mut ret = 0;
    while x > 0 {
        ret += x % 10;
        x /= 10;
    }
    ret
}


Measured memory_bytes: 2088
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
import bisect

n,q = map(int,readline().split())
a = [0] + list(map(int,readline().split()))
x = [0] + list(map(int,read().split()))

cumsum = [0] * (n+1)
cumsum_eo = [0] * (n+1)

for i in range(1,n+1):
    cumsum[i] = cumsum[i-1] + a[i]
    if(i==1):
        cumsum_eo[1] = a[1]
    else:
        cumsum_eo[i] = cumsum_eo[i-2] + a[i]

ans = []
for xi in x[1:]:
    ok = 0
    ng = (n+4)//2
    cnt=0
    while(ng-ok > 1):
        mid = (ng+ok)//2
        if( mid*2-1 > n):
            ng = mid
            continue

        t_l = a[n+1-mid]
        a_r = a[n-mid]
        a_lr = a[n+1-mid*2+1]

        if(t_l - xi < xi-a_lr ):
            ng = mid
        else:
            ok = mid

        cnt+=1

    t_l_ind = n+1-ok
    a_l_ind = n+1-ok*2

    tmp = cumsum[-1] - cumsum[t_l_ind-1]
    if(a_l_ind>1):
        tmp += cumsum_eo[a_l_ind-1]
    ans.append(tmp)
    # print(ng,ok)

print('\n'.join(map(str,ans)))

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

using namespace std;
using i64 = long long;
using f64 = double;

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

template <typename T, typename U>
inline bool chmax(T &a, U b)
{
  return a < b ? (a = b, true) : false;
}

template <typename T, typename U>
inline bool chmin(T &a, U b)
{
  return a > b ? (a = b, true) : false;
}

i64 floor(i64 a, i64 b, i64 x)
{
  return (a * x) / b - a * (x / b);
}

int main()
{
  i64 a, b, n;
  cin >> a >> b >> n;

  auto result = max(
      floor(a, b, n),
      floor(a, b, (n / b) * b - 1));
  
  cout << result << endl;
  return 0;
}


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

n2=n4=0

for a in A:
  if a%4==0:
    n4+=1
  elif a%2==0:
    n2+=1

c1=N//2 <= n4
c2=n4*2+n2 >= N

if c1 or c2:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  std::string S;
  std::cin >> S;
  std::cout << (S[2] == S[3] && S[4] == S[5] ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N,M;cin>>N>>M;
  typedef pair<int,int> P;
  std::vector<P> v(N+1);
  for(int i=0;i<N;i++){
    int a,b;cin>>a>>b;
    v[i]=P(a,b);
  }
  v[N]=P(LINF,-LINF);
  sort(v.begin(),v.end());
  priority_queue<int> pque;
  int now=0,ans=0;
  for(int i=1;i<=M;i++){
    while(v[now].first<=i)pque.push(v[now++].second);
    if(pque.size()){
      int p=pque.top();pque.pop();
      ans+=p;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2936
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 1 << 20;
const int MM = 1000000007;

int lst[MX][26];

int main()
{
	vector<pii> L;
	string S, T;
	int N;
	cin >> N >> S >> T;
	if( S == T ) return !printf("0\n");
	if( S[0] != T[0] ) return !printf("-1\n");
	for(int i = 0; i < 26; i++) lst[0][i] = -1;
	for(int i = 0; i < S.size(); i++){
		if( i ) for(int j = 0; j < 26; j++) lst[i][j] = lst[i-1][j];
		lst[i][S[i]-'a'] = i;
	}
	int rm = T.size()-1, lt = T.size()-1;

	for(int i = T.size()-1; i >= 0; i--){
		if( i == 0 || T[i] != T[i-1] ){
			lt = min(lt, i);
			if( lt < 0 || lst[lt][T[i]-'a'] == -1 ) return !printf("-1\n");
			int cur = lst[lt][T[i]-'a'];
			L.emplace_back(cur, rm);
			lt = cur-1; rm = i-1;
		}
	}
	for(int i = 0; i+1 < L.size(); i++){
		if( L[i+1].first >= L[i].first) return !printf("-1\n");
	}
	reverse(L.begin(), L.end());

	int lst = (int)L.size()-1, ans = 1;
	for(int i = (int)L.size()-2; i >= 0; i--){
		while(lst > i && L[i].second <= L[lst].first - (lst-i)) lst--;
		ans = max(ans, lst-i+1);
	}
	printf("%d\n", ans);
}


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

using namespace std;

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

  int ans = 1;
  for (int b = 2; b <= X; ++b) {
    for (int p = 2; p <= X; ++p) {
      int beki = (int)pow(b, p);
      if (beki > X) {
        continue;
      }
      ans = max((int)pow(b, p), ans);
    }
  }

  cout << ans;
}

Measured memory_bytes: 384
def inpl(): return list(map(int, input().split()))
N, M = inpl()
A = [""]*M
P = [[] for _ in range(N+1)]
for i in range(M):
    p, y = inpl()
    P[p].append((y, i))

for p, prefecture in enumerate(P):
    prefecture = sorted(prefecture, key=lambda x: x[0])
    for j, (y, i) in enumerate(prefecture):
        A[i] = "{}{}".format(str(p).zfill(6), str(j+1).zfill(6))

print(*A, sep="\n")

Measured memory_bytes: 43784
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int n; cin >> n;
    int k = 0;
    rep(i,n){
        int a; cin >> a;
        k ^= a;
    }
    if (k == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int A,B,K,Ans;
    int Xa[100],Xab[100];
    int x;
    int i=0,j=0,k=0;
    scanf("%d%d%d",&A,&B,&K);
    for(x=1;x<=100;x++){
        if(A%x==0){Xa[i]=x;
            i++;
        }}
        
        for(j=0;j<=i-1;j++){
            if(B%Xa[j]==0){
                Xab[k]=Xa[j];
                k++;
            }
        }
            Ans=Xab[k-K];
            printf("%d\n",Ans);
        
        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long n,s;
long long dight(long long x,long long y){
    if(x>y)return y;
    else return dight(x,y/x)+y%x;
}
int main(void){
    cin>>n>>s;
    if(n<s){
        cout<<"-1"<<endl;
        return 0;
    }
    if(n==s){
        cout<<n+1<<endl;
        return 0;
    }
    else{
        for(long long i=2;i<=sqrt(n);i++){
            long long res = dight(i,n);
            if(res==s){
                cout<<i<<endl;
                return 0;
            }
        }
        long long ans = 100000000000;
        for(long long a=1;a<sqrt(n);a++){
            if((n-s)%a)continue;
            long long b = (n-s)/a+1;
            long long res = dight(b,n);
            if(res==s){
                ans=min(b,ans);
            }
        }
        if(ans != 100000000000){
            cout<<ans<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
    return 0;
}


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

int main(){
    int64_t K, S;
    cin >> K >> S;
    int64_t ans = 0;
    for(int x=0; x<=K; x++){
        int64_t mn = max((int64_t)0, S-x-K), mx = min(K, S-x);
        ans += max((int64_t)0, mx-mn+1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define ll long long int
#define FOR(i,a,b) for(ll (i)=(a);i<(ll)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,n)
#define outi(a) printf("%lld\n",(a))
#define prial(a) cout << a << endl;
#define line cout << endl;
#define pb push_back
using namespace std;
inline ll read()
{
    ll x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
    return x;
}
//****************************

int tt;
bool checkit(int a)
{
  if(a < 0) return true;
  return false;
}

//****************************
int solve(int i);
int main()
{
  solve(0);
}
int solve(int qa) 
{
  int a = read();
  int arr[a];
  rep(i,a) 
  {
    int k = read();
    k--;
    arr[k] = i+1;
  }
  rep(i,a) cout << arr[i] << " ";
  cout << endl;
}

Measured memory_bytes: 1152