akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int n,l;
           cin>>n>>l;
           vst s(n);
           rep(i,0,n)cin>>s[i];
           sort(all(s));
           rep(i,0,n)cout<<s[i];
           cout<<endl;
           
}

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

namespace CSharpSample01
{
   
    class Program
    {
        
        static void Main(string[] args)
        {
            var c = new int[3, 3];
            for(int i = 0; i < 3; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                for(int j = 0; j < 3; j++)
                {
                    c[i, j] = int.Parse(str[j]);
                }
            }

            int[] a = new int[3];
            int[] b = new int[3];

            a[0] = 0;

            //a[0]の設定により1行目のbが求まる
            for(int j = 0; j < 3; j++)
            {
                b[j] = c[0, j] - a[0];
            }

            //求めたb[0]で1列目の残りのaが求まる
            for(int i = 1; i < 3; i++)
            {
                a[i] = c[i, 0] - b[0];
            }

            //確認作業
            for(int i = 1; i < 3; i++)
            {
                for(int j = 1; j < 3; j++)
                {
                    if(a[i] + b[j] != c[i, j])
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }

            Console.WriteLine("Yes");

        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ll n,k;cin>>n>>k;
    ll a[n],f[n];
    rep(i,0,n)cin>>a[i];
    sort(a,a+n);
    rep(i,0,n)cin>>f[i];
    sort(f,f+n);
    ll u=10000000000000;
    ll d=-1;
    while(u-d>1){
        ll mid=(u+d)/2;
        ll cnt=0;
        rep(i,0,n){
            ll tai=mid/f[n-1-i];
            cnt+=max((ll)0,a[i]-tai);
        }
        if(cnt>k)d=mid;
        else u=mid;
    }
    cout<<u<<endl;
}


Measured memory_bytes: 3328
abk = list(map(int,input().split()))
a=abk[0]
b=abk[1]
k=abk[2]
ans=[]
for i in range(1,101):
    if a%i == 0 and b%i ==0:
        ans.append(i)
ansr=list(reversed(ans))
print(ansr[k-1])


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int r;
  cin >> r;
  cout << 3*r*r << endl;
}


Measured memory_bytes: 256
N = int(input())
spList = [input().split() for _ in range(N)]

ispList = []
for i, sp in enumerate(spList):
    ispList.append((i+1, sp[0], int(sp[1])))

ispList.sort(key=lambda x: (x[1], -x[2]))
for i, isp in enumerate(ispList):
    print(isp[0])


Measured memory_bytes: 3060
//In the name of 'ALLAH'
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
     int n;
     cin>>n;
     int arr[n+1];
     for(int i=0;i<n;i++ )
     {
         cin>>arr[i];
     }
     sort(arr,arr+n);
     int count = 0;
     for(int i=0;i<n;i++)
     {
         for(int j=i+1;j<n;j++)
         {
             for(int k=j+1;k<n;k++)
             {
                 if(arr[i] == arr[j] || arr[j] == arr[k] || arr[i] == arr[k])continue;
                  {
                      if(arr[i] + arr[j]>arr[k])
                      {
                          count++;
                      }
                  }
             }
         }
     }
     cout << count <<endl;
}


Measured memory_bytes: 3636
r,c=map(int,input().split())
m=[]
for i in range(r):
    m.append(list(input()))
dp=[[0 for j in range(c)] for i in range(r)]

dp[0][0]=1
for i in range(0,r):
    for j in range(0,c):
        if m[i][j]=='.':
            dp[i][j]+=(dp[i-1][j]+dp[i][j-1])
        

print((dp[r-1][c-1])%(1000000007))

Measured memory_bytes: 174860
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var line string
	_, _ = fmt.Scan(&line)
	var sum int64
	for _, l := range line {
		tmp, _ := strconv.Atoi(string(l))
		sum += int64(tmp)
	}
	n, _ := strconv.ParseInt(line, 10, 64)
	if n % sum == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    static int[] bit;
    static int n;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        bit = new int[n+1];
        int[] pos = new int[n+1];
        int[] a = new int[n+1];
        for(int i=1;i<=n;i++){
            a[i] = sc.nextInt();
            pos[a[i]] = i;
        }
        int[] left = new int[n+1], right = new int[n+1];
        TreeSet<Integer> ts = new TreeSet<>();
        for(int v=1;v<=n;v++){
            int p = pos[v];
            Integer x = ts.lower(p);
            if(x==null) left[v]=p; // 1-base.
            else left[v] = p-x;
            ts.add(p);
        }
        ts = new TreeSet<>();
        for(int v=1;v<=n;v++){
            int p = pos[v];
            Integer y = ts.higher(p);
            if(y==null) right[v] = n+1-p;
            else right[v] = y-p;
            ts.add(p);
        }
        long ans = 0;
        for(int v=1;v<=n;v++){
            long cur = ((long) v)*((long)left[v])*((long)right[v]);
            ans += cur;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 95480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

ll h[100010];
//vector<ll> adj[100010];
ll ma[100010];
ll hi[100010];

void solve(){

    ll n,m;
    cin >> n >> m;
    rep(i,n){
        cin >> h[i];
    }
    rep(i,n){
        ma[i]=0;
        hi[i]=i;
    }
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        //adj[a].emplace_back(b);
        //adj[b].emplace_back(a);
        ma[a]=max(ma[a],h[b]);
        ma[b]=max(ma[b],h[a]);
    }

    ll ans = 0;
    rep(i,n){
        if(ma[i]<h[i]) ans++;
    }

    cout << ans << endl;

}

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


Measured memory_bytes: 5996
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, k, c;
    string s;
    vector<int> earliest;
    vector<int> latest;
    cin >> n >> k >> c >> s;
    for(int i = 0; i < n; i++) {
        while(s[i] == 'x')
            i+=1;
        earliest.push_back(i);
        i += c;
    }
    for(int i = n-1; i >= 0; i--) {
        while(s[i] == 'x')
            i-=1;
        latest.push_back(i);
        i -= c;
    }
    reverse(latest.begin(), latest.end());
    assert(earliest.size() == latest.size());
    if (earliest.size() == k) {
        for(int i = 0; i < earliest.size(); i++) {
            if (earliest[i] == latest[i])
                cout << latest[i]+1 << endl;
        }
    }
    return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define sd(mark) scanf("%d",&mark)
#define ss(mark) scanf("%s",&mark)
#define slld(mark) scanf("%lld",&mark)
#define clr(mark) memset(mark,0,sizeof(mark))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define sz(x) (int((x).size()))
#define PII pair<int,int>
#define PIL pair<int,long long>
#define PLL pair<long long,long long>
#define PIS pair<int,string>
#define MII map<int,int>
#define LL long long
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
#define FILEIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define INF 2000000000 // 2 * 10^9
#define INFLL 1000000000000000000LL  // 10^18
#define mod 1000000007

#define N 1012345

bool a[10];

void solve()
{
    int n,k,i,d,pw;
    for(i=0;i<10;++i)
        a[i] = 1;
    sd(n);
    sd(k);
    for(i=0;i<k;++i)
    {
        sd(d);
        a[d] = 0;
    }
    pw = 1;
    for(;pw<n;pw*=10);
    for(;n<=pw;++n)
    {
        int tmp = n;
        while(tmp)
        {
            if(!a[tmp%10]) break;
            tmp /= 10;
        }
        if(tmp==0)
        {
            //cout << " here " << endl;
            printf("%d\n",n);
            return;
        }
    }
    int dig = 0;
    while(pw)
    {
        dig++;
        pw/=10;
    }
    //cout << "here!! " << endl;
    if(a[0])
    {
        for(i=1;i<10;++i)
        {
            //cout << " a["<<i<<"]: " <<a[i] << endl;
            if(a[i]) break;
        }
        printf("%d",i);
        dig--;
        while(dig--)
        {
            printf("0");
        }
        printf("\n");
    }
    else
    {
        for(i=1;i<10;++i)
        {
            if(a[i]) break;
        }
        while(dig--)
        {
            printf("%d",i);
        }
        printf("\n");
    }
}

int main()
{
    int t = 1;
    //scanf("%d",&t);
    while(t--)
    {
        solve();
    }
}



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



int main() {
    int n,k;
    cin>>n>>k;
    int h[n+1]={0};
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        for(int j=0;j<d;j++){
            int x;
            cin>>x;
            h[x]++;
        }
    }
    int count=0;
    for(int i=1;i<=n;i++){
        if(h[i]==0)
        count++;
    }
    cout<<count;
	return 0;
}


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

int main() {
	int n;
	string s,t;
	cin >> n >> s >> t;
	for(int i = 0;i < n;i++)
	{
		cout << s.at(i) << t.at(i);
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll x ; cin >> x ;
	for(ll a=0;a<=1000;a++){
		for(ll b=0;b<=1000;b++){
			ll c = a*a*a*a*a ;
			ll d = b*b*b*b*b ;
			if(c-d==x){
				cout << a << " " << b << endl ;
				return 0 ;
			}else if(c+d==x){
				cout << a << " " << -b << endl ;
				return 0 ;
 			}
		}
	}
}


Measured memory_bytes: 3592
#include<stdio.h>
#define N 101

int MAX = (1<<21), n, A[N][N], num[N], d[N], f[N], count, Q[N*2], head, tail;

void init()
{
  head = tail = 1;
}

void enqueue(int x)
{
  Q[tail++] = x;
}

int empty()
{
  return head == tail;
}

int dequeue()
{
  int x = Q[head++];
  return x;
}

void bfs(int s){
  int i, x, y;
  init();
  enqueue(s);
  for ( i = 0; i < n; i++ )d[i] = MAX;
  d[s] = 0;
  while(!empty())
    {
      x = dequeue();
      for ( y = 0; y < n; y++ )
	{
	  if ( A[x][y] == 0 )
	    {
	      continue;
	    }
	  if ( d[y] != MAX )
	    {
	      continue;
	    }
	  d[y] = d[x] + 1;
	  enqueue(y);
	}
    }
  
  for ( i = 0; i < n; i++ )
    {
      printf("%d %d\n", i+1,((d[i]==MAX)?(-1):d[i]));
    }
  
}

int main(){
  int  x, y, z, i, j;

  scanf("%d", &n);

  for ( i = 0; i <n; i++ )
    {
      for ( j = 0; j <n; j++ )
	{
	  A[i][j] = 0;
	}
    }
  
  for ( i = 0; i < n; i++ )
    {
      scanf("%d %d", &x, &z);
   
      for ( j = 0; j < z; j++ )
	{
	  scanf("%d", &y);
     
	  A[x-1][y-1] = 1;
	}
    }
 
  bfs(0);

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N, M, X;
    cin >> N >> M >> X;
    vi C(N);
    vvi A(N, vi(M));
    rep(i, N) {
        cin >> C[i];
        rep(j, M) cin >> A[i][j];
    }

    int res = INF;
    rep(i, 1<<N) {
        int t = i;
        int tc = 0;
        vi temp(M, 0);
        rep(j, N) {
            if(t&1) {
                tc += C[j];
                rep(k, M) {
                    temp[k] += A[j][k];
                }
            }
            t >>= 1;
        }
        int ok = true;
        rep(j, M) {
            if(temp[j]<X) ok = false;
        }
        if(ok) res = min(res, tc);
    }

    if(res!=INF) cout << res << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<ll> a(n,0);
	FOR(i,0,n)cin >> a[i];
	ll q;
	cin >> q;
	FOR(j,0,q){
		ll b,e;
		cin >> b >> e;
		reverse(a.begin()+b,a.begin()+e);
	}
	FOR(i,0,n){
		if(i!=0)cout << " ";
		cout << a[i];
	}
	cout << endl;
}



Measured memory_bytes: 3172
from collections import deque
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
g=[[]for _ in range(n)]

for a,b in ab:
  g[a-1].append(b-1)
  g[b-1].append(a-1)

def bfs(i,j):# iからjへのルートの数が2本以上あるかどうか。
  seen=[[-1]for _ in range(n)]
  seen[i]=[]
  todo=deque([[i]])
  c=0
  while len(todo)>0:
    d=todo.pop()
    l=g[d[-1]]
    for li in l:
      if li in d:
        continue
      if li==j:
        c+=1
        if c>1:
          return True
        continue
      e=d.copy()
      e.append(li)
      todo.append(e)
  return False

ans=0
for a,b in ab:
  ans+= 0 if bfs(a-1,b-1) else 1
print(ans)


Measured memory_bytes: 3316
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
long long int solve(long long int a, long long int b){
	long double c=sqrtl(a*b-1);
	long long int seisuu=c;
	if(a==b){
		return seisuu*2;
	}else if(seisuu*(seisuu+1)>=a*b){
		return seisuu*2-2;
		printf("zensha\n");
	}else{
		return seisuu*2-1;		
		printf("kousha\n");
	}
} 
int main(){
	int q=0;
	long long int query[2][100];
	scanf("%d\n",&q);
	for(int i=0;i<q;i++){
		query[0][i]=0;
		query[1][i]=0;
		scanf("%d %d\n",&query[0][i],&query[1][i]);
	}
	for(int i=0;i<q;i++){
		printf("%lld\n", solve(query[0][i], query[1][i]));
	}
/*	long long int a=101;
	long double b=sqrtl(a);
	long long int c=b;
	printf("%llf\n",b);
	printf("%lld\n",c);*/
}

	

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main()
{

    int n, A[100005];
    int i, j, k, cmp, tmp;
    scanf("%d", &n);

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

    i = 0;

    for (j = 0; j < n - 1; j++)
    {
        if (A[j] <= cmp)
        {
            tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
            i++;
        }

        for (k = 0; k < n; k++)
        {
            // printf("%-5d",A[k]);
        }
        //printf("\n");
    }
    tmp = A[i];
    // printf("値tmp:%d",A[i]);
    A[i] = cmp;
    A[n - 1] = tmp;

    for (k = 0; k < n; k++)
    {
        if (k == i)
            printf("[%d]", A[k]);
        else
            printf("%d", A[k]);
        if (k != n - 1)
            printf(" ");
    }

    printf("\n");

    return 0;
}



Measured memory_bytes: 2112
#include<stdio.h>
int main(){
  int i,a,N;
  scanf("%d",&N);
  int A[N+5];
  for(i=1;i<N+1;i++){
    A[i]=0;
  }
  for(i=0;i<N-1;i++){
    scanf("%d",&a);
    A[a]=A[a]+1;
    }
  for(i=1;i<N+1;i++){
    printf("%d\n",A[i]);
  }
  return 0;
}

Measured memory_bytes: 2508
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;
double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	string s;
	cin>>s;
	cout<<s[0]<<s[1]<<s[2]<<endl;

}

Measured memory_bytes: 3124
n,m=map(int,input().split())
s=list(input())
t=list(input())

def gcd(x,y):
    if x==y:
        return x
    elif x>y:
        r=-1
        while r!=0:
            r=x%y
            x=y
            y=r
        return x
    else:
        r=-1
        while r!=0:
            r=y%x
            y=x
            x=r
        return y

N=n//gcd(n,m)
M=m//gcd(n,m)
f=1
for i in range(gcd(n,m)):
    if s[i*N]!=t[i*M]:
        f=0
if f:
    print(n*m//gcd(n,m))
else:
    print(-1)


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

const ll INF = 1LL << 60;
ll dp[100010];

int main(void){
    int N,K;
    cin >> N >> K;
    vector<int> height(N);
    for(int i=0;i<N;i++) cin >> height[i];

    for(int i=0;i<N;i++) dp[i] = INF;

    dp[0] = 0;
    for(int i=1;i<N;i++){
        for(int j=1;j<=K;j++){
            if(i-j<0) break;
            dp[i] = min(dp[i],dp[i-j]+abs(height[i]-height[i-j]));
        }
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1408
n = int(input())
a = list(map(int,input().split()))

a.sort()

N,K = a[n-1],a[0]

for i in range(1,n):
    if abs((N+1)//2 - K) > abs((N+1)//2 - a[i]):
        K = a[i]

print(N,K)


Measured memory_bytes: 14428
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int n;cin>>n;
	int data[200];
	for(int i=0;i<n;i++) cin>>data[i];
	sort(data,data+n);
	int occ[100]={0},ra[100]={0};
	int a = 1,b=0;
	for(int i=0;i<n;i++){
		if (data[i]==data[i+1]){
			a++;
		}
		else{
			occ[b]=a;
			ra[b]=data[i];
			b++;
			a = 1;
		}
	}
	int ans = 0;
	for(int i=0;i<b;i++){
		for(int j=i+1;j<b;j++){
			for(int k=j+1;k<b;k++){
				if(ra[i]+ra[j]>ra[k]){
					ans += occ[i]*occ[j]*occ[k];
				}
			}
		}
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

ll merge_cnt(vector<ll>& a) {
	int n = a.size();
	if (n <= 1) return 0;
	ll cnt = 0;
	vector<ll> b(a.begin(), a.begin() + n / 2);
	vector<ll> c(a.begin() + n / 2, a.end());
	cnt += merge_cnt(b);
	cnt += merge_cnt(c);
	int ai = 0, bi = 0, ci = 0;
	while (ai < n) {
		if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
			a[ai++] = b[bi++];
		}
		else {
			cnt += n / 2 - bi;
			a[ai++] = c[ci++];
		}
	}
	return cnt;
}


int main() {
	int n, k; cin >> n >> k;
	vector<ll> a(n), b(n+1,0);
	rep(i, 0, n) {
		cin >> a[i];
		a[i] -= k;
	}
	rep(i, 0, n) {
		b[i + 1] = b[i] + a[i];
	}
	ll ans = merge_cnt(b);
	printf("%lld", 1LL * n * (n + 1) / 2 - ans);
	return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
  int a,b;
  cin>>a>>b;
  cout<<(a-1)*(b-1)<<endl;
  return 0;
}


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

def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1


q = partition(A, 0, n-1)

out = [str(a) for a in A]
out[q] = '[' + out[q] + ']'
print(' '.join(out))



Measured memory_bytes: 16588
import java.util.*;

public class Main {

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		long x=0;
		long i=1;
		while(x<n)
		{
			x+=i;
			i++;
		}
		System.out.println(i-1);
	}
}


Measured memory_bytes: 35636
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <math.h>
#include <queue>
#include <stack>

#define N 50

using namespace std;

// ある地点のサイコロのつまれた状態を保持
stack<pair<int,int> > loc[N][N];
// 入力をqueueで保持
queue<pair<int,int> > input;

// サイコロの上面がNだった時の側面の数字dice_tf[N][0~3]で少ないもの順に上から見て左回りで保持
int dice_tf[7][4]={
	{0,0,0,0},
	{2,3,5,4},
	{1,4,6,3},
	{1,2,6,5},
	{1,5,6,2},
	{1,3,6,4},
	{2,4,5,3}
};

// 転がる方向，４方向の値を保持
// 向き	dx	dy	上から見て
// 0	 0	 1	下方向
// 1	 1	 0　右方向
// 2	 0	-1　上方向
// 3	-1	 0	左方向
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

// 現在の高さ地図を表示
void printloc(){
	for(int y=(N/2)-10;y<(N/2)+10;y++){
		for(int x=(N/2)-10;x<(N/2)+10;x++){
			if((loc[y][x].size()-1)!=0) 
				cout << (loc[y][x].size()-1);
			else
				cout << " ";
		}cout << endl;
	}
}

// x,y地点の一番上にあるサイコロが転がるかどうか
// 転がるならばそちらに転がす
void rollandfall(int x,int y){
	int pi;
	int deg=-1;
	int max=-1;
	int num;

	// トップにあるサイコロの上面と前面から，前面が側面の対応テーブルの何番目に当たるのかを選ぶ
	// piにそれを保持
	for(int i=0;i<4;i++){
		if(dice_tf[loc[y][x].top().first][i]==loc[y][x].top().second){
			pi=i;
			break;
		}
	}

	// piから上から左回りに捜査し，転がることができる最大の目の番号と方向0~3を得る
	for(int i=0;i<4;i++){
		num=dice_tf[loc[y][x].top().first][(pi+i)%4];
		if(num>3){
			if((loc[y][x].size()-1)>loc[y+dy[i]][x+dx[i]].size()){
				if(max<num){
					deg=i;
					max=num;
				}
			}
		}
	}

	// maxの値とその向きがわかる．
	// maxが-1ならそれ以上転がりおちることはないので再起がストップ
	if(max!=-1){
		// 転がった場合の上面と前面の値を次の変数で保持，初期値はとりあえず現在の値
		int next_t=loc[y][x].top().first;
		int next_f=loc[y][x].top().second;

		// もし，方向が0か1，すなわち前面か背面に転がる場合（上からみたら上か下）
		if(deg%2==0){
			// 前面に転がるなら転がった場合の"次の前面"は"現在の上面"の値になる．
			if(deg==0)	next_f=next_t;
			// 背面に転がる場合の"次の前面"の値は”現在の上面”の”裏側”の値なので
			// ７から"現在の上面"の値を引いた値にする．
			else		next_f=7-next_t;
		}
		// それ以外(左右)ならば前面の値は同じ

		// "次の上面"の値は7から"転がる方向の値"を引いた値になる
		next_t=7-max;
		
		// 転がる方向の座標にサイコロを追加する
		loc[y+dy[deg]][x+dx[deg]].push(make_pair(next_t,next_f));
		// x,yにあるサイコロを取り出す
		loc[y][x].pop();
		
		// 転がる方向の座標で転がり判定を再起でかける．
		rollandfall(x+dx[deg],y+dy[deg]);
	}

}

// 入力を保持したキューの先頭をマップの中央に落とす．
void drop(){
	pair<int,int> dice;
	dice=input.front();
	input.pop();
	loc[N/2][N/2].push(make_pair(dice.first,dice.second));
	rollandfall(N/2,N/2);
}

// 上を向いている目を数え上げる
void countup(){
	// ヒストグラムを初期化，0番目を便宜上作成する
	int hist[7]={0,0,0,0,0,0,0};

	// 地図を全部走査して数え上げる
	for(int x=0;x<N;x++){
		for(int y=0;y<N;y++){
			if(!loc[y][x].empty()){
				hist[loc[y][x].top().first]++;
			}
		}
	}
	
	// 0番を除く頻度を表示させる
	for(int i=1;i<=6;i++){
		cout << hist[i];
		if(i!=6) cout << " ";
	}
	cout << endl;
}


void solve(){
	while(!input.empty()){
//		printloc();
		drop();
	}
	countup();
}

int main(void){
	int n;

	while(true){
		cin >> n;
		if(n==0) return 0;

		for(int x=0;x<N;x++){
			for(int y=0;y<N;y++){
				//地図を初期化する
				while(!loc[y][x].empty()){
					loc[y][x].pop();
				}
				//便宜上0,0で初期を埋める
				loc[y][x].push(make_pair(0,0));
			}
		}
		
		for(int i=0;i<n;i++){
			int t;
			int f;
			cin >> t;
			cin >> f;
			input.push(make_pair(t,f));
		}

		solve();
	}

	return 0;
}

Measured memory_bytes: 2896
// This is the template example file for programming//
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    ll N,M;
    ll ans=0, wa=0;
    cin >> N >> M;
    map<ll, ll> sub;
    repll(i,0,M){
        ll p; string s;
        cin >> p >> s;
        if(sub[p]>=0){
            if(s == "AC"){
                ans++;
                wa += sub[p];
                sub[p]=-1;
            }else{
                sub[p]++;
            }
        }
    }
    cout << ans << " " << wa << endl;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	map<int,int> mp;
	REP(i,n){
		int x;
		cin>>x;
		mp[x]=i+1;
	}
	
	for(int i=1;i<=n;++i){
		cout<<mp[i]<<endl;
	}
}//re.

Measured memory_bytes: 5504
#n,*sl, = map(lambda x:''.join(sorted(x)),open(0).read().split())
n = int(input())
sl = []
for i in range(n):
  S = ''.join(sorted(input()))
  sl.append(S)
count = 0
dict ={}

for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)

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

namespace ABC122A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s == "A")
            {
                Console.WriteLine("T");
            }
            if (s == "C")
            {
                Console.WriteLine("G");
            }
            if (s=="G")
            {
                Console.WriteLine("C");
            }
            if (s=="T")
            {
                Console.WriteLine("A");
            }
        }
    }
}


Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    private int[][] cells;

    public Main() {
        // 10×10 マス領域を用意
        this.cells = new int[10][10];
    }

    public static void main(String[] args) throws Exception {
        // 入力を行ごとに分割する
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = null;

        Main droppingInk = new Main();
        // 行数分、配列へ格納する
        while((line = reader.readLine()) != null) {
            //for (String inks : args) {

            // 1回落下分のインク情報
            String[] ink = line.split(",");
            // String[] ink = inks.split(",");
            // インクのx座標
            int ink_X = Integer.parseInt(ink[0]);
            // インクのy座標
            int ink_Y = Integer.parseInt(ink[1]);
            // インクの大きさ
            int ink_size = Integer.parseInt(ink[2]);

            // インキ滴が落したマスに値を加算する
            droppingInk.carcDroppingInk(ink_X, ink_Y, ink_size);
        }

        // 結果を出力する
        droppingInk.print();

    }

    /**
     * 方眼紙にインクを滴下する。
     *
     * @param ink_X
     *            インクが滴下されるx位置
     * @param ink_Y
     *            インクが滴下されるy位置
     * @param size
     *            インクの大きさ
     */
    private void carcDroppingInk(int ink_X, int ink_Y, int size) {
        switch (size) {
        case 3:
            isRangeAdd(ink_X - 2, ink_Y);
            isRangeAdd(ink_X, ink_Y - 2);
            isRangeAdd(ink_X + 2, ink_Y);
            isRangeAdd(ink_X, ink_Y + 2);

        case 2:
            isRangeAdd(ink_X - 1, ink_Y - 1);
            isRangeAdd(ink_X - 1, ink_Y + 1);
            isRangeAdd(ink_X + 1, ink_Y - 1);
            isRangeAdd(ink_X + 1, ink_Y + 1);

        case 1:
            isRangeAdd(ink_X, ink_Y);
            isRangeAdd(ink_X - 1, ink_Y);
            isRangeAdd(ink_X, ink_Y - 1);
            isRangeAdd(ink_X + 1, ink_Y);
            isRangeAdd(ink_X, ink_Y + 1);
        }
    }

    /**
     * インクの滴下先が方眼紙の範囲内か判定する。 範囲内の場合、方眼紙に１追加する。
     *
     * @param cells_X
     *            X座標
     * @param cells_Y
     *            Y座標
     */
    private void isRangeAdd(int cells_X, int cells_Y) {
        if ((0 <= cells_X && cells_X < 10) && (0 <= cells_Y && cells_Y < 10)) {
            // インクの滴下先が方眼紙の範囲内の場合、１をセルに追加
            this.cells[cells_X][cells_Y] += 1;
        }
        // インクの滴下先が方眼紙の範囲外の場合何もしない
    }

    /**
     * 色のついていない部分のマス目の個数、１番濃いマス目の濃さを出力する。
     */
    private void print() {
        int countZero = 0;
        int maxInk = 0;

        for (int[] cells_x : this.cells) {
            for (int cell_xy : cells_x) {
                // 色のついていない部分のマス目の個数を計算
                if (cell_xy == 0) {
                    countZero++;
                }
                // １番濃いマス目の濃さを計算
                if (maxInk < cell_xy) {
                    maxInk = cell_xy;
                }
            }
        }

        // 出力
        System.out.print(countZero);
        System.out.println();
        System.out.println(maxInk);

    }
}

Measured memory_bytes: 16920
# include <cstdio>
# include <iostream>
using namespace std;
char a[50000];
int main (){
	scanf("%s",&a);
	if(a[0]=='Y'&&a[1]=='A'&&a[2]=='K'&&a[3]=='I')	printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
def main():
  import sys
  
  n=int(input())
  a=tuple(map(int,sys.stdin.readline().split()))
  b=[None]*n
  
  for number,index in enumerate(a,1):
    b[index-1]=number
  
  print(" ".join(map(str,b)))
  
if __name__=="__main__":
  main()

Measured memory_bytes: 18312
# include <stdio.h>
int main (void)
{   int A = 0;int B = 0;
    int a;int b;int c;int cnt;int temp;
    scanf("%d",&A);
    scanf("%d",&B);
    a = A + B;b = A - B;c = A * B;
    for (cnt = 0;cnt <= 2;cnt++)
    {   if (cnt == 0){
            temp = a;}
        else if(cnt == 1){
            if (b > temp){
                temp = b;}}
        else{
            if (c > temp){
                temp = c;}}
    }
    printf("%d\n",temp);
    return 0;}

Measured memory_bytes: 128
/********************************************//**
 ****** Handle: techno_phyle    *****************
 ***********************************************/

#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;
#define mod 1000000007
#define N 100010
#define M 200010
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto it:a) cout << it << " "; cout << endl
#define adbp(a) for(auto it:a) cout << it.first << " " << it.second << endl
#define pb push_back
#define mp make_pair
#define endline "\n"
#define in(x) scanf("%d",&x);
const ll INF = 1e18L + 5;
const int inf = 1e9 + 5;
typedef pair<double, long> key;
struct comp {
	bool operator()(pair<int, int> p1, pair<int, int> p2) {
		if (p1.first < p2.first) return false;
		if (p2.first < p1.first) return true;
		return p1.second < p2.second;
	};
};
//greater<pair<int,int> , greater<int>>
//ll a[M];

// int maxLen(int arr[], int n)
// {
// 	// Map to store the previous sums
// 	unordered_map<int, int> presum;

// 	int sum = 0; // Initialize the sum of elements
// 	int max_len = 0; // Initialize result

// 	// Traverse through the given array
// 	for (int i = 0; i < n; i++) {
// 		// Add current element to sum
// 		sum += arr[i];

// 		if (arr[i] == 0 && max_len == 0)
// 			max_len = 1;
// 		if (sum == 0)
// 			max_len = i + 1;

// 		// Look for this sum in Hash table
// 		if (presum.find(sum) != presum.end()) {
// 			// If this sum is seen before, then update max_len
// 			max_len = max(max_len, i - presum[sum]);
// 		}
// 		else {
// 			// Else insert this sum with index in hash table
// 			presum[sum] = i;
// 		}
// 	}

// 	return max_len;
// }
int cnt[1000010];

int solve(int arr[] , int n) {
	int high = 0;
	for (int i = 0; i < n; i++)
		high = max(high, arr[i]);
	memset(cnt , 0, high + 1);
	for (int i = 0; i < n; i++)
		cnt[arr[i]]++;
	int counter = 0;
	for (int i = high; i >= 1; i--) {
		int j = i;
		counter = 0;
		while (j <= high) {
			if (cnt[j] >= 2)
				return j;
			else if (cnt[j] == 1)
				counter++;
			j += i;
			if (counter == 2)
				return i;
		}
	}
}

int main() {
	fastIO;
	int test = 1 , j = 1;
	//cin >> test;
	while (test--) {
		int n;
		cin >> n;
		int a[n];
		for (int i = 0; i < n; i++) cin >> a[i];
		int gcd = a[0];
		for (int i = 1; i < n; i++) gcd = __gcd(gcd , a[i]);
		int maxi = max(1 , solve(a, n));
		if (gcd > 1) cout << "not coprime" << endl;
		else {
			if (maxi > 1) cout << "setwise coprime" << endl;
			else cout << "pairwise coprime" << endl;
		}

	}
	return 0;
}





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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,k,x,i;
    x=1;
    t=1;
    while(x<=t) {
      i=0,n=5;
      int arr[n];
      while(i<n) {
        cin>>arr[i];
        i++;
      }
      cin>>k;
      sort(arr,arr+n);
      if(arr[4]-arr[0]<=k)
        cout<<"Yay!"<<endl;
      else
        cout<<":("<<endl;
      x++;
    }
    return 0;
}


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

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

    long long h[n+1];
    h[0]=0;
    long long ans=0;
    long long cost[n+1];



    for(int i=1;i<=n;i++)
        cin>>h[i];


     cost[1]=0;
     cost[0]=0;
     
     cost[2]=abs(h[2]-h[1]);


    for(int i=3;i<=n;i++){
         cost[i]=min((abs(h[i]-h[i-1])+cost[i-1]),(abs(h[i]-h[i-2])+cost[i-2]));
    }

    cout<<cost[n]<<endl;

}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>

int max(int x,int y){
	if(x>y){
		return x;
	}else{
		return y;
	}
}

int min(int x, int y){
	if(x<y){
		return x;
	}else{
		return y;
	}
}

int main()
{
	int x,y,z;
	scanf("%d %d %d",&x,&y,&z);
	printf("%d %d %d\n",min(x,min(y,z)),x+y+z-min(x,min(y,z))-max(x,max(y,z)),max(x,max(y,z)));
	return 0;
}


Measured memory_bytes: 2000
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define db(x) cout << "#x:" << x << endl
#define dd() cout << "Out put!\n"
const int mod=1e9+7,eps=1e-6,pi=acos(-1.0),maxn=1000010;
const int inf=0x7f7f7f7f7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],v[maxn];
string s; 
signed main()
{
	ios::sync_with_stdio(0);
	int t=1;
//	cin >> t;
	while(t--)
	{
		int x,n;
		cin >> x >> n;
		rep(i,1,n)
			cin >> a[i],v[a[i]] = 1;
		int ans = 0;
		int minn = inf;
		rep(i,0,1000)
			if(v[i] == 0)
			{
				int dis = abs(x-i);
				if(minn > dis)
					ans = i,minn = dis;
			}
				cout <<ans;
	}
	return 0;
}

Measured memory_bytes: 3688
use std::io;
use std::cmp;
use std::collections::VecDeque;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn search(memo: & Vec<Vec<u64>>, visited: usize, r: & Vec<usize>, current: u64, last: usize) -> u64 {
    let rs = r.len();
    if visited == (1 << rs)-1 {
        return current;
    }
    let mut tmp = 1 << 29;
    for i in 0..rs {
        if (1 << i)&visited == 0 {
            tmp = cmp::min(tmp, search(&memo, visited | (1 << i), &r, current + memo[last][r[i]], r[i]));
        }
    }
    return tmp;
}

fn main() {
    let arr:Vec<usize> = read_line().split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();
    let n:usize = arr[0];
    let m = arr[1];
    let rs = arr[2];
    let r:Vec<usize> = read_line().split_whitespace()
        .map(|n| n.parse::<usize>().unwrap() - 1)
        .collect();

    let mut memo = Vec::with_capacity(n);
    for i in 0..n {
        let mut tmp = Vec::with_capacity(n);
        for j in 0..n {
            tmp.push(1 << 60);
        }
        memo.push(tmp);
    }

    for i in 0..m {
        let arr: Vec<u64> = read_line().split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect();
        let a = (arr[0]-1) as usize;
        let b = (arr[1]-1) as usize;
        let c = arr[2];
        memo[a][b] = c;
        memo[b][a] = c;
    }

    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                memo[i][j] = cmp::min(memo[i][j], memo[i][k] + memo[k][j]);
            }
        }
    }

    let mut ans = 1 << 29;
    for i in 0..rs {
        ans = cmp::min(ans, search(&memo, 1 << i, &r, 0, r[i]));
    }
    println!("{}", ans);

}


Measured memory_bytes: 4352
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int H, W;
char A[8][8];

int main(int argc, char **argv) {
	cin >> H >> W;
	REP(y, H) REP(x, W) cin >> A[x][y];
	int x = 0, y = 0;
	while (x != W - 1 || y != H - 1) {
		A[x][y] = '.';
		if (x < W - 1 && A[x + 1][y] == '#') {
			++x;
		}
		else if (y < H - 1 && A[x][y + 1] == '#') {
			++y;
		}
		else {
			break;
		}
	}
	A[x][y] = '.';
	bool res = true;
	REP(x, W) REP(y, H) if (A[x][y] == '#') res = false;
	cout << (res ? "Possible" : "Impossible") << endl;
	return 0;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    
    int counter = 0;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        if(a >= K){
            counter++;
        }    
    }

    cout << counter;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
if (N < 10):
    print(N)
elif (N < 99):
    print(9)
elif (N < 999):
    print(9 + N - 99)
elif (N < 9999):
    print(9 + 900)
elif (N < 99999):
    print(9 + 900 + N - 9999)
else:
    print(9 + 900 + 90000)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		sc.close();
		
		int total = 0;
		for(int a = 1 ; a <= N ; a += 2){
			int count = 0;
				for(int b = 1 ; b <= a ; b += 2){
					if(a % b == 0){
						count++;
					}
				}
			if(count == 8){
				total++;
			}				
		}		
		System.out.println(total);
	}
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/28  Problem: ABC 106 C / Link: http://abc106.contest.atcoder.jp/tasks/abc106_c  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	string s; cin >> s;
	LL K; cin >> K;
	FOR(i, 0, SZ(s)) {
		if (i + 1 == K|| s[i] != '1') {
			ans = s[i] - '0';
			break;
		}
	}
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int n;
	 cin>>n;
	 vector<ll> v(n);
	 ll x=0;
	 for(int i=0;i<n;i++)
	 {
		 cin>>v[i];
		 x^=v[i];
	 }
	 for(int i=0;i<n;i++)
	 {
		 ll ans=x^v[i];
		 cout<<ans<<" ";
	 }
	 
}


Measured memory_bytes: 4724
#include <iostream>
using namespace std;
int main(){
int n,e,s;
long long r;
cin>>n;
if(n>=15){
    if(n%15==0){
        r=(n/15)*200;
        cout<<(n*800)-r<<"\n";
    }
    else{
        s=n%15;
        e=n-s;
        cout<<((e*800)-((n/15)*200))+(s*800)<<"\n";
    }
}
else{
    cout<<n*800;
}


}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {
    static boolean arr[];

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        ArrayList<Character>arr = new ArrayList<>();
        String word = s.next();
        for(int i=0;i<word.length();i++){
            if(word.charAt(i)=='0'||word.charAt(i)=='1')arr.add(word.charAt(i));
            else{
                if(arr.size()!=0)arr.remove(arr.size()-1);
            }
        }
        for(char c : arr) System.out.print(c);
        System.out.println();


    }


}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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

int main(){
  int n, d1, d2;
  cin >> n;
  int cnt=0;
  for(int i=0; i<n; i++){
    cin >> d1 >> d2;
    if(d1==d2)cnt++;
    else cnt=0;
    if(cnt==3){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3168