akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

bool isprime[1000000];

void solve(int n) {
    int cnt = 0;
    for (int i = 2; i <= n ; ++i) {
        if(isprime[i]) {
            cnt++;
            for (int j = i*2; j <=n ; j = j + i) {
                isprime[j] = false;
            }
        }
    }
    cout << cnt << endl;
}

int main() {
    int n;
    while(cin>>n) {
        for (int i = 0; i <= n; ++i) {
            isprime[i] = true;
        }
        isprime[0] = isprime[1] = false;
        solve(n);
    }


    return 0;
}



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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

vector<int> to[100005];

int main(void){

	int N, M; cin >> N >> M;

	REP(i,M){
		int a, b; cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	queue<int> q;
	vector<int> dist(N, INF);
	vector<int> pre(N, -1);

	dist[0] = 0;
	q.push(0);
	while(!q.empty()){
		int v = q.front(); q.pop();
		for(int u : to[v]){
			if(dist[u] != INF) continue;
			dist[u] = dist[v] + 1;
			pre[u] = v;
			q.push(u);
		}
	}

	cout << "Yes" << endl;
	REP(i,N){
		if(i == 0) continue;
		int ans = pre[i];
		ans++;
		cout << ans << endl;
	}


	return 0;

}


Measured memory_bytes: 10532
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define WHITE 0
#define BLACK 1
typedef long long ll;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
string s;
int k;
int INFi=1000000000;
ll INFl=1000000000000000;

struct UnionFind{
    vector<int> par;//初期化
    vector<int> rank;//高さ
    UnionFind(int n=0):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);//経路圧縮
    }
    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) return;
        if(rank[rx]<rank[ry]) rank[rx]=ry;
        else rank[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
struct edge{int from,to,cost;};
vector<edge> es(100); //辺の集合
vector<int> d(100,INFi);//最短距離
int V,E;//頂点数、辺数

int main(){
    int N,D;cin>>N>>D;
    int X[N][D];
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin>>X[i][j];
        }
    }
    int count=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int s=0;
            for(int k=0;k<D;k++){
                s+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            double d=pow(s,0.5);
            int di=d;
            if(d==di) count++;
        }
    }
    cout<<count<<endl;
}




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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll h,w,m;
  cin>>h>>w>>m;
  vll y(m),x(m);
  vpl hnum(h),wnum(w);
  REP(i,h)hnum[i].SE=i;
  REP(i,w)wnum[i].SE=i;
  map<pll,ll> ex;
  REP(i,m){
    cin>>y[i]>>x[i];
    y[i]--; x[i]--;
    ex[pll(x[i],y[i])]=1;
    hnum[y[i]].FI++;
    wnum[x[i]].FI++;
  }

  sort(ALL(hnum),greater<pll>());
  sort(ALL(wnum),greater<pll>());

  ll ans=0;
  ll hmax=hnum[0].FI;
  ll wmax=wnum[0].FI;
  for(auto p:hnum){
    if(p.FI<hmax)
      break;

    ll r=0;
    for(auto q:wnum){
      if(q.FI<wmax)
        break;
      ll res=p.FI+q.FI;
      res-=ex[pll(q.SE,p.SE)];
      if(ex[pll(q.SE,p.SE)]==1){
        if(r==0)
          r++;
        else
          continue;
      }
      if(res<=ans)
        break;
      ans=max(ans,res);
    }
  }

  cout<<ans<<endl;

}



Measured memory_bytes: 54656
#include<bits/stdc++.h>
#define int long long
using namespace std;



int32_t main(){
	
	string s1,s2;cin>>s1>>s2;
	int c=0;
	for(int i=0;i<s1.length();i++){
		if(s1[i]==s2[i]){
			c++;
		}
	}
	cout<<c<<endl;

	return 0;
}

Measured memory_bytes: 256
//ABC137 B - B - One Clue
//20190905

using System;
using System;
using System.Linq;
using static System.Math;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");

            int K,X;
            var INPUT = Console.ReadLine().Split().Select(int.Parse).ToArray();
            K = INPUT[0];
            X = INPUT[1];

            for(int i =X-K+1;i<X+K;i++)
            {
                Console.Write(i + " ");
            }

            Console.WriteLine();
            
        }
    }
}


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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

ll dp[2][100001];

int main(){
    ll N,W;
    cin >> N >> W;
    ll w,v;
    cin >> w >> v;
    dp[0][w] = v;

    for(int i=1; i<N; i++){
        cin >> w >> v;
        rep(j,W+1){
            dp[1][j] = dp[0][j];
            if(j-w>=0) dp[1][j] = max(dp[1][j], dp[0][j-w]+v);
        }
        rep(j,W+1){
            dp[0][j] = dp[1][j];
            dp[1][j] = 0;
        }
    }

    ll ans = 0;
    rep(j,W+1){
        ans = max(ans, dp[0][j]);
    }
    cout << ans;
    
    return 0;
}


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

int main(void) {
    long long A, B, C, K;
    std::cin >> A >> B >> C >> K;
    if (A >= K) {
        printf("%lld\n", K);
    } else if (A + B >= K) {
        printf("%lld\n", A);
    } else {
        long long cc = K - (A + B);
        printf("%lld\n", A - cc);
    }

    return 0;
}


Measured memory_bytes: 3764
#include<iostream>
#include<string>

using namespace std;

int main() {
	
	string A;
	getline(cin, A);
	
	for(int i=0;i<A.length();i++)
	{
		if( A[i] >= 'D' && A[i] <= 'Z') {
		A[i] -= 3;
		cout << A[i];
	}
		else if( A[i] >= 'A' && A[i] <= 'C' ) {
		A[i] += 23;	
		cout << A[i];
	}
	}
	cout << "\n";

	return 0;
}


Measured memory_bytes: 3176
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  struct node *migi;
  struct node *hidari;
  struct node *oya;
  int kagi;
};
typedef struct node * Node;
int max;

Node root,NIL;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  int H;
  
  z = malloc(sizeof(struct node));
  z->kagi = k;
  z->hidari = NIL;
  z->migi = NIL;
  while(x != NIL){
    y = x;
    if(z->kagi < x->kagi){
      x = x->hidari;
    }
    else{
      x = x->migi;
    }
  }
  z->oya = y;
  if( y == NIL){
    root = z;
  }
  else{
    if(z->kagi < y->kagi){
      y->hidari = z;
    }
    else{
      y->migi = z;
    }
  }
}

void inorder( Node u){
  if( u == NIL) return;
  inorder(u->hidari);
  printf(" %d",u->kagi);
  inorder(u->migi);
}
void preorder( Node u){
  if(u == NIL)return;
  printf(" %d",u->kagi);
  preorder(u->hidari);
  preorder(u->migi);
}

int main(){
  int n, i, a;
  char A[20];
  scanf("%d", &n);
  max = 0;
  for(i = 0; i < n; i++){
    scanf("%s",A);
    if( strcmp(A, "insert") == 0){
      scanf("%d",&a);
      insert(a);
    }
    else if( strcmp(A, "print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25132
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a[256],n;
  for(int i=0;i<10;i++)a['0'+i]=i;
  for(int i=0;i<26;i++)a['a'+i]=10+i;
  for(int i=0;i<26;i++)a['A'+i]=36+i;
  cin>>n;
  int b,an1=0,an2=0;
  while(n--){
    int num=0;
    string s;
    cin>>b>>s;
    for(int i=s.size()-1,k=1;i>=0;i--,k*=b)num+=k*a[s[i]];
    int t=0;
    while(num){
      if(num%2)t++;
      else{
    if(t==1)an1++;
    if(t>=2)an2++;
    t=0;      
      }
      num/=2;
    }
      if(t==1)an1++;
      if(t>=2)an2++;
  }
  if(an2>0||an1%2)cout<<"win"<<endl;
  else cout <<"lose"<<endl;
  return 0;
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    public static ArrayList<Long> list;
    static void solve(InputReader in, PrintWriter out){
        list = new ArrayList<>();
        int k = in.ni();
        for (long i = 1; i <= 9; i++) {
            list.add(i);
            dfs(i);
        }
        Collections.sort(list);
        out.println(list.get(k-1));
    }
    public static void dfs(long x){
        if(x > 3234566667L) return;
        long f = x-x/10*10;
        list.add(10*x+f);
        dfs(10*x+f);
        if(f!=0){
            list.add(10*x+f-1);
            dfs(10*x+f-1);
        }
        if(f!=9){
            list.add(10*x+f+1);
            dfs(10*x+f+1);
        }
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 38916
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

typedef struct {

  int No;
  int Protein;  //タンパク質
  int Lipid;    //脂質
  int Carb;     //炭水化物
  int Cal;      //合計カロリー

} Nutri;

Nutri Data[1002];
int n,cnt=0;

int GetNo(Nutri x);
int GetPro(Nutri x);
int GetLip(Nutri x);
int GetCar(Nutri x);
int GetCal(Nutri x);
void DataScan(void);
Nutri NutriScan(void);
int DataProcessing(Nutri x,int i);

int main(){

  Nutri x;
  int i,a;

  while(1){

    scanf("%d",&n);
    if(n==0)break;
    
    DataScan();
    
    x=NutriScan();

    for(i=1;i<=n;i++){

      a=DataProcessing(x,i);

    }

    if(n-a==0){
      printf("NA\n");
    }
 
    cnt=0;   
  }
  
  return 0;
}
int GetNo(Nutri x){
  return x.No;
}
int GetPro(Nutri x){
  return x.Protein;
}
int GetLip(Nutri x){
  return x.Lipid;
}
int GetCar(Nutri x){
  return x.Carb;
}
int GetCal(Nutri x){
  return x.Cal;
}

void DataScan(void){

  int i,a;

  for(i=1;i<=n;i++){

    scanf("%d %d %d %d",&Data[i].No,&Data[i].Protein,&Data[i].Lipid,&Data[i].Carb);

    Data[i].Cal=Data[i].Protein*4+Data[i].Carb*4+Data[i].Lipid*9;

  }

  return;
}

Nutri NutriScan(void){

  Nutri x;
  int i;

  scanf("%d %d %d %d",&x.Protein,&x.Lipid,&x.Carb,&x.Cal);

  return x;

}
int DataProcessing(Nutri x,int i){

  if(GetPro(Data[i])>GetPro(x) || GetLip(Data[i])>GetLip(x) || GetCar(Data[i])>GetCar(x) || GetCal(Data[i])>GetCal(x)){
    cnt++;
  } else {
    printf("%d\n",GetNo(Data[i]));
  }

  return cnt;

}

Measured memory_bytes: 1216
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define mod 1000000007
#define ll long long int
#define ull unsigned long long int 
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power)
{
    ll ans=1;
    while(power>0)
    {
        if(power%2==1)
        {
            ans=(ans*B)%mod;
        }
        B=(B*B)%mod;
        power/=2;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1)
    { 
        return false; 
    }
    if(n<=3)
    { 
        return true;
    } 
    if(n%2==0 || n%3==0) 
    {
        return false; 
    }
    for(ll i=5; i*i<=n; i+=6) 
    {
        if(n%i==0 || n%(i+2)==0) 
        {
            return false; 
        }
    }
    return true; 
}
using namespace std;
const ll maxi= 1e6+4;
ll fac[maxi], finv[maxi], inv[maxi];
void run() 
{
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    loop(i,2,maxi)
    {
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll ans(ll x, ll y)
{
    if(x<y)
    {
        return 0;
    }
    if(x<0 || y<0)
    {
        return 0;
    }
    return ((fac[x]%mod)*(finv[y]*finv[x-y]%mod))%mod;
}
int main() 
{
    FAST
    FO
    FI
    int x,y;
    IN x>>y;
    if((x+y)%3!=0)
    {
        OUT 0<<endl
    } 
    else 
    {
        int temp= (x+y)/3;
        if((x-temp<0) || (2*temp-x<0))
        {
            OUT 0<<endl
        } 
        else 
        {
            run();
            OUT ans(temp,x-temp)<<endl
        }
    }
    return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
    
using namespace std;
    
#define endl "\n"
#define ll unsigned long long
#define int long long int
#define vi vector <int >
#define vii vector < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define double long double
#define a first
#define b second

bool f(int a, int b) {
    return a >b;
}

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);	
    int h, n, k, sum = 0;
    cin >> n >> k;
    vi arr(n);
    forn(i,n){
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end(), f);
    int ans = 0;
    rep(i, k, n){
        ans += arr[i];
    }
    cout << ans  << endl;

    return 0;
}

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

int main(){
   int n, length = 0, total = 0;
 
   cin >> n;
 
  for(int i = 1; i <= n; i++){
      length = 0;
     for(int j = i; j > 0; j /= 10){
        length ++;  
      }
        if(length % 2 == 1){
           total ++;
        }
    }
    cout << total;
}
// #include <bits/stdc++.h>
// using namespace std;

// int main() {
//   int N;
//   cin >> N;
//   int count = 0;

//   for(int i = 0; i < N; i++){
//       if(N < 10){
//           count = N;
//       }
//       if(N >= 10 && N < 100){
//           count = 9;
//       }
//       if(N >= 100 && N < 1000){
//           count = N - 90;
//       }
//       if(N >= 1000 && N < 10000){
//           count = N - 90;
//       }
//       if(N >= 10000 && N < 100000){
//           count = N - 9090;
//       }
//       if(N >= 100000 && N < 1000000){
//           count = N - 9091;
//       }
//       if(N == 1000000){
//           count = N - 9092;
//       }
//     }
//     cout << count;
// }

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;
	
	while (scanf("%d %d", &a, &b) != EOF){
		a += b;
		for (b = 0; a; b++){
			a /= 10;
		}
		printf("%d\n", b);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  if ((N/10)%111 == 0 || (N-N/1000*1000) == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;

int n;

void con(int x, int y) {
    printf("%d %d\n", x, y);
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n;
    if (n == (n & (-n))) {
        puts("No");
        return 0;
    } else 
    puts("Yes");
    int m = n % 2 ? n : n - 1;
    con(2, 3), con(2 + n, 3 + n), con(1, 2), con(1, 3 + n), con(1 + n, 2 + n);
    for (int i = 4; i <= m; i += 2) {
        con(i, i + 1), con(i + n, i + 1 + n);
        con(1, i), con(1, i + 1 + n);
    }
    if (n % 2 == 0) {
        int tmp;
        for (int i = 30; i >= 1; --i)
            if ((1 << i) & n) {
                tmp = 1 << i;
                break;
            }
        int t = n ^ tmp ^ 1;
        con(tmp, n), con(t + n, n + n);
    }
    return 0;
}


Measured memory_bytes: 2304
n = int(input())

def F(a, b):
    a = str(a)
    b = str(b)
    return max(len(a), len(b))
ans = 11
for a in range(1, int(n**0.5) + 1):
    if n % a == 0:
        b = n // a
        ans = min(ans, F(a, b))
print(ans)



Measured memory_bytes: 3060
N=input()
K=int(input())

dig=len(str(N))

dp=[[[0,0,0,0] for _ in range(2)] for i in range(dig+1)]
#dp[i][j][k]は上からi桁目まで，tightかどうか，0ではない数の個数(0,1,2,3)

n=int(N[0])
dp[1][0][0]=1
dp[1][0][1]=n-1
dp[1][1][1]=1


for i in range(1,dig):
    for j in range(2):
        if j==0:
            dp[i+1][j][0]=dp[i][j][0]
            dp[i+1][j][1]+=dp[i][j][0]*9+dp[i][j][1]
            dp[i+1][j][2]+=dp[i][j][1]*9+dp[i][j][2]
            dp[i+1][j][3]+=dp[i][j][2]*9+dp[i][j][3]
        if j==1:
            if N[i]=="0":
                for k in range(4):
                    dp[i+1][j][k]=dp[i][j][k]
            else:
                #tight to tight
                dp[i+1][j][1]=dp[i][j][0]
                dp[i+1][j][2]=dp[i][j][1]
                dp[i+1][j][3]=dp[i][j][2]
                
                #tight to not tight
                n=int(N[i])
                dp[i+1][j-1][1]+=dp[i][j][0]*(n-1) + dp[i][j][1]
                dp[i+1][j-1][2]+=dp[i][j][1]*(n-1) + dp[i][j][2]
                dp[i+1][j-1][3]+=dp[i][j][2]*(n-1) + dp[i][j][3]
                
            
ans=dp[-1][0][K]+dp[-1][1][K]
print(ans)



Measured memory_bytes: 38256
N = int(input())
B = list(map(int, input().split()))
A = [0 for _ in range(N)]
A[0], A[1] = B[0], B[0]

for i in range(1, N - 1):
    b = B[i]
    A[i + 1] = b
    if b < max(A[i], A[i + 1]):
        A[i], A[i + 1] = b, b

print(sum(A))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
// #define DEBUG 100
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll >;
 
const ll oo = 1e9 + 7;
const ll mod = 1e9 + 7,maxn = 2e6 + 100, maxm = 1e3+100;
const double PI = acos(-1);

ll solve(vector<ll> &vs, int n, ll k){
    ll a = 1, b = oo, best;

    while (a <= b){
        ll mid = (a + b) / 2, cnt = 0;
        for (auto it: vs) {
            cnt += (it/mid - (it%mid == 0? 1 : 0));
        }
        if (cnt > k){
            a = mid + 1;
        }
        else{
            best = mid;
            b = mid - 1;
        }
    }
    return best;
}
int main (){
    ios_base::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;

    vector<ll> vs(n);

    for (int i=0; i<n; i++){
        cin >> vs[i];
    }

    ll ans = solve(vs, n, k);

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

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

public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] first = br.readLine().split(" ", 2);
 		int n = Integer.parseInt(first[0]);
		int q = Integer.parseInt(first[1]);
		String[] nums = br.readLine().split(" ", n);
		Query[] queries = new Query[q];
		for (int i = 0; i < q; i++) {
		    String[] line = br.readLine().split(" ", 2);
		    queries[i] = new Query(i, Integer.parseInt(line[0]), Integer.parseInt(line[1]));
		}
		Arrays.sort(queries);
		int[] idxes = new int[n + 1];
		BinaryIndexedTree bit = new BinaryIndexedTree(n + 1);
		int[] ans = new int[q];
		int idx = 0;
		for (int i = 0; i < n; i++) {
		    int y = Integer.parseInt(nums[i]);
		    if (idxes[y] > 0) {
		        bit.add(idxes[y], - 1);
		    }
		    bit.add(i + 1, 1);
		    idxes[y] = i + 1;
		    while (idx < q && queries[idx].right == i + 1) {
		        ans[queries[idx].idx] = bit.getSum(queries[idx].left, queries[idx].right);
		        idx++;
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int x : ans) {
		    sb.append(x).append("\n");
		}
		System.out.print(sb);
	}
	
	static class Query implements Comparable<Query> {
	    int idx;
	    int left;
	    int right;
	    
	    public Query(int idx, int left, int right) {
	        this.idx = idx;
	        this.left = left;
	        this.right = right;
	    }
	    
	    public int compareTo(Query another) {
	        return right - another.right;
	    }
	}
}

class BinaryIndexedTree {
    int size;
    int[] tree;
    
    public BinaryIndexedTree(int size) {
        this.size = size;
        tree = new int[size];
    }
    
    public void add(int idx, int value) {
        int mask = 1;
        while (idx < size) {
            if ((idx & mask) != 0) {
                tree[idx] += value;
                idx += mask;
            }
            mask <<= 1;
        }
    }
    
    public int getSum(int from, int to) {
        return getSum(to) - getSum(from - 1);
    }
    
    public int getSum(int x) {
        int mask = 1;
        int ans = 0;
        while (x > 0) {
            if ((x & mask) != 0) {
                ans += tree[x];
                x -= mask;
            }
            mask <<= 1;
        }
        return ans;
    }
}


Measured memory_bytes: 108516
def is_odd(number):
    return number % 2 != 0
import sys

def draw_line(chk1, chk2, W):
    print((chk1 + chk2) * int(W / 2), end='')
    if is_odd(W):print(chk1, end='')
    print()
    
def draw_odd_line(W):
    draw_line('#', '.', W)
    
def draw_even_line(W):
    draw_line('.', '#', W)

def draw(H, W):
    for i in range(int(H / 2)):
        draw_odd_line(W)
        draw_even_line(W)
    if is_odd(H):draw_odd_line(W)
    print()
    
for line in sys.stdin:
    H, W = map(int, line.split())
    if H == W == 0:
        break
    draw(H, W)

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

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

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll k;
  R k;
  ll n=50;
  k-=n;
  ll a[n];
  mem(a);
  if(k<0) {
    k+=n;
    rep(i,k) a[i]+=n;
  } else {
    rep(i,n) {
      a[i]=k/n+n;
      if(i<k%n) a[i]+=n-i-k%n;
      else a[i]-=k%n;
    }
  }
  pr(n);
  PR(a,n);
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#define N 500005
using namespace std;
int nxt[N],num[N*8];char s[N*8],t[N];
void getnxt(char s[]){
    nxt[0]=nxt[1]=0;
    int l=strlen(s);
    for(int i=1;i<l;++i){
        int j=nxt[i];
        while(j && s[i]!=s[j]) j=nxt[j];
        nxt[i+1]= s[i]==s[j] ? j+1 : 0 ;
    }
}
int kmp(char s1[],char s2[]){
    getnxt(s1);
    int ans=0;
    int n=strlen(s1),m=strlen(s2);
    for(int i=0,j=0;i<m;++i){
    	num[i]=0;
        while(j && s1[j]!=s2[i]) j=nxt[j];
        if(s1[j]==s2[i]) ++j;
        if(j==n) num[i]=1+num[i-n],ans=max(ans,num[i]);
    }
    return ans;
}
int main(){
	scanf("%s%s",&s,&t);
	int n=strlen(s),m=strlen(t);
	if(n>=m){
		for(int i=n;i<4*n;++i) s[i]=s[i%n];
		int ans1=kmp(t,s);
		for(int i=4*n;i<8*n;++i) s[i]=s[i%n];
		int ans2=kmp(t,s);
		if(ans1<ans2) printf("-1\n");
		else printf("%d\n",ans1);
	}
	else{
		int len=(m/n+1)*n*2;
		for(int i=n;i<len;++i) s[i]=s[i%n];
		int ans1=kmp(t,s);
		for(int i=len;i<2*len;++i) s[i]=s[i%n];
		int ans2=kmp(t,s);
		if(ans1<ans2) printf("-1\n");
		else printf("%d\n",ans1);
	}
	return 0;
}
///

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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

void solve(std::vector<std::string> s) {
  rep(i, 3) cout << (char)(s[i][0] - ' ');
  cout << endl;
}

int main() {
    std::vector<std::string> s(3);
    for(int i = 0 ; i < 3 ; i++){
        std::cin >> s[i];
    }
    solve(std::move(s));
}


Measured memory_bytes: 3600
s = input()
k = int(input())

cand_list = []
for i in range(len(s)):
    for j in range(len(s)+1-i):
        _s = s[i:i+j+1]
        cand_list.append(_s)
        cand_list = sorted(set(cand_list))
        if len(cand_list) > k and cand_list[len(cand_list) - 1] == _s:
            cand_list.remove(_s)
            break
        elif len(cand_list) > k:
            cand_list.pop(len(cand_list) - 1)

print(sorted(cand_list)[k-1])

Measured memory_bytes: 3064
import sys 

def func():
    n=int(input())
    print(0)
    sys.stdout.flush()
    gl=input()
    if gl == 'Vacant': 
        return
    print(n-1)
    sys.stdout.flush()
    gr=input()
    if gr == 'Vacant':
        return
    l=0
    r=n-1
    m=0
    while l<r-1:
        m=(l+r)>>1
        print(m)
        sys.stdout.flush()
        gm=input()
        if gm == 'Vacant' : 
            return  
        if (m-l)%2==0 and gm==gl :
            l=m
        elif (m-l)%2==1 and gm!=gl : 
            gl=gm
            l=m
        else :
            gr=gm
            r=m

    if m==l : 
        print(r)
        sys.stdout.flush()
    else: 
        print(l)
        sys.stdout.flush()
    return 

func()


Measured memory_bytes: 3660
import java.util.*;

public class Main
{
  static int n, k;
  static int[] h;
  static Integer[] memo;
  public static void main(String[] args)
  {
    Scanner in = new Scanner(System.in);
    n = in.nextInt();
    k = in.nextInt();
    h = new int[n];
    for (int i = 0; i < n; i++)
      h[i] = in.nextInt();
    
    memo = new Integer[n];
    System.out.println(dp(0));
    in.close();
  }
  
  public static int dp(int at)
  {
	if (at == n-1)
      return 0;
    if (memo[at] != null)
      return memo[at];
    int ans = (int)1e9;
    for (int i = 1; i <= k; i++)
      if (at+i <= n-1)
        ans = (int)Math.min(ans, (int)Math.abs(h[at+i]-h[at])+dp(at+i));
    return memo[at] = ans;
  }
}


Measured memory_bytes: 64676
#include <cstdio>
#include <algorithm>

int n, a[100001];

int main() {
	scanf("%d", &n);
	for (register int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	int temp = a[1] - 1;
	for (register int i = 2; i <= n; i++) {
		if (temp > a[i]) { 
			printf("No\n");
			return 0;
		}
		temp = std::max(temp, a[i] - 1);
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<iostream>
#include<algorithm>
#define m(a,b) memset(a,b,sizeof(a));
using namespace std;
const int maxn = 1e4;
const int inf = 1<<30;
typedef long long LL;
int n,m;
int main(){
	cin >> n >> m;
	map<int,int>mp;
	map<int,bool>ans;
	ans[1] = true;
	for(int i = 2;i<=n;i++)
		ans[i] = false;
	for(int i = 1;i<=n;i++)
		mp[i] = 1;
	for(int i = 1;i<=m;i++){
		int a,b;
		cin >> a >> b;
		mp[a]--;
		mp[b]++;
		if(ans[a]) ans[b] = true;
		if(mp[a]==0) ans[a] = false;
	}
	int cont = 0;
	for(int i = 1;i<=n;i++){
		if(ans[i]) cont++;
	}
	cout << cont << endl;
	return 0;
}


Measured memory_bytes: 9600
def main():
    N = int(input())
    mod = 10**9 + 7
    C = list(map(int, input().split()))
    C.sort()
    r = 0
    for i, v in enumerate(C[:-1]):
        r += pow(2, N-i-2, mod) * (N- i + 1) * v * pow(2, i, mod)
    r += C[-1] * pow(2, N-1, mod)
    r *= pow(2, N, mod)
    r %= mod
    return r
print(main())


Measured memory_bytes: 89036
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 60;
constexpr auto mod = 1000000007;
constexpr auto MOD = 998244353;
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; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, m, r;
    cin >> n >> m >> r;

    VI town(r);
    FOR(i, 0, r) {
        cin >> town[i];
        town[i]--;
    }

    vector<VI> dis(n, VI(n, INF));
    FOR(i, 0, n)dis[i][i] = 0;
    int a, b, c;
    FOR(i, 0, m) {
        cin >> a >> b >> c;
        dis[--a][--b] = c;
        dis[b][a] = c;
    }

    FOR(k, 0, n)FOR(i, 0, n)FOR(j, 0, n) {
        chmin(dis[i][j], dis[i][k] + dis[k][j]);
    }

    int ans = INF;
    SORT(town);
    do {
        int cnt = 0;
        FOR(i, 1, r)cnt += dis[town[i - 1]][town[i]];
        chmin(ans, cnt);
    } while (next_permutation(town.begin(), town.end()));

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    int D[k];
    rep(i, k) cin >> D[i];

    queue<int> que;
    for (int i = 0; i < 10; i++)
    {
        bool isOK = true;
        for (int j = 0; j < k; j++)
        {
            if (i == D[j])
            {
                isOK = false;
            }
        }
        if (isOK)
            que.push(i);
    }

    while (que.front() < 1000000)
    {
        int now = que.front();
        que.pop();
        if (n <= now)
        {
            cout << now << endl;
            return;
        }

        for (int i = 0; i < 10; i++)
        {
            bool isOK = true;
            for (int j = 0; j < k; j++)
            {
                if (i == D[j])
                    isOK = false;
            }
            if (isOK)
                que.push(now * 10 + i);
        }
    }
}

signed main()
{
    solve();
    return 0;
}


Measured memory_bytes: 768
char s[4001];u[4001],m,j,c,d;main(n){for(;m=d=~scanf("%s ",s);printf("%d\n",m))for(n=strlen(s);d-10;d=getchar())for(j=n;j--;m<c?m=c:0)u[j+1]=c=s[j]-d?0:u[j]+1;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXSIZE=10000020;
int bufpos;
char buf[MAXSIZE];
#define NEG 0
void init(){
	#ifdef LOCAL
		freopen("F.txt","r",stdin);
	#endif
	buf[fread(buf,1,MAXSIZE,stdin)]='\0';
	bufpos=0;
}
#if NEG
int readint(){
	bool isneg;
	int val=0;
	for(;!isdigit(buf[bufpos]) && buf[bufpos]!='-';bufpos++);
	bufpos+=(isneg=buf[bufpos]=='-');
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return isneg?-val:val;
}
#else
int readint(){
	int val=0;
	for(;!isdigit(buf[bufpos]);bufpos++);
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return val;
}
#endif
char readchar(){
	for(;isspace(buf[bufpos]);bufpos++);
	return buf[bufpos++];
}
int readstr(char* s){
	int cur=0;
	for(;isspace(buf[bufpos]);bufpos++);
	for(;!isspace(buf[bufpos]);bufpos++)
		s[cur++]=buf[bufpos];
	s[cur]='\0';
	return cur;
}
int b[200002];
int main(){
	init();
	int n=readint();
	for(int i=1;i<=n;i++)
		b[i]=readint();
	if (n%2){
		for(int i=n;i>=1;i-=2)
			printf("%d ",b[i]);
		for(int i=2;i<=n;i+=2)
			printf("%d ",b[i]);
	}else{
		for(int i=n;i;i-=2)
			printf("%d ",b[i]);
		for(int i=1;i<=n;i+=2)
			printf("%d ",b[i]);
	}
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))

const ll N=3030;
const ll mod =1e9+7;
ll dp[N],sum[N],n;
string s;


int main()
{
    ios_base::sync_with_stdio(false);

    cin>>n>>s;
    dp[0]=sum[0]=1;
    //forn(i,n)cout<<dp[i]<<" ";cout<<endl;



    for(int k=1;k<n;k++)
	{
		forn(i,k+1)
		{
			dp[i]=0;
			if(s[k-1]=='<'){if(i!=0)dp[i]=sum[i-1];}
			else {dp[i]=sum[k-1];if(i!=0)dp[i]-=sum[i-1];}
		}
		forn(i,n){sum[i]=dp[i];sum[i]%=mod;sum[i]+=mod;sum[i]%=mod;if(i!=0)sum[i]+=sum[i-1];}
		//forn(i,n)cout<<dp[i]<<" ";cout<<endl;
	}
    ll ans=0;
    forn(i,n)ans+=dp[i];
    ans%=mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int n,k,q,a[N],b[N];
int solve(int x)
{
    vector<int>v;
    vector<int>res;
    for(int i=1;i<=n;i++)
        if(a[i]>=x) v.push_back(a[i]);
    else
    {
        sort(v.begin(),v.end());
        for(int i=0;i+k<=v.size();i++)
            res.push_back(v[i]);
        v.clear();
    }
    sort(v.begin(),v.end());
    for(int i=0;i+k<=v.size();i++)
        res.push_back(v[i]);
    v.clear();
    sort(res.begin(),res.end());
    if(res.size()<q) return 1e9;
    return res[q-1]-res[0];
}
int main()
{
    scanf("%d%d%d",&n,&k,&q);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),b[i]=a[i];
    sort(b+1,b+1+n);
    int tot=unique(b+1,b+1+n)-b-1;
    int ans=1e9;
    for(int i=1;i<=tot;i++)
        ans=min(ans,solve(b[i]));
    printf("%d\n",ans);
}


Measured memory_bytes: 256
from collections import Counter


def main():
    n = int(input())
    cnt = Counter()
    for _ in range(n):
        s = input()
        cnt[s] += 1
    for j in ('AC', 'WA', 'TLE', 'RE'):
        print(f'{j} x {cnt[j]}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9476
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, X, S[200], MOD = 1000000007, ANS = 0;
	static long long DP[210][100010] = {};
	cin >> N >> X;
	for (int i = 0; i < N; i++) cin >> S[i];
	sort(S, S + N, greater<long long>());
	DP[0][X] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 100000; j++) {
			DP[i + 1][j] = (DP[i + 1][j] + DP[i][j] * (N - i - 1)) % MOD;
			DP[i + 1][j % S[i]] = (DP[i + 1][j % S[i]] + DP[i][j]) % MOD;
		}
	}
	for (int i = 0; i <= 100000; i++) {
		ANS = (ANS + i * DP[N][i]) % MOD;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 157184
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>

#define SIZE 100005
#define MOD 1000000007

using namespace std;

class APoor {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int64_t a, b, c;
    cin >> a >> b >> c;
    if ((a == b && a != c) || (b == c && b != a) || (a == c && a != b)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
};


int main() {
    APoor solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [a, b] <- getIntList
  print (a*b)



Measured memory_bytes: 3776
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
AX = [0];BX = [0]

for a in A:
    AX.append(AX[-1]+a)
for b in B:
    BX.append(BX[-1]+b)    

ans = 0
j = M
for i in range(0,N+1):
    if AX[i] > K:
        break
    while AX[i]+BX[j] > K:
        j -= 1
    ans = max(ans,i+j)
print(ans)


Measured memory_bytes: 127156
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << (A==B && B==C ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int N;
    cin >> N;
    vector<double> X(N);
    vector<double> Y(N);
    REP(i, N) cin >> X[i] >> Y[i];
    double sum = 0;
    REP(i, N) {
        REP(j, N) {
            if(i == j) continue;
            sum += sqrt((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]));
        }
    }
    sum /= N;
    cout << std::setprecision(10) << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
  string S;
  cin >> S;
  int count = 0;
  for(int i = 0; i<S.length()/2 ; i++){
    int j = S.length() - 1 - i;
    if(S[i] != S[j]) ++count;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include "bits/stdc++.h"
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
template <typename T>
using treap = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fi first
#define se second

int main() {
  ios::sync_with_stdio(false);

  int T;
  cin >> T;
  while (T--) {
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    vector<pair<ll, ll>> X = {{2, A}, {3, B}, {5, C}};
    set<ll> V;
    priority_queue<pair<ll, ll>> Q;
    Q.emplace(0, N);
    while (!Q.empty()) {
      auto [d, x] = Q.top();
      Q.pop();
      if (!V.insert(x).se) continue;
      if (x == 0) {
        cout << -d << '\n';
        break;
      }
      for (auto [m, w] : X) {
        ll r = x % m;
        ll b = x - r;
        ll f = b / m;
        ll p = b - f;
        if (p >= 2e9) {
          Q.emplace(d - r * D - w, f);
          if (r) Q.emplace(d - (m - r) * D - w, f + 1);
        } else {
          Q.emplace(d - r * D - min(p * D, w), f);
          if (r) Q.emplace(d - (m - r) * D - min((p + m - 1) * D, w), f + 1);
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 4104
#include <iostream>
using namespace std;
typedef unsigned long long ull;

ull mes(int k, int ii) {
	ull tmp = 1;
	for (int i = 0; i < ii; i++) tmp *= k;
	return tmp;
}

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

	int digit = 1;
	for (int i = 1; ; i++) {
		if (mes(k, i) <= n) digit++;
		else break;
	}

	cout << digit << endl;

	return 0;
}

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

using ll=long long;
const ll z=0;

int main() {
  int N;
  cin >> N;
  vector<int> vec(3*N);
  for(int i=0;i<3*N;i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  ll sum=0;
  for(int i=1;i<N+1;i++){
    sum +=vec[3*N-2*i];
  }
  cout << sum << endl;
}

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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	int flag = 0;
	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (flag == 0) {
			if (a[i - 1] < a[i]) flag = 1;
			else if (a[i - 1] > a[i]) flag = -1;
		} else if (flag == 1) {
			if (a[i - 1] > a[i]) {
				ans++;
				flag = 0;
			}
		} else {
			if (a[i - 1] < a[i]) {
				ans++;
				flag = 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
/*----------------------|
/ Author : Ashraf Tasin |
/ Date   :   08.08.19   |
/----------------------*/

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define all v.begin(),v.end()
#define flash ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define db double
#define endl "\n"
#define mnm pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>
#define show for(int i=0;i<v.size();i++) cout << v[i] << " ";
#define eps 1e-6
#define mx 100008
#define mod 1000000007
using namespace std;

/*King Moves
int dx[]={-1,1,-1,0,1,-1,0,1};
int dy[]={0,0,-1,-1,-1,1,1,1}; */

/*Knight Moves

int dx[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int dy[] = { 1, 2, 2, 1, -1, -2, -2, -1 }; */

/*Normal Moves

int x[] = {0, 1, 0, -1};
int y[] = {-1, 0, 1, 0}; */

int main()
{
   // freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    flash

    int n,k;
    cin >> n >> k;

    if(k==1) return(cout << 0 << endl,0);
    else cout << (n-k+1)-1 << endl;

    return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
ls=len(s)
lt=len(t)
maxcount=0
for i in range(ls-lt+1):
  count = 0
  for j in range(lt):
    if s[i+j]==t[j]:
      count+=1
  maxcount=max(maxcount,count)
print(lt-maxcount)
  
  

Measured memory_bytes: 73060
package main

import (
	"fmt"
	"strings"
)

func main(){
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	answer := n

	m := n-1
	sumE := make([]int, n)
	sumW := make([]int, n)
	ss := strings.Split(s,"")

	if ss[m] == "E" {
		sumE[m] = 1
	}else{
		sumE[m] = 0
	}
	if ss[0] == "W" {
		sumW[0] = 1
	}else{
		sumW[0] = 0
	}
	for r := 1; r < len(ss); r++ {
		if ss[m-r] == "E" {
			sumE[m-r] = sumE[n-r]+1
		}else{
			sumE[m-r] = sumE[n-r]
		}

		if ss[r] == "W" {
			sumW[r] = sumW[r-1]+1
		}else{
			sumW[r] = sumW[r-1]
		}
	}

	if answer > sumW[m] {
		answer = sumW[m]
	}
	if answer > sumE[0] {
		answer = sumE[0]
	}
	for r:=1; r+1 < n; r++ {
		tmp := sumE[r+1] + sumW[r-1]
		if answer > tmp {
			answer = tmp
		}
	}

	fmt.Print(answer)
}

Measured memory_bytes: 12800
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <algorithm>
#define ii pair<int, int>
#define iii pair<ii, int>
#define pq priority_queue

using namespace std;

vector<int> bfs(vector<vector<int>> adj_list, int start, int n) {
    queue<ii> possible;
    set<int> visited;
    vector<int> no_ways(n - 1, 0);
    possible.push(make_pair(start, 0));
    while (!possible.empty()) {
        int island = possible.front().first;
        int dist_from_start = possible.front().second;
        possible.pop();
        if (visited.find(island) == visited.end()) {
            for (int adj_node : adj_list[island]) {
                possible.push(make_pair(adj_node, dist_from_start + 1));
            }
            if (dist_from_start != 0 && island > start) {
                no_ways[dist_from_start - 1]++;
            }
            visited.insert(island);
        }
    }
    return no_ways;
}

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

    int n, x, y;
    cin >> n >> x >> y;
    vector<vector<int>> adj_list(n);
    adj_list[0].push_back(1);
    adj_list[n - 1].push_back(n - 2);
    for (int i = 1; i < n - 1; i++) {
        adj_list[i].push_back(i + 1);
        adj_list[i].push_back(i - 1);
    }
    adj_list[x - 1].push_back(y - 1);
    adj_list[y - 1].push_back(x - 1);
    vector<int> answers(n - 1, 0);
    for (int i = 0; i < n; i++) {
        vector<int> ans_from_node = bfs(adj_list, i, n);
        for (int j = 0; j < n - 1; j++) {
            answers[j] += ans_from_node[j];
        }
    }
    for (int i = 0; i < n - 1; i++) {
        cout << answers[i] << '\n';
    }
}

Measured memory_bytes: 3944