akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int MAX_C = 2500;
long long INF = 1000000000000000;
int make(int st, int cnt){
  return MAX_C * st + cnt;
}
vector<long long> dijkstra(vector<vector<pair<long long, int>>> &E, int s){
  int V = E.size();
  vector<long long> d(V, INF);
  priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> Q;
  Q.push(make_pair(0, s));
  while (!Q.empty()){
    long long c = Q.top().first;
    int v = Q.top().second;
    Q.pop();
    if (d[v] == INF){
      d[v] = c;
      for (int i = 0; i < E[v].size(); i++){
        Q.push(make_pair(c + E[v][i].first, E[v][i].second));
      }
    }
  }
  return d;
}
int main(){
  int N, M, S;
  cin >> N >> M >> S;
  vector<int> U(M), V(M), A(M), B(M);
  for (int i = 0; i < M; i++){
    cin >> U[i] >> V[i] >> A[i] >> B[i];
    U[i]--;
    V[i]--;
  }
  vector<int> C(N), D(N);
  for (int i = 0; i < N; i++){
    cin >> C[i] >> D[i];
  }
  vector<vector<pair<long long, int>>> E2(N * MAX_C);
  for (int i = 0; i < M; i++){
    //鉄道路線
    for (int j = A[i]; j < MAX_C; j++){
      E2[make(U[i], j)].push_back(make_pair(B[i], make(V[i], j - A[i])));
      E2[make(V[i], j)].push_back(make_pair(B[i], make(U[i], j - A[i])));
    }
  }
  for (int i = 0; i < N; i++){
    //両替所
    for (int j = 0; j < MAX_C; j++){
      E2[make(i, j)].push_back(make_pair(D[i], make(i, min(j + C[i], MAX_C - 1))));
    }
  }
  //edges
  /*
  for (int i = 0; i < N * MAX_C; i++){
    cout << "from : st = " << i / MAX_C << ", cnt = " << i % MAX_C << endl;
    for (auto P : E2[i]){
      cout << "to: st = " << P.second / MAX_C << ", cnt = " << P.second % MAX_C << ", cost = " << P.first << endl;
    }
  }
  */
  int start = make(0, min(S, MAX_C - 1));
  vector<long long> d = dijkstra(E2, start);
  for (int i = 1; i < N; i++){
    long long ans = INF;
    for (int j = 0; j < MAX_C; j++){
      ans = min(ans, d[make(i, j)]);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 26224
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)

	var tailA int
	var headB int
	var both int
	var ret int
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)

		ret += strings.Count(s, "AB")
		if s[0] == 'B' && s[len(s)-1] == 'A' {
			both++
		} else if s[0] == 'B' {
			headB++
		} else if s[len(s)-1] == 'A' {
			tailA++
		}
	}

	if both >= tailA && both >= headB {
		if both > 0 {
			ret += both - 1
		}
		if both > 0 && tailA > 0 {
			ret += 1
			tailA -= 1
		}
		if both > 0 && headB > 0 {
			ret += 1
			headB -= 1
		}
		if tailA > headB {
			ret += headB
		} else {
			ret += tailA
		}
	} else if headB > both && both >= tailA {
		ret += tailA * 2
		restBoth := both - tailA
		restHeadB := headB - tailA
		if restBoth > 0 {
			ret += restBoth - 1
			if restHeadB > 0 {
				ret += 1
			}
		}
	} else if tailA > both && both >= headB {
		ret += headB * 2
		restBoth := both - headB
		restTailA := tailA - headB
		if restBoth > 0 {
			ret += restBoth - 1
			if restTailA > 0 {
				ret += 1
			}
		}
	} else {
		ret += both * 2
		restTailA := tailA - both
		restHeadB := headB - both
		if restTailA > restHeadB {
			ret += restHeadB
		} else {
			ret += restTailA
		}
	}

	fmt.Println(ret)
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int dp[3][2501][2501];
int R[55];
int T[55];
const int INF = (1<<29);
int main() {
  int N; cin >> N;
  for(int i=0;i<N;i++) cin >> T[i];
  for(int i=0;i<N;i++)
    R[i+1] = R[i] + T[i];

  fill(dp[0][0],dp[1][0],INF);  
  dp[0][0][0] = 0;
  for(int i=0;i<N;i++){
    int now = i&1;
    int nex = 1-now;
    //cout << "now:nex "<<now << " "<<nex << endl;
    for(int a=0;a<=2500;a++)
      for(int b=0;b<=2500;b++)
	dp[nex][a][b] = INF;
    for(int a=0;a<=R[i];a++){
      for(int b=0;b<=R[i];b++){
	if( dp[now][a][b] == INF ) continue;
	int c = R[i]-a-b;
	//	cout << i << " "<< a << " "<< b << " " << c << " " << dp[now][a][b] << endl;
	dp[nex][a+T[i]][b] = min( dp[nex][a+T[i]][b], max(dp[now][a][b], a+T[i]) );
	dp[nex][a][b+T[i]] = min( dp[nex][a][b+T[i]], max(dp[now][a][b], b+T[i]) );
	dp[nex][a][b] = min( dp[nex][a][b], max(dp[now][a][b], c+T[i]) );    
      }
    }
  }
  int res = INF;
  for(int i=0;i<=R[N];i++){
    for(int j=0;j<=R[N];j++){
      res = min( res, dp[N&1][i][j] );
    }
  }
  cout << res << endl;
  return 0;
}

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

int main()
{
    long long A, V, B, W, T;
    unsigned long long AA, BB;
    cin >> A >> V >> B >> W >> T;
    AA = (V * T);
    BB = (W * T);
    if (A < B)
    {
        if (AA + A >= BB + B)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    else if (A > B)
    {
        if (AA - A >= BB - B)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
}


Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
  int a,i,n,x,judge,result=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&a);
      judge=0;
      for(x=2;x*x<=a;x++)
	{
	  if(a%x==0)
	    {
	      judge++;
	      break;
	    }
	}
        if(judge==0) result++;
    }
  printf("%d\n",result);
  return 0;
}

Measured memory_bytes: 596
n = int(input())
s, t = [], []
for i in range(n):
    ss = input().split()
    s.append(ss[0])
    t.append(int(ss[1]))
x = input()
start = n
for i in range(n):
    if s[i] == x:
        start = i + 1
res = 0
for i in range(start, n):
    res += t[i]
print(res)

Measured memory_bytes: 38384
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	string sInput;
	int i,ans=0;
	cin >> sInput;
	for (i = 1; i < sInput.length(); ++i){
		if (sInput[i] != sInput[i - 1])
			++ans;
	}
	cout << ans << endl;
	return 0;
}

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

n,m = inpl()
dp = [[INF]*(2**n) for i in range(m+5)]
for i in range(m+1):
    dp[i][0] = 0
for i in range(m):
    val,b = inpl()
    c = inpl()
    key = 0
    for j in c:
        key += 2**(j-1)
    for j in range(2**n):
        dp[i+1][j] = min(dp[i][j], dp[i][j&(~key)]+val)
        
res = dp[m][2**n-1]
print(res if res != INF else -1)

Measured memory_bytes: 192108
#include <cstdlib>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100005
#define pb push_back
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int main()
{
  int t;
  cin>>t;
  int a[t],b[t+1],c[t];
  for(int i=0;i<t;i++) cin>>a[i];
  for(int i=1;i<=t;i++) cin>>b[i];
  for(int i=1;i<=t-1;i++) cin>>c[i];
  long long ans=0;
  for(int i=0;i<t;i++) {
      ans+=b[a[i]];
  }
  for(int i=1;i<t;i++) {
      if(a[i]-a[i-1]==1)
      ans+=c[a[i-1]];
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
//Md. Shajibul Islam..
//East West University, CSE Department'19

#include<bits/stdc++.h>
using namespace std;
#define FAST             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define loop(i,n)        for(int i=0;i<n;i++)
#define CASE_PRINT       cout<<"Case "<<C<<": "
#define CASE_PRINT2      cout<<"Case "<<C<<":"<<endl
#define ll               long long
#define ld               long double
#define Pi               2*acos(0.0) // acos(-1.0)

int main()
{
    FAST;
    int n;cin>>n;
    string s = "ACL";
    for(int i=0;i<n;i++)cout<<s;
    cout<<endl;
}






Measured memory_bytes: 3612
#include <iostream>

int main() {
    int n;  std::cin >> n;
    int harshed = 0;
    for (int i = n; i; i /= 10) harshed += i % 10;
    if (n % harshed == 0)   std::cout << "Yes" << std::endl;
    else                    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int[] x={1,2,3,4,5};
      int[] inx=new int[5];
      for(int i=0;i<5;i++){
         inx[i]=sc.nextInt();
      }
      for(int j=0;j<5;j++){
         if(inx[j]==0){
            System.out.println(x[j]);
         }
      }
   }
}


Measured memory_bytes: 35608
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, a[114514], l;
signed main() {
	cin >> n >> l;
	rep(i, n)cin >> a[i];
	int memo;
	rep(i, n - 1) {
		if (a[i] + a[i + 1] >= l) {
			memo = i;
			goto ok;
		}
	}
	cout << "Impossible" << endl;
	return 0;
ok:;
	cout << "Possible" << endl;
	rep(i, memo)cout << i + 1 << endl;
	for (int i = n - 2; i > memo; i--)cout << i + 1 << endl;
	cout << memo + 1 << endl;
}


Measured memory_bytes: 1664
from math import atan, degrees
a,b,x=[int(i) for i in input().split()]
x/=a
y=2*x/b

if y>a:
    c=b-(2*x-b*a)/a
    print(degrees(atan(c/a)))
    quit()

else:
    print(90-degrees(atan(y/b)))
    quit()

Measured memory_bytes: 3060
n = int(input())
count = 0
divisor_count = 0
for num in range(1, n+1):
    if num % 2 != 0:
        divisor_list = []
        for divisor in range(1, num+1):
            if num % divisor == 0:
                divisor_list.append(divisor)
        if len(divisor_list) == 8:
            count += 1
print(count)

Measured memory_bytes: 3060
#include<stdio.h>  
   
int a[105][105],b[10000+50];  
   
int main ()  
{  
    int h,w;  
    while(scanf("%d %d",&h,&w)!=EOF)  
    {  
        int i,j,t,k=0;  
        scanf("%d",&t);  
        for(i=0;i<t;i++)  
            scanf("%d",&b[i]);  
        for(i=0;i<h;i++)  
        {  
            if(i%2==0)  
                for(j=0;j<w;j++)  
                {  
                    a[i][j]=k+1;  
                    b[k]--;  
                    if(b[k]==0)  
                        k++;  
                }  
            if(i%2==1)  
                for(j=w-1;j>=0;j--)  
                {  
                    a[i][j]=k+1;  
                    b[k]--;  
                    if(b[k]==0)  
                        k++;  
                }  
        }  
        for(i=0;i<h;i++)  
        {  
            for(j=0;j<w-1;j++)  
                printf("%d ",a[i][j]);  
            printf("%d\n",a[i][w-1]);  
        }  
    }  
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll x,r,f=0;
    cin>>x;
    while(x)
    {
        r=x%10;
        x=x/10;
        //cout<<r<<endl;
        if(r==7)
        {
            f=1;
        }
    }
    if(f==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
import java.io.BufferedReader

fun main(args: Array<String>) {
    /** comment in when you submit **/
        System.`in`.bufferedReader().use { println(getOutputString(it)) }

    /** delete below after your test **/
//    executeTest()
}

private fun getOutputString(reader: BufferedReader): String {
    val lines = reader.readLines()
    val (l, lm) = lines[0].split(" ").map(String::toInt).let {
        Pair(it[0], it[1])
    }
    val a = lines.subList(1, 1 + l)
    val b = lines.subList(l + 1, l + 1 + lm)

    (0..(l - lm)).map { Pair(it, a[it].indexOf(b[0])) }
            .filter{ it.second >= 0 }
            .forEach { i ->
                (i.second..(l - lm)).filter { a[i.first].substring(it, it + lm) == b[0] }
                        .forEach { j ->
                            if (lm == 1) {
                                return "Yes"
                            }
                            for (k in (1..lm)) {
                                if (a[i.first + k].substring(j, j + lm) != b[k]) {
                                    break
                                }
                                if (k == lm - 1) {
                                    return "Yes"
                                }
                            }
                        }
            }

    return "No"
}

/** delete below after your test **/
private fun String.mustBe(expected: String): Unit {
    if (this != expected) throw Exception("\"$this\" must be \"$expected\"")

    println("ok")
}

private fun executeTest() {
    getOutputString("3 2\n#.#\n.#.\n#.#\n#.\n.#\n".toByteArray(Charsets.UTF_8).inputStream().bufferedReader()).mustBe("Yes")
    getOutputString("4 1\n....\n....\n....\n....\n#".toByteArray(Charsets.UTF_8).inputStream().bufferedReader()).mustBe("No")
}


Measured memory_bytes: 27692
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef    pair<int,int> pii;
typedef    pair<int,pii> ppi;
typedef    pair<pii,int> pip;
typedef    long long int ll;
typedef    unsigned long long int ull;
typedef    pair<ll,ll> pll;
typedef    vector<int> VI;
typedef    vector<pii> Vii;
typedef    vector<VI> VVI;// 2D
//typedef    priority_queue<int> PQ;// MaxHeap
typedef    priority_queue<int,VI,greater<int> > PQ;// MinHeap
//int Dx[] ={-1,0, 0,1};
//int Dy[] ={ 0,1,-1,0};
//int Dx8[]={-1,-1,-1,0,1,1, 1, 0};
//int Dy8[]={-1, 0, 1,1,1,0,-1,-1};
//int Kx[] ={2,1,-1,-2,-2,-1, 1, 2};
//int Ky[] ={1,2, 2, 1,-1,-2,-2,-1};

// code starts from here
#define pi acos(-1.0)
const int MAX=2e5+10,MOD=1e9+7;
int n,m;
bool vs[MAX];
int dist[MAX],edge[MAX];
vector<pii>g[MAX];
void bfs(int source){
    for(int i=0;i<=n;i++)dist[i]=1e9,edge[i]=-1;
    queue<int> Q;
    Q.push(1);
    dist[1]=0;
    while(!Q.empty()){
            auto u = Q.front();
            Q.pop();
            //int u = x.first;
            //int no = x.second;
            if(vs[u])continue;

            for(auto y:g[u]){

                int v = y.first;
                int no = y.second;

                if(dist[v]>dist[u] + 1){
                    dist[v] = dist[u] + 1;
                    edge[v] = u;
                    Q.push(v);
                }
            }
    }
}
void solve(){
    cin >> n >> m;

    for(int i=1;i<=m;i++){
            int u,v;cin>>u>>v;
            g[u].push_back({v,i});
            g[v].push_back({u,i});

    }
    bfs(1);
    for(int i=2;i<=n;i++){
        if(dist[i]==1e9){
            cout<<"No";
            return;
        }
    }
    cout<<"Yes\n";
    for(int i=2;i<=n;i++)cout<<edge[i]<<endl;
}
int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    while(t--)solve();
    return 0;
}



Measured memory_bytes: 15252
open System.Collections.Generic

type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI32()|]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI64()|]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF32()|]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF64()|]

    member public __.Tuple2Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]|]
    
    member public __.Tuple3Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]|]

    member public __.CountDic n (f : unit -> 'a) =
        let seqs = seq {for _ in 0 .. n - 1 -> f()}
        let dic = new Dictionary<'a, int64>();
        for i in seqs do
            if dic.ContainsKey(i)
            then dic.[i] <- dic.[i] + 1L
            else dic.Add(i, 1L)
        dic

end

[<EntryPoint>]
let main _ =
#if DEBUG
    printfn "debuged"
#endif

    let scanner = Scanner()
    let n = scanner.NextI32()
    let k = scanner.NextI32()
    let arrP = scanner.ArrayF64(n)
    let cums = Array.scan (+) 0.0 arrP
    let f d = (d + 1.0) / 2.0
    let p = n - k + 1
    let ad = [|for i in 0..p-1 -> cums.[k + i] - cums.[i]|]
    let mx = Array.max ad
    let adind = Array.findIndex (fun x -> x = mx) ad
    let narr = arrP.[adind..(adind + k - 1)]

    Array.sumBy f narr
    |> printfn "%f"
    0


Measured memory_bytes: 35932
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

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

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	int n;
	cin>>n;
	if(n<1000)cout<<"ABC"<<endl;
	else cout<<"ABD"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX_V 100
#define INF (1 << 21)

struct edge { int to, cost; };
typedef pair<int, int> P;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

// int cost[MAX_V][MAX_V];
// bool used[MAX_V];

int s = 0; // start

void dijkstra()
{
    priority_queue<P, vector<P>, greater<P> > que;
    for (int i = 0; i < V; i++) {
        d[i] = INF;
        // used[i] = false;
    }
    d[s] = 0;
    que.push(P(0, s));

    for (; !que.empty();) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }

    for (int u = 0; u < V; u++) {
        cout << u << " " << (d[u] == INF ? -1 : d[u]) << endl;
    }

}
int main()
{
    cin >> V;

    // for (int i = 0; i < V; i++) {
    //     for (int j = 0; j < V; j++) {
    //         cost[i][j] = INF;
    //     }
    // }

    for (int i = 0; i < V; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v, c;
            cin >> v >> c;
            G[u].push_back({v, c});
            // cost[u][v] = c;
        }
    }

    dijkstra();

    return 0;
}



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

typedef long long ll;
const ll MOD = 1e9 + 7;

const int INF = 1e9;
const int MAX = 2500;

int main() {
    ll x;
    cin >> x;
    ll ans = 0, a = 100;
    while(a < x) {
        a += a / 100;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int r;
	cin >> r;
	ce(3*r*r)
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

string s;

int main(){
    cin >> s;
    int cnt = 0;
    rep(i,s.size()){
        cnt += (s[i] == 'x');
    }
    if(cnt >= 8)cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

menu = [A,B,C,D,E]
menu.sort()
count  = 0
for x in menu:
    if x % 10 == 0:
        count += x
    else:
        count += 10 + (x//10)*10

cache = 10
for x in menu:
    if x%10 == 0:
        continue
    if cache > x%10:
        cache = x%10
count -= (10 - cache)
print(count)

Measured memory_bytes: 3064
<?php
	while (true) {
		$card = trim(fgets(STDIN));
		if ($card == "-") break;

		$m = trim(fgets(STDIN));
		for ($i = 0; $i < $m; $i++) {
			$h = trim(fgets(STDIN));
			$card = substr($card, $h) . substr($card, 0, $h);
		}
		echo $card . "\n";
	}

Measured memory_bytes: 6560
let n, a, b = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let ans, xs = ref 0, Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let _ = Array.iteri (fun i x -> if i > 0 then ans := !ans + min b (a * (x - xs.(i - 1)))) xs; Printf.printf "%d\n" !ans

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;

int n;
int value[101] , weight[101];


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int w;
   	cin>>n>>w;
   	int i;
   	f1(i,0,n)
   	cin>>weight[i]>>value[i];
   	int ans[100001];
   	f1(i,0,100001)
   	{
   		ans[i]=mod;
   	}
   	ans[0]=0;
   	f1(i,0,n)
   	{
   		for(int j=100000-value[i];j>=0;j--)
   		{
   			if(ans[j]!=mod)
   			{
   				ans[j+value[i]]=min(ans[j]+weight[i],ans[j+value[i]]);
   			}
   		}
   	}
   	int sum=0;
   	f1(i,0,100001)
   	{
   		if(ans[i]<=w)
   			sum=i;
   	}
   	cout<<sum;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int dp[200000];
int h[200000];
int main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%d",&h[i]);
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	rep(i,n){
		if(i+1<n){
			dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
		}
		if(i+2<n){
			dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
		}
	}
	cout<<dp[n-1]<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  int ans = 0;
  int ref = 1;
  bool flag = false;
  
  for (int i = 0; i < N; i++) {
    if (a.at(i) == ref) {
      flag = true;
      ref += 1;
    }
    else {
      ans += 1;
    }
  }
  
  if (flag) {
    cout << ans << endl;
  }
  else {
    cout << -1 << endl;
  }

}


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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK\n"

const double PI = M_PI;
const long long INF = int(10e9-1);
const long long MOD = int(10e9+7);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
   int N, M;
   string S;
   cin >> N >> M >> S;
   if(N == 1){
       cout << 1 << endl;
       ED;
   }
   int player = -1;
   vector<bool> grid (N+1);
   for(int i = 0;i < N+1;i++){
       if(S[N-i-1] == '0'){
           grid[i] = false;
       }
       else{
           grid[i] = true;
       }
   }
   vector<int> act;
   while(player+M < N+1 && player+1 < N){
       int move = -1;
       for(int i = 0;i < M;i++){
           if(player+M-i >= 0 && grid[player+M-i] == false){
               move = M-i;
               break;
           }
       }
//       cout << "MOVE = " << move << endl;
       if(move == -1){
           cout << "-1" << endl;
           ED;
       }
       player += move;
//       cout << "PLAYER = " << player << endl;
       act.push_back(move);
   }
   if(player+1 != N)act.push_back(N-player-1);

   REV(act);
   for(int i = 0;i < act.size();i++){
       if(i != act.size()-1){
           cout << act[i] << " ";
       }
       else{
           cout << act[i] << endl;
       }
   }
}


Measured memory_bytes: 1100
from math import gcd

magic = [2, 7, 61]

def mul(a, b, n):
    # calculate (a * b) % n
    r, a, b = 0, a % n, b % n
    while b:
        if b & 1:
            r = (a + r) % n
        a = (a + a) % n
        b >>= 1
    return r

def bigmod(a, p, n):
    # calculate (a ** p) % n
    if p == 0:
        return 1
    if p == 1:
        return a % n
    return mul(bigmod(mul(a, a, n), p // 2, n), a if p % 2 else 1, n)

def miller_rabin(n, a):
    if gcd(a, n) == n:
        return True
    if gcd(a, n) != 1:
        return False
    d, r = n-1, 0
    while d % 2 == 0:
        d /= 2
        r += 1
    res = bigmod(a, d, n)
    if res == 1 or res == n-1:
        return True
    while r:
        r -= 1
        res = mul(res, res, n)
        if res == n-1:
            return True
    return False

def isPrime(n):
    for a in magic:
        if not miller_rabin(n, a):
            return False
    return True


num = int(input())
ans = sum(map(int, [isPrime(int(input())) for _ in range(num)]))
print(ans)



Measured memory_bytes: 5784
function main (s) {
    s=s.split(" ");
	for(var i=0;i<3;i++)s[i]=parseInt(s[i]);
	console.log(Math.min(s[0]+s[1],s[0]+s[2],s[1]+s[2]));
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

const int MOD = 1e9 + 7;
const int NMAX = 1000002;
long long n, fact[NMAX];
long long x, y, ans, last;

long long lgpow (long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1)
      ans = ans * a % MOD;
    b >>= 1;
    a = a * a % MOD;
  }
  return ans;
}

long long  C (long long n, long long m) {
  long long a = fact[n], b = (fact[m] * fact[n - m]) % MOD;
  return (a * lgpow(b, MOD - 2)) % MOD;
}

int main()
{
  cin >> n;
  fact[0] = 1;
  for (int i = 1; i <= n; i++)
    fact[i] = (long long)fact[i - 1] * i % MOD;
  for (int k = (n + 1) / 2; k < n; k++) {
    x = C(k - 1, n - 1 - k) * fact[k] % MOD * fact[n - k - 1] % MOD;
    y = (x - last + MOD) % MOD * k % MOD;
    ans = (ans + y) % MOD;
    last = x;
  }
  cout << ans;
  return 0;
}


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

#define int long long

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

  vector<int> p(n);
  for ( int i = 0; i < n; i++ ) cin >> p[i];
  
  vector<int> dp(n+1, 0);
  for ( int i = 0; i < n; i++ ) {
    dp[p[i]] = dp[p[i]-1]+1;
  }
  
  int ans = 0;
  for ( int i = 0; i < n+1; i++ ) {
    ans = max(ans, dp[i]);
  }

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


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<vector>
#include<queue>

using namespace std;

int main(){
    int h,w;
    int score;
    int white=0;
    
    cin >> h >> w;
    char array[h*w];
    vector<int> dist(h*w,-1);
    queue<int> que;
    for(int i=0;i<h*w;i++){
        cin >> array[i];
        if(array[i]=='.'){
            white++;
        }
    }


    dist[0]=0;
    que.push(0);
    while(!que.empty()){
        int v = que.front();
        que.pop();

        if(v-w>0 && array[v-w]!='#' && dist[v-w]==-1){
            if(dist[v-w] != -1) break;
            dist[v-w]=dist[v]+1;
            /*
            cout << dist[v-w] << endl;
            cout << "a" << endl;
            */
            que.push(v-w);
        }
        if(v+w<h*w && array[v+w]!='#' && dist[v+w]==-1){
            if(dist[v+w] != -1) break;
            dist[v+w]=dist[v]+1;
            /*
            cout << dist[v+w] << endl;
            cout << "b" << endl;
            */
            que.push(v+w);
        }
        if(v%w!=0 && array[v-1]!='#' && dist[v-1]==-1){
            if(dist[v-1] != -1) break;
            dist[v-1]=dist[v]+1;
            /*
            cout << dist[v-1] << endl;
            cout << "c" << endl;
            */
            que.push(v-1);
        }
        if(v%w!=w-1 && array[v+1]!='#' && dist[v+1]==-1){
            if(dist[v+1] != -1) break;
            dist[v+1]=dist[v]+1;
            /*
            cout << dist[v+1] << endl;
            cout << "d" << endl;
            */
            que.push(v+1);
        }

        if(dist[h*w-1]>0){
            break;
        }
    }
    
    if(dist[h*w-1]<0){
        cout << -1;
    }else{
        cout << white-dist[h*w-1]-1;
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
n, m = map(int, input().split())
l = sorted(list(map(int, input().split())))
divcount = n - 1
 
l1 = l[1:]
l2 = l[:m - 1]
divl = []
 
for i in range(m - 1):
    divl.append(l1[i] - l2[i])
 
divl.sort(reverse = True)
 
if n == 1:
    print(max(l) - min(l))
else:
    if m > n:
        for i in range(divcount):
            del divl[0]
    
        print (sum(divl))
    
    else:
        print(0)

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

int main()
{
	string p;
	string str ;
	
	p = "CODEFESTIVAL2016";
	cin >> str;
	
	int cnt = 0;
	for(int i=0; i < str.size() ; i++) {
		if(p[i] != str[i]) cnt++ ;
	}
	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

    if (T.length() == S.length() + 1 && std::equal(S.begin(), S.end(), T.begin(), T.end() - 1)) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x; cin>>x;
  ll a=x/500;
  ll b=(x%500)/5;
  cout<<a*1000+b*5<<endl;
}

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

using namespace std;

int h, w, ans, curr, dist[21][21];
bool visited[21][21];
char m[21][21];
queue<pair<int, int>> q;

void bfsClear() {
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            visited[i][j] = false;
        }
    }
    while (!q.empty()) {
        q.pop();
    }
}

void bfsCheck(int a, int b, int aPrev, int bPrev) {
    if (m[a][b] == '.' && visited[a][b] == false) {
        visited[a][b] = true;
        dist[a][b] = dist[aPrev][bPrev] + 1;
        q.push({a, b});
    }
}

void bfs(int a, int b) {
    bfsClear();
    visited[a][b] = true;
    dist[a][b] = 0;
    q.push({a, b});
    while (!q.empty()) {
        int A = q.front().first;
        int B = q.front().second;
        curr = max(curr, dist[A][B]); q.pop();
        bfsCheck(A+1, B, A, B); bfsCheck(A-1, B, A, B);
        bfsCheck(A, B+1, A, B); bfsCheck(A, B-1, A, B);
    }
}

int main() {
    cin >> h >> w;
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cin >> m[i][j];
        }
    }

    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (m[i][j] == '.') {
                bfs(i, j);
                ans = max(ans, curr);
                curr = 0;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
// @supudo
// g++ -O2 -std=gnu++14 -Wall -Wextra -Wfatal-errors -Wshadow -Wno-vla-extension -pedantic -o ./build/abc137_b abc137_b.cpp -DLOCALHOST -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC
// ./build/abc137_b

#include <iostream>
using namespace std;
#define _ ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(10);

int main() { _
  int k, x;
  cin >> k >> x;

  for (int i = x - k + 1; i <= x; i++)
    cout << i << ' ';
  for (int i = x + 1; i < (x + k); i++)
    cout << i << ' ';

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int n;
  cin >> n;
  int ans=-2000000000;
  vector<vector<int>> mise(n,vector<int>(10)),p(n,vector<int>(11));
  rep(i,n){
    rep(j,10)
      cin >> mise.at(i).at(j);
  }
  rep(i,n){
    rep(j,11)
      cin >> p.at(i).at(j);
  }
  for(int tmp=1;tmp<(1 << 10);tmp++){
    int pro=0;
    bitset<10> s(tmp);
    rep(i,n){
      int k=0;
      rep(j,10)
        if((mise.at(i).at(j)&&s.test(j)))k++;
      pro+=p.at(i).at(k);
    }
    ans=max(ans,pro);
  }
  cout << ans << endl;
}
        
    

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll a, b;
    cin >> a >> b;
    if(a == b)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;


int main()
{
    int n;
    cin >> n;  
    string s;
    cin >> s;
    rep(i, s.size()){
        s[i] = s[i] + (char)n;
        if (s[i] > 'Z'){
            s[i] -= 'Z';
            s[i] += 'A' - 1;
        }
    }

    cout << s << endl;

}



Measured memory_bytes: 256
class Array
	def bsearch(l = 0, r = size - 1, &pred)
		if r - l < 10
			return (l..r).find{|j| pred[self[j]]}
		end 
		c = (l + r) / 2 
		if pred[self[c]]
			bsearch(l, c-1, &pred) || c
		else
			bsearch(c+1, r, &pred)
		end
	end
end

loop {
	d = gets.to_i
	break if d == 0
	n = gets.to_i
	m = gets.to_i
	shop = [0] + (2..n).map{ gets.to_i }.sort + [d]
	total = 0	
	(1..m).each{
		o = gets.to_i
		i = shop.bsearch{|x| x > o} 
		total += [o - shop[i-1], shop[i] - o].min
	}
	p total
}

Measured memory_bytes: 9548
s = gets.strip
ans = ''
(1 << (s.length - 1)).times do |i|
  sum = 0
  x, result = '', ''
  4.times do |j|
    x = s[j]
    if j == 0
      sum += x.to_i
      result += x
    elsif i[j - 1] == 1
      sum += x.to_i
      result += ('+' + x)
    else
      sum -= x.to_i
      result += ('-' + x)
    end
  end
  if sum == 7
    ans = result + '=7'
  end
end
puts ans

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

length_list = [int(input()) for _ in range(5)]
k = int(input())
a = length_list[0]
flag = True
for i in range(len(length_list)-1, 0, -1):
    if length_list[i] - a > k:
        print(':(')
        flag = False
        break
if flag:
    print('Yay!')


Measured memory_bytes: 38384
#include<stdio.h> 
int main(){
 
  int d,i,s_sum;
  

  while(scanf("%d",&d)!=EOF){
    s_sum=0; 
    for(i=1;(d*i)<=(600-d);i++)
    {
       s_sum=s_sum+d*(d*i)*(d*i);
    }
    
     printf("%d\n", s_sum);
   }   
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define maxn 100086

using namespace std;

int n, l, q;
int a[maxn];
int f[maxn][25];
int x, y;

int main(){
	scanf("%d", &n);
	for(int i = 1;i <= n;i++) scanf("%d", &a[i]);
	scanf("%d%d", &l, &q);
	f[n][0] = n;
	for(int i = n - 1;i;i--){
		f[i][0] = f[i + 1][0];
		while(a[f[i][0]] - a[i] > l) f[i][0]--;
	}
	for(int j = 1;j <= 20;j++) for(int i = 1;i <= n;i++) f[i][j] = f[f[i][j - 1]][j - 1];
	while(q--){
		scanf("%d%d", &x, &y);
		if(x > y) swap(x, y);
		int ans = 0;
		for(int i = 20;~i;i--){
			if(f[x][i] < y) ans += 1 << i, x = f[x][i];
		}
		printf("%d\n", ans + 1);
	}
}

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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String[] line;
      MyList list = new MyList();

      for(int i=0; i<n; i++) {
        line = br.readLine().split(" ");
        switch( line[0] ) {
          case "insert" :
            list.insertFirst( Integer.parseInt(line[1]) );
            break;
          case "deleteFirst" :
            list.deleteFirst();
            break;
          case "deleteLast" :
            list.deleteLast();
            break;
            case "delete" :
              list.delete( Integer.parseInt(line[1]) );
              break;
          default :
            System.out.println("n:" + i + " is failed.");
        }
      }

      System.out.println ( list.getAllElements() );
    }
  }
}

class Node {
  Node next,prev;
  final int key;

  public Node(int key) {
    this.key = key;
  }
}

class MyList {
  Node nil;
  Node current;
  int size;

  public MyList() {
    nil = new Node(0);
    nil.next = nil.prev = nil;
    size = 0;
  }

  public String getAllElements() {
    StringBuilder buf = new StringBuilder(size*2);

    if(size > 0){
      current = nil.next;
      for(int i=0; i<size; i++){
        buf.append(current.key).append(" ");
        current = current.next;
      }
    }
    buf.setLength(buf.length()-1);

    return buf.toString();
  }
  public void insertFirst(int x) {
    if(size == 0) {
      current = new Node(x);
      nil.next = current;
      nil.prev = current;
      current.prev = nil;
      current.next = nil;
      size++;
    }
    else {
      Node add = new Node(x);
      
      current.prev.next = add;
      add.prev = current.prev;

      add.next = current;
      current.prev = add;

      current = add;
      size++;
    }
  }
  public void deleteFirst() {
    nil.next = current.next;
    current.next.prev = current.prev;

    current = current.next;
    size--;
  }
  public void deleteLast() {
    current = nil.prev;

    nil.prev = current.prev;
    current.prev.next = current.next;

    current = nil.next;
    size--;
  }
  public void delete(int x) {
    Node target = findFirst(x);

    if(target == nil) current = current.next;
    else {
      current.prev.next = target.next;
      current.next.prev = target.prev;
      current = nil.next;
      size--;
    }
  }
  private Node findFirst(int x) {
    while(current != nil) {
      if(current.key == x) break;
      current = current.next;
    }

    return current;
  }
}


Measured memory_bytes: 189032
{-# LANGUAGE BangPatterns #-}
import Data.Word
import qualified Data.ByteString as BSW
import qualified Data.ByteString.Unsafe as BSW (unsafeIndex)
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U

-- Input: s t
-- Output: arr
--   (arr ! i) ! j == length of lcs of (drop i s, drop j t)
lcsTable :: BS.ByteString -> BS.ByteString -> V.Vector (U.Vector Word16)
lcsTable s t = V.scanr' (\ !x !v ->
                           -- for some i (0 <= i < m),
                           --   x = BS.index s i :: Char
                           --   v = arr ! (i+1) :: U.Vector Word16
                           U.scanr (\(!y,!w,!u) !l ->
                                      -- for some j (0 <= j < n)
                                      --   y = BS.index t j :: Char
                                      --   w = (arr ! (i+1)) ! j :: Word16
                                      --   u = (arr ! (i+1)) ! (j + 1) :: Word16
                                      --   l = (arr ! i) ! (j + 1) :: Word16
                                      if x == y
                                      then u + 1
                                      else max w l
                                   ) 0 (U.zip3 t' (U.init v) (U.tail v))
                        ) (U.replicate (n+1) 0) (V.fromListN m $ BS.unpack s)
  where !m = BS.length s
        !n = BS.length t
        !t' = U.fromListN n (BS.unpack t)

main = do
  s <- BS.getLine
  t <- BS.getLine
  -- BS.length s <= 3000, BS.length t <= 3000, BS.all isAsciiLower s, BS.all isAsciiLower t
  let !table = lcsTable s t
      !m = BS.length s
      !n = BS.length t
  let recon !i !j | i >= m || j >= n = Nothing
                  | x == y = let !i' = i+1 ; !j' = j+1
                             in Just (x, (i', j'))
                  | (table `V.unsafeIndex` (i+1)) `U.unsafeIndex` j >= (table `V.unsafeIndex` i) `U.unsafeIndex` (j+1) = recon (i+1) j
                  | otherwise = recon i (j+1)
        where x = BSW.unsafeIndex s i
              y = BSW.unsafeIndex t j
      (result, _) = BSW.unfoldrN (fromIntegral $ (table V.! 0) U.! 0) (\(!i,!j) -> recon i j) (0,0)
  BS.putStrLn result


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

using namespace std;

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

int visited[maxn];
vector<int> g[maxn];

void dfs(int u) {
    visited[u] = true;
    for (auto x : g[u]) {
        if (!visited[x]) {
            dfs(x);
        }
    }
}

void solve() {
    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int a, b, z;
        cin >> a >> b >> z;

        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ct = 0;
    for (int i = 1; i <= n; i++)
        if (!visited[i])
            dfs(i), ct++;
        cout << ct << endl;
}

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

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

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


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const int mod = 1e5;
const int MAX = 1e5+5;

vint c(MAX,0), cover(MAX,0);

int main() {
    int n, m; cin >> n >> m;
    vector<P> q(m);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        q[i].first = b; q[i].second = a;
    }
    int ans = 0;
    vector<bool> check(m,true);
    while (true) {
        bool ok = false;
        rep(i,m) if (check[i]) ok = true;
        if (!ok) break;
        vector<P> x;
        rep(i,m) if (check[i]) x.push_back(q[i]);
        sort(all(x));
        // cout << x[0].first << endl;
        rep(i,m) if (q[i].second <= x[0].first-1) check[i] = false;
        ans++;
        // rep(i,m) cout << check[i] << " ";
        // cout << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3688
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int i,j,a,b,ans=-7;
	char c[10];
	char d[1000]={'h'};
	while(scanf("%s",&c) !=EOF){
		/*for(i=1; i<9; i++){
			scanf("%s", &c[i]);
		}*/
		for(i=0; i<9; i++){
			//cout << c[i] <<endl;
			if(i%3==0 || i==0){
				if(c[0+i]=='o' &&c[1+i]=='o'&&c[2+i]=='o'){
					ans=1;
				}
				if(c[0+i]=='x' &&c[1+i]=='x'&&c[2+i]=='x'){
					ans=0;
					//cout << 1 <<endl;
				}
			}
			if(i <=2){
				if(c[0+i]=='o' &&c[3+i]=='o'&&c[6+i]=='o'){
					ans=1;
				}
				if(c[0+i]=='x' &&c[3+i]=='x'&&c[6+i]=='x'){
					ans=0;
					//cout << 10 <<endl;
				}
			}
		}
		if(c[0]=='o' &&c[4]=='o'&&c[8]=='o')	ans=1;
		if(c[0]=='x' &&c[4]=='x'&&c[8]=='x')	ans=0;
		if(c[2]=='o' &&c[4]=='o'&&c[6]=='o')	ans=1;
		if(c[2]=='x' &&c[4]=='x'&&c[6]=='x')	ans=0;

		if(ans==1)		/*d[a]='o';*/	cout<<'o'<<endl;
		else if(ans==0)	/*d[a]='x';*/	cout<<'x'<<endl;
		else			/*d[a]='d';*/	cout<<'d'<<endl;
		//strcpy(c, "aaaaaaaaa");
		ans=-7;
	}
/*	for(j=0; j<1000; j++){
			if(d[j] !='h'){
				if(d[j]=='o')		cout<<'o'<<endl;
				else if(d[j]=='x')	cout<<'x'<<endl;
				else			cout<<'d'<<endl;
			}
	}*/
}

Measured memory_bytes: 1148