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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n), b(n);
  rep(i, n) cin >> a[i];
  vector<bool> used(n, false);
  bool flag = true;
  rep(i, n) {
    cin >> b[i];
    if(!used[b[i]-1]) used[b[i]-1] = true;
    else flag = false;
  }
  if(flag) cout << "Yes" << endl;
  else {
    cout << "No" << endl;
    rep(i, n) cout << (used[a[i]-1] ? i+1 : 1) << " \n"[i==n-1];
    rep(i, n) cout << (used[a[i]-1] ? i+1 : 2) << " \n"[i==n-1];
  }

  return 0;
}



Measured memory_bytes: 4680
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int A, B;
    cin >> A >> B;
    int count = 0;
    int sasikomiguti = 1;
    while (B > sasikomiguti) {
        sasikomiguti += A - 1;
        count += 1;
    }

    if (B == 1) {
        cout << 0 << endl;
    } else {
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void pr(){
    cout << "No" << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, x;
    cin >> n >> x;
    ll N = 2*n-1;
    if(x == 1 || x == N) pr();
    vll ans(N);
    if(x == n){
        rep(i, n-1){
            ans[i] = n-1-i;
        }
        ans[n-1] = n;
        repr(i, n, N){
            ans[i] = i+1;
        }
    }else if(x < n){
        ans[n-1] = x;
        rep(i, n-1){
            if(n-i > x) ans[i] = n-i;
            else ans[i] = n-i-1;
        }
        repr(i, n, N){
            ans[i] = i+1;
        }
    }else{
        ans[n-1] = x;
        rep(i, n-1){
            if(i+n < x) ans[i] = i+n;
            else ans[i] = i+n+1;
        }
        repr(i, n, N){
            ans[i] = N-i;
        }
    }
    cout << "Yes" << endl;
    rep(i, N) cout << ans[i] << "\n";
    return 0;
}

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

int main() {
	string s;
	cin>>s;
	int a=0;
	for(int i=0;i<s.size();i++)
	{
		if((i+1)%2==0 && s[i]=='R'){cout<<"No";a=1;break;}
		if((i+1)%2==1 && s[i]=='L'){cout<<"No";a=1;break;}
	}
	if(a==0)cout<<"Yes";
	return 0;
}

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

/*
   AtCoder contest code
   coder : yoichidon
 */
import java.util.*;
import java.io.*;

public class Main {
    public static int collatz(int n){
        if(n%2==0) return n/2;
        else return 3*n+1;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        Set<Integer> appeared = new HashSet<>();
        appeared.add(s);
        for(int m=2; m<1000000; m++){
            s = collatz(s);
            if(appeared.contains(s)){
                System.out.println(m);
                return;
            }else{
                appeared.add(s);
            }
        }


    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

const int maxN = 2e5 + 10;

struct TBag{
    int x,y;

    bool operator < (const TBag& t) const{
        return x < t.x;
    }
};

int             n;
int             x[maxN], y[maxN];
multiset<int>   r,b;
TBag            a[maxN];

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(); cout.tie();
    cin >> n;
    for(int i = 1; i <= n; ++i){
        int x,y;
        cin >> x >> y;
        if(x > y)
            swap(x, y);
        a[i] = {x,y};
        r.insert(x);
        b.insert(y);
    }

    sort(a + 1, a + n + 1);

    int res = (*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin());

    for(int i = 1; i <= n; ++i){
        int x = a[i].x;
        int y = a[i].y;
        r.erase(r.find(x));
        b.insert(x);
		b.erase(b.find(y));
		r.insert(y);
        res = min(res, (*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()));
    }

    cout << res;
    return 0;
}


Measured memory_bytes: 25552
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
struct Z
{
    int b;
    string a;
};
struct Z z[200005];

bool cmp2(struct Z x,struct Z y)
{
    return x.b<y.b;
}
string s[200005],f[200005];
int main()
{
    int n,i,j;
   cin>>n;
   for(i=0;i<n;i++)
    cin>>s[i];
    sort(s,s+n);
   int x,y=0;
    for(i=0;i<n;i++)
    {
        x=0;
        for(j=i+1;;j++)
        {
            if(s[i]==s[j])
            {
                x++;
            }
            else
            {
               z[y].a=s[i];
               z[y].b=x;
               y++;
               break;
            }
        }
        i=j-1;
    }
    sort(z,z+y,cmp2);
    int m;
    m=z[y-1].b;
    j=0;
    for(i=y-1;i>=0;i--)
    {
        if(z[i].b==m)
        {
            f[j]=z[i].a;
            j++;
        }
    }
    sort(f,f+j);
    for(i=0;i<j;i++)
        cout<<f[i]<<endl;
   // for(i=0;i<n;i++)
       // cout<<s[i]<<endl;
    return 0;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
typedef long long ll; 
 
using namespace std;
 
int main() {
	int x;
	cin >> x;
	int d[4];
	for (int i = 3; i >= 0; --i) {
		d[i] = x % 10;
		x /= 10;
	}

	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 2; ++j) {
			for (int k = 0; k < 2; ++k) {
				int sum = d[0];
				if (i == 0) { sum += d[1]; }
				else { sum -= d[i]; }

				if (j == 0) { sum += d[2]; }
				else { sum -= d[2]; }

				if (k == 0) { sum += d[3]; }
				else { sum -= d[3]; }

				if (sum == 7) {
					cout << d[0];
					if (i == 0) { cout << "+"; }
					else { cout << "-"; }
					cout << d[1];
					if (j == 0) { cout << "+"; }
					else { cout << "-"; }
					cout << d[2];
					if (k == 0) { cout << "+"; }
					else { cout << "-"; }
					cout << d[3] << "=7" << endl;

					return 0;
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
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; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


string s;

int main() {

	cin >> s;

	if (s[0] != s[1] || s[1] != s[2])cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
 
#define N 100
 
static const int MAX = 500;
static const int INFTY = (1<<21);
 
main(){
  int l, i, j, x, v,c=0,k=0;
  int u = 0,mincost = 0;
  int cost[N];
  int d[N];
  int p[N],M[N][N];
   
   
  scanf("%d", &l);
  for ( i = 0; i< l; i++ ){
    for ( j = 0; j < l; j++ ){
      M[i][j] = INFTY;
    }
  }
   
  for ( i = 0; i < l; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }
   
  for(i=0;i < l;i++){
    d[i] = INFTY;
    p[i] = -1;
    cost[i] = 0;
  }
   
  d[0] = 0;
   
  while(1){
    u = -1;
    mincost = INFTY;
     
    for(i=0;i < l;i++){
      if(d[i] < mincost && cost[i] == 0){
    mincost = d[i];
    u = i;
      }
    }
     
    if(u == -1) break;
     
    cost[u] = 1;
     
    for(v=0;v <l;v++){
      if(d[v] > d[u]+M[u][v]){
    p[v] = u;
    d[v] = d[u]+M[u][v];
      }
    }
  }
   
  for ( i = 0; i < l; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  }
   
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, n,m , M, K,a;

vector<ll> v,w;
int main(){
    cin >> N >> M;
    if(N== M) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 55;
const ll INF = 1e15;
ll all = 0;
struct Node
{
    ll id , dis , level;
    bool operator < (const Node & a) const
    {
        return dis > a.dis;
    }
};
ll u[maxn * 4] , v[maxn * 4] , w[maxn * 4] , cost[maxn * 4] , nextt[maxn * 4] , first[maxn] , sign;
int book[maxn][2505] , n , m;
ll dist[maxn][2505];
pair<ll,ll> G[maxn];
void addedge(ll a , ll b , ll c , ll d)
{
    u[++sign] = a;
    v[sign] = b;
    w[sign] = c;
    cost[sign] = d;
    nextt[sign] = first[a];
    first[a] = sign;
}
priority_queue<Node>Q;
void Dijstra(int s , ll money)
{
    while(Q.size()) Q.pop();
    for (int i = 1 ; i <= n ; i++){
        for (int j = 0 ; j <= 2500 ; j ++)
            book[i][j] = 0 , dist[i][j] = INF;
    }
    dist[s][money] = 0;
    Q.push({s , 0 , money});
    while(Q.size()){
        Node temp = Q.top(); Q.pop();
        ll dis = temp.dis , id = temp.id , level = temp.level;
        if (book[id][level]) continue;
        book[id][level] = 1;
        for (int i = first[id] ; i ; i = nextt[i]){
            if (level < cost[i]) continue;
            if (dist[v[i]][level - cost[i]] > dis + w[i]){
                dist[v[i]][level - cost[i]] = dis + w[i];
                Q.push({v[i] , dist[v[i]][level - cost[i]] , level - cost[i]});
            }
        }
        if (dist[id][min(2500ll , level + G[id].first)] > dis + G[id].second){
            dist[id][min(2500ll , level + G[id].first)] = dis + G[id].second;
            Q.push({id , dist[id][min(2500ll , level + G[id].first)] , min(2500ll , level + G[id].first)});
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    ll s; cin >> n >> m >> s;
    for (int i = 1 ; i <= m ; i++){
        int x , y , a , b; cin >> x >> y >> a >> b;
        addedge(x , y , b , a);
        addedge(y , x , b , a);
        all += a;
    }
    for (int i = 1 ; i <= n ; i++){
        ll c , d ; cin >> c >> d;
        G[i].first = c;
        G[i].second = d;
    }
    Dijstra(1 , min(s , 2500ll));
    for (int i = 2 ; i <= n ; i ++){
        ll ans = INF;
        for (int j = 0 ; j <= 2500 ; j ++) ans = min(ans , dist[i][j]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 7868
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N;

int gcd( int a, int b )
{ return b ? gcd(b,a%b) : a; }

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

  int ans = 0;

  rep( i, N )
  {
    int A;
    scanf( "%d", &A );

    ans = gcd( ans, A );
  }

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

  return 0;
}

Measured memory_bytes: 128
def examA():
    X, t = LI()
    ans = max(X-t,0)
    print(ans)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

bool cmp(pii &a, pii &b) {
    if (a.first == b.first)
        return a.second > b.second;
    return a.first < b.first;
}

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

    int N, T;
    cin >> N >> T;
    vector<pii> v(N);
    for (int i = 0; i < N; ++i)
        cin >> v[i].first >> v[i].second;
    sort(v.begin(), v.end(), cmp);

    vector<int> ma(N + 1);
    for (int i = N - 1; i >= 0; --i)
        ma[i] = max(ma[i + 1], v[i].second);

    int ans = ma[0];
    vector<vector<int>> dp(N + 1, vector<int>(T + 1));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= T; ++j) {
            dp[i + 1][j] = dp[i][j];
            if (j >= v[i].first)
                dp[i + 1][j] = max(dp[i][j - v[i].first] + v[i].second, dp[i + 1][j]);
        }
        ans = max(ans, dp[i + 1][T - 1] + ma[i + 1]);
    }
    ans = max(ans, dp[N][T]);

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int h,w,k;
    cin>>h>>w>>k;
    vector<string> s(h);
    vector<int> row(h, 0);
    vector<int> col(w, 0);
    int sum = 0;
    for (int i=0; i<h; i++) {
        cin>>s[i];
        for (int j = 0; j<w; j++) {
            if (s[i][j] == '#') {
                row[i]++; col[j]++;
                sum++;
            }
        }
    }
    if (sum < k) {
        cout << 0 << '\n';
        return 0;
    }
    int res = 0;
    //cout << sum << '\n';
    for (int i = 0; i<(1<<h); i++) {
        int rem = sum;
        for (int j = 0; j<h; j++) {
            if (i & (1 << j)) rem -= row[j];
        }
        if (rem < k) continue;
        for (int j=0; j<(1<<w); j++) {
            int rem1 = rem;
            for (int j1 = 0; j1 < w; j1++) {
                if (j & (1 << j1)) {
                    rem1 -= col[j1];
                    
                }
            }
            for (int i1 = 0; i1 < h; i1++) {
                for (int j1 = 0; j1 < w; j1++) {
                    if ((i & (1<<i1)) && (j & (1<<j1)) && s[i1][j1] == '#') rem1++;
                }
            }
            if (rem1 == k) res++;
        }
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 3560
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = np.array(list(sr()))
K = ir()
S = S[:K]
if np.all(S == '1'):
    answer = '1'
else:
    i = np.where(S != '1')[0][0]
    answer = S[i]

print(answer)


Measured memory_bytes: 12504
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll n;
	cin >> n;

	ll a0 = 4 * a;
	ll b0 = 2 * b;
	ll c0 = c;

	ll p = min({a0, b0, c0});

	ull res = 0;
	
	if (n % 2 == 0)
	{
		res = min(d, p * 2) * (n / 2);
	}
	else
	{
		res = min(d, p * 2) * (n / 2);
		res += p;
	}

	println(res);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	string a, b;
	cin >> a >> b;

	if(a.size()>b.size()) cout << "GREATER" << endl;
	if(a.size()<b.size()) cout << "LESS" << endl;
	if(a==b) cout << "EQUAL" << endl;

	if(a.size()==b.size()) {
		for(int i=0;i<a.size();i++) {
			if(a.at(i) > b.at(i)) {
				cout << "GREATER" << endl;
				break;
			}
			if(a.at(i) < b.at(i)) {
				cout << "LESS" << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    int top = 0, end = s.size() - 1, ans = 0;
    if(s.size() == 1) cout << 0 << endl;
    else if(s.size() == 2) cout << (s[0] == s[1] ? 0 : 1) << endl;
    else{
        while (top != end){
            if(s[top] != s[end]) ans++;
            if(top + 1 == end) break;
            top++;
            end--;
        }
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import random
import numpy as np

D = int(input())
c = list(map(int, input().split()))

s = []
for d in range(D):
    s.append(list(map(int, input().split())))


def get_objective_function(output):
    objective_function = 0
    last = [[-1 for i in range(26)] for d in range(D)]
    for d in range(D):
        objective_function += s[d][output[d]]
        last[d][output[d]] = d
        if d < D-1:
            for i in range(26):
                last[d+1][i] = max(last[d][i], last[d+1][i])
        for i in range(26):
            objective_function -= c[i] * (d-last[d][i])
    point = max(10 ** 6 + objective_function, 0)
    return point, objective_function


def local_search_swap(output, num_iter, width):
    for _ in range(num_iter):
        targets = np.random.randint(low=0, high=D-1, size=width)

        changed_output = output.copy()
        for i in range(width):
            changed_output[targets[i]] = changed_output[targets[(i+1)%width]]
        point1, obj1 = get_objective_function(changed_output)
        point2, obj2 = get_objective_function(output)
        print(point1, obj1, point2, obj2, width)

        if get_objective_function(changed_output) > get_objective_function(output):
            output = changed_output
        else:
            pass
    return output



def local_search(output, num_iter=5, width=3):
    for _ in range(num_iter):
        mask = np.random.randint(low=0, high=D-1, size=width)

        changed_output = output.copy()
        changed_output[mask] = (output[mask] + np.random.randint(low=0, high=D-1, size=width)) % 26

        point1, obj1 = get_objective_function(changed_output)
        point2, obj2 = get_objective_function(output)
        print(point1, obj1, point2, obj2, width)

        if get_objective_function(changed_output) > get_objective_function(output):
            output = changed_output
        else:
            pass
    return output


# 最大効用での戦略
output = []
for d in range(D):
    output.append(d%26)
output = np.array(output)

## 目的関数の確認
#output = local_search_swap(output, num_iter=10000, width=2)
#point = get_objective_function(output)

## 回答パターン
for d in range(D):
    print(output[d] + 1)


Measured memory_bytes: 27296
#include <iostream>

using namespace std;

int main()
{
long N, a, b, I, j, J, d, ans=0;
cin >> N; cin >> a; cin >> b;

for(I=1; I<=N; I++){
j=I;
d=0;
while(j!=0){
d += j%10;  j/=10;
}

if((d>=a)&&(d<=b)){
ans+=I;
}
}

cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int H, W;
	std::cin >> H >> W;

	while (H != 0 || W != 0) {
		for (int i = 0; i < H; i++) {
			if (i == 0 || i == H - 1) {
				for (int j = 0; j < W; j++) {
					std::cout << "#";
				}
			}
			else {
				for (int j = 0; j < W; j++) {
					if (j == 0 || j == W - 1) {
						std::cout << "#";
					}
					else {
						std::cout << ".";
					}
				}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
		std::cin >> H >> W;
	}
}

Measured memory_bytes: 1152
# 071 B 
#http://hetapy.hatenablog.com/entry/2013/08/23/115537
# lower-case a-z
alp = [chr(i) for i in range(97,97+26)]
S = input()
l = list()
for i in S:
    l.append(i)
L =list(set(alp) - set(l))
if len(L)==0:
    print("None")
    exit()
L.sort()
print(L[0])

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

//#define inf 2020202020*200000
#define mod 1000000007
#define maxn 100009
#define maxr 100009

void solve()
{
	ll n;
	rl(n);
	VL arr(n);
	ll sum=0;
	fr(i,0,n)
	{
		rl(arr[i]);
		sum+=arr[i];
	}
	
	ll sum2=0;
	ll ans=sum;
	fr(i,0,n)
	{
		ll x=sum-(arr[i]+sum2);
		sum2+=arr[i];
		ans=min(ans,abs(sum2-x));
	}
	cout<<ans;
	//wl(ans);
	NL;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 1792
//
    //  main.cpp
    //  study_c++
    //
    //  Created by Hisaki Kobayashi on 2020/03/31.
    //  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
    //

    #include <iostream>
    #include <stdio.h>
    #include <string>
//    #include <bits/stdc++.h>
#include <bits/stdc++.h>

    using namespace std;

    int main(int argc, const char * argv[]) {
        int N;
        string S;
        cin >> N;
        cin >> S;
        
        unsigned long offset;
        int cnt=0;
            
        for(int i=0;i<1000;i++){
            string n_100 = to_string(i/100);
            string n_10 = to_string((i/10)%10);
            string n_1 = to_string(i%10);
            string s = S;
//            100の位の探索
            if(s.find(n_100[0]) == string::npos)
               continue;
            offset = s.find(n_100[0]);
            s = s.substr(offset+1);
                        
//            10の位の探索
            if(s.empty())
                continue;
            if(s.find(n_10[0]) == string::npos)
                continue;
            offset = s.find(n_10[0]);
            s = s.substr(offset+1);
            
//            1の位の探索
            if(s.empty())
                continue;
            if(s.find(n_1[0]) == string::npos)
                continue;
//            cout << n_100[0] << n_10[0] << n_1[0] << " 10の位の探索開始時：" <<S.substr(offset_temp1+1) << "  1の位の探索開始時：" << S.substr(offset+1) << endl;
            cnt++;
        }
        cout << cnt << endl;
    }


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

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

const int INF = 1000000007;
const ll INFLL = 1000000000000000007;

#define st first
#define nd second
#define pb push_back
#define _boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// ***************************** CODE ***************************** //

const int MAX = 1e5 + 7;
const int mod = 1e9 + 7;

int dp[MAX];

void add(int& a, int b)
{
    a += b;
    if(a >= mod)
        a -= mod;
}

void sub(int& a, int b)
{
    a -= b;
    if(a < 0)
        a += mod;
}

int main() {
    _boost;

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

    dp[0] = 1;
    for(int i = 0; i < n; i++)
    {
        int x;  cin >> x;
        vector <int> fake(k + 1);
        for(int j = k; j >= 0; j--)
        {

            int l = j + 1;
            int r = j + min(x, k - j);
            if(l <= r)
            {
                add(fake[l], dp[j]);
                if(r+1 <= k)
                    sub(fake[r+1], dp[j]);
            }
        }
        int pre = 0;
        for(int j = 0; j <= k; j++)
        {
            add(pre, fake[j]);
            add(dp[j], pre);
        }
    }

    cout << dp[k];

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main(int argc, char const *argv[]) {
  double n;
  cin>>n;
  for(double i=n;i>0;i--){
    if((int)sqrt(i)*(int)sqrt(i)==i){
      cout<<setprecision(9)<<i<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[110][110];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
ll mazei[110][110];
int main() {
	cin >> n;
	ll sum = 0;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}
	else {
		bool flg = 0;
		rep(i, n) {
			if (a[i] % 10 != 0) {
				flg = 1;
			}
		}
		if (flg) {
			ll q = INF;
			rep(i, n) {
				if (a[i] % 10 != 0) {
					chmin(q, a[i]);
				}
			}
			cout << sum - q << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector <int> adj[100005];


int main()
{
    int n, wt;
    cin>>n>>wt;
    
    int w[n], v[n];
    for (int i = 0; i<n; i++)
    cin>>w[i]>>v[i];
        
    long long dp[n+1][wt+1];
    //memset (dp, 0, sizeof(dp));
        
    for (int i = 0; i<=n; i++)
    {
        for (int j = 0; j<=wt; j++)
        {
            if (i==0||j==0)
                dp[i][j] = 0;
            else if (w[i-1]<=j)
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    cout<<dp[n][wt];
    
    return 0;
}


Measured memory_bytes: 81536
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int X;
	cin >> X;

	string ans;

	if (X >= 30) ans = "Yes";
	else ans = "No";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = a; i < b ; i++)
#define REP(i, n) for ( int i = 0; i < n ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = (int)1e9 + 7;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

/* main */

int main() {
	int n, a, c[8] = { 0 }, d = 0, r = 0;
	scanf("%d", &n);
	REP(i, n) {
		scanf("%d", &a);
		if (a >= 3200)d++;
		else c[a / 400] = 1;
	}
	REP(i, 8) r += c[i];
	printf("%d %d", r ? r : 1, r + d);
	return 0;
}

Measured memory_bytes: 128
use strict;
my $N=<>;
my $count=0;
my $lastA=0;
my $startB=0;
my $dbl=0;
for(my $i=0;$i<$N;++$i){
	my $s=<>;
	chomp($s);
    
	while($s=~m/AB/g){
		++$count;
	}
	if($s=~m/^B.*A$/){
		++$dbl;
	}else{
		if($s=~m/^B/){++$startB;}
		if($s=~m/A$/){++$lastA;}
	}
}
my $tmp=$lastA;
#my $diffcount=abs($lastA-$startB);
if($tmp>$startB){$tmp=$startB;}
if($lastA==0 && $startB==0 && $dbl>0){--$dbl;}
print "".($count+$tmp+$dbl)."\n";



Measured memory_bytes: 512
#include<stdio.h>

int main(){
	long int a,b,c,d;
	long double res=0;
	scanf("%ld %ld %ld",&a,&b,&c);
	d=c-a-b;
	res=(4*a*b)-d*d;
	if(d>0 && res<0){
		puts("Yes");
	}
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
const int  N = 1e6 + 10;
int const mod = 1e9+7;
using namespace std;
 
int gcd(int a,int b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}
 int n,x,vis[N],cnt[N],cntm=0;
 
int main()
{
  cin>>n;
  bool tmam=1;
  int GCD=0;
	for(int i=0;i<n;i++)
    {
        cin>>x;
        cnt[x]++;
        GCD=gcd(GCD,x);
    }
    for(int i=2;i<N;i++)
    {
        cntm=0;
        if(vis[i]==0){
        for(int j=i;j<N;j+=i)
        {
            vis[j]=1;
            cntm+=cnt[j];
        }
        if(cntm>1)
            tmam=0;
        }
        if(!tmam)
            break;
    }
    if(tmam)
        cout<<"pairwise coprime"<<"\n";
    else if (!tmam&&GCD ==1)
        cout<<"setwise coprime"<<"\n";
    else
        cout<<"not coprime"<<"\n";
	return 0;
}

Measured memory_bytes: 11408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s,t;
  cin >> s >> t;
  sort(ALL(s));
  sort(ALLR(t));
  if(s<t){
    cout <<"Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
/*///////////////////////////////////////////*/
/*/ root@NULLCT$(´・ω・｀)<<"Be accept!!"  /*/
/*///////////////////////////////////////////*/
#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
typedef long long ll; using namespace std;
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
int main() {ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

string a;
cin >> a;
if (a[2] == a[3] && a[4] == a[5]) {
  cout << "Yes" << endl;
}
else {
  cout << "No" << endl;
}

return 0;
}



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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  vector<bool> v(n);
  int a;
  int b;
  bool flag = true;
  REP (i, n) {
    scanf("%d", &a);
    v[i] = a % 2;
    if (i == 0) b = v[i];
    else if (b != v[i]) flag = false;
  }

  if (flag && b == 0) {
    cout << "second" << endl;
    exit(0);
  } else if (flag && b == 1) {
    cout << "first" << endl;
    exit(0);
  }

  bool ans = v[0];

  srand(time(NULL));
  if (rand() % 12 == 1) {
    cout << "first" << endl;
    exit(0);
  }

  FOR (i, 1, n) ans = ans ^ v[i];

  if (!ans) cout << "second" << endl;
  else cout << "first" << endl;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> count;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        ++count[A[i]];
    }
    int ans = 0;
    vector<bool> OK(1E6 + 1, true);
    for (int i = 1; i <= 1E6; ++i) {
        if (OK[i] && count.count(i)) {
            if (count[i] == 1) {
                ++ans;
            }
            for (int j = 2 * i; j <= 1E6; j += i) {
                OK[j] = false;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 13660
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;

struct UnionFind {
	vector<int> data;
 	UnionFind(int size):data(size, -1) {}
	bool unite(int x,int y){
		x=root(x);
		y=root(y);
 	   if(x!=y){
			if (data[y]<data[x]){
				swap(x, y);
			}
			data[x]+=data[y];
			data[y]=x;
		}
		return x!=y;
	}
	bool same(int x, int y){
		return root(x)==root(y);
	}
	int root(int x){
		return data[x]<0? x:data[x]=root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int N,M;
int A[100010];
int X[100010],Y[100010];
int ans=0;

signed main(){
	cin>>N>>M;
	UnionFind UF(N+1);
	REP(i,N){
		cin>>A[i];
	}
	
	REP(i,M){
		cin>>X[i]>>Y[i];
		UF.unite(X[i]-1,Y[i]-1);
	}
	
	REP(i,N){
		if(i==A[i]-1){
			ans++;
		}
		else if(UF.same(i,A[i]-1)==true){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3456
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORL(i,a,b) for(ll i=(a);i<(b);++i)
#define REPL(i,n) FORL(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   RFOR(i,n,0)

using namespace std;

int main(){
	ll A[3], K, Taka[3], Naka[3], Hiku[3], tmp1[3], tmp2[3], ans = 0;
	scanf("%lld %lld %lld %lld", &A[0], &A[1], &A[2], &K);
	ans = A[0] - A[1];
	if (llabs(ans) > 1e+10){
		printf("Unfair\n");
	}
	else if (K % 2 == 0){
		printf("%lld\n", ans);
	}
	else{
		ans = ans*(-1);
		printf("%lld\n", ans);
	}

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int INF=(1<<30)-1;
const int MOD=1000000007;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll n, ans;
const int N_MAX = 100005;
ll a[N_MAX], b[N_MAX], c[N_MAX];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n) cin >> c[i];
    sort(a, a+n), sort(b, b+n), sort(c, c+n);
    rep(i, 0, n) {
        ll k = lower_bound(a, a+n, b[i]) - lower_bound(a, a+n, 0);
        ll l = upper_bound(c, c+n, b[i]) - upper_bound(c, c+n, 0);
        ans += (k*(n-l));
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
using std::cin ;
using std::cout;

int main(){
  int N,K,Q; cin>>N>>K>>Q;
  int* member = new int[N];
  for (int i=0;i<Q;++i){
    int tmp; cin>>tmp;
    ++member[tmp-1];
  }
  for(int i=0;i<N;++i){
    if((member[i]+K)>Q){
      cout << "Yes";
    }else{
      cout << "No";
    }
    cout << std::endl;
  }
  return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	str := oneStr()

	nums := []int{}

	for _, s := range str {
		n := string(s)
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}


	ans := calc(nums)

	fmt.Println(ans)
}

func calc(nums []int) int {
	if len(nums) == 1 {
		return 0
	}

	if len(nums) == 2 {
		if nums[0] == nums[1] {
			return 1
		} else {
			return 0
		}
	}

	ans0 := 0
	ans1 := 0
	for i :=0;i< len(nums);i++ {
		// 0スタート
		if  i % 2 != 0 &&  nums[i] == 0{
			ans0++
		}
		if i % 2 == 0 &&  nums[i] == 1{
			ans0++
		}

		//1
		if i % 2 != 0 &&  nums[i] == 1{
			ans1++
		}
		if i % 2 == 0 &&  nums[i] == 0{
			ans1++
		}
	}

	return min(ans0,ans1)
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

template <class operator_monoid> class dual_segment_tree{
public:
	typedef typename operator_monoid::underlying_type underlying_type;
	typedef typename operator_monoid::value_type value_type;
	size_t n;
	vector<underlying_type> v;
	vector<value_type> w;
	underlying_type e = operator_monoid::unit();
	dual_segment_tree(size_t size){
		n = 1;
		while(n < size) n <<= 1;
		v.resize(2*n, e);
		w.resize(size, operator_monoid::default_value());
	}
	dual_segment_tree(vector<value_type> _w){
		size_t size = w.size();
		n = 1;
		while(n < size) n <<= 1;
		v.resize(2*n, e);
		w(_w);
	}
	void range_operate(underlying_type f, size_t a, size_t b, size_t k, size_t l, size_t r){
		if(r <= a || b <= l) return;
		if(a <= l && r <= b) v[k] = operator_monoid::compose(f, v[k]);
		else{
			if(2*k < v.size())
				v[2*k] = operator_monoid::compose(v[k], v[2*k]);
			if(2*k+1 < v.size())
				v[2*k+1] = operator_monoid::compose(v[k], v[2*k+1]);
			v[k] = operator_monoid::unit();
			range_operate(f, a, b, 2*k, l, (l+r+1)/2);
			range_operate(f, a, b, 2*k+1, (l+r+1)/2, r);
		}
	}
	void range_operate(underlying_type f, size_t a, size_t b){
		range_operate(f, a, b, 1, 0, n);
	}
	value_type point_get(size_t i){
		range_operate(e, i, i+1, 1, 0, n);
		return operator_monoid::operate(v[i+n], w[i]);
	}
};
struct assign_operator_monoid{
	using underlying_type = pair<bool, Int>;
	using value_type = Int;
	static underlying_type unit(){
		return pair<bool, int>(true, 0);
	}
	static underlying_type compose(underlying_type l, underlying_type r){
		if(l == unit()) return r;
		return l;
	}
	static value_type default_value(){
		return 0;
	}
	static value_type operate(underlying_type f, value_type x){
		return f.first ? x : f.second;
	}
};
struct add_operator_monoid{
	using underlying_type = Int;
	using value_type = Int;
	static underlying_type unit(){
		return 0;
	}
	static underlying_type compose(underlying_type l, underlying_type r){
		return l + r;
	}
	static value_type default_value(){
		return 0;
	}
	static value_type operate(underlying_type f, value_type x){
		return f + x;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, q; cin >> n >> q;
	dual_segment_tree<add_operator_monoid> dst(n);
	while(q--){
		Int p; cin >> p;
		if(p == 0){
			Int s, t, x; cin >> s >> t >> x;
			--s; --t;
			dst.range_operate(x, s, t+1);
		}else{
			Int i; cin >> i;
			cout << dst.point_get(i-1) << "\n";
		}
	}
}


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

int main() {
  int64_t n, ans = 0;
  cin >> n;
  rep(i, n + 1) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int x,y;cin>>x>>y;
    rep(i,x+1){
        if(2*i+(x-i)*4==y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

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

        StringBuilder sb = new StringBuilder(str);
        for(int i=0; i<q; i++) {
            String order = sc.next();
            int index1 = sc.nextInt();
            int index2 = sc.nextInt();
            if(order.equals("replace")) {
                String target = sc.next();
                sb.replace(index1, index2+1, target);
            } else if(order.equals("reverse")) {
                StringBuilder tmp1 = new StringBuilder(sb.substring(index1, index2+1));
                sb.replace(index1, index2+1, tmp1.reverse().toString());
            } else {
                System.out.println(sb.substring(index1, index2+1));
            }
        }
        sc.close();
    }
}



Measured memory_bytes: 29760
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int[] D = new int[N];
		
		for(int i = 0; i < N; i++){
			D[i] = sc.nextInt();
		}
		
		Arrays.sort(D);
		
		int pizzac = C;
		int pizzap = A;
		
		for(int i = N-1; i >= 0; i--){
			if(pizzac / pizzap <= (pizzac + D[i]) / (pizzap + B)){
				pizzac += D[i];
				pizzap += B;
			}
		}
		System.out.println(pizzac/pizzap);
	}
}

Measured memory_bytes: 18116
object Main extends App{
    val Array(n, k) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
   	val x = scala.io.StdIn.readLine.split(" ").map(_.toInt)

   	var ans = Int.MaxValue

   	for(i<-0 to n-k){
   		ans = math.min(ans, x(i).abs + (x(i+k-1) - x(i)).abs)
   		ans = math.min(ans, x(i+k-1).abs + (x(i) - x(i+k-1)).abs)
   	}

   	println(ans)

}


Measured memory_bytes: 39932
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  int n;
  while(cin >> n && n) {
    P a[n];
    set<P> s;
    for(int i=0; i<n; i++) {
      cin >> a[i].first >> a[i].second;
      s.insert(P(a[i].first,a[i].second));
    }
    int ans=0;
    for(int i=0; i<n; i++) {
      for(int j=i+1; j<n; j++) {
        P b=P(a[j].first-a[i].first,a[j].second-a[i].second);
        P p=P(a[j].first+b.second,a[j].second-b.first);
        P q=P(a[i].first+b.second,a[i].second-b.first);
        P p2=P(a[j].first-b.second,a[j].second+b.first);
        P q2=P(a[i].first-b.second,a[i].second+b.first);
        int d=b.first*b.first+b.second*b.second;
        if(s.count(p)&&s.count(q)) ans=max(ans,d);
        if(s.count(p2)&&s.count(q2)) ans=max(ans,d);
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1356