akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  while(1){
    string str;
    getline(cin,str);
    if(str == "END OF INPUT") break;
    int cnt = 0;
    for(int i=0;i<str.size();i++){
      if(str[i] != ' '){
	cnt++;
      } else {
	cout << cnt;
	cnt = 0;
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1188
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        String s;
        s = scan.next();
        if(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5)) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

using namespace std;


int n,m;
int h[1600],w[1600];


int main(){
    while(true){
        cin >> n >> m;
        if(n + m == 0)break;
        for(int i = 1;i <= n;i++)cin >> h[i];
        for(int j = 1;j <= m;j++)cin >> w[j];
        map<int, int> d;
        for(int i = 1;i <= m;i++){
            int sum = 0;
            for(int j = i;j <= m;j++){
                sum += w[j];
                d[sum]++;
            }
        }
        int ans = 0;
        for(int i = 1;i <= n;i++){
            int sum = 0;
            for(int j = i;j <= n;j++){
                sum += h[j];
                ans += d[sum];
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 20916
n = int(input())
color = [-1] * n
edges = [[] for i in range(n)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    edges[u - 1].append((v - 1, w))
    edges[v - 1].append((u - 1, w))
q = [0]
color[0] = 0
while len(q) > 0:
    u = q.pop(0)
    for v, w in edges[u]:
        if color[v] < 0:
            q.append(v)
            color[v] = (color[u] + w) % 2
for i in range(n):
    print(color[i])


Measured memory_bytes: 38828
#include<stdio.h>
#include<string.h>

char p[1024];
char y[1024];

int main(void){
	while(gets(p)){
		int x = strlen(p);
		int f = 0;
		for(int i = 0; i < 26; i++){
			for(int j = 0; j < x; j++)if(p[j] >= 'a' && p[j] <='z')p[j] = (p[j]+1-'a')%26 + 'a';
			
			if(strstr(p,"the")!= NULL)break;
			if(strstr(p,"that")!= NULL)break;
			if(strstr(p,"this")!= NULL)break;
		}
		puts(p);
	}
	
	return 0;
}

Measured memory_bytes: 928
#include<iostream>
#include<algorithm> 
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int N = 2e5+5;
const double pi = acos(-1.0);
const ll mod = 1e9+7; 
map<ll,int>mp;
ll n,k,c,cnt;
char s[N];
ll a[N],b[N];
void init(){
	ios::sync_with_stdio(false);
	cin.tie(0);
}
int main()
{
	init();
	cin>>n>>k>>c>>s+1;
	for(ll i=1;i<=n;i++)
	{
		if(s[i]=='o')
		{
			a[cnt++]=i;
			i+=c;
		}
		if(cnt==k)break;
	}
	for(ll i=n;i>=1;i--)
	{
		if(s[i]=='o')
		{
			b[--cnt]=i;
			i-=c;
		}
		if(!cnt)break;
	}
	for(int i=0;i<k;i++)
	if(a[i]==b[i])cout<<a[i]<<endl;
	return 0;
}

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

int main() {
	int a,b;
	cin >> a >> b;
	
	if(a > b)
		rep(i,a)
			cout << b;
	else
		rep(i,b)
			cout << a;
	cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,n,count=1,max;
    scanf("%d",&n);
    int ara[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&ara[i]);
    }
    max=ara[0];
    for(i=1;i<n;i++)
    {
        if(ara[i]<max)
        {
            max=ara[i];
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 2500
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	int a[] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n; cin >> n;

	cout << a[n-1]<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int R;
  cin >> R;
  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}

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

n_division = 0
while True:
    a_list = [a/2 for a in a_list if a % 2 == 0]
    if len(a_list) != n:
        print(n_division)
        exit()
    else:
        n_division += 1

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

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

    string s, t;
    cin >> s >> t;

    int a, b;
    cin >> a >> b;

    string u;
    cin >> u;

    if (s == u) {
        cout << (a - 1) << " " << b << endl;
    } else {
        cout << a << " " << (b - 1) << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  std::string S;
  std::cin >> S;
  for (int i=0; i<S.length(); i++){
    printf("x");
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
template<class T> void chmin(T& x, T y){if(x < y) x = y;}
template<class T> void chmax(T& x, T y){if(x > y) x = y;}
string S;

int main(){
    cin >> S;
    int N = S.size();
    bool flag = true;
    for(int i = 0; i < N / 2; i++){
        if(S[i] != S[N - i - 1]) flag = false;
    }
    int r = (N - 1) / 2;
    for(int i = 0; i < r / 2; i++){
        if(S[i] != S[r - i - 1]) flag = false;
    }
    cout << (flag ? "Yes" : "No" ) << endl;
    return 0;
}

Measured memory_bytes: 256
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;


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

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >>x2 >> y2;

    --x2; --x1; --y1; --y2;

    vector<string> mat(n);

    for (auto &it : mat) {
        cin >> it;
    }

    vector<vector<int> > dist(n, vector<int>(m, INT_MAX));

    queue <pair<int, int> > q;
    priority_queue<array<int, 3>, vector<array<int, 3>>, greater<array<int,3>>> pq;
    pq.push({x1, y1, 0});
    dist[x1][y1] = 0;

    int X[4] = {-1, 1, 0, 0};
    int Y[4] = {0, 0, -1, 1};
    while (!pq.empty()) {
        auto u =  pq.top();
        pq.pop();

        int x = u[0], y = u[1], w = u[2];

        if (dist[x][y] < w)
            continue;

        for (int k = 0; k < 4; k++) {
            int nx = x + X[k];
            int ny = y + Y[k];
            if (nx >= 0 && nx < n && ny >= 0 && ny < m && mat[nx][ny] == '.' && dist[nx][ny] > dist[x][y]) {
                dist[nx][ny] = dist[x][y];
                pq.push({nx, ny});
            }
        }

        for (int nx = x-2; nx <= x+2; nx++) {
            for (int ny = y-2; ny <= y+2; ny++) {
                if (nx >= 0 && nx < n && ny >= 0 && ny < m && mat[nx][ny] == '.' && dist[nx][ny] > dist[x][y] + 1) {
                    dist[nx][ny] = dist[x][y] + 1;
                    pq.push({nx, ny});
                }
            }
        }
        
    }

    cout << (dist[x2][y2] == INT_MAX ? -1 : dist[x2][y2]);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 8544
N,M=gets.split.map(&:to_i)
S=N.times.map{gets.split.map(&:to_i)}.sort{|l,r|l[0]<=>r[0]}
s=0
n=M
S.each do |a,b|
  x=[b,n].min
  s+=a*x
  n-=x
end
p s

Measured memory_bytes: 12792
#include<stdio.h>
#include<string.h>

char wd[10][10];
int bk[10],t,n,m,a[20],d[20],c[10];
void Dfs(int x){
  if(c[x]==1)
    Dfs(x+1);
  if(x==8){
    for(int i=0;i<8;i++)
      printf("%s\n",wd[i]);
    return;
  }
  for(int i=0;i<8;i++)
    {
      if(bk[i]==0&&a[x+i]==0&&d[x-i+8]==0)
        {
	  bk[i]=1;
	  a[x+i]=1;
	  d[x-i+8]=1;
	  wd[x][i]='Q';
	  Dfs(x+1);
	  bk[i]=0;
	  a[x+i]=0;
	  d[x-i+8]=0;
	  wd[x][i]='.';
        }
    }
}
int main()
{
  scanf("%d",&t);
  for(int i=0;i<8;i++)
    for(int j=0;j<8;j++)
      wd[i][j]='.';
  for(int i=0;i<t;i++)
    {
      scanf("%d%d",&n,&m);
      wd[n][m]='Q';
      bk[m]=1;
      a[n+m]=1;
      d[n-m+8]=1;
      c[n]=1;
    }
  Dfs(0);
  return 0;
}



Measured memory_bytes: 2080
import numpy as np

n, k = map(int, input().split())
h = np.array([int(i) for i in input().split()])

dp = np.array([0]*n)
dp[0] = 0

for i in range(1,n):
    j = max(0,i-k)
    dp[i] = np.min(np.abs(h[i] - h[j:i]) + dp[j:i] )

print(dp[-1])

Measured memory_bytes: 23088
n = gets.to_i
num = gets.strip.split.map(&:to_i)
a = num.sort[n/2-1]
b = num.sort[n/2]
#候補はaまたはb
for i in 0..n-1
  if num[i]<=a
    puts b
  else
    puts a
  end
end

Measured memory_bytes: 37140
/*
 * ALDS1_10_C.cpp
 *
 *  Created on: May 5, 2018
 *      Author: 13743
 */

#include<cstdio>
#include<cstring>
#include<algorithm>

int dp[1001][1001];

int lcm(char* X, char* Y, int nx, int ny) {
	dp[1][1] = (X[0] == Y[0]);
	for(int i=1; i<=nx; i++) {
		for(int j=1; j<=ny; j++) {
			dp[i][j] = (X[i-1]==Y[j-1]) + dp[i-1][j-1];
			dp[i][j] = std::max(dp[i-1][j], dp[i][j]);
			dp[i][j] = std::max(dp[i][j-1], dp[i][j]);
		}
	}
	return dp[nx][ny];
}

int main() {
	int q;
	scanf("%d", &q);
	char X[1001];
	char Y[1001];
	while(q--) {
		scanf("%s", X);
		scanf("%s", Y);
		int nx = (int)strlen(X);
		int ny = (int)strlen(Y);
		printf("%d\n", lcm(X, Y, nx, ny));
	}
}





Measured memory_bytes: 6516
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;
const int dx[2]={1,0};
const int dy[2]={0,1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h){
        cin >> s[i];
    }
    if(s[0][0] == '.'){
        cout << "Impossible\n";
    }else{
        s[0][0] = '.';
        int ni=0,nj=0;
        bool flag;
        while(1){
            if(ni == h-1 && nj == w-1){
                break;
            }
            flag = true;
            rep(i,2){
                int nx=ni+dx[i],ny=nj+dy[i];
                if(0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] == '#'){
                    ni = nx,nj = ny;
                    s[ni][nj] = '.';
                    flag = false;
                    break;
                }
            }
            if(flag){
                cout << "Impossible\n";
                return 0;
            }
        }
        rep(i,h){
            rep(j,w){
                if(s[i][j] != '.'){
                    cout << "Impossible\n";
                    return 0;
                }
            }
        }
        cout << "Possible\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  vector<int> b(N);
  rep(i, N)
  {
    cin >> b[i];
    b[i]--;
  }

  REVERSE(b);
  vector<int> ans;
  rep(i, N)
  {
    rep(j, b.size())
    {
      int ri = b.size() - j - 1;
      if (b[j] == (ri))
      {
        b.erase(b.begin() + j);
        ans.push_back(ri + 1);
        break;
      }
    }

    if (ans.size() != i + 1)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  REVERSE(ans);
  rep(i, N)
  {
    cout << ans[i] << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
    string S;
    int A[4];
    int val = 0;
    int ans = 0;
    cin >> S;

    for(int i = 0; i < 4; i++) A[i] = (int)(S[i]-'0');

    for(int i = 0; i < (1 << (S.size()-1)); i++) {  
         val = A[0];
         //cout << "ENTER!" <<endl;
        for(int j = 1; j < 4; j++) {
            //cout << "hi!" << i << ", " << (1<<(j-1)) << endl;
            if( (i&(1 << (j-1))) != 0) {
                val += A[j];
            //    cout << "+" << endl;
            }
            else {
                val -= A[j];
            //    cout << "-" << endl;
            }
        }
        //cout << val << endl;
        if(val == 7) {
            ans = i;
            break;
        }
    }

    for(int j = 1; j < 4; j++) {
        cout << A[j-1];
        if( (ans&(1 << (j-1))) != 0) cout << "+";
        else cout << "-";
    }
    cout << A[3] << "=7" <<endl;

    return 0;

}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            if (N == 1)
            {
                Console.WriteLine("Hello World");
            }else
            {
                var A = int.Parse(Console.ReadLine());
                var B = int.Parse(Console.ReadLine());
                Console.WriteLine(A + B);
            }
        }
    }
}

Measured memory_bytes: 11092
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val s = sc.next()

  val n = s.length

  for (i in 1 until n) {
    val sub = s.substring(0, n - i)

    val len = sub.length
    if (len % 2 != 0) {
      continue
    }

    val first = sub.substring(0, len / 2)
    val second = sub.substring(len / 2)
    if (first == second) {
      println(len)
      return
    }
  }

}


Measured memory_bytes: 36236
from sys import stdin


def main():
    result = 2019
    L, R = [int(x) for x in stdin.readline().rstrip().split()]
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            a = (i * j) % 2019
            result = min(result, a)
            if (result == 0):
                print(result)
                return
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int senbei[10][100000];

int main(){
	while(true){
		int r, c;
		cin >> r >> c;
		if(r == 0 && c == 0){ break; }
		for(int i = 0; i < r; i++){
			for(int j = 0; j < c; j++){
				cin >> senbei[i][j];
			}
		}
		int answer = 0;
		for(int i = (1 << r) - 1; i >= 0; i--){
			int sum = 0;
			for(int j = 0; j < c; j++){
				int count = 0;
				for(int k = 0; k < r; k++){
					if(senbei[k][j] ^ ((i >> k) & 0x01)){ count++; }
				}
				sum += max(count, r - count);
			}
			answer = max(answer, sum);
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 1284
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


class Main {
	public static void main(String[] args) throws IOException {
		ArrayList<String> ss = new ArrayList<String>();
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String i = new String(in.readLine());
			if(i.equals("0")){
				break;
			}
			else{
				ss.add(i);
			}
			
		}
		for(int i = 0;i < ss.size() ;i++){
			System.out.println("Case "+(i+1)+": " + ss.get(i));
		}
		
	}

}

Measured memory_bytes: 27820
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
R = 0

for n in range(N):
    R += B[A[n]-1]
    if n >= 1 and A[n] - A[n-1] == 1:
        R += C[A[n-1]-1]

print(R)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    int n;cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> k(n+1,0),l(n+1,0);
    for (int i = 0; i < n; i++) {
        k[i+1]=max(k[i],a[i]);
    }
    for (int i = 0; i < n; i++) {
        l[n-i-1]=max(l[n-i],a[n-i-1]);
    }
    for (int i = 0; i < n; i++) {
        cout << max(k[i],l[i+1]) << endl;
    }
    return 0;
}


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

// a^nを計算　O(log n)
long long int pow(long long int a, long long int n) {
    if (n == 0) {
        return 1;
    } else {
        long long int temp = pow(a, n / 2);
        if (n % 2 == 0) {
            return temp * temp;
        } else {
            return temp * temp * a;
        }
    }
}

// aをp進数で表した時の下からn桁目を計算
long long int bit(long long int a, long long int p, long long int n) {
    return (a / pow(p, n)) % p;
}

int main() {
    int n;
    cin >> n;
    vector<int> take(3);
    for (int i = 0; i < 3; i++) {
        cin >> take[i];
    }
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    int M = 1e+9;
    int mp = M;
    int temp;
    vector<int> pretake;
    int pattern = pow(4, n);
    for (int i = 0; i < pattern; i++) {
        temp = 0;
        pretake.assign(3, 0);
        for (int j = 0; j < n; j++) {
            if (bit(i, 4, j) == 3) continue;
            if (pretake[bit(i, 4, j)] > 0) temp += 10;
            pretake[bit(i, 4, j)] += l[j];
        }
        for (int i = 0; i < 3; i++) {
            if (pretake[i] == 0) {
                temp = max(temp, M);
            }
        }
        for (int i = 0; i < 3; i++) {
            temp += abs(pretake[i] - take[i]);
        }
        mp = min(mp, temp);
    }
    cout << mp << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

int main(){
    ll N;
    cin>>N;

    vector<int> v;
    while(N>0){
        v.push_back(N%26);
        N/=26;
    }
    /*
    for(auto p:v){
        cout<<p<<" ";
    }
    cout<<endl;
    //*/
    for(int i=0;i<v.size()-1;i++){
        if(v[i]<=0){
            v[i]+=26;
            v[i+1]--;
        }
    }
    //*
    for(int i=v.size()-1;i>=0;i--){
        if(v[i]>0){
            cout<<(char)('a'+v[i]-1);
        }
    }
    cout<<endl;
    //*/

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];

int main()
{
	long long N, ans = 0;

	cin >> N;

	ans = N;
	if(N % 2 != 0) ans = 2*N;

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int total = 0;
  if (a <= b) {
    total = a;
  }
  else {
    total = a - 1;
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n, m;

struct Node {
	int pos;
	bool isVisited;
	std::set<int> connects;
	int parent;
};

Node nodes[100010];


int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1 ; i <= n ; i++) {
		nodes[i].isVisited = false;
		nodes[i].parent = -1;
	}
		
	
	for (int i = 0 ; i < m ; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		nodes[u].connects.insert(v);
		nodes[v].connects.insert(u);
	}
	
	std::queue<int> q;
	q.push(1);
	
	int curP;
	int newP;
	while (!q.empty()) {
		curP = q.front();
		q.pop();
		nodes[curP].isVisited = true;
		
		std::set<int>::iterator iNode;
		
		
		for (iNode = nodes[curP].connects.begin() ;
			iNode != nodes[curP].connects.end() ; 
			iNode++) {
			newP = *iNode;
			if (nodes[newP].parent == -1) {
				nodes[newP].parent = curP;
				nodes[newP].isVisited = true;
				q.push(newP);
			}
		}
	}
	
	for (int i = 2 ; i <= n ; i++) {
		if (nodes[i].parent == -1) {
			printf("No\n");
			return 0;
		}
	}
	
	printf("Yes\n");
	for (int i = 2 ; i <= n ; i++) {
		printf("%d\n", nodes[i].parent);
	}
	
	
	return 0;
}


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

int main()
{
string n ;
ll k ;
cin >> n >> k ;
ll dp[n.size()][k+1][2]={};
dp[0][0][0]=1;
dp[0][1][1]=1;
dp[0][1][0]=n[0]-'1';
rep(i,n.size())rep(j,k+1){
dp[i+1][j][0]+=dp[i][j][0];
if(n[i+1]=='0')dp[i+1][j][1]+=dp[i][j][1];
else {
  if(j!=k)dp[i+1][j+1][1]+=dp[i][j][1];
  if(j!=k)dp[i+1][j+1][0]+=dp[i][j][1]*(n[i+1]-'1');
  dp[i+1][j][0]+=dp[i][j][1];
}
if(j!=k)dp[i+1][j+1][0]+=dp[i][j][0]*9;
}
cout << dp[n.size()-1][k][0]+dp[n.size()-1][k][1] << endl;
return 0;
}

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

int main(){
  std::string s;
  std::cin >> s;

  int tmp=0;
  int ret=0;
  for(int i=0; i < s.length(); i++){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      tmp++;
      if(ret < tmp) ret = tmp;
    }
    else tmp = 0;
  }

  std::cout << ret << std::endl;

  return 0;
}


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

int main() {
  int N;
  scanf("%d", &N);

  vector<int64_t> L(N + 1);
  L.at(0) = 2;
  L.at(1) = 1;

  for (int i = 2; i < L.size(); i++) {
    L.at(i) = L.at(i - 1) + L.at(i - 2);
  }

  cout << L.at(N) << endl;
}


Measured memory_bytes: 256
import itertools
from collections import defaultdict

def main():
    name_freq = defaultdict(int)
    N = int(input())
    for _ in range(N):
        name_freq[input()[0]] += 1

    ans = 0
    for comb in itertools.combinations(['M', 'A', 'R', 'C', 'H'], 3):
        ans += name_freq[comb[0]] * name_freq[comb[1]] * name_freq[comb[2]]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74988
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	set<int> st={1,2,3};
	int a;
	for (int i=0; i<2; i++)
		cin>>a, st.erase(a);
	cout<<*st.begin()<<"\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int m[] = new int[N];
        for(int h = 0; h < N; h++){
            m[h] = sc.nextInt();
            X -= m[h];
        }

        Arrays.sort(m);
        int counter = 0;

        while(X >= m[0]){
            X -= m[0];
            counter++;
        }

        counter += N;
        System.out.println(counter);
    }
}

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

int main() {
    int N, M;
    cin >> N >> M;
    string S;
    cin >> S;

    vector<int> ans;
    for (int i = N; i >= 0; i--) {
        int nxt = i;
        for (int j = M; j >= 1; j--) {
            if (i - j >= 0 && S[i - j] != '1') {
                nxt = i - j;
                ans.push_back(j);
                break;
            }
        }
        if (nxt == 0)
            break;
        if (nxt == i) {
            cout << -1 << endl;
            return 0;
        }
        i = nxt + 1;
    }
    reverse(ans.begin(), ans.end());
    for (int a : ans) {
        cout << a << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1144
#include<iostream>
#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ll t,n;
    cin>>t;
    n = t%(1000);
    if (n==0)
    {
        cout<<n<<endl;
    }
    else
    cout<<(1000-n)<<endl;
    return 0;
}

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

    cin >> n >> m;
    vector<ll> card(n);
    vector<pair<ll,ll>> action;
    rep(i,n) cin >> card[i];
    sort(card.begin(),card.end());
    rep(i,m){
        ll b,c;
        cin >> b >> c;
        action.push_back(make_pair(c,b));
    }
    sort(action.rbegin(),action.rend());
    rep(i,m){
        int b = action[i].second;
        int c = action[i].first;
        rep(j,b){
            if(now>n) break;
            if(card[now]<c) card[now] = c;
            now++;
            //cout << 1 ;
        }
        if(now>n) break;
    }
    ll ans=0;
    rep(i,n) ans += card[i];
    cout << ans << endl;

}

Measured memory_bytes: 6084
#include<bits/stdc++.h>
using namespace std;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()

#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef		long long       ll;
typedef		vector<ll>      vll;

int main()
{
  string s,ss;
  ll n,i=0,j=0;
  cin>>s; cin>>n;
  cout<<nn;
  while(i<s.size())
  {
      cout<<s[i];
      i+=n;
      if(i>s.size()||i==s.size()) break;
  }


//cout<<s.size();
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MX=1e18;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll x;cin>>x;
    for(ll a=-1000;a<=1000;a++){
        for(ll b=-1000;b<=1000;b++){
            ll val = a*a*a*a*a - b*b*b*b*b;
            if(val==x)return cout<<a<<" "<<b , 0;
        }
    }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
string st;
int main(){
	int n,p,d;
	cin>>n>>p;
	char c;
	do{
		d=n%p;
		n=n/p;
		if(d>=0&&d<=9){
			c=d+'0';
		}
		else{
			c=d+55;
		}
		st=c+st;
	}while(n!=0);
	cout<<st.size();
	return 0;
}


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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int a, b;
	cin >> a >> b;

	if (a > b)swap(a, b);
	FOR(0, b)cout << a;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int ans = 0;
    int d[110];
    rep(i, n) cin >> d[i];
    rep(i, n) {
        REP(j, i + 1, n - 1) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPowerSocket solver = new BPowerSocket();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPowerSocket {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int cnt = 0;
            int cur = 1;
            while (cur < b) {
                cur -= 1;
                cur += a;
                cnt++;
            }
            out.println(cnt);
        }

    }
}



Measured memory_bytes: 21716
my $n = +get;
my @ps = +<<get.words;

my $ok = False;

for (0..^$n) -> $i {
  for (0..$i) -> $j {
    (@ps[$i], @ps[$j]) = (@ps[$j], @ps[$i]);
    my $l_ok = True;
    $l_ok &&= $_ + 1 == @ps[$_] for (0..^$n);
    $ok ||= $l_ok;
    (@ps[$i], @ps[$j]) = (@ps[$j], @ps[$i]);
  }
}

say $ok ?? "YES" !! "NO";


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

int main(){
	// sengen
	long long n;
	// nyuryoku
	cin >> n;
	int word_long = 1;
	// keisan
	long long plus = 26,len = 27;
	while(len <= n){
		plus *= 26;
		len += plus;
		word_long++;
	}
	string ans;
	char c;
	int amari[word_long];
	for(int i=0;i<word_long;i++){
		amari[i] = n%26;
		if(amari[i] == 0){
			amari[i] = 26;
		}
		n = n - amari[i];
		n = n/26;
	}
	for(int i=word_long - 1;i>=0;i--){
		c = 'a' + amari[i] -1;
		if(i == word_long){
			ans = c;
		}else{
			ans = ans + c;
		}
	}
	// syutsuryoku
	cout << ans;
}

Measured memory_bytes: 3640
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

p1,p2,p3,p4 = 0,0,0,0
for i,j in zip(x,y):
    p1 += abs(i-j)
    p2 += abs(i-j)**2
    p3 += abs(i-j)**3
    p4 = abs(i-j) if p4 < abs(i-j) else p4

print(p1)
print(p2**0.5)
print(p3**(1/3))
print(float(p4))


Measured memory_bytes: 5648
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 998244353;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {  
    ll a; double b; cin >> a >> b;
    double b_ = b * 100;
    b_ = round(b_);
    ll c = b_;
    ll res = a * c / 100;
    cout << res << ln;


}



Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  sort(a,a+n);

  if(a[0]==a[n-1]){
    if(a[0]*2<=n||a[0]==n-1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }else if(a[n-1]-a[0]>1) cout<<"No"<<endl;
  else{
    int m;
    m=upper_bound(a,a+n,a[0])-lower_bound(a,a+n,a[0]);
    if(m<a[n-1]&&2*(a[n-1]-m)<=n-m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    /*if(m==a[0]) cout<<"Yes"<<endl;
    else if(m==1){
      if(a[0]*2<=(n-1)) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
    else cout<<"No"<<endl;*/
  }

  return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p_list = list(map(int, input().split()))

max_sum = sum(p_list[:K])
now_sum = max_sum
for i in range(K, N):
    now_num = p_list[i]
    now_sum -= p_list[i - K]
    now_sum += now_num
    if now_sum > max_sum:
        max_sum = now_sum

print((max_sum + K) / 2)

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

int a,b,c,d;
int main(){
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d) cout << "Yes\n";
    else if(abs(a-b)<=d && abs(b-c)<=d) cout << "Yes\n";
    else    cout << "No\n"; 

    return 0;
}

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

int main(){
    int n, k, a[100005];
    cin >> n >> k;
    for(int i=0; i<n; ++i){
        cin >> a[i];
    }
    cout << ((n-2)/(k-1)+1) << endl;
    return 0;
}

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

int main() {
  int N, a[10]={0,0,0,0,0,0,0,0,0,0};
  cin >> N;
  int i=0, sum=0;
  int A=N;
  
  while(N>0){
    a[i] = N % 10;
    N /= 10;
    sum += a[i];
    
    i++;
  }
  
  if(A % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3636
from collections import defaultdict as ddict
def cal_interval(Num):
	interval = ddict(int)
	dp = [int(raw_input()) for i in range(Num)]
	for i in range(Num):
		tmp = dp[i]
		interval[tmp] += 1
		for j in range(i):
			tmp += dp[i-j-1]
			interval[tmp] += 1
	return interval
while 1:
	N, M = map(int,raw_input().split(" "))
	if (N, M) == (0,0):
		break
	Lon = cal_interval(N)
	Lat = cal_interval(M)
	print sum(Lon[k] * Lat[k] for k in Lon if k in Lat)

Measured memory_bytes: 54372
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

const int mod = 1000000007;

long long pw(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1ll) {
			res = res * a % mod;
		}
		b >>= 1;
		a = a * a % mod;
	}
	return res;
}

int main(){
	int n = nxt(), m = nxt();
	vector<vector<int>> a(n);
	vector<int> path;
	for (itn i = 0; i < m; ++i) {
		int u = nxt() - 1, v = nxt() - 1;
		a[u].push_back(v);
		a[v].push_back(u);
		path = {u, v};
	}

	vector<char> used(n);
	used[path[0]] = used[path[1]] = 1;
	for (int _ = 0; _ < 2; ++_) {
		while (true) {
			int v = path.back();
			for (int x : a[v]) {
				if (!used[x]) {
					path.push_back(x);
					used[x] = 1;
					break;
				}
			}
			if (v == path.back()) {
				break;
			}
		}
		reverse(all(path));
	}

	printf("%d\n", (int)path.size());
	for (int x : path) {
		printf("%d ", x + 1);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 6904
/* ***********************************************
Author        :yang12138
Created Time  :2018年01月08日 星期一 01时33分21秒
File Name     :B.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=100;
char s[N];

void solve(){
	int A,B;
	scanf("%d%d",&A,&B);
	scanf("%s",s+1);
	bool flag=1;
	if(s[A+1]!='-') flag=0;

	for(int i=1;i<=A;i++){
		if(s[i]>='0' && s[i]<='9') continue;
		flag=0;
	}
	for(int i=A+2;i<=A+B+1;i++){
		if(s[i]>='0' && s[i]<='9') continue;
		flag=0;
	}
	if(flag) printf("Yes\n");
	else printf("No\n");
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ri register int
#define N 200005
using namespace std;
int n,k,ans=0,a[N]= {0};
template <typename T> inline void read(T &x) {
    T c=getchar(),f=0;
    for (; c<48||57<c; c=getchar()) if (c=='-') f=1;
    for (x=0; 48<=c&&c<=57; c=getchar()) x=(x<<3)+(x<<1)+(c^48);
    if (f) x=-x;
}
template <typename T> inline void print(T x) {
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
inline int g(int x,int k) {
	int ans=0;
	if (a[x]<0) ans=n+1;
	if (!a[x]) {
		if (k<0) return 0;
		return n-1;
	}
	if (a[x]>0) for (ri l=1,r=n,m=(l+r)>>1; l<=r; m=(l+r)>>1) {
		if (a[m]*a[x]<=k) ans=m,l=m+1;
		else r=m-1;
	} else for (ri l=1,r=n,m=(l+r)>>1; l<=r; m=(l+r)>>1) {
		if (a[m]*a[x]<=k) ans=m,r=m-1;
		else l=m+1;
	}
	if (a[x]<0) ans=n-ans+1;
	if (a[x]*a[x]<=k) ans--;
	return ans;
}
inline int f(int x) {
	int ans=0;
	for (ri i=1; i<=n; i++) ans+=g(i,x);
	return ans/2;
}
signed main() {
	read(n),read(k);
	for (ri i=1; i<=n; i++) read(a[i]);
	sort(a+1,a+1+n);
	for (ri l=-1e18,r=1e18,m=(l+r)>>1; l<=r; m=(l+r)>>1)
		if (f(m)>=k) ans=m,r=m-1;
		else l=m+1;
	print(ans);
    return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

bool odd(int x){
    string s;
    s = to_string(x);
    if(s.length() % 2 == 0)
        return false;
    return true;
}


int main(){
  FAST();

  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++){
      if(odd(i))
        ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool linear(int k,int n,int c[]){
  int i=0;
  c[n] = k;
  while(k != c[i]) ++i;
  
  if(i == n){
    return false;
  }
  else{
    return true;
  }
}

int main(){
  int n,s[10001],q,t[500];

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

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

  int cnt=0;
  for(int i=0; i<q; ++i){
    cnt+=linear(t[i],n,s);
  }

  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3108
def solve():
    N, T = [int(_) for _ in input().split()]
    res = 100000
    for i in range(N):
        c, t = [int(_) for _ in input().split()]
        if t <= T:
            res = min(res, c)
    if res < 1001:
        return res
    else:
        return 'TLE'

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
bool a[5000001] = {};

int main(){

  a[1] = true;
  for(int i=1;i<=1000000;i++){
    if(a[i]){
      a[i*2]=true;
      a[i*3]=true;
      a[i*5]=true;

    }
  }
  //for(int j = 2; j < 1000001; j+=2) a[j] = true;
  //for(int j = 3; j < 1000001; j+=3) a[j] = true;
  //for(int j = 5; j < 1000001; j+=5) a[j] = true;

  while(1){
    int m,n;
    cin >> m; if(m == 0)break;
    cin >> n;

    int count = 0;

    for(int i = m; i <= n; i++){
      if(a[i] == true)count++;
    }

    cout << count << endl;
  }
  return 0;
}



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

int main()
{
    int a,b,c;
    scanf("%d\n%d%d",&a,&b,&c);
    for(int i=b;i<=c;i++){
        if(i%a==0) {
                printf("OK\n");
                return 0;
        }

    }
    printf("NG\n");


    return 0;
}


Measured memory_bytes: 3764
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const int INF = (1LL<<30);
#else
const ll INF = (1LL<<60);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
 
signed main(void)
{
  string s;
  cin >> s;
  cout << s.substr(0, s.size()-8) << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include "stdio.h"

bool binarySearch(int matrix[], int N, int key){
  int left, mid, right;
  left = 0;
  right = N;
  
  while(left < right){
    mid = (int)( (left+right)/2. );
    
    if(matrix[mid] == key){
      return true;
    }else if(matrix[mid] > key){
      left = left;
      right = mid;
    }else{
      left = mid + 1;
      right = right;
    }  
  }
  return false;
}


int main(void){
  
  int N_sample;
  scanf("%d", &N_sample);
  
  int* sample = new int [N_sample];
  
  for(int i=0;i<N_sample;i++){
    scanf("%d", &sample[i]);
  }

  int N_target;
  scanf("%d", &N_target);

  int key;
  int cnt = 0;
  for(int i=0;i<N_target;i++){
    scanf("%d", &key);
    if(binarySearch(sample, N_sample, key)){
      cnt++;
    }
  }

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

  delete [] sample;

  return 0;
}


Measured memory_bytes: 2804
import collections

n=int(input())
arr=list(map(int,input().split()))
cnt=collections.Counter(arr)
total=0
for key in cnt.keys():
  total+=cnt[key]*(cnt[key]-1)//2
for i in range(n):
  tmp=total
  tmp-=cnt[arr[i]]*(cnt[arr[i]]-1)//2
  tmp+=(cnt[arr[i]]-1)*(cnt[arr[i]]-2)//2
  print(tmp)

Measured memory_bytes: 26780
#include <bits/stdc++.h>
#pragma GCC optimize(7)
#define int long long
using namespace std;
const int N=1e5+5;
int n,m,v,p,cnt;
int a[N];
signed main() 
{
	ios::sync_with_stdio(false);
	cin>>n>>m>>v>>p;//m个评委,每个评委给v个题目加分，选前p名 
	for (int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	if (v<=p)
	{
		for (int i=1;i<=n;i++) if (a[i]+m>=a[n-p+1]) cnt++;
		cout<<cnt<<endl;
	} else
	{
		for (int i=1;i<=n;i++) 
		{
			int j=n-i+1;//正数第j名 
			if (j<=p) 
			{
				cout<<n-i+1<<endl;
				break;
			}
			if (i+p-1>=v && a[i]+m>=a[n-p+1]) //取比自己低的人和最高的人加满 
			{
//				cout<<"CASE2"<<endl;
				cout<<n-i+1<<endl;
				break;
			}
			int tmp=v*m-(i+p-1)*m;//还需要给这么多
			int temp=0;
			for (int k=i+1;a[k]<a[i]+m,k<=n-p+1;k++)
				temp+=a[i]+m-a[k];
			if (temp>=tmp && a[i]+m>=a[n-p+1])
			{
				cout<<n-i+1<<endl;
				break;
			}
		}
	}
	return 0;
}






Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<string> words;
  while(n--)
  {
    string str;
    cin>>str;
    words.push_back(str); 
  }
  sort(words.begin(), words.end());
   vector<string> :: iterator it;
  it = unique(words.begin(), words.end());
  cout<<distance(words.begin(), it);
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    vector<int> lib(n);
    for (int i = 1; i <= n; ++i) lib[i-1] = i;
    int cnt = 1;
    int a, b;
    do {
        int flag = 11;
        rep(i,n) {
            if (flag%10) if (p[i] != lib[i]) flag -= 1;
            if (flag/10) if (q[i] != lib[i]) flag -= 10;
        }
        if (flag%10) a = cnt;
        if (flag/10) b = cnt;
        cnt++;
    } while (next_permutation(lib.begin(), lib.end()));
    int ans = abs(a-b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(998244353)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

struct mint {
	ll x;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
	bool operator==(const mint a) const {
		return x == a.x;
	}
	bool operator!=(const mint a) const {
		return x != a.x;
	}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> l(k), r(k);
    rep(i, k)cin >> l[i] >> r[i];
    vector<mint> dp(n+1), sum(n+1, 0);
    dp[0] = 1;
    rep(i, n){
        dp[i] += sum[i];
        rep(j, k){
            sum[min(n, i+l[j])] += dp[i];
            sum[min(n, i+r[j]+1)] -= dp[i];
        }
        sum[i+1] += sum[i];
    } 
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 6412