akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>
// #include <atcoder/all>


using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


#define REP(i, n) for(ll i = 0; i < n; i++)























int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d}) << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()

using namespace std;

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

    ll n,m,a;
    cin >> n >> m;

    priority_queue<ll,vector<ll>,less<ll>> que;
    rep(i,n) cin >> a, que.push(a);

    rep(i,m){
        a = que.top();
        que.pop();
        que.push(a/2);
    }

    ll ans = 0;
    rep(i,n){
        ans += que.top();
        que.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
import java.util.*;


public class Main{
  public static void main(String[] arg){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    int ansA = A * B;
    int ansB = C * D;
    if(ansA <= ansB){
      System.out.println(ansB);
    }else{
      System.out.println(ansA);
    }
  }
}

Measured memory_bytes: 21844
import collections
def MI(): return map(int, input().split())
N,Q=MI()
Edge=[[] for _ in range(N)]
Point=[0]*(N)
for _ in range(N-1):
  a,b=MI()
  Edge[a-1].append(b-1)
  Edge[b-1].append(a-1)
for _ in range(Q):
  p,x=MI()
  Point[p-1]+=x
check=[0]*N
que=collections.deque()
que.append(0)
while que:
  v=que.popleft()
  check[v]=1
  for u in Edge[v]:
    if check[u]==1:
      continue    
    Point[u]+=Point[v]
    que.append(u)  
'''
def dfs(now,pre=-1):
  for nxt in Edge[now]:
    if nxt==pre:
      continue
    Point[nxt]+=Point[now]
    #print(*Point)
    dfs(nxt,now)
dfs(0)
'''
print(*Point)

Measured memory_bytes: 56604
import heapq
from sys import stdin

n,m = map(int,stdin.readline().rstrip().split())
jobs = [[] for i in range(m)]

for i in range(n):
    tmp,tmp2 = map(int,stdin.readline().rstrip().split())
    if(tmp>m):
        continue
    jobs[m-tmp].append(tmp2)
ans = 0
h=[]
for i in range(m-1,-1,-1):
    for b in jobs[i]:
        heapq.heappush(h,-b)
    if(len(h)!=0):
        a = -heapq.heappop(h)
        ans += a
print(ans)

Measured memory_bytes: 18620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABCtest
{
    delegate void Signal();
    class Program
    {
        static void Main(string[] args)
        {
            int A, B;
            string Judg = "Yay!";            
            string[] value = Console.ReadLine().Split(' ');

            if (value.Length == 1) return;
            
            if (!int.TryParse(value[0], out A) | !int.TryParse(value[1], out B)) return;
            else if (A + B > 16 || (A > 8 | B > 8)) Judg =  ":(" ;

            Console.WriteLine(Judg);
            Console.ReadLine();


        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main() {
    long test=1;
    // cin>>test;
    while(test--)
    {
	long i,j,n,a,b,c,d,ans,A,B;
	string s1,s2,s3;
	cin>>n;
	for(i=0;i<n;i++)
	{
	    cin>>s1;
	    mp[s1]++;
	}
	ans=0;
	for(auto x:mp)
	{
	    if(x.second!=0)ans++;
	}
	cout<<ans;
	
    }
	return 0;
}

Measured memory_bytes: 19252
Nm = 0
Na = 0
Nr = 0
Nc = 0
Nh = 0
S = []
N = int(input())
for i in range(N):
  S.append(input())
for i in range(N):
  if S[i][0] == "M":
    Nm += 1
  if S[i][0] == "A":
    Na += 1
  if S[i][0] == "R":
    Nr += 1
  if S[i][0] == "C":
    Nc += 1
  if S[i][0] == "H":
    Nh += 1
s = 0
s += Nm*Na*Nr
s += Nm*Na*Nc
s += Nm*Na*Nh
s += Nm*Nr*Nc
s += Nm*Nr*Nh
s += Nm*Nc*Nh
s += Na*Nr*Nc
s += Na*Nr*Nh
s += Na*Nc*Nh
s += Nr*Nc*Nh
print(s)

Measured memory_bytes: 9772
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugV(v, n) { rep( i, 0, n ) { if(i) printf(" "); printf("%d", v[i]); } printf("\n"); }
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) { if(j) printf(" "); printf("%d", mat[i][j]); } printf("\n"); }
 
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> ii;

int N;
vector <int> adj[100010];
int dist[100010][2];
int A, B;

void dfs1(int u, int last, int d){
	dist[u][0] = d;
	rep(i, 0, adj[u].size()){
		int v = adj[u][i];
		if(v==last) continue;
		dfs1(v, u, d+1);
	}
}

void dfs2(int u, int last, int d){
	dist[u][1] = d;
	rep(i, 0, adj[u].size()){
		int v = adj[u][i];
		if(v==last || dist[v][0]<=d+1) continue;
		dfs2(v, u, d+1);
	}
}

int main(){
	
	scanf("%d %d %d", &N, &A, &B);

	int u, v;
	rep(i, 0, N-1){
		scanf("%d %d", &u, &v);
		adj[u].pb(v);
		adj[v].pb(u);
	}
	
	memset(dist, -1, sizeof dist);
	
	dfs1(B, B, 0);
	dfs2(A, A, 0);
	
	/*
	rep(i, 1, N+1) debug(dist[i][0]);
	puts("***");
	rep(i, 1, N+1) debug(dist[i][1]);
	*/
	
	int ans = 0;
	rep(i, 1, N+1){
		if(dist[i][1]==-1) continue;
		ans = max(ans, dist[i][0]-1);
	}
	
	cout << ans << "\n";
	
	
	return 0;
}

Measured memory_bytes: 12928
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {

  double A, B, P, Q, R;
  double t, b;
  double time;

  cin>>A>>B>>P>>Q>>R;

  t = P * B;
  b = Q * (B-A);
  t = t-b;
  time = (t / (Q+R)) + B;

  printf("%.12f\n", time);

  return 0;
}



Measured memory_bytes: 3284
#include<iostream>
#include<map>
using namespace std;
int main()
{

  while (1){
    int n;
    cin >> n;
    if(n == 0) break;

    map <char,char> a2b;
    char a,b;
    for(int i = 0;i < n; i++){
      cin >> a >> b;
      a2b[a]=b;
    }

    int m;
    cin >> m;
    for(int i = 0;i < m; i++){
      cin >> a;
      if( a2b.count(a) == 0 )
	cout << a;
      else cout << a2b[a];
    }
    cout << endl;
  }

  return 0;

}


Measured memory_bytes: 3092
import java.util.*;

public class Main {
    static int N;
    static int M;
    static int[] k;
    static int[][] s;
    static int[] p;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        k = new int[M];
        s = new int[M][N];
        for (int i = 0; i < M; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                s[i][j] = sc.nextInt();
            }
        }
        p = new int[M];
        for (int i = 0; i < M; i++) {
            p[i] = sc.nextInt();
        }
        //bit
        int ans = 0;
        for (int bits = 0; bits < modPow(2,N); bits++) {
            int b = bits;
            int[] d = new int[N];
            for (int i = 0; i < N; i++) {
                d[i] = b%2;
                b /= 2;
            }
            boolean ok = true;
            for (int j = 0; j < M; j++) {
                int SUM = 0;
                for (int l = 0; l < k[j]; l++) {
                    SUM += d[s[j][l]-1];
                }
                if (SUM % 2 == p[j]) {
                    continue;
                } else {
                    ok = false;
                    break;
                }
            }
            if (ok) ans++;
        }
        System.out.println(ans);

    }

    public static final int MOD = 1_000_000_007;
    public static int[] fact;
    public static int[] invfact;
    /**
     * preCalcFactorials() should be executed beforehand.
     * Calculate nCm modulo to global MOD.
     * @param n
     * @param m
     * @return
     */
    public static int combMod(int n, int m) {
        int ans = modProd(fact[n], invfact[n-m]);
        ans = modProd(ans, invfact[m]);
        return ans;
    }
    /**
     * Calculate a product of 2 integers modulo to mod
     * @param x
     * @param y
     * @param mod modulo
     * @return
     */
    public static int modProd(int x, int y) {
        long ans = ((long) x) * ((long) y); //prevent overflow
        ans %= MOD;
        if (ans < 0) ans += MOD;
        return (int) ans;
    }
    /**
     * Calculate a power of integer modulo to mod
     * @param x
     * @param pow
     * @param mod
     * @return
     */
    public static int modPow(int x, int pow) {
        if (pow == 0) return 1;
        int y = modProd(x,x);
        int ans; 
        if (pow % 2 == 1) {
            ans = x;
        } else {
            ans = 1;
        }
        ans = modProd(ans, modPow(y, pow/2));
        return ans;
    }
    /**
     * Calculate a inverse of an integer modulo to mod, using Fermat's Theorem.
     * Assuming mod is a prime number.
     * @param x
     * @param mod
     * @return
     */
    public static int invMod(int x) {
        return modPow(x, MOD - 2);
    }

    /**
     * x / y modulo MOD global
     * @param x
     * @param y
     * @return
     */
    public static int modDivide(int x, int y) {
        return modProd(x, invMod(y));
    }



}

Measured memory_bytes: 23764
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


bool isOK(ll index, vl a) {
  bool pass = false;
  ll now = a[index];
  
  for(ll i=0; i < ll(a.size()); i++){
    if(!pass and a[index] == a[i]){
      pass = true;
      continue;
    }
    
    if(a[i] <= 2*now) now += a[i];
    else return false;
  }
  
  return true;
}

int binary_search(vl a) {
    ll ng = -1;
    ll ok = (ll)a.size(); 


    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (isOK(mid, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
  ll n; cin >> n;
  cout << (n+1)/2 << endl;
  
  
  
}

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


def main():
    s = input()

    if len(set(s)) == 1:
        print(0)
        exit()

    alphabets = [chr(ord('a') + i) for i in range(26)]
    ans = float('inf')

    for alphabet in alphabets:
        t = s
        count = 0

        while len(t) >= 2:
            t_dash = ''

            for i in range(len(t) - 1):
                if t[i] == alphabet or t[i + 1] == alphabet:
                    t_dash += alphabet
                else:
                    t_dash += t[i]

            count += 1
            t = t_dash

            if len(set(t_dash)) == 1:
                break

        ans = min(ans, count)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
 
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		double x[3], y[3], a1, a2, b1, b2, px, py, r;
		for(int i = 0; i < 3; i++){
			cin >> x[i] >> y[i];
		}
		bool check = true;
		if(y[1]-y[0] == 0){
			px = (x[1]+x[0])/2;
			check = false;
		}else{
			a1 = (x[0]-x[1])/(y[1]-y[0]);
			b1 = (y[1]+y[0])/2-a1*(x[1]+x[0])/2;
		}
		if(y[2]-y[0] == 0){
			px = (x[2]+x[0])/2;
			check = false; 
		}else{
			a2 = (x[0]-x[2])/(y[2]-y[0]);
			b2 = (y[2]+y[0])/2-a2*(x[2]+x[0])/2;
		}
		if(check){
			px = (b2-b1)/(a1-a2);
			py = a1*px+b1;	
		}else if(y[1]-y[0] == 0){
			py = a2*px+b2;
		}else if(y[2]-y[0] == 0){
			py = a1*px+b1;
		}
		r = pow(px-x[0], 2)+pow(py-y[0], 2);
		r = sqrt(r);
		cout << fixed << setprecision(3) << px << ' ' << py << ' ' << r << endl;
	}
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N;cin>>N;
    vector<int>A(N);
    int sum=0;
    REP(i,N){
        cin>>A[i];
        A[i]-=(i+1);
        sum+=A[i];
    }
  	vector<int>C(N);C=A;
  	sort(C.begin(),C.end());
  	int z=C[N/2];
  	int y=C[N/2-1];
  	int ans1=0,ans2=0;
  	REP(i,N){
      	ans1+=abs(A[i]-z);
      	ans2+=abs(A[i]-y);
    }
    cout<<min(ans1,ans2)<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N;
    int A[104];
    cin >> N;
    REP(i,N){
        cin >> A[i];
    }
    bool deny=false;
    REP(i,N){
        if(A[i]%2==0){
            if((A[i]%3!=0)&&(A[i]%5!=0)){
                deny=true;
            }
        }
    }
    
    if(deny){
        cout << "DENIED" << endl;
    }else{
        cout << "APPROVED" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp> 
using namespace std;
 
vector<string> inputVS(void);
 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    long N, A, B;
    cin >> N >> A >> B;
 
    long n = N / (A + B); 
    long remain = N % (A + B);
    long co = n * A;
    if (remain < A){
        co += remain;
    }
    else {
        co += A;
    }
 
    cout << co << "\n";
 
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import Counter

def main():
    N = int(input())
    a = list(map(int,input().split()))
    l = Counter(a)
    d = [0] + [l[i+1] for i in range(10**5)]
    Q = int(input())
    s = sum(a)
    for _ in range(Q):
        B,C = map(int,input().split())
        if d[B] != 0:
            tmp = d[B]
            d[B] = 0
            d[C] += tmp
            s = s - tmp*B + tmp*C
        print(s)




if __name__ == '__main__':
    main()

Measured memory_bytes: 21468
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rf1(i,n) for(int i=n-1;i>=1;--i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  //bitshift works on 32 bit integers only
#define mod (ll)1000000007
#define mod1 (ll)998242353
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;

//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}
//square
ll sq(ll n){
    return n*n;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(b==0){
        return a;
    }    
    else{
        return gcd(b,a%b);
    }
}

//LCM
ll lcm(ll a,ll b){
    if(a==0 || b==0){
        return 0;
    }
    else{
        return((ll)((a*b)/gcd(a,b)));
    }
}

//sort pair by second values
bool sortsec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}
//sort pair by first vals in descending
bool sortinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.first > b.first); 
} 

//Binary Exponentiation
ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

//All Non-Empty SubSequences(O(2*n))
vvi SubSeq;
void allSub(vector<int> arr, int index,vector<int> subarr){
    if (index == arr.size()){ 
        int l = subarr.size(); 
        if (l != 0){
            SubSeq.pb(subarr); 
        }
    } 
    else{ 
        allSub(arr, index + 1, subarr); 
        subarr.push_back(arr[index]); 
        allSub(arr, index + 1, subarr); 
    } 
    return; 
} 

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

    int n,k;
    cin>>n>>k;
    int a[n];
    f(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    int cum=0;
    f(i,k){
        cum+=a[i];
    }
    cout<<cum<<endl;
    


    return 0;
}



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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N, M;
  cin >> N >> M;
  int cnt = 0;
  int A;
  rep (i, M) {
    cin >> A;
    cnt += A;
  }
  if (cnt <= N) {
    cout << N-cnt << endl;
  }
  else
    cout << "-1" << endl;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(){
 long n,S[10000],q,T,cnt=0;

 scanf("%d",&n);
 for(int i=0;i<n;i++){
  scanf("%d",&S[i]);
 }
 scanf("%d",&q);
 for(int i=0;i<q;i++){
  scanf("%d",&T);
  for(int j=0;j<n;j++){
   if(T==S[j]){
    cnt++;
    break;
   }
  }
 }
 printf("%d\n",cnt);
 return 0;
}

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

int main(){
    
    int n,b,c;
    cin >> n>> b>> c;
    int i[100];
    int sum=0;
    
    for(int k=0;k<n;k++){
        cin >> i[k];
    }
    
    for(int j=0;j<n;j++){
        int k=0;
        while(1+i[j]*k<=b){
            sum+=1;
            k+=1;
        }
    }
    
    
    cout << sum+c << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug if (1)

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define pb push_back

const int N = 2e5+7;

int adj[N][2];
int n, m;

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

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a,b);

        if (a == 1)
            adj[b][0] = 1;
        if (b == n)
            adj[a][1] = 1;
    }

    for (int i = 2; i < n; i++) {
        if (adj[i][0] && adj[i][1]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 1792
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))



n=input1()

for i in range(int(math.sqrt(n)) +1,-1,-1):
	if n%i==0: #iがnの約数
		print((i-1) + (n//i -1))
		break









Measured memory_bytes: 23208
#include<bits/stdc++.h>
 
 
int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == (i + 1)){cnt++;i++;}
    }
    std::cout << cnt << std::endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
  int A[5][5];
  for(int i=1;i<=3;i++)
    scanf("%d %d %d",&A[i][1],&A[i][2],&A[i][3]);
  int N;
  scanf("%d",&N);
  int b;
  for(int i=1;i<=N;i++){
    scanf("%d",&b);
    for(int j=1;j<=3;j++){
      for(int k=1;k<=3;k++){
        if(A[j][k]==b) A[j][k]=0;
      }
    }
  }
  int c=0;
  for(int i=1;i<=3;i++){
    if(A[i][1]+A[i][2]+A[i][3]==0) c=1;
    if(A[1][i]+A[2][i]+A[3][i]==0) c=1;
  }
  if(A[1][1]+A[2][2]+A[3][3]==0) c=1;
  if(A[1][3]+A[2][2]+A[3][1]==0) c=1;
  if(c==1) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 1632
c=0
def ans(a):
    global c
    b=a.index(min(a))
    f=min(a)
    a=[i-f for i in a]
    c+=f
    if a[:b]:ans(a[:b])
    if a[b+1:]:ans(a[b+1:])
n=input()
d=list(map(int, input().split()))
ans(d)
print(c)

Measured memory_bytes: 3060
a, b, c, d = map(int,input().split())

diff1 = b - a
diff2 = d - c
l1 = [a, b]
l2 = [c,d]
# if diff1 >= 0 and diff2 >= 0:
#     print(b * d)
# elif
m = 0
sl = []
for i in range(len(l1)):
    for j in range(len(l2)):
        s = l1[i] * l2[j]
        sl.append(s)
        m = max(m, s)
b = False
for l in sl:
    if l > 0:
        b = True

if b == False:
    print(max(sl))
else:
    print(m)


Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cstring>

using namespace std;

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

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

ll bit[11234567], bit_n;

ll bit_sum(int i)
{
    ll s = 0;
    while (i > 0)
    {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void bit_add(int i, int x)
{
    while (i <= bit_n)
    {
        bit[i] += x;
        i += i & -i;
    }
}

int main()
{
    int n, a[112345];

    cin >> n;
    REP(i, n)
    cin >> a[i];

    if (n == 1)
    {
        cout << a[0] << endl;
        return 0;
    }

    ll l = 0;
    ll r = 1e12;
    ll nn = (ll)n * (n + 1) / 2;

    while (r - l > 1)
    {
        ll m = (r + l) / 2;

        ll s[112345];
        s[0] = 0;

        for (int i = 0; i < n; i++)
        {
            if (a[i] >= m)
                s[i + 1] = s[i] + 1;
            else
                s[i + 1] = s[i] - 1;
        }

        for (int i = 0; i <= n; i++)
        {
            s[i] += 112345;
        }

        bit_n = 112345 * 10;
        memset(bit, 0, sizeof(bit));

        ll cnt = 0;

        for (int i = 0; i <= n; i++)
        {
            cnt += bit_sum(s[i]);
            bit_add(s[i], 1);
        }

        if (cnt > nn - (nn / 2 + 1))
            l = m;
        else
            r = m;
    }

    cout << l << endl;

    return 0;
}

Measured memory_bytes: 89216
#include<iostream>
using namespace std;
int main()
{
    int n,t;
    int l[200000];
    int sum;

    cin>>n>>t;
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    sum=t;
    for(int i=1;i<n;i++){
        if(l[i]-l[i-1]>t){
            sum+=t;
        }
        else{
            sum+=l[i]-l[i-1];
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <bitset>
#include <string>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <list>
#include <deque>
using namespace std;
#define INF 10000000
#define LLINF 100000000000000
typedef pair<int, int> P;
typedef long long ll;
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define VSORT(v) sort(v.begin(), v.end());
#define fi first
#define se second
#define out(x) cout << x << endl;
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0,1,0,-1 };
ll MOD = 1000000007;

ll bit[100005] = { 0 };
int n, q;

int sum(int x) {
	ll res = 0;
	while (x > 0) {
		res += bit[x];
		x -= x & -x;
	}
	return res;
}

void add(int x, int a) {
	while (x <= n) {
		bit[x] += a;
		x += x & -x;
	}
}

int main() {
	cin >> n >> q;
	for (int i = 0; i < q; i++) {
		int com, x;
		ll y;
		cin >> com;
		cin >> x >> y;
		if (com == 0) {
			add(x, y);
		}
		else {
			cout << sum(y) - sum(x - 1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3888
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  string s;
  cin >> s;
  int n = s.size() + 1;
  vl left(n, 0), right(n, 0);
  REP(i, 1, n) {
    if (s[i - 1] == '<') {
      left[i] = left[i - 1] + 1;
    } else {
      left[i] = 0;
    }
  }
  for (int i = n - 2; i >= 0; i--) {
    if (s[i] == '>') {
      right[i] = right[i + 1] + 1;
    } else {
      right[i] = 0;
    }
  }
  ll ans = 0;
  rep(i, n) { ans += max(left[i], right[i]); }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  ll dp[100];
  dp[0] = 2;
  dp[1] = 1;
  for (int i = 2; i <= n; ++i) {
    dp[i] = dp[i - 1] + dp[i - 2];
  }

  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
td = sorted([list(map(int, input().split()))
             for _ in range(N)], key=lambda x: x[1], reverse=True)
q = []
v = set()
cnt = 0
for t, d in td[:K]:
    cnt += d
    if t in v:
        q.append(d)
    else:
        v.add(t)
cnt += len(v) ** 2
ans = cnt
for t, d in td[K:]:
    if t not in v and len(q) != 0:
        x = q.pop()
        cnt += d + 2 * len(v) + 1 - x
        v.add(t)
        ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 30776
#include <iostream>
using namespace std;
int main(){
    int n,x;
    cin >> n >> x;
    int l[n];
    for(int i=0;i<n;i++){
        cin >> l[i];
    }
    int d[n+1];
    int sum=1;
    d[0]=0;
    for(int i=0;i<n;i++){
        d[i+1]=d[i]+l[i];
        if(d[i+1]>x){
            break;
        }
        sum++;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}

ll par[105];
ll find(ll x){
    if(par[x]<0)return x;
    return par[x]=find(par[x]);
}
void unite(ll x,ll y){
    x=find(x),y=find(y);
    if(x==y)return;
    par[y]=x;
}

void solve(){
    double eps=1e-8;
    while(1){
        ll n;cin>>n;
        if(n==0)return;
        memset(par,-1,sizeof(par));

        vector<double> x(n),y(n),z(n),r(n);
        rep(i,n)cin>>x[i]>>y[i]>>z[i]>>r[i];
        vector<pair<double,ll> > a;
        vl src,to;
        ll idx=0;
        rep(i,n)fore(j,i+1,n-1){
            a.push_back(pair<double,ll>(sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]))-r[i]-r[j],idx++));
            src.push_back(i);
            to.push_back(j);
        }
        sort(all(a));
        double ans=0;
        rep(i,a.size()){
            if(find(src[a[i].second])!=find(to[a[i].second])){
                ans+=max(0.0,a[i].first);
                unite(src[a[i].second],to[a[i].second]);
            }
        }
        printf("%.3f\n",ans);
    }
}

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



Measured memory_bytes: 3344
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")


def solve(n):
    n = str(n)[-1]
    if n in "24579":
        return "hon"
    elif n in "0168":
        return "pon"
    return "bon"


if __name__ == "__main__":
    n = int_in()
    out(solve(n))

Measured memory_bytes: 61816
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    int H,W,cnt=0,can=1;
    cin >>H>>W;
    vs s(H);
    FOR(i,0,H-1){
        cin >>s[i];
    }
    
    FOR(i,0,H-1){
        FOR(j,0,W-1){
            if(s[i][j]=='#') {
                cnt=0;
                if((i!=0)&&(s[i-1][j]=='#')) cnt++;
                if((j!=0)&&(s[i][j-1]=='#')) cnt++;
                if((i!=H-1)&&(s[i+1][j]=='#')) cnt++;
                if((j!=W-1)&&(s[i][j+1]=='#')) cnt++;
                if(cnt==0) can=0;
            }
        }
    }
    Yn(can);

    return 0;
}

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

const int maxn=405;
const int mod=998244353;
int n,cnt,tot;
int len[maxn],f[maxn][maxn],g[maxn][maxn],dp[maxn][maxn][3];
int h[maxn],c[maxn][maxn],pw2[maxn];
void Add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}

int solve(int l,int r,int low){
	vector<int>v;
	int high=n+1;
	for(int i=l;i<=r;i++)high=min(high,h[i]);
	for(int i=l;i<=r;i++)if(h[i]>high){
		int j=i;
		while(j<=r&&h[j]>high)j++;
		v.push_back(solve(i,j-1,high));
		i=j-1;
	}
	++cnt;
	len[cnt]=r-l+1;
	for(int i=0;i<=high-low;i++)for(int j=0;j<=len[cnt];j++)
		dp[i][j][0]=dp[i][j][1]=dp[i][j][2]=0;
	dp[0][0][0]=dp[0][0][2]=1;
	int sum=0;
	for(int i=0;i<int(v.size());i++){
		sum+=len[v[i]];
		for(int j=sum;j>=0;j--){
			int ndp0=0,ndp2=0;
			for(int k=0;k<=j&&k<=len[v[i]];k++){
				Add(ndp0,1LL*g[v[i]][k]*dp[0][j-k][0]%mod);
				Add(ndp2,1LL*f[v[i]][k]*dp[0][j-k][2]%mod);
			}
			dp[0][j][0]=ndp0;
			dp[0][j][2]=ndp2;
		}
	}
	for(int i=0;i<high-low;i++)for(int j=0;j<=len[cnt];j++){
		for(int tp=0;tp<=1;tp++){
			int cur=dp[i][j][tp];
			if(!cur)continue;
			Add(dp[i+1][j][1],cur);
			for(int k=0;k<=len[cnt]-j;k++){
				int coef=pw2[j]-(k==0);
				Add(dp[i+1][j+k][tp],1LL*cur*coef%mod*c[len[cnt]-j][k]%mod);
			}
		}
		int cur=dp[i][j][2];
		if(!cur)continue;
		for(int k=0;k<=j;k++){
			int coef=pw2[len[cnt]-j]-(k==0);
			Add(dp[i+1][j-k][2],1LL*cur*coef%mod*c[j][k]%mod);
		}
	}
	for(int j=0;j<=len[cnt];j++){
		Add(g[cnt][j],dp[high-low][j][0]);
		Add(g[cnt][j],dp[high-low][j][1]);
		Add(f[cnt][len[cnt]-j],dp[high-low][j][1]);
		Add(f[cnt][j],dp[high-low][j][2]);
	}
	return cnt;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<=n;i++)c[i][0]=1;
	pw2[0]=1;
	for(int i=1;i<=n;i++){
		pw2[i]=2LL*pw2[i-1]%mod;
		for(int j=1;j<=n;j++){
			c[i][j]=c[i-1][j-1];
			Add(c[i][j],c[i-1][j]);
		}
	}
	for(int i=1;i<=n;i++)scanf("%d",&h[i]);
	int ans=solve(1,n,0);
	printf("%d\n",f[ans][0]);
	return 0;
}

Measured memory_bytes: 4096
N, Y = map(int, input().split())
flag = 0
for x in range(N + 1):
  if flag == 1:
    break
  for y in range(N + 1 - x):
    if flag == 1:
      break
    z = N - x - y
    if 10000 * x + 5000 * y + 1000 * z == Y:
      flag = 1
      print(str(x) + ' ' + str(y) + ' ' + str(z))

#出力は１つだけで良い！
if flag == 0:
  print('-1 -1 -1')


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

int main(){
  int n;
  cin>>n;
  int arr[n+1];
  for (int i=1;i<=n;++i)cin>>arr[i];
  int count = 0;
  for (int i=1;i<=n;++i){
    if (i%2!=0 && arr[i]%2!=0)count++;
  }
  cout<<count;
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];

			var chotenCount = new Dictionary<long, long>();

			//頂点　<つながっている点、きょり>
			_mapinfo = new Dictionary<long, List<Tuple<long, long>>>();

			for (int i = 0; i < N-1; i++) {
				var inp= retreiveLongArray();
				var a = inp[0];
				var b = inp[1];
				var kyori = inp[2];

				if (!chotenCount.ContainsKey(a)) {
					chotenCount.Add(a, 1);
					_mapinfo.Add(a, new List<Tuple<long, long>>());
				}
				else {
					chotenCount[a]++;
				}

				if (!chotenCount.ContainsKey(b)) {
					chotenCount.Add(b, 1);
					_mapinfo.Add(b, new List<Tuple<long, long>>());
				}
				else {
					chotenCount[b]++;
				}
				//マップ作製
				_mapinfo[a].Add(new Tuple<long, long>(b, kyori));
				_mapinfo[b].Add(new Tuple<long, long>(a, kyori));

			}

			var qk = retreiveLongArray();
			var Q = qk[0];
			var K = qk[1];

			_kyoriFromK = new Dictionary<long, long>();

			//すべての頂点に対し、Kから距離を調べる
			dFS(K, 0,-1);

			var answers = new List<long>();
			for (int i = 0; i < Q; i++) {
				var inp = retreiveLongArray();
				var a = inp[0];
				var b = inp[1];

				var answer = _kyoriFromK[a] + _kyoriFromK[b];
				answers.Add(answer);
			}
			foreach (var item in answers) {
				Console.WriteLine(item);
			}

		}

		//フィールドの定義
		private static Dictionary<long, List<Tuple<long, long>>> _mapinfo;
		private static Dictionary<long, long> _kyoriFromK;



		private static void dFS(long current, long kyori, long fromChouten) {
			_kyoriFromK.Add(current, kyori);

			var hens = _mapinfo[current];

			foreach (var hen in hens) {
				if (hen.Item1 != fromChouten) {
					dFS(hen.Item1, kyori + hen.Item2, current);
				}
			}

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 66424
n = int(input() )
for i in range(n):
    a, b, c = [int(x) for x in input().split()]
    if (b > a):
        a, b = b, a
    if (c > a):
        a, c = c, a #a = max
    if (b*b + c*c - a*a == 0):
        print("YES")
    else:
        print("NO")
    


Measured memory_bytes: 5604
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int nums[] = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = input.nextInt();
        }
        int count =0;
        for(int i = 1;i<n-1;i++){
            if(nums[i] <= nums[i+1]&&nums[i] >= nums[i-1])
                count++;
            else if(nums[i] >= nums[i+1]&&nums[i] <= nums[i-1])
                count++;
        }
        System.out.println(count);

    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <algorithm>

int T[16][17], T_[1<<16][16];
int dp[1<<16][16];

int main(){
    int N;
    while(scanf("%d", &N), N){
        for(int i=0;i<N;i++){
            for(int j=0;j<=N;j++){
                scanf("%d", &T[i][j]);
            }
        }

        for(int i=0;i<1<<N;i++){
            for(int j=0;j<N;j++){
                int mn = T[j][0];
                for(int k=0;k<N;k++){
                    if(!(i >> k & 1)){continue;}
                    mn = std::min(mn, T[j][k+1]);
                }
                T_[i][j] = mn;
            }
        }

        for(int i=0;i<1<<N;i++){
            for(int j=0;j<N;j++){
                dp[i][j] = i == 0 ? 0 : 1001001001;
            }
        }

        for(int i=0;i<1<<N;i++){
            for(int j=0;j<N;j++){
                for(int k=0;k<N;k++){
                    if(i >> k & 1){continue;}
                    int ni = i | (1 << k);
                    dp[ni][k] = std::min(dp[ni][k], dp[i][j] + T_[i][k]);
                }
            }
        }

        int res = 1001001001;
        for(int i=0;i<N;i++){
            res = std::min(res, dp[(1<<N)-1][i]);
        }

        printf("%d\n", res);
    }
}

Measured memory_bytes: 9204
import sys
from time import time
from random import randint
from numpy import int64

def func(s, x):
    last = [0] * 26
    score = 0
    for i, v in enumerate(x, 1):
        last[v] = i
        c = 0
        for j in range(26):
            c += s[j] * (i - last[j])
        score += s[i * 26 + v] - c
    return score

def main():
    start = time()
    d, *s = map(int, sys.stdin.buffer.read().split())
    s = int64(s)
    x = int64(([*range(26)] * 15)[:d])
    M = func(s, x)
    while time() - start < 1.88:
        y = x.copy()
        if randint(0, 1):
            y[randint(0, d - 1)] = randint(0, 25)
        elif randint(0, 1):
            i = randint(0, d - 16)
            j = randint(i + 1, i + 15)
            y[i], y[j] = y[j], y[i]
        else:
            i = randint(0, d - 15)
            j = randint(i + 1, i + 7)
            k = randint(j + 1, j + 7)
            if randint(0, 1):
                y[i], y[j], y[k] = y[j], y[k], y[i]
            else:
                y[i], y[j], y[k] = y[k], y[i], y[j]
        t = func(s, y)
        if t > M:
            M = t
            x = y
    print(*x + 1, sep='\n')

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('func', 'i8(i8[:], i8[:])')(func)
    cc.compile()

if __name__ == '__main__':
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
    from my_module import func
    main()

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

int waru(int a){
    int cnt=0;
    while(a>0){
        if(a%100==0) cnt++;
        a /= 100;
    }
    return cnt;
}

int main(void){

    int D,N; cin>>D>>N;
    int a = pow(100,D);
    int cnt=0;
    int ans=0;
    while(cnt<N){
        ans += a;
        if(waru(ans)==D) cnt++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    string s;
    ll ans;
    vector<int> r, g, b;

    cin >> n >> s;

    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            r.push_back(i);
        }
        else if (s[i] == 'G')
        {
            g.push_back(i);
        }
        else
        {
            b.push_back(i);
        }
    }

    ans = r.size() * b.size() * g.size();

    for (auto x : r)
    {
        for (auto y : g)
        {
            int i, j;
            i = min(x, y);
            j = max(x, y);

            int res = 0;

            if ((i + j) % 2 == 0)
            {
                if (s[(i + j) / 2] == 'B')
                {
                    res++;
                }
            }

            if (2 * j - i < n)
            {
                if (s[2 * j - i] == 'B')
                {
                    res++;
                }
            }

            if (2 * i - j >= 0)
            {
                if (s[2 * i - j] == 'B')
                {
                    res++;
                }
            }

            ans -= res;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    ll k;
    cin >> k;
    if (k % 2 == 0) {
        cout << -1 << endl;
        ret();
    }

    ll prev = 0;

    map<ll, ll> tmp;

    while (true) {
        ll next = prev;

        next *= 10;
        next += 7;
        next %= k;

        if (tmp.find(prev) != tmp.end()) {
            break;
        }

        tmp[prev] = next;

        prev = next;

    }

    bool b = [&] {
        for (auto e : tmp) {
            if (e.second == 0) {
                return true;
            }
        }

        return false;
    }();


    if (!b) {
        cout << -1 << endl;
        ret();
    }


    int ans = [&] {
        ll prev = 0;
        int a = 0;
        while (true) {
            a++;
            prev = tmp[prev];
            if (prev == 0) {
                return a;
            }
        }
    }();

    cout << ans << endl;

}


Measured memory_bytes: 66120
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main() {
	int x, ans = 0;
	cin >> x;
	if (x == 1) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 2; i < x; i++) {
		int j = 2;
		while (pow(i, j) <= x) {
			if (ans < pow(i, j))ans = pow(i, j);
			j++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
def actual(H, W, A):
    answer = ''

    answer += '#' * (W + 2) + '\n'

    for a in A:
        answer += f'#{a}#\n'

    answer += '#' * (W + 2)

    return answer

H, W = map(int, input().split())
A = [input() for _ in range(H)]

print(actual(H, W, A))

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

void opt(pair<int, int> p){
  cout << setfill('0') << setw(6) << right << p.first;
  cout << setfill('0') << setw(6) << right << p.second;
  cout << endl;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>>ret(m+1); //県,順番
  vector<tuple<int, int, int>>ipt(m+1); //県,年,番号
  for(int i=1; i<=m; i++){
    cin >> get<0>(ipt[i]) >> get<1>(ipt[i]);
    get<2>(ipt[i])=i;
  }
  sort(ipt.begin(), ipt.end());
  int mem=1;
  for(int i=1; i<=n; i++){
    int cnt=1;
    while(mem<=m && get<0>(ipt[mem])==i){
      ret[get<2>(ipt[mem])]=make_pair(i, cnt);
      cnt++;
      mem++;
    }
    if(mem>m)break;
  }
  for(int i=1; i<=m; i++){
    opt(ret[i]);
  }
  return 0;
}

Measured memory_bytes: 3456
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1000 + 5;
const int M = 200000 + 5;

int n, m;
int vis[N], flag;
vector<pair<int, int>> adj[N];
int ans[M];
int minv[N];

void dfs(int u, int mark = 1, int forbid = -1)
{
    if (u == forbid) return;
    if (vis[u]) return;
    vis[u] = mark;
    for (auto e : adj[u]) {
        int v = e.first;
        dfs(v, mark, forbid);
    }
}

void solve()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        --u, --v;
        adj[u].push_back(make_pair(v, i));
    }

    for (int i = 0; i < n; i++) {
        memset(vis, 0, sizeof vis);
        dfs(i);
        for (int u = 0; u < n; u++) {
            if (! vis[u]) continue;
            for (auto e : adj[u]) {
                if (e.first != i) continue;
                ans[e.second] ++;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        memset(vis, 0, sizeof vis);
        for (auto e : adj[i]) {
            dfs(e.first, e.second + 1, i);
        }
        for (int j = 0; j < n; j++) {
            minv[j] = vis[j];
        }
        memset(vis, 0, sizeof vis);
        for (auto e = adj[i].rbegin(); e != adj[i].rend(); e++) {
            dfs(e->first, e->second + 1, i);
        }
        for (auto e : adj[i]) {
            int v = e.first;
            if (e.second + 1 != minv[v] || e.second + 1 != vis[v]) {
                ans[e.second] += 2;
            }
        }
    }

    for (int i = 0; i < m; i++) {
        puts(ans[i] == 3 || ans[i] == 0 ? "same" : "diff");
        //cout << ans[i] % 2 << ' ' << ans[i] / 2 << endl;
    }

}

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



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

int main(){
  int A, B;
  cin >> A >> B;

  if (A < 9 && B < 9){
    cout << "Yay!" << endl;
  }
  else
  {
    cout << ":(" << endl;
  }
  
}

Measured memory_bytes: 3596