akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

vector<int> graph[100001];
bool moddist0[100001];
bool moddist1[100001];
bool moddist2[100001];
ll ans;

void bfs (int start, int goal){
	queue<pair<int, int> > que;
	que.push(make_pair(start, 0));

	while(!que.empty()){
		pair<int, int> p = que.front();
		que.pop();
		int now = p.first, dist = p.second;
		if (now == goal && dist%3 == 0){
			ans = dist/3;
			return;
		}
		for (auto x : graph[now]){
			if ((dist+1)%3 == 0){
				if (moddist0[x] == false){
					moddist0[x] = true;
					que.push(make_pair(x, dist+1));
				}
			}else if ((dist+1)%3 == 1){
				if (moddist1[x] == false){
					moddist1[x] = true;
					que.push(make_pair(x, dist+1));
				}
			}else{
				if (moddist2[x] == false){
					moddist2[x] = true;
					que.push(make_pair(x, dist+1));
				}
			}
		}

	}
	return;
}


int main(){
	int n, m, s, t;
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		int u, v;
		cin >> u >> v;
		graph[u].push_back(v);
	}
	cin >> s >> t;

	ans = MOD;
	moddist0[s] = true;
	bfs(s, t);

	if (ans == MOD) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <nmmintrin.h>
using namespace std;

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

    int n, c;
    cin >> n >> c;

    const int T = (int)1e5;

    vector<int> a(T);
    for (int i = 0; i < n; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        s--; t--; c--;

        for (int j = s; j <= t; j++) {
            a[j] |= 1 << c;
        }
    }

    int r = 0;
    for (int j = 0; j < T; j++) {
        r = max(r, __builtin_popcount(a[j]));
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 640
import * as fs from 'fs';

//in
// 3
// 3 1 2
// 2 5 4
// 3 6
//out
// 14
const main = (inp: string) => {

    const n: number = parseInt(inp.split('\n')[0]);
    const a: number[] = inp.split('\n')[1].split(' ').map(Number);
    const b: number[] = inp.split('\n')[2].split(' ').map(Number);
    const c: number[] = inp.split('\n')[3].split(' ').map(Number);

    let prevVal: number = -1;
    let ans: number = 0;
    a.map((val) => {
        ans += b[val - 1];
        if (prevVal === val - 1) {
            ans += c[prevVal - 1];
        }
        prevVal = val;
    });
    console.log(ans);
};

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


Measured memory_bytes: 7500
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

using namespace std;

typedef long long ll;

typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const ll inf=100000000000000;
struct edge{
	int to,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

#define MAX_N 100001
int dp[MAX_N]={};
bool d[MAX_N]={};
vector<edge> G[MAX_N];

int main() {
	int n;
	cin>>n;
	rep(i,n){
		int a1;
		cin>>a1;
		dp[a1]++;
	}
	bool flg=false;
	for(int i=n-1;i>0;--i){
		if(dp[i+1]==n-dp[i]){
			if(dp[i]<=i&&dp[i]>=2*i+2-n)flg=true;
			if((i==n-1||i==1)&&dp[i]==n)flg=true;
		}
	}
	yesno(flg);

	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int l,r,a,b,c,d;
int main(){
    cin>>a>>b>>c>>d;
    l=a+b;
    r=c+d;
    if(l>r)cout<<"Left"<<endl;
    if(l==r)cout<<"Balanced"<<endl;
    if(l<r)cout<<"Right"<<endl;
}


Measured memory_bytes: 256
base1 = 1009
base2 = 1013
mask = (1 << 32) - 1


def calculate_hash(f, r, c):
    global ph, pw, h
    tmp = [[0 for _ in range(c)] for _ in range(r)]
    dr, dc = r - ph, c - pw

    t1 = 1
    for _ in range(pw):
        t1 = (t1 * base1) & mask
    for i in range(r):
        e = 0
        for j in range(pw):
            e = e * base1 + f[i][j]
        for j in range(dc):
            tmp[i][j] = e
            e = (e * base1 - t1 * f[i][j] + f[i][j + pw]) & mask
        tmp[i][dc] = e

    t2 = 1
    for _ in range(ph):
        t2 = (t2 * base2) & mask
    for j in range(dc + 1):
        e = 0
        for i in range(ph):
            e = e * base2 + tmp[i][j]
        for i in range(dr):
            h[i][j] = e
            e = (e * base2 - t2 * tmp[i][j] + tmp[i + ph][j]) & mask
        h[dr][j] = e


th, tw = map(int, input().split())
t = [[ord(x) for x in input().strip()] for _ in range(th)]
ph, pw = map(int, input().split())
p = [[ord(x) for x in input().strip()] for _ in range(ph)]

if th >= ph and tw >= pw:
    h = [[0 for _ in range(tw)] for _ in range(th)]
    calculate_hash(p, ph, pw)
    key = h[0][0] & mask
    calculate_hash(t, th, tw)
    for i in range(th - ph + 1):
        for j in range(tw - pw + 1):
            if h[i][j] & mask == key:
                print(i, j)


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

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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;

int main(){
    int N;
    cin >> N;
    long long h[100010];
    long long dp[100010];
    for(int i = 0; i < N; i++){
        cin >> h[i];
        //dp[i] = INF;
    }
    for(int i = 0; i < N; i++){
        dp[i] = INF;
    }


    dp[0] = 0;

    for(int i = 1; i < N; i++){
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));

        if(i > 1){
            chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        }
    }

    cout << dp[N-1] << endl;


}

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

int main() {
  string s;
  cin>>s;
  string t;
  int k=0;
  for (int i=0; i<s.length(); i++) {
    if (s[i]=='0') {
      t.insert(k,"0");
      k++;
    } else if (s[i]=='1') {
      t.insert(k,"1");
      k++;
    } else {
      if (!t.empty()) {
        t.erase(t.begin()+k-1);
        k--;
      }
    }
  }
  cout<<t<<endl;
  return 0;
}


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

int main() {

  vector<vector<int>> data(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> data.at(i).at(j);
    }
  }

  int N;
  cin >> N;

  vector<int> b(N);
  for (int i = 0; i < N; i++) {
  cin >> b.at(i);
  }

  for(int k = 0; k < N; k++){
   for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
       if(data.at(i).at(j)==b.at(k)){
      data.at(i).at(j)=0;
        }
      }
    }
  }


  if(data.at(0).at(0)+data.at(0).at(1)+data.at(0).at(2)==0){
    cout << "Yes" << endl;
  }

  else if(data.at(1).at(0)+data.at(1).at(1)+data.at(1).at(2)==0){
    cout << "Yes" << endl;
  }

  else if(data.at(2).at(0)+data.at(2).at(1)+data.at(2).at(2)==0){
    cout << "Yes" << endl;
  }

  else if(data.at(0).at(0)+data.at(1).at(0)+data.at(2).at(0)==0){
  cout << "Yes" << endl;
  }

  else if(data.at(0).at(1)+data.at(1).at(1)+data.at(2).at(1)==0){
  cout << "Yes" << endl;
  }

  else if(data.at(0).at(2)+data.at(1).at(2)+data.at(2).at(2)==0){
  cout << "Yes" << endl;
  }

  else if(data.at(0).at(0)+data.at(1).at(1)+data.at(2).at(2)==0){
  cout << "Yes" << endl;
  }

  else if(data.at(2).at(0)+data.at(1).at(1)+data.at(0).at(2)==0){
  cout << "Yes" << endl;
  }

  else{
  cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int main(void) {
	int a[3];
	for (int i = 0;i < 3;i++)
		scanf(" %d ", &a[i]);
	int max = 0;
	for (int i = 0;i < 3;i++)
		if (max < a[i]) max = a[i];
	int ans = max * 9 + a[0] + a[1] + a[2];
	printf(" %d", ans);
}

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


int mn = 1<<30;
vector<ll> h;
ll n, a, b;
bool check(vector<ll> v, int x){
    for(int j = 0; j < n; ++j) {
        v[j] -= x*b;
    }
    ll cnt = 0;
    for(int j = 0; j < n; ++j){
        if(v[j] <= 0) continue;
        cnt += (v[j]+a-b-1)/(a-b);
        v[j] = 0;
    }
    return cnt <= x;
}


int main(){
    cin >> n >> a >> b;
    h.resize(n);
    for(int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    ll ok = 1000000000;
    ll ng = -1;

    while(abs(ok-ng) > 1) {
        ll mid = (ok+ng)/2;
        if(check(h, mid)) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 1792
h,w = list(map(int,input().split()))
l = [list(input()) for i in range(h)]

x = [1,-1,1,-1,0,0,1,-1]
y = [1,-1,0,0,1,-1,-1,1]
n_s = []
for i in range(h):
    n_l = []
    for j in range(w):
        cnt=0
        for k in range(8):
            if l[i][j]=="#":
                cnt = "#"
                break
            elif 0<=i+x[k]<h and 0<=j+y[k]<w:
                if l[i+x[k]][j+y[k]]=="#":
                    cnt+=1
            else:
                continue
        n_l.append(str(cnt))
    n_s.append(n_l)

for i in n_s:
    print("".join(i))




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

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  int a[100];
  for(int i=0;i<m;i++){
    cin >> a[i];
  }
  int left = 0;
  int i = 0;
  while(a[i] < x){
    left++;
    i++;
  }
  int right = m - left;
  cout << min(left,right) << endl;
  return 0;
}


Measured memory_bytes: 256
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):  # リストに重複した要素があるか判定（要素にリストがある場合）
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


s = input()
t = input()
# print(s)
# print(t)


def rotate(s):
    a = []
    a.append(s[-1])
    a.append(s[:-1])
    return ''.join(a)


def solve(r):
    if r == s:
        return False
    if r == t:
        return True
    return solve(rotate(r))


if s == t:
    print("Yes")
    exit()
if solve(rotate(s)):
    print("Yes")
else:
    print("No")


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

int main() {
  int n;
  string s;
  cin >> n >> s;
    
  if (n % 2 == 1) {
    cout << "No" << endl;
  } else {
    if (s.substr(0,n/2) == s.substr(n/2,n/2)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    COMinit();
    REP(i,K){
        LL ans = COM(K-1,i) * COM(N-K+1,i+1) % MOD;
        cout << ans << endl;
    }



}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define itn int
typedef long long ll;
typedef pair<int,int> p;

vector<vector<int>> other(100,vector<int>(10, 0));
vector<vector<int>> store(100,vector<int>(11, 0));
int ans = INT_MIN;
int n;

vector<int> tmp(10, 0);

void slove()
{
  int score = 0;
  for (int i = 0; i < n; i++){
    int count = 0;
    bool flag = false;
    for(int j : tmp)
    {
      if(j != 0) flag = true;
    }
    if(!flag) return;
    for (int j = 0; j < 10; j++){
      if (other[i][j] == tmp[j] && tmp[j] == 1) {
        count++;
      }
    }
    // cout << count << endl;
    // cout << store[i][count] << endl;
    score += store[i][count];
  }
  // cout << "=========-" << endl;
  // cout << score << endl;
  // cout << ans << endl;
  ans = max(score, ans);
  return;
}

void dfs(int pos)
{
  if(pos == 10)
  {
    slove();
    return;
  }
  else
  {
    tmp[pos] = 0;
    dfs(pos+1);
    tmp[pos] = 1;
    dfs(pos+1);
  }
}

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++){
    for (int j = 0; j < 10; j++){
      cin >> other[i][j];
    }
  }
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < 11; j++){
      cin >> store[i][j];
    }
  }
  dfs(0);
  dfs(1);

  cout << ans << endl;
  // cout << "================================" << endl;
  // for(itn i : store[0]) cout << i;
  // cout << endl;
  // for(itn i : store[1]) cout << i;

}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s;

int main() {
	cin >> s;
	rep(i,s.length()-1) {
		if (s.substr(i,2)=="AC") {
			cout << "Yes" << ln;
			return 0;
		}
	}
	cout << "No" << ln;
}

Measured memory_bytes: 256
import sys
n=int(input())
if n==3:
  print(61)
  sys.exit()
mod=10**9+7
l=['A','C','G','T']
NG=['AGC','GAC','ACG']
NG2=['AAGC','ACGC','AGGC','ATGC','AGAC','AGCC','AGTC']
L=[]
for i1 in range(4):
  for i2 in range(4):
    for i3 in range(4):
      for i4 in range(4):
        L.append(l[i1]+l[i2]+l[i3]+l[i4])
dp=[[0 for i in range(256)] for j in range(n+1)]
for i in range(256):
  if L[i][1:4] in NG or L[i][0:3] in NG or L[i] in NG2:
    dp[4][i]=0
  else:
    dp[4][i]=1
for j in range(5,n+1):
  for i in range(256):
    if L[i][1:4] in NG or L[i][0:3] in NG or L[i] in NG2:
      dp[j][i]=0
    else:
      for i2 in range(256):
        if L[i2][1:4]==L[i][0:3]:
          dp[j][i]+=dp[j-1][i2]
    dp[j][i]%=mod
print(sum(dp[n])%mod)

Measured memory_bytes: 43228
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >> y[i];
typedef long long int ll;
using namespace std;
bool isprime(int n,int k=2){
	if(n==1){
		return false;
	}
	if(n<k*k){
		return true;
	}
	if(n%k==0){
		return false;
	}
	return isprime(n,k+1);
}
int main(){
	int a,d,n,c;
	while(1){
		cin >> a>>d>>n;
		if(n==0)break;
		c=0;
		while(c<n){
			if(isprime(a))c++;
			a+=d;
		}
		cout << a-d << endl;
	}
}


Measured memory_bytes: 3084
n = input()
a = list(map(int, input().split()))
count = 0
for i in a:
    if i % 2 == 1:
        count += 1
    elif i % 6 == 0 or i % 10 == 0:
        count += 1
if count == int(n):
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000009
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int pow(int p,int r){
	int ans=1;
	while(r>0){
     if(r&1){
		 ans=((ans%mod)*(p%mod))%mod;
	 }
	 r=r>>1;
     p=((p%mod)*(p%mod))%mod;
	}
}
signed main() {
	garou;
	map<int,int> mp;
	for(int i=0;i<=1000;i++){
	  mp[pow(i,5)]=i;
	}
	int x;
	cin>>x;
    for(int i=0;i<=1000;i++){
		int a=pow(i,5)-x;
		if(mp.find(a)!=mp.end()){
			cout<<i<<' '<<mp[a];
			break;
		}
		if(mp.find(-a)!=mp.end()){
			cout<<i<<' '<<-(mp[-a]);
			break;
		}
	}
}

Measured memory_bytes: 4076
def isBingo(ary):
  ret = False
  if (
    (ary[0] == ary[1] == ary[2] == 0)
    or (ary[3] == ary[4] == ary[5] == 0)
    or (ary[6] == ary[7] == ary[8] == 0)
    or (ary[0] == ary[3] == ary[6] == 0)
    or (ary[1] == ary[4] == ary[7] == 0)
    or (ary[2] == ary[5] == ary[8] == 0)
    or (ary[0] == ary[4] == ary[8] == 0)
    or (ary[2] == ary[4] == ary[6] == 0)
  ):
    ret = True

  return ret

A = []
for i in range(3):
  row = input().split(" ")
  for n in row:
    A.append(int(n))

B = []
N = int(input())
for i in range(N):
  B.append(int(input()))
  
B = list(set(B))
C = list(map(lambda a: 0 if a in B else a, A))

print("Yes") if isBingo(C) else print("No")

Measured memory_bytes: 9272
#include<bits/stdc++.h>
using namespace std;
int m,n,a[10],st[]={0,2,5,5,4,5,6,3,7,6};
string dp[20000];
string maxx(string s,string t)
{
	if (s.size()>t.size()) return s;
	if (s.size()<t.size()) return t;
	for (int i=0;i<s.size();i++)
	  if (s[i]<t[i]) return t;
	  else if (s[i]>t[i]) return s;
	return s;
}
int main()
{
  cin>>n>>m;
  for (int i=0;i<m;i++)
    cin>>a[i];
  for (int i=0;i<=n;i++)
  {
  	if (i==0||dp[i].size()) 
  	{
  		for (int j=0;j<m;j++)
  		{
  			dp[i+st[a[j]]]=maxx(dp[i+st[a[j]]],char('0'+a[j])+dp[i]);
  		}
  	}
  }
  cout<<dp[n]<<endl;
  return 0;
}


Measured memory_bytes: 31744
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll n, m, i, j, k, now = 0, tmp, ans = 0;
  scanf("%lld%lld", &n, &m);
  ll sum[n];
  sum[0] = 0;
  for(i = 1; i < n; ++i) {
    scanf("%lld", &tmp);
    sum[i] = sum[i - 1] + tmp;
  }
  for(i = 0; i < m; ++i) {
    scanf("%lld", &tmp);
    ans += sum[now + (tmp > 0 ? tmp : 0)] - sum[now + (tmp < 0 ? tmp : 0)];
    now += tmp;
    ans %= 100000;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3504
fun main(args: Array<String>) = p18()

fun p18() {
    readLine()
    val sSet = readLine()!!.split(' ').map { it.toInt() }.toSet()
    readLine()
    val qList = readLine()!!.split(' ').map { it.toInt() }

    val answer = qList.count { it in sSet }

    println(answer)
}



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

int x, y, z, cnt;

int main(){
	scanf("%d%d%d",&x,&y,&z);
	x -= z;
	while(x>=y+z){
		cnt ++;
		x -= y+z;
	}
	printf("%d\n",cnt);
	return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  map<string,int> A;
  for(int i=0;i<N;i++){
    int K;
    cin >> K;
    for(int i=0;i<K;i++){
      string S;
      cin >> S;
      A[S]++;
    }
  }
  int count=0;
  for(auto it=A.begin();it!=A.end();it++){
    if((*it).second==N){
      count++;
    }
  }
  cout << count << endl;
} 

Measured memory_bytes: 3604
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
#from math import floor, ceil
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
#inf = 10**17
#mod = 10**9 + 7

n=I()
strs=[]
for i in range(n):
    strs.append(input().rstrip())
u=Counter(strs)
#print(u)
ans=n
for i in u.values():
    ans-=i-1
print(ans)
    


Measured memory_bytes: 38716
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,k;
    cin >> n >> k;
    long long v[n];
    multiset<long long>st;
    long long ans = 0;
    rep(i,n){
        cin >> v[i];
    }
    long long tem = 0;
    rep(i,min(n,k)+1){
        rep(j,i+1){
            rep(l,j){
                st.insert(v[l]);
            }
            rep(l,i-j){
                st.insert(v[n-1-l]);
            }
            auto itrr = st.begin();
            rep(l,k-i){
                if(st.size() == 0){
                    break;
                }
                if(itrr == st.end()){
                    break;
                }
                if(*itrr < 0){
                    tem-=*itrr;
                }
                else{
                    break;
                }   
                itrr++;
            }
            //cout << tem << endl;
            if(st.size()!=0){
                for(auto itr = st.begin();itr!=st.end();itr++){
                    tem+=*itr;
                }
            }
            ans = max(ans,tem);
            tem = 0;
            st = {};
            //cout << ans << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    set<int> values;
    for (int i = 0; i < n; ++i) {
        values.insert(a[i]);
    }
    cout << values.size() << endl;
    return 0;
}



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

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int n = in.i();
        int[] a = new int[n];

        for (int x = 1; ; x++) {
            int k = g(x, x, x);
            if (n < k) break;
            for (int y = x; ; y++) {
                k = g(x, y, y);
                if (n < k) break;
                for (int z = y; ; z++) {
                    k = g(x, y, z);
                    if (n < k) break;
                    int w = h(x, y, z);
                    a[k - 1] += w;
                }
            }
        }

        for (int i = 0; i < a.length; i++) {
            out.println(a[i]);
        }
        out.close();
    }

    static int g(int x, int y, int z) {
        return x * x + y * y + z * z + x * y + y * z + z * x;
    }

    static int h(int x, int y, int z) {
        return x == y ? (y == z ? 1 : 3) : (y == z ? 3 : 6);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 33864
#include <iostream>

using namespace std;

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

    char str[27] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    string ans = "";
    for(char c : s){
        for (int i = 0; i < 27; i++){
            char ch = str[i];
            if(c == ch){
                ans += str[(i + n) % 26];
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define all(v) v.begin(), v.end()
typedef int64_t lint;
using pint = pair<lint, int>;
using tint = tuple<int, int, int>;
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; }
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;

int main() {
	int N, K;
	cin >> N >> K;

	lint a=-INF, b=0, c=0, x, y, z;
	vector<int> P(N);
	rep(i, N) {
		cin >> P.at(i);
		P.at(i)--;
	}
	vector<lint> C(N);
	rep(i, N) {
		cin >> C.at(i);
	}

	vector<pint> v(N);
	rep(i, N) {
		v.at(i) = make_pair(0, -INF);
	}
	rep(i, N) {
		if (v.at(i).second != -INF) continue;
		b = 0;
		x = P.at(i);
		y = x;
		rep1(j, N) {
			b += C.at(x);
			x = P.at(x);
			if (x == y) {
				x = P.at(i);
				rep(k, N) {
					v.at(x) = make_pair(b, j);
					x = P.at(x);
					if (x == y) break;
				}
				break;
			}
		}
	}
	rep(i, N) {
		b = 0;
		x = P.at(i);
		y = x;
		rep1(j, N) {
			b += C.at(x);
			x = P.at(x);
			chmax(a, b);
			tie(c, z) = v.at(y);
			chmax(a, b+c*((K-j)/z));
			if (j == K) break;
			if (x == y) break;
		}
	}
	std::cout << a << '\n';
}


Measured memory_bytes: 3752
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

int main() {

	long N; cin >> N;
	vector<pair<pair<string, long>, long>> resta;

	for (int i = 0; i < N; i++) {
		string s; cin >> s;
		long p; cin >> p;

		resta.push_back(make_pair(make_pair(s,100 - p), i + 1));
	}

	sort(resta.begin(), resta.end());

	for (int i = 0; i < N; i++) cout << resta[i].second << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  bool n[102];
  memset(n,0,sizeof(n));
  int p,k;
  cin>>p>>k;
  while(k--)
  {
    int tem;
    cin>>tem;
    while(tem--)
    {
      int l;
      cin>>l;
      n[l]=1;
    }
  }
  int ans=0;
  for(int i=1;i<=p;i++)if(!n[i])ans++;
  cout<<ans;
}


Measured memory_bytes: 3608
n, m = map(int,input().split())
c = [0]*m
for i in range(n):
    k = list(map(int,input().split()))
    for j in k[1:]:
        c[j-1] += 1
a = 0
for i in c:
    if i == n:
        a += 1
print(a)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(){
 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    string s;
    cin >> s;
    if(s[0]=='7' || s[1] == '7' || s[2] == '7'){
    	cout << "Yes\n";
    }
    else{
    	cout << "No\n";
    }
 
	return 0;
}

Measured memory_bytes: 3652
import numpy as np
from scipy.sparse.csgraph import shortest_path

H, W = map(int, input().split())
m = []
for i in range(H):
  s = input()
  z = []
  for x in s:
    if x == '.':
      z.append(0)
    if x == '#':
      z.append(1)
  m.append(z)
m = np.array(m)

graph = np.array([[0] * (H * W) for _ in range(H * W)])
for i in range(H):
  for j in range(W):
    if m[i][j] == 0:
      if i-1 >= 0:
        if m[i-1][j] == 0:
          graph[W * i + j][W * (i-1) + j] = 1
      if i+1 <= H-1:
        if m[i+1][j] == 0:
          graph[W * i + j][W * (i+1) + j] = 1
      if j-1 >= 0:
        if m[i][j-1] == 0:
          graph[W * i + j][W * i + (j-1)] = 1
      if j+1 <= W-1:
        if m[i][j+1] == 0:
          graph[W * i + j][W * i + (j+1)] = 1

a = shortest_path(graph)
print(int(np.nanmax(a[a != np.inf])))


Measured memory_bytes: 20812
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;

int main()
{
    ll a,b,i,j,n,t;
    cin>>n;
    ll count=0;
    for(i=1;i<=n;i++)
    {
        count+=n/i;
        if(n%i==0) count--;
    }
    cout<<count;
}

Measured memory_bytes: 3632
n = gets.to_i
min_count = 100000
(n / (9 ** 5)).downto(0) do |a|
  count1 = a
  if count1 < min_count
    n1 = n - (9 ** 5) * a
    (n1 / (6 ** 6)).downto(0) do |b|
      count2 = count1 + b
      if count2 < min_count
        n2 = n1 - (6 ** 6) * b
        ([n2 / (6 ** 5), 5].min).downto(0) do |c|
          count3 = count2 + c
          if count3 < min_count
            n3 = n2 - (6 ** 5) * c
            ([n3 / (9 ** 4), 8].min).downto(0) do |d|
              count4 = count3 + d
              if count4 < min_count
                n4 = n3 - (9 ** 4) * d
                ([n4 / (6 ** 4), 5].min).downto(0) do |e|
                  count5 = count4 + e
                  if count5 < min_count
                    n5 = n4 - (6 ** 4) * e
                    ([n5 / (9 ** 3), 8].min).downto(0) do |f|
                      count6 = count5 + f
                      if count6 < min_count
                        n6 = n5 - (9 ** 3) * f
                        ([n6 / (6 ** 3), 5].min).downto(0) do |g|
                          count7 = count6 + g
                          if count7 < min_count
                            n7 = n6 - (6 ** 3) * g
                            ([n7 / (9 ** 2), 8].min).downto(0) do |h|
                              count8 = count7 + h
                              if count8 < min_count
                                n8 = n7 - (9 ** 2) * h
                                ([n8 / (6 ** 2), 5].min).downto(0) do |i|
                                  count9 = count8 + i
                                  if count9 < min_count
                                    n9 = n8 - (6 ** 2) * i
                                    ([n9 / 9, 8].min).downto(0) do |j|
                                      count10 = count9 + j
                                      if count10 < min_count
                                        n10 = n9 - 9 * j
                                        ([n10 / 6, 5].min).downto(0) do |k|
                                          count11 = count10 + k
                                          if count11 < min_count
                                            n11 = n10 - 6 * k
                                            l = n11
                                            count12 = count11 + l
                                            min_count = count12 if min_count > count12
                                          end
                                        end
                                      end
                                    end
                                  end
                                end
                              end
                            end
                          end
                        end
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end
puts min_count


Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;

int main() {
  int n;
  cin>>n;
  int a=n/100;
  int b=(n-a*100)/10;
  int c=(n-a*100-b*10);
  cout<<(10-a)*100+(10-b)*10+(10-c)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}

vector<int>v(maxn);

signed main()
{
    showoff;
    int n;
    cin >> n;
    FOR(i,1,n+1){
    	cin >> v[i];
    }
    sort(v.begin()+1,v.begin()+n+1);
    double tot = (v[1]*1.0l+v[2]*1.0l)/2;
    FOR(i,3,n+1){
    	tot = (tot+v[i]*1.0l)/2;
    }
    cout << tot;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...   

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}


int main(void){
    int d;
    cin >> d;
    int c[26];
    REP(i,26) cin >> c[i];
    int s[d][26];
    REP(i,d){
        REP(j,26) cin >> s[i][j];
    }

    /* scoring */
    int t[d];
    REP(i,d){
        cin >> t[i];
        t[i]--;
    }

    int last[26] = {0};
    
    
    ll satis = 0;
    for(int i = 0; i < d; i++){
        satis += s[i][t[i]];
        last[t[i]] = i+1;
        for(int j = 0; j < 26; j++){
            satis -= c[j] * (i + 1 - last[j]);
        }

        cout << satis << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
ans=0
n,m=map(int,input().split())
lst=[0]*n
zan=m
for i in range(n):
    a,b=map(int,input().split())
    lst[i]=[a,b]
lst.sort(key=lambda x: x[0])

for i in range(n):
    if lst[i][1]<=zan:
        zan-=lst[i][1]
        ans+=lst[i][1]*lst[i][0]
    elif lst[i][1]>zan:
        ans+=lst[i][0]*zan
        break
print(ans)

Measured memory_bytes: 21208
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
 
using namespace std;
const int MAX_N = 100000;
long long N, M, A[MAX_N];
long long dp[MAX_N + 1];
 
void solve() {
    long long res = 0;
    unordered_map<long long, long long> mp;
 
    for (int i = 0; i < N; i++) {
        dp[i + 1] = (dp[i] + A[i]) % M;
        mp[dp[i + 1]]++;
    }
 
    for (auto const &val: mp) {
        res += val.second * (val.second - 1) / 2;
        if (val.first == 0) {
            res += val.second;
        }
    }
 
    printf("%lld\n", res);
}
 
int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] = A[i] % M;
    }
    solve();
    return 0;
}

Measured memory_bytes: 4876
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

// Solution
public class Main {
  private static Scanner in;
  private static PrintWriter out;
  private static final String INPUT = ""; // input file name

  /**
   * Interactive get next command
   */
  static int get(int pos) {
    out.println(pos + 1);
    out.flush();
    return ni();
  }

  static void solve() {
    int n = ni();
    int[] arr = new int[n];

    for (int i = 0; i < n; i++) {
      arr[i] = ni();
    }

    int[] dp = new int[n];
    dp[0] = 0;
    dp[1] = Math.abs(arr[1] - arr[0]);

    for (int i = 2; i < n ; i++) {
      dp[i] = Math.min(
          dp[i - 2] + Math.abs(arr[i] - arr[i - 2]),
          dp[i - 1] + Math.abs(arr[i] - arr[i - 1])
      );
    }

    out.println(dp[n - 1]);
  }

  public static void main(String[] args) throws Exception {
    long S = System.currentTimeMillis();
    in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
    out = new PrintWriter(System.out);

    solve();
    out.flush();
    long G = System.currentTimeMillis();
    tr(G - S + "ms");
  }

  private static int gcd(int a, int b) {
    while (b != 0) {
      int t = b;
      b = a % b;
      a = t;
    }

    return a;
  }

  private static int ni() {
    return Integer.parseInt(in.next());
  }

  private static long nl() {
    return Long.parseLong(in.next());
  }

  // Math Utils
  private static int pi(int num, int pow) {
    int result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        result *= num;
      }

      num *= num;
      pow /= 2;
    }

    return result;
  }

  private static int pim(int num, int pow, int mod) {
    int result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        // keep collecting `odd` num in result
        result = (result * num) % mod;
      }

      num = (num * num) % mod;
      pow /= 2;
    }

    return result;
  }

  private static long pl(long num, long pow) {
    long result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        result *= num;
      }

      num *= num;
      pow /= 2;
    }

    return result;
  }

  private static long plm(long num, long pow, long mod) {
    long result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        // keep collecting `odd` num in result
        result = (result * num) % mod;
      }

      num = (num * num) % mod;
      pow /= 2;
    }

    return result;
  }

  static void tr(Object... o) {
    if (!INPUT.isEmpty())
      out.println(Arrays.deepToString(o));
  }
}


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

int main()
{
	int A, B;
	cin >> A >> B;
	int plus, minus, kurosu;
	plus = A + B;
	minus = A - B;
	kurosu = A * B;
	int answer;
	answer = max(plus, max(minus, kurosu));
	cout << answer;
	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}

string S,T,U;
int a,b,c;
vl A,B;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
    ld R;cin>>R;
    cout << 2*PI*R<<endl;
}

Measured memory_bytes: 3804
n,k = map(int,input().split())
S = list(input())
ans=0
cnt=0
for i in range(n-1):
    if S[i]!=S[i+1]:
        cnt+=1
    else:
        ans+=1

if cnt <= k*2:
    print(n-1)
else:
    print(ans+k*2)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool A, B;
  A = B = false;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'A') A = true;
    if (s[i] == 'B') B = true;
  }
  puts((A&B)?"Yes":"No");
  return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <tuple>
#include <queue>
#define PII pair<int, int>
#define T3I tuple<int, int, int>
using namespace std;

typedef long long ll;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

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

    int n, r;
    cin >> n >> r;

    int d = (10 - n)*100;
    if(d < 0) {
        cout << r << endl;
    }else {
        cout << r+d << endl;
    }
}

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    ll n, m; cin >> n >> m;
    V<V<ll> > v(n + 1);
    V<P<ll, ll> > w(m);
    for(int i = 0; i < m; i++){
        ll p, y; cin >> p >> y;
        v[p].push_back(y);
        w[i] = make_pair(p, y);
    }

    map<ll, ll> x;
    for(int i = 1; i <= n; i++){
        sort(all(v[i]));
        for(int j = 0; j < v[i].size(); j++){
            x[v[i][j]] = j + 1;
        }
    }

    for(int i = 0; i < m; i++){
        int a = w[i].first;
        int b = x[w[i].second];
        printf("%06d", a);
        printf("%06d", b);
        cout << "\n";
    }

}


Measured memory_bytes: 14720
n=int(input())
h=list(map(int,input().split()))
count=0
maxcount=0

for i in range(n-1):
  if h[i]>=h[i+1]:
    count+=1
  elif h[i]<h[i+1]:
    if count>=maxcount:
      maxcount=count
    count=0
  if i==n-2:
    if count>=maxcount:
      maxcount=count
      
print(maxcount)

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

namespace ABC125_C
{
    class Program
    {
        static void Main(string[] args)
        {
            
            
            var N = int.Parse(Console.ReadLine());
            var str1 = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int max = 0;

            List<int> Number = new List<int>();
            
            for(var x=0;x<N;x++)
            {
                Number.Add(str1[x]);
            }

            var L = Enumerable.Repeat(0, N).ToList();
            for(var i = 0; i < N; ++i)
            {
                L[i] = i == 0 ? 0 : Gcd(L[i - 1], Number[i - 1]);
            }

            var R = Enumerable.Repeat(0, N).ToList();
            for(var i = N - 1; i >= 0; --i)
            {
                R[i] = i == N - 1 ? 0 : Gcd(R[i + 1], Number[i + 1]);
            }
            for(var i = 0; i < N; ++i)
            {
                max = Math.Max(Gcd(L[i], R[i]), max);
            }

            Console.WriteLine(max);

        }

        public static int Gcd(int a, int b)
        {
            if (a < b)
                return Gcd(b, a);
            while(b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}


Measured memory_bytes: 31324
include Math
class Point
  def initialize(x, y)
    @x = x.to_f
    @y = y.to_f
  end
  def distance(p)
    dx = @x - p.x
    dy = @y - p.y
    sqrt(dx * dx + dy * dy).to_f
  end
  def getX()
    @x
  end
  def getY()
    @y
  end
  def internally_dividing_point(p,m,n)
    Point.new(((n*@x+m*p.x)/(m+n)).to_f,((n*@y+m*p.y)/(m+n)).to_f)
  end
  def getC(p)
    cx=(((p.x-@x)*Math.cos(Math::PI/3)-(p.y-@y)*Math.sin(Math::PI/3))+@x).to_f
    cy=(((p.x-@x)*Math.sin(Math::PI/3)+(p.y-@y)*Math.cos(Math::PI/3))+@y).to_f
    Point.new(cx,cy)
  end
  protected
  attr_reader :x, :y
end
queue = Array.new()
queue.push(Point.new(0,0))
queue.push(Point.new(100,0))
queue.push(Point.new(0,0))
#p queue[0].internally_dividing_point(queue[1],1,2)
n = gets.chomp.to_i

n.times {|i|
 a,e = queue.shift,queue.shift
while e.getX() != 0
  
  b = a.internally_dividing_point(e,1,2)
  d = a.internally_dividing_point(e,2,1)
  c = b.getC(d)
  #p b,d,c
  queue.push(a) #first vertex
  queue.push(b)
  queue.push(c)
  queue.push(d)
  a,e = e,queue.shift
  if e.getX() == 0
    queue.push(a)
    queue.push(Point.new(0,0))
  end
end
}
queue.pop

#p queue[0].getX()
(queue.size).times {|i| 
  printf("%f %f\n",(queue[i].getX()),(queue[i].getY()))
}

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

bool comp(const tuple<string, int, int> &t1, const tuple<string, int, int> &t2){
	if(get<0>(t1) == get<0>(t2))
		return get<1>(t1) > get<1>(t2);
	else
		return get<0>(t1) < get<0>(t2);
}

int main(){
	int n;
	scanf("%d", &n);
	vector< tuple<string, int, int> > t(n);
	for(int i=0; i < n; i++) {
		cin >> get<0>(t.at(i)) >> get<1>(t.at(i));
		get<2>(t.at(i)) = i+1;
	}
	sort(t.begin(), t.end(), comp);
	for(int i=0; i < n; i++) {
		printf("%d\n", get<2>(t.at(i)));
	}
}


Measured memory_bytes: 256