akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long a[222222],b[222222];
int main()
{
	long long n,m,k;
	cin>>n>>m>>k;
	a[0]=b[0]=0;
	for(long long i=1;i<=n;i++)
	{
		long long tmp;cin>>tmp;
		a[i]=a[i-1]+tmp;
	 }
	 for(long long i=1;i<=m;i++)
	{
		long long tmp;cin>>tmp;
		b[i]=b[i-1]+tmp;
	 }
	 int maxn=0;
	 int j=m;
	 for(int i=0;i<=n;i++)
	 {
	 		for(;j>=0;j--)
	 		{
	 			if(a[i]+b[j]>k) continue;
	 			else {
	 				maxn=max(maxn,i+j);break;
				 }
			 }
	   }  
	   cout<<maxn;
	return 0; 
 } 

Measured memory_bytes: 6744
#include <iostream>
#include <algorithm>
#include <vector>
#include<queue>
using namespace std;
typedef long long ll;
ll h[100005][2] = {0};
priority_queue <ll,vector<ll>,greater<ll>>P;
int main()
{
	long long int n, m,a;
	cin >> n >> m;
	ll ZZ = n;
//	long long int sum = 0;
	for (ll i = 1; i <= n; i++) {
		cin >> a;
		P.push(a);
	}
	for (ll i = 1; i <= n; i++) {
		h[i][0]=P.top();
		P.pop();
	}
	priority_queue <pair<ll, ll>>Q;

	for (ll i = 1; i <= m;i++) {
		long long int b, c;
		cin >> b >> c;
		Q.push(make_pair(c, b));
	}
	long long int Nsum=0;
	ll k = 1;
	while (Q.empty()==0) {

		for (ll i = 1; i <=  Q.top().second; i++) {
			h[k][1] = Q.top().first;
		//	cout << "#" << h[k][1] << endl;/////////////////////
			k++;

			if (k > ZZ)break;
		}
		if(k>ZZ) break;
		Q.pop();
	}

	for (ll i = 1; i <= ZZ; i++) {
    //cout<<h[i][0]<<" "<<h[i][1]<<endl;
		//cout << max(h[i][0], h[i][1]) << endl;
		Nsum += max(h[i][0], h[i][1]);
	}


	cout << Nsum <<endl;




}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int ans =0;
	int n;
	cin>>n;
	while (n--)
	{
		int a,b;
		cin>>a>>b;
		ans+=1+b-a;
	}
	printf("%d\n",ans );

	return 0;
}

Measured memory_bytes: 256
/*
*/
#include<bits/stdc++.h>
using namespace std;
#define maxn 300010
#define ll long long
#define pii pair<ll,ll>
int a[maxn]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ;
int main()
{
	ios::sync_with_stdio(false);
	ll a,b,c;cin>>a>>b>>c;
	ll t=c-a-b;
	if(t<0)
	{
		cout<<"No"<<endl;return 0;
	}
	if(4*a*b<t*t) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
s = input()
if n % 2 == 1:
    print("No")
else:
    m = n // 2
    flag = False
    for i in range(m):
        if s[i] != s[i + m]:
            flag = True
            break
    if flag:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 2940
import sys
from io import StringIO
import unittest


def resolve():
    s = list(input())
    t = list(input())

    print(sum([1 for ss, tt in zip(s, t) if ss != tt]))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """cupofcoffee
cupofhottea"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """abcde
bcdea"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """apple
apple"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 103168
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////





int main() {

	ll N,T ;
	cin >> N >> T;

	ll ans = 2000;

	repn(i, N) {
		ll c, t;
		cin >> c >> t;
		if (t <= T) { ans = min(ans, c); }
	}

	if (ans == 2000) { cout << "TLE"; }
	else { cout << ans; }





	system("PAUSE");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,m,a[100];
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int sum=0;
    for(int i=0;i<n;i++)
        sum+=a[i];
    int cnt=0;
    for(int i=0;i<n;i++)
        if(a[i]>=sum/4./m)
            cnt++;
    cout<<(cnt>=m?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdio.h"


int main()
{
	int i, j, temp,sum,sei[100],num=0;
	scanf("%d",&sum);

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

	for (i = 0; i < sum; i++)
	{
		for (j = sum - 1; j > i; j--)
		{
			if (sei[j] < sei[j - 1])
			{
				temp = sei[j - 1];
				sei[j - 1] = sei[j];
				sei[j] = temp;
				num++;
			}
		}
	}

	for (i = 0;; i++)
	{
		printf("%d",sei[i]);
		if (i >= sum-1)break;
		printf(" ");
	}

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

Measured memory_bytes: 604
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
S = readline().decode().rstrip()

ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    idx = 0
    flag = True

    for s in num:
        acc = S[idx:].find(s)
        if acc == -1:
            flag = False
            break
        else:
            idx += acc + 1
    if flag:
        ans += 1

print(ans)


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

const int MAX_N = 3 * 1e5 + 3;

int is_prime[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i = 2; i < MAX_N; i++) {
        is_prime[i] = 1;
    }
    for (int i = 2; i < MAX_N; i++) {
        if (is_prime[i] == 0) continue;
        int now_num = i * 2;
        while (now_num < MAX_N) {
            is_prime[now_num] = 0;
            now_num += i;
        }
    }
    for (int i = 2; i < MAX_N - 1; i++) {
        is_prime[i + 1] += is_prime[i];
    }
    int N;
    while (true) {
        cin >> N;
        if (N == 0) break;
        cout << is_prime[2 * N] - is_prime[N] << endl;
    }
    return 0;
}


Measured memory_bytes: 4296
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iostream>
#include <deque>
#include <math.h>
#include <cstdio>
#include <functional>
#include <set>
#include <iomanip>
typedef  long long ll;
using namespace std;

int main(void) {
	ll n;
	cin >> n;
	vector<ll> a(3 * n);
	for (int i = 0; i < n * 3; i++) cin >> a[i];
	sort(a.begin(), a.end(), greater<ll>());
	ll ans =0;
	for (int i = 1; i < n * 2; i += 2)
	{
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
typedef unsigned long long ull;
int N, A[20], cnt;
int S[20]; // select?

ull gcd(ull x, ull y){
  ull r, t;
  if ( x < y ) { t = x; x = y; y = t; }
  while( y > 0 ){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}
ull lcm(ull x, ull y){
  return x/gcd(x, y)*y;
}

void rec(int p, ull LCM, int sum){
  int ok;
  if ( p == N ){
    ok = (sum > 0); // 一人以上いる
    for ( int i = 0; i < N; i++ ){
      if ( LCM >= A[i] && LCM % A[i] == 0 ){
        if ( S[i] == 0 ) ok = 0; //　選ばれていない人の周期
      }
    }
    if ( ok ) cnt++;
    return;
  }
  S[p] = 1;
  rec(p+1, lcm(LCM, A[p]), sum+1);
  S[p] = 0;
  rec(p+1, LCM, sum);
}
int main(){
  int i;
  scanf("%d", &N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);
  cnt = 0;
  rec(0, 1, 0);
  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 2088
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] x = new int[n], sortedX = new int[n];
			IntStream.range(0, n).forEach(i -> x[i] = sortedX[i] = scanner.nextInt());
			Arrays.sort(sortedX);
			IntStream.range(0, n).map(i -> {
				int index = Arrays.binarySearch(sortedX, x[i]);
				return (index <= (n - 1) / 2) ? sortedX[n / 2] : sortedX[(n - 1) / 2];
			}).forEach(System.out::println);
		}
	}
}


Measured memory_bytes: 95616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define sz(s) (ll)s.size()
#define print(d) cout << fixed << setprecision(15) << d
#define pii pair<ll,ll>
#define ppii pair<ll,pii>
#define ff first
#define ss second
const ll MOD = 1000000007;
const ll MAXN = 1e6 + 5;
const ll inf = 2e18;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
tree_order_statistics_node_update> ord_set;
#define debug(x) cerr << #x << " = " << x << endl


ll power(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 

ll sum(ll v)
{
   ll ans=v;
   ans*=(v+1ll);
   ans/=2;
   return ans;
} 


int main()
{
    fast
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ll n,k,s;
    cin >> n >> k >> s;
    if(s==(ll)1e9)
    {
        fr(i,0,k)
        {
            cout << s << " ";
        }
        fr(i,k,n)
        cout << 1 << " ";
    }
    else
    {
        fr(i,0,k)
        {
            cout << s << " ";
        }
        fr(i,k,n)
        cout << (ll)1e9 << " ";
    }
    return 0;

}










Measured memory_bytes: 1280
#include <iostream>
    #include <algorithm>
    #include <vector>
    #include <string>
    #include <memory.h>
    #include <queue>
    #include <cstdio>
    #include <cstdlib>
    #include <map>
    #include <cctype>
    #include <iomanip>
    #include <sstream>
    #include <set>
    #include <cctype>
    #include <fstream>
    #include <cmath>
    using namespace std;
     
    #define rep(i, n) for(int i = 0; i< n; i++)
    #define rep2(i, m, n) for(int i = m; i < n; i++)
    typedef long long ll;
    typedef pair<int, int> P;
    const int INF = 1000 * 1000 * 1000 + 7;
    const double EPS = 1e-10;
    const int SZ = 1000;
     
    int score[10][10];
    int ex[10];
    int id[10];
    int cnt[10];
    int used[SZ+10];
     
     
    int main(){
    int N;
    cin >> N;
    char c;
    rep(i, N)rep(j, N){
    cin >> c;
    if(c == 'o') score[i][j] = 3;
    if(c == 'x') score[i][j] = 0;
    if(c == '-') score[i][j] = 1;
    }
    rep(i, N){
    ex[i] = 0;
    id[i] = i + 1;
    rep(j, N) ex[i] += score[i][j];
    }
    rep(i, N)rep(j, N - 1){
    if(ex[j+1] > ex[j]){
    swap(ex[j+1], ex[j]);
    swap(id[j+1], id[j]);
    }
    }
    //if(ex[0] == 3 * (N - 1) + 1) sz = 1;
    used[0] = id[0];
    rep(i, SZ){
    printf("%d\n", used[rand()%(i+1)]); fflush(stdout);
    scanf("%d", &used[i+1]);
    }
    return 0;
    }

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

int main(){
  int N,X;
  cin >> N >> X;
  vt<int> x(N);
  rep(i,N) cin >> x[i];
  sort(x.begin(),x.end());
  int tmp1 = 1e9, tmp2 = 1e9;
  rep(i,N){
    tmp1 = min(tmp1,abs(x[i]-X));
    if(i > 0)
      tmp2 = min(tmp2,x[i]-x[i-1]);
  }

  bool f = false;
  int mini = min(tmp1,tmp2);
  for(mini; mini > 0; mini--){
    rep(j,N){
      int ab = abs(x[j]-X);
      if(ab%mini!=0)
        break;
      if(j == N-1)
        f = true;
    }
    if(f) break;
  }

  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 640
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!


const figureNames = ['A', 'B', 'C', 'D', 'E', 'F', 'G']

// 左上にブロックがあるとき、そのブロックから見た他のブロックの位置 ['右', '下']
const figureIndices = [
    [[1,0], [0, 1], [1, 1]],
    [[0, 1], [0, 2], [0, 3]],
    [[1, 0], [2, 0], [3, 0]],
    [[-1, 1], [0, 1], [-1, 2]],
    [[1, 0], [1, 1], [2, 1]],
    [[0, 1], [1, 1], [1, 2]],
    [[1,0], [-1, 1], [0, 1]]
]

function distinguishFigure(plane){

    const rows = plane.split('\n')
    
    for(let i = 0, l = rows.length; i < l; i++){
        
        for(let j = 0, m = rows[i].length; j < m; j++){
            
            // 図形の左上になるブロックを見つけた
            if(rows[i][j] === '1'){
                
              for(let k = 0, n = figureIndices.length; k < n; k++){
                   
                  let figureIndex = figureIndices[k]
                   
                  let isFound = true
                   
                  for(let index of figureIndex){
                       
                        let right = index[0]
                        let down = index[1]
                        
                        if(
                            !( (j + right) < m && (j + right) >= 0 && (i + down) < l ) || // 境界条件
                            rows[i+down][j+right] === '0'
                        ){
                            isFound = false
                            break
                        }
                        
                       
                  }
                   
                  if(isFound)
                        return figureNames[k]
                   
              }
                
            }
            
        }
        
    }

}

const fs = require('fs')
const length = fs.fstatSync(process.stdin.fd).size
const buffer = Buffer.alloc(length)
const bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0)
const input = buffer.toString('utf8', 0, bytesRead)

let result = ''

for(let plane of input.split('\n\n')){
    
    result += `${distinguishFigure(plane)}\n`

}

console.log(result.slice(0, -1))











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

using namespace std;

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

	int a, b, h;
	cin >> a >> b >> h;

	cout << ((a + b) * h) / 2;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n,m,c,tmp,cnt,i,j;
    tmp = 0, cnt = 0;
    scanf("%d%d%d",&n,&m,&c);
    int b[m];
    int a[n][m];

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

    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            scanf("%d",&a[i][j]);
            tmp += a[i][j] * b[j];
        }
        tmp += c;
        if(tmp > 0) cnt++;
        tmp = 0;
    }
    printf("%d\n",cnt);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	int N; cin >> N; 
	long long stop[100010] = {};
	long long str[100010] = {}; 
	long long bra[100010] = {}; 
	long long total = -1; // 枝分かれの総数 
	for(int i = 0; i <= N; i++){
		cin >> stop[i]; total += stop[i]; 
	}
	if(N == 0 && stop[0] == 1){
		cout << 1 << endl; return 0; 
	}else if(N == 0 || stop[0] > 0){
		cout << -1 << endl; return 0; 
	}
	if(total > 0){
		bra[0] = 1; total --; 
	}else{
		str[0] = 1; 
	}
	for(int i = 1; i <= N; i++){
		long long v = bra[i-1] * 2 + str[i-1]; 
		if(stop[i] > v){
			cout << -1 << endl; return 0; 
		}
		v -= stop[i]; 
		long long t = min(total, v); 
		bra[i] = t; 
		str[i] = v - t; total -= t; 
	}
	long long ans = 0; 
	for(int i = 0; i <= N; i++){
		ans += stop[i]; ans += bra[i]; ans += str[i]; 
	}
	//for(int i = 0; i <= N; i++) cout << stop[i] << " " << str[i] << " " << bra[i] << endl; 
	cout << ans << endl; 
}

Measured memory_bytes: 6008
import math
N, M = map(int, input().split())

if abs(N - M) > 1:
    print(0)
else:
    multi = 2 if N == M else 1
    # 犬と猿で独立に並べ方を数える。
    dog  = math.factorial(N)
    monkey = math.factorial(M)
    print(multi * dog * monkey % 1000000007)

Measured memory_bytes: 5316
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String A = "0" + sc.next();
		int ans = 0;
		for (int i = 1; i < A.length(); ++i) {
			String sum = A.substring(i);
			String sub = A.substring(0, i);
			if (sum.charAt(0) == '0' && sum.length() > 1) continue;
			int sumi = Integer.parseInt(sum);
			int subi = Integer.parseInt(sub);
			if ((sumi + subi) % 2 == 0 && sumi >= subi) ++ans;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 17328
#include <iostream>

using namespace std;

int a,b;

int main(){
    cin >> a >> b;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    if(b <= a){
        cout << 1 << endl;
        return 0;
    }
    int bb = a;
    int c = 1;
    while(true){
        bb += (a-1);
        c++;
        if(bb >= b){
            cout << c << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const string S = "ACL";
    int k; cin >> k;
    string ans = "";
    REP(i,k) ans += S;
    OUT(ans)

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;


int main(){
long N, M, tmp, Ptmp;
string Stmp;

cin >> N;
vector<pair<string, long>> v;
map<pair<string, long>, long> mp;
erep(i, N){
    cin >> Stmp >> Ptmp;
    v.push_back(make_pair(Stmp, -1*Ptmp));
    mp[pair<string, long>(Stmp, -1*Ptmp)] = i;
}
sort(all(v));
rep(i, N){
    long x = mp[pair<string, long>(v[i].first, v[i].second)];
    show(x);
}



// rep(i, v.size()){
//     cout << v[i].first << "," << v[i].second << endl;
// }


return 0;
}

Measured memory_bytes: 256
S=chomp(readline())
K=parse(Int,readline())
A=Int[1]
for i=2:length(S)
	if S[i-1]==S[i]
		A[end]+=1
	else
		push!(A,1)
	end
end
if length(A)==1
	println(div(A[1]*K,2))
else
	ans=div(A[1],2)+div(A[end],2)
	T=0
	for i=2:length(A)-1
		T+=div(A[i],2)
	end
	ans+=T*K
	if S[1]==S[end]
		ans+=(K-1)*div(A[1]+A[end],2)
	else
		ans+=(K-1)*(div(A[1],2)+div(A[end],2))
	end
	println(ans)
end


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

using namespace std;

void solve(void)
{
	int n;
	cin >> n;
	vector<int> as(n);
	set<int> s;
	for (int i = 0; i < n; i++)
	{
		cin >> as[i];
		s.insert(as[i]);
	}
	map<int, int> mp;
	int cnt = 0;
	for (int v : s)
	{
		mp[v] = cnt++;
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if ((mp[as[i]] ^ i) & 1) ans++;
	}
	cout << ans/2 << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define mk make_pair
#define f first
#define s second
typedef pair<int,int> P;
int a[51][51],ax,bx,ay,by;
int dx1[]={1,0,-1,0};
int dy1[]={0,1,0,-1};
int dx2[]={-1,0,1,0};
int dy2[]={0,-1,0,1};
bool used[10000000];
int gethash(P q,P w){
  return q.f+q.s*52+w.f*52*52+w.s*52*52*52;
}
int main(){
  int w,h;
  while(cin>>w>>h,w){
    memset(used,0,sizeof(used));
    cin>>ax>>ay>>bx>>by;ax--,ay--,bx--,by--;
    r(i,h)r(j,w)cin>>a[i][j];
    used[gethash(P(ay,ax),P(by,bx))]=1;
    queue<pair<int,pair<pair<int,int>,pair<int,int> > > >q;
    q.push(mk(0,mk(mk(ay,ax),mk(by,bx))));
    while(!q.empty()){
      pair<int,pair<pair<int,int>,pair<int,int> > >p=q.front();q.pop();
      P p1=p.s.f,p2=p.s.s;
      if(p1==p2){
	cout<<p.f<<endl;
	goto L;
      }
      r(i,4){
	int x1=p1.s+dx1[i],x2=p2.s+dx2[i],y1=p1.f+dy1[i],y2=p2.f+dy2[i];
	if(x1<0||x1>=w)x1=p1.s;
	if(x2<0||x2>=w)x2=p2.s;
	if(y1<0||y1>=h)y1=p1.f;
	if(y2<0||y2>=h)y2=p2.f;
	if(a[y1][x1])x1=p1.s,y1=p1.f;
	if(a[y2][x2])x2=p2.s,y2=p2.f;
	if(!used[gethash(P(y1,x1),P(y2,x2))]){
	  used[gethash(P(y1,x1),P(y2,x2))]=1;
	  q.push(mk(p.f+1,mk(mk(y1,x1),mk(y2,x2))));
	}
      }
    }
    cout<<"NA"<<endl;L:;
  }
}

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

int main()
{   char s[100001];
    scanf("%s",s);
    if(strlen(s)==1){
        printf("0");
        return 0;
    }
    int l=0,r=0;
    for(int i=1;i<strlen(s);i++){
        if(s[i]!=s[i-1]){
            l++;
        }
    }
    for(int i=strlen(s)-2;i>=0;i--){
        if(s[i]!=s[i-1]){
            r++;
        }
    }
    if(r<l){
        printf("%d",r);
    }else{
        printf("%d",l);
    }
    return 0;
}


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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> field(h);
    rep(i,h) cin >> field[i];

    queue<int> queh;
    queue<int> quew;
    vvi dist(h, vi(w, -1));
    vvi res(h, vi(w, -1));
    vi dh = {0, -1, 0, 1};
    vi dw = {1, 0, -1, 0};

    rep(i,h)rep(j,w){
        if (field[i][j] == '#'){
            queh.push(i); quew.push(j);
            dist[i][j] = 0;
        }
    }
     while (!queh.empty() && !quew.empty()){
        int i = queh.front(); queh.pop();
        int j = quew.front(); quew.pop();
        rep(k,4){
            int ni = i + dh[k];
            int nj = j + dw[k];
            if (ni < 0 || ni >= h || nj < 0 || nj >=w) continue;
            if (dist[ni][nj] != -1) continue;
            if (field[ni][nj] == '#') continue;
            queh.push(ni);
            quew.push(nj);
            dist[ni][nj] = dist[i][j] + 1;
        }
    }

    int ans = 0;
    rep(i,h)rep(j,w){
        ans = max(ans, dist[i][j]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 21108
#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <utility>
#include <functional>
using namespace std;

using ll = long long int;
using P = pair<int, int>;
string word[100];
int score[100];
string line[4];
set<string> words;
map<string, int> cnt;
bool vis[4][4];
vector<P> v[10];
ll sum[10];
ll sum_v[10][10001];
ll dp[10][10001];
int N, T;
void dfs(int x, int y, int d, string &s) {
	if (words.count(s) > 0) {
		cnt[s]++;
	}
	if (d > 8) return;
	for (int dx = -1; dx <= 1; dx++) {
		for (int dy = -1; dy <= 1; dy++) {
			if(dx==0 && dy==0) continue;
			int nx = x + dx;
			int ny = y + dy;
			if (0 > nx || nx >= 4 || 0 > ny || ny >= 4 || vis[ny][nx]) continue;
			vis[ny][nx] = 1;
			s.push_back(line[ny][nx]);
			dfs(nx, ny, d + 1, s);
			vis[ny][nx] = 0;
			s.pop_back();
		}
	}
}
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> word[i] >> score[i];
		words.insert(word[i]);
	}
	for (int i = 0; i < 4; i++) cin >> line[i];
	cin >> T;
	string s = "";
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			s.push_back(line[i][j]);
			vis[i][j] = 1;
			dfs(j, i, 1, s);
			vis[i][j] = 0;
			s.pop_back();
		}
	}
	for (int i = 0; i < N; i++) {
		if (cnt.count(word[i])>0) {
			v[word[i].size()].emplace_back(score[i], cnt[word[i]]);
			sum[word[i].size()] += cnt[word[i]];
		}
	}
	for (int i = 1; i <= 8; i++) {
		sort(v[i].begin(), v[i].end(), greater<P>());
	}
	for (int i = 1; i <= 8; i++) {
		int idx = 0, k = 0;
		for (int j = 1; j <= min(sum[i], 10000LL); j++) {
			sum_v[i][j] = sum_v[i][j - 1] + v[i][idx].first;
			k++;
			if (v[i][idx].second <= k) {
				idx++;
				k = 0;
			}
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i <= 8; i++) {
		for (int j = 0; j <= T; j++) {
			for (int k = 0; k <= min((ll)(j / i), min(sum[i], 10000LL)); k++) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - i*k] + sum_v[i][k]);
			}
		}
	}
	ll ans = 0;
	for (int i = 1; i <= T; i++) {
		ans = max(ans, dp[8][i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 4132
#include <stdio.h>

#define N 3

void bubble_sort(int array[]);
void selection_sort(int array[]);
void insertion_sort(int array[]);

int main(void)
{
	int i, numbers[N];

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

	//bubble_sort(numbers);
	//selection_sort(numbers);
	insertion_sort(numbers);

	printf("%d %d %d\n",numbers[0], numbers[1], numbers[2]);
	
	return 0;
}

void bubble_sort(int array[])
{
	int i, j, temp;

	for(i = 0; i < (N - 1); i++){
		for(j = 0; j < (N - 1 - i); j++){
			if(array[j + 1] < array[j]){
				temp = array[j + 1];
				array[j + 1] = array[j];
				array[j] = temp;
			}
		}
	}
}

void selection_sort(int array[])
{
	int i, j, temp;

	for(i = 0; i < (N - 1); i++){
		for(j = (i + 1); j < N; j++){
			if(array[j] < array[i]){
				temp = array[j];
				array[j] = array[i];
				array[i] = temp;
			}
		}
	}
}

void insertion_sort(int array[])
{
	int i, j, temp;

	for(i = 1; i < N; i++){
		temp = array[i];
		for(j = i; (j > 0) && (temp < array[j - 1]); j--){
			array[j] = array[j - 1];
		}
		array[j] = temp;
	}
}


Measured memory_bytes: 1968
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a*n, b) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(name, start, stop) for (auto(name) = (start); (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

int main(void) {
    ll x;
    cin >> x;
    ll cnt500 = x / 500;
    ll cnt5 = (x % 500) / 5;
    ll delight = cnt500 * 1000 + cnt5 * 5;
    cout << delight << endl;
    return 0;
}


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

#define  BeatMeScanf  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  tc(x)        int x; cin >> x; while(x--)
#define  ll           long long
#define  vi           vector<int>
#define  pii          pair<int,int>
#define  mii          map<int,int>
#define  inf          1<<28
#define  mem(x,y)     memset(x, y, sizeof(x))
#define  ps(x,y)      fixed<<setprecision(y)<<x
#define  show(val)    cout<< #val << " -> " << val << endl
#define  Case         cout<< "Case "<< ++cs << ": "
#define  all(v)       (v).begin(), (v).end()
#define  rall(v)      (v).rbegin(), (v).rend()
#define  MOD          1000000007
#define  MAX          100005

int main()
{
    BeatMeScanf;
    ll n;
    cin >> n;

    ll prod = 1, zero = 0, flag = 0;
    for (ll i = 0; i < n; ++i)
    {
        ll x;
        cin >> x;
        if(x == 0)
        {
           cout << 0 << '\n';
           return 0;
        }
        if(x <= 1000000000000000000 / prod)
            prod *= x;
        else
            flag++;
    }

    if(flag > 0) cout << -1 << '\n';
    else cout << prod << '\n';
   
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,n) for(i=0;i<n;i++)in(v[i]);
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define cf(n) printf("%I64d\n",n)
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
typedef long long int ll;
int main()
{
    int n,x=0,a;
    in(n);
    ll ans=0;
    int m=INT_MAX;
    while(n--)
    {
        in(a);
        ans+=abs(a);
        m=min(m,abs(a));
        if(a<0)
            x++;
    }
    if(x&1)
        ans-=(2*m);
    cout << ans << endl;
}


Measured memory_bytes: 256
<?php
$r = []; $first = 0; $second = 0;
fscanf(STDIN, "%d", $n);
for ($i=0; $i < $n; $i++) {
    fscanf(STDIN, "%d", $a);
    if ($first < $a) {
        $second = $first;
        $first = $a;
    } elseif ($second < $a) {
        $second = $a;
    }
    $r[] = $a;
}
for ($i=0; $i < $n; $i++) {
    echo ($r[$i] === $first ? $second : $first)."\n";
}
?>

Measured memory_bytes: 14196
W = input().lower()
count = 0
line = []
while True:
    tmp_line = input()
    if tmp_line == "END_OF_TEXT":
        break
    line += tmp_line.lower().split()    
    
for word in line:
    if word == W:
        count += 1
    else:
        pass    
print(count)


Measured memory_bytes: 5560
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define FILL(x, val)            memset(x, val, sizeof(x))
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (int)1000000007
#define INF                     (int)0x3f3f3f3f

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

typedef long long i64; 
typedef vector< int > vi;
typedef vector< i64 > vi64;
typedef pair< int, int > pi;
typedef vector< pair< int, int > > vpi;
string s;
vi64 sol;
i64 ans = 0;

void solve(int pos, string curr) {
	if (pos == (int) s.size()) {
		int si = curr.size();
		//trace(curr);
		forn(i, si) {
			i64 temp = 0;
			while (i < si && curr[i] != '+') temp = temp * 10 + (curr[i++] - '0');
			ans += temp;
		}
		return;
	}
	if (!pos) {
		curr += string(1, s[pos]);
		solve(pos + 1, curr);
	}
	else {
		solve(pos+1, curr + string(1, s[pos]));
		solve(pos+1, curr + "+" + string(1, s[pos]));
	}
}

void crypt() {
	cin >> s;
	solve(0, "");
	cout << ans << "\n";
}

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	cout << fixed;
	int t = 1; 
//	cin >> t;
	while (t--) crypt();
	return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>

using namespace std;

int main()
{
    priority_queue<int> qu;
    int n;
    for( int i = 0; i < 10; i++){
        cin >> n;
        qu.push(n);
    }

    for( int i =0; i < 3; i++){
        cout << qu.top()<< endl;
        qu.pop();
    }

    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1e9+7
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;


int main() {
    string s;
    cin>>s;
    rep(i,0,s.length()-1){
        if(s[i]=='S'&&s[i+1]=='T'){
            s.erase(s.begin()+i);
            s.erase(s.begin()+i);
            i-=2;   
        }
    }
    cout<<s.length()<<endl;
    
    
    return 0;
}


Measured memory_bytes: 640
(defparameter *hash-memo* (make-hash-table :test #'equal))

(defmacro dp (&body func)
  `(let* ((f (quote func))
          (num (gethash f *hash-memo*)))
     (if num
       num
       (setf (gethash f *hash-memo*) ,func))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))


(let ((line (loop repeat 3 collect (read))))
  (princ (if (= 2 (length (remove-duplicates line))) "Yes" "No")))


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

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();

      int[] d = new int[n];
      for(int i=0,p=0; i<n; i++) {
        if(line.charAt(i) == 'E')
          d[i] = ++p;
        else
          d[i] = p;
      }

      int maxE = d[n-1];
      int ans = maxE - d[0];
      for(int i=1; i<n; i++) {
        ans = Math.min(ans, i-d[i-1] + maxE-d[i]);
      }

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 28756
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange

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

    ll ans = (ll)powl(10, n);
    ll ten = 1, eight = 1, nine = 1;

    for (ll i = 0; i < n; i++)
    {
        ten *= 10;
        ten %= MOD;
        nine *= 9;
        nine %= MOD;
        eight *= 8;
        eight %= MOD;
    }

    ans = ten;
    ans = (ans - nine) % MOD;
    ans = (ans - nine) % MOD;
    ans = (ans + eight) % MOD;

    if(ans < 0)
        ans += MOD;

    cout << ans << endl;
}


Measured memory_bytes: 3632
import java.io.InputStream;
import java.util.Scanner;

/**
 * Created on 2017/10/29.
 */
public class Main {
    public static void main(String args[]){
        int ans = 1;

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        for (int i = 0; i < N; i++) {
            if(ans*2 < ans+K) {
                ans = ans * 2;
            }else{
                ans = ans + K;
            }
        }
    System.out.println(ans);

    }

}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while (a > 0 || c > 0){
        c -= b;
        if (c <= 0){
            break;
        }
        a -= d;
        if (a <= 0){
            break;
        }
    }

    cout << (a <= 0 ? "No" : "Yes") << endl;
}


Measured memory_bytes: 3592
x=gets.chomp.to_i
rx = x**(1/2.0)
i = x
while true do
    flag = true
    2.upto(rx) do |j|
        if i % j == 0
            flag = false
            break
        end
    end
    if flag
        puts i
        exit
    end
    i+=1
end

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main() {
  int n; cin >> n;
  vector<int> as(n, 0), bs(n, 0), cs(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> as[i]; cin >> bs[i]; cin >> cs[i];
  }
  
  vector< vector<int> > dp(n, vector<int>(3, 0));
  dp[0][0] = as[0]; dp[0][1] = bs[0]; dp[0][2] = cs[0];
  for (int i = 1; i < n; i++) {
    dp[i][0] = max(dp[i - 1][1] + as[i], dp[i - 1][2] + as[i]);
    dp[i][1] = max(dp[i - 1][2] + bs[i], dp[i - 1][0] + bs[i]);
    dp[i][2] = max(dp[i - 1][0] + cs[i], dp[i - 1][1] + cs[i]);
  }
  cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}

Measured memory_bytes: 9852
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cctype>
#include<cstring>
#define maxn 2007
#define SDOI2020 RP++ 
using namespace std;
int a,b,c,n; 
inline int read()
{
	int x=0;
	int flag=0;
	char ch;
	ch=getchar();
	while(!isdigit(ch)) 
	{
		if(ch=='-') flag=1;
	ch=getchar();	
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+ch-48;
		ch=getchar();
		}
		if(flag==1) x=-x;	
		return x;
}


int main()
{
	n = read();
	a = read();
	if(n >= 10)
	{
		printf("%d\n",a);
	} 
	else
	{
		printf("%d\n",a + (100 * (10 - n)));
	}
	return 0;
} 

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;

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

    int m = 0;
    vector<int> b(n);
    for(int i = n - 1; i >= 0; i--){
        int tmp = 0;
        for(int j = i; j < n; j += (i + 1)){
            if(b[j] == 1) tmp++;
        }
        if(tmp % 2 == 0 && a[i] == 1){
            b[i] = 1;
            m++;
        } else if(tmp % 2 == 1 && a[i] == 0){
            b[i] = 1;
            m++;
        }
    }

    cout << m << endl;
    for(int i = 0; i < n; i++){
        if(b[i] == 1){
            cout << i + 1 << endl;
        }
    }
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int i,n,x[101],y[101];
double M=0,U=0,T=0,MAX=0;
scanf("%d",&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++){
M+=fabs(x[i]-y[i]);
U+= fabs(x[i]-y[i])*fabs(x[i]-y[i]);
T+= fabs(x[i]-y[i])*fabs(x[i]-y[i])*fabs(x[i]-y[i]);
if(MAX<fabs(x[i]-y[i])) MAX=fabs(x[i]-y[i]);
}
printf("%lf\n",M);
printf("%lf\n",sqrt(U));
printf("%lf\n",pow(T,1.0/3.0));
printf("%lf\n",MAX);
}



Measured memory_bytes: 2132
x,k,d=list(map(int,input().split()))
if k>=abs(x)//d:
    y=abs(x)//d
    ans=abs(abs(x)-y*d)
    ans=abs(ans-((k-y)%2)*d)
else:
    ans=abs(abs(x)-k*d)
print(ans)

Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <regex>
#include <utility> // pair
#include <algorithm> // swap
#include <numeric> // accumulate
#include <cmath> // pow
#include <iomanip> // setprecision
using namespace std;

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()

signed main() {
  int n, y;
  cin >> n >> y;
  rep(ichiman, n+1) {
    rep(gosen, n-ichiman+1) {
      int sen = n - ichiman - gosen;
      if (ichiman*10000 + gosen*5000 + sen*1000 == y) {
        cout << ichiman << " " << gosen << " " << sen << endl;
        exit(0);
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;

int main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	rep(i, N) cin >> vec.at(i);

	string ans = "APPROVED";
	for(int num : vec) {
		if(num % 2 == 0) {
			if(!(num % 3 == 0 || num % 5 == 0)) ans = "DENIED";
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<climits>
#include<cmath>
#include<stdio.h>

using namespace std;



int main(){
    long long a,b;
    cin>>a>>b;
    if(a*b<=0){
        cout<<"Zero"<<endl;
    }else if(a<0&&(min(0ll,b)-a)%2==0){
        cout<<"Negative"<<endl;
    } else {
        cout<<"Positive"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int zh(string x){
	int s=0;
	for(int i=0;i<x.size();i++)
	{
		s=s*10+(x[i]-'0');
	}
	return s;
}
int main()
{
	int a;
	string x,y;
	cin>>x>>y;
	x=x+y;
	a=zh(x);
	if(sqrt(a)==int(sqrt(a))) cout<<"Yes";
	else cout<<"No"<<endl;
	return 0;
	
} 

Measured memory_bytes: 256
h,w = map(int,input().split())
row = [False] * h
col = [False] * w
a = []
for i in range(h):
    a.append(input())

for i in range(h):
    for x in range(w):
        if a[i][x] == '#':
            row[i] = True
            col[x] = True
for i in range(h):
    if row[i]:
        for x in range(w):
            if col[x]:
                print(a[i][x],end='')
        print()


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string S;
    cin >> S;
    if(S == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    return 0;
}


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

int main(){
	string t;
	cin >> t;
	rep(i,t.size()){
		if(t[i] == '?'){
			t[i] = 'D';
		}
	}
	cout << t << endl;
    return 0;
}



Measured memory_bytes: 3716
#include <iostream>
#include <string>
using namespace std;
int n, k, ans = 0, roop, save3[10], roop2, card[10], res, save2;
bool save[100000000];
void solve(){
    roop--;
    for (int i = 0; i<n; i++){
        if(save3[i]==1) continue;
            if (roop == 0){
                save2 = res;
                if(card[i]/10>=1){
                    res = res*100;
                }
                else{
                    res = res*10;
                }
                res += card[i];
                if (save[res] == 0){
                    ans++;
                    save[res]=1;
                }
                res = save2;
            }
            else{
                if(card[i]/10>=1){
                    res = res*100;
                }
                else{
                    res = res*10;
                }
                res += card[i];
                save3[i]=1;
                solve();
                save3[i]=0;
                roop++;
                res -= card[i];
                if(card[i]/10>=1){
                    res = res/100;
                }
                else{
                    res = res/10;
                }
        }
    }
}
int main() {
    while (true){
        cin >> n >> k;
        roop2 = 0;
        if (n == 0 && k == 0){
            return 0;
        }
        for (int i = 0; i < n; i++){
            cin >> card[i];
        }
        for (int i = 0; i < n; i++){
            roop = k - 1;
            res = card[i];
            save3[i] = 1;
            solve();
            save3[i]=0;
        }
        cout << ans << endl;
        ans=0;
        for (int i = 0; i < 10000000; i++){
            save[i] = 0;
        }
    }
}

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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

ll lcm(ll a,ll b){
    ll g=GCD(a,b);
    return a/g*b;
}

int main(){
    int N;
    cin>>N;
    ll ANS=1;
    rep(i,N){
        ll T;
        cin>>T;
        ANS=lcm(ANS,T);
    }
    cout<<ANS<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

long long pow_mod(long long x, long long n, long long mod_num) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) { res = (res * x) % mod_num; }
        x = (x * x) % mod_num;
        n = (n >> 1);
    }
    return res;
}

class Combi_Num {
    public:
    long long mod_num;
    std::vector<long long> factorial, factorial_inv, inv;
    Combi_Num() {}
    Combi_Num(const int n, const long long mod_num_in) {
        mod_num = mod_num_in;
        factorial.resize(n+1, 0);
        factorial_inv.resize(n+1, 0);
        inv.resize(n+1, 0);
        factorial[0] = 1;
        factorial_inv[0] = 1;
        inv[0] = 1;
        for (int i = 1; i <= n; i++) {
            factorial[i] = (factorial[i-1] * i) % mod_num;
            inv[i] = pow_mod(i, mod_num - 2, mod_num);
            factorial_inv[i] = (factorial_inv[i-1] * inv[i]) % mod_num;
        }
    }

    long long combi(const int n, const int r) {
        return (factorial[n] * ((factorial_inv[r] * factorial_inv[n-r]) % mod_num)) % mod_num;
    }

    long long perm(const int n, const int r) {
        return (factorial[n] * factorial_inv[n-r]) % mod_num;
    }
};

const long long MOD = 1000000007;
const int MAX_NM = 200050;
int N, M, K;

Combi_Num combi_num = Combi_Num(MAX_NM, MOD);

int main(int argc, char **argv) {
    std::cin >> N >> M >> K;

    long long ret = 0;

    for (int d = 1; d <= N - 1; d++) {
        long long pat = (N - d) * M * M;
        pat = pat % MOD;
        pat = (pat * combi_num.combi(N*M - 2, K - 2)) % MOD;
        ret = ret + (d * pat) % MOD;
        ret = ret % MOD;
    }

    for (int d = 1; d <= M - 1; d++) {
        long long pat = (M - d) * N * N;
        pat = pat % MOD;
        pat = (pat * combi_num.combi(N*M - 2, K - 2)) % MOD;
        ret = ret + (d * pat) % MOD;
        ret = ret % MOD;
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 4992