akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
using namespace std;
int main() {
  int flag = 1;
  int flag2 = 1;
  int ans = 0;
  int c;
  int n;
  while ((c = getchar_unlocked()) >= '0') {
    n = c - '0';
    flag2 = flag;
    if (n < 4) {
      if (flag == -1) {
        ans += n + 1;
      } else {
        ans += n;
      }
      flag = 1;
    }
    else if (n > 5) {
      if (flag == 1) {
        ans += 10 - n;
      }
      else {
        ans += 9 - n;
      }
      flag = -1;
    } else if (n == 4) {
      if (flag == -1) {
        flag = 0;
        ans += 5;
      }
      else {
        flag = 1;
        ans += 4;
      }
    } else if (n == 5) {
      if (flag == 1) {
        flag = 0;
        ans += 5;
      } else {
        flag = -1;
        ans += 4;
      }
    }
  }
  if (n > 5 || (n == 5 && flag2 != 1)){
    ++ans;
  }
  printf("%d\n", ans);
  return 0;
}
 

Measured memory_bytes: 384
package main
import "fmt"

func main(){
  a, b := 0, 0
  fmt.Scanf("%d %d", &a, &b)
  fmt.Println(a*b/lcm(a, b))
}
func lcm(a, b int)int{
  if a < b{
    a, b = b, a
  }
  if b == 0{
    return a
  }else{
    return lcm(b, a%b)
  }
}

Measured memory_bytes: 1832
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int sum = 0;
  cin >> N;
  vector<int>a(N), b(N), c(N-1);
  for(int i=0; i<N; i++)
    cin >> a[i];
  for(int i=0; i<N; i++)
    cin >> b[i];
  for(int i=0; i<N-1; i++)
    cin >> c[i];
  for(int i=0; i<N; i++) {
    sum += b[a[i]-1];
    if(a[i]==a[i+1]-1)
      sum += c[a[i]-1];
  }
  cout << sum << endl;
  return 0;
  
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

lmax = max(l)
l.remove(lmax)

out_flag = False

if lmax < sum(l):
    out_flag = True

def out(x):
    if x:
        print("Yes")
    else:
        print("No")

out(out_flag)

Measured memory_bytes: 3060
//10のi乗pow(10, i);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N,L;
  cin >> N >>L;
  vector<int>a(N);
  vector<int>b(N);
  rep(i,N) a.at(i) = i+L;
  int sum=0;
  rep(i,N) sum +=a.at(i);
  rep(i,N) b.at(i) = sum -a.at(i);
  int mi = abs(sum-b.at(0));
  rep(i,N) mi=min(mi,abs(sum-b.at(i)));
//  cout << sum <<endl;
//  cout << mi <<endl;
  if(sum > 0)  cout << sum - mi << endl;
  else cout << sum + mi <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000

int A[N],n; 

int partition( int p , int r ){
    
  int x,i,j,t;
  x = A[r];
  i = p - 1;
  for( j = p ; j < r ; j++){
    if( A[j] <= x ){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i + 1];
  A[i + 1] = A[r];
  A[r] = t;
  return i + 1;
  
}


main(){
  int q,i;

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    scanf("%d",&A[i]);
      }
  q = partition( 0 , n - 1 );
 
  for( i = 0 ; i < n ; i++ ){
    if( i ){
      printf(" ");
    }
    if( i == q ){
      printf("[");
    }
    printf("%d",A[i]);
    if( i == q ){
      printf("]");
    }
  }
  printf("\n");
 
  return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;

// 文字列で表された正の整数を比較
string compStringNumber(string a, string b) {
	string res;
	int size_a = a.size(), size_b = b.size();
	if (size_a > size_b) 
	{
		res = "GREATER";
	}
	else if (size_a < size_b) 
	{
		res = "LESS";
	}
	else 
	{
		res = "EQUAL";
		REP(i, size_a) 
		{
			int digit_a = a[i] - '0', digit_b = b[i] - '0';
			if (digit_a > digit_b) 
			{
				res = "GREATER";
				break;
			}
			else if (digit_a < digit_b) 
			{
				res = "LESS";
				break;
			}
			else 
			{
				continue;
			}
		}
	}

	return res;
}

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

    ans = compStringNumber(A, B);

    cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> xl(n);
    vector<pair<int, int>> state(n);
    for(int i = 0; i < n; i++) {
        cin >> xl[i].first >> xl[i].second;
        state[i].first = xl[i].first + xl[i].second;
        state[i].second = xl[i].first - xl[i].second;
    }

    int count = 0;
    sort(state.begin(), state.end());
    for(int i = 0; i < state.size()-1; i++) {
        if(state[i+1].second < state[i].first) {
            count++;
            state[i+1] = state[i];
        }
    }
    cout << n-count << endl;
    return 0;
}

Measured memory_bytes: 1792
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    ans = 0
    sl = False
    S=[]
    for i in range(N):
        s,t = ST().split()
        t = int(t)
        S.append((s,t))
    X = ST()
    for s,t in S:
        if s==X:
            sl=True
        else:
            if sl:
                ans+=t
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin>>n;
    int arr[n];
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    int x=sum/n;
    int y=sum/n+1;
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++){
        sum1+=(arr[i]-x)*(arr[i]-x);
        sum2+=(arr[i]-y)*(arr[i]-y);
    }
    cout<<min(sum1,sum2);
}

Measured memory_bytes: 256
S = input()
T = input()
if len(S) < len(T):
    print('UNRESTORABLE')
    exit()

candidates = []
for i in range(len(S) - len(T) + 1):
    for c1,c2 in zip(S[i:i+len(T)], T):
        if c1 != '?' and c1 != c2:
            break
    else:
        cand = S[:i] + T + S[i+len(T):]
        candidates.append(cand.replace('?','a'))

if candidates:
    print(min(candidates))
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#if loc||local
#define _GLIBCXX_DEBUG
#endif

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
constexpr ll dx[]={1,0,-1,0,1,1,-1,-1};
constexpr ll dy[]={0,1,0,-1,1,-1,1,-1};
constexpr ll ddx[] = {2,2,2,2,2,-2,-2,-2,-2,-2,1,0,-1,1,0,-1};
constexpr ll ddy[] = {0,1,2,-1,-2,2,1,0,-1,-2,2,2,2,-2,-2,-2};
using T3 = tuple<ll,ll,ll>;
using T4 = tuple<ll,ll,ll,ll>;
signed main(){

  int h,w;
  cin>>h>>w;
  int ch,cw;
  cin>>ch>>cw;
  int dh,dw;
  cin>>dh>>dw;
  auto s = vec<char>(h,w);
  cin>>s;
  ch--;cw--;dh--;dw--;

  auto dist = vec<ll>(h,w);
  for(auto& di:dist)for(auto& dij:di)dij=INF;
  deque<T3> deq;
  deq.emplace_back(0,ch,cw);
  while(!deq.empty()){
    auto [cost,y,x] = deq.front();
    deq.pop_front();
    if(!chmin(dist[y][x],cost))continue;
    rep(i,4){
      int ny = y+dy[i];
      int nx = x+dx[i];
      if(ny==-1||nx==-1||ny==h||nx==w)continue;
      if(s[ny][nx]=='#')continue;
      if(dist[ny][nx]!=INF)continue;
      deq.emplace_front(cost,ny,nx);
    }
    rep(j,4){
      int ny = y+dy[j+4];
      int nx = x+dx[j+4];
      if(ny==-1||nx==-1||ny==h||nx==w)continue;
      if(s[ny][nx]=='#')continue;
      if(dist[ny][nx]!=INF)continue;
      deq.emplace_back(cost+1,ny,nx);
    }
    rep(k,16){
      int ny = y+ddy[k];
      int nx = x+ddx[k];
      if(ny<0||nx<0||ny>=h||nx>=w)continue;
      if(s[ny][nx]=='#')continue;
      if(dist[ny][nx]!=INF)continue;
      deq.emplace_back(cost+1,ny,nx);
    }
  }
  cout<<(dist[dh][dw]==INF?-1:dist[dh][dw])<<endl;

}


Measured memory_bytes: 13440
import java.util.Scanner;

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

    int H, W;

    while(true){
      H = sc.nextInt();
      W = sc.nextInt();
      if(H==0 && W==0) break;

      for (int i=0; i<H; i++) {
        if(i==0 || i==H-1){
          for (int j=0; j<W; j++) {
            System.out.printf("#");
          }
          System.out.printf("\n");
        }
        else{
          for (int j=0; j<W; j++) {
            if (j==0 || j==W-1) System.out.printf("#");
            else System.out.printf(".");
          }
          System.out.printf("\n");
        }
      }
      System.out.printf("\n");
    }
  }
}



Measured memory_bytes: 58892
#include"bits/stdc++.h"
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();
LL ave(LL, LL);
bool isMultiOf(LL, LL);

int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a <= c && c <= b)coutY();
	else coutN();
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}
LL ave(LL a, LL b) {
	return (a + b) / 2;
}
bool isMultiOf(LL a, LL b) {
	return a % b == 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

	int ans1 = (a > b? b: a);

	int ans2;

	if (a + b < n) ans2 = 0;
	else ans2 = a + b - n;

	cout << ans1 << " " << ans2 << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n;;cin>>n;
    vector<int> takoyaki(n);rep(i,n)cin>>takoyaki[i];
    int sum = 0;
    rep(i,n){
        for(int j=i+1; j<n; ++j){
            sum+=takoyaki[i]*takoyaki[j];
        }
    }
    cout<<sum<<endl;return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9+5]*n
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    for j in range(max(0,i-k),i):
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[-1])

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

using namespace std;

const int N = 101;
const int K = 100001;
const int MOD = 1e9 + 7;
int dp[N][K], pre[K];
int a[N];

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i <= n; i++) {
        dp[i][0] = 1;
    }
    for (int child = 1; child <= n; child++) {
        memset(pre, 0, sizeof pre);
        pre[0] = 1;
        for (int i = 1; i <= k; i++) {
            pre[i] = pre[i - 1] + dp[child - 1][i];
            pre[i] %= MOD;
        }
        for (int remained = 1; remained <= k; remained++) {
            if (remained - a[child] - 1 < 0) {
                dp[child][remained] = pre[remained];
            } else {
                dp[child][remained] = (pre[remained] - pre[remained - a[child] - 1] + MOD) % MOD;
            }
        }
    }
    cout << dp[n][k];
    return 0;
}


Measured memory_bytes: 39680
import std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.string,
       std.array,
       std.stdio,
       std.conv;

const INF = (1<<30);
alias Edge = Tuple!(int, "to",int , "cost");
alias tie = TypeTuple;

int[] dijkstra(in Edge[][] tree, int start) {
  alias PriorityQueue = BinaryHeap;

  size_t V = tree.length;
  auto dist = new int[V];
  fill(dist, INF);

  auto queue = new PriorityQueue!(Array!Edge, "a.cost>=b.cost")();

  dist[start] = 0;
  queue.insert(Edge(start,0));
  while (!queue.empty()) {
    int v;
    int cost;
    tie!(v, cost) = queue.front();
    queue.popFront();

    if (dist[v] < cost) {
      continue;
    }
    foreach(const ref Edge e; tree[v]) {
      if (dist[v] + e.cost < dist[e.to]) {
        dist[e.to] = dist[v] + e.cost;
        queue.insert(Edge(e.to, dist[e.to]));
      }
    }
  }

  return dist;
}

void readlnToken(T...)(auto ref T args) {
  auto line = split(readln());
  foreach(ref arg; args) {
    arg = to!(typeof(arg))(line[0]);
    line = line[1..$];
  }
  assert(line.empty());
}

void main() {
  int V, E, r;
  readlnToken(V, E, r);

  auto tree = new Edge[][](V,0);
  foreach(i; 0..E)  {
    int s, t, d;
    readlnToken(s,t,d);
    tree[s] ~= Edge(t, d);
  }

  auto dists = dijkstra(tree, r);
  foreach (dist; dists) {
    if (dist == INF) {
      writeln("INF");
    } else {
      writeln(dist);
    }
  }
}



Measured memory_bytes: 53652
def main():
    card_num = int(input())
    cards = list(map(int, input().split()))
    answer = float("inf")
    num_sum = [cards[0]] * card_num
    for i in range(1, card_num):
        num_sum[i] = num_sum[i - 1] + cards[i]
    for i in range(card_num - 1):
        answer = min(answer, abs(2 * num_sum[i] - num_sum[-1]))
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 24832
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

object Solve {

  private val br = BufferedReader(InputStreamReader(System.`in`))
  private val out = PrintWriter(System.out)

  fun solve() {

    val n = br.readLine()!!.toInt()

    var ans = -1

    for (i in 1..50000){
      if(i * 108 / 100 == n){
        ans = i
      }
    }

    out.println(if(ans == -1) ":(" else ans)
    out.flush()
  }
}

fun main(args: Array<String>){
  Solve.solve()
}

Measured memory_bytes: 34180
#include<algorithm>
#include<iostream>
#include<vector>
#include<bitset>
#define pb push_back
using namespace std;

int N, a, b, endp, maxx;
bitset<100003> vis;
vector<int> v[100003];

int dfs(int now = 0) {
	vis[now] = 1;
	if(v[now].size() == 1) ++endp;
	vector<int> w = {0, 0};
	for(unsigned i = 0; i < v[now].size(); ++i) if(!vis[v[now][i]])
		w.pb(dfs(v[now][i]));
	sort(w.rbegin(), w.rend()); // 降序排序 
	maxx = max(maxx, (v[now].size() == 2) + w[0] + w[1]);
	return (v[now].size() == 2) + w[0];
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> N;
	while(--N) {
		cin >> a >> b;
		v[--a].pb(--b);
		v[b].pb(a);
	}
	dfs();
	cout << maxx + endp << '\n';
	return 0;
}


Measured memory_bytes: 5888
N, M = gets.split(" ").map(&:to_i)
A = gets.split(" ").map(&:to_i).sort_by{|a| -a}
B = []
m = M
while m > 0 do
    if B.empty? || A[0] > B[0]
        a = A.shift
        B << (a / 2)
    else
        b = B.shift
        B << (b / 2)
    end
    m -= 1
    if A.empty?
        A = B
        B = []
    end
end

puts (A + B).inject(:+)


Measured memory_bytes: 11648
package main

import (
       "bufio"
       "fmt"
       "os"
       "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
     sc.Scan()
     i, e := strconv.Atoi(sc.Text())
     if e != nil {
     	panic(e)
     }
     return i
}

func main() {
     sc.Split(bufio.ScanWords)
     n := nextInt()
     ans := n / 2 + n % 2
     
     fmt.Println(ans)
}

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

int main() {
    //
    int num, m;
    long long sum = 0;
    cin >> num >> m;

    priority_queue<long long> que;
    for (int i = 0; i < num; i++) {
        long long tmp;
        cin >> tmp;
        que.push(tmp);
    }

    for (int i = 0; i < m; i++) {
        long long tmp;
        tmp = que.top();
        que.pop();
        tmp /= 2;
        que.push(tmp);
    }

    while (!que.empty()) {
        sum += que.top();
        que.pop();
    }

    cout << sum << endl;
    //
}

Measured memory_bytes: 4260
//PKMKB
#include <bits/stdc++.h>
#define ll long long int
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define scanarr(a,b,c) for( i=b;i<c;i++)cin>>a[i]
#define showarr(a,b,c) for( i=b;i<c;i++)cout<<a[i]<<' '
#define ln cout<<'\n'
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define MAX 100005
using namespace std;
////////////////////////////////////////////////////////////////CODE STARTS HERE////////////////////////////////////////////////////////////////

void solve(){
   
   int i, n, tmp, q, b, c;
   cin >> n;
   unordered_map <ll, ll> cnt;
   ll sum = 0;

   for(i = 0; i < n; ++i){
       
       cin >> tmp;
       sum += tmp;
       ++cnt[tmp];
   }
   cin >> q;

   while(q--){

       cin >> b >> c;
       sum -= b * cnt[b];
       sum += c * cnt[b];
       cnt[c] += cnt[b];
       cnt[b] = 0;
       cout << sum << endl;
   }





}
int main(){

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
   
    solve();
}

Measured memory_bytes: 7084
aa = list(sorted(map(int, input().split())))
nn = sum(map(lambda x: x % 2, aa))
ans = 0
if nn == 1:
    ans += 1
    for i in range(3):
        if aa[i] % 2 == 0:
            aa[i] += 1
elif nn == 2:
    ans += 1
    for i in range(3):
        if aa[i] % 2 == 1:
            aa[i] += 1
ans += (aa[2] - aa[0]) // 2
ans += (aa[2] - aa[1]) // 2
print(ans)

Measured memory_bytes: 61928
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 1;
    int max_cnt = 0;
    int cnt = 0;
    int num = 0;
    for (int i=1; i<=n; ++i){
        cnt = 0;
        num = i;
        while(num % 2 == 0){
            cnt++;
            num /= 2;
        }
        if(max_cnt < cnt){
            ans = i;
            max_cnt = cnt;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderD
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = new int[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(words[i]);
            }
        }

        int[] answers = new int[n];

        for (int i = n; i > 0; i--)
        {
            int sum = 0;
            for (int j = i * 2; j <= n; j = j + i)
            {
                sum += answers[j - 1];
            }
            answers[i - 1] = (sum % 2 == a[i - 1]) ? 0 : 1;
        }

        Console.WriteLine(answers.Sum());

        if (answers.Sum() > 0)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < n; i++)
            {
                if (answers[i] != 0)
                {
                    sb.Append(" " + (i + 1));
                }
            }
            Console.WriteLine(sb.ToString().Trim());
        }
    }
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> h[i];

  int x0, y0, h0;
  for (int i = 0; i < n; i++) {
    if (h[i]) {
      x0 = x[i];
      y0 = y[i];
      h0 = h[i];
      break;
    }
  }
  vector<vector<int>> cand;
  for (int cx = 0; cx < 101; cx++) {
    for (int cy = 0; cy < 101; cy++) {
      int ch = h0 + abs(cx - x0) + abs(cy - y0);
      bool flag = true;
      for (int i = 0; i < n; i++) {
        if (max(ch - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]) {
          flag = false;
          break;
        }
      }
      if (flag) {
        cand.push_back({ch, cx, cy});
      }
    }
  }
  sort(cand.begin(), cand.end(), greater<vector<int>>());
  printf("%d %d %d\n", cand[0][1], cand[0][2], cand[0][0]);
  return 0;
}

Measured memory_bytes: 256
import numpy as np
from numpy.fft import rfft,irfft

# 参考: https://atcoder.jp/contests/practice2/submissions/16645527

def convolve(a1,a2):
    n = 2**(len(a1)+len(a2)+1).bit_length()
    b1,b2=np.zeros(n),np.zeros(n)
    b1[:len(a1)], b2[:len(a2)]= a1,a2
    return (irfft(rfft(b1)*rfft(b2))+0.5).astype(int)
  
def convolve_large(a,b,mod):
    d = 1<<10
    a1, a2 = np.divmod(a,d*d)
    a2, a3 = np.divmod(a2,d)
    b1, b2 = np.divmod(b,d*d)
    b2, b3 = np.divmod(b2,d)
    aa = convolve(a1,b1) % mod
    bb = convolve(a2,b2) % mod
    cc = convolve(a3,b3) % mod
    dd = (convolve(a1+a2, b1+b2) - (aa+bb)) % mod
    ee = (convolve(a2+a3, b2+b3) - (bb+cc)) % mod
    ff = (convolve(a1+a3, b1+b3) - (aa+cc)) % mod
    h = (((aa*d*d) % mod)*d*d + ((dd*d*d) % mod)*d + (bb+ff)*d*d + ee*d + cc) % mod
    return h


def main():
  N,M=map(int,input().split())
  *A,=map(int,input().split())
  *B,=map(int,input().split())
  mod = 998244353

  print(*convolve_large(A,B,mod)[:N+M-1])
  
if __name__=="__main__":
  main()

Measured memory_bytes: 280188
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <limits.h>
using namespace std;

typedef pair<int,int> II;
typedef pair<int, II > P;//cost num チケット(1:未使用0:使用）

int cost[101][101];
vector<int> to[101];
vector<int> to2[101];
int mincost[101][2];//1:チケット未使用0:チケットしよう
int maxn,maxm;
bool gf[2];

void bfs()
{
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0,II(1,1)));
	mincost[1][1] = 0;
	while(!q.empty()){
		P p = q.top();q.pop();
		int now = p.second.first;
		int ti = p.second.second;
		if(now == maxn)
			gf[ti] = true;
		if(gf[0] == true && gf[1] == true)
			return;
		for(int i=0;i<to[now].size();++i){
			if(mincost[to[now][i]][ti] > mincost[now][ti]+cost[now][to[now][i]]){
				mincost[to[now][i]][ti] = mincost[now][ti] + cost[now][to[now][i]];
				q.push(P(mincost[to[now][i]][ti],II(to[now][i],ti)));
			}
		}
		if(ti >= 1)//チケットがある場合
		{
			for(int i=0;i<to2[now].size();++i){
				if(mincost[to2[now][i]][0] > mincost[now][1]){
					mincost[to2[now][i]][0] = mincost[now][1];
					q.push(P(mincost[to2[now][i]][0],II(to2[now][i],0)));
				}
			}
		}
	}
}

int main(void){
	while(1){
		for(int i=0;i<2;++i) gf[i] = false;
		for(int i=0;i<101;++i){
			to[i].clear();
			to2[i].clear();
			for(int j=0;j<101;++j) cost[i][j] = INT_MAX/2;
			for(int j=0;j<2;++j) mincost[i][j] = INT_MAX/2;
		}
		cin >> maxn >> maxm;
		if(maxn+maxm == 0)
			return 0;
		for(int i=0;i<maxm;++i){
			int a,b,c;
			cin >> a >> b >> c;
			cost[a][b] = c;
			cost[b][a] = c;
			to[a].push_back(b);
			to[b].push_back(a);
		}
		for(int i=1;i<=maxn;++i){
			for(int j=0;j<to[i].size();++j){
				for(int k=0;k<to[to[i][j]].size();++k){
					to2[i].push_back(to[to[i][j]][k]);
				}
			}
		}
		bfs();
		cout << (mincost[maxn][0] > mincost[maxn][1]?mincost[maxn][1]:mincost[maxn][0]) << endl;
	}
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007

int main(){
 	int N; cin >>N;
  	int count=0,cnto=0;
  	vector<int>A(N);
 	ll sumans=0;
  	rep(i,N){
      int a;cin >>a;
      if(a<0){count++;A[i]=((-1)*a);}
      else if(a==0){cnto++;A[i]=a;}
      else{A[i]=a;}
    }
    sort(A.begin(),A.end());
  	rep(i,N){sumans+=A[i];}
    if(count%2==1&&cnto==0){sumans-=(2*A[0]);}
     cout<<sumans; 
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = 1000000000;
ll inf = 1000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n, k;
	cin >> n >> k;
	int i;
	bool Not[10] = {};
	for (i = 0; i < k; i++) {
		int a;
		cin >> a;
		Not[a]++;
	}
	for (i = 1; i < 100000; i++) {
		int ci = i;
		bool flag = true;
		while (ci) {
			if (Not[ci % 10]) flag = false;
			ci /= 10;
		}
		if (flag && i >= n) break;
	}
	cout << i;
	return(0);
}

Measured memory_bytes: 256
import math

a,b=map(int,input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(math.sqrt(n))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)
    return arr
  
a_list = factorization(a)
b_list = factorization(b)

a_b_and = set(a_list) & set(b_list)
print(len(a_b_and) + 1)


Measured memory_bytes: 3064
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = []
    SOLVED = (1, 2, 3, 4, 5, 6, 7, 8, 0)
    for _ in range(3):
        S += LI()

    neighbor = (
        (1, 3),      
        (0, 2, 4),   
        (1, 5),      
        (0, 4, 6),   
        (1, 3, 5, 7),
        (2, 4, 8),   
        (3, 7),      
        (4, 6, 8),   
        (5, 7)       
    )

    dist = dict()
    que = collections.deque()
    S = tuple(S)
    que.append((S, S.index(0)))
    dist[S] = 0
    while que:
        c, idx_0 = que.popleft()
        if c == SOLVED:
            break
        for i in neighbor[idx_0]:
            c_l = list(c)
            c_l[idx_0], c_l[i] = c_l[i], c_l[idx_0]
            n = tuple(c_l)
            if not n in dist:
                que.append((n, i))
                dist[n] = dist[c] + 1

    print(dist[SOLVED])

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 44304
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int w, a, b;
	cin >> w >> a >> b;
	if(a < b)
	{
		if(b - (a + w) < 0) cout << 0 << endl;
		else cout << b - (a + w) << endl;
	}
	else
	{
		if(a - (b + w) < 0 ) cout << 0 << endl;
		else cout << a - (b + w) << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

ll n;
ll a[300000];
ll ma[300000], mi[300000];

int main(int argc, char **argv) {
	cin >> n;
	REP(i, 3 * n) cin >> a[i];

	map<ll, ll> m;
	ll s = 0;
	REP(i, 3 * n) {
		++m[a[i]];
		s += a[i];
		if (i >= n) {
			ll v = m.begin()->first;
			s -= v;
			--m[v];
			if (m[v] == 0) m.erase(v);
		}
		ma[i] = s;
	}

	m.clear();
	s = 0;
	REP(_i, 3 * n) {
		ll i = 3 * n - 1 - _i;
		++m[a[i]];
		s += a[i];
		if (_i >= n) {
			ll v = (--m.end())->first;
			s -= v;
			--m[v];
			if (m[v] == 0) m.erase(v);
		}
		mi[i] = s;
	}

	ll res = -1000000000000000;
	FOR(i, n, 2 * n + 1) {
		res = max(res, ma[i - 1] - mi[i]);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 13568
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int[] hill=new int[10];
		int len;
		for(int i=0;i<(len=hill.length);i++) hill[i]=sc.nextInt();
		Arrays.sort(hill);
		for(int i=0;i<3;i++) System.out.println(hill[len-1-i]);
		sc.close();
	}
}

Measured memory_bytes: 17164
n = int(input())
d = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
a = ''
while n:
  n -= 1
  a = d[n % 26] + a
  n //= 26
print(a)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

double x[10];
double y[10];

int main(){
	long long N;
	cin >> N;

	rep(i, N) {
		cin >> x[i];
		cin >> y[i];
	}

	vector<long long>vec;
	rep(i, N) {
		vec.push_back(i);
	}


	double sum = 0;
	double cnt = 0;
	do {
		cnt++;

		rep(i, N-1) {
			long long idx = vec[i];
			long long next = vec[i+1];
			sum += sqrt((x[idx] - x[next]) *  (x[idx] - x[next]) + (y[idx] - y[next]) *  (y[idx] - y[next]));
		}
	} while (std::next_permutation(vec.begin(), vec.end()));

	printf("%.10f\n", sum/cnt);
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

class dice{
  int* me;
public:
  dice(int me_[6]){
    me = me_;
  }
  int getMe(int i){
    return *(me+i);
  }
  void East(){
    swap(me[0], me[3]);
    swap(me[3], me[5]);
    swap(me[5], me[2]);
  }
  void West(){
    swap(me[0], me[2]);
    swap(me[2], me[5]);
    swap(me[5], me[3]);
  }
  void North(){
    swap(me[0], me[1]);
    swap(me[1], me[5]);
    swap(me[5], me[4]);
  }
  void South(){
    swap(me[0], me[4]);
    swap(me[4], me[5]);
    swap(me[5], me[1]);
  }
  void Rotate(){
    swap(me[1], me[2]);
    swap(me[2], me[4]);
    swap(me[4], me[3]);
  }
};

bool same(dice d1, dice d2){
  REP(i,6)
    if(d1.getMe(i)!=d2.getMe(i))
      return false;
  return true;
}

int main(){ _;
  int me[6],me_[6];
  REP(i,6) cin>>me[i];
  dice d{me};
  REP(i,6) cin>>me_[i];
  dice e{me_};
  REP(i,4){
    if(same(d,e)){
      cout<<"Yes"<<endl;
      return 0;
    }
    d.Rotate();
  }
  d.North();
  REP(i,4){
    if(same(d,e)){
      cout<<"Yes"<<endl;
      return 0;
    }
    d.Rotate();
  }
  d.West();
  REP(i,4){
    if(same(d,e)){
      cout<<"Yes"<<endl;
      return 0;
    }
    d.Rotate();
  }
  d.West();
  REP(i,4){
    if(same(d,e)){
      cout<<"Yes"<<endl;
      return 0;
    }
    d.Rotate();
  }
  d.West();
  REP(i,4){
    if(same(d,e)){
      cout<<"Yes"<<endl;
      return 0;
    }
    d.Rotate();
  }
  d.North();
  REP(i,4){
    if(same(d,e)){
      cout<<"Yes"<<endl;
      return 0;
    }
    d.Rotate();
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 1188
#include<stdio.h>
#include<stdlib.h>

#define SENTINEL 10000000000000000

int count = 0;

void mergeSort(long long int A[], long long int left,long long int right) {
	long long int i, mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}



void merge(long long int A[], long long int left, long long int mid, long long int right) {
	long long int n1, n2, i, j, k;
	long long int *L, *R;
	n1 = mid - left;
	n2 = right - mid;
	L = (int *)malloc(sizeof(long long int)*(n1 + 1));
	R = (int *)malloc(sizeof(long long int)*(n2 + 1));
	for (i = 0; i <= n1 - 1; i++) {
		L[i] = A[left + i];
	}
	for (j = 0; j <= n2 - 1; j++) {
		R[j] = A[mid + j];
	}
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;
	i = 0;
	j = 0;
	for (k = left; k <= right - 1; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
			count++;
		}
		else {
			A[k] = R[j];
			j++;
			count++;
		}
	}
	free(L);
	free(R);
}


main() {
	long long int A[500000];
	long long int n, i;
	long long int p,q;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%lld", &A[i]);
	}
	mergeSort(A, 0, n);
	
	if (n % 2 == 1) {
		for (int j = 0; j < (n / 2)-1; j++) {
			p -= 2*A[j];
		}
		p -= A[(n / 2) - 1];
		p -= A[(n / 2) ] ;
		for (int j = (n / 2) + 1; j < n ; j++) {
			p += 2 * A[j];
		}

		for (int j = 0; j < (n / 2)  ; j++) {
			q -= 2 * A[j];
		}
		q += A[(n / 2) + 1];
		q += A[(n / 2)];
		for (int j = (n / 2) + 2; j < n; j++) {
			q += 2 * A[j];
		}
		if (p >= q) {
			printf("%lld", p);
		}
		else {
			printf("%lld", q);
		}
	}
	else {
		for (int j = 0; j < (n / 2) - 1; j++) {
			p -= 2 * A[j];
		}
		p -= A[(n / 2) - 1];
		p += A[(n / 2)];
		for (int j = (n / 2) + 1; j < n; j++) {
			p += 2 * A[j];
		}
		printf("%lld", p);
	}
	return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    IO
    ll n,ans=100,ma=1e18;
    cin>>n;
    vector <ll> v;
    for(ll i=0;ans<=ma;i++)
    {
        ll sum=(ans)+(ans/100);
        v.push_back(sum);
        ans=sum;
    }
    for(ll i=0;i<v.size();i++)
    {
        if(v[i]>=n)
        {
            cout<<i+1;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
	int x,X;

	cin >> X;

	int t,e;
	int y=1, Y=1;
	int max = 0;
	for (x = 1; x <= 1000; x++) {
		y = x;
		for (t = 2; t <= 1000; t++) {
			y *= x;
			if (y > X) {
				break;
			}
			else {
				if (y > max)
					max = y;
			}
		}
	}

	cout << max;
}


Measured memory_bytes: 256
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//var min, min2, count: Int!
//for i in 1...10 {
//    let x = Int(readLine()!)!
//    if i == 1 {
//        min = x
//        count = 1
//    } else if x < min {
//        min2 = min
//        min = x
//        count = 1
//    } else if x == min && count == 1 {
//        min2 = x
//        count = 2
//    }
//}
//print(min2)

/*************** メインプログラム ***************/

let A = readInt()!
let B = readInt()!
let C = readInt()!
let X = readInt()!
var ans = 0
for i in 0...A {
    for j in 0...B {
        for k in 0...C {
            if i*500 + j*100 + k*50 == X {
                ans += 1
            }
        }
    }
}
print(ans)


Measured memory_bytes: 3828
n=int(input())
flag=True
for a in range(1,3501):
    for b in range(1,3501):
        if 4*a*b-n*(a+b)>0 and (n*a*b)%(4*a*b-n*(a+b))==0:
            print(a,b,n*a*b//(4*a*b-n*(a+b)))
            exit()

Measured memory_bytes: 40556
import sys
import math
def get_array(): return list(map(int,sys.stdin.readline().strip().split()))
def get_ints(): return map(int,sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
x1,x2,x3,x4,x5=get_ints()
a=[x1,x2,x3,x4,x5]
for i in range(5):
    if a[i]==0:
        break 
print(i+1)
            
        

    

Measured memory_bytes: 62056
#include <stdio.h>
#include <stdlib.h>

int main()
{
    unsigned char N;
    unsigned char *X;
    unsigned char i;
    unsigned char elem = 0;
    unsigned int out = 0;
    unsigned short sum = 0;
    
    scanf("%u ", &N);
    
    X = (unsigned char *) malloc(N);
    
    for(i = 0; i < N; i++)
    {
        scanf("%u ", &X[i]);
        sum = sum + X[i];
    }
    
    elem = sum / N;
    float rem = (float) sum / (float)N;
    rem = rem - elem;
    if(rem > 0.5)
    {
        elem++;
    }
    
    for(i = 0; i < N; i++)
    {
        out = out + ((X[i] - elem) * (X[i] - elem));
    }
    
    printf("%d ", out);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
    int n,i,max=0,sum=0;

    scanf("%d",&n);
    int p[n+1];

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

    for(i=1;i<=n;i++){
        if(p[i]>max){
            max=p[i];
        }
        sum+=p[i];
    }

    sum-=max/2;
    printf("%d",sum);
  
    return 0;
}

Measured memory_bytes: 128
O = str(input())
E = str(input())
ans = str()

if len(O) == len(E):
    for i in range(len(O)):
        ans = ans + O[i] + E[i]
else:
    for i in range(len(O)-1):
        ans = ans + O[i] + E[i]
    ans = ans + O[-1]
    
print(ans)

Measured memory_bytes: 3064
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())
    if abs(A-B)<=T*(V-W):
        print('YES')
    else:
        print('NO')



if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
a = raw_input().split()
for i in range(4):
    a[i] = int(a[i])
res = 0
b = [1, 0, -1]
t = a[3]
i = 0
while t:
    if a[i] < t:
        t -= a[i]
        res += a[i] * b[i]
        i += 1
    else:
        res += b[i] * t
        print res
        break


Measured memory_bytes: 64244
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
const int N=255;
int mod,f[N*2][N],c1,c2;
pair<int,int> a[N*2];
#define fi first
#define se second
inline int mul(ri x,ri y){
	return (ll)x*y%mod;
}
inline void add(int &x,ri y){
	x=(x+=y)>=mod?x-mod:x;
}
int main(){
	ri n,i,j,k,lstg,lstf,ans;
	scanf("%d%d",&n,&mod);
	lstg=lstf=2*n-1;
	for(i=0;i<n;++i){
		while(lstg*lstg+i*i>= n*n) --lstg;
		while(lstf*lstf+i*i>4*n*n) --lstf;
		a[i+1]=make_pair(lstg+1,lstf+1);
	//	printf("%d %d\n",a[i+1].fi,a[i+1].se);
	}
	for(;i<2*n;++i){
		while(lstf*lstf+i*i>4*n*n) --lstf;
		a[i+1]=make_pair(lstf+1,0);
	//	printf("%d %d\n",a[i+1].fi,a[i+1].se);
	}
	sort(a+1,a+1+2*n);
	f[0][0]=1;
	ans=0;
	for(k=0;k<=n;++k){
		for(i=1;i<=2*n;++i)
			for(j=0;j<=k&&j<=i;++j)
				f[i][j]=0;
		c1=c2=0;
		for(i=1;i<=2*n;++i){
			if(!a[i].se){
				for(j=0;j<=c2&&j<=k;++j)
					if(a[i].fi-(j+c1)>0)
						add(f[i][j],mul(f[i-1][j],a[i].fi-(j+c1)));
				++c1;
			}
			else{
				for(j=0;j<=c2&&j+1<=k;++j)
					if(a[i].fi-(j+c1)>0)
						add(f[i][j+1],mul(f[i-1][j],a[i].fi-(j+c1)));
				for(j=0;j<=c2;++j)
					if(a[i].se-(n+k+c2-j)>0)
						add(f[i][j],mul(f[i-1][j],a[i].se-(n+k+c2-j)));
				++c2;
			}
		//	for(j=0;j<=c2;++j)
		//		printf("f %d %d %d\n",i,j,f[i][j]);
		}
	//	printf("%d %d\n",k,f[2*n][k]);
		ans=(ans+(ll)(k&1?mod-1:1)*f[2*n][k])%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
n=int(input())
xy=[]
for i in range(n):
  t_a=int(input())
  xy.append([list(map(int,input().split())) for i in range(t_a)])

ans=0
for i in range(2**n):
  list=[[] for j in range(n)]
  honest=[]
  for k in range(n):
    if (i>>k)&1:
      honest.append(k)
      for x,y in xy[k]:
        x-=1
        list[x].append(y)

  check=1
  for m in range(n):
    t_l=list[m]
    if t_l:
      if 0 in t_l and 1 in t_l:
        check=0
      elif 1 in t_l and m not in honest:
        check=0
      elif 0 in t_l and m in honest:
        check=0

  if check==1:
    ans=max(ans,len(honest))

print(ans)

Measured memory_bytes: 47196
N = int(input())
a = list(map(int,input().split()))
L = [0]*(10**5+1)
for i in a:
    L[i] += 1
hoge = sum(L[:3])
ans = hoge
for i in range(10**5-2):
    hoge += L[i+3]-L[i]
    ans = max(ans,hoge)
print(ans)

Measured memory_bytes: 14092
import sys

N = int(input())

for h in range(3500):
    h += 1

    for n in range(3500):
        n += 1

        if (4*h*n - N*n - N*h) > 0 and (N*h*n) % (4*h*n - N*n - N*h) == 0 :
            w = (N*h*n) // (4*h*n - N*n - N*h)

            print (h,n,w)
            sys.exit()


Measured memory_bytes: 40428
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
    if(p[i]>min(p[i-1],p[i],p[i+1]) and p[i]<max(p[i-1],p[i],p[i+1]) ):
        ans+=1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  string s; cin >> s;
  ll n = SZ(s);
  vector<ll> cnt(26,0);
  ll ans = 1 + n*(n-1)/2;
  REP(i,n) cnt[s[i]-'a']++;
  REP(i,26) ans -= cnt[i] * (cnt[i]-1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 640