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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define ins insert
#define ft front()
#define bk back()
#define f first
#define s second
#define trav(a,x) for(auto& a : x)
#define ALL(x) (x).begin(), (x).end()

const int MOD = 1000000007;
const int MX = 2e5+2;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);
const pi dir[4] = {{1,0}, {0,1}, {-1,0}, {0,-1}};

// -----------

// https://atcoder.jp/contests/abc151/tasks/abc151_d
// BFS from each point, ez brute force

int h, w;
char grid[21][21];
int dist[21][21];

int bfs(int x, int y){
    queue<pi> q;
    q.push({x,y});
    R0F(y1,h){
        F0R(x1,w){
            dist[x1][y1] = 0;
        }
    }
    int res = 0;
    while(!q.empty()){
        int currX = q.front().f; int currY = q.front().s;
        q.pop();
        F0R(i,4){
            if(currX + dir[i].f < 0 || currX + dir[i].f >= w) continue;
            if(currY + dir[i].s < 0 || currY + dir[i].s >= h) continue;
            if(grid[currX + dir[i].f][currY + dir[i].s] == '#') continue;
            if(currX + dir[i].f == x && currY + dir[i].s == y) continue;
            if(dist[currX + dir[i].f][currY + dir[i].s]) continue;
            dist[currX + dir[i].f][currY + dir[i].s] = dist[currX][currY] + 1;
            res = max(res, dist[currX + dir[i].f][currY + dir[i].s]);
            q.push({currX + dir[i].f, currY + dir[i].s});
        }
    }
    return res;
}

int main(){
    IOS;
    cin >> h >> w;
    R0F(y,h){
        F0R(x,w){
            cin >> grid[x][y];
        }
    }
    int ans = 0;
    R0F(y,h){
        F0R(x,w){
            if(grid[x][y] == '.'){
                ans = max(ans, bfs(x,y));
            }
        }
    }
    cout << ans;
    return 0;
    // You should actually read the notes to self.
}

/* NOTES TO SELF:
    Int overflow? Array bounds?
    Edge cases? (n = 1, n = 0)
    Don't be dumbosity please pace yourself.
*/

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int x, y; cin >> x >> y;

    int ans = 0;
    int i = 0;
    while( 1 ){
        if( x <= y ){
            ans++;
        }else{
            break;
        }
        y /= 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
	char s[1010];

    while (1) {
        scanf ("%s", s);
        if (s[0] == '0') break;
        int sum = 0;
        for (int i = 0; i < strlen(s); i++) {
            sum += (s[i] - '0');
        }
        printf ("%d\n", sum);
    }
    
    return 0;
}


Measured memory_bytes: 2708
n,p=map(int,input().split())
s=input()
if p==2 or p==5:
    ans=0
    for i in range(n):
        if int(s[i])%p==0:
            ans+=i+1
    print(ans)
else:
    t=[]
    ti=0
    for i in range(n):
        ti+=int(s[-i-1])*pow(10,i,p)
        ti%=p
        t.append(ti)
    from collections import Counter
    tc=Counter(t)
    ans=0
    for v in tc.values():
        ans+=(v*(v-1))//2
    if 0 in tc:
        ans+=tc[0]
    print(ans)


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

if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
    print(0)
elif a == b == c:
    print(-1)
else:
    count = 0
    while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        a, b, c = (b+c)/2, (a+c)/2, (a+b)/2
        count += 1
    print(count)


Measured memory_bytes: 9200
s = input()
swi = 0
lst = ["a", "b", "c", "d", "e", "f", "g", "h", \
       "i", "j", "k", "l", "m", "n", "o", "p", \
       "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

for i in range(26):
    if (lst[i] in s) == False:
        print(lst[i])
        swi = 1
        break
if swi == 0:
    print("None")

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

const int maxn = 10000010, P = 1000000007;
int n, A, fact[maxn], finv[maxn], inv[maxn];

int main() {
    scanf("%d %d", &n, &A);
    fact[0] = finv[0] = inv[0] = inv[1] = 1;
    for (int i = 1; i <= n; i++) {
        fact[i] = 1LL * i * fact[i - 1] % P;
        if (i > 1) inv[i] = 1LL * (P - P / i) * inv[P % i] % P;
        finv[i] = 1LL * finv[i - 1] * inv[i] % P;
    }
    auto C = [&](int x, int y) {
        return 1LL * fact[x] * finv[y] % P * finv[x - y] % P;
    };
    int ans = 0;
    for (int t = 2; t <= A + 1; t++) {
        int a = t - 1, b = n - A, c = max(0, A - t);
        for (int j = 0; j <= a; j++) {
            int coef = j & 1 ? P - 1 : 1;
            ans = (ans + 1LL * coef * C(a, j) % P * (a - j) % P * inv[a - j + b]
                % P * fact[a - j + b + c]) % P;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

using ll = long long;

bool judge(vector<ll>& a, vector<ll>& b) {
    int n = b.size();
    vector<int> ids_a(n), ids_b(n);
    iota(ids_a.begin(), ids_a.end(), 0);
    iota(ids_b.begin(), ids_b.end(), 0);
    sort(ids_a.begin(), ids_a.end(), [&](int i1, int i2){return a[i1] < a[i2];});
    sort(ids_b.begin(), ids_b.end(), [&](int i1, int i2){return b[i1] < b[i2];});
    
    bool ans = false;
    for (int ii = 0, jj = 0; ii < n; ii++) {
        int i = ids_b[ii];
        while (jj < n) {
            int j = ids_a[jj];
            if (a[j] <= b[i]) {
                jj++;
            }
            else break;
        }
        if (jj <= ii) return false;
        if (jj > ii + 1) {
            ans = true;
        }
    }

    if (ans) return true;

    vector<int> zip(n);
    for (int i = 0; i < n; i++) zip[ids_a[i]] = i;

    vector<int> used(n, false);
    int cnt = 0;
    for (int i = 0; !used[ids_a[i]]; i = zip[ids_b[i]]) {
        used[ids_a[i]] = true;
        cnt++;
    }
    return (cnt < n - 1);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    if (!judge(a, b)) {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------

string s;
int cnt;
int maxcnt;

int main(){
    cin >> s;
//    debug(s[4])

    REP(i, s.size()){
        
        if(s.at(i)== 'A' || s.at(i)== 'T' || s.at(i) == 'C' || s.at(i) == 'G'){
            cnt++;
        }
        else{
            cnt = 0;
        }
        maxcnt = max(cnt, maxcnt);
    }
    cout << maxcnt << endl;

    return 0;
}

Measured memory_bytes: 764
A,B,C,D,E,F = map(int,input().split())
concentration_max = 0
tatal_max = 0
sugar_max = 0
for a in range(int(F/100/A)+1):
    rest_F = F - 100*A*a
    for b in range(int(rest_F/100/B)+1):
        sum_water = 100*(A*a+b*B)
        sum_sugar_max = min(sum_water/100*E,F-sum_water)
        for c in range(int(sum_sugar_max/C)+1):
            sum_sugar_max_rest = sum_sugar_max - c*C
            for d in range(int(sum_sugar_max_rest/D)+1):
                #print(a,b,c,d)
                sum_sugar = c*C+d*D
                sum_total = sum_water+sum_sugar
                if sum_total == 0:
                    break
                concentration = sum_sugar/(sum_water+sum_sugar)
                if concentration >= concentration_max:
                    concentration_max = concentration
                    total_max = sum_total
                    sugar_max = sum_sugar
print(total_max,sugar_max)

Measured memory_bytes: 3064
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: u8 = iterator.next().unwrap().parse().unwrap();
    let b: u8 = iterator.next().unwrap().parse().unwrap();

    let ans = 6 - (a + b);

    return ans.to_string();
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
const int N=1e5+5;
int ad[N],l[N],r[N];
int main(){
	int n,i,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		ad[x]=i;
	}
	
	for(i=1;i<=n;i++){
		l[i]=i-1;r[i]=i+1;
	}
	
	int y,z,p;
	ll ans=0;
	for(i=1;i<=n;i++){
		x=l[ad[i]];y=l[x];
		z=r[ad[i]];p=r[z];
		
		if(x!=0) ans+=1ll*(x-y)*(z-ad[i])*i;
		if(z!=n+1) ans+=1ll*(ad[i]-x)*(p-z)*i;
		
		r[x]=z;
		l[z]=x;
	}
	
	printf("%lld",ans);
	return 0;
}

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

int a[200];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        if (a[i] % 2 == 0 && (a[i] % 3 && a[i] % 5)) {
            printf("DENIED\n");
            return 0;
        }

    printf("APPROVED\n");
    return 0;
}

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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  vector<int> H(N); // 標高を格納
  for (int i = 0; i < N; i++)
    cin >> H.at(i);
  /*
  for (int i = 0; i < N; i++)
    cout << H.at(i) << endl;
  */
  // ここまでOK
  vector<double> temp(N); // 平均気温を格納
  for (int i = 0; i < N; i++)
    temp.at(i) = T - H.at(i) * 0.006;
  /*
  for (int i = 0; i < N; i++)
    cout << temp.at(i) << endl;
  */
  vector<double> d(N); // 温度差を格納
  for (int i = 0; i < N; i++) {
    if (temp.at(i) < A)
      d.at(i) = A - temp.at(i);
    else
      d.at(i) = temp.at(i) - A;
  }
  int ans;
  for (int i = 0; i < N; i++) {
    if (d.at(i) < d.at(ans))
      ans = i;
  }
  cout << ans+1 << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000;
#define mod MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    ll a, b, c; cin >> a >> b >> c;
    ll cnt = 0;
    if(a + b > c){
        cnt = b+c;
    } else if(a + b == c){
        cnt = b+c;
    } else {
        cnt = a+b+1 + b;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from fractions import gcd

# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np    # numpy.lcm()
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk
# import networkx as nx
# G = Graph()

# slist = "abcdefghijklmnopqrstuvwxyz"
A,B = map(int,input().split())

print(A*B)
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
 
template <typename T>
vector<T> dijkstra(Int s,vector<vector<pair<Int, T> > > & G,T INF){
  using P = pair<T, Int>;
  Int n=G.size();
  vector<T> d(n,INF);
  vector<Int> b(n,-1);
  priority_queue<P,vector<P>,greater<P> > q;
  d[s]=0;
  q.emplace(d[s],s);
  while(!q.empty()){
    P p=q.top();q.pop();
    Int v=p.second;
    if(d[v]<p.first) continue;
    for(auto& e:G[v]){
      Int u=e.first;
      T c=e.second;
      if(d[u]>d[v]+c){
	d[u]=d[v]+c;
	b[u]=v;
	q.emplace(d[u],u);
      }
    }
  }
  return d;
}
//INSERT ABOVE HERE
signed main(){
  Int n,m,s,t;
  cin>>n>>m>>s>>t;
  s--;t--;
  
  using P = pair<Int, Int>;
  vector<vector<P> > G(n),H(n);
  for(Int i=0;i<m;i++){
    Int x,y,a,b;
    cin>>x>>y>>a>>b;
    x--;y--;
    G[x].emplace_back(y,a);
    G[y].emplace_back(x,a);
    H[x].emplace_back(y,b);
    H[y].emplace_back(x,b);
  }
  
  const Int INF = 1e17;
  auto A=dijkstra(s,G,INF);
  auto B=dijkstra(t,H,INF);
 
  vector<Int> ans(n+1,INF);
  for(Int i=n-1;i>=0;i--)
    ans[i]=min(ans[i+1],A[i]+B[i]);
 
  Int tmp=1e15;
  for(Int i=0;i<n;i++) cout<<tmp-ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 19364
program swap
  implicit none

  integer :: N, M
  integer :: i, j
  integer :: sum_vote
  real(kind=8) :: rate
  integer, allocatable :: A(:)

  read *, N, M

  allocate(A(1:N))
  read *, A(:)

  sum_vote = sum(A(:))
  rate = sum_vote * dble(4*M)**(-1)

  j = 0
  do i = 1, N
    if (A(i) >= rate) then
      j = j + 1
    end if
  end do

  if (j >= M) then
    print *, "Yes"
  else if (j < M) then
    print *, "No"
  end if
end program swap


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

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % int(powl(10,9) + 7);
    }

    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;

    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    cout << n * 800 - n / 15 * 200 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define Fi first
#define Se second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>

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

void scani(int &x)
{
    register int c = gc();x = 0;int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

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

int main()
{
    fsscan();
    int x,y;
    cin>>x>>y;
    if(x>=13)
    cout<<y;
    else
    if(x>=6 && x<=12)
    cout<<y/2;
    else
    cout<<"0";
    return 0;
}


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

int n,m;
int a[50],b[50];

bool graph[50][50];
bool visited[50];

void dfs(int v) {
  visited[v] = true;
  for ( int v2 = 0; v2 < n; v2++ ) {
    if ( graph[v][v2] == false ) continue;
    if ( visited[v2] == true ) continue;
    dfs(v2);
  }
}

int main() {

  cin >> n >> m;

  for ( int i = 0; i < m; i++ ) {
    cin >> a[i] >> b[i];
    a[i]--,b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  
  int ans = 0;

  for ( int i = 0; i < m; i++ ) {
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

    for ( int j = 0; j < n; j++ ) visited[j] = false;

    dfs(0);

    bool bridge = false;
    for (int j = 0; j < n; j++ ) if ( visited[j] == false ) bridge = true;
    if(bridge) ans++;

    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

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


Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


void solve()
{
    int n ,m ;
    cin >> n >> m ;
    int pr[n] = {} , done[n] = {}  ;
    rep(i , m){
        int p ;
        string s ;
        cin >> p >> s ;
        --p;
        if(!done[p]) pr[p] += (s == "WA");
        done[p] |= (s == "AC");
    }
    int co = 0 , wa = 0;
    rep(i , n) co += done[i] ;
    rep(i , n) if(done[i]) wa += pr[i] ;
    cout << co << " " << wa;  
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 1792
use std::io;
use std::io::prelude::*;
use std::cmp::{max, min};
use std::str::FromStr;

fn main() {
    let hwd: Vec<usize> = reads(&get_line());
    let (h, w, d) = (hwd[0], hwd[1], hwd[2]);
    let locs = read_locs(h as usize, w as usize);
    let mut costs: Vec<Vec<u32>> = vec![vec![]];
    for offset in 1..d + 1 {
        // because 1-indexed
        // I would really like to use `scan`
        // but some interfaces I'd hope for are missing..??
        let mut costl = vec![0];
        let mut c = 0;
        for mul in 1..1 + (w * h - offset) / d {
            c += mhd(locs[offset + (mul - 1) * d], locs[offset + mul * d]);
            costl.push(c);
        }
        costs.push(costl);
    }
    let q: usize = get_line().parse().unwrap();
    let tasks: Vec<Task> = get_lines(q).iter().map(|l| parse_task(l)).collect();
    for task in tasks {
        let offset = match task.l % d as usize {
            0 => d as usize,
            m => m,
        };
        let this_cost = costs[offset][(task.r - offset) / d as usize]
            - costs[offset][(task.l - offset) / d as usize];
        println!("{}", this_cost);
    }
}

/// returns a Vec. locs[n] returns (x,y), the (0-origin) coordinate
/// of the grid with the value `n`.
fn read_locs(h: usize, w: usize) -> Vec<(u32, u32)> {
    let stdin = io::stdin();
    let mut locs: Vec<(u32, u32)> = Vec::with_capacity(h * w + 1);
    unsafe {
        // something I'd like to have entry?
        locs.set_len(h * w + 1);
    }
    // FIXME : locs[0] is unsafe. Option<_> will be too verbose, but.....
    let lock = stdin.lock();
    for (i, l) in lock.lines().take(h).enumerate() {
        // can't we just annotate type for `n`?
        // also, can't the rustc just infer n as usize?
        for (j, &n) in reads::<usize>(&l.unwrap()).iter().enumerate() {
            locs[n] = (i as u32, j as u32);
        }
    }
    locs
}

fn mhd(p0: (u32, u32), p1: (u32, u32)) -> u32 {
    max(p0.0, p1.0) - min(p0.0, p1.0) + max(p0.1, p1.1) - min(p0.1, p1.1)
}

fn get_line() -> String {
    let mut inp = String::new();
    io::stdin().read_line(&mut inp).expect("read error");
    inp.trim().to_string()
}

fn get_lines(n: usize) -> Vec<String> {
    let stdin = io::stdin();
    let lock = stdin.lock();
    let lines = lock.lines().take(n).map(|l| l.unwrap()).collect(); // for lifetime?
    lines
}

fn reads<T>(input: &str) -> Vec<T>
where
    T: FromStr,
    T::Err: std::fmt::Debug,
{
    input
        .trim()
        .split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect()
}

fn parse_task(input: &str) -> Task {
    let ns: Vec<usize> = reads(input);
    Task { l: ns[0], r: ns[1] } // hate this verboseness
}

struct Task {
    l: usize,
    r: usize,
}


Measured memory_bytes: 18684
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

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

  vector<int> w(N);
  int wsum=0;
  vector<int> b(N);
  int bsum=0;
  REP(i,N){
    if(S.at(i)=='.'){
      wsum++;
      w[i]=wsum;
    }
  }
  REPR(i,N-1){
    if(S.at(i)=='#'){
      bsum++;
      b[i]=bsum;
    }
  }

  int MIN = INF;
  REP(i,N+1){
    if(i==0){
      MIN=min(MIN,N-i-b[i]);
    }else if(i==N){
      MIN=min(MIN,i-w[i-1]);
    }else{
      MIN=min(MIN,N-i-b[i]+i-w[i-1]);
    }
  }

  cout << MIN << endl;
}

Measured memory_bytes: 2180
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

using namespace std;


#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




int main() {
	ll n;
	cin >> n;
	vector<ll> ans(n,0);
	vector<ll> as(n);
	rep(i,n){
		cin >> as[i];
		if(i>0){
			ans[0] = ans[0]^as[i];
		}
	}
	reps(i,n-1){
		ans[i] = ans[i-1]^as[i]^as[i-1];
	}
	rep(i,n){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
int MOD = 998244353;
const int mxN = 2e9 + 9;




int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b;
	cin >> a >> b;
	cout << a*b;




}


Measured memory_bytes: 3640
def main():
    n = int(stdinput())

    st = [None] * (4**12)

    for _ in range(n):
        cmd, value = stdinput().split()
        if cmd == 'insert':
            st[get_hash(value)] = 1
        elif cmd == 'find':
            if st[get_hash(value)] == 1:
                print('yes')
            else:
                print('no')

CODES = {'A' : 1, 'C' : 2, 'G' : 3, 'T' : 4}
def get_hash(s):
    base = 1
    h = 0
    for c in s:
        code = CODES[c]
        h += code * base
        base *= 4
    return h

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')


Measured memory_bytes: 137144
# -*- coding: utf-8 -*-
N = int(input())
A = [int(input()) for _ in range(N)]
setA = set(A)
tempA = list(setA)
R = sorted(tempA, reverse=True)
max_v = R[0]
if len(R) >= 2:
  max_v2 = R[1]
else:
  max_v2 = R[0]
R2 = sorted(A, reverse=True)
if R2[0] == R2[1]:
  signal = 1
else:
  signal = 0
  
for i in range(N):
  if A[i] == max_v and signal == 0:
    print(max_v2)
  else:
    print(max_v)

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

int main() {
  int N; cin >> N;
  vector<string> W(N);
  map<string, int> mp;
  for (int i = 0; i < N; ++i) {
    cin >> W[i];
    ++mp[W[i]];
  }
  bool ans = true;
  for (auto&& c : mp) {
    if (c.second > 1) ans = false;
  }
  for (int i = 1; i < N; ++i) {
    if (W[i - 1].back() != W[i].front()) ans = false;
  }
  cout << ( (ans) ? "Yes" : "No" ) << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

#define mod 1000000007
#define INF 1000000000
#define SIZE 100

int main(){
  int a,b;

  scanf("%d%d",&a,&b);

  printf("%d\n",a*b);
}

Measured memory_bytes: 1192
#include<iostream>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>
#define pb push_back
#define ff first
#define ss second
#define N 100001
using namespace std;

int n;
vector<int> v[N];
vector<long long> w[N];
int clr[N];
bool vis[N];

void fun(int i,int c){
    vis[i] = 1;
    clr[i] = c;
    for(int j=0;j<v[i].size();j++){
        if(!vis[v[i][j]]){
            if(w[i][j]%2==0){
                 fun(v[i][j],c);
            }
            else{
                fun(v[i][j],1-c);
            }
        }
    }
}

int main(){
   cin>>n;
   int x,y;
   long long w1;
   for(int i=0;i<n;i++){
       cin>>x>>y>>w1;
       v[x].pb(y);
       w[x].pb(w1);
       v[y].pb(x);
       w[y].pb(w1);
   }
   fun(1,0);
   for(int i=1;i<=n;i++){
       cout<<clr[i]<<endl;
   }
}

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

int main() {
	char n[5]; cin >> n;

	if (n[0] == n[1] && n[1] == n[2]) cout << "Yes" << endl;
	else if (n[1] == n[2] && n[2] == n[3]) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<cassert>
#include<map>
#define eps (1e-8)
#define MAX 100000
using namespace std;
int n,m,k;
int M[MAX];

void dfs(int a,int b,int cost)//a->n , b->m
{
  if(a >= n)
    {
      assert(cost < MAX);
      M[max(cost-k,1)]++;
      return;
    }

    for(int i=1;i<=m;i++)
    {
      dfs(a+1,b+i,cost+i);
    }

}

int main()
{
  while(cin >> n >> m >> k,n|m|k)
    {    
      for(int i=0;i<MAX;i++)M[i] = 0;     
      dfs(0,0,0);
      long double total = 0;
      for(int i=0;i<MAX;i++)total += i*M[i];
      cout << setiosflags(ios::fixed) << setprecision(8) << total/pow((double)m,(double)n) << endl;
    }
  return 0;
}

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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = (a*b) % MOD;
}

int main(){
    int N, A[300];
    cin >> N;
    int sum = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum += A[i];
    }
    const int MX = 300*300;
    static int64_t dp[301][MX+301], sub[301][MX+301];
    dp[0][0] = 1;
    sub[0][0] = 1;
    for(int i=0; i<N; i++) for(int j=0; j<=MX; j++){
        add(dp[i+1][j+A[i]], dp[i][j]);
        add(dp[i+1][j], 2*dp[i][j]);
        add(sub[i+1][j+A[i]], sub[i][j]);
        add(sub[i+1][j], sub[i][j]);
    }

    int64_t ng = 0;
    for(int j=(sum+1)/2; j<=MX; j++) add(ng, dp[N][j]);
    if(sum%2 == 0) add(ng, MOD - sub[N][sum/2]);
    mul(ng, 3);

    int64_t ans = 1;
    for(int i=0; i<N; i++) mul(ans, 3);
    add(ans, MOD - ng);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 424192
X = int(input())
a = [i for i in range(1, 10**5)]
import bisect
from collections import deque
s = deque([])
s.append(0)
i = 0
while s[i] < 10 ** 9:
    s.append(s[i] + a[i])
    i += 1

print(bisect.bisect_left(s, X))


Measured memory_bytes: 9112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    int r = 0;
    for (int k = 0; k <= 28; k++) {
        int l = 1 << k;
        int m = l * 2 - 1;

        for (int h = 0; h < 2; h++) {
            int j = 0;
            for (int i = 0; i < n; i++) {
                if (!(a[i] & l)) c[j++] = a[i];
            }
            for (int i = 0; i < n; i++) {
                if (a[i] & l) c[j++] = a[i];
            }
            if (h == 0) {
                a.swap(b);
                b.swap(c);
            } else {
                c.swap(a);
            }
        }

        int s = n;
        for (int h = 1; h <= 3; h++) {
            int t = l * h;
            int j = 0;
            for (int i = n - 1; i >= 0; i--) {
                while (j < n && (a[i] & m) + (b[j] & m) < t) j++;
                s ^= j;
            }
        }
        if (s & 1) r ^= l;
    }

    cout << r << endl;

    return 0;
}

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

int n;
typedef long long i64;

vector<i64> a;

#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int main()
{
    cin >> n;
    a.resize(n,0);
    rep(i,0,n - 1) cin >> a[i];
    sort(a.begin(),a.end());
    int result = 0;
    int cou = 1;
    rep(i,1,n - 1)
    {
        if(a[i - 1] == a[i]) cou++;
        else
        {
            if(cou % 2 == 1) result++;
            cou = 1;
        }
    }
    if(cou % 2 == 1) result++;
    cout << result << endl;
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h,n;cin>>w>>h>>n;
  int x,y,a;
  int tmpx1=0,tmpx2=w,tmpy1=0,tmpy2=h;
  for(int i=0;i<n;i++){
    cin>>x>>y>>a;
    if(a==1){
      if(tmpx1<x)tmpx1=x;
    }
    else if(a==2){
      if(tmpx2>x)tmpx2=x;
    }
    else if(a==3){
      if(tmpy1<y)tmpy1=y;
    }
    else{
      if(tmpy2>y)tmpy2=y;
    }
  }
  if(tmpx2-tmpx1<=0||tmpy2-tmpy1<=0){
    cout <<0<<endl;
    return 0;
  }
  else{
    cout <<(tmpx2-tmpx1)*(tmpy2-tmpy1)<<endl;
  }
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<map>

using namespace std;


int n, k, p;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> k >> p;
		if (k%p == 0)
			cout << p << endl;
		else
			cout << k%p << endl;
	}
	//cin >> n;
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
using std::cerr;
using std::cin;
using std::cout;
using std::pair;
using std::string;
using std::vector;
//region
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (b); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repr1(i, n) for (int i = (n); i > 0; i--)
#define outif(b, t, f) cout << ((b) ? (t) : (f)) << endl
#define all(vec) (vec).begin(), (vec).end()
#define sz(x) (int((x).size()))
#define mset(v, n) std::memset((v), n, sizeof(v))
#define BIT(N) (1LL << (N))
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using vint = vector<int>;
using vlong = vector<ll>;
using vstr = vector<string>;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpll = vector<pll>;
using vvi = vector<vint>;
using vvl = vector<vlong>;
vector<string> split(const string &s, const string &delim) {
  vector<string> res;
  uint pos = 0;
  while (true) {
    const int found = s.find(delim, pos);
    if (found < 0) {
      res.push_back(s.substr(pos));
      break;
    }
    res.push_back(s.substr(pos, found - pos));
    pos = found + delim.size();
  }
  return res;
}
template<typename T> string join(vector<T> &vec, const string &sep) {
  size_t size = vec.size();
  if (!size) return "";
  std::stringstream ss;
  for (int i = 0; i < size - 1; i++)
    ss << vec[i] << sep;
  ss << vec[size - 1];
  return ss.str();
}
template<typename T> std::istream &operator>>(std::istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template<typename Iter> inline void print(const Iter &first, const Iter &last, const std::string &d, bool endline) {
  cout << *first;
  for (Iter iter = first + 1; iter < last; ++iter) {
    cout << d << *iter;
  }
  if (endline) cout << "\n";
}
constexpr ll powmod(ll a, ull b, ull p) {
  ll res = 1;
  while (b > 0) {
    if (b % 2) res = res * a % p;
    a = a * a % p;
    b >>= 1u;
  }
  return res;
}
template<class T> bool chmax(T &a, const T &b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, const T &b) { return a > b ? (a = b, true) : false; }
template <typename T> void bsort(vector<T>& v) { std::sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T>& v) { std::sort(v.begin(), v.end(), std::greater<T>()); }
struct iii {
    iii() {
      cin.tie(nullptr); cout.tie(nullptr);
      std::ios::sync_with_stdio(false);
      cout << std::fixed << std::setprecision(16);
    }
} init;
//endregion

void solve();

int main() {
  int t = 1;
  // scanf("%d", &t);
  rep(_,t) solve();
  return 0;
}

void solve() {
  string S;cin>>S;

  size_t cnt1=0;
  for(char c:S)cnt1+=c=='1';
  printf("%d\n", std::min(cnt1,S.size()-cnt1)*2);
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main(){
	int h, w, i, j;
	string l[105];
	cin >> h >> w;
	for(i = 0; i < h; i++){
		cin >> l[i];
	}
	for(i = 0; i < l[0].length()+2; i++){
		cout << "#";
	}
	cout << endl;
	for(i = 0; i < h; i++){
		cout << "#" << l[i] << "#" << endl;
	}
	for(i = 0; i < l[0].length()+2; i++){
		cout << "#";
	}
	cout <<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	int N;
	cin>>N;
	vl A(N);
	rep(i,0,N){
		cin>>A[i];
		if(A[i]==0){
			cout<<0<<endl;
			return 0;
		}
	}
	DBG("","","","");
	ll ans;
	ans=A[0];
	rep(i,1,N){
		ll check;
		check=INF/ans;
//		if(INF%ans) check++;
		if(check<A[i]){
			ans=-1;
			break;
		}
		else{
			ans*=A[i];
		}
	}
	if(ans>INF) ans=-1;
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  rep(i,0,n) rep(j,i,n) {
    bool flag = true;
    rep(k,i,j+1) {
      if (s[k] != 'A' && s[k] != 'C' && s[k] != 'G' && s[k] != 'T') {
        flag = false;
      }
    }
    if (flag) {
      ans = max(ans,j-i+1);
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{

    int a,b;
    cin>>a;
    cin>>b;
    int s=1;
    for(int i=1; i<=a; i++)
    {
        if(s<b)
        {
            s*=2;
        }
        else
        {
            s+=b;

        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

n, m = gets.chomp.split(/ /).map(&:to_i)
array = []
n.times do
  array << gets.chomp.split(/ /).map(&:to_i)
end

pattern = Array.new
f = [1, -1]
s = [1, -1]
t = [1, -1]

f.each do |i|
  s.each do |j|
    t.each do |k|
      pattern << [i, j, k]
    end
  end
end

ans = 0

pattern.each do |pat|
  kari = Array.new
  array.each do |e|
    kari << (pat[0] * e[0] + pat[1] * e[1] + pat[2] * e[2])
  end
  kari.sort!{|a, b| (b<=>a)}
  num = 0
  (0...m).each do |l|
    num += kari[l]
  end
  ans = num if ans < num
end

puts ans

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

int main(){
    int n, m;
    cin >> n >> m;
    
    vector<ll> x(n), y(n), z(n), s(n);
    rep(i, n){
        cin >> x[i] >> y[i] >> z[i];
    }

    ll ans = 0;
    for (int i = 0; i < 1<<3; i++){
        int ax, ay, az;
        if(i&1){
            ax = 1;
        }else{
            ax = -1;
        }
        if(i>>1 &1){
            ay = 1;
        }else{
            ay = -1;
        }
        if(i>>2&1){
            az = 1;
        }else{
            az = -1;
        }

        rep(i, n){
            s[i] = ax*x[i] + ay*y[i] + az*z[i];
        }
        sort(s.begin(), s.end(), greater<>());
        
        ll su= 0;
        rep(i, m){
            su += s[i];
        }
        ans = max(ans, su);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = b - 1; i >= a; i--)
#define RREP(i, n) RFOR(i, 0, n)
#define rep(i, a, b) for (auto i = a; i < b; i++)
#define rrep(i, a, b) for (auto i = a; i > b; i--)
#define range(i, a, b) (a <= i && i < b)
#define int long long
#define fi first
#define fs first
#define se second
#define sc second
using namespace std;
using vec = vector<int>;
using mat = vector<vec>;
typedef pair<int, int> P;

int n, x, y;

void solve(){
	vec step(n);
	int cur = 1;
	REP(i, n - 1) cur *= 2;
	int mid = cur;
	REP(i, n) {
		if (x <= cur) {
			step[i] = 1; //ue
			x = cur - x + 1;
		}
		else {
			step[i] = 0; //sita
			x = x - cur;
		}
		cur /= 2;
	}

	//REP(i, n) cout << step[i] << endl;
	//return;

	reverse(step.begin(), step.end());

	REP(i, n) {
		if (y <= mid) {
			if (step[i]) {
				cout << 'L';
				y = mid - y + 1;
			}
			else {
				cout << 'R';
			}
		}
		else {
			if (step[i]) {
				cout << 'R';
				y = 2 * mid - y + 1;
			}
			else {
				cout << 'L';
				y -= mid;
			}
		}
		mid /= 2;
	}
	cout << endl;
}

signed main() {
	while (cin >> n >> x >> y, n) solve();
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	long long int s=0;
	long long int ans=400000000000000000;
	int i;
	for(i=0;i<n;i++)
	cin>>a[i];
	s=a[0];
	long long int p=0;
	if(s>0)
	{
		for(i=1;i<n;i++)
		{
			if(i%2)
			{
				if(s+a[i]<0)
				{
					 s+=a[i];
				}
				else 
				{
					p+=1+s+a[i];
					s=-1;
				}		
			}
			else
			{
				if(s+a[i]>0)
				s+=a[i];
				else
				{
					p+=1-s-a[i];
					s=1;
				}	
			}
		}
		s=-1;
		ans=min(ans,p);
		p=a[0]+1;
		for(i=1;i<n;i++)
		{
			if(i%2==0)
			{
				if(s+a[i]<0)
				{
					 s+=a[i];
				}
				else 
				{
					p+=abs(1+s+a[i]);
					s=-1;
				}		
			}
			else
			{
				if(s+a[i]>0)
				s+=a[i];
				else
				{
					p+=abs(1-s-a[i]);
					s=1;
				}	
			}
		}
		ans=min(ans,p);     
		cout<<ans<<endl;
	}
	else if(s<0)
	{
		for(i=1;i<n;i++)
		{
			if(i%2==0)
			{
				if(s+a[i]<0)
				{
					 s+=a[i];
				}
				else 
				{
					p+=abs(1+s+a[i]);
					s=-1;
				}		
			}
			else
			{
				if(s+a[i]>0)
				s+=a[i];
				else
				{
					p+=abs(1-s-a[i]);
					s=1;
				}	
			}
		}
		s=1;
		ans=min(ans,p);
		p=(-1)*a[0]+1;
		for(i=1;i<n;i++)
		{
			if(i%2==1)
			{
				if(s+a[i]<0)
				{
					 s+=a[i];
				}
				else 
				{
					p+=abs(1+s+a[i]);
					s=-1;
				}		
			}
			else
			{
				if(s+a[i]>0)
				s+=a[i];
				else
				{
					p+=abs(1-s-a[i]);
					s=1;
				}	
			}
		}
		ans=min(ans,p);
		//cout<<p<<endl; 
		cout<<ans<<endl;
	}
	else
	{
		p=1;
		s=1;
		for(i=1;i<n;i++)
		{
			if(i%2)
			{
				if(s+a[i]<0)
				{
					 s+=a[i];
				}
				else 
				{
					p+=abs(1+s+a[i]);
					s=-1;
				}		
			}
			else
			{
				if(s+a[i]>0)
				s+=a[i];
				else
				{
					p+=abs(1-s-a[i]);
					s=1;
				}	
			}
		}
		s=-1;
		ans=min(ans,p);
		p=1;
		for(i=1;i<n;i++)
		{
			if(i%2==0)
			{
				if(s+a[i]<0)
				{
					 s+=a[i];
				}
				else 
				{
					p+=abs(1+s+a[i]);
					s=-1;
				}		
			}
			else
			{
				if(s+a[i]>0)
				s+=a[i];
				else
				{
					p+=abs(1-s-a[i]);
					s=1;
				}	
			}
		}
		ans=min(ans,p);
		cout<<ans<<endl;		
	}
	return 0;
}



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

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

int main() {
  int w,h,v;
  string s;
  while(cin>>w>>h, w||h) {
    int x=1,y=1,dir=0;
    while(1) {
      cin>>s;

      if(s == "STOP") {
	cout<<x<<" "<<y<<endl;
	break;
      }else if(s == "FORWARD") {
	cin>>v;
	x += v*dx[dir];
	y += v*dy[dir];
      }else if(s == "BACKWARD") {
	cin>>v;
	x += -v*dx[dir];
	y += -v*dy[dir];
      }else if(s == "RIGHT") {
	dir++;
      }else if(s == "LEFT") {
	dir--;
      }
      x = min(w,x);
      x = max(1,x);
      y = min(h,y);
      y = max(1,y);
      dir = (dir+4)%4;
    }
  }
}

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

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

		if( a == b )
		{
		cout << "a == b" << endl;
		}else{
			if( a > b)
			{
			cout << "a > b" << endl;
			}else{
			cout << "a < b" << endl;
			}
		}

}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

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

int main(){
    int n;
   cin >> n;
    int a,c;
    a = n / 100;
    c = n % 10;

    if(a == c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL=int64_t;
const int INF=0x3f3f3f3f;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    string s;
    cin>>a>>b>>s;
    int flag=0;
    for(int i=0;i<s.length();i++) {
        if(i<a&&s[i]>='0'&&s[i]<='9') continue;
        else if(i==a&&s[i]=='-') continue;
        else if(i>a&&s[i]>='0'&&s[i]<='9') continue;
        else flag=1;
    }
    if(flag==1) cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}


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

typedef long long ll;
const int MOD = 998244353;

map<string, int> g, f;

int F(string s);
int G(string s);

int main()
{
	f[""] = 1;
	string s;
	cin >> s;
	cout << F(s) << endl;
	return 0;
}

int F(string s)
{
	if(f.find(s) != f.end()) return f[s];
	int& ans = f[s];
	for(int i = 1; i <= s.size(); ++i)
		(ans += (ll)F(s.substr(0, s.size() - i)) * G(s.substr(s.size() - i, i)) % MOD) %= MOD;
	return ans;
}

int G(string s)
{
	if(g.find(s) != g.end()) return g[s];
	int& ans = g[s];
	if(s.size() == 1) return ans = s[0] - '0' + 1;
	for(int i = 1; i < s.size(); ++i)
		if(s.size() % i == 0)
		{
			string t;
			for(int j = 0; j < i; ++j)
			{
				int r = 1;
				for(int k = 0; k < s.size() / i; ++k)
					if(s[i * k + j] == '0') r = 0;
				t += (char)(r + '0');
			}
			(ans += F(t)) %= MOD;
		}
	return ans;
}

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

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> H(N);

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

	sort(H.begin(), H.end());

	long long ans = 0;

	for (int i = 0; i < N-K; i++) {
		ans += H[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int K,i;
    char str[100];

    scanf("%d",&K);
    for(i=0;i<K*3;i=i+3){
        str[i]='A';
        str[i+1]='C';
        str[i+2]='L';
        str[i+3]='\0';
    }

    printf("%s\n",str);

    return 0;
}

Measured memory_bytes: 2084
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

int main(void) {
    string S;
    cin >> S;

    int ans = 0;
    for (int i = 0; i < (int) S.size(); i++) {
        if (S[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }

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


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()

min_a = float('inf')
#max_a = -1
cnt = 0
for num in A:
    if num < min_a:
        cnt += 1
        min_a = num
print(cnt)

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

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

	char a[26] = {'q','a','z','w','s','x','e','d','c','r','f','v','t','g','b','y','h','n','u','j','m','i','k','o','l','p'};
    int b [26] = {0};
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < 26;j++){
			if(s[i] == a[j]) b[j] += 1; 
		}
	}

	bool can =true;

	for(int i=0; i<26; i++){
		if(b[i] % 2 != 0) can = false;
	}
	cout<<"\n";

	if(can) cout<<"Yes\n";
	else cout<<"No\n";

	
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAX = 1e5+5;


int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n;
        cin >> n;
        LL a[n+2] , dp[n+2];
        for(int i = 1 ; i <= n ; i++)
        {
                cin >> a[i];
        }
        dp[1] = 0;
        dp[2] = abs(a[2] - a[1]);
        for(int i  = 3 ; i <= n ; i++)
        {
                dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]) , dp[i-2] + abs(a[i] - a[i-2]));
        }
        cout << dp[n] << endl;
        return 0;
}

Measured memory_bytes: 1792