akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
using namespace std;
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  string s,t;
  ll count = 0;
  IN1(s);
  IN1(t);
  if (t.size() == (s.size() + 1)){
    FOR(i,s.size()){
      if(s[i]==t[i]){
        count++;
      }
    }
    if (count == s.size()){
      OUT("Yes");
    }
    else
    {
      OUT("No");
    }
    
  }
  else
  {
    OUT("No");
  }
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define sz size
#define re return
#define gl getline
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,a,b) for(int i=a;i<=b;i++)
#define all(a) (a).begin(),(a).end()
#define inf 1<<30
char weather[3]; 
int main(){
	ios::sync_with_stdio(false),cin.tie(0);
	int ans[3]={0,0,0};
	int use=0;
	for(int i=0;i<3;i++){
		cin>>weather[i];
		if(weather[i]=='R')ans[use]++;
		else if(weather[i]=='S')use++;
	}
	int ans2=0;
	for(int i=0;i<3;i++)if(ans[i]>ans2)ans2=ans[i];
	cout<<ans2<<endl;
	return 0;
} 

Measured memory_bytes: 3664
#include <iostream>
#include <string>
typedef long long ll;
using namespace std;

int d[60];

int main()
{
	int n, i, j, total = 0;
	cin >> n;
	for(i = 1; i <= n; i++) {
		cin >> d[i];
	}
	for(i = 1; i <= n; i++) {
		for(j = i + 1; j <= n; j++) {
			total += d[i] * d[j];
		}
	}
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

struct Node
{
    int parent;
    int left;
    int right;

    Node() : parent(-1), left(-1), right(-1) {}
};

void preorder(const vector<Node>& T, int id)
{
    if (id == -1)
        return;

    cout << ' ' << id;
    preorder(T, T[id].left);
    preorder(T, T[id].right);
}

void inorder(const vector<Node>& T, int id)
{
    if (id == -1)
        return;

    inorder(T, T[id].left);
    cout << ' ' << id;
    inorder(T, T[id].right);
}

void postorder(const vector<Node>& T, int id)
{
    if (id == -1)
        return;

    postorder(T, T[id].left);
    postorder(T, T[id].right);
    cout << ' ' << id;
}

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

    vector<Node> T(n);
    for (int i = 0; i < n; ++i) {
        int id;
        cin >> id;
        cin >> T[id].left >> T[id].right;

        if (T[id].left != -1)
            T[T[id].left].parent = id;
        if (T[id].right != -1)
            T[T[id].right].parent = id;
    }

    int root = -1;
    for (int i = 0; i < n; ++i) {
        if (T[i].parent == -1) {
            root = i;
            break;
        }
    }

    cout << "Preorder\n";
    preorder(T, root);

    cout << "\nInorder\n";
    inorder(T, root);

    cout << "\nPostorder\n";
    postorder(T, root);
    cout << '\n';
}



Measured memory_bytes: 3100
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL << 60;    // 1.15x10^18
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using edge = pair<int, long long>;
using Graph = vector<vector<edge>>;

vector<long long> dijkstra(const Graph &g, int s) {
    int n = g.size();
    vector<long long> dist(n, INF);
    vector<bool> fixed(n);
    dist[s] = 0;
    while (true) {
        int u = -1;
        for (int i = 0; i < n; i++) if (!fixed[i]) {
            if (u == -1 || dist[i] < dist[u]) u = i;
        }
        if (u == -1) break;
        fixed[u] = true;
        for (auto &e: g[u]) chmin(dist[e.first], dist[u] + e.second);
    }
    return dist;
}

int main() {
    int V; cin >> V;
    Graph g(V);
    for (int i = 0; i < V; i++) {
        int u, k; cin >> u >> k;
        while (k--) {
            int v, c; cin >> v >> c;
            g[u].emplace_back(v, c);
        }
    }
    auto dist = dijkstra(g, 0);
    for (int u = 0; u < V; u++) cout << u << " " << dist[u] << endl;
    return 0;
}


Measured memory_bytes: 11440
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct { int parent, left, right;} Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left)  + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  int deg = 0;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  if(T[u].left  != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  
  if(T[u].parent == NIL) {
    printf("root\n");
  } else if(T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main(void) {
  int i, v, l, r, root = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].parent = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left  = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }
  
  for(i=0; i<n; i++)
  if(T[i].parent == NIL) root = i;
  
  setDepth(root,0);
  setHeight(root);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}

/*
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1
*/


Measured memory_bytes: 2108
n, D = map(int, input().split())
x = list(map(int, input().split()))
Q = int(input())
q = list(map(int, input().split()))

ind = [D]
for i in range(n):
	ind.append(min(ind[-1], abs(ind[-1] - x[i])))

l = [1]
for i in range(n-1, -1, -1):
	if x[i] < 2*l[-1]:
		l.append(x[i] + l[-1])
	else:
		l.append(l[-1])
l = l[::-1]

for i in range(Q):
	if l[q[i]] <= ind[q[i]-1]:
		print("YES")
	else:
		print("NO")

Measured memory_bytes: 136048
#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	S = list(input())
	if S.count("A") == 3 or S.count("B") == 3:
		print("No")
	else:
		print("Yes")



if __name__ == '__main__':
	main()

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

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;

    public void go() throws IOException
    {
        ntok();
        int n = ipar();
        int m = ipar();
        PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
        ntok();
        for (int i = 0; i < n; i++)
        {
            pq.add(ipar());
        }
        for (int i = 0; i < m; i++)
        {
            int min = pq.remove();
            min /= 2;
            pq.add(min);
        }
        long sum = 0;
        while (!pq.isEmpty())
        {
            sum += pq.remove();
        }
        out.println(sum);

        out.flush();
        in.close();
    }

    public void ntok() throws IOException
    {
        tok = new StringTokenizer(in.readLine());
    }

    public int ipar()
    {
        return Integer.parseInt(tok.nextToken());
    }

    public int[] iapar(int n)
    {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = ipar();
        }
        return arr;
    }

    public long lpar()
    {
        return Long.parseLong(tok.nextToken());
    }

    public long[] lapar(int n)
    {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = lpar();
        }
        return arr;
    }

    public double dpar()
    {
        return Double.parseDouble(tok.nextToken());
    }

    public String spar()
    {
        return tok.nextToken();
    }

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


Measured memory_bytes: 45652
#include<iostream>
using namespace std;
int main()
{
  int n, p;
  while(1){
    cin >> n >> p;
    if(n==0 && p==0){
      break;
    }else{
      int c[50] = {};
      int i = 0, b = p;
      while(1){
        if(p){
          c[i]++;
          p--;
        }else{
          p += c[i];
          c[i] = 0;
        }
        if(c[i]==b){
          cout << i << endl;
          break;
        }
        i++;
        if(i>n-1)
        i=0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3068
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
tab = [a, b, c]
tab += [[a[0], b[0], c[0]]]
tab += [[a[1], b[1], c[1]]]
tab += [[a[2], b[2], c[2]]]
tab += [[a[0], b[1], c[2]]]
tab += [[a[2], b[1], c[0]]]

n = int(input())
p = []
for _ in range(n):
  x = int(input())
  p.append(x)

for v in tab:  
  x = 0
  for i in v:
    if i in p:
      x += 1
  if x == 3:
    print('Yes')
    exit()
print('No')





Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 

int isprime(int n)
{
    for(int i=2;i<=sqrt(n);++i)
    {
        if(n%i==0) return 0;
    }
    return 1;
}

lli count=0;

lli counts(lli n)
{
    if(n>1) return 2*counts(n/2)+1;
    if(n==1) return 1;
}

int main()
{
    fastio();
    lli n; cin>>n;
    cout<<counts(n);    
    return 0;
}

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


#define int long long


#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;

typedef vector<vint>mat;

mat mul(mat A,mat B){
    mat C(A.size(),vint(B[0].size()));

    for(int i=0;i<A.size();i++){
        for(int j=0;j<B[0].size();j++){
            for(int k=0;k<A[0].size();k++){
                C[i][j]=(C[i][j]+A[i][k]*B[k][j])%mod;
            }
        }
    }

    return C;
}

mat matpow(mat A,int k){
    mat B(A.size(),vint(A.size()));
    for(int i=0;i<A.size();i++)B[i][i]=1;
    while(k){
        if(k&1)B=mul(B,A);
        A=mul(A,A);
        k>>=1;
    }
    return B;
}

int F(int n){
    mat A(2,vint(2));
    A[0][0]=1;A[0][1]=1;
    A[1][0]=1;A[1][1]=0;

    mat X(2,vint(1));
    X[0][0]=1;X[1][0]=0;

    X=mul(matpow(A,n),X);
    return X[0][0];
}

signed main(){
    /*
    for(int i=2;i<=20;i++){
        for(int j=1;i-j>=1;j++){
            cout<<F(j)*F(i-j)<<" ";
        }cout<<endl;
    }*/

    int K;
    cin>>K;
    int lb=0,ub=1000000000;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(mid*(mid+1)<K)lb=mid;
        else ub=mid;
    }

    K-=lb*(lb+1);

    int s=ub*2;

    if(K>ub){
        K-=ub;
        s++;
    }


    int t=s/2;
    int w;
    if(K<=(t+1)/2){
        w=K*2-1;
    }
    else{
        K=t-K+1;
        w=K*2;
    }
    cout<<F(w)*F(s-w)%mod<<endl;

    return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    //lol result{0};
    lol a, b, k; cin >> k >> a >> b;
    //lol k; cin >> k;
    /*
    vector<lol> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    */
   bool fl = false;
   FOR(i, a, b)
   {
        if(i%k == 0)
        {
            fl = true;
            break;
        }
   }
   if(fl)
   {
       cout << "OK" << endl;
   }
   else
   {
       cout << "NG" << endl;
   }
    

    //cout << result << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

#define MAX 12800

signed main() {
    int h, w;
    cin >> h >> w;
    int a[h][w], b[h][w];
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
        }
    }
    rep(i, h) {
        rep(j, w) {
            cin >> b[i][j];
        }
    }
    bool dp[h + 1][w + 1][MAX + 1];
    dp[0][1][0] = true;
    dp[1][0][0] = true;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k <= MAX; k++) {
                int d = abs(a[i][j] - b[i][j]);
                dp[i + 1][j + 1][k] |= dp[i + 1][j][abs(k - d)];
                dp[i + 1][j + 1][k] |= dp[i][j + 1][abs(k - d)];
                if (k + d > MAX) continue;
                dp[i + 1][j + 1][k] |= dp[i + 1][j][k + d];
                dp[i + 1][j + 1][k] |= dp[i][j + 1][k + d];
            }
        }
    }
    int ans = INF;
    for (int i = 0; i <= MAX; i++) {
        if (dp[h][w][i]) ans = min(ans, i);
    }
    cout << ans << endl;
    return 0;
}

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

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

	cout << (t/a)*b << endl;

	return 0;	
}

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

namespace AtCoderBeg20190427
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var A = read[0];
            var B = read[1];
            var T = read[2];

            var count = T / A;
            Console.WriteLine(count * B);
        }
    }
}


Measured memory_bytes: 13268
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-17 07:20:26
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  assert(n & 1);
  vector<int> a(n); cin >> a;

  map<int, int> mp;
  for (int x : a) ++mp[x];

  debug(mp);

  int ans = mp.size();

  debug(ans);

  int even = 0;

  for (auto x : mp) {
    if (x.second % 2 == 0) ++even;
  }

  if (even & 1) --ans;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5376
using System.Collections.Generic;
using System.Linq;
using System;

public class C
{
    public const int INF = 999999999;
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var r = new int[n, n];
            var minc = new int[n];
            for (int i = 0; i < n; i++)
            {
                minc[i] = C.INF;
                for (int j = 0; j < n; j++) r[i, j] = C.INF;
            }
            var m = int.Parse(Console.ReadLine().Trim());
            for (int i = 0; i < m; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(',');
                var a = int.Parse(line[0]);
                var b = int.Parse(line[1]);
                var d = int.Parse(line[2]) / 100;
                r[a, b] = d; r[b, a] = d;
            }
            goPrim(r, minc, 0);
            Console.WriteLine(minc.Sum() - n + 1);
        }
    }
    public static void goPrim(int[,] r, int[] minc, int targ)
    {
        var n = r.GetLength(0);
        var xL = new List<int>();
        xL.Add(targ);  minc[targ] = 0;
        var count = 0;
        while (count++ < n)
        {
            for (int i = 0; i < n; i++)
                if (!xL.Contains(i) && r[targ, i] != C.INF && r[targ, i] < minc[i]) minc[i] = r[targ, i];
            var mint = C.INF; var minb = -1;
            for (int i = 0; i < n; i++)
                if (!xL.Contains(i) && minc[i] < mint) {  mint =  minc[i] ; minb = i; }
            xL.Add(minb);
            targ = minb;
        }
    }
}

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

#define ll   long long

int main() {

    ll N;
    cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);

    for(ll i=0; i<A.size(); i++){
        cin >> A[i];
    }
    for(ll i=0; i<B.size(); i++){
        cin >> B[i];
    }

    ll sum = 0;
    for(ll i=0; i<N; i++){
        if(A[i] >= B[i]){
            sum+=B[i];
        }else{
            B[i]-=A[i];
            sum+=A[i];
            if(A[i+1] >= B[i]){
                A[i+1]-=B[i];
                sum+=B[i];
            }else{
                sum+=A[i+1];
                A[i+1] = 0;
            }
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    string s;
    cin >> s;
    int k;
    cin >> k;
    set<string> se;
    rep(i, s.size())
    {
        repi(j, i, s.size())
        {
            if (j - i >= k)
            {
                break;
            }
            string t = s.substr(i, j - i + 1);
            se.insert(t);
        }
    }
    auto ite = se.begin();
    rep(i, k - 1)
    {
        ite++;
    }
    cout << *ite << endl;
    return 0;
}

Measured memory_bytes: 1664
lis = list(map(int, input().split()))
lis2 = input().split()
n = lis[0]
k = lis[1]
d = {}

for i in range(n):
    if lis2[i] not in d.keys():
       d[lis2[i]] = 1
    else:
        d[lis2[i]] += 1 
        
if len(list(d.values())) <= k:
    print(0)
else:
    a = list(d.values())
    a.sort()
    a.reverse()
    swap = 0
    for i in range(k,len(a)):
        swap += a[i]
    print(swap)

Measured memory_bytes: 35616
#include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  string s;
  cin>>s;
  ll k;
  cin>>k;
  ll n=s.size();
  set<string> h;
  rep(i,n){
    ll l=min(n-i,k);
    for(int j=1;j<=l;j++){
      string f=s.substr(i,j);
      h.insert(f);
    }
  }
  auto iu=h.begin();
  rep(i,k-1) iu++;
  COUT(*iu);
}
    
               


Measured memory_bytes: 1664
n=int(input())
ans=0
xway=[]
xsay=[]
for i in range(n):
  t1,t2=map(int,input().split())
  xway.append(t1+t2)
  xsay.append(t1-t2)
xway.sort()
xsay.sort()
ans=max(ans,xway[-1]-xway[0])
ans=max(ans,xsay[-1]-xsay[0])
print(ans)

Measured memory_bytes: 25844
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int x=sc.nextInt();
				int y=sc.nextInt();
				int s=sc.nextInt();
				if(x==0 && y==0 && s==0) break;
				int max=0;
				for(int i=1; i<1000; i++) {
					for(int j=1; j<1000; j++) {
						//System.out.println(Math.floor((i*(100+x)/100+j*(100+x)/100)));
						if(Math.floor((i*(100+x)/100+j*(100+x)/100))==s) {
							max=Math.max((int)Math.floor((i*(100+y)/100+j*(100+y)/100)), max);
						}
					}
				}
				System.out.println(max);
			}
			
		}
	}
}


Measured memory_bytes: 29168
N = int(input())
A = [int(x) for x in input().split()]
while len(A) > 1:
  A.sort()
  _A = [A[0]]
  for a in A[1:]:
    a %= A[0]
    if a:
      _A.append(a)
  A = _A
print(A[0])


Measured memory_bytes: 14252
program reversing_and_concatenating
  implicit none
  integer :: n, k, i, j
  character(5000) :: s = "", o = ""
  character(10000) :: u = ""
  read(*,*) n, k
  read(*,*) s
  do i = 1, k
    o = s(1:n)
    u = s(1:n)
    call reverse(s(1:n))
    u = u(1:n)//s(1:n)
    do j = 1, n+1
      s = min(s(1:n),u(j:j+n-1))
    end do
    if (i < k) call reverse(s(1:n))
    if (o == s) then
      write(*,'(a)') s(1:n)
      stop
    end if
  end do
  write(*,'(a)') s(1:n)
contains
  subroutine reverse(s)
    character(*), intent(inout) :: s
    character(1) :: t
    integer :: n, i
    n = len(s)
    do i = 1, n/2
      t = s(n-i+1:n-i+1)
      s(n-i+1:n-i+1) = s(i:i)
      s(i:i) = t
    end do
  end
end program reversing_and_concatenating

Measured memory_bytes: 500
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s,t;
  cin >> s >> t;
  sort(rng(s));
  sort(rng(t));
  reverse(rng(t));
  if(s<t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n, q = map(int, input().split())
S = list(input())

lr = []
for _ in range(q):
    l, r = map(int, input().split())
    lr.append([l, r])

t = [0] * (n+1)
for i in range(n-1):
    if S[i] == "A" and S[i+1] == "C":
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

for temp in lr:
    l, r = temp
    print(t[r-1] - t[l-1])

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

	long long p,n,x,a,b,ans;

long long min(long long a,long long b)
{
	return(a<b?a:b);
}
int main()
{ios::sync_with_stdio(false);
	cin>>n>>a>>b;
	cin>>p;
	for(int i=2;i<=n;i++)
	{
		cin>>x;
		ans+=min(a*(x-p),b);
		p=x;
	}
	cout<<ans;
}

Measured memory_bytes: 256
n = int(input())
l = [int(input()) for i in range(n)]
ans = sum(l)
if ans % 10 != 0:
  print(ans)
else:
  l.sort()
  for i in l:
    if i % 10 != 0:
      print(ans-i)
      exit()
  print(0)

Measured memory_bytes: 2940
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const N = BigInt(input[0].split(" ")[0]);
    const K = BigInt(input[0].split(" ")[1]);
    if(N%K == 0){
        console.log(0)
        return
    } 

    let tmp = N % K
    if(Number(tmp) < Math.abs(Number(K-tmp))) console.log(Number(tmp))
    else console.log(Math.abs(Number(K-tmp)))

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 30108
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("F:/cpp/input.txt", "r", stdin);
    //freopen("F:/cpp/output.txt", "w", stdout);
    //#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll a[n], i, dp[n] = {0};
    for (i=0;i<n;i++)
    {
        cin >> a[i];
    }
    dp[n-1] = 0;
    dp[n-2] = abs(a[n-1] - a[n-2]);
    for (i=n-3;i>=0;i--)
    {
        dp[i] = min(abs(a[i] - a[i+1]) + dp[i+1], abs(a[i] - a[i+2]) + dp[i+2]);
    }
    cout << dp[0];
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
	int n , i , a[26] , r;
	while(1){
		scanf("%d" , &n);
		if(n==0) break;
		for(i=0;i<n;i++) scanf("%d" , &a[i]);
		r = 32;
		for(i=0;;i++){
			r -= (r-1) % 5;
			printf("%d\n" , r);
			r -= a[i%n];
			if(r<0) r=0;
			printf("%d\n" , r);
			if(r==0) break;
		}
	}	
	return 0;
}

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

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

    int r = n % 1000;
    if (r == 0) cout << 0 << endl;
    else cout << 1000 - r << endl;

    return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;
const lli e3 = 1 << 12;

lli n,m;
lli graph[e3][e3];
lli dp[e3][e3];
lli visit[e3];
lli split[e3];
lli s[2][e3];
lli ans = INT_MAX;

void error(){
  cerr << "error" << endl;
  cout << -1 << endl;
  exit(0);
}

void dfs(lli x,lli b,lli idx){
  if(visit[x]){
    if(split[x] != b) error();
    return;
  }
  visit[x] = 1;
  split[x] = b;
  s[b][idx]++;
  for(lli y = 1;y <= n;y++){
    if(y == x) continue;
    if(graph[x][y] == 0) dfs(y,b ? 0 : 1,idx);
  }
  return;
}



int main(){
  cin >> n >> m;
  for(lli i = 0;i < m;i++){
    lli a,b;
    cin >> a >> b;
    graph[a][b] = graph[b][a] = 1;
  }
  for(lli i = 1;i <= n;i++){
    if(!visit[i]){
      dfs(i, 0, i);
    }
  }
  dp[0][0] = 1;
  for(lli i = 0;i < n;i++){
    for(lli j = 0;j <= n;j++){
      dp[i+1][j+s[0][i+1]] = dp[i+1][j+s[0][i+1]] || dp[i][j];
      dp[i+1][j+s[1][i+1]] = dp[i+1][j+s[1][i+1]] || dp[i][j];
    }
  }
  for(lli i = 0;i <= n;i++){
    if(dp[n][i]){
      ans = min(ans,(i*(i-1)+(n-i)*(n-i-1)));
    }
  }
  cout << ans/2 << endl;
}


Measured memory_bytes: 47872
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    int n=0;
    cin>>a;
    cin>>b;
    cin>>c;
    for(int i=a;i<=b;++i){
        if(c%i==0) n=1+n;
    }
    cout<<n;
    cout<<endl;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	int m,d,ans=0;
	cin>>m>>d;
	for(int i=1;i<=m;i++)
		for(int j=10;j<=d;j++)
		{
			int v=j/10,f=j%10;
			if(v*f==i&&v>1&&f>1)
				{
				ans++;
				}
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  DPpractice
//
//  Created by abhishek kumar on 20/04/20.
//  Copyright © 2020 abhishek kumar. All rights reserved.
//

#include <iostream>
#include<vector>
using namespace std;
typedef long long int ll;
const long long int N=1000;
const int INF=1e9 + 5;
ll n,m,arr[N+1][N+1],dp[N+1][N+1],visited[N+1][N+1];


int main(int argc, const char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    vector<int> h(n);
    for(auto& it : h) cin>>it;
    vector<int> dp(n,INF);
    dp[0]=0;
    ll k=2;
    for(auto i=0;i<n;i++)
    {
        for(auto j=i+1;j<=i+k;j++)
            dp[j]= min(dp[j],dp[i] + abs(h[j]-h[i]));
    }
    cout<<dp[n-1];
  
    return 0;
        
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    string s,t;
    cin >> s >> t;
    cout << t << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int main() {

	int INF = 10000000;

	int n;
	scanf("%d", &n);

	vector<pair<int, int>> G[n];
	for (int i = 0; i < n; ++i) {
		int from;
		scanf("%d", &from);

		int v;
		scanf("%d", &v);

		for (int j = 0; j < v; ++j) {
			int to;
			int w;
			scanf("%d %d", &to, &w);
			G[from].push_back(make_pair(to, w));
		}
	}

	int C[n];
	for (int i = 0; i < n; ++i)
		C[i] = INF;

	int color[n];
	int WHITE = 0;
	int BLACK = 1;
	for (int i = 0; i < n; ++i)
		color[i] = WHITE;

	priority_queue<pair<int, int>> PQ;
	PQ.push(make_pair(0, 0));
	C[0] = 0;
	while (!PQ.empty()) {
		int u = PQ.top().second;
		PQ.pop();
		color[u] = BLACK;
		for (int i = 0; i < (int) G[u].size(); ++i) {
			auto c = G[u][i];
			if (color[c.first] != BLACK && c.second + C[u] < C[c.first]) {
				C[c.first] = c.second + C[u];
				PQ.push(make_pair(C[c.first] * -1, c.first));
			}
		}
	}

	for (int i = 0; i < n; ++i) {
		cout << i << " " << C[i] << endl;
	}

	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int n;
  cin >> s;
  n = s.size();
  set<int> st;
  int current = 0;
  int ans = 0;
  rep(i,n){
    if(s[i] == 'R'){
      current++;
      current %= 4;
      st.insert(current);
    }else{
      current += 4;
      current--;
      current %= 4;
    }

    if(current == 0){
      if(st.size() == 4){
        ans ++;
        // cout << i << "," << st.size() << endl;
      }
      st.clear();
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3240
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    int a, b, c, d, e, f;
    private ArrayList<Integer> listW, listS;

    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        d = sc.nextInt();
        e = sc.nextInt();
        f = sc.nextInt();
        listW = new ArrayList<>();
        listS = new ArrayList<>();
    }

    private double calc(int a, int b) {
        return (double) (100 * b) / (a + b);
    }

    private void solve() {
        for (int i = 0; i < f; i++) {
            for (int j = 0; j < f; j++) {
                int w = a * i + b * j;
                w *= 100;
                if (w != 0 && w < f) {
                    listW.add(w);
                }
            }
        }
        for (int i = 0; i < f; i++) {
            for (int j = 0; j < f; j++) {
                int s = c * i + d * j;
                if (s < f)
                    listS.add(s);
            }
        }
        double rate = -1.;
        int ansS = -1, ansW = -1;
        for (int w: listW) {
            for (int s : listS) {
                if (w + s <= f && s <= (w / 100) * e) {
                    double tmp = calc(w, s);
                    if (rate < tmp) {
                        ansS = s;
                        ansW = w;
                        rate = tmp;
                    }
                }
            }
        }
        System.out.printf("%d %d\n", (ansS + ansW), ansS);
    }


}


Measured memory_bytes: 27856
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
ll mod=1e9+7;

int main(){
    int n,l;cin>>n>>l;
    vector<int> v(n);
    int mi=100000; bool pos=1;
    for(int i=0;i<n;i++){
        v[i]=i+l;
        if(abs(v[i])<mi){
            mi=abs(v[i]);
            if(v[i]>0)pos=1;
            else if(v[i]<0)pos=0;
        }
    }
   if(pos) cout<<accumulate(v.begin(),v.end(),0)-mi;
   else cout<<accumulate(v.begin(),v.end(),0)+mi;
    
}

Measured memory_bytes: 256
S = gets.chomp
A = ['dream', 'dreamer', 'erase', 'eraser']
sss = S

# str=任意長の文字列
# output=dream, dreamer, erase, eraser の誰か
def hoge(str)
  if str[0..5] == A[3]
    return 5+1
  elsif str[0..4] == A[2]
    return 4+1
  elsif str[0..6] == A[1] && str[7] != 'a'
    return 6+1
  elsif str[0..4] == A[0]
    return 4+1
  else
    return 0
  end
end

while hoge(sss) > 0
  sss = sss[hoge(sss)..-1]
end

if sss.empty?
  print 'YES'
else
  print 'NO'
end


Measured memory_bytes: 2812
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
  for j in range(b+1):
    lest = x - i*500 - j*100
    if lest >= 0 and lest % 50 == 0 and lest // 50 <= c:
      ans += 1
      
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main ()
{
    char s[102];
    int i;
    scanf("%s", s);
    for (i=0; i<strlen(s); i++) {
        if (i % 2){
            if ((s[i] != 'L') && (s[i] != 'U') &&(s[i] != 'D')) {
                printf("No\n");
                return 0;
            }
        }
        else {
            if ((s[i] != 'R') && (s[i] != 'U') &&(s[i] != 'D')) {
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<lint>> a(n, vector<lint>(n));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> a[i][j];
        }
    }
    lint ret = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            lint mini = inf;
            for (int k = 0; k < n; ++k) {
                if (k == i || k == j)
                    continue;
                chmin(mini, a[i][k] + a[k][j]);
            }
            if (mini < a[i][j]) {
                cout << -1 << "\n";
                return 0;
            } else if (mini > a[i][j])
                ret += a[i][j];
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    if((A1 + A2 + A3) >= 22) {
        cout << "bust";
    }
    else {
        cout << "win";
    }

    
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll a,b,c; cin >> a >> b >> c;
  
  if((10*b+c) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
n,d = map(int,input().split())
p = [[int(i) for i in input().split()] for y in range(n)]

def how_far(a,b):
  x = 0
  for s in range(0,d):
    x += (a[s] - b[s]) ** 2
  x = x ** (1/2)
  return x
count = 0
for i in range(n-1):
  for j in range(i+1,n):
    kyori = how_far(p[i],p[j])
    true_kyori = int(kyori)
    if kyori == true_kyori:
      count += 1
      
print(count)
      


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

int main(){
  int P,Q,R; cin >>P >>Q >>R;

  int t1,t2,t3;
  t1 = P+Q;
  t2 = Q+R;
  t3 = R+P;

  cout << min(t1,min(t2,t3)) << endl;
}


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


int main() {

    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 1; i < n; ++i) {
        int cnt = 0;
        for (char c = 'a'; c <= 'z'; ++c) {
            bool left = false, right = false;
            for (int j = 0; j < i; ++j) {
                if (s[j] == c) left = true;
            }
            for (int k = i; k < n; ++k) {
                if (s[k] == c) right = true;
            }
            if (left && right) ++cnt;
        }
        if (ans < cnt) ans = cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  if (n / 100 == 7 || n / 10 % 10 == 7 || n % 10 == 7) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 1620
'use strict'
function Main(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  var N=input.shift(), M=input.shift();
  var p=input.splice(0,N);
  var nodes=[];
  for(let k=0;k<N;k++)
    nodes[k]=new Node(k);
  for(let k=0;k<M;k++)
    nodes[input[2*k]-1].merge(nodes[input[2*k+1]-1]);
  var counter=0;
  for(let k=0;k<N;k++)
    if(nodes[k].top()===nodes[p[k]-1].top())
      counter++;
  console.log(counter);
}

function Node(v){
  var t=this;
  t.value=v;
  t.parent=null;
  t.weight=1;
}

Node.prototype.top=function(){
  var t=this;
  var p=t.parent;
  if(!p)return t;
  else return p.top();  
}

Node.prototype.adopt=function(progeny){
  var t=this.top();
  var c=progeny.top();
  c.parent=t;
  t.weight+=c.weight;
}

Node.prototype.merge=function(b){
  var a=this.top();
  b=b.top();
  if(a===b)return;
  if(a.weight<b.weight)b.adopt(a);
  else a.adopt(b);
}

Main(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 62312
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var AB = ReadLine().Split().Select(int.Parse).ToArray();
        var A = AB[0];
        var B = AB[1];
        WriteLine(A<B?0:10);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
int main(){
    std::string a,b;
    int i = 0;
    for(std::cin>>a,b=a,reverse(a.begin(),a.end()); i<a.size(); ++i)
    	a[i] = (a[i]=='b')?'d':((a[i]=='d')?'b':(a[i]=='p')?'q':'p');
    puts(a==b?"Yes":"No");
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,a[100005],dp[1005][2];
int main()
{
	cin>>n;
	dp[0][0]=1;
	for (i=1;i<=n;i++) cin>>a[i];
	for (i=1;i<=n;i++)
	{
		if (a[i]%2==0)
		{
			dp[i][0]=dp[i-1][0]*2;
			dp[i][1]=dp[i-1][1]*3+dp[i-1][0]*1;
		}
		else
		{
			dp[i][0]=dp[i-1][0]*1;
			dp[i][1]=dp[i-1][1]*3+dp[i-1][0]*2;
		}
	}
	cout<<dp[n][1];
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key)
{
    int left = 0;
    int right = n;
    int mid;
    while( left < right)
    {
        mid = (left + right) / 2;
        if ( key == A[mid]) return 1;
        if ( key > A[mid]) left = mid + 1;
        else if ( key < A[mid]) right = mid;
    }
    return 0;
}

int main()
{
    int i, q, k, sum = 0;

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

    scanf("%d", &q);

    for (i = 0; i < q; i++)
    {
        scanf("%d", &k);
        if ( binarySearch(k))
        {
            sum++;
        }
    }
    printf("%d\n", sum);

    return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<vector>
#include<cctype>
using namespace std;
typedef long long ll;
 
const ll mod = 1000000007;
string t;
vector<int> table;
 
ll parse(int l,int r){
  //cout << t.substr(l,r-l) << endl;
  vector<ll> v;
  for(int i=l;i<r;i++){
    if(t[i] == 'S'){
      int k = 1, pos = i+2;
      while(pos<r){
	if(t[pos] == 'S')k++;
	if(t[pos] == '>' && !table[pos])k--;
	if(!k){
	  ll tmp = parse(i+2,pos);
	  v.push_back(tmp*tmp%mod);
	  i = pos;
	  break;
	}
	pos++;
      }
      i = pos;
    }else if(isdigit(t[i])){
      ll tmp = 0;
      while(isdigit(t[i]))tmp = tmp*10 + t[i]-'0', i++;
      v.push_back(tmp);
      i--;
    }
  }
 
  //for(int i=0;i<v.size();i++)cout << v[i] << " "; cout << endl;
  ll res = v[0];
  for(int i=1;i<v.size();i++)res >>= min(63ll,v[i]);
  return res;
}
 
int main(){
  string s;
  while(getline(cin,s),s!="#"){
    t = "";
    for(int i=0;i<s.size();i++){
      if(s[i]!=' ')t+=s[i];
    }
    table.resize(t.size());
    for(int i=0;i<t.size();i++)table[i] = 0;
    for(int i=0;i<t.size();i++){
      if(i!=0 && isdigit(t[i])){
	if(t[i-1]=='>')table[i-1] = table[i-2] = 1;
      }
      if(i!=0 && t[i] == 'S'){
	if(t[i-1]=='>')table[i-1] = table[i-2] = 1;
      }
    }
 
    cout << parse(0,t.size()) << endl;
  }
}

Measured memory_bytes: 6080
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad         (replicateM)
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)
import           GHC.Exts              (sortWith)

main :: IO ()
main = print =<< solve <$> getInput

getInput :: IO (Int, Int, [(Int, Int)])
getInput = do
  [n, h] <- readInts
  abs <- replicateM n readInt2
  return (n, h, abs)

readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

readInt2 = do
  [a, b] <- readInts
  return (a, b)

solve (n, h, abs) = nAttack + mAttack
  where maxA = maximum $ map fst abs
        (nAttack, restHP) = throwAttack maxA (map snd abs) h
        mAttack = swingAttack maxA restHP

throwAttack :: Int -> [Int] -> Int -> (Int, Int)
throwAttack a bs h = if null powerfulBs
  then (0, h)
  else if null rest
       then (length throwns, h - last throwns)
       else (length throwns + 1, h - head rest)
  where powerfulBs = filter (> a) bs
        (throwns, rest) = span (< h) . scanl1 (+) $ sortWith (* (-1)) powerfulBs

swingAttack a h
  | h <= 0   = 0
  | otherwise = h `div` a + if h `mod` a == 0 then 0 else 1
      --ceiling $ fromIntegral h / fromIntegral a


Measured memory_bytes: 45564
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            li = l[i]
            lj = l[j]
            lk = l[k]
            if li == lj or lj == lk or lk == li:
                continue
            else:
                s = max(li, lj, lk)
                if li+lj+lk > 2*s:
                    ans += 1
print(ans)



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

int main() {
    
    string s; cin >> s;
    int ans = 0;
    if (s[0] == '1') ans++;
    if (s[1] == '1') ans++;
    if (s[2] == '1') ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600