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

class Main {
	Scanner sc = new Scanner(System.in);

	int[] count = new int[26];

	public void run() {
		while(sc.hasNext()){
			String str = sc.nextLine();
			str=str.toLowerCase();
			char[] c = str.toCharArray();
			for (int i = 0; i < c.length; i++) {
				if ('a' <= c[i] && c[i] <= 'z')
					count[c[i] - 'a']++;
			}
		}
		for (int i = 0; i < count.length; i++) {
			ln(((char) (i + 'a')) + " : " + count[i]);
		}
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {
    public static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
        int n = in.nextInt();
        String str = in.next();
        int red = 0;
        for (int i = 0; i < n; i++) {
            red += str.charAt(i) == 'R' ? 1 : 0;
        }
        int answer = 0;
        for (int i = 0; i < red; i++) {
            answer += str.charAt(i) == 'W' ? 1 : 0;
        }
        System.out.println(answer);
    }
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  bool ans = false;
  if(A + B == C) ans = true;
  if(A + C == B) ans = true;
  if(C + B == A) ans = true;
  
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

#define INF 10000000000

int answer=1;

int L[200000], R[200000], D[200000];

pair<int, int> Li[200000]={}, Ri[200000]={};
int start_Li[100000]={};
int start_Ri[100000]={};

long long x[100000]={};

///////////////////////////////////////////////

int check(int num,int M){
	for(int cnt=start_Li[num]; num==Li[cnt].first && cnt<M; cnt++){
		if(x[ R[Li[cnt].second]]==INF){
			x[R[Li[cnt].second]]=x[num]+D[Li[cnt].second];	
			check(R[Li[cnt].second], M);
		}
		else if(x[ R[  Li[cnt].second ]]!=x[num]+D[Li[cnt].second]){

			answer=0;
		}
	}
	for(int cnt=start_Ri[num]; num==Ri[cnt].first && cnt<M; cnt++){
			
		if(x[ L[ Ri[cnt].second  ] ]==INF){
			x[ L[ Ri[cnt].second  ] ]=x[num]-D[Ri[cnt].second];
			check(L[Ri[cnt].second], M);
		}else if(	x[ L[ Ri[cnt].second  ] ]!=x[num]-D[Ri[cnt].second]){

			answer=0;
		}
		
	}
}

//////////////////////////////////////////////

int main() {
	int N,M;
	cin >> N >> M;
	
	if(M==0){cout << "Yes"<<endl; return 0;}
//
	for(int i=0; i<M; i++){
		cin >> L[i] >> R[i] >> D[i];
		L[i]--;
		R[i]--;
	}
	
//
	for(int i=0; i<M; i++){
		Li[i].first=L[i];
		Li[i].second=i;
		Ri[i].first=R[i];
		Ri[i].second=i;
	}
//
	sort(Li,Li+M);
	sort(Ri,Ri+M);
//	
	for(int i=0; i<M; i++){

		
		if(Li[i].first!=Li[i-1].first){
			start_Li[Li[i].first]=i;
		}
		if(Ri[i].first!=Ri[i-1].first){
			start_Ri[Ri[i].first]=i;
		}
		
		
		
	}
//

	for(int i=0; i<N; i++){
		x[i]=INF;
	}
	for(int i=0; i<N; i++){
		if(x[i]==INF){
			x[i]=0;
			check(i, M);
		}
	}

	
	if(answer==0){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

using namespace std;

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

#define pb push_back
#define mp make_pair

int main()
{
        int n, m;
        cin >> n >> m;
        for(int i = 0; i < n; i++){
                for(int j = 0; j < m; j++){
                        string s;
                        cin >> s;
                        if(s == "snuke"){
                                cout << (char)(j + 'A') << i + 1;
                                exit(0);
                        }
                }
        }
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>

typedef std::vector<int> Vec;
typedef std::vector<bool> Marks;

int path_finding( const Vec& as ) {
  Marks marks(as.size(), false);
  marks[0] = true;

  int c = 0;
  int current = 0;
  for( ; ; ) {
    const int next = as[ c ];
    if( next == 1 ) return current + 1;
    if( marks[ next ] ) return -1;
    marks[ next ] = true;
    c = next;
    current += 1;
  }
}

int main( void ) {
  int N;
  Vec as;
  std::cin >> N;
  for( size_t i = 0; i < N; ++i ) {
    int a;
    std::cin >> a;
    as.push_back( a - 1 );
  }

  if ( N < 2 ) {
    std::cout << -1 << std::endl;
    return 0;
  }

  std::cout << path_finding( as ) << std::endl;
  return 0;
}

Measured memory_bytes: 1020
void main()
{
    long n = rdElem;
    string[] s = n.rdCol!string;

    long[] alpha = new long[26];
    alpha[] = inf;
    foreach (x; s)
    {
        foreach (i, y; lowercase)
        {
            alpha[i] = min(alpha[i], x.count(y));
        }
    }

    string result;
    foreach (x, y; zip(alpha, lowercase))
    {
        foreach (i; 0 .. x)
        {
            result ~= y;
        }
    }

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    int N;
    cin >> N;
    string n = to_string(N);
    int tmp = 0;
    rep(i, n.size())
    {
        tmp += int(n[i] - '0');
    }
    if (N % tmp == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

#define rep(i,n) for(ll i=0;i<n;i++)
#define repm(i,m,n) for(ll i=m;i<n;i++)
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define YesNo(a) (a)?cout<<"Yes"<<endl:cout<<"No"<<endl
#define YESNO(a) (a)?cout<<"YES"<<endl:cout<<"NO"<<endl
#define INF (2e9)
#define PI (acos(-1))
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

typedef long long ll;

int main(){
  double n; cin >> n;
  cout << fixed << setprecision(10) << 2*n*PI << endl;
}

Measured memory_bytes: 3792
Imports System.Collections.Generic
Imports System.Console

Module Program
    Const price_c As Integer = 4
    Const price_d As Integer = 7

    Sub Main()
        Dim N As Integer = CInt(NextString())
        Dim flg As Boolean

        For c As Integer = 0 To N \ price_c
            For d As Integer = 0 To N \ price_d
                If c * price_c + d * price_d = N Then flg = True
            Next
        Next

        WriteLine(New String() {"No", "Yes"}(B2I(flg)))
    End Sub


    Function B2I(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


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

using namespace std;
bool j(int u,int m){
	while(u%m==0&&u>1){
		u/=m;
	}
	if(u==1){
		return 1;
	}
	return 0;
}
bool h(int s){
	if(s==1){
		return 1;
	}
	for(int i=2;i<=sqrt(s);i++){
		if(s%i==0&&j(s,i)==1){
			return 1;
		}
	}
	return 0;
}
int main() {
int a;
cin>>a;
for(int i=a;i>=1;i--){
	if(h(i)==1){
		cout<<i;
		return 0;
	}
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FILE
#define ll long long
#define cn continue
using namespace std;
const ll M = 1e3;
ll n  ,mx = -1e9 , m  , ans;
long double a , b , cnt;
string s , s1;
int main(){
    #ifdef FILEs
        freopen(".in" , "r" , stdin);
        freopen(".out" , "w" , stdout);
    #endif
    cin >> n >> m;
    for( int i = 0;i < n;i ++ ){
        cin >> a >> b;
        if(a * a + b * b <= m * m )
            ans ++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3708
#!/usr/bin/env python3

def is_prime(x):
    i = 2
    while i*i <= x:
        if x%i == 0: return False
        i += 1
    return x != 1

x = int(input())

while True:
    if is_prime(x):
        print(x)
        break
    x += 1

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,wmx;
  cin >> n >> wmx;
  vector<int32> w(n),v(n);
  cin >> w[0] >> v[0];
  int32 w0 = w[0];
  w[0] = 0;
  FOR(i,1,n){
    cin >> w[i] >> v[i];
    w[i] -= w0;
  }
  int32 ans = 0;
  FOR(k,1,n+1){
    int32 wcur = min(3 * k, wmx - w0 * k);
    if(wcur < 0)break;
    vector<vector<int32>> dp(k+1,vector<int32>(wcur+1,0));
    REP(i,n){
      FORR(j,wcur,0){
        if(j - w[i] < 0)break;
        FORR(l,k,1){
          dp[l][j] = max(dp[l][j], dp[l-1][j-w[i]]+v[i]);
        }
      }
    }
    // REP(i,k+1){
    //   REP(j,wcur+1){
    //     cout << dp[i][j] << " ";
    //   }
    //   cout << endl;
    // }
    // cout << k << " " << dp[k][wcur] << endl;
    ans = max(ans, dp[k][wcur]);
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 544
from itertools import accumulate
 
n, k = list(map(int, input().split()))
s = input()
 
l = []

prev = '1'
cnt = 0
for c in s :
  if prev == c:
    cnt +=1 
  else :
    l.append(cnt)
    cnt = 1
  prev = c
l.append(cnt)

if prev == '0':
  l.append(0)

w = 2 * k + 1

if len(l)<= w :
  print(n)
else :
  acc = [0] + list(accumulate(l))
  ans = 0
  for i in range(0, len(l) - w + 1, 2):
    #print(i+w, i)
    #print(ans, acc[i+w]-  acc[i])
    ans = max(ans, acc[i + w] - acc[i])
  print(ans)

Measured memory_bytes: 8700
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int N,K,A,ans=0;
	cin >> N >> K;
	vector<int> v(N);
	
	for(int i=0;i<N;i++){
		cin >> A;
		v[A-1]++;
	}
	
	sort(v.begin(),v.end(),greater<int>());
	for(int i=0;i<K;i++){
		ans+=v[i];
	}
	ans=N-ans;
	cout << ans << endl;

	return 0;
}

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

int main(){
	int N;
	cin >> N;
	int a;
	int max = 0;
	int min = 1000;
	for (int i = 0; i < N; i++){
		cin >> a;
		if (a < min){
			min = a;
		}
		if (a > max){
			max = a;
		}
	}

	cout << max - min << endl;
	return 0;
}

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

const int N=2e5+10, mod=1e9+7;
ll n,k,a[N],ans,flag;

int main(){
	cin>>n>>k;
	for(ll i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	sort(a,a+n,greater<ll>());
	ll l=0, r=n-1;
	ans=1; flag=1;//注意如果开始k是偶数，flag要初始化 
	if(k%2) ans=a[l], l++, flag=(ans>=0?1:-1), k--;
//cout<<ans<<" f"<<flag<<endl;
	while(k){
//cout<<l<<" "<<r<<endl;
		ll x=a[l]*a[l+1], y=a[r]*a[r-1];
		if(flag*x>flag*y) ans=ans*(x%mod)%mod, l+=2;
		else ans=ans*(y%mod)%mod, r-=2;
		k-=2;
//cout<<x<<" "<<y<<" "<<ans<<endl;
	}
	cout<<(ans+mod)%mod<<endl;
	return 0;
}


Measured memory_bytes: 5228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(x % y, y);
}
ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll modpow(ll a, ll n, ll m) {
    ll ret = 1;
    ll now = a;
    while (n > 0) {
        if (n % 2 == 1) ret = ret * now % m;
        now = now * now % m;
        n /= 2;
    }
    return ret;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    if (n == 1) {
        cout << (a[0] + a[0]) % MOD << endl;
        return 0;
    }

    sort(all(a), greater<ll>());

    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        ans += (((i + 2) * modpow(2, n - 2, MOD)) % MOD * a[i]) % MOD;
        ans %= MOD;
    }
    cout << ans * modpow(2, n, MOD) % MOD << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,m;
  cin>>n>>m;
  vll p(m);
  vstr s(m);
  vb t(n,false);
  ll ans=0;
  vll j(n);
  rep(i,m) {
    cin>>p[i]>>s[i];
    if(s[i]=="AC"&&!t[p[i]-1]){
      ans++;
      t[p[i]-1]=true;
    }
    if(s[i]=="WA"&&!t[p[i]-1]){
      j[p[i]-1]++;
    }
  }
  ll cu=0;
  rep(i,n){
    if(t[i]){
      cu+=j[i];
    }
  }
  cout<<ans<<" "<<cu<<endl;
}
  

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

int main(void) {
    int N, A;
    int large, small;

    cin >> N;
    cin >> A;

    large = N % 500;

    if (large==0) {
        cout << "Yes" << endl;
    }
    else {
        if (large <= A) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {a: i8, b: i8, c:i8};
    if a == b && b == c {
        println!("No")
    } else if a == b || a == c || c == b {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2112
#include <stdio.h>

int main(void)
{
	int time;
	
	time = 0;
	for (int i = 0; i < 4; i++){
		int t;
		scanf("%d", &t);
		time += t;
	}
	
	printf("%d\n%d\n", time / 60, time % 60);
	
	return (0);
}

Measured memory_bytes: 0
import java.util.Scanner;

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

        String n = sc.next();
        if (n.endsWith("2")) {
            System.out.println("hon");
        } else if (n.endsWith("4")) {
            System.out.println("hon");
        } else if (n.endsWith("5")) {
            System.out.println("hon");
        } else if (n.endsWith("7")) {
            System.out.println("hon");
        } else if (n.endsWith("9")) {
            System.out.println("hon");
        } else if (n.endsWith("0")) {
            System.out.println("pon");
        } else if (n.endsWith("1")) {
            System.out.println("pon");
        } else if (n.endsWith("6")) {
            System.out.println("pon");
        } else if (n.endsWith("8")) {
            System.out.println("pon");
        } else if(n.endsWith("3")){
            System.out.println("bon");
        }
    }
}


Measured memory_bytes: 35740
if __name__ == '__main__':
	n, m = map(int, input().split())
	coin_list = list(map(int, input().split()))
	dp = [50000] * (n + 1)
	dp[0] = 0

	for coin in coin_list:
		for i in range(n - coin + 1):
			if dp[i + coin] > dp[i] + 1:
				dp[i + coin] = dp[i] + 1

	print(dp[-1])


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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int main(){ _
	int n; ll k;
	cin >> n >> k;
	vector<vector<int>> p(61, vector<int>(n+1));
	for (int i = 1; i <= n; i++)
		cin >> p[0][i];
	for (int j = 1; j <= 60; j++)
		for (int i = 1; i <= n; i++)
			p[j][i] = p[j-1][ p[j-1][i] ];

	int curr = 1;
	for (int j = 60; j >= 0; j--){
		if (k&(1LL << j))
			curr = p[j][curr];
	}
	cout << curr << endl;
	
	exit(0);
}


Measured memory_bytes: 51800
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        if (S.contains("1") && S.contains("9") && S.contains("7") && S.contains("4")) {
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }
    }
}

Measured memory_bytes: 23764
#include <stdio.h>

int powy(int a,int b){
	int ans=1;
	for(int i=0;i<b;i++){
		ans=ans*a;
	}

	return ans;
}

int main(void){
	char str[100];
	scanf("%s",str);
	int str_length;
	for(str_length=0;str[str_length]!='\0';++str_length);
	
	int temp=str_length-1;
	printf("%c%d%c", str[0],str_length-2,str[temp]);
	return 0;
} 

Measured memory_bytes: 128
h, w = map(int, input().split())
blankw = [True] * w
blankh = [False] * h
data = []
for i in range(h):
    s = input()
    line = []
    if s.find("#") == -1:
        blankh[i] = True
    for j in range(w):
        line.append(s[j])
        if s[j] == "#":
            blankw[j] = False
    data.append(line)

for i in range(h):
    if blankh[i] is True:
        continue
    for j in range(w):
        if blankw[j] is True:
            continue
        print(data[i][j], end="")

    print("")

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

int main(){
  int n, x, a[200];
  cin >> n >> x;
  int minv = 1100;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    x -= a[i];
    minv = min(minv, a[i]);
  }
  int cnt = n + ( x / minv );
  cout << cnt << endl;
  return 0;
}


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

int main()
{
  int64_t N, M, a, b;
  cin >> N >> M;
  vector<int64_t> A(N + 1, 0);
  for (int i = 0; i < M; i++)
  {
    cin >> a >> b;
    A.at(a)++;
    A.at(b)++;
  }
  for (auto n : A)
  {
    if (n % 2)
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

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

int main() {
	// your code goes here
	int n,i;
	cin>>n;
	int A[n];
	for(i=0;i<n;i++)
		cin>>A[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(A[0]-A[1]);
	for(i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(A[i]-A[i-1]),dp[i-2]+abs(A[i]-A[i-2]));
		
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
N, M, X, Y = map(int, input().split())
x_li = list(map(int, input().split()))
y_li = list(map(int, input().split()))

max_x = max(x_li)
min_y = min(y_li)
for i in range(X + 1, Y + 1) :
    if max_x < i and min_y >= i :
        print("No War")
        exit()
print("War")


Measured memory_bytes: 3060
def next(num):
    s = str(num)
    length = len(s)

    index = -1

    for i in range(length - 1):
        if (s[i] > s[i + 1]) or (int(s[i]) <= 8 and s[i] == s[i + 1]):
            index = i

    ans = ""
    if index != -1:
        for i in range(length):
            if i <= index:
                ans += s[i]
            elif i == index + 1:
                ans += str(int(s[i]) + 1)
            else:
                if ans[-1] == "0":
                    ans += "0"
                else:
                    ans += str(int(ans[-1]) - 1)
    
    else:
        for i in range(length):
            if i == 0:
                ans += str(int(s[i]) + 1)
            else:
                if ans[-1] == "0":
                    ans += "0"
                else:
                    ans += str(int(ans[-1]) - 1)

    return int(ans)



K = int(input())

ans = 0
while K > 0:
    ans = next(ans)
    K -= 1

print(ans)

Measured memory_bytes: 3064
import itertools

s = str(input())
length = len(s)

bins = []
for i in range(2**(length-1)):
    bins.append(list(str(format(i,'b')).zfill(length-1)))

ans = 0
for i in range(2**(length-1)):
    tmp_str=s[0]
    for j in range(length-1):
        if(bins[i][j]=='0'):
            tmp_str += s[j+1]
        else:
            ans += int(tmp_str)
            tmp_str = s[j+1]
    ans+=int(tmp_str)
print(ans)
            
    

Measured memory_bytes: 39792
import sys
from collections import deque
from bisect import bisect_left

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(int(input()) for _ in range(n))

    que = deque([A[0]])
    for i in range(1, n):
        idx = bisect_left(que, A[i])
        if idx == 0:
            que.appendleft(A[i])
        else:
            idx -= 1
            que[idx] = A[i]
    print(len(que))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 13812
n,m=map(int,input().split())
alis=set([])
for i in range(m):
	a=int(input())
	alis.add(a)
if 1 in alis:
	dp=[1,0]
else:
	dp=[1,1]
for i in range(2,n+1):
	if i in alis:
		d=0
		dp.append(d)
	else:
		d=dp[i-2]+dp[i-1]
		dp.append(d)
print(dp[n]%(10**9+7))


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

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }

    int ans = n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i != j) {
                int p=x[j]-x[i], q=y[j]-y[i];
                int cnt = 0;
                for (int k = 0; k < n; k++) {
                    for (int l = 0; l < n; l++) {
                        if (k!=l) {
                            if (x[k]+p==x[l] && y[k]+q==y[l]) cnt++;
                        }
                    }
                }
                ans = min(ans, n-cnt);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>

int pasta(int a,int b,int c){
  if(a<b){
    if(c<a){
      return c;
    }
    else{
      return a;
    }
  }
  else{
    if(c<b){
      return c;
    }
    else{
      return b;
    }
  }
}

int drink(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

int main(){
  int p[3];
  int d[2];
  int ps,ds;
  int i;
  int ans;

  for(i=0;i<3;i++){
    scanf("%d",&p[i]);
  }
  for(i=0;i<2;i++){
    scanf("%d",&d[i]);
  }

  ans=pasta(p[0],p[1],p[2])+drink(d[0],d[1])-50;

  printf("%d\n",ans);

  return 0;
}

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

static const int N = 100;

int main() {
  int n, p[N + 1], m[N + 1][N + 1];
  cin >> n;
  for ( int i = 1; i <= n; i++ ) {
    cin >> p[i - 1] >> p[i];
  }

  for ( int i = 1; i <= n; i++ ) m[i][i] = 0;

  for ( int l = 2; l <= n; l++ ) {
    for ( int i = 1; i <= n - l + 1; i++ ) {
      int j = i + l - 1;
      m[i][j] = (1 << 21);
      for ( int k = i; k <= j - 1; k++ ) {
        m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
      }
    }
  }

  cout << m[1][n] << endl;

  return 0;
}



Measured memory_bytes: 3144
def solve():
    from sys import stdin
    f_i = stdin
    
    n = int(f_i.readline())
    A = list(map(int, f_i.readline().split()))
    q = int(f_i.readline())
    
    from bisect import bisect_left as bl
    print('\n'.join(str(bl(A, int(f_i.readline()))) for i in range(q)))

solve()


Measured memory_bytes: 24180
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

using psi = pair<string, int>;

int main() {
	int n; cin >> n;
	vector<psi> songs(n);
	for (int i = 0; i < n; ++i)
		cin >> songs[i].first >> songs[i].second;
	string x; cin >> x;
	int res = 0; bool flg = false;
	for (int i = 0; i < n; ++i) {
		if (flg) res += songs[i].second;
		if (songs[i].first == x) flg = true;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string.h>
using namespace  std;
int main(){


   string s1,s2;
   cin>>s1;
   cin>>s2;

int l=s2.size();
char m=s2.at(l-1);


//char ch = s2[s2.size()-1];
//strcat(s1, s2[s2.size()-1]);

s1.append(1,m);


if(s1!=s2){
cout<<"No"<<endl;
}
else{
cout<<"Yes"<<endl;
}
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  long a[200000];
  bool bo[200000];
  for(int i=0;i<n;i++) {
    cin >> a[i];
    bo[i] = false;
  }
  int count = 0;
  sort(a,a+n);
  for(int i=n-1;i>0;i--){
    long t = 1;
    if(bo[i]) continue;
    while(t<=a[i]) t <<= 1;
    long dst = t - a[i];
    int b=0,e=i;
    while(b+1<e){
      int m = (b+e)/2;
      if(dst<a[m] || (dst==a[m]&&bo[m])) e=m;
      else b=m;
    }
    if(a[b]!=dst || bo[b]) continue;
    count ++;
    bo[b] = true;
    //cout << b << ":" << a[b] << ", " << i << a[i] << endl;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int a,b,c[100],d=0;;
	cin>>a>>b;
	for(int i=0;i<a;i++){
		cin>>c[i];
		if(b-c[i]>c[i]){
			d=d+c[i];
		}else{
			d=d+b-c[i];
		}
	}
	cout<<d*2<<endl;
	

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int asc(const void *a, const void *b)
{
    return *(int *)b - *(int *)a;
}
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int a[300005];
    for (i = 0; i < 3 * n; i++)
        scanf("%d", &a[i]);
    qsort(a, 3 * n, sizeof(int), asc);
    unsigned long long int ans = 0;
    for (i = 1; i < 2 * n; i += 2)
        ans += (unsigned long long int)a[i];
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2556
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
        x: usize
    }

    let mut ans = 0;

    for i in 0..a+1 {
        for j in 0..b+1 {
            for k in 0..c+1 {
                if i * 500 + j * 100 + k * 50 == x {
            ans += 1;
        }
            }
        }
    }
    
    println!("{}", ans);
}


Measured memory_bytes: 4352
n,k=map(int,input().split())
A=sorted(list(map(int,input().split())))
F=sorted(list(map(int,input().split())),reverse=True)
ng=-1
ok=10**12+10
while ok-ng>1:
  mid=(ok+ng)//2
  a=0
  for i in range(n):
    a=a+max(0,A[i]-mid//F[i])
  if a>k:
    ng=mid
  else:
    ok=mid
print(ok)

Measured memory_bytes: 121036
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll ans = 0;
  for (ll i = 0; i < 5; ++i) {
    ll x;
    cin >> x;
    if (x == 0) {
      ans = i + 1;
    }
  }
  cout << ans << "\n";
}


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

template<class J>
struct semi_lattice {
	const J join;
	semi_lattice (J join) : join(join) { }
	template<class T> bool operator() (T &a, const T &b) {
		if (not join(a, b)) { a = b; return true; }
		return false;
	}
};

template<class J>
semi_lattice<J> make_sl(J join) {
	return semi_lattice<J>(join);
}

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	
	auto chmin = make_sl(less<int>());
	
	vector<int> dp(n, (1 << 30));
	dp[0] = 0;
	
	for (int i = 0; i < n; i++) {
		for (int j : {1, 2}) {
			if (i + j < n) {
				int cost = abs(h[i] - h[i + j]);
				chmin(dp[i + j], dp[i] + cost);
			}
		}
	}
	
	cout << dp[n - 1] << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7)puts("YES");
	else puts("NO");
	getchar();getchar();
	return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  
  if (a==b) cout << "Draw" << endl;
  else if (a==1 && b==13) cout << "Alice" << endl;
  else if (a==13 && b==1) cout << "Bob" << endl;
  else if (a>b) cout << "Alice" << endl;
  else if (a<b) cout << "Bob" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python
# coding: UTF-8

n, a, b = map(int,input().split())

if n == 1:
  print(1 if a == b else 0)
else:
  if b >= a:
    print((b - a)*(n - 2) + 1 if n != 1 else 1)
  else:
    print(0)

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

int main()
{
	string str;
	int n;
	int point=0,outcount=0,run=0;
	cin >> n;
	while(n != 0){
		cin >> str;
		if(str == "OUT"){
			outcount++;
			if(outcount == 3){
				cout << point << endl;
				point = 0;outcount=0;run=0;
				n--;
			}
		}
		else if(str == "HOMERUN"){
			point+=run+1;
			run = 0;
		}
		else if(str == "HIT"){
			run++;
			point += run/4;
			run -= run/4;
		}
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++) {
    cin >> W[i];
  }
  
  int ans = 100000;
  int s = 0;
  int s1 = 0;
  for (int i = 0; i < N; i++) {
    s += W[i];
  }
  for (int i = 0; i < N; i++) {
    s1 += W[i];
    ans = min(ans, abs(s - s1*2));
    if (s <= s1*2) {
      break;
    }
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] num = new int [N];
		int culc = 0;
		int temp = 0;
		int number = 0;
		boolean ans = true;
		
		for(int i = 0; i < N; i++) {
			num[i] = sc.nextInt();
		}

		for(int i = 0; i < N - 1; i++) {
			if(num[i + 1] < num[i]) {
				if(culc == 0) {
					temp = num[i];
					number = i;
					culc++;
				}else {
					num[number] = num[i + 1];
					num[i + 1] = temp;
				}
			}
		}
		
		for(int i = 0; i < N - 1; i++) {
			if(!(num[i] < num[i + 1])) {
				ans = false;
			}
		}
		
		if(ans) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		sc.close();
	}
}

Measured memory_bytes: 21844
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A;
  int B;
  rd(A);
  rd(B);
  wt_L(6-A-B);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191214-1

// --- original code ---
// {
//   int A, B;
//   rd(A,B);
//   wt(6-A-B);
// }


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

int main() {

    int n;
    string s;
    cin >> n >> s;

    if (n < 1 || n > 100){
        cout << "No" << endl;
        return 0;
    } 

    if ((n % 2) == 1){
        cout << "No" << endl;
        return 0;
    }
   
    if (n != s.size()){
        cout << "No" << endl;
        return 0;
    } 

    for (int i = 0; i < n; i++) {
        char c = s[i];
        //cout << "c = " << c << endl;
        if (isupper(c)){
            cout << "No" << endl;
            return 0;
        }
    }

    string harf = s.substr(n / 2);
    //cout << "harf = " + harf << endl;

    if (s == harf + harf){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define mod 1000000000+7
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  string s;
  cin>>s;
  int f=1,i=0,n;
  n=s.size();
  for(i;i<n;i++){
    char c;
    c=s.at(i);
    if(i%2==0){
      if(c=='L')break;
    }
    if(i%2==1){
      if(c=='R')break;
    }
  }

  if(i==n)f=0;

  if(f==1)cout<<"No";
  else cout<<"Yes";
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    *cumsum, = accumulate(A)
    C=Counter(cumsum)
    ans = C[0]
    for v,c in C.items():
        ans += c*(c-1)//2
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 44032
#include<bits/stdc++.h>
using namespace std;
int main()
{
int i,j,k,l,o,p,q,r,n,m,cnt=0,ma=100000000;
cin>>n;
int a[n];
for(i=0;i<n;i++)
cin>>a[i];
int dp[n];
dp[0]=0;
dp[1]=abs(a[1]-a[0]);
for(i=1;i<n-1;i++)
{
	dp[i+1]=min(dp[i]+abs(a[i+1]-a[i]),dp[i-1]+abs(a[i+1]-a[i-1]));
}
cout<<dp[n-1];
}


Measured memory_bytes: 1024
// {{{ Template for Competitive Programming
// -std=c++14 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

using vint = vector<int>;
using pint = pair<int, int>;

#define int long long
#define FOR(i, a, b)  for (int(i) = (a); (i) < (b); ++(i))
#define CFOR(i, a, b) for (int(i) = (a); (i) <= (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) >= (b); --(i))
#define rep(i, n) FOR((i), 0, (n))
#define crep(i, n) CFOR((i), 0, (n))
#define rrep(i, n) RFOR((i), (n), 0)
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x), 0)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline void debug(T a) { cout << "[ "; for (const auto e : a) { cout << e << ", "; } cout << "]" << endl; }

int ceil(int a, int b) { return (a + (b - 1)) / b; }

const int INF = 1'010'000'000'000'000'017LL;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// }}}

signed main() {
	int n;
	cin >> n;
	vector<int> b(n + 1);
	CFOR (i, 1, n - 1) cin >> b[i];
	b[n] = INF;

	int ans = b[1];
	CFOR (i, 2, n) {
		ans += min(b[i - 1], b[i]);
	}

	cout << ans << endl;

}



Measured memory_bytes: 256
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x: x, y = x.left if key < x.key else x.right, x
    if y is None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    else: print(inorder(root)); print(preorder(root))



Measured memory_bytes: 63540
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair< int , int > Pi;

int dp[150][77][11];
const int INF = 1 << 30;

int main(){
  int n, m;
  while(cin >> n >> m, n){
    vector< vector< Pi > > data(n);

    for(int i = 0; i < n; i++){
      int k;
      cin >> k;
      for(int j = 0; j < k; j++){
        int a, b;
        cin >> a >> b;
        data[i].push_back( make_pair( a, b));
      }
    }
    
    fill_n( **dp, 150 * 11 * 77, INF);
    for(int i = 0; i < min( 2, m + 1); i++){
      for(int j = 0; j < data[i].size(); j++){
        dp[i][m - i][j] = 0;
      }
    }

    int ret = INF;
    for(int i = 0; i < n; i++){
      for(int j = m; j >= 0; j--){
        for(int k = 0; k < data[i].size(); k++){
          if(dp[i][j][k] == INF) continue;
          if(i == n - 1){
            ret = min( ret, dp[i][j][k]);
          } else {
            for(int l = 0; l < data[i + 1].size(); l++){
              dp[i + 1][j][l] = min( dp[i + 1][j][l], dp[i][j][k] + (data[i][k].second + data[i + 1][l].second) * abs(data[i][k].first - data[i + 1][l].first));
            }
          }
          if(j == 0 || i == n - 1) continue;
          if(i == n - 2){
            ret = min( ret, dp[i][j][k]);
          } else {
            for(int l = 0; l < data[i + 2].size(); l++){
              dp[i + 2][j - 1][l] = min( dp[i + 2][j - 1][l], dp[i][j][k] + (data[i][k].second + data[i + 2][l].second) * abs(data[i][k].first - data[i + 2][l].first));
            }
          }
        }
      }
    }
    cout << ret << endl;
  }

}

Measured memory_bytes: 1720
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

S = list(s())
T = list(s())
N = len(S)
s = [[] for _ in range(26)]
t = [[] for _ in range(26)]
for i in range(N):
    s[ord(S[i])-97].append(i)
    t[ord(T[i])-97].append(i)
for i in range(26):
    s[i].sort()
    t[i].sort()
for i in range(26):
    if s[i] not in t:
        print('No')
        exit()
print('Yes')

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll X, t; cin >> X >> t;
  ll ans = 0;
  if(X - t < 0) ans = 0;
  else ans = X - t;
  cout << ans << endl;
}


Measured memory_bytes: 256
num, food_num = map(int, input().rstrip().split(" "))

food_list = [i + 1 for i in range(food_num)]

for i in range(num):
    input_line = input().rstrip().split(" ")
    input_line.pop(0)
    favorite_food = [int(j) for j in input_line]
    food_list = list(set(favorite_food) & set(food_list))

print(len(food_list))


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

using namespace std;

int main(){
    int n,i;
    int mx=0;
    string ans;
    cin >> n;
    int p[n];
    REP(i,n){
        cin>>p[i];
        if(p[i]-1!=i){
            mx++;
        }
    }
    if(mx>=3){
        ans="NO";
    }
    else{
        ans="YES";
    }



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

Measured memory_bytes: 256
ab = [int(x) for x in input().split()]

# Naive Algorithm
# m = min(ab)
# gcd = 1
# for i in range(2, int(m/2)):
#     if ab[0] % i == 0 and ab[1] % i == 0:
#         gcd = i
# print(gcd)

# Euclidean Algorithm
while True:
    min_i = ab.index(min(ab))
    max_i = ab.index(max(ab))
    r = ab[max_i] % ab[min_i]
    if r == 0:
        print(ab[min_i])
        break
    else:
        ab[max_i] = r

Measured memory_bytes: 5604
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0 ; i < N; i++  ){
			A[i] = sc.nextInt();
		}
		bubbleSort(A,N);
	}

	public static void bubbleSort(int [] A,int N){
		int flag =1;
		int cnt =0;
		while(flag == 1){
			flag = 0;
			for(int j = N-1; j >= 1;j--){
				if(A[j] < A[j-1]){
					int tmp = A[j-1];
					A[j-1] = A[j];
					A[j] = tmp;
					flag =1;
					cnt++;
				}
			}
		}
		show(A);
		System.out.println(cnt);
		return ;
	}
	public static void show(int[] A){
		StringBuilder sb = new StringBuilder();
		for (int i = 0 ; i < A.length; i++){
			sb.append(A[i]);
			if(i != A.length -1){
				sb.append(" ");
			}
		}
		System.out.println(sb); 
	}
	
}

Measured memory_bytes: 26220
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
using namespace std;
typedef long long LL;

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

	cout << a[0] << b[1] << c[2] << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

long long gcd(long long a, long long b) {
  if (b == 0) return a;

  return gcd(b, a % b);
}

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

ll A, B, C, D;

int main() {
  cin >> A >> B >> C >> D;
  ll ca = abs(C - A);
  ll db = abs(D - B);
  ll g = gcd(ca, db);

  cout << g * ((ca / g - 1) + (db / g - 1) + 1) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define MOD 1000000007
#define int long
int md[100000], dp[100000][13];
int cnt = 0, idx, idx2;
signed main(){
    string s, x;
    cin >> s;
    //前処理
    md[0] = 1; //[0]は1桁目
    for(int i = 1; i < s.size(); i++){
        md[i] = (md[i - 1] * 10) % 13;
    }
    //
    if(s[0] == '?'){
        idx = md[s.size() - 1];
        for(int j = 0; j < 10; j++){
            idx2 = idx * j;
            idx2 %= 13;
            dp[0][idx2]++;
        }
    }
    else{
        idx2 = md[s.size() - 1] * (s[0] - '0');
        idx2 %= 13;
        dp[0][idx2]++;
    }

    for(int i = 1; i < s.size(); i++){
        if(s[i] == '?'){
            idx = md[s.size() - i - 1];
            for(int j = 0; j < 10; j++){
                idx2 = idx * j;
                idx2 %= 13;
                for(int k = 0; k < 13; k++){
                    dp[i][(k + idx2) % 13] += dp[i - 1][k];
                    dp[i][(k + idx2) % 13] %= MOD;
                }
            }
        }
        else{
            idx2 = md[s.size() - i - 1] * (s[i] - '0');
            idx2 %= 13;
            for(int k = 0; k < 13; k++){
                dp[i][(k + idx2) % 13] += dp[i - 1][k];
                dp[i][(k + idx2) % 13] %= MOD;
            }
        }
    }
    cout << dp[s.size() - 1][5] << endl;
}

Measured memory_bytes: 11392