akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
bool prime(int i){
  bool res=true;
  int sup=(int)sqrt(i)+1;
  for(int j=2;j<=sup;j++){
    if(i%j==0)res=false;
  }
  if(i==2)res=true;
  if(i==1)res=false;
  return res;
}
signed main(){
  int q;cin>>q;
  vector<int> sum(100005,0);
  for(int i=3;i<=100001;i+=2){
    sum[i]=sum[i-2];
    if(prime(i)&&prime((i+1)/2)){
      sum[i]++;
    }
  }
  vector<int> res(q);
  rep(i,q){
    int l,r;cin>>l>>r;
    if(l==1)l=2;
    res[i]+=sum[r]-sum[l-2];
  }
  rep(i,q){
    cout<<res[i]<<"\n";
  }
  return 0;
}


Measured memory_bytes: 2176
n = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(n):
    minj = i
    for j in range(i, n):
        if A[j] < A[minj]:
            minj = j
    A[i], A[minj] = A[minj], A[i]
    if minj != i:
        cnt += 1
print(' '.join(map(str, A)))
print(cnt)


Measured memory_bytes: 5600
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int n;
ll t[100];

ll gcd(ll a, ll b) {
	if (b > a) return gcd(b, a);
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n) cin >> t[i];
	ll res = t[0];
	FOR(i, 1, n) {
		ll u = gcd(res, t[i]);
		res /= u;
		res *= t[i];
	}
	cout << res << endl;
	return 0;
}

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

long long a,b,c,d;

int main(){

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

    cin>>a>>b>>c>>d;
    cout<<max(max(a*c,b*d),max(a*d,b*c));

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <array>

std::array<int, 55> primes = {11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381};

int main() {
  int N;
  std::cin >> N;

  for(int i = 0; i < N; i++){
    std::cout << primes[i] << ' ';
  }
  std::cout << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		if (A>B) {
			System.out.println(A+A-1);
		} else if(A<B) {
			System.out.println(B+B-1);
		} else {
			System.out.println(A*2);
		}

	}
}


Measured memory_bytes: 22740
// abc131_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N,L;
    cin >> N >> L;

    int sm = 0;
    int mn = INF;
    REP(i, N){
        int a = L + i;
        sm += a;
        if (abs(a) < abs(mn)) {
            mn = a;
        }
    }

    print(sm - mn);

    return 0;
}


Measured memory_bytes: 256
// include
//------------------------------------------

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
// container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
// for
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

// const

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

// debug
//------------------------------------------

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    int n; cin >> n;
    int m; cin >> m;
    vector<char> a(m);
    REP(i, m) cin >> a[i];
    FOR(i, n, 99999) {
        bool flag = true; 
        string tmp = std::to_string(i);
        REP(j, tmp.length()) {
            REP(k,m) {
                if (a[k] == tmp[j]) flag = false;
            }
        }
        if (flag) {
            cout << i << endl;;
            break;
        }
    
    }
    return 0;
}

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

const int N = 4;

int main(){
  int n;
  cin >> n;
  vector<int> cnt(N);
  rep(i,n){
    string s;
    cin >> s;
    if(s == "AC") cnt[0]++;
    else if(s == "WA") cnt[1]++;
    else if(s == "TLE") cnt[2]++;
    else if(s == "RE") cnt[3]++;
  }
  printf("AC x %d\n", cnt[0]);
  printf("WA x %d\n", cnt[1]);
  printf("TLE x %d\n", cnt[2]);
  printf("RE x %d\n", cnt[3]);
  return 0;
}


Measured memory_bytes: 3732
n,l=map(int,input().split())

taste=l-1

apples=[]
for i in range(1,n+1):
    apples.append(i+taste)
#print(apples)

plus=[]
for j in apples:
    if j>=0:
        plus.append(j)

minas=[]
for k in apples:
    if k<0:
        minas.append(k)

if len(plus)>0:
    print(sum(plus[1:])+sum(minas))

else:
    print(sum(minas[:-1]))


Measured memory_bytes: 3064
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <deque>
using namespace std;


int main()
{
    int q;
    int d,x,com;
    deque<int> v;
    
    cin >> q;
    for(int i=0; i<q; i++){
        cin >> com;
        
        if(com == 0){
            cin >> d >> x;
            if(d==0)v.push_front(x);
            else    v.push_back(x);
        }
        else if(com == 1){
            cin >> d;
            cout << v[d] << endl;
        }
        else{
            cin >> d;
            if(d==0)v.pop_front();
            else    v.pop_back();
        }
    }
    
    return 0;
}



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

int main() {
  string S;
  cin >> S;
  int price = 700;
  if (S[0] == 'o') price += 100;
  if (S[1] == 'o') price += 100;
  if (S[2] == 'o') price += 100;
  cout << price << endl;
}
  

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> h;
    for (int i = 0; i < N; i++) {
        int hi;
        cin >> hi;
        h.push_back(hi);
    }
    h.push_back(0);

    int count = 0;
    while (*max_element(h.begin(), h.end()) > 0){
        int prev = h.at(0);
        for (int i = 1; i < N + 1; i++) {
            if (prev > 0 && h.at(i) <= 0) {
                count++;
            }
            prev = h.at(i);
        }
        for (int i = 0; i < N; i++) {
            h[i]--;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}
	var cnt int
	var ans int
	for i := 0; i < n-1; i++ {
		if h[i] >= h[i+1] {
			cnt++
			ans = max(cnt, ans)
		} else {
			cnt = 0
		}
	}
	fmt.Println(ans)
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}


Measured memory_bytes: 5504
#include<cstdio>
#include<algorithm>
#include<vector>
#define pii pair<int,int>
using namespace std;
int n, D[101000], Old[101000];
vector<pii>OO[101000];
void Add(int a, int b) {
	printf("%d %d\n", a, b);
}
int main() {
	int i, j, k;
	scanf("%d", &n);
	int sz = 1;
	while (sz < n)sz *= 2;
	if (sz == n) {
		puts("No");
		return 0;
	}
	puts("Yes");
	Add(1, 2);
	Add(2, 3);
	Add(3, n+1);
	Add(n+1, n+2);
	Add(n+2, n+3);

	for (i = 4; i < n; i += 2) {
		Add(i, i + 1);
		Add(i + 1, n + 1);
		Add(n + 1, n + i);
		Add(n + i, n + i + 1);
	}
	if (n % 2 == 0) {
		Add(n - 1, n);
		Add(n + (n ^ (n - 1) ^ 1), n + n);
	}
	
}

Measured memory_bytes: 5120
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse = True)
ans = A[0]
L = [0] * N
cnt = 1
for i in range(N - 2):
  ans += A[cnt]
  L[cnt] += 1
  if L[cnt] >= 2:
    cnt += 1

print(ans)

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

int main() {
  int n, m;
  cin >> n >> m;
  ll a[3][n];
  rep(i, n) cin >> a[0][i] >> a[1][i] >> a[2][i];

  ll ans = 0;
  rep(i, 8) {
    ll total[n] = {};
    ll tmp = 0;
    rep(j, 3) {
      if (i & (1 << j)) {
        rep(k, n) total[k] += a[j][k];
      }
      else {
        rep(k, n) total[k] -= a[j][k];
      }
    }

    sort(total, total + n, greater<ll>() );
    rep(j, m) tmp += total[j];
    if (tmp > ans) ans = tmp;
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define pb push_back
#define ff first
#define ss second
#define SIZE 200001
#define INF 2e9 + 9
#define BIG_INF 1e18 + 9
#define acmpIN "input.txt"
#define acmpOUT "output.txt"

//#pragma GCC optimize("Ofast")
//



int x, y, n, m, k, r[SIZE], g[SIZE], c[SIZE];


bool comp(const int& x, const int& y)
{
    return x > y;
}


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen(acmpIN, "r", stdin);
//    freopen(acmpOUT, "w", stdout);



    cin >> x >> y >> n >> m >> k;
    for(int i = 0; i < n; i++) cin >> r[i];

    for(int i = 0; i < m; i++) cin >> g[i];

    for(int i = 0; i < k; i++) cin >> c[i];



    sort(c, c + k, comp);
    sort(r, r + n, comp);
    sort(g, g + m, comp);


    multiset<int> red, green;
    ll sumRed = 0, sumGreen = 0;

    for(int i = 0; i < x; i++) {red.insert(r[i]); sumRed += r[i];}
    for(int i = 0; i < y; i++) {green.insert(g[i]); sumGreen += g[i];}


    for(int i = 0; i < k; i++)
    {
        int rb = red.size() ? *red.begin() : 0, gb = green.size() ? *green.begin(): 0;
//        cout << rb << ' ' << gb << endl;
        if(c[i] > rb && c[i] > gb)
        {
            if(rb < gb)
            {
                sumRed -= ll(rb);
                if(red.size())
                    red.erase(red.begin());
                red.insert(c[i]);
                sumRed += ll(c[i]);
            }else
            {
                sumGreen -= ll(gb);
                if(green.size())
                    green.erase(green.begin());
                green.insert(c[i]);
                sumGreen += ll(c[i]);
            }
        }else if(c[i] > rb)
        {
            sumRed -= ll(rb);
            if(red.size())
                red.erase(red.begin());
            red.insert(c[i]);
            sumRed += ll(c[i]);

        }else if(c[i] > gb)
        {
            sumGreen -= ll(gb);
            if(green.size())
                green.erase(green.begin());
            green.insert(c[i]);
            sumGreen += ll(c[i]);
        }

    }

    cout << sumRed + sumGreen;



    return 0;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  int a;
  cin>>a;
  cout <<a+a*a+a*a*a;
}


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

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;

string str;

int main(){
    cin >> str;
    int ans = 1000;
    for(int i = 0; i < 26; i++) {
        int cnt = 0;
        int pre = 0;
        rep(j,str.size()) {
            if(str[j] -'a' != i) {
                cnt++;
            } else {
                cnt = 0;
            }
            pre = max(pre,cnt);
        }
        ans = min(ans, pre);
    }
    cout << ans << endl;
}
































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

int main(){
  int n, w, h, s, t;
  while(true){
    cin >> n;
    if(n == 0)
      break;

    cin >> w >> h;
    vector< vector<int> > plane(w, vector<int>(h, 0));
    int x, y;
    for(int i=0; i<n; i++){
      cin >> x >> y;
      plane[x-1][y-1] = 1;
    }

    cin >> s >> t;
    int nmax = 0;
    for(int i=0; i<w-s+1; i++){
      for(int j=0; j<h-t+1; j++){
        int sum = 0;
        for(int ti=0; ti<s; ti++){
          for(int tj=0; tj<t; tj++){
            sum += plane[i + ti][j + tj];
          }
        }
        nmax = max(nmax, sum);
      }
    }

    cout << nmax << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int N;
    double p[3000];
    double dp[3000][3000];
    cin >> N;
    rep(i, N){
        cin >> p[i+1];
    }

    rep(i, N+1){
        rep(j, N+1){
            if (i == 0 && j == 0){
                dp[0][0] = 1;
            } else if (i < j){
                dp[i][j] = 0;
            } else if (j == 0) {
                dp[i][j] = dp[i-1][j]*(1-p[i]);
            } else {
                dp[i][j] = dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
            }
//            cout << dp[i][j] << endl;
        }
    }

    double ans = 0.0;
    REP(i, N/2+1, N+1){
        ans += dp[N][i];
    }

    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 70528
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
using namespace std;
int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){return x+y-min(x,y);}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
int main()
{
    int n;
    cin>>n;
    long long a[n];
    rep(i,n)
    {
        cin>>a[i];
    }
    int cnt=0;
    bool flag;
    rep(i,n)
    {
        flag=true;
        while(flag)
        {
            cnt++;
            flag=(a[i]%2==0);
            a[i]/=2;
        }
    }
    W(cnt-n)
    return 0;
}

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

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

    set<char> st;
    rep(i, s.size()) st.insert(s[i]);
    if (st.size() == 1) cout << "No" << endl;
    else cout << "Yes" << endl;
}


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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int n;
	cin >> n;
	int minus = 0;
	ll sum = 0;
	ll mini = 1000000001;
	ll a;
	for(int i = 0; i < n; i++){
		cin >> a;
		sum += abs(a);
		mini = min(mini,abs(a));
		if(a < 0)minus++;
	}
	if(minus % 2)cout << sum - 2 * mini << endl;
	else cout << sum << endl;
	return 0; 
}


Measured memory_bytes: 256
#include <stdio.h>
#define swap(type, x, y) do{ type temp; temp = x; x = y; y = temp;}while(0);

int main(void) {
    int backnum[3][8] = {0};
    double time[3][8] = {0};
    int sup_backnum[8] = {0};
    double sup_time[8] = {0};
    int i, j, k;
    int count = 0;
    
    for(i = 0; i < 3; i++) {
        for(j = 0; j < 8; j++) {
            scanf("%d %lf", &backnum[i][j], &time[i][j]);
        }
    }
    
    for(k = 0; k < 3; k++) {
        for(i = 0; i < 8; i++) {
            for(j = i + 1; j < 8; j++) {
                if(time[k][i] > time[k][j]) {
                    swap(double, time[k][i], time[k][j]);
                    swap(double, backnum[k][i], backnum[k][j]);
                }
            }
        }
    }
    
    for(i = 0; i < 3; i++) {
        for(j = i + 1; j < 3; j++) {
            if(time[i][2] > time[j][2]) {
                swap(double, time[i][2], time[j][2]);
                swap(double, backnum[i][2], backnum[j][2]);
            }
        }
    }
    
    for(k = 0; k < 3; k++) {
        for(i = 0; i < 2; i++) {
            
            sup_backnum[count] = backnum[k][i];
            
            sup_time[count] = time[k][i];
            
            count++;
        }
    }
    
    
    for(i = 6; i < 8; i++) {
        sup_backnum[i] = backnum[i - 6][2];
        sup_time[i] = time[i - 6][2];
    }
    
    for(i = 0; i < 8; i++) {
        printf("%d %.2f\n", sup_backnum[i], sup_time[i]);
    }

    
    return(0);
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
bool flg[100][100];
REP(i,100) REP(j,100) flg[i][j] = true;
int w,h,n;
cin >> w >> h >> n;
REP(i,n){
int a,x,y;
cin >> x >> y >> a;
if(a == 1){
REP(i,x) REP(j,h) flg[i][j] = false;
}else if(a == 2){
FOR(i,x,w) REP(j,h) flg[i][j] = false;
}else if(a == 3){
REP(i,y) REP(j,w) flg[j][i] = false;
}else{
FOR(i,y,h) REP(j,w) flg[j][i] = false;
}
}
int ans = 0;
REP(i,w) REP(j,h) if(flg[i][j]) ans++;
cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

typedef long long ll;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
    int n;
    cin >> n;

    int a[n*3];
    for(int i = 0;i < n*3;i ++)
         scanf("%d",&a[i]);

    ll s = 0, c = 0;
    sort(a, a + 3*n);
    for(int i = 3*n - 2;i >= 0;i -= 2){
         s += a[i];
         c ++;
         if(c == n)
             break;
    }
    cout << s << endl;
	return 0;
}


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

int main(){
  int n;
  while(cin >> n && n){
    int a[101];
    for(int i=0;i<n+1;i++) cin >> a[i];
    for(int i=0;i<n+1;i++){
      int c = a[1] - a[0],prev = a[0];
      bool f = false;
      if(i == 0 || i == 1) c = a[3] - a[2];
      if(i == 0) prev = a[1];
      for(int j=1;j<n+1;j++){
        if(i == j || (i == 0 || i == 1) && j == 1) continue;
        if(a[j] - prev != c){
          f = true;
          break;
        }
        prev = a[j];
      }
      if(!f){
        cout << a[i] << endl;
        break;
      }
    }

  }
}

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

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
           
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll max1=max(a*c,a*d);
    ll max2=max(b*c,b*d);
    cout<<max(max1,max2)<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    string s;
    cin >> s;
    if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi")
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

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

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    int N;
    int M;
    cin >> N >> M;
    vector<int> X(M);
    vector<int> L(M);
    rep(i,M){
        cin >> X[i];
    }
    sort(X.begin(), X.end());

    for(int i=0; i<M-1; i++){
        L[i] = X[i+1]-X[i];
    }
    sort(L.begin(), L.end(), greater<int>());

    int kukan = 0;

    if(M<=N){
        cout << 0 <<endl;
    } else {
        rep(i, N-1){
            kukan = kukan + L[i];
        }
        cout << X.back()-X.front() - kukan << endl;
    }

    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()

int main() {
	int k;
	string s;
	cin >> k >> s;
	if (s.size() > k) {
		rep(i, k) {
			cout << s[i];
		}
		
		cout<<"..." << endl;
		return 0;
	}
	cout << s << endl;

}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[16]; int h=0;
    for(int i=0;i<16;i++)  cin>>s[i];
    if(s[0]!='C')  h++;
    if(s[1]!='O')  h++;
    if(s[2]!='D')  h++;
    if(s[3]!='E')  h++;
    if(s[4]!='F')  h++;
    if(s[5]!='E')  h++;
    if(s[6]!='S')  h++;
    if(s[7]!='T')  h++;
    if(s[8]!='I')  h++;
    if(s[9]!='V')  h++;
    if(s[10]!='A')  h++;
    if(s[11]!='L')  h++;
    if(s[12]!='2')  h++;
    if(s[13]!='0')  h++;
    if(s[14]!='1')  h++;
    if(s[15]!='6')  h++;
    cout<<h;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    ll N, W;
    cin >> N >> W;
    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1));
    REP(n, N) {
        ll w, v;
        cin >> w >> v;
        REP(w2, W + 1) {
            dp[n + 1][w2] = max(dp[n + 1][w2],
                                dp[n][w2]);

            if (w2 + w <= W) {
                dp[n + 1][w2 + w] = max(dp[n + 1][w2 + w],
                                        dp[n][w2] + v);
            }
        }
    }
    ll ans = 0;
    REP(w, W + 1) {
        ans = max(dp[N][w], ans);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    if(s.size() < 4){
        cout<<"No"<<endl;
        return 0;
    }
    string t = "YAKI";
    for(int i=0; i<4; i++){
        if(s[i] != t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

char table[100][100];
using namespace std;


int f(int w, int h, int x, int y){
  int ret = 0;
  if(x < 0 || y < 0 || x >= w || y >= h){
    return 0;
  }
  if(table[y][x] == '#'){
    return 0;
  }
  ret = 1;
  table[y][x] = '#';
  ret += f(w, h, x, y + 1);
  ret += f(w, h, x, y - 1);
  ret += f(w, h, x - 1, y);
  ret += f(w, h, x + 1, y);
  return ret;
}

int main(){
  while(true){
    int startX, startY;
    int width, height;
    cin >> width >> height;
    if(width == 0 && height == 0){
      break;
    }
    for(int i = 0; i < height; i++){
      for(int j = 0; j < width; j++){
        cin >> table[i][j];
        if(table[i][j] == '@'){
          //cout << "startX = " << j << " startY = " << i << endl;
          startX = j;
          startY = i;
          table[i][j] = '.';
        }
      }
      
    }
    cout << f(width, height, startX, startY) << endl;
  }
}



Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i, n) for(int i = n-1; i >= (int)0; i--)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    ll a,b;
    std::cin >> a>>b;
    if(a*b<=0ll){
        std::cout << "Zero" << std::endl;
        exit(0);
    }
    if(a>0ll)std::cout << "Positive" << std::endl;
    
    else{
        int cnt=min(b,0ll)-a;
        if(cnt%2==1ll)std::cout << "Positive" << std::endl;
        else std::cout << "Negative" << std::endl;    
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  string s;
  cin>>s;
  int N=s.size();
  int64_t ans=0;
  for(int p=0;p<(1<<N-1);p++){
    int64_t now=s[0]-'0';
    int64_t sum=0;
    for(int i=0;i<N-1;i++){
      if((p>>i)&1){sum+=now;now=s[i+1]-'0';}
      else{now*=10;now+=s[i+1]-'0';}
    }
    sum+=now;
    ans+=sum;
  }
  cout<<ans<<endl;
  return 0;  
}

Measured memory_bytes: 3628
function main(inputs) {
  const [X, Y] = inputs[0].split(" ").map(v=>parseInt(v));
  for(let kame=0;kame<=X;kame++){
    const tsuru = X-kame;
    if(kame*4+tsuru*2 === Y){
      console.log("Yes");
      return;
    }
  }
  console.log("No");
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n'));

Measured memory_bytes: 29580
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  int a[n+2];
  int total = 0;
  a[0] = 0;
  a[n+1] = 0;
  FOR(i,1,n+1){
    cin >> a[i];
    total += abs(a[i]-a[i-1]);
  }
  total += abs(a[n+1]-a[n]);
  FOR(i,1,n+1) cout << total+abs(a[i+1]-a[i-1])-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1])) << endl;

}


Measured memory_bytes: 1664
import java.util.Scanner;
 
public class Main{
	static int M = 1000000007;
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int pre = 0, curr = 1, ans = 0;
		boolean flag = false;
		while (num > 0) {
			curr = num % 10;
			if (pre == curr) {
				ans++;
				pre = curr;
			} else {
				ans = 1;
				pre = curr;
			}
			if (ans >= 3) {
				flag = true;
				break;
			}
			num /= 10;
 
		}
		System.out.println(flag == true ? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import defaultdict


def main():
    n = int(input().strip())
    a_list = map(int, input().split())

    b_2_e = defaultdict(int)
    for i, a in enumerate(a_list):
        emp_i = i + 2
        b_2_e[a] += 1

    for i in range(n):
        print(b_2_e[i + 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 45676
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n, m; cin >> n >> m;
	vector<vector<int>> d(n, vector<int>(m));

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

	set<int> s;
	for (int i = 0; i < 10000; i++) {
		s.insert(i*i);

	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			int val = 0;
			for (int k = 0; k < m; k++) {
				int diff = abs(d[i][k] - d[j][k]);
				val += diff * diff;
			}

			if (s.count(val))ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
n = int(input())
s = input()
x, now_num, max_num = 0, 0, 0

for c in s:
    if c == 'I':
        now_num += 1
    else:
        now_num -= 1
    if now_num > max_num:
        max_num = now_num

print(int(max_num))

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int n,m;
    cin>>n>>m;
    int a[200200],b[200200];
    bool c[200200],d[200200];
    REP(i,200200)c[i]=d[i]=false;
    REP(i,m){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        if(a[i]==0)c[b[i]]=true;
        if(b[i]==0)c[a[i]]=true;
        if(a[i]==n-1)d[b[i]]=true;
        if(b[i]==n-1)d[a[i]]=true;
    }
    for(int i=1;i<n;i++){
        if(c[i]&&d[i]){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<cstring>
#define ll long long int
#define MOD 1000000007
using namespace std;

ll dp[22][(1 << 22)];
int match(vector<vector<int> > &compat, int i, int womenSubset, int N) {
    if(i == (N + 1)) { // Base Case
        if(womenSubset == 0) return 1; // All Women Are Paired i.e. Right Config.
        else return 0; // Some Women Is Not Paired i.e. Invalid.
    }
    if(dp[i][womenSubset] != -1) return dp[i][womenSubset];
    ll ans = 0;
    for(int women = 0; women < N; women++) {
        bool available = (((1 << women) & (womenSubset)) == 0) ? 0 : 1;
        if(available && compat[i][women + 1]) {
            ans = (ans + match(compat, (i + 1), (womenSubset ^ (1 << women)), N)) % MOD;
        }
    }
    return (dp[i][womenSubset] = ans);
}

int main() {
    int n;
    cin >> n;
    vector<vector<int> > compat((n + 1), vector<int> (n + 1));
    memset(dp, -1, sizeof(dp));
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) cin >> compat[i][j];
    }
    cout << match(compat, 1, ((1 << n) - 1), n) << endl;
    return 0;
}

Measured memory_bytes: 724408
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a[3], k;
	cin >> a[0] >> a[1] >> a[2] >> k;
	for (int i = 0; i < k; i++) {
		sort(a, a + 3);
		a[2] *= 2;
	}
	cout << a[0] + a[1] + a[2] << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
const int maxn = 1<<19, mod = 1e9 + 7;
int n;
vi g[maxn];
ll t = 0;
void dfs(int v, int p = -1, int h = 0) {
	t += h;
	for(auto &i : g[v]) if(i != p) dfs(i, v, h + 1);
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	vi a(n), sz(n+1, 1);
	map<ll, int> id;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		id[a[i]] = i+1;
	}
	sort(rall(a));
	vector<pair<int, int>> edges;
	for(auto x : a) {
		int i = id[x];
		if(sz[i] == n) continue;
		ll nd = x + 2*sz[i] - n;
		if(nd < x && id.count(nd)) {
			edges.pb({i, id[nd]});
			sz[id[nd]] += sz[i];
		}
	}
	for(auto i : edges) {
		int x = i.first, y = i.second;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(id[a.back()]);
	if(edges.size() != n-1 || t != a.back()) return cout << -1, 0;
	for(auto i : edges) cout << i.first << " " << i.second << '\n';
}


Measured memory_bytes: 28536
a, b = map(int, input().split())

an = 0
for x in range(a, b + 1):
    x = str(x)
    f = True
    for i in range(len(x)):
        if x[i] != x[len(x) - i - 1]:
            f = False
    if f:
        an += 1
print(an)


Measured memory_bytes: 2940
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		boolean ok = true;
		for(int i = 0; i < S.length; i++) {
			if(i % 2 == 0) {
				if(S[i] == 'L')
					ok = false;
			}
			else {
				if(S[i] == 'R')
					ok = false;
			}
		}
		System.out.println(ok ? "Yes" : "No");

	}

}


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

int main(){
  int N,K;
  cin>>N>>K;
  for(int i=0;i<N;i++)
    cin;
  N-=K;
  if(N%(K-1)==0)
    cout<<1+N/(K-1)<<endl;
  else
    cout<<1+1+N/(K-1)<<endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    int N;
    cin>>N;
    int ans=0;
    for(int i=1;i<=N;i++){
        int keta=0;
        int n=i;
        while(n!=0){
            keta++;
            n/=10;
        }
        if(keta%2==1) ans++;
    }
    cout<<ans<<endl;
}


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

int main(){
    int K;
    cin >> K;
    int A,B;
    cin >> A >> B;

    if(B/K-A/K==0&&A%K!=0){
        cout << "NG" << endl;
    }
    else{
        cout << "OK" << endl;
    }
}

Measured memory_bytes: 3624
q, h, s, d = map(int, input().split())
n = int(input())

# 2L min cost
cost2 = min(q*8, h*4, s*2, d)
# 1L min cost
cost1 = min(q*4, h*2, s)

ans = (n // 2) * cost2
if n % 2 == 1:
  ans += cost1
print(ans)

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

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

    int64_t dp[2] = {0};
    dp[0] = n.back() - '0';
    dp[1] = 10 - dp[0];
    for(int i=n.size()-2;i>=0;--i){
        int64_t prev[2] = {dp[0], dp[1]};
        dp[0] = min(prev[0] + (n[i] - '0'), prev[1] + (n[i] - '0' + 1));
        dp[1] = min(prev[0] + 10 - (n[i] - '0'), prev[1] + 10 - (n[i] - '0' + 1));
    }
    cout << min(dp[0], dp[1] + 1) << endl;
        
    return 0;
}

Measured memory_bytes: 1412
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <cmath>
#include <queue>
using namespace std;

typedef complex<double> P;

const double INF = (double)(1<<29);
const double EPS = 1e-7;

int n, ans;
vector<int> G[20][20];
double r, theta;
bool  memo[20][20][10001];
P v[20];

struct state{
  int prev,pos,sum;
  double dis;
  state(int p=0, int po=0, int s=0, double d=0):prev(p),pos(po),sum(s),dis(d){}
  bool operator < (const state &s) const {
    return dis > s.dis;
  }
};

bool equal(double a, double b){
  return fabs(a-b) < EPS;
}

double calcTheta(P a, P b, P c){
  double A = abs(b - a);
  double B = abs(b - c);
  double C = abs(a - c);
  double ans = acos((A*A + B*B - C*C) / (2*A*B));
  return M_PI - ans;
}

/*
void dfs(int prev, int pos, int sum, double dis){
  //if(memo[prev][pos][sum] <= dis || equal(memo[prev][pos][sum],dis)) return;
  ans = max(ans,sum);
  for(int i=0;i<G[prev][pos].size();i++){
    int next = G[prev][pos][i];
    if(dis + abs(v[pos]-v[next]) > r || memo[pos][next][sum+1] <= dis + abs(v[pos]-v[next]) || equal(memo[pos][next][sum+1], dis + abs(v[pos]-v[next]))) continue;
    memo[pos][next][sum+1] = dis + abs(v[pos]-v[next]);
    dfs(pos, next, sum+1, dis+abs(v[pos]-v[next]));
  }
}
*/

void bfs(){
  priority_queue<state> Q;
  state u,next;
  for(int i=1;i<n;i++){
    if(abs(v[i]-v[0]) > r) continue;
    memo[0][i][1] = true;
    Q.push(state(0,i,1,abs(v[i]-v[0])));
  }

  while(!Q.empty()){
    u = Q.top();
    Q.pop();
    ans = max(ans,u.sum);
    for(int i=0;i<G[u.prev][u.pos].size();i++){
      next = state(u.pos, G[u.prev][u.pos][i], u.sum+1, u.dis);
      next.dis += abs(v[u.pos]-v[next.pos]);
      if(next.dis > r || memo[u.pos][next.pos][next.sum]) continue;
      memo[u.pos][next.pos][next.sum] = true;
      Q.push(next);
    }
  }
}

int main(){
  while(cin >> n){
    ans = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        G[i][j].clear();
        for(int k=0;k<10001;k++) memo[i][j][k] = false;
      }
    }

    cin >> r >> theta;
    for(int i=0;i<n;i++){
      int x,y;
      cin >> x >> y;
      v[i] = P(x,y);
    }
    theta *= M_PI / 180.0;

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i == j) continue;
        for(int k=0;k<n;k++){
          if(i == k || j == k) continue;
          if(calcTheta(v[i],v[j],v[k]) < theta) G[i][j].push_back(k);
        }
      }
    }

    /*
    for(int i=1;i<n;i++){
      if(abs(v[i]-v[0]) > r) continue;
      memo[0][i][1] = abs(v[i]-v[0]);
      dfs(0, i, 1, abs(v[i]-v[0]));
      }
    */
    bfs();

    cout << ans << endl;
  }
}

Measured memory_bytes: 5420
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

int F(unsigned long long int A, unsigned long long int B)
{
    int d = 0;

    for (unsigned long long int i = 1;; i*=10) {
        if(!(B/i)) {
            return d;
        }
        d++;
    }
}

int main()
{
	unsigned long long int N;
    cin >> N;
    for (unsigned long long int i = sqrt(N); i > 0; i--) {
        if (N%i) {
            continue;
        } else {
            cout << F(i, N/i) << endl;
            return 0;
        }
    }

	return 0;
}


Measured memory_bytes: 256
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
dump(N, P, Q)

factrials = it.permutations(range(1, N+1), N)
a = -1
b = -1
for i, fact in enumerate(it.permutations(range(1, N+1), N)):
    dump(list(zip(list(fact), P)), list(zip(list(fact), Q)))
    if all([x == y for (x, y) in zip(list(fact), P)]):
        a = i
        dump("  a=", a)
    if all([x == y for (x, y) in zip(list(fact), Q)]):
        b = i
        dump("  b=", b)
    dump(fact)
print(abs(a-b))


Measured memory_bytes: 52440
import sys
readline = sys.stdin.readline
def dfs(root):
    visited = [False] * n
    queue = [(0, root)]
    longest = (-1, -1)
    while queue:
        total_weight, node = queue.pop()
        if visited[node]: continue
        visited[node] = True
        longest = max(longest, (total_weight, node))
        queue += [(total_weight + w, t) for w, t in edges[node] if not visited[t]]
    return longest
n = int(readline())
edges = [set() for _ in range(n)]
for _ in range(n - 1):
    s, t, w = map(int, readline().split())
    edges[s].add((w, t))
    edges[t].add((w, s))
_, ln = dfs(0)
ld, _ = dfs(ln)
print(ld)

Measured memory_bytes: 52868
def main():
    n=int(input())
    g=[[] for _ in [0]*n]
    if n==3:
        print(2)
        print(1,3)
        print(2,3)
    elif n%2==0:
        print((n-2)*n//2)
        for i in range(1,n+1):
            for j in range(i+1,n+1):
                if i+j!=n+1:
                    print(i,j)
    else:
        n-=1
        print((n*(n-2))//2+n)
        for i in range(1,n+1):
            for j in range(i+1,n+1):
                if i+j!=n+1:
                    print(i,j)
        for i in range(1,n+1):
            print(i,n+1)
main()

Measured memory_bytes: 3612