akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll W,H,N;
    cin>>W>>H>>N;
    
    ll mxw=W,mxh=H,mnw=0,mnh=0;
    REP(i,N){
        ll x,y,a;
        cin>>x>>y>>a;
        switch(a){
            case 1:
                mnw=max(mnw,x);
            break;
            case 2:
                mxw=min(mxw,x);
            break;
            case 3:
                mnh=max(mnh,y);
            break;
            case 4:
                mxh=min(mxh,y);
            break;
        }
    }
    //s(mxh,mnh,mxw,mnw)
    if((mxh-mnh)<0||(mxw-mnw)<0){
        cout<<0;return 0;
    }
    ll S=(mxh-mnh)*(mxw-mnw);
    cout<<S;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc039_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int cnt(string s) {
  ll tmp = 0;
  ll sum = 0;
  char c = s[0];
  rep(i, s.size()) {
    if (c == s[i])
      tmp++;
    else {
      if (tmp > 1) sum += tmp / 2;
      tmp = 1;
      c = s[i];
    }
  }
  if (tmp > 1) sum += tmp / 2;
  return sum;
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S;
  ll K;
  cin >> S >> K;
  int N = S.size();
  set<char> c;
  rep(i, N) c.insert(S[i]);

  ll ans = 0;
  ans = cnt(S);
  if (K == 1) {
    cout << ans << endl;
    return 0;
  } else if (c.size() == 1) {
    cout << S.size() * K / 2 << endl;
    return 0;
  }

  ans *= K;
  if (S[0] == S[N - 1]) {
    int a = 0;
    rep(i, N) {
      if (S[0] == S[i])
        a++;
      else
        break;
    }
    int b = 0;
    for (int i = N - 1; i >= 0; i--) {
      if (S[0] == S[i])
        b++;
      else
        break;
    }
    ans -= ((a / 2) + (b / 2) - (a + b) / 2) * (K - 1);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3584
x,y,a,b,c=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
l=[]
for i in range(x):
    l.append(A[i])
for i in range(y):
    l.append(B[i])
for i in C:
    l.append(i)
l.sort(reverse=True)
print(sum(l[:(x+y)]))

Measured memory_bytes: 115436
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();
        int T = sc.nextInt();

        int Z = T/A;
        System.out.println(Z*B);

        }

    }

Measured memory_bytes: 21844
# ABC057b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
c = [list(map(int, input().split())) for _ in range(m)]

ans = [0] * len(a)

for i in range(len(a)):
    for j in range(len(c)):
        if (abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]) < abs(a[i][0] - c[ans[i]][0]) + abs(a[i][1] - c[ans[i]][1])):
            ans[i] = j

for i in ans:
    print(i+1)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
        int num, i = 0, j, k;
        int keta[10] = { 0 };
        int ans[10] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
        int tmpans = 1;

        while ( scanf( "%d", &num ) == 1 ) {
                i = 0;
                while ( num / 2 ) {
                        keta[i] = num % 2;
                        num /= 2;
                        i++;
                }
                keta[i] = num % 2;

                for ( j = 0 ; j <= i ; j++ ) {
                        if ( keta[j] == 1 ) {
                                if ( j == i ) {
                                        printf( "%d\n", ans[j] );
                                } else {
                                        printf( "%d ", ans[j] );
                                }
                        }
                }

        }
        return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

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

  ll ans0 = 0;
  for (ll i = 0; i < s.size(); ++i) {
    if (i%2 == 0) {
      if (s[i] == '1') ++ans0;
    } else {
      if (s[i] == '0') ++ans0;
    }
  }

  ll ans1 = 0;
  for (ll i = 0; i < s.size(); ++i) {
    if (i%2 != 0) {
      if (s[i] == '1') ++ans1;
    } else {
      if (s[i] == '0') ++ans1;
    }
  }

  cout << min(ans0, ans1) << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  if (abs(a-b-1)%2)
    cout << "Alice" << endl;
  else
    cout << "Borys" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	int [][] via;
	boolean [][] used;
	
	void printPath1_aux(int begin, int end) {
	    if (via[begin][end] == begin) {
	        if (begin != end){
//	            System.out.printf("%d ", begin);
	        	used[begin][end] = true;
	        	used[end][begin] = true;
	        }
	        return;
	    }

	    printPath1_aux(begin, via[begin][end]);
	    printPath1_aux(via[begin][end], end);
	}

	void printPath1(int start, int goal) {
	    printPath1_aux(start, via[start][goal]);
	    printPath1_aux(via[start][goal], goal);
//	    System.out.printf("%d\n", goal);
	}
	
	private void doit(){
		
		Scanner sc = new Scanner(System.in);
		long mod = 1000000007;
		int INF = 1 << 29;
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [][] pass = new int[n][n];
			int [][] orig = new int [n][n];
			via = new int[n][n];
			used = new boolean[n][n];
			for(int i =0; i < n;i++){
				Arrays.fill(pass[i], INF);
				pass[i][i] = 0;
				Arrays.fill(orig[i], INF);
				orig[i][i] = 0;
				
				Arrays.fill(via[i], i);
			}
			
			for(int i = 0; i < m; i++){
				int a = sc.nextInt() - 1;
				int b = sc.nextInt() - 1;
				int c = sc.nextInt();
				pass[a][b] = c;
				pass[b][a] = c;
				orig[a][b] = c;
				orig[b][a] = c;
			}
			
			for(int j = 0; j < n; j++){
				for(int i = 0; i < n; i++){
					for(int k = 0; k < n; k++){
//						pass[i][k] = Math.min(pass[i][k], pass[i][j] + pass[j][k]);
						if(pass[i][k] > pass[i][j] + pass[j][k]){
							pass[i][k] = pass[i][j] + pass[j][k];
							via[i][k] = j;
						}
					}
				}
			}
			
			for(int i =0; i < n;i++){
				for(int j = 0; j <n; j++){
//					debug(i, j, pass[i][j]);
					printPath1(i, j);
				}
			}
			
			int count = 0;
			for(int i =0; i < n; i++){
				for(int j = i+ 1; j < n; j++){
					if( orig[i][j] == INF || used[i][j]) continue;
					
					count++;
				}
			}
			System.out.println(count);
		}

	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 14916
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


using mint = Fp<MOD>;


mint s[2010];
mint t[2010];
mint dp[2010][2010];
mint sm[2010][2010];

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, n) cin >> s[i];    
    rep(i, m) cin >> t[i];
    
    dp[0][0] = 1;
    sm[1][1] = 1;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if (i == 0 && j == 0) continue;
            if (i >= 0 && j >= 0 && s[i-1] == t[j-1]) dp[i][j] = sm[i][j];
            sm[i+1][j+1] = sm[i][j+1] + sm[i+1][j] - sm[i][j] + dp[i][j];
        }
    }
    cout << sm[n+1][m+1] << endl;

    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  if(n == 3) reverse(s.begin(),s.end());
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
l = [[] for _ in range(n)]
ans = 0

for i in range(n):
    a = int(input())
    for j in range(a):
        xy = input().split()
        l[i].append(list(map(int, xy)))

for i in range(2**n):
    judge = True
    for j in range(n):
        if i & (1 << j): #証言者が正直者設定なら進む。
            for x, y in l[j]:
                if y == 0 and i & 1 << (x - 1): #証言:不親切 設定:親切
                    judge = False
                if y == 1 and i & 1 << (x - 1) == 0: #証言:正直、設定:不親切
                    judge = False
    if judge == True:
        cnt = bin(i).count("1")
        ans = max(ans, cnt)

print(ans)

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n = 0;;
	string s;
	cin >> s;
	REP(i, s.size()) {
		n *= 10;
		n += s[i] - '0';
	}
	ll ans = 0;
	ll t = n;
	while (t > 0) {
		ans += t % 10;
		t /= 10;
	}
	FOR(i, 1,s.size()) {
		ll tmp = 1;
		REP(j, i)tmp *= 10;
		if (n%tmp == tmp - 1)continue;
		ll m = n - tmp, cnt = 0;
		REP(j, s.size()) {
			if (j < i)cnt += 9;
			else cnt += m % 10;
			m /= 10;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}


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

using namespace std;

int main() {
    int H,W;
    char a[100][101];

    scanf("%d %d", &H, &W);
    for(int i=0; i<H; i++){
            scanf("%s", a[i]);
    }

    bool b[100][100];
    int i,j;

    for(i=0; i<H; i++){
        for(j=0; j<W; j++){
            if(a[i][j]=='#'){
                break;
            }
        }
        if(j==W){
            for(j=0; j<W; j++){
                b[i][j]= true;
            }
        }
    }

    for(j=0; j<W; j++){
        for(i=0; i<H; i++){
            if(a[i][j]=='#'){
                break;
            }
        }
        if(i==H){
            for(i=0; i<H; i++){
                b[i][j]= true;
            }
        }
    }

    int sign = 0;

    for(i=0; i<H; i++){
        sign = 0;
        for(j=0; j<W; j++){
            if(b[i][j]==false) {
                printf("%c", a[i][j]);
                sign = 1;
            }
        }
        if(sign==1) {
            printf("\n");
        }
    }


    return 0;

}

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

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		int sum = 0;
		int tmp = i;
		while(tmp != 0)
		{
			sum += tmp % 10;
			tmp /= 10;
		}
	
		if(a <= sum && b >= sum)
		{
			ans += i;
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

fourEven = 0
odd = 0
otherEven = 0
for num in n:
    if num % 4 == 0:
        fourEven += 1
    elif num % 2 == 1:
        odd += 1
    else:
        otherEven += 1

# print(len(n) == fourEven + otherEven + otherEven)

if len(n) // 2 <= fourEven:
    print('Yes')
elif odd <= fourEven and otherEven >= 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>

#define MAX 100

using namespace std;

int adjacencyList[MAX + 1][MAX + 1];

int main(void)
{

	int n;
	int u;
	int k;
	int v;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> u >> k;

		for (int j = 0; j < k; j++) {
			cin >> v;
			adjacencyList[u][v] = 1;
		}

	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j > 1) {
				putchar(' ');
			}
			
			printf("%d",adjacencyList[i][j]);
		}

		putchar('\n');

	}


	return 0;
}

Measured memory_bytes: 3224
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	vector<int> v(5),vv(5);
	int res = 0;
	rep(i, 5) {
		cin >> v[i];
		int x = 10 - v[i] % 10;
		if (x != 10)vv.push_back(x);
		res += v[i];
	}
	sort(vv.begin(), vv.end(),greater<>());
	for (int i = 0; i < vv.size(); i++) {
		res += vv[i];
	}
	res -= vv[0];
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int numOfTr = sc.nextInt();
    int numOfCost = sc.nextInt();
    int current = sc.nextInt();
    int[] cost = new int[numOfCost];
    for (int i = 0; i < numOfCost; i++) {
      cost[i] = sc.nextInt();
    }
    int left = 0;
    int right = 0;
    for (int i = 0; i < current; i++) {
      for (int j = 0; j < numOfCost; j++) {
        if (i == cost[j]) {
          left++;
        }
      }
    }
    for (int i = current + 1; i < numOfTr + 1; i++) {
      for (int j = 0; j < numOfCost; j++) {
        if (i == cost[j]) {
          right++;
        }
      }
    }
    System.out.println(left < right ? left : right);
  }

}


Measured memory_bytes: 21332
# -*- coding: utf-8 -*-

if __name__ == '__main__':
    N = int(input())
    V = list(map(int, input().split()))

    while True:
        V.sort(reverse=True)
        V[-2] = (V[-2]+V[-1])/2
        V = V[:-1]

        if len(V)==1:
            break

    print(V[0])


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <tuple>
#include <utility>
#include <functional>
#include <sys/time.h>
#include <iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(i, m, n) for(int i = (m); i < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

constexpr int SZ = 26;
constexpr int D = 365;
array<int, SZ> C;
array<array<int, SZ>, D> S;

int main(void){
	int tmp;
	cin >> tmp;
	rep(i, SZ) cin >> C[i];
	rep(i, D) rep(j, SZ) cin >> S[i][j];

	array<int, SZ> last;
	rep(i, SZ) last[i] = 0;

	for (int d = 1; d <= D; ++d){
		int max = 0, ans = 0;
		rep(i, SZ) if (chmax(max, C[i] * (d - last[i]))) ans = i;
		cout << ans + 1 << endl;
		last[ans] = d;
	}

	return 0;
}


Measured memory_bytes: 3672
def resolve():
    #n=int(input())
    #a,b=map(int,input().split())
    #x=list(map(int,input().split()))
    #a=[list(map(lambda x:int(x)%2,input().split())) for _ in range(h)]
    n=int(input())
    ans=0
    for a in range(1,n):
      if n-a*a<=0:
        break
      else:
        ans+=1
    for a in range(1,n-1):
      for b in range(a+1,n):
        if n-a*b<=0:
          break
        else:
          ans+=2
    print(ans)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output3.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    string s,t;
    cin>>s>>t;
    if((t.substr(0,s.size()) == s ) && (t.size() == s.size()+1))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3660
X, N = map(int, input().split())
if N==0:
    ans = X
else:
    p = list(map(int, input().split()))
    
    finished = False
    cnt = 1

    if X not in p:
        ans = X

    else:    
        while(not finished):
            L = X-cnt
            R = X+cnt

            if L not in p:
                ans = L
                finished = True
            elif R not in p:
                ans = R
                finished = True

            else:
                cnt += 1

print(ans)

Measured memory_bytes: 9204
// C++ program to print the number of elements 
// greater than k in a subarray of range L-R. 
#include <bits/stdc++.h> 
using namespace std; 

// Structure which will store both 
// array elements and queries. 
struct node { 
	int pos; 
	int l; 
	int r; 
	int val; 
}; 

// Boolean comparator that will be used 
// for sorting the structural array. 
bool comp(node a, node b) 
{ 
	// If 2 values are equal the query will 
	// occur first then array element 
	if (a.val == b.val) 
		return a.l > b.l; 

	// Otherwise sorted in descending order. 
	return a.val > b.val; 
} 

// Updates the node of BIT array by adding 
// 1 to it and its ancestors. 
void update(int* BIT, int n, int idx) 
{ 
	while (idx <= n) { 
		BIT[idx]++; 
		idx += idx & (-idx); 
	} 
} 
// Returns the count of numbers of elements 
// present from starting till idx. 
int query(int* BIT, int idx) 
{ 
	int ans = 0; 
	while (idx) { 
		ans += BIT[idx]; 

		idx -= idx & (-idx); 
	} 
	return ans; 
} 

// Function to solve the queries offline 
void solveQuery(int arr[], int n, int QueryL[], 
				int QueryR[], int QueryK[], int q) 
{ 
	// create node to store the elements 
	// and the queries 
	node a[n + q + 1]; 
	// 1-based indexing. 

	// traverse for all array numbers 
	for (int i = 1; i <= n; ++i) { 
		a[i].val = arr[i - 1]; 
		a[i].pos = 0; 
		a[i].l = 0; 
		a[i].r = i; 
	} 

	// iterate for all queries 
	for (int i = n + 1; i <= n + q; ++i) { 
		a[i].pos = i - n; 
		a[i].val = QueryK[i - n - 1]; 
		a[i].l = QueryL[i - n - 1]; 
		a[i].r = QueryR[i - n - 1]; 
	} 

	// In-built sort function used to 
	// sort node array using comp function. 
	sort(a + 1, a + n + q + 1, comp); 

	// Binary Indexed tree with 
	// initially 0 at all places. 
	int BIT[n + 1]; 

	// initially 0 
	memset(BIT, 0, sizeof(BIT)); 

	// For storing answers for each query( 1-based indexing ). 
	int ans[q + 1]; 

	// traverse for numbers and query 
	for (int i = 1; i <= n + q; ++i) { 
		if (a[i].pos != 0) { 

			// call function to returns answer for each query 
			int cnt = query(BIT, a[i].r) - query(BIT, a[i].l - 1); 

			// This will ensure that answer of each query 
			// are stored in order it was initially asked. 
			ans[a[i].pos] = cnt; 
		} 
		else { 
			// a[i].r contains the position of the 
			// element in the original array. 
			update(BIT, n, a[i].r); 
		} 
	} 
	// Output the answer array 
	for (int i = 1; i <= q; ++i) { 
		cout << ans[i] << endl; 
	} 
} 

// Driver Code 
int main() 
{ 
	int n,q;
	cin >> n >> q;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}

	map<int,int> mp;
	int b[n];
	b[n-1] = 1e9;
	mp[a[n-1]] = n-1;

	for(int i=n-2;i>=0;i--){
		if(mp.find(a[i])!=mp.end()){
			b[i] = mp[a[i]];
			mp[a[i]] = i;
		}
		else{
			mp[a[i]] = i;
			b[i] = 1e9;
		}
		// cout <<i << " " << b[i] << endl;
	}	

	int ql[q],qr[q],qk[q];

	for(int i=0;i<q;i++){
		cin >> ql[i] >> qr[i];
		// ql[i]--;qr[i]--;
		qk[i] = qr[i]-1;
	}

	// number of queries 

	// Function call to get 
	solveQuery(b, n, ql, qr, qk, q); 

	return 0; 
} 


Measured memory_bytes: 56568
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
 
using namespace std;

int main(){
    int N, P;   cin >> N >> P;
    ll ans;
    vector<int> m(2,0);
    for(int i=0; i<N; i++){
        int a;  cin >> a;
        m[a%2]++;
    }
    if(P==1 && m[1]==0){print(0);return 0;}
    if(m[1] > 0)    m[1]--;
    ans = pow(2,m[0]+m[1]);
    print(ans);
}

Measured memory_bytes: 4004
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007

using namespace std;
#define ll long long
#define dbg if(0)

int main(){
    ll n,w,h,ans;
    cin >>n>>h>>w;
    ans=(1+n-w)*(1+n-h);
    cout <<ans<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 69;
const int MAXT = 2569;
const int INF = 1e18;
struct vl{
    int x,y,z;
    bool operator<(vl t)const{
        if(x==t.x&&y==t.y)return z<t.z;
        if(x==t.x)return y<t.y;
        return x<t.x;
    }
};
vector<vl>a[MAXN];
int m,n,q,k,S,t;
int c[MAXN];
int d[MAXN];
int dist[MAXN][MAXT];
void Dij(int x){
    for(int i=1;i<=n;i++){
        for(int j=0;j<=2500;j++){
            dist[i][j]=INF;
        }
    }
    dist[1][S]=0;
    set<vl>s;
    s.insert({0,S,1});
    while(!s.empty()){
        vl t = *s.begin();
        s.erase(s.begin());
        int u = t.z;
        int money = t.y;
        for(vl tmp:a[u]){
            int v = tmp.x;
            int w = tmp.y;
            int fee = tmp.z;
            if(money<fee)continue;
            if(dist[u][money]+w>=dist[v][money-fee])continue;
            set<vl>::iterator itr = s.find({dist[v][money-fee],money-fee,v});
            if(itr!=s.end())s.erase(itr);
            dist[v][money-fee] = dist[u][money]+w;
            s.insert({dist[v][money-fee],money-fee,v});
        }
        for(int i=1;money+c[u]*i<=2500;i++){
            if(dist[u][money+c[u]*i]<=dist[u][money]+d[u]*i)continue;
            set<vl>::iterator itr = s.find({dist[u][money+c[u]*i],money+c[u]*i,u});
            if(itr!=s.end())s.erase(itr);
            dist[u][money+c[u]*i] = dist[u][money] + d[u]*i;
            s.insert({dist[u][money+c[u]*i],money+c[u]*i,u});
        }
    }
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>S;
    S = min(S,2500ll);
    for(int i=1;i<=m;i++){
        int x,y,z,t;
        cin>>x>>y>>t>>z;
        a[x].push_back({y,z,t});
        a[y].push_back({x,z,t});
    }
    for(int i=1;i<=n;i++)cin>>c[i]>>d[i],c[i]=min(c[i],2500ll);
    Dij(1);
    for(int i=2;i<=n;i++){
        int tmp = INF;
        for(int j=0;j<=2500;j++){
            tmp = min(tmp,dist[i][j]);
        }
        cout<<tmp<<'\n';
    }
}


Measured memory_bytes: 12188
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int array[3];
    cin >> array[0] >> array[1] >> array[2];

    sort(array, array+3);
    cout << 10 * array[2] + array[1] + array[0] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main(void) {
    
    int n;
    int k;
    int ans = 0;
    
    cin >> n >> k;
    
    for (int i = 0; i < n; ++i) {
        
        int x; cin >> x;
        
        int a = abs(k - x);
        
        if (a < x) {
            
            ans += a * 2;
            
        } else {
            
            ans += x * 2;
            
        }
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}




























Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        //List<Integer> list = new ArrayList<Integer>(Arrays.asList(0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1));
        int list[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String ans = (list[a] == list[b])? "Yes" : "No";
        System.out.println(ans);
    }    
}

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	vector<int> v(n + 1);
	rep(i, 1, n + 1) read(v[i]);
	int a = 0;
	rep(i, 1, n + 1) if (i % 2 == 1 && v[i] % 2 == 1) a++;
	write(a);
}


Measured memory_bytes: 3624
n, x, m = map(int, input().split())
pass_num = set()
route = []
num = x
count = 0
ans = 0
while num not in pass_num:
    count += 1
    pass_num.add(num)
    route.append(num)
    num = (num * num) % m
# 何回目からループなのか求める
index = route.index(num)
pre = route[:index]
latter = route[index:]
if count >= n:
    # 趣味レーションで間に合う
    print(sum(route[:n]))
    exit()
else:
    ans = sum(pre)
    n -= len(pre)
    roop_cnt = len(latter)
    N = n // roop_cnt
    ans += N * sum(latter)
    n -= N * roop_cnt
    ans += sum(latter[:n])
    print(ans)



Measured memory_bytes: 77060
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var a = o.m(n);
  a.sort((a,b)=>-a[0]-a[1]+b[0]+b[1]);
  var ans = 0;
  for(var i = 0; i < n; i++){
    if(i & 1)ans -= a[i][1];
    else ans += a[i][0];
  }
  return ans;
}

Measured memory_bytes: 69168
#include <bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
 char c[9];
for(int i=0;i<9;++i){
cin >> c[i] ;
}
cout << c[0] << c[4] << c[8] << endl;

}


Measured memory_bytes: 256
N = int(input())
info = [list(map(int, input().split())) for _ in range(N)]

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        h_max = float("inf")
        for m in info:
            x, y, h = m[0], m[1], m[2]
            if h > 0:
                H = f(x, y, c_x, c_y) + h
                d.append(H)
            else:
                h_max = min(h_max, f(x, y, c_x, c_y))
        else:
            d = list(set(d))
            if len(d) == 1 and 1 <= d[-1] and d[-1] <= h_max:
                print(c_x, c_y, d[-1])
                exit()


Measured memory_bytes: 48220
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N; cin>>N;
    vec A(N);
    vec oddeven(2,0);
    REP(i,N){
        cin>>A[i];
        if(A[i]%2==0) oddeven[0]++;
        else oddeven[1] ++;
    }
    int ans = 1;
    REP(i,N) ans *= 3;
    int dis = 1;
    REP(i,oddeven[0]) dis *=2;
    ans -= dis;
    Out(ans);
}

Measured memory_bytes: 256
# frozen-string-literal: true

n, m, k = gets.split.map(&:to_i)
0.upto(n) do |x|
  0.upto(m) do |y|
    if x * m + y * n - 2 * x * y == k
      puts 'Yes'
      exit
    end
  end
end
puts 'No'


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <math.h>
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin>>s;
	ll n=s.length();
	cout << s[0]<<n-2<<s[n-1]<<endl;
	return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int 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 For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm

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

    int3(a, b, c);
    int3(d, e, f);

    double ans = 0.0;
    int st = 0, wt = a*100;

    for (int i = 0; i <= f; i += a * 100) {
        for (int j = 0; i + j <= f; j += b * 100) {
            for (int k = 0; i + j + k <= f; k += c) {
                for (int l = 0; i + j + k + l <= f; l += d) {
                    double yui = k + l, kyoko = i + j;
                    if (kyoko + yui == 0) continue;
                    if (yui > kyoko / 100 * e) continue;
                    if (ans < yui / (kyoko + yui)) {
                        ans = yui / (kyoko + yui);
                        st = yui;
                        wt = kyoko + yui;
                    }
                }
            }
        }
    }

    cout << wt << " " << st << endl;

    return 0;
}



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




int main() {
    int n;
    cin>>n;
    vector<int>v(n);
    set<int>s;
    int big=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        if(v[i]<400){
            s.insert(1);
        } else if(v[i]<800){
            s.insert(2);
        } else if(v[i]<1200){
            s.insert(3);
        } else if(v[i]<1600){
            s.insert(4);
        } else if(v[i]<2000){
            s.insert(5);
        } else if(v[i]<2400){
            s.insert(6);
        } else if(v[i]<2800){
            s.insert(7);
        } else if(v[i]<3200){
            s.insert(8);
        } else {
            big++;
        }
    }
    int mi=s.size();
    if(s.size()==0){
        if(big){
            mi=1;
        }
    }
    
    int ma=(int)s.size()+big;
    cout<<mi<<" "<<ma<<endl;
    
    /*
     
     Rating 1-399 : gray
     Rating 400-799 : brown
     Rating 800-1199 : green
     Rating 1200-1599 : cyan
     Rating 1600-1999 : blue
     Rating 2000-2399 : yellow
     Rating 2400-2799 : orange
     Rating 2800-3199 : red
     */
    
}


Measured memory_bytes: 256
s = input()
k = int(input())
#5,000,000,000,000,000
count = 5000000000000000

lis = [int(s[i]) for i in range(len(s))]
for l in lis:
    if l == 1:
        if k > 1:
            k -= 1
            continue
        else:
            print(1)
            exit()
    else:
        print(l)
        exit()

Measured memory_bytes: 3060
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define loop while (true)

#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define sort(a) sort((a).begin, (a).end())

#define pii pair<int, int>
#define pllll pair<long long, long long>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vvll vector<vector<long long>>

using namespace std;

typedef long long ll;

#define MAX 2000

ll a[MAX];
ll b[MAX][MAX];
int N;
inline int next(int n)
{
    return (n == N - 1) ? 0 : n + 1;
}
inline int prev(int k, int n)
{
    return (n >= k) ? n - k : n + N - k;
}

int main()
{
    ll x;
    cin >> N >> x;
    ll sum = 0;
    rep(i, N)
    {
        cin >> a[i];
        sum += a[i];
        b[0][i] = a[i];
    }

    ll min_cost = sum;
    FOR(k, 1, N)
    {
        ll cost = 0;
        rep(i, N)
        {
            b[k][i] = min(a[prev(k, i)], b[k - 1][i]);
            cost += b[k][i];
        }
        cost += x * k;
        if (min_cost > cost) {
            min_cost = cost;
        }
    }
    cout << min_cost << endl;

    return 0;
}


Measured memory_bytes: 31488
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
using namespace std;
typedef long long LL;
const int N=110;
template<typename T>inline T chkmax(T A,T B){return A>B?A:B;}
template<typename T>inline T chkmin(T A,T B){return A<B?A:B;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,p;
LL a[N],C[N][N],x[N],ans;
inline void init()
{
	C[0][0]=1;
	For(i,1,100)
	{
		C[i][0]=1;
		For(j,1,100)
			C[i][j]=C[i-1][j]+C[i-1][j-1];
	}

}
int main()
{
	read(n);read(p);
	init();
	For(i,1,n)
	{
		read(a[i]),a[i]%=2;
		x[a[i]]++;
	}
	for(int i=p;i<=x[1];i+=2)
		For(j,0,x[0])
			ans+=C[x[1]][i]*C[x[0]][j];
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for(int i = 0;i < n; ++i) a[i] = scan.nextInt();
	
		int[] count = new int[1000001];
		for(int i:a){
			if(count[i] != 0){
				count[i] = 2;
				continue;
			}

			for(int j = i;j <= 1000000; j +=i){
				++count[j];
			}
		}
		int ans = 0;
		for(int i : a){
			ans += (count[i] == 1?1:0);
		}
		System.out.print(ans);
	}
}



Measured memory_bytes: 60380
#include <iostream>
using namespace std;
int main(){
	int n,b=-2;
	cin>>n;
	while(n--){
		int e;
		cin>>e;
		if(e<b){
			cout<<"No"<<endl;
			return 0;
		}
		if(e>b){
			b=e-1;
		}
	}
	cout<<"Yes"<<endl;
}

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

using namespace std;

int main()
{
	int n;

	cin >> n;

	vector<unsigned long long> vec(n);
	int t[62] = { 0 };
	unsigned long long ans = 0;

	for (int i = 0; i < n; i++) {
		cin >> vec[i];
		
		for (int j = 0; j < 62; j++) {
			if (((vec[i] >> j) & 1) == 1) {
				t[j]++;
			}
		}
	}
	unsigned long long s = 1;
	unsigned long long u;
	for (int i = 0; i < 62; i++, s *= 2) {
		u = s % 1000000007;
		u *= t[i];
		u %= 1000000007;
		u *= (n - t[i]);
		u %= 1000000007;
		ans += u;
		ans %= 1000000007;
	}

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

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


int main() {
	char s[200];
	unsigned long long k;
	int i;

	scanf("%s", s);

	scanf("%llu", &k);

	unsigned long long sum = 0;
	for (i = 0; i < strlen(s); i++) {
		if (s[i] == '1') {
			sum++;

			if (sum == k) {
				printf("1");
				break;
			}
		}
		else
		{
			printf("%c", s[i]);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define M 1000000007
#define deb(x) cout<<#x<<'='<<x<<endl
using namespace std;
vector<int> d[100005];
bool vis[100005];
int dp[100005];
int dfs(int s)
{
    vis[s] = true;
    for(int i:d[s])
    {
       	if(vis[i] == false)
       		dfs(i);
		dp[s]=max(dp[s],1+dp[i]);
    }
    return dp[s];
}

signed main()
{
	int n,m;
	cin>>n>>m;
	memset(dp,0,sizeof(dp));
	memset(vis,0,sizeof(vis));
	int u[m],v;
	for(int i=0; i<m; i++)
	{
		cin>>u[i]>>v;
		d[u[i]].push_back(v);
	}
	for(int i=0; i<m; i++)
	{
		if (!vis[u[i]])
			dfs(u[i]);
	}
	int ans=0;
	for(int i=1; i<=n; i++)
		ans=max(ans,dp[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 9856
#include <stdio.h>
int main(void)
{
    int N,n=0;
    scanf("%d",&N);
    int s=N;
    while (s>0){
        n+=s%10;
        s/=10;
    }
    if (N%n==0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define N 100
#define A 1
#define B 2
#define C 3

int n,d[N],f[N],time,S[N],G[N][N];

void DFS(void);
void DFSiku(int);

int main(){
  int i,j,u,v,k;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j]=0;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u-1][v-1]=1;
    }
  }

  DFS();

  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}

void DFS(void){
  int i;
  
  for(i=0;i<n;i++){
    S[i]=A;
  }
  time=0;
  for(i=0;i<n;i++){
    if(S[i]==A){
      DFSiku(i);
    }
  }
}

void DFSiku(int u){
  int i;

  S[u]=B;
  d[u]=++time;

  for(i=0;i<n;i++){
    if(G[u][i]==1 && S[i]==A){
      DFSiku(i);
    }
  }

  S[u]=C;
  f[u]=++time;
}

Measured memory_bytes: 636
n, l = map(int, input().split())
taste = [0]*n
taste2 = [0]*n
for i in range(n):
    taste[i] = l + i
    taste2[i] = abs(l + i)
ate_idx = taste2.index(min(taste2))
taste[ate_idx] = 0
print(sum(taste))




Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

int main(){
  string s;
  cin>>s;
  int ans = 10000000;
  rep(i,s.size()-2){
    string str = s.substr(i,3);
    int tmp = atoi(str.c_str());
    ans = min(ans,abs(753-tmp));
  }
  
  print(ans)
  return 0;
}


Measured memory_bytes: 256