akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back
#define fi first
#define be begin()
#define en end()
#define se second

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

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; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  ll x;
  cin>>x;
  ll ans(0);
  ll tmp = 1;
  while (x >= 1){
    ans += tmp; 
    x /= 2;
    tmp *= 2;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define N 1002
#define INF 1e9+1

int Levenshtein(string s1,string s2){//hensyu kyori
	vector<vector<int> > dp;
	int ss1=s1.size(),ss2=s2.size();
	int n=max(ss1,ss2)+1;
	dp.resize(n);for(int i=0;i<n;i++)dp[i].resize(n);
	for(int i=0;i<ss1+1;i++)dp[i][0]=i;
	for(int i=0;i<ss2+1;i++)dp[0][i]=i;
	for(int i=1;i<ss1+1;i++){
		for(int j=1;j<ss2+1;j++){
			int a,b=1;
			if(s1[i-1]==s2[j-1])b=0;
			a=min(dp[i-1][j]+1,dp[i][j-1]+1);
			a=min(a,dp[i-1][j-1]+b);
			dp[i][j]=a;
		}
	}
	return dp[s1.size()][s2.size()];
}

string s1,s2;
int main(){
	cin>>s1>>s2;
	cout<<Levenshtein(s1,s2)<<endl;
	return 0;
}


Measured memory_bytes: 6800
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod = 1000000007


def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x, y: x * y % mod, range(n, n - r, -1), 1)
    denom = pow(reduce(lambda x, y: x * y % mod, range(1, r + 1), 1), mod - 2, mod)
    return numer * denom % mod


def solve():
    pass


def main():
    S = int(input().strip())
    if S<3:
        print(0)
        return
    dp = [0 for i in range(S + 1)]
    dp[0] = 0
    dp[1] = 0
    dp[2] = 0
    dp[3] = 1
    for i in range(4, S + 1):   # dp[i]は，「和がiになるような数列の個数」
        for j in range(3, i):
            dp[i] = (dp[i] + dp[i - j]) % mod
        dp[i] += 1

    print(dp[S])
    # eprint('dp ', end=':\n')
    # eprint(dp)


if __name__ == '__main__':
    main()


Measured memory_bytes: 78380
h, w = map(int, input().split())
lis = [list(input()) for _ in range(h)]
cnt = 0
for i in reversed(range(h)):
    if set(lis[i])=={'.'}:
        lis.pop(i)
        cnt += 1
for j in reversed(range(w)):
    if set([l[j] for l in lis])=={'.'}:
        for k in range(h-cnt):
            lis[k].pop(j)
for m in lis:
    print("".join(m))


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

int main() {

string x1 , x2 ;
int c=0 ;
cin >> x1 >> x2 ;
for(int i=0 ; i<3 ; i++){
    if(x1[i]==x2[i])c++;
}
cout << c ;
return 0 ;
}


Measured memory_bytes: 256
def getlist():
	return list(map(int, input().split()))

N, A, B, C = getlist()
L = []
for i in range(N):
	L.append(int(input()))

ans = float("inf")
for i in range(1 << 2 * len(L)):
    a = []
    b = []
    c = []
    for j in range(len(L)):
    	if ((i >> 2 * j) & 1) == 1:
    		if ((i >> 2 * j + 1) & 1) == 1:
    			a.append(L[j])
    		else:
    			b.append(L[j])
    	else:
    		if ((i >> 2 * j + 1) & 1) == 1:
    			c.append(L[j])
    	v = 0
    	if len(a) != 0 and len(b) != 0 and len(c) != 0:
    		v += 10 * (len(a) - 1)
    		v += 10 * (len(b) - 1)
    		v += 10 * (len(c) - 1)
    		v += abs(sum(a) - A) + abs(sum(b) - B) + abs(sum(c) - C)
    		ans = min(ans, v)

print(ans)

Measured memory_bytes: 3064
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final InputStream inputStream = System.in;
        final OutputStream outputStream = System.out;
        final InputReader in = new InputReader(inputStream);
        final PrintWriter out = new PrintWriter(outputStream);
        final Solution solver = new Solution();
        solver.solve(in, out);
        out.close();
    }

    static class Solution {
        void solve(final InputReader in, final PrintWriter out) {
            final int N = in.nextInt();
            final int K = in.nextInt();
            int currentValue = 1;
            for (int i = 0; i < N; i++) {
                currentValue = Math.min(currentValue * 2, currentValue + K);
            }
            out.println(currentValue);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(final InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 23124
#D問題
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
AB=sorted(AB, key=lambda x: x[1])
bridges=[]
for i in range(M):
    if len(bridges) == 0:
        bridges.append(AB[i][1]-1)
    elif max(bridges)>=AB[i][0]:
        pass
    else:
        bridges.append(AB[i][1]-1)
print(len(bridges))

Measured memory_bytes: 29848
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>
#include <map>

using namespace std;

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

	int N;
	cin >> N;

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

	map<long long, int> count;
	for (int i = N - 1; i >= 0; i--)
	{
		count[i + A[i]]++;
	}

	long long result = 0;
	for (int i = N - 1; i >= 0; i--)
	{
		long long val = i - A[i];
		if (count.find(val) != count.end())
		{
			result += count[val];
		}
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 17076
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(10);
		   int n;
           string s,t;
           cin>>n>>s>>t;
           int ans=n+n;
           rep(i,0,n){
             bool ok=true;
            rep(j,0,n-i){
             if(s[i+j]!=t[j])ok=false; 
            }
             if(ok){
               ans-=n-i;
               break;
             }
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>

using namespace std;

class Cell
{
private:
	int key;
	Cell *prev, *next;
public:
	Cell(int x, Cell* prev, Cell* next)
	{
		key = x;
		this->prev = prev;
		this->next = next;
	}
	int getKey() { return key; }
	void setKey(int key) { this->key = key; }
	Cell* getPrev() { return prev; }
	void setPrev(Cell* prev) { this->prev = prev; }
	Cell* getNext() { return next; }
	void setNext(Cell* next) { this->next = next; }
};

class LinkedList
{
private:
	Cell* centinel;
	Cell* findCellHas(int x)
	{
		Cell* ret;
		for (ret = getFirst(); ret->getKey() != x; ret = ret->getNext())
		{
			if (ret->getKey() == -1)
			{
				break;
			}
		}
		return ret;
	}
	void del(Cell* c)
	{
		c->getPrev()->setNext(c->getNext());
		c->getNext()->setPrev(c->getPrev());
		delete c;
	}
public:
	LinkedList()
	{
		centinel = new Cell(-1, NULL, NULL);
		centinel->setPrev(centinel);
		centinel->setNext(centinel);
	}
	~LinkedList()
	{
		delete centinel;
	}
	Cell* getFirst() { return centinel->getNext(); }
	Cell* getLast() { return centinel->getPrev(); }
	Cell* ins(int x)
	{
		Cell* c = new Cell(x, centinel, centinel->getNext());
		centinel->setNext(c);
		c->getNext()->setPrev(c);
		return c;
	}
	void del(int x)
	{
		Cell* c = findCellHas(x);
		if (c == centinel)
		{
			return;
		}
		else
		{
			del(c);
		}
	}
	void delFirst()
	{
		del(getFirst());
	}
	void delLast()
	{
		del(getLast());
	}
};

int main()
{
	int n;
	cin >> n;
	LinkedList ll;
	string cmd;
	int key;
	for (int i = 0; i < n; i++)
	{
		cin >> cmd;
		if (cmd == "insert")
		{
			cin >> key;
			ll.ins(key);
		}
		else if(cmd == "delete")
		{
			cin >> key;
			ll.del(key);
		}
		else if (cmd == "deleteFirst")
		{
			ll.delFirst();
		}
		else if (cmd == "deleteLast")
		{
			ll.delLast();
		}
	}
	for (Cell* c = ll.getFirst(); c != ll.getLast(); c = c->getNext())
	{
		cout << c->getKey() << " ";
	}
	cout << ll.getLast()->getKey() << endl;
	return 0;
}


Measured memory_bytes: 34384
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String pattern = sc.next();
        
        str += str;
        if(str.indexOf(pattern) != -1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

using namespace std;

typedef long long ll;

const int M = 111;

int n, a[M];

int cost(int x) {
	int ans = 0;
	auto sq = [](int x) {
		return x * x;
	};
	
	for (int i = 0; i < n; ++i)
		ans += sq(a[i] - x);
	
	return ans;
}

void read() {
	cin >> n;
	for (int i = 0; i < n; ++i)
			cin >> a[i];
}

void kill() {
	int ans = cost(0);
	for (int x = -100; x <= 100; ++x)
		ans = min(ans, cost(x));
	cout << ans << endl;
}

int main() {
	read();
	kill();	
	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
S = [input() for _ in range(H)]
 
ans = [[0]*W for _ in range(H)]
 
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            ans[i][j] += 11

#入力が1列の場合
if W == 1:
    for i in range(H-1):
        if ans[i+1][0] > 10:
            ans[i][0] += 1
    for i in range(1, H):
        if ans[i-1][0] > 10:
            ans[i][0] += 1

    for i in range(H):
        if ans[i][0] > 10:
            ans[i][0] = "#"
        ans[i] = map(str, ans[i])
        ans[i] = "".join(ans[i])

    for a in ans:
        print(a)
    exit()
 
#横方向の確認
for i in range(H):
    for j in range(W - 1):
        if ans[i][j+1] > 10:
            ans[i][j] += 1
    for j in range(1, W):
        if ans[i][j-1] > 10:
            ans[i][j] += 1
 
#縦方向の確認
for j in range(1, W-1):
    for i in range(H-1):
        if ans[i+1][j-1] > 10:
            ans[i][j] += 1
        if ans[i+1][j] > 10:
            ans[i][j] += 1
        if ans[i+1][j+1] > 10:
            ans[i][j] += 1
 
    for i in range(1, H):
        if ans[i-1][j-1] > 10:
            ans[i][j] += 1
        if ans[i-1][j] > 10:
            ans[i][j] += 1
        if ans[i-1][j+1] > 10:
            ans[i][j] += 1
 
#j = 0
for i in range(H-1):
    if ans[i+1][0] > 10:
        ans[i][0] += 1
    if ans[i+1][1] > 10:
        ans[i][0] += 1
for i in range(1, H):
    if ans[i-1][0] > 10:
        ans[i][0] += 1
    if ans[i-1][1] > 10:
        ans[i][0] += 1
 
#j = W-1
for i in range(H-1):
    if ans[i+1][W-1] > 10:
        ans[i][W-1] += 1
    if ans[i+1][W-2] > 10:
        ans[i][W-1] += 1
for i in range(1, H):
    if ans[i-1][W-1] > 10:
        ans[i][W-1] += 1
    if ans[i-1][W-2] > 10:
        ans[i][W-1] += 1
 
for i in range(H):
    for j in range(W):
        if ans[i][j] > 10:
            ans[i][j] = "#"
    ans[i] = map(str, ans[i])
    ans[i] = "".join(ans[i])
 
for a in ans:
    print(a)

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int N = 1e5 + 3;
int h[N];
int dp[N];

int main() {
    ios_base::sync_with_stdio(false);
    memset(dp, INF, sizeof dp);
    int n; cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];

    dp[0] = 0;
    for(int i = 1; i < n; i++)
        for(int j = max(0,i-2); j < i; j++)
            dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));

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



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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

vi solve(set<tuple<int,int,int,int,int>> rs)
{
	vi order;
	while(rs.size()){
		int x1,y1,x2,y2,i; tie(x1,y1,x2,y2,i)=*begin(rs); rs.erase(begin(rs));
		order.push_back(i);
		decltype(rs) rs2;
		int left=INF;
		for(auto it=begin(rs);it!=end(rs);++it){
			if(get<1>(*it)<y2 && y2<get<3>(*it)){
				left=get<0>(*it);
				break;
			}
		}
		for(auto it=begin(rs);it!=end(rs);){
			if(get<2>(*it)<=left && get<3>(*it)<=y2){
				rs2.insert(*it);
				it=rs.erase(it);
			}
			else
				++it;
		}
		vi tmp=solve(rs2);
		order.insert(end(order),all(tmp));
	}
	return order;
}

int main()
{
	bool first=true;
	for(int n;cin>>n && n;first=false){
		if(!first) cout<<endl;
		set<tuple<int,int,int,int,int>> rs; // x1,y1,x2,y2,i
		rep(i,n){
			int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
			if(x1>x2) swap(x1,x2);
			if(y1>y2) swap(y1,y2);
			rs.insert(mt(x1,y1,x2,y2,i));
		}
		vi order=solve(rs);
		vi res(n);
		rep(i,n) res[order[i]]=i;
		rep(i,n) cout<<res[i]+1<<endl;
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int a, b; cin >> a >> b;
	int now = 1;
	if(b == 1) {
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1; ; ++i) {
		now--;
		now += a;
		if(now >= b) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

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

using namespace std;

int x,n,aux,menor;
int nums[123] = {-1};

int main(void){
    fill_n(nums, 103, 1);
    cin >> x >> n;
    for(int i = 0; i < n; i++){
        cin >> aux;
        nums[aux] = 0;
    }
    menor = -1;
    for(int i = -1; i <= 101; i++){
        if(nums[i]){
            if(abs(i - x) < abs(menor - x)){
                menor = i;
            }
        }
    }

    cout << menor << endl;

    return 0;
}

Measured memory_bytes: 3624
n,a,b = [int(_) for _ in input().split()]

result = []
for i in range(1,n+1): # n=20のとき1~20を検査するよ
  i = str(i)
  wa = 0
  for j in range(0,len(str(i))): # strとして認識するために、文字列は配列として0個目の文字列＋1個目の文字列みたいに足し算をしていくよ
    wa = wa + int(i[j])
  if a <= wa <= b:
    result.append(int(i))

print(sum(result))

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

int main() {
    ll h, n;
    cin >> h >> n;

    vl a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }

    vvl dp(n+1, vl(h+1, INF));  // dp[i+1][j] : i番目の魔法まででjダメージ与えるときの魔力の総和の最小値
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, h+1) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(j + a[i], h)], dp[i+1][j] + b[i]);
        }
    }

    out(dp[n][h]);
    re0;
}

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

int main()
{
    long int n,a,b,sum=0,n1,n2,i;
    scanf("%ld%ld%ld",&n,&a,&b);
    scanf("%ld",&n1);
    i=n-1;
    while(i--)
    {
        scanf("%ld",&n2);
        if(a*(n2-n1)>b) sum=sum+b;
        else sum=sum+a*(n2-n1);
        n1=n2;
    }
    printf("%ld",sum);
    return 0;
}


Measured memory_bytes: 128
import fractions

def gcd(A):
    ans = A[0]
    for x in range(1,len(A)):
        ans = fractions.gcd(ans,A[x])
    return ans
def lcm(A):
    ans = A[0]
    for x in range(1,len(A)):
        ans = ans * A[x] // fractions.gcd(ans,A[x])
    return ans
    

def main():
    n = int(input())
    T = []
    for x in range(n):
        T.append(int(input()))
    print(lcm(T))

if __name__ == '__main__':
    main()


Measured memory_bytes: 63936
N = int(input())
res = 0
for i in range(N):
  if  (i+1) // 100000 >= 1:
    pass
  elif (i+1) // 10000 >= 1:
    res +=1
  elif (i+1) // 1000 >= 1:
    pass
  elif (i+1) // 100 >= 1:
    res += 1
  elif (i+1) // 10 >= 1:
    pass
  else:
    res += 1
print(res)

Measured memory_bytes: 9120
s = input()
last = len(s)
ans = 'YES'
while last > 0:
    if s[last - 5 : last] == 'dream' or s[last - 5 : last] == 'erase':
        last -= 5
    elif s[last-6:last] == 'eraser':
        last -= 6
    elif s[last-7:last] == 'dreamer':
        last -= 7
    else:
        ans = 'NO'
        break
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <cstring>
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
int const maxn = 105;
int num[maxn];
int main(){
	int n;
	scanf("%d", &n);
	int flag = 1;
	for(int i = 0; i < n; i++){
		scanf("%d", &num[i]);
		if(num[i] % 2 == 0&&num[i] % 3 != 0&&num[i] % 5 != 0){
			flag = 0;
			break;
		}
	}
	if(flag == 1) printf("APPROVED\n");
	else printf("DENIED\n");
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC095A
{
    class Program
    {
        static void Main(string[] args)
        {
            int price = 700;
            string str = Console.ReadLine();
            if(str[0] == 'o') price += 100;
            if(str[1] == 'o') price += 100;
            if(str[2] == 'o') price += 100;
            Console.WriteLine("{0}", price);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#define repeat(n) for (size_t i = 0; i < n; i++)
#define ull unsigned long long
#define vll vector<ull>
constexpr ull MOD = 10e8+7;

using namespace std;

ull mod_saberi(ull x, ull y)
{
	return (x % MOD + y % MOD) % MOD;
}
ull mod_pomnozi(ull x, ull y)
{
	return ((x % MOD) * (y % MOD)) % MOD;
}
bool je_paran(ull broj) { return !(broj & 1); }
ull brzo_stepenuj(ull osnova, ull exponent)
{
	if (exponent == 0)
		return 1;
	if (je_paran(exponent))
	{
		ull exp_pola = brzo_stepenuj(osnova, exponent / 2);
		return mod_pomnozi(exp_pola, exp_pola);
	}
	else
	{
		ull ostatak = osnova;
		ull exp_pola = brzo_stepenuj(osnova, (exponent - 1) / 2);
		return mod_pomnozi(ostatak, mod_pomnozi(exp_pola, exp_pola));
	}
}
ull n_choose_k(ull n_faktorijel, ull k_faktorijel, ull nk_faktorijel)
{
	return mod_pomnozi(n_faktorijel, brzo_stepenuj(mod_pomnozi(k_faktorijel, nk_faktorijel), MOD - 2));
}

vll broj_nacina_do_polja(ull polja_horizontalno, ull polja_vertikalno, int broj_polja)
{
	vll broj_nacina = vll(broj_polja);
	ull n_faktorijel = 1, k_faktorijel = 1, nk_faktorijel = 1;
	for (ull i = 1; i <= polja_horizontalno + polja_vertikalno; i++)
	{
		n_faktorijel = mod_pomnozi(n_faktorijel, i);
		if (i == (polja_vertikalno))
			nk_faktorijel = n_faktorijel;
		if (i == polja_horizontalno)
			k_faktorijel = n_faktorijel;
	}

	for (size_t i = 1; i <= broj_polja; i++)
	{
		broj_nacina[i - 1] = n_choose_k(n_faktorijel, k_faktorijel, nk_faktorijel);
		n_faktorijel = mod_pomnozi(n_faktorijel, polja_horizontalno + polja_vertikalno + i);
		nk_faktorijel = mod_pomnozi(nk_faktorijel, polja_vertikalno + i);
	}
	return broj_nacina;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	vll broj_nacina_desno = broj_nacina_do_polja(W - B - 1, A, H - A);
	reverse(broj_nacina_desno.begin(), broj_nacina_desno.end());
	vll broj_nacina_levo = broj_nacina_do_polja(B - 1, 0, H - A);
	ull ukupno_nacina = 0;
	for (size_t i = 0; i < broj_nacina_levo.size(); i++)
	{
		ukupno_nacina = mod_saberi(ukupno_nacina, mod_pomnozi(broj_nacina_levo[i], broj_nacina_desno[i]));
	}
	cout << ukupno_nacina << "\n";
	return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    if (B % A == 0) {
        cout << A + B << endl;
    } else {
        cout << B-A << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] P = new int[N];
		int[] Q = new int[N];
		int a;

		for (int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
			a = P[i];
			Q[i] = a;
		}

		int count = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = N - 1; j > i; j--) {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (Q[i] - P[i] != 0) {
				count++;
			}
		}
		if(count <= 2) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}

	}

}

Measured memory_bytes: 23892
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();		
		int N = r.ri();
		int[] arr = r.ria();
		int count = 0;
		
		boolean go = true;
		while(go) {
			for(int i = 0; i<arr.length; i++)
			{
				if((arr[i]%2) == 1) {
					go = false;
					break;
				}
				arr[i] /= 2;
			}
			if(go) count++;
		}
		print(count);
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 22484
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};
struct Node T[MAX];
int n;

void preparse(int u)
{
  if( u == NIL )return;
  printf(" %d",u);
  preparse(T[u].l);
  preparse(T[u].r);
}

void inparse(int u)
{
  if( u == NIL )return;
  inparse(T[u].l);
  printf(" %d",u);
  inparse(T[u].r);
}

void postparse(int u)
{
  if( u == NIL )return;
  postparse(T[u].l);
  postparse(T[u].r);
  printf(" %d",u);
}

int main()
{
  int i;
  int right;
  int left;
  int root;
  int k;

  scanf("%d",&n);
  for( i = 0 ; i < n ; i++ ){
    T[i].p = NIL;
  }
  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d%d",&k,&left,&right);
    T[k].l = left;
    T[k].r = right;
    if( left != NIL )T[left].p = k;
    if( right != NIL )T[right].p = k;
  }
  for( i = 0 ; i < n ; i++ ){
    if( T[i].p == NIL ){
      root = i;
    }
  }
  printf("Preorder\n");
  preparse(root);
  printf("\n");
  printf("Inorder\n");
  inparse(root);
  printf("\n");
  printf("Postorder\n");
  postparse(root);
  printf("\n");

  return 0;
  
}
  



Measured memory_bytes: 2124
#include <stdio.h>
int judge(int a, int b, int c) {
	return a == b + c || b == c + a || c == a + b;
}
int main() {
	int num;
	int a, b, c;
	scanf(" %d", &num);
	while (num--) {
		scanf(" %d %d %d", &a, &b, &c);
		printf("%s\n", judge(a * a, b * b, c * c) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


ll a, b, n;
ll calc(ll x) {
    return (ll)((double)a*(double)x/(double)b) - a*(ll)((double)x/(double)b);
}

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

    ll ans = 0;
    if (b > n) ans = calc(n);
    else ans = calc(b-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

char arr[M][M];
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int bestX[M][M], bestY[M][M];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, m;
  vector<pair<int, int>> vv;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> arr[i][j];
      if(arr[i][j] == '.')
        vv.push_back({i, j});
    }
  }
  for (int i = 0; i < n; ++i) {
    int cur = 0;
    for (int j = 0; j < m; ++j) {
      if(arr[i][j] == '#') {
        if(cur) {
          int temp = cur;
          bestX[i][j - temp] = temp;
          while(cur--) {
            if(!cur)
              break;
            bestX[i][j - cur] = temp;
          }
        }
        cur = 0;
        continue;
      }
      ++cur;
    }
    int temp = cur;
    if(cur > 0) {
      bestX[i][m - temp] = temp;
    }
    while(cur--) {
      if(cur <= 0)
        break;
      bestX[i][m - cur] = temp;
    }
  }
  for (int i = 0; i < m; ++i) {
    int cur = 0;
    for (int j = 0; j < n; ++j) {
      if(arr[j][i] == '#') {
        if(cur) {
          int temp = cur;
          bestY[j - temp][i] = temp;
          while(cur--) {
            if(!cur)
              break;
            bestY[j - cur][i] = temp;
          }
        }
        cur = 0;
        continue;
      }
      ++cur;
    }
    int temp = cur;
    if(cur > 0) {
      bestY[0][i] = temp;
    }
    while(cur--) {
      if(cur <= 0)
        break;
      bestY[n - cur][i] = temp;
    }
  }
  int best = 0;
//  cerr << bestX[1][1] << ' ' << bestY[1][1];

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      best = max(best, bestX[i][j] + bestY[i][j] - 1);
    }
  }
  cout << best;
  return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int N, K;
vi logs;

bool check(int x) {
	int cnt = 0;
	for (int p : logs) {
		cnt += (p - 1) / x;
		if (cnt > K) return false;
	}
	return true;
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> K;
	logs.resize(N);
	F0R(i, N) cin >> logs[i];

	int lo = 1;
	int hi = 1e9+5;
	while (lo < hi) {
		int mid = lo + (hi - lo) / 2;
		if (check(mid)) {
			hi = mid;
		} else {
			lo = mid + 1;
		}
	}
	print(lo);
}

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

typedef struct{
  int number;
  char symbol;
}Record;

void quicksort(Record *,int,int);
int partition(Record *,int,int);
void merge(Record *,int,int,int);
void mergesort(Record *,int,int);

int main(){
  int n,p,r,i,right,left=0,x=0,j;
  Record A[N],B[N];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf(" %c%d", &(A[i].symbol), &(A[i].number));
  }

  for(i=0;i<n;i++){
    B[i].number = A[i].number;
    B[i].symbol = A[i].symbol;
  }

  r = n-1;
  right = n;
  p = 0;

  quicksort(A,p,r);

  mergesort(B,left,right);

  for(i=0;i<n;i++){
    if(!((A[i].number == B[i].number) && (A[i].symbol == B[i].symbol))){
	x = 1;
      }
  }
  if(x == 1){
    printf("Not stable\n");
  }else{
    printf("Stable\n");
    }

  for(i=0;i<n;i++){
    printf("%c %d\n",A[i].symbol,A[i].number);
    }

  return 0;
}




void quicksort(Record A[],int p,int r){
  int q;
  if(p < r){
    q = partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}

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

void merge(Record B[],int left,int mid,int right){
  int n1,n2,i,j,k;
  Record L[N],R[N];
  n1 = mid - left;
  n2 = right - mid;

  for(i=0;i<n1;i++){
    L[i] = B[left + i];
  }

  for(i=0;i<n2;i++){
    R[i] = B[mid + i];
  }

  L[n1].symbol = 'X';
  L[n1].number = 1000000000;
  R[n2].symbol = 'X';
  R[n2].number = 1000000000;
  i = 0;
  j = 0;

  for(k=left;k<right;k++){
    if(L[i].number <= R[j].number){
      B[k] = L[i];
      i++;
    }else{
      B[k] = R[j];
      j++;
    }
  }
}

void mergesort(Record B[],int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergesort(B,left,mid);
    mergesort(B,mid,right);
    merge(B,left,mid,right);
  }
}



Measured memory_bytes: 4148
#include <bits/stdc++.h>
#include <set>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
        return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //COMinit();
    string s; cin>>s;
    string ans="No";

        if(s[0]==s[1]&&s[2]==s[3])
        {
           if( s[0]!=s[2] ) ans="Yes";
        }
        else if(s[0]==s[2]&&s[1]==s[3])
        {
            if(s[0]!=s[1]) ans="Yes";
        }
        else if(s[0]==s[3]&&s[1]==s[2])
        {
            if(s[0]!=s[1]) ans="Yes";
        }


    cout<<ans<<endl;

    return 0;
    }





Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <memory.h>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)

//FILE *in = freopen("input.txt", "r", stdin);
//FILE *out = freopen("output.txt", "w", stdout);

void solution(int iMax){
	vector<ll> shorter(4, -1);
	bool ng=false;

	// 初期値
	shorter[0] = 0;
	uint currentPos = 0;
	ull currentTime = 0;
	for(int i=0;i<iMax;++i){
		vector<ull> nextTotalMove[4];
		uint p;
		ull t;
		cin >> p;
		cin >> t;

		// i-1の時の最短のパターン達からそれぞれ、一回戻るものと直接取りに行く場合を考える
		for(int k=0; k<4; ++k){
			if(shorter[k] == -1) continue;
			// 一回家に戻る場合
			ull returnTime = currentPos * (k+1) + p;
			if(returnTime+currentTime <= t){
				nextTotalMove[1].push_back(shorter[k] + currentPos + p);
			}
			// そのまま取りに行く場合
			if(k+1<=3){
				ull directTime = std::abs<int>(currentPos-p) * (k+1);
				if(directTime+currentTime <= t){
					nextTotalMove[k+1].push_back(shorter[k] + std::abs<int>(currentPos-p));
				}
			}
		}

		// 今回の考えられるパターンの中でそれぞれ持ってる風船の個数ごとに最短を更新
		for(int k=0; k<4; ++k){
			if(nextTotalMove[k].empty()){
				shorter[k] = -1;
			}else{
				shorter[k] = *std::min_element(nextTotalMove[k].begin(), nextTotalMove[k].end());
			}
		}

		if(!ng){
			// もしどうにも取れない風船が出てきたら
			int k;
			for(k=0; k<4; ++k){
				if(shorter[k] != -1) break;
			}
			if(k==4){
				cout << "NG " << i+1 << endl;
				ng = true;
			}
		}

		currentPos = p;
		currentTime = t;
	}

	ll shortest = 0x7fffffff;
	for(int k=0; k<4; ++k){
		if(shorter[k]==-1) continue;
		shortest = std::min(shorter[k], shortest);
	}
	if(!ng){
		cout << "OK " << shortest + currentPos << endl;
	}
}

int main() {
	while(true){
		int iMax;
		cin >> iMax;
		if(iMax==0) break;
		solution(iMax);
	}
	return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int ans = -999999999, minv; cin >> minv;
  for (int i = 1; i < n; ++i) {
    int a;
    cin >> a;
    ans = max(ans, a - minv);
    minv = min(minv, a);
  }
  cout << ans << endl;
  //system("pause");
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n, k;
int a[100010];
int dp[100010];

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

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

    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=dp[i-1]+abs(a[i-1]-a[i]);
        for(int j=1;j<=k && i-j>=0;j++)
            dp[i]=min(dp[i-j]+abs(a[i-j]-a[i]),dp[i]);
    }
    cout<<dp[n-1];


	return 0;
}


Measured memory_bytes: 1024
// VABC049_D
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define pll pair<ll, ll>

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.resize(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, K, L, p, q;
    cin >> N >> K >> L;
    vector<ll> res(N, 1);
    UnionFind Road(N), Rail(N);
    REP(i, K) {
        cin >> p >> q; --p; --q;
        Road.merge(p, q);
    }

    REP(i, L) {
        cin >> p >> q; --p; --q;
        Rail.merge(p, q);
    }

    // 道路でも電車でも連結してる
    // 根が同じ
    map<pll, ll> mp;
    REP(i, N) mp[{Road.root(i), Rail.root(i)}]++;
    REP(i, N) cout << mp[{Road.root(i), Rail.root(i)}] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 19584
n = int(input())
a = []
for i in range(2):
	tmp = []
	for j in map(int,input().split()):
		tmp.append(j)
	a.append(tmp)

amax = []
k = 0
for _ in range(n):
	i = 0
	sum = 0
	for j in range(n):
		sum += a[i][j]
		if k == j:
			i = 1
			sum += a[i][j]
	amax.append(sum)
	k += 1
print(max(amax))


Measured memory_bytes: 3064
#include <stdio.h>
#define MAX 100000
#define NIL -1

struct Node{
    int parent,right,left;
    int sibling,deg;
};

int getDepth(struct Node *,int);
int getHeight(struct Node *,int);

int main(){
    int n,m;
    int id,c,tmp;
    int right,left;
    int depth[MAX];
    int height[MAX];

    struct Node TREE[MAX];

    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        TREE[i].parent = TREE[i].left = TREE[i].right = TREE[i].sibling = NIL;
        TREE[i].deg = 0;
    }

    for(int i = 0;i < n;i++){
        scanf("%d",&id);
        scanf("%d%d",&right,&left);
        //j == 0の時は、子供ではなく親となるノードなので
        if(right != NIL && left != NIL){
            TREE[id].deg = 2;
            TREE[id].right = right;
            TREE[id].left = left;
            TREE[right].parent = id;
            TREE[left].parent = id;                
            TREE[right].sibling = left;
            TREE[left].sibling = right;
        }
        else if(right != NIL && left == NIL){
            TREE[id].deg = 1;
            TREE[id].right = right;
            TREE[right].parent = id;
            TREE[right].sibling = NIL;
        }
        else if(right == NIL && left != NIL){
            TREE[id].deg = 1;
            TREE[id].left = left;
            TREE[left].parent = id;
            TREE[left].sibling = NIL;
        }
    }
    for(int i = 0;i < n;i++){
        depth[i] = getDepth(TREE,i);
        height[i] = getHeight(TREE,i);
    }

    for(int i = 0; i < n; i++){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, TREE[i].parent,TREE[i].sibling,TREE[i].deg, depth[i],height[i]);
        //親がいなかったら
        if(TREE[i].parent == NIL){
            printf("root");
        }
        // 子供がいなかったら
        else if(TREE[i].left == NIL && TREE[i].right == NIL){
            printf("leaf");
        }
        // どちらでもない時
        else{
            printf("internal node");
        }
        printf("\n");  
    }

    return 0;
}

int getDepth(struct Node *TREE,int i){
    if(TREE[i].parent == NIL)return 0;
    return getDepth(TREE,TREE[i].parent) + 1;
}

int getHeight(struct Node *TREE,int i){
    int count1 = 0,count2 = 0;

    if(TREE[i].left != NIL)count1 = getHeight(TREE,TREE[i].left) + 1;
    if(TREE[i].right != NIL)count2 = getHeight(TREE,TREE[i].right) + 1;

    return ((count1 >= count2)? count1:count2);
}


Measured memory_bytes: 2104
fun main(args : Array<String>) {
    val (n, a, b) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!

    var passed = 0
    var fPos = 0

    s.forEach {
        if (it == 'c') {
            println("No")
        } else if (it == 'a') {
            if (passed < a+b) {
                println("Yes")
                passed++
            } else {
                println("No")
            }
        } else if (it == 'b') {
            fPos++
            if (passed < a+b && fPos <= b) {
                println("Yes")
                passed++
            } else {
                println("No")
            }
        }
    }
}

Measured memory_bytes: 42080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			int p = sc.nextInt();
			sum += p;
			max = Math.max(max, p);
		}
		sum -= max/2;
		System.out.println(sum);
		sc.close();
	}
}

Measured memory_bytes: 21844