akhauriyash/Code-Regression huggingface dataset:
#include	<bits/stdc++.h>
using	namespace	std;
typedef	long long ll;

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define K18 1000000000000000000

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N;
	cin >>N;
	ll A=1;
	vector<ll> AAA(N, 0);
	bool Z=false;
	Rep0(i, N) {
		cin >>AAA.at(i);
		if (0==AAA.at(i))
			Z=true;
	}
	if (Z) {
		cout <<0 <<endl;
		return 0;
	}
	for (ll AA: AAA) {
		if (K18/AA<A) {
			cout <<-1 <<endl;
			return 0;
		}
		A*=AA;
		if (A>1000000000000000000) {
			cout <<-1 <<endl;
			return 0;
		}
		if (A<0) {
			cout <<-1 <<endl;
			return 0;
		}
	}
	cout <<A <<endl;
	return 0;
}



Measured memory_bytes: 4020
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
#define INF 1000000
#define all(x) (x).begin(), (x).end()

vector<int> dp;
vector<int> h;

int dfs(int i){
    if(i == 0){
        return 0;
    }
    int ans;
    if(dp.at(i) != -1){
        ans = dp.at(i);
    }else if(i - 2 < 0){
        ans = dfs(i - 1) + abs(h.at(i) - h.at(i - 1));
        dp.at(i) = ans;
    }else{
        ans = min(dfs(i - 1) + abs(h.at(i) - h.at(i - 1)), dfs(i - 2) + abs(h.at(i) - h.at(i - 2)));
        dp.at(i) = ans;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    h = vector<int>(n);
    rep(i, n){
        cin >> h.at(i);
    }
    dp = vector<int>(n, -1);
    cout << dfs(n - 1) << endl;
}


Measured memory_bytes: 6384
#include <cstdio>
#define MAXN 100007
#include <cstring>

char mayRed[MAXN];
int numOfBall[MAXN];

int main(void)
{
    mayRed[1]=1;
    int i,N,M;
    int x,y;
    scanf("%d%d",&N,&M);
    for(i=1;i<=N;i++)
    {
        numOfBall[i]=1;
        mayRed[i]=0;
    }
    mayRed[1]=1;

    for(i = 0;i<M;i++)
    {
        scanf("%d%d",&x,&y);
        if(mayRed[x])
        {
            mayRed[y]=1;
        }
        numOfBall[y]+=1;
        numOfBall[x]-=1;
        if(numOfBall[x]==0)
        {
            mayRed[x]=0;
        }
    }
    int r = 0;
    for(i=1;i<=N;i++)
    {
        r+=mayRed[i];
    }
    printf("%d\n",r);

    return 0;
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int h,w;
  cin >> h >> w;
  vector<vector<char>> x(h, vector<char>(w));
  vector<vector<char>> y(w, vector<char>(h));
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      char tmp;
      cin >> tmp;
      x.at(i).at(j) = tmp;
      y.at(j).at(i) = tmp;
    }
  }
  string X="";
  string Y="";
  for(int i= 0; i < h; i++){
    X+=".";
  }
  for(int j= 0; j < w; j++){
    Y+=".";
  }

  map<int,bool> mx,my;
  for(int i = 0; i < h; i++){
    string tmp = "";
    for(int j = 0; j < w; j++){
      tmp += x.at(i).at(j);
    }
    if(tmp == Y){
      mx[i] = true;
    }
  }
  for(int j = 0; j < w; j++){
    string tmp = "";
    for(int i = 0; i < h; i++){
      tmp += y.at(j).at(i);
    }
    if(tmp == X){
      my[j] = true;
    }
  }

  for(int i = 0; i < h; i++){
    if(mx.count(i) != 0) continue;
    for(int j = 0; j < w; j++){
      if(my.count(j) != 0) continue;
      cout << x.at(i).at(j);
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_9_D
{
    class Program
    {
        static IEnumerable<string> ReadLines()
        {
            while (true)
            {
                yield return Console.ReadLine();
            }
        }


        static IEnumerable<string[]> ReadSplitWords(IEnumerable<string> strings, char splitChar)
        {
            foreach (var n in strings)
            {
                yield return n.Split(splitChar);
            }                
        }


        static void Print(char[] str, int startIndex, int endIndex)
        {
            for (var i = startIndex; i <= endIndex; ++i)
            {
                Console.Write(str[i]);
            }
            Console.WriteLine();
        }


        static void Reverse(char[] str, int startIndex, int endIndex)
        {
            for (var i = 0; i < (endIndex + 1 - startIndex) / 2; ++i)
            {
                var index = startIndex + i;
                var inverse = endIndex - i;

                var temp = str[index];
                str[index] = str[inverse];
                str[inverse] = temp;
            }
        }


        static void Replace(char[] str, int startIndex, int endIndex, string add)
        {
            for (var i = startIndex; i <= endIndex; ++i)
            {
                str[i] = add[i - startIndex];
            }
        }


        static bool IsValidArgment(int strLength, int startIndex, int endIndex)
        {
            if (startIndex < 0 || strLength <= startIndex) return false;
            if (endIndex < 0 || strLength <= endIndex) return false;
            if (endIndex < startIndex) return false;
            return true;
        }


        static void Main(string[] args)
        {
            var word = Console.ReadLine().ToCharArray();
            var count = int.Parse(Console.ReadLine());

            foreach (var n in ReadSplitWords(ReadLines(), ' ').Take(count))
            {
                var arg1 = int.Parse(n[1]);
                var arg2 = int.Parse(n[2]);
                var arg3 = n.Length < 4 ? null : n[3];

                if (IsValidArgment(word.Length, arg1, arg2) == false)
                {
                    continue;
                }

                switch (n[0]) 
                {
                    case "print": Print(word, arg1, arg2); break;
                    case "reverse": Reverse(word, arg1, arg2); break;
                    case "replace": Replace(word, arg1, arg2, arg3); break;
                }

            }
            
        }
    }
}

Measured memory_bytes: 5744
from heapq import heappush,heappop
INF=10**20

def dijkstra(G, start = 0):
    d = [INF for i in range(len(G))]
    d[start] = 0
    prev = [0 for i in range(len(G))]
    
    que = []
    heappush(que, (0, start))

    while len(que) != 0:
        p = heappop(que)
        v = p[1]
        
        if d[v] < p[0]:
            continue
            
        for u in G[v].keys():
            if d[u] > d[v] + G[v][u]:
                d[u] = d[v] + G[v][u]
                prev[u] = v
                heappush(que, (d[u], u))
    
    return d,prev

N,M=map(int,input().split())
G=[{} for _ in range(N+1)]

edgelist=[]
for i in range(M):
  a,b,c=map(int,input().split())
  G[a][b]=G[b][a]=c
  a,b=sorted([a,b])
  edgelist.append((a,b))
edgelist = set(edgelist)
  
shortest_edges=set()
for i in range(1,N+1):
  d,prev = dijkstra(G,i)
  for j in range(1,N+1):
    if j ==i:continue
    a,b = sorted([j,prev[j]])
    shortest_edges.add((a,b))
    
diff = edgelist.difference(shortest_edges)
print(len(diff))

Measured memory_bytes: 9372
import sys
input = sys.stdin.readline

n, d = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(n)]

cnt = 0
for i in range(n):
    if xy[i][0]**2 + xy[i][1]**2 <= d**2:
        cnt += 1

print(cnt)

Measured memory_bytes: 45460
// Last Change: 10/24/2019 19:19:59.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

void setFoot(string ipt, int foot[2]) {
  int i = 0, j = 0;
  if (ipt[0] == 'r') {
    i = 1;
  }
  if (ipt[1] == 'u') {
    j = 1;
  }
  foot[i] = j;
  // cout << foot[0] << foot[1];
}

bool isChanged(bool &state, int foot[]) {
  if (foot[0] == foot[1]) {
    // cout << state << ' ' << foot[0] << ' ';
    if (state != foot[0]) {
      state = foot[0];
      //  cout << "@";
      return 1;
    }
  }
  return 0;
}

void solve(ll n) {
  bool state = false;
  int foot[2] = {0};
  ll score = 0;
  for (ll i = 0; i < n; ++i) {
    string ipt;
    cin >> ipt;
    setFoot(ipt, foot);
    score += isChanged(state, foot);
    // cout << endl;
  }
  cout << score << endl;
}

int main() {
  ll n;
  while (cin >> n and n > 0) {
    solve(n);
  }
}



Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  vector<vector<int>> a(n+1);
  for(int i = 2; i <= n; i++){
    int x; cin >> x;
    a[x].push_back(i);
  }

  vector<int> dp(n+1, 1);
  function< void(int) > dfs =
  [&](int u){
    vector<int> vec;
    for(int v : a[u]){
      dfs(v);
      vec.push_back(dp[v]);
    }
    sort(vec.rbegin(),vec.rend());
    for(int i = 0; i < vec.size(); i++){
      dp[u] = max(dp[u], vec[i] + i+1);
    }
    return;
  };
  dfs(1);
  cout << dp[1]-1 << endl;

  return 0;
}


Measured memory_bytes: 17408
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int x[n], l[n];
    for (int i = 0; i < n; i++) cin >> x[i] >> l[i];
    vector<pair<int, int> > v;
    for (int i = 0; i < n; i++) v.push_back({x[i]-l[i], x[i]+l[i]});
    sort(v.begin(), v.end());
    int ans = n, e = v[0].second;
    for (int i = 1; i < n; i++) {
        // cerr << v[i].first << ' ' << v[i].second << ' ' << e << endl;
        if (e <= v[i].first) e = v[i].second;
        else { ans--; e = min(e, v[i].second); }
    }
    cout << ans << endl;
}


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

using namespace std;

pair<int, int> point[4][100005];
int cr[4], c, r, n, x, y, z, t;

bool check(int x,int y)
{
    if(x == 0 || y == 0 || x == r || y == c)
        return true;
    return false;
}

void func(int x,int y,int indx)
{
    if(y == 0)
        point[0][cr[0]++] = make_pair(x, indx);
    else if(x == r)
        point[1][cr[1]++] = make_pair(y, indx);
    else if(y == c)
        point[2][cr[2]++] = make_pair(x, indx);
    else if(x == 0)
        point[3][cr[3]++] = make_pair(y, indx);
}

bool cmp1(pair<int,int> a, pair<int,int> b)
{
    return a.first < b.first;
}

bool cmp2(pair<int,int> a, pair<int,int> b)
{
    return a.first > b.first;
}

int main() {
	cin >> r >> c >> n;
	for(int i = 1; i <= n; i++) {
		cin >> x >> y >> z >> t;
		if(check(x, y) && check(z, t)) {
			func(x, y, i);
			func(z, t, i);
		}
	}
	sort(point[0], point[0] + cr[0], cmp1);
	sort(point[1], point[1] + cr[1], cmp1);
	sort(point[2], point[2] + cr[2], cmp2);
	sort(point[3], point[3] + cr[3], cmp2);
	stack<int> S;
	for(int i = 0; i < 4; i++) {
		for(int j = 0; j < cr[i]; j++) {
			if(S.empty()) {
				S.push(point[i][j].second);
			}
			else {
				if(S.top() == point[i][j].second) S.pop();
				else S.push(point[i][j].second);
			}
		}
	}
	if(!S.empty()) cout << "NO";
	else cout << "YES";
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
char c[8][8];
void dfs(int x,int y){
	c[y][x]='0';
	for(int i=x+1;i<=min(7,x+3);i++){
		if(c[y][i]=='1'){
			dfs(i,y);
		}
	}
	for(int i=x-1;i>=max(0,x-3);i--){
		if(c[y][i]=='1'){
			dfs(i,y);
		}
	}
	for(int i=y+1;i<=min(7,y+3);i++){
		if(c[i][x]=='1'){
			dfs(x,i);
		}
	}
	for(int i=y-1;i>=max(0,y-3);i--){
		if(c[i][x]=='1'){
			dfs(x,i);
		}
	}
}
int main(){
	int n;cin>>n;
	int d=1;
	while(n--){
		for(int i=0;i<8;i++){
			cin>>c[i];
		}
		int sx,sy;
		cin>>sx>>sy;sx--;sy--;
		dfs(sx,sy);
		cout<<"Data "<<d<<":"<<endl;
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				cout<<c[i][j];
			}
			cout<<endl;
		}
		d++;
	}
}



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

int main(){
    int a, b, cnt = 0;
    cin >> a >> b;
    
    repa(i, a, b+1){
        string tmp, tmp_rev;
        tmp += to_string(i);
        tmp_rev += to_string(i);
        reverse(tmp_rev.begin(), tmp_rev.end());
        if(tmp == tmp_rev) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a,a+n,greater<int>());
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(i%2 == 0) ans += a[i];
    else ans -= a[i];
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
m,d =map(int,input().split())
cnt =0
for i in range(10,d+1):
    d10 = int(str(i)[0])
    d1 = int(str(i)[1])
    
    if d10 >= 2 and d1 >= 2:
        if d10 * d1 <= m:
            cnt = cnt +1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
    int n;ll k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i=0;i<n;i++){
        cin >> a.at(i);
    }
    vector<int> s;
    vector<int> ord(n+1,-1);
    int c = 1; 
    int l=0;
    {
        int v = 1;
        while(ord[v]== -1){
            ord[v] = s.size();
            s.push_back(v);
            v = a[v-1];
        }
        c = s.size() -ord[v];
        l = ord[v];
    }
    if(k < l) 
        cout << s[k] << endl;
    else {
        k -= l;
        k %= c;
        cout << s[l+k] << endl;
    }
    return 0;
}

Measured memory_bytes: 5832
<?php
$input=trim(fgets(STDIN));
$array_data=explode(" ", $input);
$a=$array_data[0];
$b=$array_data[1];
$c=$array_data[2];
$array_result=array();
for($i=$a;$i<=$b;$i++){
	if($c % $i ==0){
		$array_result[]=$i;
	}
}
printf("%d\n",count($array_result));

Measured memory_bytes: 15464
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func Matrix(h, w, a, b int) [][]int {
	// Slice of Slice
	dary := make([][]int, h)
	for i := range dary {
		dary[i] = make([]int, w)
	}

	for i := 0; i < h; i++ {
		for j := 0; j < a; j++ {
			if i < b {
				dary[i][j] = 0
			} else {
				dary[i][j] = 1
			}
		}
		for j := a; j < w; j++ {
			if i < b {
				dary[i][j] = 1
			} else {
				dary[i][j] = 0
			}
		}
	}
	return dary
}

func main() {
	var h, w, a, b int
	fmt.Scan(&h, &w, &a, &b)
	matrix := Matrix(h, w, a, b)
	for _, l := range matrix {
		sl := make([]string, w)
		for _, s := range l {
			sl = append(sl, strconv.Itoa(s))
		}
		fmt.Println(strings.Join(sl, ""))
	}
}


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

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

    if (a == b)
    {
        if (a != c)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else if (b == c)
    {
        if (b != a)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else if (c == a)
    {
        if (c != b)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
object Main extends App {
	val hw = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val s = Array.ofDim[Int](hw(0)+2, hw(1)+2)

	var list = List[(Int, Int)]()

	for(i<-1 to hw(0)){
		val temp = scala.io.StdIn.readLine.toArray

		for(j<-0 until hw(1)){
			temp(j) match {
				case '#' => {
					list = (i,j)::list
					s(i-1)(j+0) += 1
					s(i-1)(j+1) += 1
					s(i-1)(j+2) += 1
					s(i+0)(j+0) += 1
					s(i+0)(j+2) += 1
					s(i+1)(j+0) += 1
					s(i+1)(j+1) += 1
					s(i+1)(j+2) += 1
				}
				case _ =>
			}
		}
	}

	for(i<-list){
		s(i._1)(i._2 + 1) = -1
	}

	for(i<-1 to hw(0)){
		for(j<-1 to hw(1)){
			if(s(i)(j) == -1) print("#")
			else print(s(i)(j))
		}
		println(" ")
	}
}

Measured memory_bytes: 25548
/**
*    created: 21.06.2020 00:32:58
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    cout << "2018" << s.substr(4,6) << endl;
    return 0;
}

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

int main() {
  long long x, y;
  cin >> x >> y;

  long long ans = 1;

  while ( 1 ) {
    // cout << x << endl;
    x *= 2;
    if ( y - x < 0 ) break;
    ans++;
  }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vi a(m,0);
	rep(i,n){
		int k;
		cin>>k;
		rep(j,k){
			int t;cin>>t;
			a[t-1]++;
		}
	}
	int ans=0;
	rep(i,m){
		if(a[i]==n)ans++;
	}
	puta(ans);
	return 0;
}

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

#define MOD 1000000007

int n;

void add(int &a, int b) {
    a = (a + b) % MOD;
}

int mul(int a, int b) {
    return (long long) a * b % MOD;
}

struct Matrix {
    int m[50][50];

    Matrix() {
        memset(m, 0, sizeof(m));
    }

    Matrix operator * (Matrix other) const {
        Matrix ret;
        for (int i=0; i<n; i++)
            for (int j=0; j<n; j++)
                for (int k=0; k<n; k++)
                    add(ret.m[i][j], mul(m[i][k], other.m[k][j]));
        return ret;
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long long k;
    Matrix a;
    cin >> n >> k;
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++)
            cin >> a.m[i][j];

    Matrix r;
    for (int i=0; i<n; i++)
        r.m[i][i] = 1;
    while (k > 0) {
        if (k & 1)
            r = r * a;
        a = a * a;
        k >>= 1;
    }

    int ret = 0;
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++)
            add(ret, r.m[i][j]);

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
 
int main() {
  int n,d;
  cin >> n >> d;
  int ans =0;
  vector<vector<double>> data(n,vector<double>(d));
  
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++)
      cin >> data.at(i).at(j);
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      double x = 0;
      for(int k=0;k<d;k++){
        if(i!=j){
          double len = data.at(i).at(k) - data.at(j).at(k);
          len = len*len;
          x += len;
        }
      }
      if(floor(sqrt(x))==sqrt(x) && x!=0)
        ans++;
    }
  }
 cout << ans/2 << endl;
}

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

int main() {
  string s;
  cin >> s;
    
  if (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main()
{
    int n, l;
    cin >> n >>l;

    int a[n] = {100};
    int min =0;
    for(int i=0; i<n; i++){
        a[i] = pow(l+i, 2.0);
        if(a[min] > a[i]){
            min = i;
        }
    }
    int sum = 0;
    for(int i=0; i<n; i++){
        if(i != min){
            sum += l+i;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        e: [(usize, usize); m],
    }
    let mut g = vec![vec![]; n + 1];
    let mut deg = vec![0; n + 1];
    for i in 1..=n {
        g[0].push(i);
        deg[i] += 1;
    }
    for (x, y) in e {
        g[x].push(y);
        deg[y] += 1;
    }
    let mut q = vec![];
    let mut stack = vec![0];
    while let Some(v) = stack.pop() {
        q.push(v);
        for &u in g[v].iter() {
            deg[u] -= 1;
            if deg[u] == 0 {
                stack.push(u);
            }
        }
    }
    let mut dp = vec![0; n + 1];
    for &v in q.iter().rev() {
        let mut d = 0;
        for &u in g[v].iter() {
            d = std::cmp::max(d, dp[u] + 1);
        }
        dp[v] = d;
    }
    let ans = dp[0] - 1;
    println!("{}", ans);
}


Measured memory_bytes: 11396
def main():
    n = int(input())
    x = list(map(int, input().split()))

    ans = 1e9
    for p in range(1, 101):
        tans = 0
        for i in range(0, n):
            tans += (x[i-1] - p) ** 2
        ans = min(ans, tans)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n, k = map(int, input().split())
s, p, r = map(int, input().split()) 
dic = {"p":p, "r":r, "s":s}
t = input()
ans = 0
for i in range(k):
    bef = "a"
    for j in range(i, n, k):

        if bef == t[j]:
            bef = "a"
        else:
            ans += dic[t[j]]
            bef = t[j]
print(ans)

Measured memory_bytes: 9320
N, A, B, C, D = map(int, input().split())
S = input()
for i in range(A-1,max(C,D)-1):
    if S[i] == '#' and S[i+1] == '#':
        print('No')
        exit()
if D < C:
    for i in range(B-2,N-2):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            print('Yes')
            exit()
        if i+1 == D-1:
            break
    print('No')
    exit()
else:
    print('Yes')
    exit()

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int inf = 1e9;
const int maxn = 12;
const int maxm = 1010;

int n, m;
int a[maxm];
int b[maxm];
int dp[2][1<<maxn];

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		int c;
		cin >> a[i] >> c;
		b[i] = 0;
		for (int j = 0; j < c; ++j) {
			int k;
			cin >> k;
			b[i] |= (1 << (k-1));
		}
	}
	for (int msk = 0; msk < (1 << n); ++msk) {
		dp[1][msk] = inf;
	}
	dp[1][0] = 0;
	for (int i = 1; i <= m; ++i) {
		// swap dp[0] and dp[1], set dp[1] to inf
		for (int msk = 0; msk < (1 << n); ++msk) {
			dp[0][msk] = dp[1][msk];
			dp[1][msk] = inf;
		}
		// transitions
		for (int msk = (1 << n)-1; msk >= 0; --msk) {
			dp[1][msk] = min(dp[1][msk], dp[0][msk]);
			dp[1][msk | b[i]] = min(dp[1][msk | b[i]], dp[0][msk] + a[i]);
		}
	}
	if (dp[1][(1 << n)-1] == inf) {
		cout << -1 << endl;
	} else {
		cout << dp[1][(1 << n)-1] << endl;
	}
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int a, b, k;
    cin >> a >> b >> k;
    for(int i = 100; i >= 1; --i)
        if(a % i == 0 && b % i == 0 && !(--k))
            cout << i << endl, exit(0);
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int32_t main()
{
  long long n;cin>>n;
  long long sum=(n*(n+1)/2);
  for(long long i=3;i<=n;i+=3)
  {
    if(i%5!=0)sum-=i;
  }
  for(long long i=5;i<=n;i+=5)
  {
  sum-=i;
  }
  cout<<sum;

           return 0;
}

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

int Item[3005][3005];
ll DP[3005][3005][4];

int main(){
    int R,C,k;cin>>R>>C>>k;
    rep(i,k){
        int r,c,v;
        scanf("%d %d %d",&r,&c,&v);
        r--;c--;
        Item[r][c]=v;
    }
    rep(i,R)rep(j,C){
        for(int k=2;k>=0;k--){
            chmax(DP[i][j][k+1],DP[i][j][k]+Item[i][j]);
        }
        rep(k,4){
            chmax(DP[i+1][j][0],DP[i][j][k]);
            chmax(DP[i][j+1][k],DP[i][j][k]);
        }
    }

    ll ans=0;
    rep(k,4)chmax(ans,DP[R-1][C-1][k]);
    cout<<ans<<endl;
}

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

string S;

signed main() {
    cin>>S;

    int ctn1=0;
    int ctn2=0;
    if(S[0]==S[1] and S[2]==S[3]) {
        if(S[0]==S[2]) {
            cout<<"No";
        }else{
            cout<<"Yes";
        }
    }else if(S[0]==S[2] and S[1]==S[3]) {
        if(S[0]==S[1]) {
            cout<<"No";
        }else{
            cout<<"Yes";
        }
    }else if(S[0]==S[3] and S[1]==S[2]) {
        if(S[0]==S[1]) {
            cout<<"No";
        }else{
            cout<<"Yes";
        }
    
    }else{
        cout<<"No";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	ll n;
	cin>>n;
	ll a[n+1];
	for(int i=1;i<=n;i++)cin>>a[i];
	ll sum=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			sum+=(a[i]*a[j]);
		}
	}cout<<sum<<endl;return 0;
}/*『你强归你强，我永不示弱』*/




Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int a;
	int  b,c,d,e;
	long long int g=0;
	scanf ("%d",&a);
	for(int i = 1;i<=a;i++){
		if (i%5==0&&i%3==0) {
			d++;
		} else if (i%3==0) {
			c++;
		}
		else if (i%5==0) {
			e++;
		} else g+=i;
	}
	printf ("%lld",g);
	return 0;
}

Measured memory_bytes: 1732
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		int[] cs=new int[c+1];
		for(int i=0;i<c+1;i++){
			cs[i]=0;
		}
		for(int i=0;i<r;i++){
			int rs=0;
			for(int j=0;j<c;j++){
				int a=sc.nextInt();
				rs+=a;
				cs[j]+=a;
				System.out.print(a+" ");
			}
			System.out.println(rs);
			cs[c]+=rs;
		}
		for(int i=0;i<c;i++){
			System.out.print(cs[i]+" ");
		}
		System.out.println(cs[c]);
	}
}

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

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

  int n, k;
  cin >> n >> k;
  unordered_set<int> d;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    d.insert(a);
  }

  int i = n;
  while (true) {
    int m = i;
    bool flag = false;
    while (m) {
      if (d.find(m % 10) != d.end()) {
        flag = true;
        break;
      }
      m /= 10;
    }
    if (flag) {i++; continue;}
    cout << i << '\n';
    return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int C = 3010;
bool dp1[C], dp2[C];
int a, b, c, d, e, f;
int P, Q;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	cin >> a >> b >> c >> d >> e >> f;
	dp1[0] = 1;
	dp2[0] = 1;
	for (int x = 0; x < C; x++) {
		if (dp1[x]) {
			if (x + a < C)
				dp1[x + a] = 1;
			if (x + b < C)
				dp1[x + b] = 1;
		}
		if (dp2[x]) {
			if (x + c < C)
				dp2[x + c] = 1;
			if (x + d < C)
				dp2[x + d] = 1;
		}
	}

	P = 0;
	Q = a;
	for (int x = 1; x <= f / 100; x++) {
		if (!dp1[x]) continue;
		for (int y = 0; 100 * x + y <= f; y++) {
			if (y > x * e) break;
			if (!dp2[y]) continue;
			if (y * Q > x * P) {
				P = y;
				Q = x;
			}
		}
	}
	cout << P + 100 * Q << " " << P << endl;


	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		sc.nextLine();
		int first=0;
		int last=n-1;
		int medium=(first+last+1)/2;
		System.out.println(0);
		String fS=sc.next();
		if(fS.startsWith("V")) {
			return;
		}
		while(true) {
			System.out.println(medium);
			String s=sc.next();
			if(s.startsWith("V")) {
				return;
			}
			else if((s.startsWith(fS)&&(medium-first)%2==1)||
					 ((!s.startsWith(fS))&&(medium-first)%2==0)){
				last=medium;
			}
			else {
				first=medium;
				fS=s;
			}
			medium=(first+last+1)/2;
		}
		
	}
	}


Measured memory_bytes: 24484
n = gets.to_i
h = gets.split.map(&:to_i)
a = Array.new(n + 1, 0)
a[0] = 0
a[1] = 0
h.unshift(h[0])
2.upto(n) do |i|
  a[i] = [(h[i] - h[i - 1]).abs + a[i - 1], (h[i] - h[i - 2]).abs + a[i - 2]].min
end
puts a[n]

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

int main() {
  int N;
  cin>>N;
  
  int X;
  X=N%1000;
  
  if (N%1110<10 || X%111==0 || N%1000==0){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

char mp[100][100];

int main(){
	int h, w, k; cin >> h >> w >> k;
	for( int i = 0; i < h; ++i ){
		for( int j = 0; j < w; ++j ){
			cin >> mp[i][j];
		}
	}
	int ans = 0;
	for( int r = 0; r < (1<<w); ++r ){
		for( int c = 0; c < (1<<h); ++c ){
			int cnt = 0;
			for( int i = 0; i < h; ++i ){
				for( int j = 0; j < w; ++j ){
					if( mp[i][j] == '#' and !((1<<i) bitand c) and !((1<<j) bitand r) ){
						++cnt;
					} 
				}
			}
			if( cnt == k ) ++ans;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
map<int,int>a;
vector<int>q;
int n,ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        if(!a[x])q.push_back(x);
        a[x]++;
	}
	int top=q.size();
	for(int i=0;i<top;i++){
        if(a[q[i]]>=q[i])ans+=a[q[i]]-q[i];
        else ans+=a[q[i]];
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 5112
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;

// // A
// int main(){
//     int A1, A2, A3;
//     cin >> A1 >> A2 >> A3;
//     vector<int> data={A1, A2, A3};
//     sort(data.begin(), data.end());
//     int B;
//     B = (data[1]-data[0]) + (data[2]-data[1]);
//     cout << B <<endl;
//     return 0;
// }


// B
int main(){
    string str1, str2;

    cin >> str1 >> str2;

    int N = str1.length();

    char c1[N], c2[N];
    str1.copy(c1, N);
    int k = 1;

    char tmp;
    if (str1 == str2){
        k = 1;
        cout << "Yes" <<endl;
    }
    else{
        for (int i=0; i<N-1; i++){

            tmp = c1[N-1];
            for (int j=N; j>0;){
                c1[j] = c1[j-1];
                j = j-1;}
            c1[0] = tmp;

            std::string str(c1, N);
            if (str == str2){
                cout << "Yes" <<endl;
                k = 0;}
        }

    if (k==1){
        cout << "No" <<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
# A - DDCC Finals
x,y = map(int, input().split())
X = 0
Y = 0


if x == 3:
    X = 100000
elif x == 2:
    X = 200000
elif x == 1:
    X = 300000
else :
    X = 0

if y == 3:
    Y = 100000
elif y == 2:
    Y = 200000
elif y == 1:
    Y = 300000
else:
    Y = 0

if x == 1 and y == 1:
    print(X+Y+400000)
else:
    print(X +Y)

Measured memory_bytes: 38644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
  ll ansa = 0, ansb = 0;
  double dim = 0.0;
  for (ll i=0; i <= f/(100*a); i++) {
    for (ll j=0; j <= (f-(100*a*i))/(100*b); j++) {
      if (i==0 && j==0) continue;
      for (ll k=0; k <= (f-(100*a*i)-(100*b*j))/c; k++) {
        for (ll l=0; l <= (f-(100*a*i)-(100*b*j)-c*k)/d; l++){
          if ((a*i+b*j)*e < c*k + d*l) break;
          if (100 * (c*k+d*l) / (double)(100*a*i+100*b*j+c*k+d*l) > dim) {
            dim = 100 * (c*k+d*l) / (double)(100*a*i+100*b*j+c*k+d*l);
            ansa = 100*a*i+100*b*j+c*k+d*l;
            ansb = c*k+d*l;
          }
        }
      }
    }
  }
  if (ansb == 0) cout << min(a, b)*100 << ' ' << ansb << endl;
  else cout << ansa << ' ' << ansb << endl;
  return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())

# 2進数のn桁目の0からxまでの和が偶数か奇数かを返す
def even_odd(x, n):
    if n == 1:
        if x % 4 == 1 or x % 4 == 2:
            return 1
        else:
            return 0

    num = (x % (2 ** n)) - 2 ** (n - 1)
    if num < 0:
        return 0
    elif num % 2 == 0:
        return 1
    else:
        return 0

# 10 ** 12 => 2 ** 40
s = 0
for i in range(1, 41):
    if (even_odd(B, i) + even_odd(A-1, i)) % 2 == 1:
        s += 2 ** (i - 1)
print(s)

Measured memory_bytes: 3064
#include <cstdio>
#include <assert.h>

typedef long long LL;

const int MAXM = 1e5, MOD = 1e9 + 7;
int n, m;

inline int add ( int a, const int b ) { return ( a += b ) < MOD ? a : a - MOD; }
inline int mul ( LL a, const int b ) { return ( a *= b ) < MOD ? a : a % MOD; }

inline int rint () {
	int x = 0; char s = getchar ();
	for ( ; s < '0' || '9' < s; s = getchar () );
	for ( ; '0' <= s && s <= '9'; s = getchar () ) x = x * 10 + ( s ^ '0' );
	return x;
}

struct Matrix {
	int n, m, mat[3][3];
	Matrix (): n ( 0 ), m ( 0 ), mat {} {}
	Matrix ( const int tn, const int tm ): n ( tn ), m ( tm ), mat {} {}
	inline int* operator [] ( const int key ) { return mat[key]; }
	inline Matrix operator * ( Matrix t ) {
		assert ( m == t.n );
		Matrix ret ( n, t.m );
		for ( int i = 0; i < n; ++ i ) {
			for ( int k = 0; k < m; ++ k ) {
				for ( int j = 0; j < t.m; ++ j ) {
					ret[i][j] = add ( ret[i][j], mul ( mat[i][k], t[k][j] ) );
				}
			}
		}
		return ret;
	}
};

inline Matrix qkpow ( Matrix a, int b ) {
	Matrix ret ( a.n, a.m );
	for ( int i = 0; i < ret.n; ++ i ) ret[i][i] = 1;
	for ( ; b; a = a * a, b >>= 1 ) if ( b & 1 ) ret = ret * a;
	return ret;
}

Matrix I ( 3, 1 ), A ( 3, 3 ), B ( 3, 3 );

inline void init () {
	I[0][0] = 1;
	A[0][0] = 1;
	A[1][0] = 2, A[1][1] = 1;
	A[2][0] = A[2][1] = A[2][2] = 1;
	B = A, ++ B[0][0], ++ B[0][1], ++ B[0][2];
}

int main () {
	init ();
	n = rint (), m = rint ();
	int las = 0;
	for ( int i = 1, x; i <= m; ++ i ) {
		x = rint ();
		I = A * qkpow ( B, x - las - 1 ) * I;
		las = x;
	}
	
	I = A * qkpow ( B, n - las - 1 ) * I;
	printf ( "%d\n", I[2][0] );
	return 0;
}

Measured memory_bytes: 3204
#include<stdio.h>
int main(void)
{
	int a,b,c;
	1<=a,b,c<=10;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a==7&&b==5&&c==5||a==5&&b==7&&c==5||a==5&&b==5&&c==7)	{
		printf("YES\n");
	}
	else	{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  for (;;) {
    auto rd = readln.split.map!(to!int), m = rd[0], f = rd[1], r = rd[2];
    if (m == -1 && f == -1 && r == -1) break;

    if (m == -1 || f == -1)
      writeln("F");
    else if (m + f >= 80)
      writeln("A");
    else if (m + f >= 65 && m + f < 80)
      writeln("B");
    else if (m + f >= 50 && m + f < 65)
      writeln("C");
    else if (m + f >= 30 && m + f < 50) {
      if (r >= 50)
        writeln("C");
      else
        writeln("D");
    }
    else
      writeln("F");
  }
}

Measured memory_bytes: 2452
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+8+7;
ll n,m,l;
string s,t;
int d[100],dp[100][100];

int main(){
  vector<ll> vec;
  cin >> n >> m;
  vec.pb(n);
  while(1){
    if(vec[vec.sz-1]*2 <= m){
      vec.pb(vec[vec.sz-1]*2);
    }else{
      break;
    }
  }
  print(vec.sz);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <algorithm>

int main(){
  // read problem
  long long int N, tmp_a, tmp_b, tmp_c;
  std::vector<std::vector<long long int> > activity_list(3);
  
  scanf("%lld", &N);
  for(long long int i = 0; i < N; i++){
    scanf("%lld%lld%lld", &tmp_a, &tmp_b, &tmp_c);
    activity_list[0].push_back(tmp_a);
    activity_list[1].push_back(tmp_b);
    activity_list[2].push_back(tmp_c);
  }
  
  std::vector<std::vector<long long int> > max_happiness(3);
  max_happiness[0].push_back(0);
  max_happiness[1].push_back(0);
  max_happiness[2].push_back(0);
  
  for(long long int i = 0; i < N; i++){
    max_happiness[0].push_back(std::max(max_happiness[1][i], max_happiness[2][i]) + activity_list[0][i]);
    max_happiness[1].push_back(std::max(max_happiness[0][i], max_happiness[2][i]) + activity_list[1][i]);
    max_happiness[2].push_back(std::max(max_happiness[0][i], max_happiness[1][i]) + activity_list[2][i]);
  }
  
  std::cerr << "Answer:" << std::endl;
  std::cout << std::max(max_happiness[0][N], std::max(max_happiness[1][N], max_happiness[2][N])) << std::endl;
  
  return 0;
}


Measured memory_bytes: 5728
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	n, k := nextInt(), nextInt()
	h := nextInts(n)

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

	fmt.Println(dp[n-1])

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}
func max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


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

const int NEUTRAL = 0;
const int ASCENDING = -1;
const int DESCENDING = 1;

int main(){
  int N, numbers[100005];
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> numbers[i];
  }
  
  int flag = NEUTRAL;
  int ans = 1;
  for(int i=0; i<N-1; i++){
    if((flag == ASCENDING && numbers[i] > numbers[i+1]) || 
       (flag == DESCENDING && numbers[i] < numbers[i+1])) {
          ans++;
          flag = NEUTRAL;
       }
    else if(numbers[i] < numbers[i+1]) flag = ASCENDING;
    else if(numbers[i] > numbers[i+1]) flag = DESCENDING;
  }
  
  cout << ans << endl;
  
  return 0;
} 

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

int main(void) {
    std::string S, T;

    std::cin >> S >> T;

    int ret = 10000;
    for(int i = 0; i <= S.size()-T.size(); ++i){
        std::string substr = S.substr(i, T.size());
        int temp = 0;
        for(int j = 0; j < T.size(); ++j){
            if(substr[j] != T[j]) ++temp;
        }
        
        ret = std::min(ret, temp);
    }

    std::cout << ret << std::endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

vi adj[100001];
deque<int> ans;
bool visited[100001];

void dfs(int u, bool mode)
{
	if(!visited[u])
	{
		visited[u]=1;
		if(mode) ans.pb(u);
		else ans.push_front(u);
	}
	for(int i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i];
		if(!visited[v])
		{
			dfs(v,mode);
			return ;
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int u, v; cin>>u>>v; u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}
	for(int i=0;i<n;i++)
	{
		if(adj[i].size()>=1)
		{
			dfs(i,1);
			dfs(i,0);
			cout<<ans.size()<<'\n';
			for(int i=0;i<ans.size();i++)
			{
				cout<<ans[i]+1;
				if(i+1<ans.size()) cout<<' ';
			}
			cout<<'\n';
			return 0;
		}
	}
}


Measured memory_bytes: 6784
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll
 
int cnt[100];
signed main(void)
{
	int n, m;
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		cnt[a-1]++;
		cnt[b-1]++;
	}
 
	REP(i, n) {
		cout << cnt[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in a:
    ct=0
    big=10**5
    while i%2==0:
        i=i/2
        ct+=1
    big=min(ct,big)
    ans.append(big)
b=sorted(ans)
print(b[0])

Measured memory_bytes: 9152