akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

       int n = scan.nextInt(); 
       int []x = new int[n];
       int []y = new int[n];
       double p1 = 0;
       double p2 = 0;
       double p3 = 0;
       double pi = 0;

       for(int i =0;i<n;i++){
          x[i]=scan.nextInt();
       }
       for(int i =0;i<n;i++){
          y[i]=scan.nextInt();
       }

       for(int i=0;i<n;i++){

          p1 += Math.abs(x[i]-y[i]);

          p2 += Math.pow(x[i]-y[i],2);

          p3 += Math.pow(Math.abs(x[i]-y[i]),3);

          pi = Math.max(pi,Math.abs(x[i]-y[i]));
       }

       p2 = Math.sqrt(p2);

       p3 = Math.cbrt(p3);

       System.out.println(p1+"\n"+p2+"\n"+p3+"\n"+pi);

 
       }
   }



Measured memory_bytes: 26464
N,M = [int(zz) for zz in input().split()]

li = [[0,0] for _ in range(N)]

for i in range(M):
    p,s = [zz for zz in input().split()]
    if li[int(p)-1][1] == 0 and s == 'WA':
        li[int(p)-1][0] += 1
    elif s == 'AC':
        li[int(p)-1][1] = 1

penalty = 0
AC_count = 0
for i in range(N):
    penalty += li[i][0]*li[i][1]
    AC_count += li[i][1]

print(AC_count,penalty)


Measured memory_bytes: 13172
import java.util.*;
import java.io.*;

//atcoder
public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out, false);
        int n = scanner.nextInt();
        long[] arr = new long[n];
        for(int i = 0; i < n; i++) arr[i] = scanner.nextLong();
        ArrayList<Long>[] lists = new ArrayList[62];
        int[] cnt = new int[62];
        for(int i = 0; i < n; i++) for(int j = 61; j >= 0; j--) if (((1L << j) & arr[i]) > 0) cnt[j]++;
        for(int i = 0; i < 62; i++) for(int j = 0; j < n; j++) if (cnt[i] % 2 == 1 && ((1L << i) & arr[j]) > 0) arr[j] ^= 1L << i;
        for(int i = 0; i < 62; i++) lists[i] = new ArrayList<>();
        for(int i = 0; i < n; i++) for(int j = 61; j >= 0; j--) if (((1L<<j) & arr[i]) > 0) {
            lists[j].add(arr[i]);
            break;
        }
        long ans = 0;
        for(int i = 0; i < 62; i++) if ( cnt[i] > 0 && cnt[i] % 2 == 1) ans |= (1L << i);
        long val = 0;
        for(int i = 61; i>= 0; i--) {
            if (!lists[i].isEmpty()) {
                Collections.sort(lists[i], Collections.reverseOrder());
                val = Math.max(val, val ^ lists[i].get(0));
                long t  = lists[i].get(0);
                for(int j = 1; j < lists[i].size(); j++) {
                    long cur = lists[i].get(j) ^ t;
                    for(int k = i - 1; k >= 0; k--) if (((1L << k) & cur) > 0) {
                        lists[k].add(cur);
                        break;
                    }
                }
            }
        }
        out.println((val * 2 + ans));
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 150188
#include <stdio.h>

int main(void) {
	int A, B, C;
	int rA;
	int i;

	scanf("%d %d %d", &A, &B, &C);
	rA = A % B;
	for(i = 0; i < B; i++) {
		if(rA == C) {
			printf("YES\n");
			return 0;
		}
		rA = (rA + A) % B;
	}

	printf("NO\n");

	return 0;
}


Measured memory_bytes: 128
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val S = rd.readInt()

    val dp = LongArray(2005){0}
    for (i in 0 until 3) {
        dp[i] = 0
    }
    for (i in 3 until 6) {
        dp[i] = 1
    }

    for (i in 6 .. S) {
        dp[i] += dp[i-3]
        dp[i] %= MOD
        dp[i] += dp[i-1]
        dp[i] %= MOD
    }

    val ans = dp[S]
    println(ans)
}


//val rd = debug.Reader("abc", "178", "d", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readDouble: () -> Double = { br.readLine().toDouble() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readIntArray: () -> IntArray = { readListInt().toIntArray() }
    val readLongArray: () -> LongArray = { readListLong().toLongArray() }
    val readListStringCol: (Int) -> List<String> = { N -> (0 until N).map { readString() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { readListInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val readListLongCols: (Int) -> List<List<Long>> = { N -> (0 until N).map { readListLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 34744
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++){
        cin >> h[i];
    }
    
    int count = 0;
    for (int i = 0; i < N; i++){
        if (h[i] >= K){
            count += 1;
        }
    }
    
    cout << count;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define ll long long

using namespace std;

int main() {
      cin.sync_with_stdio(0);
      int k;
      string s;
      cin >> k >> s;
      if (s.size() > k) {
            while (s.size() > k)
                  s.pop_back();
            s += "...";
      }
      cout << s;
      return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
   int n;
   bool ans = true;
   cin >> n;
   map<string, int> mp;
   rep(i,n){
      char last;
      string s;
      cin >> s;
      if(mp[s] != 0) ans = false;
      mp[s]++;
      if(i != 0){
         if(s[0] != last) ans = false;
      }
      last = s.back();
   }
   if(ans) cout << "Yes" << endl;
   else cout << "No" << endl;
}

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


int main(){
  int x;
  cin >> x;
  string ans;
  if(x < 30){
    ans = "No";
  }
  else {
    ans = "Yes";
  }
  
  cout << ans << endl;
  return 0;
}

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

public class Main {

    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            String[] input = in.readLine().split(" ");
            int n = Integer.parseInt(input[0]);
            int m = Integer.parseInt(input[1]);
            int[][] A = new int[n][m];
            int[] b = new int[m];

            for (int i = 0; i < n; i++) {
                String[] aij = in.readLine().split(" ");
                for (int j = 0; j < m; j++) {
                    A[i][j] = Integer.parseInt(aij[j]);
                }
            }

            for (int i = 0; i < m; i++) {
                b[i] = Integer.parseInt(in.readLine());
            }

            int[] c = new int[n];
            for (int i = 0; i < n; i++) {
                int[] a = A[i];
                int sum = 0;
                for (int j = 0; j < m; j++) {
                    sum = sum + a[j] * b[j];
                }
                c[i] = sum;
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < n; i++) {
                sb.append(c[i]);
                sb.append("\n");
            }
            System.out.print(sb);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 27276
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>

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

using namespace std;
using ll = long long;

int dis(int x1, int y1, int x2, int y2) {
	return abs(x1 - x2) + abs(y1 - y2);
}

int main() {

	int n;

	cin >> n;

	int cx = 0, cy = 0, ct = 0;
	REP(i, n) {
		int t, x, y;
		cin >> t >> x >> y;
		ll d = dis(cx, cy, x, y);
		if (d > t - ct) {
			cout << "No" NL;
			return 0;
		}
		if ((d + t - ct) % 2 == 1) {
			cout << "No" NL;
			return 0;
		}

	}

	cout << "Yes" NL;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int dsum(int x)
{
	int n=x,sum=0;
	while (n>0){
		sum+=n%10;
		n/=10;
	}
	return sum;
}

int main()
{
	int n,a,b,sum=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++){
		if (dsum(i)>=a and dsum(i)<=b)
			sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

struct q {
    int a, b, c, d;
    void input() { cin >> a >> b >> c >> d; }
    bool operator<(const q& tmp) const {
        return d < tmp.d;
    }
};

ll ret;
int N, M, Q;
int a[101], b[101], c[101], d[101];

int ans[101];
void solve(int i, int ma=1) {
    if (i >= N) {
        // ok
        ll tmp = 0;
        rep(i, Q) {
            if (ans[b[i]-1] - ans[a[i]-1] == c[i]) tmp += d[i];
        }
        ret = max(ret, tmp);
        return;
    }

    for (int j=ma; j<=M; ++j) {
        ans[i] = j;
        solve(i+1, j);
        ans[i] = -1;
    }
    return;
}

int main() {
    cin >> N >> M >> Q;
    rep(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    solve(0);
    cout << ret << endl;
}


Measured memory_bytes: 3636
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int ans;
    string s,t,u,sr,tr,ur;
    cin >> s;

    t = s.substr(0,(s.size() - 1) / 2);
    u = s.substr((s.size() + 3) / 2 - 1, (s.size() - 1) / 2);

    sr = s;
    tr = t;
    ur = u;

    reverse(all(s));
    reverse(all(t));
    reverse(all(u));

    if(s == sr && t == tr && u == ur){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

int main(){
  int a, b ;
  cin >> a >> b;
  
  1 <= a <= 10000;
  1 <= b <= 10000;
  
  int product = a * b;
  
  if (product % 2 == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}


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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)2 2
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

ll f(ll n) {
	return (((n-1)*n)/2);
}

int main() {
    godspeed;
 	ll n, m; cin >> n >> m;

 	cout << f(n) + f(m);
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define fi first
#define se second
#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(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#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 pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n, k;
  cin >> n >> k;
  k--;
  vl x(n);
  rep(i, n) cin >> x[i];

  ll mi = 1LL<<60;
  rep(i, n) {
    if (i + k >= n) continue;
    ll d = abs(x[i]) + x[i + k] - x[i];
    mi = min(mi, d);
  }

  drep(i,n){
    if(i-k <0)continue;
    ll d = abs(x[i]);
    ll r = x[i], l= x[i-k];
    d+=r-l;
    mi = min(mi, d);
  }
  print(mi);
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, M;

int main()
{
    cin >> N;
    vector<string> s(N);
    map<string, int> mp;
    for (int i = 0; i < N; i++)
    {
        cin >> s[i];
        mp[s[i]]++;
    }

    cin >> M;
    vector<string> t(M);
    for (int i = 0; i < M; i++)
    {
        cin >> t[i];
        mp[t[i]]--;
    }
    int ans = 0;

    for (auto &p : mp)
    {
        int v = p.second;
        ans = max(v, ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		System.out.print(Z + " " + X + " " + Y);
	}
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
typedef vector<int> vi;
typedef vector<vector<int>> vi2;

lli solve(lli h);
int main(void)
{
    lli H;
    cin >> H;
    int count = 0;
    lli ans = solve(H);
    cout << ans << endl;
    return 0;
}

lli solve(lli h)
{
    if (h == 1)
    {
        return 1;
    }
    else
    {
        return 2 * solve((lli)h / 2) + 1;
    }
}

Measured memory_bytes: 256
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);
            var s = Console.ReadLine().Trim();

            if(s[a] == '-'){
                var x = s.Substring(0, a);
                var y = s.Substring(a + 1, b);

                var o = 0;
                if(int.TryParse(x, out o) && int.TryParse(y, out o)){
                    Console.WriteLine("Yes");
                }else{
                    Console.WriteLine("No");
                }
            }else{
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11220
import java.util.Scanner;

import static java.lang.Math.max;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] blocks = new int[n];
        int count = 0;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            blocks[i] = sc.nextInt();
        }
        for (int i = 1; i < n; i++) {
            if (blocks[i] <= blocks[i - 1]) {
                count++;
            } else {
                ans = max(count, ans);
                count = 0;
            }
        }
        ans = max(count, ans);

        System.out.println(ans);
    }
}

Measured memory_bytes: 50500
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>

using namespace std;

int main(){

    string s;
    cin >> s;

    int len = s.length() - 2;


    cout << s[0] << len  << s[s.length()-1] << endl;

}

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

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

int main() {
  int n;
	cin >> n;
	vector<ll> ma(n);
	REP(i,n) cin >> ma[i];
	int c = 0;
	int M = 0;
	REP(i,n-1) {
		if (ma[i]>=ma[i+1]){

			c+=1;
			M = max(M,c);
		}
		else{
			c = 0;
		}
	}

  cout << M << endl;
}


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

int main() {
	int  n,m;
	int tv[100000]={};
	int tl[100000]={};
	int r[5001]={};
	int rn[5000]={};
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> tv[i] >> tl[i];
	}
	int ch;
	do{
		ch=0;
		for(int i=0;i<m;i++){
			if(r[tl[i]]<r[tv[i]]+1){
				r[tl[i]]=r[tv[i]]+1;
				ch=1;
			}
		}
	}while(ch);
	int dn=0;
	int oa= 0;
	for(int i=0;dn<n;i++){
		int cn = 0;
		for(int j=1;j<=n;j++){
			if(r[j]==i){
				rn[dn]=j;
				cout << j << endl;
				dn++;
				cn++;
			}
		}
		if(cn>1){
			oa=1;
		}
	}
	cout << oa << endl;
}

Measured memory_bytes: 1968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
    }

    for(int i = 1; i <= n; i++)
    {
        cout << i * 20000 << " ";
    }
    cout << endl;

    for(int i = 1; i <= n; i++)
    {
        int pos = distance(p.begin(), find(p.begin(), p.end(), i));
        cout << (n-i) * 20000 + pos+1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 768
#include <iostream>

using namespace std;

int main() {
	string s;

	cin >> s;

	string t;

	cin >> t;

	int len;
	len = t.size();
	
	string t_new;
	t_new = t.substr(0, len - 1);

	if (t_new == s) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3036
A,B,C,D,E,F = map(int, input().split())

import functools
import sys
sys.setrecursionlimit(10**5)

@functools.lru_cache(maxsize=None)
def calc_strength(sugar, water):
    if water == 0: return -1
    return sugar * 100 / (sugar + water)

@functools.lru_cache(maxsize=None)
def f(strength, sugar, water):
    cand = [(strength, sugar + water, sugar)]
    for x in ((C, 0), (D, 0), (0, 100*A), (0, 100*B)):
        s, w = sugar + x[0], water + x[1]
        if s + w <= F and s * 100 <= w * E:
            cand.append(f(calc_strength(s, w), s, w))
    return max(cand)
    
print(*f(-1, 0, 0)[1:])

Measured memory_bytes: 7988
# -*- coding: utf-8 -*-
TABLE = {
  0.0   => 'light fly',
  48.00 => 'fly',
  51.00 => 'bantam',
  54.00 => 'feather',
  57.00 => 'light',
  60.00 => 'light welter',
  64.00 => 'welter',
  69.00 => 'light middle',
  75.00 => 'middle',
  81.00 => 'light heavy',
  91.00 => 'heavy',
}

STDIN.map(&:to_f).each {|w| puts TABLE.inject(""){|c, r| w > r[0] ? r[1] : c }}

Measured memory_bytes: 6088
#include <cstdio>
#include <utility>
#include <vector>
#include <string>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define is inline bool scan
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
is(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
is(char &c){c=gcu();gcu();return c!=EOF;}
is(string &s){int c; s = "";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

typedef vector<string> v;

char pat_search(v &a) {
	static auto p = [&a](int i, int j) {
		return i < 8 && j < 8 && a[i][j] == '1';};
	for (int i = 0; i < 8; i++)
		for (int j = 0; j < 8; j++)
			if (a[i][j] == '1') {
				return p(i + 1, j + 1)? p(i, j + 1)? p(i + 1, j + 2)? 'E' : 'A' : 'F' :
					p(i, j + 1)? p(i, j + 2)? 'C' : 'G' : p(i + 2, j)? 'B' : 'D';
			}
	return 'X';
}

int main() {
	v a(8);
	do {
		for (auto &s: a)
			scan(s);
		out(pat_search(a), '\n');
	} while (gcu() == '\n');
}


Measured memory_bytes: 2668
# coding: utf-8
# Your code here!
a= input()
c=0
for i in range(len(a)):
    if i==0:
        if a[i]=='0':
            flag=True
        else:
            flag=False
    else:
        if a[i]=='0' and flag==True:
            c+=1
            flag=False
        elif a[i]=='0' and flag==False:
            pass
            flag=True
        elif a[i]=='1' and flag==True:
            pass
            flag=False
        elif a[i]=='1' and flag==False:
            c+=1
            flag=True
                
print(c)
        
        
        



Measured memory_bytes: 3316
class Gcd:#クラスになれるために無理やりつかってみた
    def __init__(self,x,y):
        if(x<=y):
            self.__a=x
            self.__b=y
        else:
            self.__a=y
            self.__b=x
    
    def gcd(self):
        self.__c=(self.__b)%(self.__a)
        if(self.__c==0):
            print(self.__a)
            return 0
        self.__b=self.__a
        self.__a=self.__c
        self.gcd()


        

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


Measured memory_bytes: 5600
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

x,a,b = inpl()
print('A' if abs(x-a) < abs(x-b) else 'B')

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

using namespace std;

int main() {

int N, K;
	cin >> N >> K;
	vector<int> h(N);
	for(auto &x: h) cin >> x;

	vector<int> a(N);
	a[0] = 0;
	for(int i = 1; i < N; i++) {
		int l = min(K, i);
		vector<int> b(l);
		for(int j = 0; j < l; j++) {
			b[j] = a[i - j - 1] + abs(h[i] - h[i - j - 1]);
		}
		a[i] = *min_element(b.begin(), b.end());
	}

	cout << a[N-1] << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<fstream>
#include<vector>

using namespace std;

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  long N;
  cin>>N;

  vector<long> X(N);
  long MIN=1000000000;
  long MAX=0;
  for(int i=0;i<N;i++){
    long TEMP;
    cin>>TEMP;
    MAX=max(MAX,TEMP);
    MIN=min(MIN,TEMP);
    X.at(i)=TEMP;
  }

  //cout<<MAX<<','<<MIN<<endl;

  long T=0;
  long ans=1000000000000;
  //cout<<ans<<endl;

  for(int i=MIN;i<MAX+1;i++){
    for(int j=0;j<N;j++){
      T += (X.at(j)-i)*(X.at(j)-i);
    }
    //cout<<i<<','<<T<<endl;
    if(T<ans) ans=T;
    T=0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int dp[2002002]={};
int main(){
    fast_io
    
    int n, k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n) {
        cin>>a[i];
        dp[a[i]-1]++;
    }
    sort(dp, dp+n);
    int ans=0;
    for(int i=0;i<n-k;i++) ans+=dp[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#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 all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int x;
  cin>>x;
  ll ans = 0;
  REP(b,1,100){
    REP(p,2,100){
      if((ll)pow(b,p) <= x)ans = max(ans,(ll)pow(b,p));
    }
  }
  cout << ans << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;

    if (y == NIL) {
        root = z;
    }
    else {
        if (z->key < y->key) y->left = z;
        else y->right = z;
    }
}

Node *find(Node *u, int k) {
    while (u != NIL && u->key != k) {
        u = (u->key < k ? u->right: u ->left);
    }
    return u;
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}


int main(void) {
    int n, i, k;
    string com;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            scanf("%d", &k);
            insert(k);
        }
        else if (com == "find") {
            scanf("%d", &k);
            Node *x = find(root, k);
            if (x != NIL) printf("yes\n");
            else printf("no\n");
        }
        else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 20004
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

void rotate(vector<string>& s) {
	vector<string> t = s;
	for (int i = 0; i < 8; i++)
		for (int j = 0; j < 8; j++)
			if (t[7 - i][7 - j] == 'o') s[i][j] = 'x';
			else if (t[7 - i][7 - j] == 'x') s[i][j] = 'o';
			else s[i][j] = '.';
}

int foo(vector<string>& s, int i, int j, int di, int dj) {
	if (i < 0 || i >= 8 || j < 0 || j >= 8 || s[i][j] == '.') return -1;
	else if (s[i][j] == 'o') return 0;
	else {
		int x = foo(s, i + di, j + dj, di, dj);
		return x == -1 ? -1 : x + 1;
	}
}

int bar(vector<string>& s, int i, int j, int di, int dj) {
	if (i < 0 || i >= 8 || j < 0 || j >= 8 || s[i][j] == '.') return -1;
	else if (s[i][j] == 'o') return 0;
	else {
		int x = bar(s, i + di, j + dj, di, dj);
		if (x == -1) return -1;
		else {
			s[i][j] = 'o';
			return x + 1;
		}
	}
}

int main() {
	vector<string> s(8);
	for (int i = 0; i < 8; i++) cin >> s[i];
	bool flag = true;
	int t;
	for (t = 0; ; t++) {
		int _i, _j, maxi = 0;
		for (int i = 0; i < 8; i++)
			for (int j = 0; j < 8; j++) {
				if (s[i][j] != '.') continue;
				int sum = 0;
				for (int di = -1; di <= 1; di++)
					for (int dj = -1; dj <= 1; dj++)
						if (di || dj)
							sum += max(0, foo(s, i + di, j + dj, di, dj));
				if (sum > maxi) {
					_i = i; _j = j; maxi = sum;
				}
			}
		if (maxi > 0) {
			s[_i][_j] = 'o';
			for (int di = -1; di <= 1; di++)
				for (int dj = -1; dj <= 1; dj++)
					if (di || dj)
						bar(s, _i + di, _j + dj, di, dj);
			flag = true;
		}
		else if (flag) flag = false;
		else break;
		rotate(s);
	}
	if (t % 2 == 1) rotate(s);
	for (int i = 0; i < 8; i++)
		cout << s[i] << endl;
}

Measured memory_bytes: 1188
N,M = map(int,input().split())
L = []
R = []
LR = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    L.append(LR[i][0])
countL = 0
countL = max(L)
for j in range(M):
    R.append(LR[j][1])
countR = 0
countR = min(R)
if countR - countL + 1 <= 0:
    print(0)
else:
    print(countR-countL+1)
    


    



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

using namespace std;

int main()
{
    long A, B, C, i, z=0;
    cin>>A>>B>>C;
        if(C<=B)
        cout<<B+C;
        else
            if(C>B && A+B<C)
        cout<<A+B+B+1;
        else
        if(C>B && A+B>=C)
            cout<<C+B;




    return 0;
}


Measured memory_bytes: 256
/*                        
                            In the name of Almighty ALLAH
                                    ISLAM IS PEACE

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************
   
   
   
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE 
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
 
*/


#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb               push_back
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(v)           v.begin(),v.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;



int main() {
    
    FASTIO;
    
    string s = "ACL";
    
    ll n;
    cin >> n;
    while(n--){
        cout << s;
    }
    
    cout << endl;
    
    
    
    
    
	return 0;
}

Measured memory_bytes: 3560
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int N = Integer.parseInt(in.next());
		int K = Integer.parseInt(in.next());
		int[] x = new int[N];
		for(int i = 0; i < N; i++)x[i]=Integer.parseInt(in.next());
		int ans = 0;
		for(int i = 0; i < N; i++)ans += Math.min(x[i],K-x[i]);
		System.out.println(ans*2);
	}
}

Measured memory_bytes: 25556
#include <bits/stdc++.h>
using namespace std;
int n;
int a[10] = {0, 111, 222, 333, 444, 555, 666, 777, 888, 999};
int res;

int main() {
	cin >> n;
	for(int i = 1; i <= 9; i++) {
		if(a[i] >= n) {
			res = a[i]; break;
		}
	}
	cout << res << endl;
}

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

int main() {

  string S,T;
  cin >> S >> T;

  int n = T.size();
  int ans = 1e9;
  for(int i = 0;i <= (int)S.size()-n;i++) {
    string s = S.substr(i,n);
    int sum = 0;
    for(int j = 0;j < n;j++) {
      if(s[j] != T[j]) sum++;
    }
    ans = min(ans,sum);
  }

  cout << ans << endl;


}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int N = 1e5+9;

string s;
int ans[N];
int n;

int main() {
    cin >> s;
    s.push_back('R');
    n = s.size();
    ll cnt = 0;
    int r_last, l_first;
    char step = 'R';
    for(int i = 0; i < n; i++) {
        if(s[i] == step) {
            cnt++;
            continue;
        }

        if(step == 'R') { // s[i] == 'L'
            r_last = i-1;
            l_first = i;
            step = 'L';
            cnt++;
        }
        else if(step == 'L') { // s[i] == 'R'
            int right = i;
            int left = i - cnt + 1;
            int odd = cnt / 2;
            int even = cnt / 2;
            if(cnt % 2 == 1)  (left % 2 ? odd : even)++;
            ans[r_last] = (r_last % 2 ? even : odd);
            ans[l_first] = (l_first % 2 ? even : odd);
            cnt = 1;
            step = 'R';
        }
    }

    for(int i = 0; i < n-1; i++)
        cout << ans[i] << (i == n-2 ? "\n" : " ");
}

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

typedef pair<int,int> P;
typedef pair<int,P> PP;
typedef pair<int,PP> PPP;

const int INF = 1 << 28;

int dlx[] = { 1, 1, 1, 1, 1, 2, 2, 2, 3};
int drx[] = {-1,-1,-1,-1,-1,-2,-2,-2,-3};
int dy[]  = {-2,-1, 0, 1, 2,-1, 0, 1, 0};


int main ()
{
    int h, w;
    while (cin >> w >> h, h + w) {
        vector<vector<int> > field(h, vector<int>(w, INF));
        vector<P> s;
        vector<P> t;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                char str;
                cin >> str;
                if ('0' <= str && str <= '9') {
                    field[i][j] = (int)(str - '0');
                } else if (str == 'T') {
                    field[i][j] = 0;
                    t.push_back(P(i,j));
                } else if (str == 'S') {
                    field[i][j] = 0;
                    s.push_back(P(i,j));
                } else if (str == 'X') {
                    field[i][j] = INF;
                }
            }
        }

        priority_queue<PPP, vector<PPP>, greater<PPP> > que;
        vector<vector<vector<int> > > d(2, vector<vector<int> >(h, vector<int>(w, INF)));
        for (int i = 0; i < s.size(); i++) {
            que.push(PPP(0, PP(0, P(s[i])) ) );
            que.push(PPP(0, PP(1, P(s[i])) ) );
            d[0][s[i].first][s[i].second] = 0;
            d[1][s[i].first][s[i].second] = 0;
        }

        while (que.size()) {
            PPP ppp = que.top(); que.pop();
            int cost = ppp.first;
            PP pp = ppp.second;
            int dir = pp.first;
            int y = pp.second.first;
            int x = pp.second.second;

            if (d[dir][y][x] < cost) continue;

            for (int i = 0; i < 9; i++) {
                int nx = x, ny = dy[i] + y;
                nx += dir == 1 ? dlx[i] : drx[i];
                if (0 <= nx && nx < w && 0 <= ny && ny < h && field[ny][nx] != INF) {
                    if (d[1 - dir][ny][nx] > cost + field[ny][nx]) {
                        d[1 - dir][ny][nx] = cost + field[ny][nx];
                        que.push(PPP(d[1 - dir][ny][nx], PP(1 - dir, P(ny, nx) ) ) );
                    }
                }
            }
        }

        int res = INF;
        for (int i = 0; i < t.size(); i++) {
            int y = t[i].first;
            int x = t[i].second;
            res = min(res, d[0][y][x]);
            res = min(res, d[1][y][x]);
        }

        cout << (INF == res ? -1 : res) << endl;
    }

    return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  string s,t;
  cin >> s >> t;
  int ans = 0;
  rep(i,s.size())if(s[i] != t[i])ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3860
// https://atcoder.jp/contests/abc052/tasks/abc052_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    int now = 0, maxv = 0;
    for (auto &x : s) {
        if (x == 'I') {
            now++;
        } else {
            now--;
        }
        maxv = max(maxv, now);
    }
    cout << maxv << endl;

    return 0;
}


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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> a(N), b(M);
    rep(i, N) cin >> a[i];
    rep(i, M) cin >> b[i];
    vector<ll> suma(N+1, 0), sumb(M+1, 0);
    for(int i = 1; i < N+1; i++) suma[i] = suma[i-1] + a[i-1];
    for(int i = 1; i < M+1; i++) sumb[i] = sumb[i-1] + b[i-1];
    int ans = 0;
    //a基準
    for(int i = 0; i < N+1; i++){
        int mx = 0;
        if(suma[i] <= K) mx = i;
        else break;
        int key = K - suma[i];
        mx += (upper_bound(sumb.begin(), sumb.end(), key) - sumb.begin() - 1);
        ans = max(ans, mx); 
    } 
    //b基準
    for(int i = 0; i < M+1; i++){
        int mx = 0;
        if(sumb[i] <= K) mx = i;
        else break;
        int key = K - sumb[i];
        mx += (upper_bound(suma.begin(), suma.end(), key) - suma.begin() - 1);
        ans = max(ans, mx);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8016
n, d = gets.chomp.split.map(&:to_i)
xx = []
n.times do
  xx << gets.chomp.split.map(&:to_f)
end

ans = 0
n.times do |i|
  n.times do |j|
    next if i == j
    tmp = 0
    d.times do |k|
      tmp += (xx[i][k] - xx[j][k])**2
    end

    dis = Math.sqrt(tmp)

    ans += 1 if dis == dis.to_i
  end
end

p ans/2



Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
long long const MAX=1e9+7;
double dp[3002];
int main()
{long long i,j,n,r,k,p,w,y,sum,m;
double x;
x=1;
cin>>n;
double a[n];
k=n/2;
for(i=0;i<n;i++)
{scanf("%lf",&a[i]);}
dp[0]=x;
for(i=1;i<=n;i++)
{for(j=i;j>=0;j--)
{ dp[j]=dp[j]*(x-a[i-1]);
if(j>0)
dp[j]=dp[j]+dp[j-1]*a[i-1];
}}
x=0;
for(i=k+1;i<=n;i++)
{x=x+dp[i];}
printf("%.10lf",x);
return 0;}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<iomanip>
#include<bitset>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define mmax 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<lli> s(m);
  rep(i,0,n){
    int k;
    cin>>k;
    vector<lli> a(k);
    rep(j,0,k){
      cin>>a.at(j);
      ++s.at(a.at(j)-1);
    }
  }
  int ans=0;
  rep(i,0,s.size()){
    if(s.at(i)==n)
      ++ans;
  }
  ou(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
 
using namespace std;
 
int main(){
  int a,b,c,d;
    cin >> a>>b>> c>> d;
    if(a+b > c+d){
    cout << "Left";
    }else if(a+b < c+d){
        cout << "Right";
    }else {
        cout <<"Balanced";
    }
    
return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  long long ans=0;
  vector<int> a(n);
  priority_queue<int> que;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    que.push(a.at(i));
    ans += a.at(i);
  }
  int k=m,x;
  long long count=0;
  while(k>0){
    count += (que.top() +1)/2;
    x = que.top()/2 ;
    que.push(x);
    que.pop();
    k--;
  }
  
  cout << ans - count << endl;
  
  return 0;
}


Measured memory_bytes: 1276
#include <iostream>

using namespace std;

typedef long long LL;

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

int main() {
  LL A, B;
  LL C, D;
  cin >> A >> B >> C >> D;

  LL lcd = C * D / gcd(C, D);
  LL perblock = lcd - (lcd / C + lcd / D - 1);
  LL count = (B / lcd - (A + lcd - 1) / lcd) * perblock;

  LL start = A, end = (A + lcd - 1) / lcd * lcd;
  if (start <= end)
    count += (end - start + 1) - ((end/C-(start-1)/C) + (end/D-(start-1)/D));

  start = B / lcd * lcd + 1; end = B;
  if (start <= end)
    count += (end - start + 1) - ((end/C-(start-1)/C) + (end/D-(start-1)/D));

  cout << count + 1 << endl;
  return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

ll n,m,T,k,d;
const ll big = 1000000007;

const int lim = 20;

vi A;
vi A2;
bool before = 0;

int B[200001][lim] = {0};

bool test(int i){
    if(i == 1){
        for(int c1 = 1; c1 < n; c1++){
            if(A[c1] <= A[c1-1])return 0;
        }
        return 1;

    }

    if(sz(A2) == 0)return 1;
    for(int c1 = 0; c1 < A2[0]; c1++){
        B[0][c1] = 0;
        if(c1 == A2[0]-1 && before)B[0][c1] = 1;
    }

    for(int c1 = 1; c1 < sz(A2); c1++){
        if(A2[c1] <= A2[c1-1]){
            ll diff = -1;
            for(int c2 = A2[c1]-1; c2 >= 0; c2--){
                if(B[c1-1][c2] != i-1){
                    diff = c2;
                    break;
                }
            }
            if(diff == -1)return 0;
            for(int c2 = 0; c2 < A2[c1]; c2++){
                if(c2 < diff){
                    B[c1][c2] = B[c1-1][c2];
                }
                if(c2 == diff){
                    B[c1][c2] = B[c1-1][c2]+1;
                }
                if(c2 > diff){
                    B[c1][c2] = 0;
                }
            }
        }
        else{
            for(int c2 = 0; c2 < A2[c1]; c2++){
                if(c2 < A2[c1-1]){
                    B[c1][c2] = B[c1-1][c2];
                }
                else{
                    B[c1][c2] = 0;
                }
            }

        }
    }
    return 1;
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,e;
    cin >> n;
   // n = 200000;
    for(int c1 = 0; c1 < n; c1++){
        cin >> a;
       // a = rand()+1;
        A.push_back(a);
        if(a < lim)A2.push_back(a);



    }

    if(sz(A2) == 0){

        if(test(1)){
            cout << "1\n";
        }
        else{
            cout << "2\n";
        }
        return 0;
    }

    before = 0;
    if(A[0] >= lim)before = 1;

    ll l = 0;
    ll r = sz(A2);

    while(l < r-1){
        ll mid = (l+r)/2;
        if(test(mid)){
            r = mid;
        }
        else{
            l = mid;
        }
    }

    cout << r <<"\n";

    return 0;
}


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

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

using namespace std;

int main(){
  string s;
  cin >> s;
  if(s.size()==3){
    cout << s[2] << s[1] << s[0] << endl;
  }else{
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
n, x = map(int,input().split())
assert n >= 2
if x == 1 or x == 2 * n - 1:
    print('No')
else:
    a = [ x - 1, x, x + 1 ]
    b = list(range(1, x - 1)) + list(range(x + 2, 2 * n))
    c = b[n - 2 :] + a + b[: n - 2]
    print('Yes')
    print(*c, sep='\n')


Measured memory_bytes: 18492
N = int(input())
A = [[int(_) for _ in input().split()] for i in range(N)]

def calc(N, A):
    r = 0
    if N == 1:
        return 0
    if N == 2:
        return A[0][1]
    for i in range(0, N):
        for j in range(i + 1, N):
            a = A[i][j]
            d = min(A[i][k] + A[k][j] for k in range(0, N) if k != i and k != j)
            if a > d:
                return -1
            if a < d:
                r += a
    return r

print(calc(N, A))


Measured memory_bytes: 44764