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

int N2(){
  int n;cin>>n;
  vector<int>d;
  int b;
  for(int i=0; i<n; i++){
    cin>>b;
    d.push_back(b);
  }
  int s = d.size();
  int ans = 0;
  for(int i=0; i<s-1; i++)for(int j=i+1; j<s; j++){
    ans += d[i]*d[j];
  }
  return ans;
}

int N(){
  int n;cin>>n;
  vector<int> d;
  int b;
  for(int i=0; i<n; i++){
    cin>>b;
    d.push_back(b);
  }
  int s = d.size();
  int sum = d[0];
  int ans = 0;
  for(int i=1; i<s; i++){
    ans += d[i] * sum;
    sum += d[i];
  }
  return ans;
}

int main(){
  cout<<N()<<endl;
}

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

int main(){
  ll n;
  cin >> n;
  map<string,ll> a;
  rep(i,n){
    string s;
    cin >> s;
    a[s]++;
  }
  cout << a.size() << "\n";
  return 0;
}


Measured memory_bytes: 19228
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(n,a) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define int ll

int n,m,s,t;

vector<int> dijkstra(vector<vector<P> >& g,int sp){
  vector<int> dir(n+1,INF);
  dir[sp]=0;
  priority_queue<P,vector<P>,greater<P> > q;
  q.push(P(0,sp));
  while(!q.empty()){
    int d=q.top().F;
    int p=q.top().S; q.pop();
    if(dir[p]!=d) continue;
    rep(i,g[p].size()){
      int np=g[p][i].F;
      int cost=g[p][i].S;
      if(dir[np]>d+cost){
        dir[np]=d+cost;
        q.push(P(dir[np],np));
      }
    }
  }
  return dir;
}

signed main(){
  cin>>n>>m>>s>>t;
  vector<vector<P> > v(n+1),w(n+1);
  rep(i,m){
    int u,q,a,b;
    cin>>u>>q>>a>>b;
    v[u].push_back(P(q,a));
    v[q].push_back(P(u,a));
    w[u].push_back(P(q,b));
    w[q].push_back(P(u,b));
  }

  vector<int> a=dijkstra(v,s);
  vector<int> b=dijkstra(w,t);

  int c[100000];

  c[n]=a[n]+b[n];

  rrep(i,n-1){
    c[i] = min(c[i+1],a[i]+b[i]);
  }

  FOR(i,1,n+1){
    cout<<INF-c[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 19232
s = input()
n = len(s)

A = [chr(i) for i in range(ord('a'), ord('z')+1)]
B = {}
for i in range(len(A)):
    B[A[i]] = i

C = [[-1] for i in range(len(A))]

for i in range(n):
    C[B[s[i]]].append(i)
for i in range(len(C)):
    C[i].append(n)

# print(C)

ans = float("inf")

for i in range(len(C)):
    ans0 = -float("inf")
    for j in range(len(C[i])-1):
        ans0 = max(ans0, C[i][j+1] - C[i][j])
    ans = min(ans, ans0)

print(ans-1)

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

int main(){
	
	int t;
	
	while(cin >> t,t){
		int ice[10]={},i,g,n,p;
		
		for(p=0;p<t;p++){
			cin >> i;
			
			ice[i]++;
		}
		
		for(g=0;g<=9;g++){
			if(ice[g]==0){
				cout << "-" << endl;
			}
			
			else if(ice[g]>0){
				for(n=0;n<ice[g];n++){
					cout << "*";
				}
				
				cout << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int N;
    cin >> N;
    int A[N + 1];
    int B[N];
    REP(i, N + 1) {
        cin >> A[i];
    }
    REP(i, N) {
        cin >> B[i];
    }
    ll mons = 0;
    REP(i, N) {
        int hit1 = min(A[i], B[i]);
        mons += hit1;
        int hit2 = min(A[i + 1], B[i] - hit1);
        mons += hit2;
        A[i + 1] -= hit2;
    }
    cout << mons << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, M, X;
  cin >> N >> M >> X;

  vi C(N);
  vvi A(N, vi(M));

  rep(i,N){
    i64 c;
    vi a(M);
    cin >> c >> a;
    C[i] = c;
    rep(j,M){
      A[i][j] = a[j];
    }
  }

  i64 ans = INF;

  rep(i,1<<N){
    v(bool) read(N, false);
    rep(j,N){
      if(i&(1<<j)) read[j] = true;
    }

    vi score(M,0);
    rep(n,N) rep(m,M){
      if(read[n]) score[m] += A[n][m];
    }

    bool flag = true;
    rep(m,M) {
      if(score[m]<X) flag = false;
    }

    if(flag){
      i64 ans_tmp = 0;
      rep(n,N){
        if(read[n]){
          ans_tmp += C[n];
        }
      }
      chmin(ans,ans_tmp);
    }
  }

  if(ans >= INF){
    ans = -1;
  }

  cout << ans << "\n";

}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 3652
fun main() {
    var n = readLine()!!.toLong()

    var ans = ""
    while(n != 0L) {
        var c: Char = 'a'
        var a = if(n.rem(26L) == 0L) { 25L } else {n.rem(26L) - 1}
        ans = (c.toLong() +  a).toChar() + ans
        n -= a
        n /= 26L
    }
    println(ans)
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#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 ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
  int N, m;
  cin >> N >> m;
  vi shop(N);
  REP(i, m){
    int c, d;
    cin >> c >> d;
    shop[c-1]++;
    shop[d-1]--;
  }
  int res = N + 1;
  int cnt = 0;
  int start = -1;
  REP(i, N){
    if(shop[i] == 0) continue;
    cnt += shop[i];
    if(start == -1) start = i;
    if(cnt == 0) {
      res += (i - start) * 2;
      start = -1;
    }
  }
  cout << res << endl;
}

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

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if (a - b >= c)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << c - (a - b) << endl;
    }
    return 0;
}

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

using namespace std;

int main() {

	int a[32]{ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	int i;
	cin >> i;

	cout << a[i - 1] << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    int H, W, D;
    cin >> H >> W >> D;
    map<int, pair<int, int> > mp;
    rep(i, 0, H) rep(j, 0, W) {
        int a;
        cin >> a;
        mp[a] = make_pair(j, i);
    }

    int tmp[H * W + 1];
    memset(tmp, 0, sizeof(tmp));
    for(int i = 1; i <= H * W; i++) {
        if(i <= D) tmp[i] = 0;
        else tmp[i] = tmp[i - D] + abs(mp[i].first - mp[i - D].first) + abs(mp[i].second - mp[i - D].second);
    }

    int Q;
    cin >> Q;
    vector<int> ans;
    rep(i, 0, Q) {
        int l, r;
        cin >> l >> r;
        ans.push_back(tmp[r] - tmp[l]);
    }

    rep(i, 0, ans.size()) cout << ans[i] << endl;






}


Measured memory_bytes: 7672
#define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
//#include <bits/stdc++.h>

#define LOG(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;
const ll INF = 1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// print(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 50 == 49) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  std::vector< ll > va(3);
  std::cin >> va[0] >> va[1] >> va[2];

  std::vector< ll >::iterator max_it = std::max_element(va.begin(), va.end());
  ll ans = 1;
  std::vector< ll >::iterator it;
  for (it = va.begin(); it != va.end(); it++) {
    if (it != max_it) {
      ans *= *it;
    }
  }

  print(ans / 2);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ll long long
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++)

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //testcase {
  ll n,a,b,mn,mx,ans;
  cin>>n>>a>>b;
  mn=(n-1)*a+b;
  mx=(n-1)*b+a;
  ans=mx-mn+1;
  if(ans>0) { cout<<ans; }
  else { cout<<0; }
  //}
  return 0;
}

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

//template <class T>
//class Array2d {
//    const size_t x_;
//    std::vector<T> v_;
//public:
//    Array2d(size_t x, size_t y) : x_(x), v_(std::vector<T>(x * y)) {}
//    T *operator[](size_t y) {return &v_[x_ * y]; }
//};

inline int Sq(int x){
    return x*x;
}

int main(){
    int N=0,D=0;
    cin >> N >> D;
    //double a[N][D];
    //Array2d<int> a(D,N);
    vector<vector<int> > a(N, vector<int>(D));
    for (int point=0; point<N; ++point) {
        for (int dimension=0; dimension<D; ++dimension) {
            int tmp=0;
            cin >> a[point][dimension];
        }
    }
    int num=0;
    for (int pointi=0; pointi<N; ++pointi) {
        for (int pointj=pointi+1; pointj<N; ++pointj) {
            int dissq=0;
            //cout << "i" << pointi << ", j" << pointj <<endl;
            for (int dimension=0; dimension<D; ++dimension) {
                dissq+=Sq(a[pointi][dimension]-a[pointj][dimension]);
                //cout << Sq(a[pointi][dimension]-a[pointj][dimension]) <<endl;
            }
            //cout <<"dissq " << dissq <<endl;
            for (int k=1; k<=dissq; ++k) {
                int ksq=Sq(k);
                if (ksq==dissq) {
                    ++num;
                    break;
                }else if (ksq>dissq){
                    break;
                }
            }
        }
    }
    //std::cout<<"num: " <<num<<endl;
    cout<<num<<endl;
//    const int X=2;
//    int y = 3;
//    std::vector<int[X]> a(y);
//    for (int po=0; po<X; ++po) {
//        for (int dim=0; dim<Y; ++dim) {
//            cin >> a(y);
//        }
//    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX_N 50

//こいつがすべてを計算する
int solve(int n, int d[], int i, int j);

int main() {

	int n, d[MAX_N];

	//入力
	scanf("%d", & n);
	for (int i = 0; i < n; i++) {
		scanf("%d", d + i);
	}

	//solve関数で答えをゲット
	int answer = solve(n, d, 0, 1);

	//出力
	printf("%d\n", answer);
}

/*
  for(int i = 0; i < n - 1; i++){
     for(int j = i + 1; j < n; j++){
	    answer += d[i] * d[j];
	 }
  }
  を、再帰で書き換えた
*/

int solve(int n, int d[], int i, int j) {

	//最後の条件
	if (i == n - 2) return d[n - 2] * d[n - 1];

	//for文で言うところの、ネストされたfor文の最後の処理
	else if (i < n - 2 && j == n - 1) return solve(n, d, i + 1, i + 2) + d[i] * d[j];

	//その他
	else return solve(n, d, i, j + 1) + d[i] * d[j];
}


Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
long long n,m,t;
int main(){
	scanf("%lld",&n);
	m=sqrt(n);
	if(m*m==n){
		cout<<2*m-2<<endl;
		return 0;
	}else{
		for(int i=m;i>=1;i--){
			if((n/i)*i==n){
				cout<<i+n/i-2<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int A,B;
    cin >> A >> B;
    A--;B--;
    cout << "100 100" << endl;
    char C[570][570];
    REP(i,100){
        REP(j,50){
            C[i][j]='#';
            C[i][j+50]='.';
        }
    }
    REP(i,A){
        C[2*(i/20) +1][2*(i%20)]='.';
    }
    REP(i,B){
        C[2*(i/20) +1][50+2*(i%20)+1+5]='#';
    }
    REP(i,100){
        REP(j,100){
            cout << C[i][j];
        }cout << endl;
    }cout << endl;
    return 0;
}   


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,s,v) for(int i=(int)s;i<(int)v;++i)
#define rf(i,s,v) for(int i=(int)s-1;i>(int)v;--i)
#define pb push_back
#define all(v) ((v.begin()),(v.end()))
#define memset(c, value) memset(c, (int)value, sizeof(c))
using namespace std;
typedef long long ll;
const int oo = 1e9+5;
const ll MOD =1e9+7;
const double pi = acos(-1);
void fast(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n, m;
bool valid (int r,int c){
    return (r < n && r >= 0 && c >= 0 && c < m);
}

int row[] = {0 , 1 , 0, -1};
int column[] = {1 , 0, -1, 0};

char a[1001][1001];
int dp[1001][1001];

int path(int r, int c){
    if(!valid(r, c) || a[r][c] == '#')
        return 0;
    if(r == n-1 && c == m-1)
        return 1;

    int &ret = dp[r][c];
    if(ret != -1) return ret;

    ret = 0;

    return ret = (ret + path(r+1, c)%MOD + path(r, c+1)%MOD)%MOD;
}

int main()
{
    fast();

    cin>>n>>m;
    f(i, 0, n)
    f(j, 0, m)
        cin>>a[i][j];
    memset(dp, -1);
    cout<<path(0,0)<<'\n';

    return 0;
}


Measured memory_bytes: 8624
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
int rezolvare(int n, vector<int> &a, vector<int> &b, vector<int> &c, int imp, int **&memo){
   int rezultat = 0;
   if(n == -1)
      return 0;
   if(memo[n][imp] != 0)
      return memo[n][imp];
   if(imp == 0){
      int temp1, temp2, temp3;
      temp1 = a[n] + rezolvare(n-1, a, b, c, 1, memo);
      temp2 = b[n] + rezolvare(n-1, a, b, c, 2, memo);
      temp3 = c[n] + rezolvare(n-1, a, b, c, 3, memo);
      rezultat = max(temp1, max(temp2, temp3));
   }
   else if(imp == 1){
      int temp2, temp3;
      temp2 = b[n] + rezolvare(n-1, a, b, c, 2, memo);
      temp3 = c[n] + rezolvare(n-1, a, b, c, 3, memo);
      rezultat = max(temp2, temp3);
   }
   else if(imp == 2){
      int temp1, temp3;
      temp1 = a[n] + rezolvare(n-1, a, b, c, 1, memo);
      temp3 = c[n] + rezolvare(n-1, a, b, c, 3, memo);
      rezultat = max(temp1, temp3);
   }
   else if(imp == 3){
      int temp1, temp2;
      temp1 = a[n] + rezolvare(n-1, a, b, c, 1, memo);
      temp2 = b[n] + rezolvare(n-1, a, b, c, 2, memo);
      rezultat = max(temp1, temp2);
   }
   memo[n][imp] = rezultat;
   return rezultat;
}
int main()
{
   //ifstream fin("date.in");
    vector<int> a, b, c;
    int n, **memo, valoare;
    cin >> n;
    memo = new int*[n]();
    for(int i = 0 ; i < n ; i++){
      memo[i] = new int[4]();
      cin >> valoare;
      a.push_back(valoare);
      cin >> valoare;
      b.push_back(valoare);
      cin >> valoare;
      c.push_back(valoare);
    }
    rezolvare(n - 1, a, b, c, 0, memo);
    cout << memo[n-1][0];
    return 0;
}


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

using namespace std;

int main(){
	string s;
	cin >> s;
	long long k;
	cin >> k;
	int p = 0;
	while(s[p] == '1' && p < s.size())
		p++;
	if(k <= p)
		return cout << 1, 0;
	for(int i = 0; i < s.size(); i++)
		if(s[i] != '1')
			return cout << s[i], 0;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args []){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int num = 0;
        for(int i=1;i<=N/2;i++) if(N-i!=i)num++;
        System.out.println(num);
    }
}


Measured memory_bytes: 22356
// Problem E

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <cassert>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <numeric>

#define P 1000000007
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long int ll;
typedef pair<int, int> ii;

int N;
map<pair<ll, ll>, int> mappa;
int num00;
ll pow2[300000];

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

int main() {
  cin >> N;
  ll a, b;
  pair<ll, ll> c;
  for (int i=0; i<N; i++) {
    cin >> a >> b;
    if (a == 0 && b == 0) {num00++; continue;}
    else if (a == 0) c = mp((ll)0, (ll)1);
    else if (b == 0) c = mp((ll)1, (ll)0);
    else {
      ll x = gcd(abs(a), abs(b));
      if (a < 0) {a = -a; b = -b;}
      c = mp(a/x, b/x);
    }
    
    // aggiungo alla mappa
    if (mappa.find(c) != mappa.end()) mappa[c]++;
    else mappa[c]=1;    
  }
  
  pow2[0] = (ll)1;
  for (int i=1; i<=N; i++)
    pow2[i] = (pow2[i-1]*(ll)2) % P;
  
  ll res = 1;
  map<pair<ll, ll>, int>::iterator it;
  set<pair<ll, ll> > used;
  for (it = mappa.begin(); it != mappa.end(); it++) {
    c = it->first;
    ll x = it->second;
    if (used.find(c) != used.end()) continue;
    
    pair<ll, ll> opposite = mp(-c.second, c.first);
    
    if (opposite.first < 0) {opposite.first = -opposite.first; opposite.second = -opposite.second; }
    else if (opposite.first == 0) opposite.second = 1;
    
    //~ cout << c.first << " " << c.second << " " << opposite.first << " " << opposite.second << endl;
    
    if (mappa.find(opposite) == mappa.end()) {
      res = (res*pow2[x])%P;
      used.insert(c);
    }
    else {
      ll y = mappa[opposite];
      res = (res*(pow2[x] + pow2[y] + P - 1))%P;
      used.insert(c);
      used.insert(opposite);
    }
  }
  
  res = (res + num00 + P - 1) % P;
  cout << res << endl;
  
  
  return 0;
}


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

long long n;
vector<long long> v;

long long solve();

int main() {
  cin >> n;

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(long long i = 1; i * i <= n; ++i) {
    if(n % i == 0) {
      v.push_back(i);
      v.push_back(n / i);
    }
  }
  for(int i = 0; i < v.size(); ++i) {
    long long now = v[i] - 1;
    if(now == 0) continue;
    if(n % now == n / now) ans += now;
  }
  return ans;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
    int a, b, c, k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    int count = 0;
    while(a >= b){
        count ++;
        b *= 2;
    }
    while(b >= c){
        count ++;
        c *= 2;
    }
    if(count <= k)
        puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  int n;
  string s;
  cin >> n >> s;
  rep(i, s.length()) {
    s[i] += n;
    if(s[i] > 'Z') {
      s[i] = s[i] - 'Z' + 64;
    }
  }
  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;
    scanf("%lld", &n);
    ll a = n;
    ll cnt = 0;
    ll val;
    char c;
    vector<char> v;
    while (n > 0)
    {
        ll d = n % 26;
        if (d == 0)
        {
            d = 96 + 26;
            c = d;
        }
        else
        {
            c = 96 + d;
        }
        v.push_back(c);
        if (n % 26 == 0)
        {
            n = n / 26 - 1;
        }
        else
        {
            n = n / 26;
        }
    }

    for (int i = v.size() - 1; i >= 0; i--)
    {
        printf("%c", v[i]);
    }
    printf("\n");
}

Measured memory_bytes: 3592
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll k;
    cin>>k;
    if(k%2!=0){
        cout<<(k/2)*(k/2+1)<<endl;
    }else{
        cout<<(k/2)*(k/2)<<endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	if(n >= m/2) ans = m/2;
	else{
		ans += n;
		m -= 2*n;
		ans += m/4;
	}
	cout << ans;
		

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	
	int n,x,i,j,k;
	
	while(1){
		int cnt=0;
		scanf("%d %d",&n,&x);
		if(n==0 && x==0)break;
		
		for(i=1;i<=n;i++){
			for(j=i+1;j<=n;j++){
				for(k=j+1;k<=n;k++){
					if((i+j+k)==x)cnt++;
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}


Measured memory_bytes: 2056
#include <stdio.h>

int main() {

  int a,b=0,i,j,N,A[100],count,minj;

  while(1) {
    scanf("%d",&N);
    if(N<0 || 100<N) printf("error\n");
    else break;
  }

  while(1) {
    count=0;
    for(i=0; i<N; i++) scanf("%d",&A[i]);
    for(i=0; i<N; i++) if(A[i]<0 || 100<A[i]) count++;
    if(count!=0) printf("error\n");
    else break;
  }

  for(i=0; i<N; i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j] < A[minj]) {
        minj = j;
        count++;
      }
    }
    if(count!=0) {
      a = A[i];
      A[i] = A[minj];
      A[minj] = a;
      b++;
      count = 0;
    }
  }

  for(i=0; i<N; i++) {
    printf("%d",A[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",b);

  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  constexpr int inf = 1e9;

  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<> dp(1 << n, inf);
  dp[0] = 0;
  while (m--) {
    int a, b; cin >> a >> b;
    int T = 0;
    while (b--) {
      int c; cin >> c, --c;
      T |= 1 << c;
    }
    auto ndp = dp;
    for (int S = 0; S < 1 << n; ++S) if (dp[S] < inf) {
      ndp[S | T] = min(ndp[S | T], dp[S] + a);
    }
    swap(dp, ndp);
  }
  if (dp.back() < inf) {
    cout << dp.back() << '\n';
  } else {
    cout << -1 << '\n';
  }
}


Measured memory_bytes: 3684
#include<stdio.h>
int main()
{
    char n[10];
    gets(n);
    if(n[0]=='S')
      {  printf("Cloudy\n");  }
    else if(n[0]=='C')
      {  printf("Rainy\n");  }

      else
      {
          printf("Sunny\n");
      }
    return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

char s[10][10];
int main()
{
   int r,c,t,n,i,j,k,mn=0, mx=0;
   si2(r,c);
   si(t);
   for(int i=0; i<r; i++)
   {
       for(int j=0; j<c; j++)
       {
           cin>>s[i][j];
       }
   }
   int ans=0;
   for(int i=0; i<(1<<r); i++)
    {
        for(int j=0; j<(1<<c); j++)
        {
            int cnt=0;
            for(int k=0; k<r; k++)
            {
                for(int l=0; l<c; l++)
                {
                    if(s[k][l]=='#' && (i&(1<<k))==0 && (j&(1<<l))==0)
                        cnt++;
                }
            }
          //  cout<<cnt<<endl;
            ans+=cnt==t;
        }
    }
    cout<<ans;
}

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

int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	ll p = 4*a*b;
	ll q= (c-a-b)*(c-a-b);
	if(a+b>c)cout<<"No"<<endl;
	else if(p<q)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
# 解説AC
N,M = map(int, input().split())
edge = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

used = [False] * N
used[0] = used[edge[0][0]] = True
path = [0, edge[0][0]]

def not_use(v):
    """
    頂点vの隣接頂点で未使用なものを返す
    ない場合 -> -1
    """
    for e in edge[v]:
        if used[e]: continue
        else: return e
    return -1

def append():
    """
    右端に頂点を追加していく
    """
    while True:
        v = not_use(path[-1])
        if v < 0:
            break
        else:
            path.append(v)
            used[v] = True

def main():
    """
    DFS的に頂点を追加していくと、
    どこにも遷移できない頂点に行き着く
    -> それが端点
    これは条件3を満たしている
    """
    append()
    path.reverse()
    append()

    ans = [v + 1 for v in path]
    print(len(ans))
    print(*ans, sep=" ")

if __name__ == "__main__":
    main()

Measured memory_bytes: 29108
N=int(input())
s=0
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
if N<200000:
    t=0
elif 400000>N>=200000:
    t=1
elif 600000>N>=400000:  
    t=2
elif 800000>N>=600000:
    t=3
elif 900000>N>=800000:
    t=4
else:
    t=5
    
lis=[0,2472071,5221424,8075420,10997400,12478098]
s=lis[t]
if N%200000==0 and N!=1000000:
  print(lis[N//200000])
elif N==900000:
  print(lis[5])
elif t<5:
  for i in range((N//200000)*200000+1,N+1):
    s+=len(make_divisors(i-1))
  print(s)
elif t==5:
  for i in range(900001,N+1):
    s+=len(make_divisors(i-1))
  print(s)

Measured memory_bytes: 67988
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 100001
#define MCONS 1001

using namespace std;

string cur;
ll N;

ll dp[101][4][4][4];

bool check(int j, int k, int m, int s)
{
    if(j == 2 && k == 1 && m == 0) return false;
    if(j == 1 && k == 2 && m == 0) return false;
    if(j == 1 && k == 0 && m == 2) return false;
    if(k == 2 && m == 1 && s == 0) return false;
    if(k == 1 && m == 2 && s == 0) return false;
    if(k == 1 && m == 0 && s == 2) return false;
    
    if(j == 1 && m == 2 && s == 0) return false;
    if(j == 1 && k == 2 && s == 0) return false;
    if(j == 1 && k == 2 && m == 0) return false;
    
    return true;
}


int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> N;
    
    for(int j = 0; j < 4; j++)
        for(int k = 0; k < 4; k++)
            for(int m = 0; m < 4; m++)
            {
                if(j == 2 && k == 1 && m == 0) continue;
                if(j == 1 && k == 2 && m == 0) continue;
                if(j == 1 && k == 0 && m == 2) continue;
                dp[3][j][k][m] = 1;
            }
    
    for(int i = 4; i <= N; i++)
    {
        for(int j = 0; j < 4; j++)
        {
            for(int k = 0; k < 4; k++)
            {
                for(int m = 0; m < 4; m++)
                {
                    for(int s = 0; s < 4; s++)
                    {
                        if(!check(j, k, m, s)) continue;
                        dp[i][j][k][m] += dp[i-1][k][m][s];
                        dp[i][j][k][m] %= mod;
                    }
                }
            }
        }
    }
    
    
    
    
    ll ret = 0;
    for(int i = 0; i < 4; i++)
    {
        for(int j = 0; j < 4; j++)
        {
            for(int k = 0; k < 4; k++)
            {
                ret += dp[N][i][j][k];
                ret %= mod;
            }
        }
    }
    
    cout << ret << endl;
    
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

int col[9];

bool solve() {
	int n; cin >> n;
	REP (i,n) {
		int a; cin >> a;
		if (a >= 3200) a = 3200;
		col[a/400]++;
	}
	int tmp = 0;
	REP (i,8) {
		if (col[i] != 0) {
			tmp++;
		}
	}
	if (tmp == 0) {
		cout << 1 << " ";
	} else {
		cout << tmp <<" ";
	}
	cout << tmp + col[8] << endl;
}

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

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int a[3010],b[3010],num[6010];
string s;int n;
string cal(int l,int h){
	string ret="";
	if(a[l]<b[l]){
		while(l<h){
			ret+="ab";
			int ne=l;
			while(ne<n && a[ne]<b[l]) ne++;
			l=ne;
		}
	}
	else{
		REP(i,l,h){
			string t="";
			REP(j,l*2,h*2){
				if(num[j]>=i) t+=s[j];
			}
			ret=max(ret,t);
		}
	}
	return ret;
}
int main()
{
	cin>>n;cin>>s;
	int an=0,bn=0,now=0;
	vector<int> v;v.pb(0);
	rep(i,n*2){
		if(s[i]=='a'){
			a[an]=i;num[i]=an++;now++;
		}
		else{
			b[bn]=i;num[i]=bn++;now--;
		}
		if(now==0) v.pb(i+1);
	}
	vector<string> ret;
	rep(i,(int)v.size()-1) ret.pb(cal(v[i]/2,v[i+1]/2));
	string out="";
	reverse(All(ret));
	rep(i,ret.size()){
		if(out<ret[i]+out) out=ret[i]+out;
	}
	cout<<out<<endl;
}


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

int main(void){

    char T[200001];
    int i,j,T_len;

    scanf("%s",T);
    T_len = strlen(T);
    
    for(i = 0;i < T_len;i++){
        if(T[i] == '?'){
            T[i] = 'D';
        }
    }

    printf("%s\n",T);
    return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  vector<vector<int>> field(8,vector<int>(8,0));
  int vecx[8]={-1,-1,-1,0,0,1,1,1};
  int vecy[8]={-1,0,1,-1,1,-1,0,1};
  string s;
  for(int i=0;i<8;i++){
    cin >> s;
    for(int j=0;j<8;j++){
      if(s[j]=='o'){
        field[i][j]=1;
      }else if(s[j]=='x'){
        field[i][j]=2;
      }
    }
  }
  bool turn=true; //true:o false:x
  bool passed=false;
  int count,okikae,maxokikae,x,y;
  int posx,posy;
  int flag,f;
  while(1){
    posx=posy=-1;
    maxokikae=0;
    flag=0;
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){
        if(!field[i][j]){
          okikae=0;
          f=0;
          for(int k=0;k<8;k++){
            x=j+vecx[k];
            y=i+vecy[k];
            count=0;
            if(0<=y&&y<=7&&0<=x&&x<=7){
              while(field[y][x]==(turn?2:1)){
                count++;
                x+=vecx[k];
                y+=vecy[k];
                if(y<0||y>7||x<0||x>7){
                  x-=vecx[k];
                  y-=vecy[k];
                  break;
                }
              }
              if(field[y][x]==(turn?1:2)){
                okikae+=count;
                f+=(1<<k);
              }
            }
          }
          if(okikae>maxokikae){
            maxokikae=okikae;
            posx=j;
            posy=i;
            flag=f;
          }else if(okikae==maxokikae){
            if(!turn){
              posx=j;
              posy=i;
              flag=f;
            }
          }
        }
      }
    }
    if(maxokikae==0){
      if(passed){
        for(int i=0;i<8;i++){
          for(int j=0;j<8;j++){
            cout << (field[i][j]?(field[i][j]==1?'o':'x'):'.');
          }
          cout <<endl;
        }
        return 0;
      }else{
        // cout << (turn?'o':'x') << endl;
        passed=true;
      }
    }else{
      // cout << (turn?'o':'x') << endl;
      // cout << "(" << posx << "," << posy << ")" << endl;
      passed=false;
      field[posy][posx]=(turn?1:2);
      for(int k=0;k<8;k++){
        if(flag&(1<<k)){
          x=posx+vecx[k];
          y=posy+vecy[k];
          if(0<=y&&y<=7&&0<=x&&x<=7){
            while(field[y][x]==(turn?2:1)){
              field[y][x]=(turn?1:2);
              x+=vecx[k];
              y+=vecy[k];
              if(y<0||y>7||x<0||x>7){
                break;
              }
            }
          }
        }
      }
    }
    turn=(!turn);
  }
  return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    long long sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            for(int k=1;k<=n;k++){
                sum+=__gcd(i,__gcd(j,k));//
            }
	cout<<sum<<"\n";
	return 0;
}

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

int main()
{
	int a[256]={0};
	char c;
	while(cin>>c)
	{
		a[(int)c]++;
	}
	c='a';
	for(int i=0;i<26;i++)
	{
		cout<<c<<" : "<<a['a'+i]+a['A'+i]<<endl;
		c++;
	}
	return 0;
}


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

int main() {
    while (true) {
        int sum10;
        cin >> sum10;
        if (sum10 == 0) {
            break;
        }
        int sum9 = 0;
        for (int i = 0; i < 9; i++) {
            int price;
            cin >> price;
            sum9 += price;
        }
        cout << sum10 - sum9 << endl;
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<functional>
#include<list>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<string.h>
#include<limits.h>
#define int long long
using namespace std;

int ans = LLONG_MAX;
int a, b;
int K[15];
int cost;
void saiki(int c, int d,int e) {//c個目まで見てd個とった 最高の高さはe
	if (c == a) {
		if (d >= b) {
			ans = min(ans, cost);
		}
		return;
	}
	if (K[c] > e) {
		saiki(c + 1, d + 1, K[c]);
	}
	else {
		saiki(c + 1, d, e);
		cost += e - K[c] + 1;
		saiki(c + 1, d + 1, e + 1);
		cost -= e - K[c] + 1;
	}
}
signed main() {
	 scanf("%lld%lld", &a, &b);
	 for (int c = 0; c < a; c++) {
		 scanf("%lld",&K[c]);
	 }
	 saiki(1, 1, K[0]);
	 printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
struct BIT {
  int n;
  vector<int> xs;
  BIT(int n) : n(n), xs(n+1, 0) {}
  void add(int i, int v) {
    for (int x=i+1; x<=n; x+=x&-x) xs[x] += v;
  }
  int sum(int i) {
    int s = 0;
    for (int x=i+1; x>0; x-=x&-x) s += xs[x];
    return s;
  }
};

int N;
int B[3][100000];
int A[100000];
bool F[100000];
int rev[100000];
bool T[100001];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, 3) rep(j, N) cin >> B[i][j], B[i][j]--;
  rep(i, N) {
    int x = B[0][i]/3;
    if      (B[0][i] == 3*x && B[1][i] == 3*x+1 && B[2][i] == 3*x+2) A[i] = x;
    else if (B[0][i] == 3*x+2 && B[1][i] == 3*x+1 && B[2][i] == 3*x) A[i] = x, F[i] ^= 1;
    else {
      cout << "No\n";
      return 0;
    }
  }
  rep(i, N) if ((A[i]+i)%2) {
    cout << "No\n";
    return 0;
  }
  vector<int> pos[2];
  rep(i, N) pos[i%2].pb(A[i]/2);
  rep(k, 2) {
    int n = pos[k].size();
    BIT bit(n);
    rep(i, n) bit.add(i, 1);
    rep(i, n) rev[pos[k][i]] = i;
    rep(i, n) {
      int x = rev[i];
      bit.add(x, -1);
      int s = bit.sum(x);
      int pos = 2*i+k;
      T[pos+1] ^= 1;
      T[pos+2*s+1] ^= 1;
      if (s%2) {
        T[pos] ^= 1;
        T[pos+1] ^= 1;
      }
    }
  }
  //rep(i, N) cout<<A[i]<<",";cout<<"\n";
  rep(i, N) T[i+1] ^= T[i];
  rep(i, N) F[i] ^= T[i];
  //rep(i, N) cout<<F[i]<<","; cout<<"\n";
  int c[2] = {0, 0};
  rep(i, N) c[i%2] ^= F[i];
  if (c[0]+c[1] == 0) {
    cout << "Yes\n";
  }
  else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 2812
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <list>
#include <set>
#include <map>

using namespace std;

unsigned long long w[10000010];
unsigned long long v[10000010];
unsigned long long f[10000010];

int main(void)
{
    //freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
	int n,m;
	cin >> n >> m;
	for(int i=1;i<=n;i++)
	{
		cin >> w[i] >> v[i];
	}
	
	for(int i=1;i<=n;i++)
	{
		for(int j=m;j>=w[i];j--)
		{
			f[j] = max(f[j],f[j-w[i]]+v[i]);
		}
	}
	cout << f[m] << endl;
	return 0;
}


Measured memory_bytes: 5120
n = int(input())
list_a = list(map(int, input().split()))

list_even_idx = []
list_odd_idx = []
for i, a in enumerate(list_a):
  if i % 2 == 0:
    list_even_idx.append(str(a))
  else:
    list_odd_idx.append(str(a))

if n % 2 == 0:
  result1 = " ".join(list_odd_idx[::-1])
  result2 = " ".join(list_even_idx)
  print(result1 + " " + result2)
else:
  result1 = " ".join(list_even_idx[::-1])
  result2 = " ".join(list_odd_idx)
  print(result1 + " " + result2)

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

int M[105][100005];
int A[105];

void filly(int n, int k)
{
    for(int i = 1; i < n; i++)
    {
        M[i][0] = 1;
        for(int j = 1; j <= k; j++)
        {
                M[i][j] = M[i][j-1];
                M[i][j] += (M[i-1][j] - (j - A[i] - 1 >= 0 ? M[i-1][j - A[i] - 1] : 0) + 1000000007) % 1000000007;
                M[i][j] %= 1000000007;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n, k;
    cin >> n >> k;

    for(int i = 0; i < n; i++)
        cin >> A[i];
    for(int i = 0; i <= A[0]; i++)
        M[0][i] = i+1;
    for(int i = A[0]+1; i <= k; i++)
        M[0][i] = M[0][A[0]];

    filly(n, k);
    cout << (M[n-1][k] - M[n-1][k-1] + 1000000007) % 1000000007;

    return 0;
}


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

#define double long double
#define int long long
#define ALL(x) x.begin(),x.end()
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define eb emplace_back
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 998244353 
#define F(i, a, n) for(i=a;i<n;i++)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

const int N = 303;
double E[N][N][N];

int32_t main(void)
{
    FASTER;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j;
    int n;
    SI(n);
    int co[3] = {0};
    F(i, 0, n)
    {
    	int x;
    	SI(x);
    	co[x - 1]++;
    }
    double nn = n;
    for(int c = 0; c + 1 < N; c++)
    {
    	for(int b = 0; b + 1 < N; b++)
    	{
    		for(int a = 0; a + 1 < N; a++)
    		{
    			double aa = a;
    			double bb = b;
    			double cc = c;
    			if(!a && !b && !c)
    				continue;
    			if(a + b + c > n)
    					continue;
    			if(a && b && c)
    			{
    				E[a][b][c] = (nn/(aa+bb+cc))*(1 + (aa/nn)*E[a - 1][b][c] + (bb/nn)*E[a + 1][b - 1][c] + (cc/nn)*E[a][b + 1][c - 1]);
    			}
    			else if(a && b)
    			{
    				E[a][b][c] = (nn/(aa+bb))*(1 + (aa/nn)*E[a - 1][b][c] + (bb/nn)*E[a + 1][b - 1][c]);
    			}
    			else if(b && c)
    			{
    				E[a][b][c] = (nn/(cc+bb))*(1 + (bb/nn)*E[a + 1][b - 1][c] + (cc/nn)*E[a][b + 1][c - 1]);
    			}
    			else if(c && a)
    			{
    				E[a][b][c] = (nn/(aa+cc))*(1 + (aa/nn)*E[a - 1][b][c] + (cc/nn)*E[a][b + 1][c - 1]);
    			}
    			else if(a)
    			{
    				E[a][b][c] = (nn/aa)*(1 + (aa/nn)*E[a - 1][b][c]);
    			}
    			else if(b)
    			{
    				E[a][b][c] = (nn/bb)*(1 + (bb/nn)*E[a + 1][b - 1][c]);
    			}
    			else if(c)
    			{
    				E[a][b][c] = (nn/cc)*(1 + (cc/nn)*E[a][b + 1][c - 1]);
    			}
    		}
    	}
    }
    cout << setprecision(13);
    cout << fixed << E[co[0]][co[1]][co[2]] << "\n";
    
    #ifdef LOCAL
    	cout<<endl<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
    #endif
    return 0;
}

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

int main() {
  int N;
  int d[110];
  cin >> N;
  for(int i=0;i<N;i++) cin >> d[i];
  
  int num[110] = {0};
  for(int i = 0; i < N; i++){
    num[d[i]]++; //d[i]が1個増える
  }
  int res=0;
  for(int i=0; i<=100; ++i){
    if(num[i]){ // 0より大きかったら
      ++res;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
lists=list(map(int,input().split()))
cnt=0
for i in range(n):
    for j in range(i+1,n):
        if lists[i]>lists[j]:
            cnt+=1
cnt=(cnt*k)%(10**9+7)
additional=0
for some in lists:
    count=0
    for other in lists:
        if some>other:
            count+=1
    additional+=count
    
            

an=(((k*(k-1)*additional)//2)%(10**9+7))
print((cnt+an)%(10**9+7))    

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll L,R;
    cin >> L >> R;
    if(R-L>=2019) {
        cout << 0 << endl;
        return 0;
    }
    ll ans=2019;
        ll tmp;
        for(ll i=L;i<R;i++){
            for(ll j=i+1;j<=R;j++){
                ll tmp=((i%2019)*(j%2019))%2019;
                ans=min(ans,tmp);
            }
        }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 384