akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int N = sc.nextInt();
        var x = new int[N];
        var y = new int[N];
        var h = new int[N];
        for (int i = 0; i < N; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            h[i] = sc.nextInt();
        }

        for (int i = 0; i <= 100; i++) {
            for (int j = 0; j <= 100; j++) {
                var needH  = -1;
                bool hit = true;
                for (int k = 0; k < N; k++) {
                    if (h[k] == 0) continue;
                    var H = Math.Abs(x[k] - i) + Math.Abs(y[k] - j) + h[k];

                    if (needH == -1) {
                        needH = H;
                    } else {
                        if (H != needH) {
                            hit = false;
                            break;
                        }
                    }
                }

                for (int k = 0; k < N; k++) {
                    if (h[k] == 0) {
                        var dist = Math.Abs(x[k] - i) + Math.Abs(y[k] - j);
                        if (needH > dist) {
                            hit = false;
                            break;
                        }
                    }
                }

                if (hit) {
                    WriteLine(i + " " + j + " " + needH);
                    return;
                }
            }
        }
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


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

const int MAX_N = 1e5 + 5;
int A[MAX_N], B[MAX_N];

int main(){
    int n, h; cin >> n >> h;
    for(int i=0;i<n;i++) cin >> A[i] >> B[i];

    sort(A, A+n); sort(B, B+n);
    reverse(A, A+n); reverse(B, B+n);

    int ans = 0;
    for(int i=0;i<n && 0<h;i++){
        if(B[i]<A[0]) break;
        h -= B[i]; ans++;
    }

    if(0<h) ans += (h+A[0]-1) / A[0];
    cout << ans << endl;
    return 0;   
}


Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]

fn main() {
    input!{
        n: usize,
        b: [i32; n - 1],
    }
    let mut ans = b[0] + b[n - 2];
    for i in 0..(n - 2) {
        ans += min(b[i], b[i + 1]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int x;
    cin >> x;
    int cnt = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (500 * i + 100 * j + 50 * k == x) {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main() {
  int x, n; cin >> x >> n;
  vector<int> a(111);
  rep(i, n) {
    int p; cin >> p;
    a[p]++;
  }
  int d = 0;
  while (1) {
    if (a[x-d] == 0) {
      cout << x - d << endl;
      return 0;
    }else if (a[x+d] == 0) {
      cout << x + d << endl;
      return 0;
    }
    d++;
  }
  return 0;
}

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

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11


int main()
{
    string s,t; cin >> s >> t;
    int cnt = 0;
    rep(i,s.size()){
        if(s[i] != t[i]) cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 3916
from collections import Counter as ct

n = int(input())
s = input().split()
a = ct(s[::2])
b = ct(s[1::2])
sa = sorted(a.items(), key=lambda x: -x[1])
sb = sorted(b.items(), key=lambda x: -x[1])
if sa[0][0] == sb[0][0]:
    if len(sa)*len(sb)==1:
        dt=n//2
    elif sa[0][1] - sa[1][1] < sb[0][1] - sb[1][1] or len(sb)==1:
        dt = sa[1][1] + sb[0][1]
    else:
        dt = sa[0][1] + sb[1][1]
else:
    dt = sa[0][1] + sb[0][1]
print(sum([x for x in a.values()]+[y for y in b.values()])-dt)


Measured memory_bytes: 25572
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,x,t;
  cin >> n >> x >> t;
  long long int time=0;
  if(n%x==0){
    time=(n/x)*t;
  }else{
    time=((n/x)+1)*t;
  }
  cout << time << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        long MOD = 1_000_000_007;
        long ans = 1;
        int[] c = new int[3];
        for (int i = 0; i < n; i++) {
            long cnt = 0;
            int id = -1;
            if (a[i] == c[0]) {
                cnt++;
                id = 0;
            }
            if (a[i] == c[1]) {
                cnt++;
                id = 1;
            }
            if (a[i] == c[2]) {
                cnt++;
                id = 2;
            }
            if (id == -1) {
                System.out.println(0);
                return;
            }
            ans *= cnt;
            c[id]++;
            ans %= MOD;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 51108
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

vector<int> G[1 << 17];
bool used[1 << 17];
int col[1 << 17];

bitset<100001> b;

void solve() {
	int n, m; cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<P> v;
	rep(i, n) {
		if (used[i])continue;
		int c[2] = {};
		int id = 0; queue<int> q;
		q.push(i); used[i] = true; col[i] = 0;
		while (!q.empty()) {
			id ^= 1;
			int len = q.size();
			c[id^1] += len;
			rep(aa, len) {
				int v = q.front(); q.pop();
				rep(j, G[v].size()) {
					int to = G[v][j];
					if (used[to]) {
						if (col[to] == col[v]) {
							cout << -1 << endl; return;
						}
						continue;
					}
					used[to] = true; col[to] = id;
					q.push(to);
				}
			}
		}
		v.push_back({ c[0],c[1] });
	}
	b[0] = 1;
	rep(i, v.size()) {
		b = (b << v[i].first) | (b << v[i].second);
	}
	ll ans = 0;
	rep(i, n + 1) {
		if (b[i]) {
			//cout << i << endl;
			ans = max(ans,(ll)i*(n - i) - m);
		}
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 10552
using System;
using System.Linq;
public class Program {
  public static void Main() {
    int N = int.Parse(Console.ReadLine());
    string[] words = new string[N];
    char latest = '.';
    for (int i = 0; i < N; i++) {
      words[i] = Console.ReadLine();
      if (words.Count(x => x == words[i]) == 2 ||
        (latest != '.' && latest != words[i][0])) {
        Console.WriteLine("No");
        return;
      }
      latest = words[i][words[i].Length-1];
    }
    Console.WriteLine("Yes");
  }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define v(x) vector<int> x;
#define all(x) x.begin(),x.end()
#define s(x,n) memset(x,n,sizeof(x));
#define pb(x) push_back(x)

using namespace std;
int main()
{   fast 
    ll n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<n;i++)
    {
        cout<<s[i]<<t[i];
    }
    cout<<"\n";
    return 0;
}

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

int main() {
  ll N;
  cin >> N;
  ll ans = 0;

  // NlogN + N
  // vector<int> F(N + 1, 0);
  // for (ll i = 1; i <= N; i++) {
  //   ll j = 1;
  //   while (i * j <= N) {
  //     F.at(i * j)++;
  //     j++;
  //   }
  // }
  // for (ll i = 1; i <= N; i++) {
  //   ans += i * F.at(i);
  // }

  // NlogN
  for (ll i = 1; i <= N; i++) {
    ll j = 1;
    while (i * j <= N) {
      ans += i * j;
      j++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<math.h>
#define ll long long

int main(){
  ll n,i,p[200001],min=200001,cnt=0;
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&p[i]);
    if(p[i]<min){
      min=min<p[i]?min:p[i];
      cnt++;
    }
  }
  printf("%lld",cnt);
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int m[n+1]={0};
for(int i=0;i<n-1;i++){
  int x;
  cin>>x;
  m[x]++;
}
for(int i=1;i<=n;i++) cout<<m[i]<<endl;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000009
const long long INF = 1LL<<29;

int main() {
    int n,m;
    cin>>n>>m;
    map<int,int> mp;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        mp[a]++;
        mp[b]++;
    }

    bool ok=true;
    for( auto i = mp.begin(); i != mp.end() ; ++i ) {
        int x=i->second;
        if(x%2==1) ok=false;
    }
    if(ok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnPreOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnInOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnInsert(StNode*& rpoRoot, StNode* poNewNod)
{
  StNode* poParnt = nullptr;
  StNode* poNode = rpoRoot;

  while (poNode != nullptr)
  {
    poParnt = poNode;
    if (poNewNod->m_nKey < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;
  }

  poNewNod->m_poParnt = poParnt;
  if (poParnt == nullptr)
    rpoRoot = poNewNod;
  else if (poNewNod->m_nKey < poParnt->m_nKey)
    poParnt->m_poLeft = poNewNod;
  else
    poParnt->m_poRigt = poNewNod;
}

void fnBinSchTree(StNode* poRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(poRoot, poNewNod);
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(poRoot);
      cout << endl;
      fnPreOrder(poRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
  fnPstOrder(poRoot);
}

Measured memory_bytes: 26572
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define mii map<int,int>
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main() {
	io;
	int n;
  	cin>>n;
  	cout<<n*n*n;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
c = []
c.append(S.count('.'))

for i in range(1, N+1):
  if S[i-1] == '#':
    c.append(c[i-1] + 1)

  if S[i-1] == '.':
    c.append(c[i-1] - 1)   

print(min(c))

Measured memory_bytes: 11464
n = gets.chomp.to_i

ans = 0

1.upto(n) do |i|
  next if i.even?
  d = 0
  1.upto(i) do |j|
    if i % j == 0
      d += 1
    end
  end
  if d == 8
    ans += 1
  end
end
puts ans

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

H,W = list(map(int, input().rstrip().split()))
a_list = [input().strip() for _ in range(H)]
#-----

for i in range(H+2):
    if i==0 or i==(H+1):
        print( "#"*(W+2) )
    else:
        print("#" + a_list[i-1] + "#")


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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


int main() {
  int N, Y;
  cin >> N >> Y;
  REP(i, N + 1) {
    // 1万円がi枚と仮定する
    int y = Y - 10000 * i;
    if (y > (N - i) * 5000)
      continue;
    REP(j, N - i + 1) {
      int rest = Y - (10000 * i + 5000 * j);
      if (rest == (N - i - j) * 1000) {
        cout << i << " " << j << " " << N - i - j << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


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

int main() {
  // (6 <= i) && (5 <= i && i -1 <= i)

  int n;
  cin >> n;

  int h[21];
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  int ans = 1;
  for (int i = 1; i < n; i++) {
    bool ok = true;
    for (int j = 0; j < i; j++) {
      if (h[j] > h[i]) {
        ok = false;
      }
    }
    if (ok) {
      ans++;
    }
  }

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

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

class point{
public:
  int x, y;
};

void solve(){
  vector<point> p(4);
  cin >> p[0].x >> p[0].y >> p[1].x >> p[1].y;
  int x = p[1].x - p[0].x;
  int y = p[1].y - p[0].y;
  p[2].x = p[1].x - y;
  p[2].y = p[1].y + x;
  p[3].x = p[0].x - y;
  p[3].y = p[0].y + x;
  cout << p[2].x << " " << p[2].y << " " << p[3].x << " " << p[3].y << endl;
  return;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define DEF_ELEM_MAX 10001

int count=0;

int A[DEF_ELEM_MAX];
int n;

void Linear(int key)
{
	int k=0;
	A[n]=key;
	while(A[k] != key){
		k++;
	}

	if( k == n) return;

	count++;
	return ;
}

int main( void )
{
	int i;
	int j;
	int t;
	int q;

	scanf("%d",&n);

	for( i = 0; i < n; i++){
		scanf("%d", &A[i]);
	}

	scanf("%d",&q);
	for(j=0;j<q;j++){
		scanf("%d", &t);
		Linear(t);
	}

	printf("%d\n",count);
	return 0; 
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int k;
	cin >> k;
	int c = 1;
	int seq = 7;
	map<int, int> mods;
	while (seq % k != 0)
	{
		seq = (seq * 10 + 7) % k;
		if (mods.count(seq) > 0)
		{
			cout << -1;
			return 0;
		}
		mods[seq] = 1;
		c++;
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 50512
D = [[[0 for V in range(10)] for F in range(3)] for B in range(4)]

n = int(input())

for i in range(n):
    b,f,r,v = map(int,input().split())
    D[b-1][f-1][r-1] += v

for B in D[:-1]:
    for F in B:
        print(' ' + ' '.join(map(str,F)))
    print('#'*20)
for F in D[-1]:
    print(' ' + ' '.join(map(str,F)))

Measured memory_bytes: 7736
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

int main() {
    string a, b; cin >> a >> b;
    double combined = stoi(a + b);
    Yes(sqrt(combined) == floor(sqrt(combined)));
    return 0;
}

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

int main(){
  string n,m,ans,l;
  cin >> n;
  l="hi";
  ans="Yes";
  while(n.size()!=0){
    m=n.substr(0,2);
    n.erase(0,2);
    if(m!=l){
      ans="No";
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}



int main() {
	long long int X;
	cin >> X;
	int c = 0;
	long long int y = 100;
	while (1) {
		if (y < X) {
			y = (long long int)(y*1.01);
			c++;
		}
		else
			break;

	}
	cout << c;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	char c;
	cin>>c;
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
		cout<<"vowel"<<endl;
	}else{
		cout<<"consonant"<<endl;
	}
	return 0;
}

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

using namespace std;

#define ll long long
const int N = 300005;

int n, a[10],cnt ,f, x[10], y[10], orderx, ordery;

int main()
{
    cin >>  n;
    for ( int i=1; i<=n; i++)a[i]= i, cin >>x[i];
    for ( int i=1; i<=n; i++) cin >>y[i];

    do {
        cnt++, f=1;
        for ( int i=1; i<=n; i++) if (a[i]!=x[i]) f=0;
        if (f) orderx = cnt;

        f=1;
        for ( int i=1; i<=n; i++) if (a[i]!=y[i]) f=0;
        if(f) ordery = cnt;

    }while (next_permutation(a, a+n+1));

    cout << abs(orderx-ordery);
    return 0;
}


Measured memory_bytes: 3608
n, x = map(int, input().split())
lst = [int(i) for i in input().split()]

bound = [0]
for i in range(1, n+1):
    if i == 1:
        bound.append(lst[i-1])
    else:
        b = bound[i-1] + lst[i-1]
        bound.append(b)

ans = []
for i in bound:
    if i <= x:
        ans.append(i)

print(len(ans))

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

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (v).begin(),(v).end()
#define prin(a) cout << #a << " = " << a<< endl
#define all(v) (v).begin(),(v).end()
typedef long long ll;

const int N = 3e3+10;
ll dp[2][N], v[N];
#define cur_dp dp[(i+1)&1]
#define ant_dp dp[i&1]
const ll MOD = 998244353;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	ll n, s; cin >> n >> s;
	fr(i,n) cin >> v[i];
	
	dp[0][0] = 1;
	fr(i,n){
		for(int j = 0; j<=s; j++){
			cur_dp[j] = 2*ant_dp[j]%MOD;
			if(v[i]<=j) cur_dp[j] = (ant_dp[j-v[i]]+cur_dp[j])%MOD;	
		}
	}
	cout << dp[n&1][s] << endl;
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
 
char *flag;
int head,rear;
int *que;
int factorial[10];
 
int cal_factorial(int n) {
  if(n == 0) return 1;
  return cal_factorial(n-1)*n;
}
 
int stotag(char *s) {
  int tag = 0;
  int i;
  for(i = 0; i < 9; i++) {
    int t,j;
    t = 0;
    for(j = 0; j < i; j++) {
      if(s[j] < s[i]) t++;
    }
    tag += factorial[8-i]*(s[i]-'0'-t);
  }
  return tag;
}
 
char *tagtos(int tag) {
  int i;
  char *s;
  s = (char*)malloc(sizeof(char)*10);
  for(i = 0; i < 9; i++) {
    s[i] = tag%factorial[9-i]/factorial[8-i] + '0';
  }
  s[9] = '\0';
  for(i = 7; i >= 0; i--) {
    int j;
    for(j = 8; j > i; j--) {
      if(s[i] <= s[j]) s[j]++;
    }
  }
  return s;
}
 
 
char *move_up(char s[], int x) {
  if(x < 3) return NULL;
  char *s_new;
  s_new = (char*)malloc(sizeof(char)*10);
  strcpy(s_new,s);
  s_new[x] = s[x-3];
  s_new[x-3] = s[x];
  return s_new;
}
 
char *move_left(char s[], int x) {
  if(x%3 == 0) return NULL;
  char *s_new;
  s_new = (char*)malloc(sizeof(char)*10);
  strcpy(s_new,s);
  s_new[x] = s[x-1];
  s_new[x-1] = s[x];
  return s_new;
}
 
char *move_right(char s[], int x) {
  if(x%3 == 2) return NULL;
  char *s_new;
  s_new = (char*)malloc(sizeof(char)*10);
  strcpy(s_new,s);
  s_new[x] = s[x+1];
  s_new[x+1] = s[x];
  return s_new;
}
 
char *move_down(char s[], int x) {
  if(x > 5) return NULL;
  char *s_new;
  s_new = (char*)malloc(sizeof(char)*10);
  strcpy(s_new,s);
  s_new[x] = s[x+3];
  s_new[x+3] = s[x];
  return s_new;
}
 
int create(char s[], int t) {
  if(strcmp(s,"123456780") == 0) return t;
  int tag = stotag(s);
  if(flag[tag]) return 0;
  flag[tag] = t;
  que[rear] = tag;
  rear++;
  return 0;
}
 
int check_x(char *s) {
  int i = 0;
  while(s[i] != '0') i++;
  return i;
}
 
int cal() {
  char *s_right,*s_left,*s_up,*s_down;
  int k,tag;
 
  tag = que[head];
  char *s = tagtos(tag);
  int x = check_x(s);
   
  if((s_right = move_right(s, x)) != NULL) {
    if((k = create(s_right,flag[tag]+1))) return k;
    free(s_right);
  }
  if((s_left = move_left(s, x)) != NULL) {
     if((k = create(s_left,flag[tag]+1))) return k;
     free(s_left);
  }
  if ((s_up = move_up(s, x)) != NULL) {
    if((k = create(s_up,flag[tag]+1))) return k;
    free(s_up);
  }
  if((s_down = move_down(s, x)) != NULL) {
    if((k = create(s_down,flag[tag]+1))) return k;
    free(s_down);
  }
  free(s);
  head++;
  return 0;
}
   
 
int solve(char s0[]) {
  int k;
  if((k = create(s0,1))) return k;
   
  while(!(k = cal())) {
    if(head == rear) break;
  }
  return k;
}
 
int main()
{
 
  int i,d;
  char s[10];
  for(i = 0; i < 10; i++) factorial[i] = cal_factorial(i);
  flag = (char*)malloc(sizeof(char)*factorial[9]);
  memset(flag , 0, factorial[9]);
  que = (int*)malloc(sizeof(int)*factorial[9]);
  head = 0;
  rear = 0;
  for (i = 0; i < 9; i++) {
    scanf("%d", &d);
    s[i] = d+'0';
  }
  s[9] = '\0';
  printf("%d\n",solve(s)-1);
   
  return 0;
}


Measured memory_bytes: 2860
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	ll a,b;cin>>a>>b;
	ll res=(a*b)/gcd(a,b);
	cout<<res;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath> 
#include <tuple>
#include <bitset>
#include <string>
// #include <sstream>
// #include <iomanip>
//pair sort firstに揃う

#define int long long
#define double long double
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define PairV vector<pair<int , int> >
#define F first
#define S second
#define Vector1 vector<int>
#define VectorS vector<string>
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define incin2(n,m) int (n),(m); cin >> (n)>>(m);
#define dcin(n) double (n); cin >> (n);
#define dcin2(n,m) double (n),(m); cin >> (n) >> (m);
#define stcin(s) string (s); cin>>(s);
#define all(v) (v).begin() , (v).end()
namespace Mathf
{
    const int INF = 1000000000000;
    const double PI = 3.14159274;
    const double Rad2Deg = 57.29578;
    const double log2(double a,double b);
    const double log2(double a,double b){
        return log(b)/log(a);
    }
} // namespace Mathf

using namespace std;

int MD(pair<int,int> a,pair<int,int> b){//ManhattanDisRance
    return abs(a.first-b.first) + abs(a.second-b.second);
}
int MOD(int a,int b){
    return abs(a%b);
}
template <typename T1,typename T2> bool Comp (pair<T1,T2> a,pair<T1,T2> b){
    if(a.first!=b.first){
        return a.first<b.first;//first昇順
    }
    if(a.second!=b.second){
        return a.second > b.second;//second降順
    }else{
        return  true;
    }
}
template <typename T1> bool In (vector<T1> v,T1 x){
    for(int i=0;i<v.size();i++){
        if (v[i]==x){
            return true;
        }
    }
    return false;
}
double Dis(pair<int,int> a,pair<int,int> b){
    return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}
int Step(int N){
    if(N==0){
        return 1;
    }else{
        return N*Step(N-1);
    }
}
int GCM(int a,int b){
    if(a<b){
        swap(a,b);
    }
    int r = a%b;
    while (r!=0)
    {
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int LCM(int a,int b){
    return a*(b/GCM(a,b));
}

int Pemu(int n,int r){
    int ans = n;
    for(int i=1;i<r;i++){
        ans*=(ans-i);
    }
    return ans;
}
int Comb(int n,int m){
    int a=n,b=m;
    for(int i=1;i<m;i++){
        a *= (a-i);
    }
    for(int i=1;i<m;i++){
        b *= (b-i);
    }
    
    return a/b;
}
int Sigma(int n){
    if(n==1){
        return 1;
    }else{
        return n + Sigma(n-1);
    }
}
int Digit(int x){
    string ss = to_string(x);
    int size = ss.size();
    int sum = 0;
    for(int i=0;i<size;i++){
        sum+=ctoi(ss[i]);
    }
    return sum;
}
class Menu{
    public:
        int t;
        int rt;
        int sc;
};
signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    incin2(a,b);
    cout<<LCM(a,b)<<endl;
    return 0;
}


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

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}

int main() {
    int n,m,sum=0;
    cin>>n>>m;

    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }

    int cnt=0,jdg=(sum+4*m-1)/(4*m);
    rep(i,n){
        if(a[i]>=jdg){cnt++;}
    }

    if(cnt>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import sys
import math
import time
sys.setrecursionlimit(20000)
INT_MAX = 2**31 - 1

def update(tree,x,y,z,N):
    left = x + N #- 1
    right = y + N#- 1

    while True:
        if(left >= right):
            break
        if(right % 2 == 1):
            right -= 1
            tree[right - 1] = z
        if(left % 2 == 1):
            tree[left - 1] = z
            left += 1

        #left += 1#math.floor((left + 1)/2)
        #right -= 1#math.floor((right - 1)/2)
        left >>= 1
        right >>= 1

def find(tree,x,N):
    x += N - 1
    s = (INT_MAX, -1)
    while True:
        if(x < 0):
            break
        if(tree[x][0] is not None and (tree[x][1] > s[1])):
            s = tree[x]
        x = math.floor((x - 1)/2)
    return s[0]

if __name__ == '__main__':
    _N,query_num = map(int, input().split())
    N = 1
    while True:
        if(N >= _N):
            break
        N *= 2
    A = [(None,-1)]*(2*N - 1)

    #start = time.time()
    for i in range(query_num):
        query = list(map(int,input().split()))
        # update
        if(query[0]==0):
            update(A,query[1],query[2]+1,(query[3],i),N)
            #print(A)
        # find
        if(query[0]==1):
            #z = find(A,lazy_A,query[1],query[1]+1,0,0,N,N)
            z = find(A,query[1],N)
            print(z)
    #elapsed_time = time.time() - start
    #print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")



Measured memory_bytes: 11860
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

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


Measured memory_bytes: 256
//____________________________________________________________________
  //________________________________NAMAN_______________________________
 //________________________________TALAYCHA______________________________
//_________________________________________________________________________

#include <bits/stdc++.h>
#define ll              long long
#define int             long long
#define pmin            priority_queue < ll, vector<ll>, greater<ll> >
#define pmax            priority_queue <ll>
#define endl            '\n'
#define mii             map<ll , ll >
#define pii             pair< ll, ll >
#define vi              vector<ll>
#define all(a)          (a).begin(), (a).end()
#define DEBUG           cerr<<"/n>>>I'm Here<<</n"<<endl;
#define rep(i, a, b )   for (ll i = a; i < b; i++)
#define rrep(i, a, b)   for (ll i = a; i >= b; i--)
#define bs              binary_search
#define present(c, x)   ((c).find(x) != (c).end())
#define cpresent(c, x)  (find(all(c), x) != (c).end())
#define p1(i)           cout<<i<<endl;
#define p2(i,j)         cout<<i<<" "<<j<<endl;
#define line            cout<<endl;
#define prt(s,b,n)      rep(i,(b),(n)) { cout<<(s)[i]<<" ";} line
#define lower(u)        transform(u.begin(), u.end(), u.begin(), ::tolower);  //convert string u to lowercase;
#define upper(u)        transform(u.begin(), u.end(), u.begin(), ::toupper);
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define hell 1e6+3
#define mod 998244353

using namespace std;

//_________________________________________________________________________________________________________
//__________________________________________START____________________________________________________________

//................EVERY COIN HAS TWO SIDES...............................................................................................................
ll N=100005;
vector<ll> g[100005];
ll vis[100005];
ll d[100005];
ll ans=0;
ll dfs(ll u, ll p)
{
    if(d[u]) return d[u];
   for(auto v : g[u])
   {  
      if(v==p) continue;
      d[u]=max(d[u],1+dfs(v,u));
   }
   ans=max(ans,d[u]);
   return d[u];
}

void solve()
{
  ll n,m,u,v; 
  cin>>n>>m;
  rep(i,0,m)
  {cin>>u>>v;
    g[u].push_back(v);
  } 
  rep(i,1,n+1) d[i]=0;

  rep(i,1,n+1)
  dfs(i,-1);
 p1(ans)

}

//__________________________________________________________________________________________________________
//__________________________________________END______________________________________________________________

signed main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  #ifndef ONLINE_JUDGE 
  freopen("input.txt" , "r", stdin);
  freopen("out12.txt" , "w", stdout);
  #endif  

  ll TESTS = 1;
 //  cin>>TESTS;
  while (TESTS--) 
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 11916
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

vector<vector<long long>> comb(int n, int r) {
  vector<vector<long long>> v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main(void){
    int n;
    cin >> n;
    map<string, int> m;
    ll ans=0;
    REP(i,n){
        string s;
        cin >> s;
        sort(ALL(s));
        if(m.count(s)!=0){
            ans+=m[s];
            m[s]++;
            continue;
        }
        m[s]=1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 11336
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a[5];
  int ans=0;
  int mn=9,mnpn=0;
  rep(i,5){
    cin>>a[i];
    if(mn>a[i]%10 && a[i]%10!=0){mnpn=i;mn=a[i]%10;}
  }
  rep(i,5){
    if(i!=mnpn){
      ans+=a[i];
      if(a[i]%10!=0) ans+=10-(a[i]%10);
    }
    //cout<<ans<<endl;
  }
  ans+=a[mnpn];
  cout<<ans<<endl;
  
  

  return 0;
}


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

using namespace std;
typedef long long ll;
const int N = 1e5+5;
const ll oo = 1e18;
const ll mod = 1e9+7;
const int INF = 1 << 30;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
    
    string s;
    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
    
    return 0;
}

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

using namespace std;

int wy[1000010];
int tab[510];
int zuzyte[510];

priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> kol;
queue<pair<int, int>> kol2;

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

    int n;
    cin >> n;
    for( int a, i=1; i<=n; i++ ) {
        cin >> a;
        wy[a] = i;
        tab[i] = a;
        zuzyte[i] = i-1;
        if( i != 1 )
            kol.push( {a, i} );
    }
    for( int i=1; i<=n*n; i++ ) {
        if( wy[i] ) {
            if( zuzyte[ wy[i] ] != 0 ) {
                cout << "No";
                return 0;
            }
            if( wy[i] != n )
                kol2.push( {n-wy[i], wy[i]} );
            continue;
        }

        if( !kol.empty() ) {
            wy[i] = kol.top().second;
            zuzyte[kol.top().second]--;
            if( zuzyte[kol.top().second] == 0 ) {
                kol.pop();
            }
        } else if( !kol2.empty() ) {
            wy[i] = kol2.front().second;
            kol2.front().first--;
            if( kol2.front().first == 0 ) {
                kol2.pop();
            }
        } else {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes\n";
    for( int i=1; i<=n*n; i++ ) {
        cout << wy[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int r,D,st;
  cin >> r >> D >> st;
  
  long long int ne = st;
  for(long long int i=0;i<10;i++){
     ne =  (ne*r)-D;
     cout << ne << endl;;
  }
}


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

void solve() 
{
    int n,T=0,X=0,Y=0;cin>>n;
    REP(i,n){
        int t,x,y;cin>>t>>x>>y;
        int tt=t-T;
        int sum=abs(X-x)+abs(Y-y);
        if(tt>=sum&&(tt-sum)%2==0){
            T=t;X=x;Y=y;
        }else{
            cout<<"No"<<endl;
            return;
        }
    }cout<<"Yes"<<endl;
}

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

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

int main() {
  int n;
  cin >> n;
  vector<int>a(n),b(n),c(n-1);
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
  }
    for(int i = 0;i < n;i++){
    cin >> b.at(i);
  }
    for(int i = 0;i < n-1;i++){
    cin >> c.at(i);
  }
  
  int ans = 0;
  for(int i = 0;i < n;i++){
    ans += b.at(a.at(i)-1);
    if(i < n-1){
      if(a.at(i)+1 == a.at(i+1)){
        ans += c.at(a.at(i)-1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

def solve():
    N = int(readline())
    A = list(map(int, readline().split()))

    money = 1000
    stock = 0
    for i in range(N):
        if i == N - 1:
            money += stock * A[i]
        else:
            if A[i + 1] > A[i]:
                inc_stock = money // A[i]
                stock += inc_stock
                money -= inc_stock * A[i]
            else:
                money += stock * A[i]
                stock = 0
    
    print(money)

solve()


Measured memory_bytes: 62004
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int x; cin >> x;
    int ret = 1;

        for (int i = 1; i <= x; i++) {
            for (int j = 2; j <= x; j++) {
                if (pow(i, j) > x) break;
                // cout << "i: " << i << "j: " << j << endl;
                ret = max(ret, int(pow(i, j)));
            }
        // for (int i = 1; i <= x;i++) {
        //     if (i > x) break;
        //     for (int j = 2;;j++) {
        //         if (pow(i, j) > x) break;
        //         ret = max(ret, int(pow(i, j)));
        //     }
        // }
    }

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

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    if ( N == 1 ) {
        cout << "1" << endl;
        return 0;
    }
    int cnt = 1;
    int sum = 0;
    while (N > sum) {
        sum += cnt;
        cnt++;
        //dump(sum);
    }
    int tmp = 1;
    while (cnt > 1) {
        if (tmp != sum - N) {
            cout << tmp << endl;
        }
        cnt--;
        tmp++;
    }

    

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_B&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        H, W = map(int, input().split())
        if H == 0 and W == 0:
            break

        print('#' * W)
        for _ in range(H - 2):
            print('#' + '.'*(W-2) + '#')
        print('#' * W)
        print()


if __name__ == '__main__':
    main(sys.argv[1:])
    

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

using namespace std;

#define all(x) x.begin(), x.end()
#define endl '\n'
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

const int N = 1e5 + 5;
vector<vector<int>>g(N);
bool vis[N];
int p[N];
vector<int>pos, val;
void dfs(int nd){
	vis[nd] = 1;
	pos.emplace_back(nd);
	val.emplace_back(p[nd]);
	for(auto ch: g[nd]){
		if(vis[ch])continue;;
		dfs(ch);
	}
}

int main(){
	IO;

	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> p[i];
	for(int i = 0; i < m; i++){
		int u, v; cin >> u >> v;
		g[u].emplace_back(v);
		g[v].emplace_back(u);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(vis[i])continue;
		pos.clear();
		val.clear();
		dfs(i);
		sort(all(pos));
		sort(all(val));
		while(pos.size() && val.size()){
			if(pos.back() == val.back())
				ans++, pos.pop_back(), val.pop_back();
			else if(pos.back() > val.back())
				pos.pop_back();
			else if(val.back() > pos.back())
				val.pop_back();
		}
	}
	cout << ans;

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  int min = 99999999;
  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    
    int dev_cnt = 0;
    while(a % 2 == 0) {
      a /= 2;
      dev_cnt += 1;
    }
    if(dev_cnt <= min)
      min = dev_cnt;
  }
  
  cout << min << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k;
    cin >> k;

    int count = 0;
    for(int i=1;i<k;i++){
        for(int j=i+1;j<=k;j++){
            if((i%2==0 and j%2!=0) or (i%2!=0 and j%2==0)) {
                count++;
                //cout << i << " " << j << endl;
            }
        }
    }
    
    cout << count;
}


Measured memory_bytes: 3580
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return
    maxans = 10 ** 18
    ans = 1
    for i in a:
        ans *= i
        if ans > maxans:
            print(-1)
            return
    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 21476
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>

using namespace std;


#include <math.h> 


int main() {

	int64_t N;
	cin >> N;
	vector<int64_t> A(N);

	for (int i= 0; i < N; i++) {
		cin >> A[i];
	}

	sort(A.begin(), A.end(), std::greater<int64_t>());

	int64_t comfortable = 0;

	if (N % 2 != 0) {
		for (int i = 0; i < N / 2; i++) {
			comfortable += A[i];

		}
		for (int i = 0; i < N / 2; i++) {
			comfortable += A[i + 1];

		}
	}
	else {
		for (int i = 0; i < N / 2-1; i++) {
			comfortable += A[i];

		}
		for (int i = 0; i < N / 2; i++) {
			if (i == N / 2 - 1) {
				comfortable += A[i];
			}
			else {
				comfortable += A[i + 1];
			}
		}


	}

	cout << comfortable;
	return 0;
}

Measured memory_bytes: 4820
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    cnt=[0]*4
    s=["AC","WA","TLE","RE"]
    n=II()
    for _ in range(n):
        t=SI()
        i=s.index(t)
        cnt[i]+=1
    for i in range(4):
        print("{} x {}".format(s[i],cnt[i]))

main()

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

int solve() {
    ll N, M;
    cin >> N >> M;
    vector<ll> S(M), C(M);
    for ( int i = 0; i < M; i++ ) {
        cin >> S[i] >> C[i];
    }
    ll st = 1;
    for ( int i = 1; i < N; i++ ) {
        st *= 10;
    }
    int f = N == 1 ? 0 : st;
    for ( int i = f; i < st*10; i++ ) {
        bool ng = false;
        string s = to_string(i);
        for ( int j = 0; j < M; j++ ) {
            if ( (int)(s[S[j]-1] - '0') != C[j] ) {
                ng = true;
                break;
            }
        }
        if ( !ng ) {
            return i;
        }
    }
    return -1;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;

int main() {
  fastio;
  string S, T;
  cin >> S >> T;
  T.pop_back();
  if (T == S) {
    cout << "Yes" << endl;
    return 0;
  }
  else cout << "No" << endl;
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Measured memory_bytes: 3612