akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    def gcd(a, b):
        while b: a, b = b, a % b
        return a
    def isPrimeMR(n):
        d = n - 1
        d = d // (d & -d)
        L = [2]
        for a in L:
            t = d
            y = pow(a, t, n)
            if y == 1: continue
            while y != n - 1:
                y = (y * y) % n
                if y == 1 or t == n - 1: return 0
                t <<= 1
        return 1
    def findFactorRho(n):
        m = 1 << n.bit_length() // 8
        for c in range(1, 99):
            f = lambda x: (x * x + c) % n
            y, r, q, g = 2, 1, 1, 1
            while g == 1:
                x = y
                for i in range(r):
                    y = f(y)
                k = 0
                while k < r and g == 1:
                    ys = y
                    for i in range(min(m, r - k)):
                        y = f(y)
                        q = q * abs(x - y) % n
                    g = gcd(q, n)
                    k += m
                r <<= 1
            if g == n:
                g = 1
                while g == 1:
                    ys = f(ys)
                    g = gcd(abs(x - ys), n)
            if g < n:
                if isPrimeMR(g): return g
                elif isPrimeMR(n // g): return n // g
                return findFactorRho(g)
    #[(p1,n1),(p2,n2),...]の形で返す
    def primeFactor(n):
        i = 2
        ret = {}
        rhoFlg = 0
        while i*i <= n:
            k = 0
            while n % i == 0:
                n //= i
                k += 1
            if k: ret[i] = k
            i += 1 + i % 2
            if i == 101 and n >= 2 ** 20:
                while n > 1:
                    if isPrimeMR(n):
                        ret[n], n = 1, 1
                    else:
                        rhoFlg = 1
                        j = findFactorRho(n)
                        k = 0
                        while n % j == 0:
                            n //= j
                            k += 1
                        ret[j] = k

        if n > 1: ret[n] = 1
        if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
        return ret
    
    from math import gcd
    N=I()
    A=LI()
    from collections import defaultdict
    dd = defaultdict(int)
    flag=1
    
    for i in range(N):
        a=A[i]
        ret=primeFactor(a)
        for p,pn in ret.items():
            if dd[p]:
                flag=0
                break
            dd[p]+=1
            
    if flag:
        print("pairwise coprime")
    else:
        g=A[0]
        for i in range(1,N):
            g=gcd(g,A[i])
        if g==1:
            print("setwise coprime")
        else:
            print("not coprime")
                
            
    

main()


Measured memory_bytes: 185860
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

bool comp(string &a, string &b)
{
	if (a.size() == b.size()) return a < b;
	else return a.size() < b.size();
}

int main()
{
	int n;
	while (cin >> n, n)
	{
		vs v, t(n);
		REP(i, n) cin >> t[i];
		sort(ALL(t));
		t.erase(unique(ALL(t)), t.end());
		REP(i, t.size())
		{
			bool f = true;
			REP(j, t.size())
			{
				if (i == j) continue;
				if (t[j].find(t[i]) != string::npos) f = false;
			}
			if (f) v.push_back(t[i]);
		}
		string mp[11][11];
		REP(i, v.size())REP(j, v.size())
		{
			if (i == j) continue;
			for (int k = min(v[i].size(), v[j].size()); k >= 0; k--)
			{
				string x = v[i].substr(v[i].size() - k);
				string y = v[j].substr(0, k);
				if (x == y)
				{
					mp[i][j] = v[j].substr(k);
					break;
				}
			}
		}
		n = v.size();
		int index[20];
		REP(i, n) index[i] = i;
		string ans(111, 'z');
		do
		{
			string tmp = v[index[0]];
			FOR(i, 1, v.size())
			{
				tmp += mp[index[i-1]][index[i]];
			}
			if (ans.size() > tmp.size()) ans = tmp;
			else if (ans.size() == tmp.size()) chmin(ans, tmp);
		} while (next_permutation(index, index + n));
		cout << ans << endl;
	}
	return 0;
}

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

a = int(input())
b = int(input())
c = int(input())
x = int(input())

counter = 0
s = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            s = 500 * i + 100 * j + 50 * k
            if x == s:
                counter += 1
            s = 0

print(counter)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K;
	cin >> N >> K;
	ll a = 0;
	ll b = 0;
	ll ans = 0;
	for(ll i = 1;i<=N;i++){
		if(i%K==0)a++;
		if(K%2==0 && i%K==(K/2))b++;
	}
	ans = (ll)pow(a,3) + (ll)pow(b,3);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
int main(){
	long long int k=0;
	long long int a=0;
	long long int b=0;
	scanf("%lld %lld %lld\n",&k,&a,&b);
	if(a+2<b){
		if(k-(a-1)>0){
			int change=(k-(a-1))/2;
			printf("%lld\n",1+change*(b-a)+k-change*2);
		}else{
			printf("%lld\n",1+k);
		}
	}else{
		printf("%lld\n",1+k);
	}
}

Measured memory_bytes: 128
A, B = gets.chomp.split.map(&:to_i)

result = -1
for i in (A / 0.08).to_i..((A + 1) / 0.08) do
  if (i * 0.08).floor == A && (i * 0.1).floor == B then
    result = i
    break
  end
end
puts result 

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

const int maxn = 3005, M = 998244353;
int n, s;
ll a[maxn];

void madd(ll& a, ll b) {
    a += b;
    a %= M;
}

ll dp[maxn][maxn][3];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> s;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    dp[1][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= s; j++) {
            madd(dp[i+1][j][0],dp[i][j][0]);
            madd(dp[i+1][j][1],(dp[i][j][0]+dp[i][j][1])%M);
            madd(dp[i+1][j][2],(dp[i][j][0]+dp[i][j][1]+dp[i][j][2])%M);
            if (j+a[i] <= s) {
                madd(dp[i+1][j+a[i]][1],(dp[i][j][0]+dp[i][j][1])%M);
                madd(dp[i+1][j+a[i]][2],(dp[i][j][0]+dp[i][j][1])%M);
            }
        }
    }
    ll ans = dp[n+1][s][2];
    cout << ans << '\n';
}




Measured memory_bytes: 211584
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#include "bits/stdc++.h"

namespace adaptor = boost::adaptors;

struct Point {
    double x, y;
};

void koch(int64_t n, Point a, Point b) {
    if (n == 0) return;
    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    std::cout << s.x << " " << s.y << std::endl;
    koch(n - 1, s, u);
    std::cout << u.x << " " << u.y << std::endl;
    koch(n - 1, u, t);
    std::cout << t.x << " " << t.y << std::endl;
    koch(n - 1, t, b);
}

void solve() {
    Point a, b;
    int64_t n;
    std::cin >> n;

    a.x = 0.0;
    a.y = 0.0;
    b.x = 100.0;
    b.y = 0.0;

    std::cout << a.x << " " << a.y << std::endl;
    koch(n, a, b);
    std::cout << b.x << " " << b.y << std::endl;

    return;
}

int main() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(8);
    solve();
}



Measured memory_bytes: 3296
#include<stdio.h>
void printflame(int w){
	int i;
	printf("+");
	for(i=0;i<w-2;i++){
		printf("-");
	}
	printf("+\n");
	return;
}
void printbox(int w){
	int i;
	printf("|");
	for(i=0;i<w-2;i++){
		printf(".");
	}
	printf("|\n");
	return;
}
void printchar(int w,char c){
	int i;
	printf("|");
	for(i=0;i<(w-3)/2;i++){
		printf(".");
	}
	printf("%c",c);
	for(i=0;i<(w-2)/2;i++){
		printf(".");
	}
	printf("|\n");
	return;
}
int main()
{
	int w,h,i;
	char c;
	scanf("%d %d %c",&w,&h,&c);
	printflame(w);
	for(i=0;i<(h-3)/2;i++){
		printbox(w);
	}
	printchar(w,c);
	for(i=0;i<(h-3)/2;i++){
		printbox(w);
	}
	printflame(w);
	return 0;
}



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

#define N 2

int matrix(double **x);
 
int main(void){
	double x[N][N+1];
	double *y[N];
	double su1=0,su2=0;
	int i,j,k,n;
	char str[100],*line;
    
	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		for(i=0;i<N;i++){
			for(j=0;j<N+1;j++){
				if(i==0 && j==0)
					line = strtok(str," ");
				else
					line = strtok(NULL," ");
				sscanf(line,"%d",&n);
				x[i][j]=n;
			}
		}
		for(i=0;i<N;i++)
			y[i]=x[i];
		matrix(y);
		for(i=0;i<N;i++){
			if(i) printf(" ");
			printf("%3.3f",x[i][N]);
		}
		printf("\n");
	}
	return 0;
}

int matrix(double **x){
	int i,j,k;
	double su1=0,su2=0;

	for(k=0;k<=N-2;k++){
		for(j=k+1;j<=N-1;j++){
			su1=x[k][k];
			su2=x[j][k];
			for(i=0;i<=2;i++){
				x[j][i]=x[j][i]-x[k][i]*su2/su1;
			}
		}
	}	
	for(k=0;k<=N-2;k++){
		for(j=k+1;j<=N-1;j++){
			su1=x[1-k][1-k];
			su2=x[1-j][1-k];
			for(i=0;i<=2;i++){
				x[1-j][i]=x[1-j][i]-x[1-k][i]*su2/su1;
			}
		}
	}
	su1=0;
	for(j=0;j<=N-1;j++){
	su1=x[j][j];
		for(i=0;i<=N;i++){
		x[j][i]=x[j][i]/su1;
		}	
	}
	return 0;
}

Measured memory_bytes: 652
program digital_gifts
  implicit none
  integer :: n, i, j = 0
  character(1) :: u
  real(8) :: x, b = 0.d0
  character(64) :: s
  read(*,*) n
  do i = 1, n
    read(*,*) x, u
    if (u == "J") then
      j = j+nint(x)
    else
      b = b+x
    end if
  end do
  write(s,'(f32.16)') 380000.d0*b+j
  write(*,'(a)') trim(adjustl(s))
end program digital_gifts

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l.at(i);
    }

    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());

    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans += l.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()
d = {'r':P, 's':R, 'p':S}

ans = 0
for k in range(K):
    ban = True
    pre = '_'
    for i in range(k,N,K):
        if T[i] != pre:
            ans += d[T[i]]
            ban = True
        elif ban:
            ban = False
        else:
            ans += d[T[i]]
            ban = True
        pre = T[i]
print(ans)

Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

auto main (void) -> int {
  string s, t;
  cin >> s;
  cin >> t;

  int s_length = s.length ();
  int t_length = t.length ();

  int min_diff = t_length;

  for (auto i = 0; i <= s_length - t_length; i++) {
    int diff = 0;

    for (auto j = 0; j < t_length; j++) {
      if (s[i + j] != t[j]) diff++;
    }

    min_diff = min (min_diff, diff);
  }

  cout << min_diff << endl;

  return 0;
}


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

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

signed main(){
    string s, t;
    cin>>s>>t;
    int n1 = s.size();
    int n2 = t.size();
    int dp[n1+1][n2+1];
    for(int i=0; i<=n1; i++){
        for(int j=0; j<=n2; j++){
            if(i==0 || j==0) dp[i][j] = 0;
            else if(s[i-1] == t[j-1]) dp[i][j] = 1 + dp[i-1][j-1];
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    int index = dp[n1][n2];
    char lcs[index+1];
    lcs[index] = '\0';
    int i =n1 , j=n2;
    while(i>0 && j>0){
        if(s[i-1] == t[j-1]){
            lcs[index-1] = s[i-1];
            index--;
            j--;
            i--;
        }
        else if(dp[i][j-1] > dp[i-1][j]) j--;
        else i--;

    }
    cout<<lcs<<endl;
    return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


int prime[200000];
bool is_prime[1000001];

void sieve()
{
	for (int i=0; i<1000001; i++) is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for (int i=2; i<1000001; i++)
	{
		if (is_prime[i])
		{
			for (int j=2*i; j<1000001; j+=i) is_prime[j] = false;
		}
	}
	return;
}


int main()
{
	int a, d, n;
	
	sieve();
	
	while (cin >> a >> d >> n, a || d || n)
	{
		int cnt = 0;
		
		for (int i=a; 1; i+=d)
		{
			if (is_prime[i])
			{
				cnt++;
			}
			if (cnt == n)
			{
				cout << i << endl;
				break;
			}
		}
	}
	
	return 0;
}


bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

ll gcd(ll a, ll b)
{
	return (b > 0) ? gcd(b, a % b) : a;
}

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

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 2136
/*12??????????????????????¢????
 * 
 * Created by SharpDevelop.
 * User: yog-sothoth
 * Date: 2017/04/23
 * Time: 17:25
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System.Collections.Generic;
using System;
using System.IO;

namespace Dictionary
{
	
	public class DictionaryList
	{
		
		
		public static void Main(string[] args)
		{		
			int num = int.Parse(Console.ReadLine());// the number of instructions
			
			
			bool[] table = new bool[250000000];
		
			var sw = new StreamWriter(Console.OpenStandardOutput())
	    	{ AutoFlush = false };
			
			Console.SetOut(sw);
			
			for (int i = 0; i < num; i++) {
				string iands = Console.ReadLine();//instruction and s tring
				string[] instAndStr = iands.Split();
			
				
				//Add list instAndStr[1]		
				if (instAndStr[0] == "insert") {//??????????????\???
					//??????????????°????????????????????????table[index]???????????°??????????????????????????¨????????????????????§????????????
					//????????°???????????????
					int index = 0;
					for (int j = 0; j < instAndStr[1].Length; j++) {
			
						index *= 4;
				
						switch (instAndStr[1][j]) {
							case 'A':
								index += 1;
								break;
							case 'C':
						
								index += 2;
						
								break;
							case 'G':
						
								index += 3;
								break;
							case 'T':
						
								index += 4;
								break;			
						}
						
		
					}
					table[index]=true;
		
					
				} else { //?????????find
					
					
					int index = 0;
					for (int k = 0; k < instAndStr[1].Length; k++) {
			
						index *= 4;
				
						switch (instAndStr[1][k]) {
							case 'A':
								index += 1;
								break;
							case 'C':
						
								index += 2;
						
								break;
							case 'G':
						
								index += 3;
								break;
							case 'T':
						
								index += 4;
								break;			
						}
						
		
					}
					if(table[index]!=true)
					{
						Console.WriteLine("no");
					}else
						Console.WriteLine("yes");
				}
				
			}
			Console.Out.Flush();
		}
		
	}
}

Measured memory_bytes: 380220
#coding:utf-8
S=raw_input()

all=1
a=ab=abc=0
MOD=(10**9)+7
for _ in range(len(S)):
    i=_+1
    c=S[_]
    if c=="A":
        a+=all
    if c=="B":
        ab+=a
    if c=="C":
        abc+=ab
    if c=="?":
        abc=abc*3+ab
        ab=ab*3+a
        a=a*3+all
        all*=3
    a%=MOD
    ab%=MOD
    abc%=MOD
    all%=MOD
print(abc%((10**9)+7))

    














Measured memory_bytes: 5892
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long

int32_t main() {
	int n;
	cin >> n;
	cout << (1000 - (n % 1000)) % 1000;
	return 0;
}


Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



class UnionFind {
	vector<int> par;
	vector<int> rank;
public:
	UnionFind(int max_n) :par(max_n), rank(max_n) {}
	void init(int n) {
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};


int N, M, K;
int A[100000];
int B[100000];
int C[100000];
int D[100000];
unordered_set<int> fri[100000];
vector<int> block[100000];


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

	cin >> N >> M >> K;
	UnionFind uf(N);
	uf.init(N);

	rep(i, M) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
		uf.unite(A[i], B[i]);
		fri[A[i]].insert(B[i]);
		fri[B[i]].insert(A[i]);
	}
	vector<int> si(N, 0);
	rep(i, N) si[uf.find(i)]++;

	rep(i, K) {
		cin >> C[i] >> D[i];
		C[i]--; D[i]--;
		block[C[i]].push_back(D[i]);
		block[D[i]].push_back(C[i]);
	}

	rep(i, N) {
		int ans = si[uf.find(i)] - 1;

		for (int f: fri[i]) {
			if (uf.same(i, f)) {
				ans--;
			}
		}
		for (int b : block[i]) {
			if (uf.same(i, b) && fri[b].count(b) == 0) {
				ans--;
			}
		}
		if (i)cout << ' ';
		cout << ans;
	}
	cout << endl;


	return 0;
}

Measured memory_bytes: 24576
#include <cstdio>
int main (){
	int N;
	long long x, a[100000], ans = 0;
	scanf("%d %lld", &N, &x);
	for (int i = 0; i < N; i++)
		scanf("%lld", &a[i]);
	for (int i = 0; i < N; i++){
		if (a[i] > x){
			ans += a[i] - x;
			a[i] = x;
		}
	}
	for (int i = 1; i < N; i++){
		if (a[i - 1] + a[i] > x){
			ans += a[i - 1] + a[i] - x;
			a[i] = x - a[i - 1];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
int main(void){
	
	int n,i;
	double man=0,yu2=0,yu3,che=0;
	scanf("%d",&n);
	int x[n],y[n];
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	for(i=0;i<n;i++){
		scanf("%d",&y[i]);
	}
	for(i=0;i<n;i++){//マンハッタン距離 
		if(x[i]>y[i]){
			man+=x[i]-y[i];
		}
		else{
			man+=y[i]-x[i];
		}
	}
	for(i=0;i<n;i++){//ユークリッド２ 
		if(x[i]>y[i]){
			yu2+=(x[i]-y[i])*(x[i]-y[i]);
		}
		else{
			yu2+=(y[i]-x[i])*(y[i]-x[i]);
		}
	}
	yu2=sqrt(yu2);
	for(i=0;i<n;i++){//ユークリッド3 
		if(x[i]>y[i]){
			yu3+=(x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]);
		}
		else{
			yu3+=(y[i]-x[i])*(y[i]-x[i])*(y[i]-x[i]);
		}
	}
	yu3=pow(yu3,1.0/3.0);
	
	for(i=0;i<n;i++){//チェビシェフ距離 
		if(x[i]>y[i]){
			if(che<x[i]-y[i]) che=x[i]-y[i];
		}
		else{
			if(che<y[i]-x[i]) che=y[i]-x[i];
		}
	}
	
	
	
	printf("%lf\n%lf\n%lf\n%lf\n",man,yu2,yu3,che);
	return 0;
}


Measured memory_bytes: 2036
program main
    implicit none
    real(8) x, y, z, v, vmax
    real(8) xmax, ymax, zmax
    integer i, j, L

    read(*,*) L 
    vmax = 0.0

    do i = 1, 100
        x = real(L)/100.0*real(i)
        do j = 1, 100
            y = (real(L) - x)/100.0*real(j)
            z = real(L) - x - y
            v = x*y*z
            if (v > vmax) then
                vmax = v
                xmax = x
                ymax = y
                zmax = z
            end if
        end do
    end do

    do i = -50, 50
        x = xmax + real(L)/10000.0*real(i)
        do j = -50, 50
            y = ymax + real(L)/10000.0*real(j)
            z = real(L) - x - y
            v = x*y*z
            if (v > vmax) then
                vmax = v
            end if
        end do
    end do

    write(*,*) vmax


end program

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int sum=0;
    for(int i=0;i<=n;i++){
        string ni=to_string(i);
        int dsum=0;
        for(int j=0;j<ni.size();j++){
            dsum+=ni.at(j)-'0';
        }
        if(dsum>=a && b>=dsum) sum+=i;
    }
    cout << sum << endl;

}

Measured memory_bytes: 256
#!/usr/bin/ruby
# encoding: utf-8

#main

# input 
N,M = gets.split.map(&:to_i)
L = Array.new(M)
R = Array.new(M)

(0..M-1).each do |i|
  L[i],R[i] = gets.split.map(&:to_i)
end

ans = 0
ans = [R.min - L.max + 1,0].max

puts ans  


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

double pi=3.141592653589793238;

int main(){
  double x;
  cin >> x;
  cout << fixed << setprecision(6);
  cout << pi * x * x << ' ';
  cout << 2.0 * pi * x << endl;

  return 0;
}



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

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

    int count = 0;

    if(N>=3*5*7) count++;
    if(N>=3*5*11) count++;
    if(N>=3*5*13) count++;
    if(N>=3*3*3*5) count++;
    if(N>=3*3*3*7) count++;

    cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
N,A,B,C,D=map(int,input().split())
S=input()

if C<D:
  if '##' not in S[A-1:C] and '##' not in S[B-1:D]:
    print('Yes')
  else:
    print('No')
else:
  if '##' not in S[A-1:] and '...' in S[B-2:D+1]:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 3572
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

s = STR()
n = len(s) + 1
arr = [0 for _ in range(n)]
for i in range(n - 1):
    if s[i] == '<':
        arr[i + 1] = arr[i] + 1
debug(arr)
for i in reversed(range(n - 1)):
    debug(i - 1, i)
    if s[i] == '>':
        arr[i] = max(arr[i], arr[i + 1] + 1)
debug(arr)
print(sum(arr))


Measured memory_bytes: 98376
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,k;
    cin>>n>>k;
    if(k==1)cout<<0<<endl;
    else {
        cout<<n-k<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int a=ir.nextInt();
		int b=ir.nextInt();
		int c=ir.nextInt();
		out.println(a<=c&&b>=c?"Yes":"No");
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 22100
#include <iostream>
using namespace std;
int main(void){
    int x,y,t;
    // Your code here!
    for(int i=1;i>0;i++){
        
        cin>>x>>y;
        if(x==0&&y==0) break;
        if(x>y){
            t=x;
            x=y;
            y=t;
            
        }
        cout<<x<<" "<<y<<"\n";

   }
   }



Measured memory_bytes: 3020
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e15+100)
#define N 100005



// Driver code to tes above functions
int32_t main()
{
    
 
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    
    int l, r;
    cin >> l >> r;

    if(r-l>=2019)
        cout << 0;
    else
    {
        int ans = MAXI;
        for(int i=l;i<=r;i++)
        {
            for(int j=i+1;j<=r;j++)
            {
                ans = min(ans, (i*j)%2019);
            }
        }
        cout << ans;
    }

    return 0;
    
} 

Measured memory_bytes: 256
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.annotation.tailrec
import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map(converter)
  }

  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val (n, k, c) = get[Int, Int, Int]
    val s = get[String]

    val mins = Array.fill(k)(Int.MaxValue)

    @tailrec
    def updateEager(today: Int, work: Int, off: Int, calendar: List[Char]): Unit = {
      if (work != 0) {
        calendar match {
          case Nil =>
          case 'x' :: rest =>
            updateEager(today + 1, work, Math.max(off - 1, 0), rest)
          case 'o' :: rest =>
            if (off > 0) {
              updateEager(today + 1, work, off - 1, rest)
            } else {
              mins(k - work) = today
              updateEager(today + 1, work - 1, c, rest)
            }
          case x => throw new Error(x.toString())
        }
      }
    }
    updateEager(0, k, 0, s.toList)

    val maxs = Array.fill(k)(Int.MinValue)
    @tailrec
    def updateLazier(today: Int, work: Int, off: Int, calendar: List[Char]): Unit = {
      if (work != 0) {
        calendar match {
          case Nil =>
          case 'x' :: rest =>
            updateLazier(today - 1, work, Math.max(off - 1, 0), rest)
          case 'o' :: rest =>
            if (off > 0) {
              updateLazier(today - 1, work, off - 1, rest)
            } else {
              maxs(work - 1) = today
              updateLazier(today - 1, work - 1, c, rest)
            }
          case x => throw new Error(x.toString())
        }
      }
    }
    updateLazier(n - 1, k, 0, s.toList.reverse)

    mins.zip(maxs).foreach {
      case (min, max) =>
        if (min == max) {
          out.println(min + 1)
        }
    }

    out.flush()
  }
}

Measured memory_bytes: 74136
import bisect
import copy
import heapq
import sys
import itertools
import math
from functools import lru_cache
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N = int(input())
    A = read_list()
    A.sort(reverse=True)
    
    res = 0
    for n in range(N):
        if n == 0:
            res += 0
        else:
            res += A[n // 2]

    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32180
# -*- coding: utf-8 -*-
# 整数の入力
s, t = input().split()
# スペース区切りの整数の入力
a, b = map(int, input().split())

u = input()
if s == u:
  a = a-1
else:
  b = b-1

print("{} {}".format(a, b))

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    int sum = 0;
    int a;
    for(int i = 0; i < N; i ++)
    {
        cin >> a;
        sum += a - 1;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.LongStream;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String str1 = scan.nextLine();

		String[] stringArray = str1.split(" ");

		long numberA = Long.parseLong(stringArray[0]);
		long numberB = Long.parseLong(stringArray[1]);

		Long[] commonDivisors = calculateCommonDivisor(numberA, numberB);

		Long[] results = likeSieveOfEratosthenes(commonDivisors);

		System.out.println(results.length);
	}

	public static Long[] calculateCommonDivisor(long numberA, long numberB) {

		long highNumber = Math.max(numberA, numberB);

		List<Long> divisorList = calculateDivisor(highNumber);

		long lowNumber = numberA == highNumber
				? numberB
				: numberA;

		List<Long> commonDivisorList = divisorList.stream()
				.filter(l -> lowNumber % l == 0)
				.collect(Collectors.toList());

		return commonDivisorList.toArray(new Long[commonDivisorList.size()]);
	}

	public static List<Long> calculateDivisor(long number) {

		List<Long> halfResultArray = new ArrayList<>();

		long[] targetArray = LongStream.range(1, (long) Math.sqrt(number) + 1)
				.toArray();

		for (long targetNumber : targetArray) {

			if (number % targetNumber == 0) {
				halfResultArray.add(targetNumber);
			}
		}

		List<Long> resultArray = new ArrayList<>();
		resultArray.addAll(halfResultArray);

		for (long targetNumber : halfResultArray) {

			resultArray.add(number / targetNumber);
		}

		return resultArray;
	}

	public static Long[] likeSieveOfEratosthenes(Long[] targetArray) {

		List<Long> resultArray = new ArrayList<>();

		while (targetArray.length > 0) {

			long firstNumber = targetArray[0];

			resultArray.add(targetArray[0]);

			if (firstNumber == 1) {

				// 1だけ除外する
				targetArray = Arrays.stream(targetArray)
						.filter(i -> i != 1)
						.toArray(l -> new Long[l]);
			} else {

				targetArray = Arrays.stream(targetArray)
						.filter(i -> i % firstNumber != 0)
						.toArray(l -> new Long[l]);
			}
		}

		return resultArray.toArray(new Long[resultArray.size()]);
	}
}

Measured memory_bytes: 35668
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const int INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,m_a,m_b;
	cin >> n >> m_a >> m_b;
	vector<int> a(n+1),b(n+1),c(n+1);
	for(int i = 1; i <= n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}

	int dp[41][401][401] = {0};

	for(int i = 0; i <= 40; i++){
		for(int j = 0; j <=400; j++){
			for(int k = 0; k <= 400; k++){
				dp[i][j][k] = INF;
			}
		}
	}

	dp[0][0][0] = 0;
	for(int i = 1; i <= 40; i++){
		for(int j = 400; j >= 0; j--){
			for(int k = 400; k >= 0; k--){
				if(j-a[i]>=0 && k-b[i]>=0){
					dp[i][j][k] = min(dp[i-1][j-a[i]][k-b[i]]+c[i],dp[i-1][j][k]);
				}else{
					dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k]);
				}
			}
		}
	}

	int ans = INF;
	for(int j = 1; j <= 400; j++){
			for(int k = 1; k <= 400; k++){
				if(k*m_a == j*m_b && dp[n][j][k] < ans) ans = dp[n][j][k];
			}
		}

	if(ans == INF) cout << -1 << endl;
	else cout << ans << endl;

	return 0;
}

Measured memory_bytes: 25984
n=int(input())
l=list(map(int,input().split()))
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
d={2:0}
import collections
for y in l:
  c = collections.Counter(prime_factorize(y))
  for x in c:
    if x in d:
      d[x]=max(d[x],c[x])
    else:
      d[x]=c[x]
mod=10**9+7
gc=1
for x in d:
  gc*=(x**d[x])%mod
ans=0
inv=[1]*1000002
for i in range(2,1000002):
  inv[i]=mod-(inv[mod%i]*(mod//i))%mod
for x in l:
  ans+=gc*inv[x]%mod
print(ans%mod)
      
      
    

Measured memory_bytes: 59224
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<set>
#include<iomanip>
using ll=long long int;
using namespace std;


int main() {

	int n, k;
	cin >> n >> k;
	int ans = 1;

	for (int i = 0; i < n; i++) {
		if (ans * 2 < ans + k) {
			ans *=2;
		}
		else {
			ans += k;
		}
	}

	cout << ans << endl;

	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using ull = unsigned long long;
using ul = unsigned;
using ll = long long;
#define mod 10e+7+7
#define rep(i,a,b) for (int i =a;i<b;++i)
using namespace std;
void solve();
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin); 
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
#endif
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();
	 cout<<"\n";
	}
	
	cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	return 0;

}
void solve()
{
	int n;
	cin>>n;
	int h[n];
	rep(i,0,n)
	cin>>h[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min((dp[i-1]+abs(h[i]-h[i-1])),(dp[i-2]+abs(h[i]-h[i-2])));
		//cout<<dp[i]<<" ";
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 4540
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;

template<class T> struct PrimalDual {
    
  struct Edge {
    int to, rev;
    T cap, cost;
    Edge () {}
    Edge (int _to, T _cap, T _cost, int _rev) :
      to(_to), cap(_cap), cost(_cost), rev(_rev) {}
  };
    
  const T INF = numeric_limits<T>::max() / 2;
  int N;
  vector< vector< Edge > > G;
  vector< T > h;
  vector< T > dist;
  vector< int > prevv, preve;
  PrimalDual (int n) : N(n), G(n), h(n), dist(n), prevv(n), preve(n) {}
    
  void add_edge(int from, int to, T cap, T cost) {
    G[from].push_back(Edge(to,cap,cost,(T)G[to].size()));
    G[to].push_back(Edge(from,0,-cost,(T)G[from].size()-1));
  }
    
  T get_min(int s, int t, T f) {
    T ret = 0;
    fill(h.begin(),h.end(),0);
    while (f > 0) {
      priority_queue< pair<T,int>, vector< pair<T,int> >, greater< pair<T,int> > > que;
      for (int i = 0; i < N; i++) dist[i] = INF;
      dist[s] = 0;
      que.push(make_pair(0,s));
      while (que.size() != 0) {
	pair< T, int > p = que.top();
	que.pop();
	int v = p.second;
	if (dist[v] < p.first) continue;
	for (int i = 0; i < G[v].size(); i++) {
	  Edge &e = G[v][i];
	  if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
	    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
	    prevv[e.to] = v;
	    preve[e.to] = i;
	    que.push(make_pair(dist[e.to], e.to));
	  }
	}
      }
      if (dist[t] == INF) {
	return -1;
      }
      for (int v = 0; v < N; v++) h[v] += dist[v];
      T d = f;
      for (int v = t; v != s; v = prevv[v]) {
	d = min(d,G[prevv[v]][preve[v]].cap);
      }
      f -= d;
      ret += d * h[t];
      for (int v = t; v != s; v = prevv[v]) {
	Edge &e = G[prevv[v]][preve[v]];
	e.cap -= d;
	G[v][e.rev].cap += d;
      }
    }
    return ret;
  }
    
};

int main(){
  int V, E, F;

  cin >> V >> E >> F;
  PrimalDual<int> Graph(V);

  for(int i =0;i<E;i++){
    int ui,vi,ci,di;
    cin >> ui >> vi >> ci >> di;
    Graph.add_edge(ui,vi,ci,di);
  }
  
  cout << Graph.get_min(0,V-1,F) << endl;

  
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A+B)>(C+D)) {
    cout << "Left" << endl;
  }
  else if ((A+B)==(C+D)) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
  
  }

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";

        while ((line = br.readLine()) != null && !line.isEmpty()) {
            char[] str = line.toCharArray();
            char c;
            for (int i = 0; i < str.length / 2; i++) {
                c = str[i];
                str[i] = str[str.length - 1 - i];
                str[str.length - 1 - i] = c;
            }
            System.out.println(new String(str));
        }
    }
}

Measured memory_bytes: 16876
// https://atcoder.jp/contests/abc078/tasks/arc085_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> v(n);
    REP(i, n) cin >> v[i];
    if (n == 1) {
        cout << abs(v[0] - w) << endl;
    } else {
        int t1 = abs(v[n - 1] - w);
        int t2 = abs(v[n - 1] - v[n - 2]);
        cout << max(t1, t2) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int l, r;
	l = a + b;
	r = c + d;
	if (l > r) cout << "Left" << endl;
	else if (l < r)cout << "Right" << endl;
	else cout << "Balanced" << endl;

	return 0;
}

Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
          _
          int A,B,C,X,Y,ans=0;
          cin >> A >> B >> C >> X >> Y;
          if(A+B<2*C){
            ans=X*A+Y*B;
          }else{
            ans=min(X,Y)*C*2+max(X-Y,0)*min(A,2*C)+max(Y-X,0)*min(B,2*C);
          }
          cout << ans << endl;

return 0;
}




Measured memory_bytes: 256
# coding: utf-8

cnt = int()
m = int()
g = []

def insersion_sort(a, n, g):
    global cnt
    for i in xrange(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            cnt += 1
        a[j+g] = v
    return list(a)

def shell_sort(a, n):
    global cnt
    global m
    global g
    cnt = 0
    m = 0
    g = []
    nn = n
    while True:
        nn = nn/2
        if nn < 1:
            break
        g.append(nn)
        m += 1
    if n == 1:
        m = 1
        g = [1]
    for i in g:
        a = insersion_sort(a, n, i)
    return a

def main():
    global cnt
    global m
    global g
    n = input()
    a = []
    for i in xrange(n):
        a.append(input())
    a = shell_sort(a, n)
    print m
    print " ".join(map(str, g))
    print cnt
    for i in xrange(n):
        print a[i]

main()

Measured memory_bytes: 53640
#include <stdio.h>

int main(void)
{
	int i, j;
	int a[4];
	int b[4];
	int hit;
	int blow;
	
	while (scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF){
		hit = 0; blow = 0;
		for (i = 0; i < 4; i++){
			if (a[i] == b[i]){
				hit++;
				a[i] = 10;
			}
		}
		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if (a[i] == b[j]){
					blow++;
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}
	return (0);
}

Measured memory_bytes: 592
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int a[100005], b[100005], t[100005]; 
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d %d %d", &t[i], &a[i], &b[i]);
	}
	for(int i = 0; i < n; i++)
	{
		if(a[i]+ b[i] > t[i])
		{
			printf("No\n");
			return 0;
		}
		if((a[i] + b[i]) % 2 != t[i] % 2)
		{
			printf("No\n");
			return 0;
		}
		if((a[i] + b[i]) % 2 == t[i] % 2 && a[i] + b[i] <= t[i])
		{
			continue;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1280
# coding: utf-8
# Your code here!
H,W=map(int,input().split())
S=[]
ans=0

for _ in range(H):
    S.append(list(input()))

l=[[0]*W for _ in range(H)]

for h in range(H):
    count=0
    start=0
    for i in range(W):
        if S[h][i]=="#":
            count=0
            start=i+1
        else:
            count+=1
            l[h][i]+=count

for h in range(H):
    count=0
    start=W-1
    for i in range(W)[::-1]:
        if S[h][i]=="#":
            count=0
            start=i
        else:
            count+=1
            l[h][i]+=count

for w in range(W):
    count=0
    start=0
    for i in range(H):
        if S[i][w]=="#":
            count=0
            start=i+1
        else:
            count+=1
            l[i][w]+=count

for w in range(W):
    count=0
    start=H-1
    for i in range(H)[::-1]:
        if S[i][w]=="#":
            count=0
            start=i
        else:
            count+=1
            l[i][w]+=count
            ans=max(ans,l[i][w])

print(ans-3)


Measured memory_bytes: 214280
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
        int X = sc.nextInt();
        int a = sc.nextInt();
        int ans = X-a;

        if (ans < 0) {
            ans = 0;
        }

        System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 21840