akhauriyash/Code-Regression huggingface dataset:
/******************************************************************************

                         بسم الله الرحمن الرحيم
                     Author: Mst: Mhamuda Khatun
                               RUCSE27

*******************************************************************************/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define MAX 1000000000000
#define N 305

int main()
{
    fastio;
    ll n,m,p,i,sum=0;
    cin>>n>>m;

    for(i=0;i<m;i++)
    {
        cin>>p;
        sum+=p;
    }

    cout<<((n-sum)<0?-1:(n-sum));
    cout<<"\n";
    return 0;   //:D
}




Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main()
{
char c;
cin >> c;
if (c == 'a')
cout << "vowel" << endl;
if(c == 'i')
cout << "vowel" << endl;
if(c == 'u')
cout << "vowel" << endl;
if(c == 'e')
cout << "vowel" << endl;
if(c == 'o')
cout << "vowel" << endl;
if (!(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'))
cout << "consonant" << endl;
return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
	public static void Main()
	{
		Console.ReadLine();
		Program.InsercionSort(Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse) );
	}
	
	public static void InsercionSort(int[] A)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( A, x=>x.ToString() ) ) );
		
		for(int i = 1; i<A.Length; i++) {
			int v = A[i];
			
			if(A[i-1] > v) {
				int j = i;
				for(; j > 0 && A[j - 1] > v; j--) {
					A[j] = A[j-1];
				}
				A[j] = v;
			}
			Console.WriteLine(string.Join(" ", Array.ConvertAll( A, x=>x.ToString() ) ) );
		}
	}
}

Measured memory_bytes: 9308
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]

class BIT():
    # 作りたい要素数nで初期化, 1-index
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n+1)

    #bit_indexにxをO(log(n))で加算する
    def add(self,i,x):
        #if(i<=0 or i>n):return iに0以下の数字は代入しない
        while i <= self.n:
            self.bit[i] += x
            i += (i & -i)
    #bit_1 + bit_2 + …  + bit_n をO(log(n))で求める
    def sum(self,i):
        s = 0
        #iに0以下の数字は代入しない。
        while i > 0:
            s+=self.bit[i]
            i -= (i & -i)
        return s
    
    def rangesum(self,i,k):
        return self.sum(k) - self.sum(i)
    #a_1 + a_2 + … + a_i >= x となるような最小のiを求める(a_k >= 0)
    #xが0以下の場合は該当するものなし→0を返す
    def lower_bound(self,x):
        if x <= 0:
            return 0
        else:
            i = 0
            r = 1
            #最大としてありうる区間の長さを取得する
            #n以下の最小の二乗のべき(BITで管理する数列の区間で最大のもの)を求める
            while(r<self.n):
                r=r<<1
            len = r
            while len > 0:
                if(i+len<self.n and self.bit[i+len]<x):
                    x-=self.bit[i+len]
                    i+=len
                len = len >> 1
            return i+1

def main():
    N, Q = MI()
    X, Y = BIT(N), BIT(N)
    xmin = N-2
    ymin = N-2
    X.add(1, N-2)
    X.add(N-1, -(N-2))
    Y.add(1, N-2)
    Y.add(N-1, -(N-2))

    res = (N-2)**2
    for i in range(Q):
        a, b = MI()
        if a == 1:
            x = X.sum(b-1)
            if ymin > b-2:
                temp = Y.sum(1)
                Y.add(1, b-2-temp)
                Y.add(xmin+1, -(b-2-temp))
                ymin = b-2
            res -= x
        else:
            y = Y.sum(b-1)
            if xmin > b-2:
                temp = X.sum(1)
                X.add(1, b-2-temp)
                X.add(ymin+1, -(b-2-temp))
                xmin = b-2
            res -= y
            
    print(res)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 12576
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

int main(){
	fastio;
	ll n;
	cin>>n;
	vll v(n);
	ll ax = 0;
	for(ll i=0; i<n; i++){
		cin>>v[i];
		ax^=v[i];
	}
	LG(ax)
	for(ll i=0; i<n; i++){
		cout<<(ax^v[i])<<" ";
	}

}

Measured memory_bytes: 4764
while True:
    H,W = map(int,input().split())
    if 3 <= H and W <= 300:
        print(W * ('#') +'\n' + (H - 2) * (('#' + (('.') * (W - 2)) + '#') + '\n') + W * ('#'))
    if H == W == 0:
        break
    print()

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

int main(void){
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(u==s){
        cout << a-1 <<" "<< b << endl;
    }
    else if (u==t){
        cout << a <<" "<<b-1 << endl;
    }
}

Measured memory_bytes: 3544
import math
N, K = map(int, input().split())
p = [0] * N
for i in range(N):
    n = i + 1
    x = 1 / N
    while n < K:
        x *= 0.5
        n *= 2
    p[i] = x
ans = math.fsum(p)
print(ans)

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

int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  string ans="";
  string S="";
  for(int i=0;i<ty-sy;i++){
    S+='U';
  }
  for(int i=0;i<tx-sx;i++){
    S+='R';
  }
  ans+=S;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='R'){
      ans+='L';
    }else if(S.at(i)=='U'){
      ans+='D';
    }
  }
  S="L";
  for(int i=0;i<ty-sy+1;i++){
    S+='U';
  }
  for(int i=0;i<tx-sx+1;i++){
    S+='R';
  }
  S+='D';
  ans+=S;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='R'){
      ans+='L';
    }else if(S.at(i)=='U'){
      ans+='D';
    }else if(S.at(i)=='D'){
      ans+='U';
    }else if(S.at(i)=='L'){
      ans+='R';
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]

Point_0 = [K-Q for _ in range(N)]
#(Point_0)
Point_Q = [0 for _ in range(N)]
for a in A:
    Point_Q[a-1] += 1
Point = [i+j for i,j in zip(Point_0,Point_Q)]
hantei = [print("Yes") if p>0 else print("No") for p in Point]

Measured memory_bytes: 17408
#include <iostream>
#include <queue>
#include <string>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mp make_pair
typedef pair<int, int> P;

vector<vector<int>> dist = {{1,0}, {-1,0}, {0,1}, {0,-1}};

int main(){
    int h,w;cin >> h >> w;
    vector<string> da(h);
    rip(i,h,0) cin >> da[i];
    vector<vector<int>> li(h,vector<int>(w,-1));
    queue<pair<P, int>> q;
    q.push(mp(mp(0,0),1));
    while(!q.empty()){
        auto now = q.front();
        q.pop();
        int x = now.first.first,y = now.first.second;
        if(li[x][y] > 0 || da[x][y] == '#') continue;
        li[x][y] = now.second;
        rip(i,4,0){
            if(0 <= x + dist[i][0] && x + dist[i][0] < h && 0 <= y + dist[i][1] && y + dist[i][1] < w) q.push(mp(mp(x + dist[i][0], y + dist[i][1]),now.second + 1));
        }
    }
    int ans = h * w;
    rip(i, h, 0){
        rip(j, w, 0){
            if(da[i][j] == '#') ans--;
        }
    }
    ans -= li[h-1][w-1];
    if(li[h-1][w-1]==-1) ans = -1;
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int no_of_input,m;
  int input;
  vector<int> vect1;
  int sum = 0;
  cin >> no_of_input >> m;
  for(int i=0;i<no_of_input;i++){
    cin >> input;
    sum += input;
    vect1.push_back(input);
  }
  int mini;
  if(sum%(4*m)==0){
    mini = sum/(4*m)-1;
  }
  else{
    mini = sum/(4*m);
  }
  int k = 0;
  for(int i=0;i<no_of_input;i++){
    if(vect1[i]<=mini){
      k++;
    }
  }
  if(no_of_input-k>=m){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'


long long int entrada,resultado;
int main()
{
	cin>>entrada;
	if(entrada%2==0){
		resultado = entrada;
	}
	else{
		resultado = entrada*2;
	}
	cout<<resultado<<'\n';
	return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

// Rabin-Karp string search algorithm
class RollingHash{
    private:
      using ULL = unsigned long long;
      int n;
      const ULL mod = 1ULL << 63;
      const ULL base = 1000000007ULL;
      vector<ULL> hash, power;
    public:
      RollingHash(string s){
          n = s.size();
          hash.assign(n+1, 0ULL);
          power.assign(n+1, 0ULL);
          power[0] = 1ULL; 
          for(int i = 0; i < n; i++){
              power[i+1] = power[i] * base % mod;
              hash[i+1] = (s[i] + hash[i] * base) % mod;
          }
      }
      ULL GetHash(int l, int r){
          return ((hash[r] - hash[l] * power[r-l]) % mod + mod) % mod;
      }
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<string> s(n);
    REP(i, n) cin >> s[i];

    vector<string> h(n, ""), w = s;
    REP(j, n){
        REP(i, n){
            h[j] = h[j] + s[i][j];
        }
    }
    REP(i, n){
        h[i] = h[i] + h[i] + h[i];
        w[i] = w[i] + w[i] + w[i];
    }

    vector<vector<bool>> check(n, vector<bool>(n, true));
    vector<RollingHash> hhash, whash;

    REP(i, n){
        hhash.pb(RollingHash(h[i]));
        whash.pb(RollingHash(w[i]));
    }

    REP(i, n){
        REP(j, n){
            REP(k, n-1){
                int sz = n - k;
                check[(i+n-k)%n][(j+n-k)%n] = check[(i+n-k)%n][(j+n-k)%n] 
                    && hhash[j].GetHash(i+1, i+1+sz) == whash[i].GetHash(j+1, j+1+sz);
                //cout << i << " " << j << " " << hhash[j].GetHash(i+1, i+1+sz) << " " << whash[i].GetHash(j+1, j+1+sz) << endl;
                //cout << (i+n-k)%n << " " << (j+n-k)%n << " " << hh[j][(i+1)%n][sz] << " " << ww[i][(j+1)%n][sz] << endl;
                //cout << (i+n-k)%n << " " << (j+n-k)%n << " " << h[j].substr(i+1, sz) << " " << w[i].substr(j+1, sz) << endl;
                //cout << "h: " << j << " " << i+1 << " w: " << i << " " << j+1 << endl;
            }
        }
    }
    int ans = 0;
    REP(i, n) REP(j, n){
        //cout << i << " " << j << " " << (check[i][j] ? 1 : 0) << endl;
        ans += check[i][j] ? 1 : 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9728
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    double p[3][2],m[2][2],a[2],inv[2][2],o[2],det;
    for(int i=0; i<3; i++) for(int j=0; j<2; j++) cin >>p[i][j];
    for(int i=1; i<3; i++) for(int j=0; j<2; j++) p[i][j]-=p[0][j];
    for(int i=0; i<2; i++) for(int j=0; j<2; j++) m[i][j] = 2*p[i+1][j];
    for(int i=0; i<2; i++) a[i] = p[i+1][0]*p[i+1][0]+p[i+1][1]*p[i+1][1];
    det = m[0][0]*m[1][1]-m[0][1]*m[1][0];
    inv[0][0] = m[1][1]/det;
    inv[0][1] = -m[0][1]/det;
    inv[1][0] = -m[1][0]/det;
    inv[1][1] = m[0][0]/det;
    for(int i=0; i<2; i++) o[i] = inv[i][0]*a[0]+inv[i][1]*a[1];
    printf("%.3lf %.3lf %.3lf\n",o[0]+p[0][0],o[1]+p[0][1],sqrt(o[0]*o[0]+o[1]*o[1]));
  }
  return 0;
}

Measured memory_bytes: 1244
Q = int(input())
queries = [tuple(map(int, input().split())) for _ in range(Q)]
primes = [2]
MAX = 10**5
p_list = [0] * (MAX+1)
cnt = 0
for i in range(3, MAX+1):
  is_prime = True
  likely = False
  for prime in primes:
    if i%prime == 0:
      is_prime = False
      break
    if (i+1)//2 == prime:
      likely = True
      break
    elif (i+1)//2 < prime:
      break
    else:
      continue
  if is_prime:
    primes.append(i)
    if likely:
      cnt += 1
  p_list[i] = cnt

for l, r in queries:
  if p_list[l] > p_list[l-1]:
    print(p_list[r]-p_list[l]+1)
  else:
    print(p_list[r]-p_list[l])

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

using namespace std;
using ll=long long;

void solve() {
    int n; ll m;
    cin >> n >> m;
    vector<ll> a(n);
    ll lcm = 1;
    for (auto& x: a) {
        cin >> x;
        ll g = __gcd(lcm, x);
        lcm = lcm * x / g;
        if (lcm > 2*m) {
            cout << 0; return;
        }
    }
    ll z = lcm/2;
    // ck
    for (ll x: a) {
        if (z%x != x/2) {
            cout << 0; return;
        }
    }
    ll res = m/lcm + (m%lcm >= z);
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

double rad(double ang){
	return ang / 180 * M_PI;
}

int main()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;

	double angA = 30*h + 0.5*m - 45;
	double angB = 6*m - 45;

	angA = rad(angA);
	angB = rad(angB);

	double dist = sqrt(pow(a*cos(angA) - b*cos(angB), 2) + pow(a*sin(angA) - b*sin(angB),2));

	printf("%.15f\n", dist);

	return 0;
}

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

struct Node{
    int parent = -1;
    int depth  = 0;
    vector<int> child;
};

class Tree{
    vector<Node> node;
    void set_depth(int id){
        for (int i = 0; i < node[id].child.size(); i++) {
            node[node[id].child[i]].depth = node[id].depth + 1;
            set_depth(node[id].child[i]);
        }
    }
public:
    Tree(int n) {
        node.resize(n);
    }
    void add_node(int id, const vector<int>& child){
        node[id].child = child;
        for (int i = 0; i < child.size(); i++) {
            node[child[i]].parent = id;
        }
    }
    void calc_depth(){
        int root;
        for (int i = 0; i < node.size(); i++) {
            if (node[i].parent == -1){
                root = i;
                break;
            }
        }
        set_depth(root);
    }
    void print_all(){
        for (int i = 0; i < node.size(); i++) {
            cout << "node " << i << ": parent = " << node[i].parent;
            cout << ", depth = " << node[i].depth;
            cout << ", ";
            if (node[i].parent == -1) {
                cout << "root";
            } else if (node[i].child.size() == 0) {
                cout << "leaf";
            } else {
                cout << "internal node";
            }
            cout << ", [";
            for (int j = 0; j < node[i].child.size(); j++) {
                cout << node[i].child[j];
                if (j < node[i].child.size() - 1) cout << ", ";
            }
            cout << "]";
            cout << endl;
        }
    }
};

int main(){
    int n;
    cin >> n;
    Tree T(n);
    for (int i = 0; i < n; i++) {
        int id;
        cin >> id;
        int k;
        cin >> k;
        Node n;
        vector<int> child;
        for (int j = 0; j < k; j++) {
            int c;
            cin >> c;
            child.push_back(c);
        }
        T.add_node(id, child);
    }
    T.calc_depth();
    T.print_all();



    return 0;
}

Measured memory_bytes: 6688
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int N;
    cin >> N;
    set<int> set;
    for (int i = 0;i < N;i++) {
        int tmp;
        cin >> tmp;
        if (!set.insert(tmp).second) {
            cout << "NO" << endl;
            return 0;
        };
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
using namespace std;
int n,m,i,j,x,s;
int main()
{
	cin>>n;
	for (i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if (x%2==1) s++;
	}
	if (s%2==0) cout<<"YES"; else cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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 int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int x, y;
  cin >> x >> y;
  int ret = (y - 1 + x - 2) / (x - 1);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector> 
using namespace std;
#define REP(i,a,b) for(int i = (int)(a); (i) < (b); i++)
#define rep(i,n) REP(i,0,n)

int main(){
	string s,t;
	string res;
	cin >> s >> t;
	if (s.size() == t.size()){
		rep(i,s.size()){ res += s[i]; res += t[i]; }	
	}else{
		rep(i,t.size()){ res += s[i]; res += t[i]; }
		res += s.back();
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
A = list(map(int,input().split()))
flag = 0

total = sum(A)
A.sort(reverse = True)

for i in range(M):
    if A[i] >= total/(4*M) :
        pass
    else :
        flag = 1

if flag == 0:
    print("Yes")
else :
    print("No")

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int t = sc.nextInt();
		for(int i=0;i<t;i++){
			int x1 = sc.nextInt();
			int y1 = sc.nextInt();
			int x2 = sc.nextInt() + x1;
			int y2 = sc.nextInt() + y1;
			
			int n = sc.nextInt();
			int count = 0;
			int x, y;
			for(int j=0;j<n;j++){
				x = sc.nextInt();
				y = sc.nextInt();
				if(x1<=x && x<=x2 && y1<=y && y<=y2) count++;
			}
			System.out.println(count);
		}
	}	
}

Measured memory_bytes: 24480
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000

typedef pair<int, int> P;
vector<P> edge[500050];
int minDist[500050];
map<P, int> mp;
int tot;
int Dijsktra(int s, int e)
{
    fill(minDist + 1, minDist + tot + 1, INF);
    minDist[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, 1});
    while(que.size())
    {
        P now = que.top();
        que.pop();
        if(minDist[now.second] != now.first)
            continue;
        for(vector<P>::size_type i = 0;i < edge[now.second].size();++i)
        {
            P next = edge[now.second][i];
            if(minDist[now.second] + next.second < minDist[next.first])
            {
                minDist[next.first] = minDist[now.second] + next.second;
                que.push({minDist[next.first], next.first});
            }
        }
    }
    if(minDist[e] != INF)
        return minDist[e];
    return -2;
}
void AddEdge(int u, int v, int w)
{
    edge[u].push_back({v, w});
    edge[v].push_back({u, w});
}
int GetId(int u, int c)
{
    if(mp.find({u, c}) != mp.end())
        return mp[{u, c}];
    return mp[{u, c}] = ++tot;
}
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    tot = n;
    for(int i = 1; i <= m; ++i)
    {
        int u, v, c;
        scanf("%d%d%d", &u, &v, &c);
        int a = GetId(u, c);
        int b = GetId(v, c);
        AddEdge(a, b, 0);
        AddEdge(u, a, 1);
        AddEdge(v, b, 1);
    }
    printf("%d\n", Dijsktra(1, n) / 2);
    return 0;
}

Measured memory_bytes: 58108
#include <stdio.h>

int main () {
	int panjang;
	int kecil;
	char abc[52];
	
	scanf("%d %d", &panjang, &kecil);
	kecil--;
	scanf("%s", &abc);
	abc[kecil] = abc[kecil] + 32;
	printf("%s", abc);
	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  ll n, a, b;
  cin >> n >> a >> b;
  cout << n/(a+b)*a + min(n%(a+b),a) << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
sp = []
for i in range(n):
    a,b=input().split()
    sp.append((a,int(b),i+1))
sp = sorted(sp, reverse=True, key = lambda x: x[1])
sp = sorted(sp, key = lambda x: x[0])
for i in sp:
    print(i[2])

Measured memory_bytes: 9116
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

use std::cmp::*;

fn main() {
    let hn: Vec<i64> = read_vec();
    let abi: Vec<Vec<i64>> = read_vec2(hn[1] as u32);

    let h = hn[0];
    let max_cost = 10000 * 10000 as usize + 1;

    // 添字...消費コスト 値...与ダメージ
    let mut dp = vec![0_u64; max_cost];
    for i in 1..max_cost as usize {
        for j in 0..hn[1] as usize {
            if abi[j][1] > i as i64 { continue; }
            let short: usize = i - abi[j][1] as usize;
            dp[i] = max(dp[i], abi[j][0] as u64 + dp[short]);
        }

        if dp[i] >= h as u64 { println!("{}", i); return; }
    }
}


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

int main()
{
string s ;
cin >> s ;
if(s=="SUN")ans=7;
if(s=="MON")ans=6;
if(s=="TUE")ans=5;
if(s=="WED")ans=4;
if(s=="THU")ans=3;
if(s=="FRI")ans=2;
if(s=="SAT")ans=1;

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

Measured memory_bytes: 764
n = int(input())
a = list(map(int, input().split()))
b = {}
for i in a:
    b.setdefault(i, 0)
    b[i] += 1
temp = 0
for i in b.values():
    temp += i * (i - 1) // 2
for i in range(n):
    ans = temp - (b[a[i]] - 1)
    print(ans)

Measured memory_bytes: 87756
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = sc.nextInt();
    if(500 * k >= x){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

using ll = long long;

int ans(int n, int m, int x, int i, vector<int> till_now, vector<int> cost, vector<vector<int>> grid) {

    bool already = true;
    for(int xt : till_now) {
        if(xt < x) {
            already = false;
            break;
        }
    }
    if(already) {
        return 0;
    }

    //base case - only one book is left;
    if(i == n - 1) {
        for(int j = 0; j < m; ++j) {

            till_now[j] += grid[i][j];

            if(till_now[j] < x) {
                return -1;
            }
        }

        return cost[i];
    }

    //make two cases;

    //book ith is purchased;

    vector<int> till_now2(m);
    for(int j = 0; j < m; ++j) {
        till_now2[j] = till_now[j] + grid[i][j];
    }

    int ans1;

    if(ans(n, m, x, i + 1, till_now2, cost, grid) == -1) {
        ans1 = -1;
    }else {
        ans1 = cost[i] + ans(n, m, x, i + 1, till_now2, cost, grid);
    }


    // int ans1 = cost[i] + ans(n, m, x, i + 1, till_now2, cost, grid);
    int ans2 = ans(n, m, x, i + 1, till_now, cost, grid);

    // cout << ans1 << " " << ans2 << "\n";

    if(ans1 == -1 && ans2 == -1) {
        return -1;
    }

    if(ans1 == -1 || ans2 == -1) {
        if(ans1 == -1) {
            return ans2;
        }
        return ans1;
    }

    return min(ans1, ans2);

}


int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> cost(n);
    vector<vector<int>> grid(n, vector<int>(m));

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= m; ++j) {
            int x;
            scanf("%d", &x);
            if(j == 0) {
                cost[i] = x;
            }else{
                grid[i][j - 1] = x; 
            }
        }
    }
    vector<int> till_now(m, 0);

    cout << ans(n, m, x, 0, till_now, cost, grid) << "\n";
}

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

int main(void) {
    constexpr long MOD = 1e9 + 7;

    long n;
    cin >> n;

    vector<long> x(n);
    for(auto &e: x) cin >> e;
    // | # . # . # .
    // 0 1 2 3 4 5 6

    long c = 0;
    long r = 1;
    for(long i=0; i<n; i++) {
        if(2*c+1 <= x[i]) {
            c++;
        } else {
            r *= c+1, r %= MOD;
        }
    }

    for(long i=1; i<=c; i++)
        r *= i, r %= MOD;

    cout << r << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
	int N,Q; cin >> N >> Q;
	Graph G(N);
	rep(i,N-1) {
		int a,b; cin >> a >> b;
		G[a-1].push_back(b-1);
		G[b-1].push_back(a-1);
	}
	vector<int> X(N,0),ans(N,-1);
	ans[0] = 0;
	rep(i,Q) {
		int p,x; cin >> p >> x;
		X[p-1] += x;
	}

	queue<pair<int, int>> que;
	que.push(make_pair(0,0));
	while(!que.empty()) {
		int v = que.front().first;
		int u = que.front().second;
		que.pop();

		ans[v] = ans[u] + X[v];
		for (int i : G[v]) {
			if (ans[i] != -1) continue;
			que.push(make_pair(i,v));
		}
	}

	rep(i,N) cout << ans[i] << " ";
	cout << endl;
}

Measured memory_bytes: 17140
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n = ni()
a = nl()
c = collections.Counter(a)

key = list(c.keys())
key.sort(reverse=True)
count = 0
for i in range(len(key)):
    if c[key[i]] >= 4 and count != 1:
        print(key[i] ** 2)
        exit()
    if c[key[i]] >= 2:
        if count == 0:
            a = key[i]
            count += 1
        elif count == 1:
            b = key[i]
            count += 1
    if count >= 2:
        print(a * b)
        exit()
print(0)


Measured memory_bytes: 18720
import heapq
pq = []

def insert(S,k):
    heapq.heappush(pq, - k)

def extractMax(S):
    a = - heapq.heappop(S)
    print(str(a))

L = input()
while L != "end":
    if L =="extract":
        extractMax(pq)
    else:
        L = L.split()
        insert(pq, int(L[1]))
    L = input()

Measured memory_bytes: 47292
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
        public static void main (String[]args)
        {
            // your code goes here
            Scanner s = new Scanner(System.in);
            int k = s.nextInt();
            String str = s.next();
            if(str.length()<=k)
                System.out.println(str);
            else
            {
                for(int i=0; i<k; i++)
                {
                    System.out.print(str.charAt(i));
                }
                System.out.print("..."+'\n');
            }


        }
}


Measured memory_bytes: 35660
#include <unistd.h>

int n;
long long int A[100000];

char ibuf[4000000];
char *ibufe = ibuf-1;

void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

long long int read_uintll(){
  long long int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');

  return x;
}

char buf[2100000];
char *bufe = buf;

void write_uintll(long long int x){
  int i;
  static char tmp[14];
  if(x==0){
    *bufe++ = '0';
    *bufe++ = '\n';
    return;
  }

  for(i=0; x; i++){
    tmp[i] = '0' + x % 10;
    x /= 10;
  }
  for(i--; i >= 0; i--){
    *bufe++ = tmp[i];
  }
  *bufe++ = '\n';
}

void writeall(){
  int k, t = 0;
  while((k=write(STDOUT_FILENO, buf+t, bufe-buf-t))>0) t += k;
}



int main(){
  int i;
  long long int a=0, b, c, z=0;
  readall();
  n = read_uintll();
  for(i=0;i<n;i++){
    A[i] = read_uintll();
    a ^= A[i];
  }

  for(b=1LL<<59;b;b>>=1){
    if(b&a) continue;
    for(i=0;i<n;i++){
      if(A[i]&b) break;
    }
    if(i==n) continue;
    if(!(z&b)) z ^= A[i];
    c = A[i];
    for(;i<n;i++){
      if(A[i]&b) A[i] ^= c;
    }
  }

  write_uintll(2*(z&~a) + a);
  writeall();

  return 0;
}


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

int main() {
  int n;
  cin >> n ;
  bool ans=0;
    for(int i=0;i<10;i++){
      for(int j=0;j<10 ;j++){
        if(i*j==n){
          ans=1;
        }
      }
    }
  if(ans) cout <<"Yes" << endl;
  else cout << "No" <<endl;
      
      
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 100050


vector<int>adj[N];
int n,a,b,m,visited[N];

vector<vector<int>>com;

bool check(string s)
{
     set<char>dc;
     for(auto i : s)dc.insert(i);
     return dc.size()==1;
}

signed main() 
{

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
     string s,temp;
     cin>>s;

     int ans=MOD;

     for(char ch='a';ch<='z';ch++)
     {
          int zi=0;
          temp=s;
          while(check(temp)==false)
          {
               string bb="";
               for(int i=0;i<temp.size()-1;i++)
               {
                    if(temp[i]==ch or temp[i+1]==ch)
                    bb.pb(ch);
                    else
                    {
                         bb.pb(temp[i]);
                    }
                    
                    
                    
                    
               }
               zi++;
              // if(ch=='a')cout<<bb<<endl;
               temp=bb;
          }
          ans=min(ans,zi);
     }

     cout<<ans;




          
     return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 2560
#include <iostream>
#include <map>

using namespace std;

typedef pair<int,int> pi;
typedef long long ll;
int n, w;

pi items[100];
//map<pi,ll> memo;
ll memo[100][100000];
ll dp(int i, ll c)
{
	pi now = {i, c};
	if(i < 0)
		return 0;
	if(memo[i][c] != 0)
		return memo[i][c];
	else
	{
		pi considering = items[i];
		ll best = dp(i-1, c);
		if(c+considering.first <= w)
		{
			best = max(best, considering.second + dp(i-1, c+considering.first));
		}
		memo[i][c] = best;
		return best;
	}
}

int main()
{
	cin >> n >> w;
	for(int i = 0; i < n; i++)
	{
		pi pa;
		cin >> pa.first >> pa.second;
		items[i] = pa;
	}
	cout << dp(n-1, 0LL) << endl;
}


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

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

void bfs(ll s, ll now,ll p,vector<vector<ll>> &d,vector<vector<ll>> &m){
    if(m[now].size()==1&&m[now][0]==p){
        return;
    }else{
        for(int i = 0; i < m[now].size(); i++){
            if(d[s][now]+1 > d[s][m[now][i]]){
                continue;
            }else{
                d[s][m[now][i]] = d[s][now] + 1;
                bfs(s, m[now][i], now, d, m);
            }
        }
    }
    return;
}



int main(){

    ll n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;

    vector<vector<ll>> m(n);
    rep(i,n-1){
        m[i].push_back(i+1);
        m[i+1].push_back(i);
    }
    m[x].push_back(y);
    m[y].push_back(x);

    vector<vector<ll>> d(n,vector<ll>(n,1000000000000000));

    map<ll,ll>mp;
    rep(i,n){
        d[i][i]=0;
        bfs(i,i,-1,d,m);
        rep(j,n){
            mp[d[i][j]] ++;
        }
    }
    // rep(i,n)rep(j,n){
    //     cout << d[i][j];
    //     if(j==n-1){
    //         cout << endl;
    //     }
    // }

    rep(i,n-1){
        cout << mp[i+1]/2 << endl;
    }
    return 0;
}  

Measured memory_bytes: 32000
#include <algorithm>
#include <iostream>
#include <vector>

template <typename T> void merge_sort(std::vector<T> &a) {
  int n = a.size();
  if (n <= 1) {
    return;
  }

  std::vector<int> b(a.begin(), a.begin() + n / 2);
  std::vector<int> c(a.begin() + n / 2, a.end());

  merge_sort(b);
  merge_sort(c);

  int ai = 0, bi = 0, ci = 0;
  // merge の処理
  while (ai < n) {
    if (bi < (int)b.size() && (ci == (int)c.size() || b[bi] <= c[ci])) {
      a[ai++] = b[bi++];
    } else {
      a[ai++] = c[ci++];
    }
  }
}

int main() {
  int n, k;
  std::cin >> n >> k;

  std::vector<int> h(n);
  for (int i = 0; i < n; i++) {
    std::cin >> h[i];
  }
  merge_sort(h);

  int ans = (int)1e9 + 9;
  for (int i = 0; i < n - k + 1; i++) {
    ans = std::min(ans, h[i + k - 1] - h[i]);
  }
  std::cout << ans << std::endl;

  return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

void solve() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b and b == c) {
        cout << "No" << endl;
        return;
    }
    set<int> st;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    if (st.size() == 2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;


template<class T>T max(T a, T b) { return a > b ? a : b; }
template<class T>T min(T a, T b) { return a < b ? a : b; }
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmix(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

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


using namespace std;
int main()
{
	ll a, b;
	cin >> a >> b;

	if ((a + b) % 2 == 1) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	cout << (a+b)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
s = defaultdict(int)
for _ in range(n):
    s[input().rstrip()] += 1

m = int(input())
t = defaultdict(int)
for _ in range(m):
    t[input().rstrip()] += 1

ans = 0
for w in s.keys():
    tmp = s[w] - t[w]
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 3316
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a,b,c,d = MAP()

while(True):
    c=c-b
    if(c<=0):
        winner = "Yes"
        break
    a =a-d
    if(a<=0):
        winner = "No"
        break

print(winner)

Measured memory_bytes: 9952
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_10_D
 */
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>

using namespace std;

double
cubic(const double a)
{
    return a * a * a;
}

double
square(const double a)
{
    return a * a;
}

int
main()
{
    ios::sync_with_stdio(false);

    int n;
    cin >> n; cin.ignore();

    vector<double> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i]; cin.ignore();
    }
    vector<double> y(n);
    for (int i = 0; i < n; i++) {
        cin >> y[i]; cin.ignore();
    }

    vector<double> d;
    for (int i = 0; i < n; i++) {
        d.push_back( abs( x[i] - y[i] ) );
    }
    x.clear();
    y.clear();

    cout << setprecision(6) << fixed;

    cout << accumulate(d.cbegin(), d.cend(), 0.0) << endl;

    vector<double> d2;
    transform(d.begin(), d.end(), back_inserter(d2), square);
    cout << sqrt( accumulate(d2.cbegin(), d2.cend(), 0.0) ) << endl;
    d2.clear();

    transform(d.cbegin(), d.cend(), back_inserter(d2), cubic);
    cout << cbrt( accumulate(d2.cbegin(), d2.cend(), 0.0) ) << endl;
    d2.clear();

    sort(d.begin(), d.end(), greater<double>());
    auto it = d.cbegin(); 
    cout << *it << endl;
    d.clear();

    return 0;
}

Measured memory_bytes: 3420
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b;
  cin >> a >> b;
  cout << a*b <<endl;
}

Measured memory_bytes: 3624
<?php
fscanf(STDIN, '%d %d', $a, $b);

$result = 0;
for ($i = 0; $i < 2; $i++) {
    if ($a >= $b) {
        $result += $a;
        $a--;
    } else {
        $result += $b;
        $b--;
    }
}

echo $result;

Measured memory_bytes: 4604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		int ave = (int) Math.ceil((a + b) / 2);

		System.out.println(ave);
	}
}

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

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

    int ans = 1005;
    int range = s.size()-t.size();
    for(int i=0;i<=range;i++){
        int cnt = 0;
        for(int j=0;j<t.size();j++){
            if(s[i+j]==t[j]) cnt++;
        }
        cnt = t.size()-cnt;
        ans = min(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }

  void __solve(Scanner cin) {
	  int A = cin.nextInt();
	  int B = cin.nextInt();
	  if( A >= 13 ) {
		  //;
	  }
	  if( 6 <= A && A <= 12 ) {
		  B /= 2;
	  }
	  if( A <= 5 ) {
		  B = 0;
	  }
	  System.out.println(B);
  }

}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll i,ans1,ans2,b,v,w,t,flag=0;
    char a;
    scanf("%c",&a);
    if(a<='Z'&&a>='A')
        printf("A\n");
    else
        printf("a\n");

}


Measured memory_bytes: 3684
#include<iostream>
#include<cmath>
#include<string>

using namespace std;
int main(){
    int a[3],b[2];
    cin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1];
    int min=4000;
    for(int i=0;i<3;i++){
        for(int j=0;j<2;j++){
            if(a[i]+b[j]<min){
                min=a[i]+b[j];
            }
        }
    }
    cout << min-50 << endl;
    return 0;
}



Measured memory_bytes: 3088
n = int(input())
l = list(map(int,input().split()))
u = []
a = 0
for j, i in enumerate(l):
    a += i*((-1)**j)
u.append(a)
mae = a
for j, i in enumerate(l):
    usi = int((i - mae/2) * 2)
    u.append(usi)
    mae = usi
print(*u[:-1])

Measured memory_bytes: 70756
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<u32>();
    println!("{}", n * n* n);
}


Measured memory_bytes: 4352
n = gets.chomp.to_i
num = gets.chomp.split
max = 0
sum = 0

for i in 0..(n-1)
  num[i] = num[i].to_i
  if max < num[i]
    max = num[i]
  end
  sum += num[i]
end
sum -= max
if max < sum
  puts "Yes"
else
  puts "No"
end
  

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const int sqrtN = 512;
const int logN = 64;
const ll LINF=1e18;
const ld PI=abs(acos(-1));

struct LowestCommonAncestor{
	vector<vector<int>> g, parent;
	vector<int> depth;
	bool built = false;
	int N;
	
	LowestCommonAncestor(int n) : N(n) {
		g.resize(N);
		parent.resize(logN, vector<int>(N));
		depth.resize(N);
	}
	
	void add_edge(int u, int v){
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	void dfs(int v, int par = -1, int d = 0){
		parent[0][v] = par;
		depth[v] = d;
		
		for(auto e:g[v]){
			if(e == par) continue;
			dfs(e, v, d + 1);
		}
	}
	
	void build(){
		dfs(0);
		REP(k, 0, logN - 1){
			REP(i, 0, N){
				if(parent[k][i] < 0) parent[k + 1][i] = -1;
				else parent[k + 1][i] = parent[k][parent[k][i]];
			}
		}
	}
	
	int get(int u, int v){
		if(!built) build(); built = true;
		if(depth[u] > depth[v]) swap(u, v);
		
		REP(k, 0, logN) if(((depth[v] - depth[u]) >> k) & 1) v = parent[k][v];	
		if(u == v) return u;
		
		RREP(k, logN - 1, 0){
			if(parent[k][u] == parent[k][v]) continue;
			u = parent[k][u];
			v = parent[k][v];			
		}
		
		return parent[0][u];
	}
};

int main(){
	int n; cin >> n;
	LowestCommonAncestor lca(n);
	REP(i, 0, n){
		int a; cin >> a;
		REP(j, 0, a){
			int u; cin >> u;
			lca.add_edge(i, u);
		}
	}
	
	int q; cin >> q;
	REP(i, 0, q){
		int a,b; cin >> a >> b;
		cout << lca.get(a, b) << endl;
	}
	
	return 0;
}



Measured memory_bytes: 36716