akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>                                                                        
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> W(N);
  int s1,s2;
  int min=1000;
  for(int i=0; i<N; i++){
    cin >> W.at(i);
  }
    for(int i=0; i<N; i++){
      for(int j=0; j<=i; j++)
        s1+=W.at(j);
      for(int k=i+1; k<N; k++)
        s2+=W.at(k);
      if(min>abs(s1-s2))
        min=abs(s1-s2);
      s1=0;
      s2=0;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
x,n,*a=map(int,open(0).read().split())
b=[1]*103
for i in a:
    b[i]=0
c=1000 
ans=n
for i in range(102):
    if b[i] and c>abs(x-i):
        c=abs(x-i)
        ans=i
print(ans)

Measured memory_bytes: 9192
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;

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


int main(){
    ll X;
    cin>>X;
    ll res=0;
    ll a = X/500;
    res+= a*1000;
    X -= a*500;
    res +=(X/5)*5;
    cout<<res<<endl;
    
}

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

int main(){
    while(1){
        int count = 0;
        char X[1001];
        scanf("%s",X);
        if (X[0]== '0') break;
        for(int i=0;i < strlen(X);i++){
            count += (X[i] -'0');
            
        }
        cout << count << endl;
        
    }
    
    return 0;
}


Measured memory_bytes: 3256
#include <iostream>
using namespace std;
typedef long long int lli;

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

    lli ans;
    if(a + b >= c){
        ans = b + c;
    }else{
        ans = b + (b + a) + 1;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
const int mod = 1e9 + 7;
using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int dp[3030][3030];
string s,t;
int n,m;
int solve(int i,int j){
    if(i == n||j == m)return 0;
    if(dp[i][j]+1)return dp[i][j];
    dp[i][j] = 0;
    if(s[i] == t[j])dp[i][j] = solve(i+1,j+1)+1;
    dp[i][j] = max(dp[i][j],solve(i+1,j));
    dp[i][j] = max(dp[i][j],solve(i,j+1));
    return dp[i][j];
}
void path(int i,int j){
    if(i == n||j == m)return ;
    if(s[i] == t[j]&&dp[i][j] == solve(i+1,j+1)+1){
        cout << s[i];path(i+1,j+1);
        return ;
    }
    if(dp[i][j] == solve(i+1,j))path(i+1,j);
    else path(i,j+1);
}
int main(){
    ios::sync_with_stdio(0);
    cin >> s >> t;n = s.size(),m = t.size();
    memset(dp,-1,sizeof dp);
    solve(0,0);
    path(0,0);
    return 0;
}


Measured memory_bytes: 36608
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	ll x, k, d;
	cin >> x >> k >> d;
	if (x < 0) x *= -1;
	if (x/d >= k) {
		cout << x - k * d << endl;
		return 0;
	}
	ll kk = k - x / d;
	x %= d;
	if (kk % 2 == 0) {
		cout << x << endl;
	}
	else{
		cout << d-x << endl;
	}
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	private static final int BIG_NUM  = 2000000000;
	private static final int MOD  = 1000000007;

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input_str[] = new String[2];

		Set<String> Dictionary = new HashSet<String>();
		StringBuilder ans = new StringBuilder();

		try {
			int Q = Integer.parseInt(br.readLine());

			for(int loop = 0; loop < Q; loop++){

				input_str = br.readLine().split("\\s+");

				if(input_str[0].equals("insert")){
					Dictionary.add(input_str[1]);
				}else{ //find
					if(Dictionary.contains(input_str[1])){
						ans.append("yes\n");
					}else{
						ans.append("no\n");
					}
				}
			}

			System.out.print(ans.toString());

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}




Measured memory_bytes: 323584
#include <cstdio>

int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){

                if((i + j) % 2 == 0) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2600
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P>PP;
int a[100006];

signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	int l = -1, r = -1;
	rep(i, n) {
			if (i + 1 > a[i]) {
				l = a[i - 1] - i;
				r = 0;
				for (int j = i; j < n; j++)if (i == a[j])r++;
				break;
			}
		}
	if (l == -1 && r == -1) {
		l = 0;
		r = a[n - 1] - n;
	}

	if (l % 2 == 0 && r % 2 == 0)puts("Second");
	else puts("First");
}

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

int main(int argc, char **argv)
{
    int N;
    std::cin >> N;
    std::vector<int> d(N);
    for(int i = 0; i < N; i++){
        std::cin >> d.at(i);
    }
    int sum = 0;
    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            sum += d.at(i) * d.at(j);
        }
    }
    std::cout << sum << std::endl;
}


Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll A, B; cin >> A >> B;
    FOR(C, 1, 4){
        if((A*B*C) % 2 == 1) {cout << "Yes" << endstr; return 0;};
    }
    cout << "No" << endstr;
    return 0;
}


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

using namespace std;
using ll = long long;

static const ll N = 200001;
static const long long MOD = 998244353;

struct Combination {
    vector<ll> fact, inv, finv;
    Combination(int n): fact(n+1), inv(n+1), finv(n+1) {
        fact[0] = fact[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for(int i=2; i<n+1; i++) {
            fact[i] = fact[i-1] * i % MOD;
            inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    int operator() (int n, int k) {
        if(k < 0 || k > n) return 0;
        return fact[n] * (finv[k] * finv[n-k] % MOD) % MOD;
    }
};

int main() {
    long long n, m, k;
    cin >> n >> m >> k;

    Combination cmb(200001);

    ll ans = 0, col = m;
    for(int x=n-1; x>=0; x--) {
        ll now = col;
        now *= cmb(n-1, x);
        now %= MOD;
        if(x <= k) ans = (ans + now) % MOD;
        col *= m-1;
        col %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8016
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n;
	cin>>n;
	int ans = 0;
	for(int i=1;i<=n;i++){
        int counter = 0;
        for(int j=1;j<=i;j++){
            if(i%j==0){
                counter++;
            }
        }
        if(counter==8&&i%2!=0){
            ans++;
        }
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

N = read()

if 1 <= N <= 2:
  print(N); exit()

for k in range(N):
  if (k-1)*k < N*2 <= k*(k+1):
    break

while N > 0 and k > 0:
  if k <= N:
    N -= k; print(k)
  k -= 1


Measured memory_bytes: 4068
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	int n; cin>>n;
	cout<<(n*(n+1))/2<<'\n';
	
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; ++i) {
		cin >> L[i];
	}
	int sum = 0, mx = 0;
	for (int i = 0; i < N; ++i) {
		sum += L[i];
		mx = max(mx, L[i]);
	}
	sum -= mx;
	cout << (mx < sum ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

ll calc(ll a, ll b, ll n) {
    ll x = n >= b? b - 1 : n;
    ll max = 0;

    max = floor((a*x)/b) - a * floor(x/b);

    return max;
}

int main() {
    ll a, b, n;

    cin >> a >> b >> n;

    cout << calc(a, b, n) << endl;

    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    string s;
    cin>>s;
    string ans="Yes";
    
    string hoge=s;
    reverse(hoge.begin(),hoge.end());
    if(s!=hoge) ans="No";
    
    hoge=s.substr(0,(s.size()-1)/2);
    reverse(hoge.begin(),hoge.end());
    if(s.substr(0,(s.size()-1)/2)!=hoge) ans="No";
    
    hoge=s.substr((s.size()+3)/2-1,s.size()-((s.size()+3)/2-1));
    reverse(hoge.begin(),hoge.end());
    if(s.substr((s.size()+3)/2-1,s.size()-((s.size()+3)/2-1))!=hoge) ans="No";
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


INF = 10 ** 10 // 3
def main():
    N, Ma, Mb = map(int, input().split())
    l = []
    for _ in range(N):
        a, b, c = map(int, input().split())
        l.append((a, b, c))

    dp = [[[INF] * 401 for _ in range(401)] for _ in range(N + 1)]
    dp[0][0][0] = 0
    for i in range(len(l)):
        for a in range(len(dp[0])):
            for b in range(len(dp[0][0])):
                if dp[i][a][b] != INF:
                    dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])
                    dp[i + 1][a + l[i][0]][b + l[i][1]] = min(dp[i + 1][a + l[i][0]][b + l[i][1]], dp[i][a][b] + l[i][2])

    ans = INF
    for i in range(len(dp)):
        for a in range(1, len(dp[0])):
            for b in range(1, len(dp[0][0])):
                if dp[i][a][b] != INF:
                    if Ma * b == Mb * a:
                        ans = min(ans, dp[i][a][b])

    print(-1 if ans == INF else ans)


if __name__ == '__main__':
    main()


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

int main() {
  int A,B,C,D;
  1 <= A,B,C,D <= 10;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
  cout << "Left" << endl;
  }
  else if (A + B == C + D) {
  cout << "Balanced" << endl;
  }
  else {
  cout << "Right" << endl;
  }
}

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

int dp[105][105];

int main() {
  int H,W;
  cin >> H >> W;
  vector< string > S(H+1);
  REP(i,H) {
    cin >> S[i+1];
    S[i+1] = "." + S[i+1];
  }
  REP(i,W+1)  S[0][i] = '.';

  REP(i,W+1)  dp[0][i] = 100000;
  REP(i,H+1)  dp[i][0] = 100000;
  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[1][0] = 0;
  for( int i=1; i<H+1; i++ ) {
    for( int j=1; j<W+1; j++ ) {
      dp[i][j] = min( (S[i][j] == S[i-1][j]) ? dp[i-1][j] : dp[i-1][j]+1,
                      (S[i][j] == S[i][j-1]) ? dp[i][j-1] : dp[i][j-1]+1 );
    }
  }
  if (S[H][W] == '#' ) dp[H][W]++;
  int ans = dp[H][W] / 2 + (dp[H][W]%2);
  cout << ans << endl;

//  REP(i,H+1) {
//    REP(j,W+1){
//      if ( dp[i][j] == 100000 ) cout << "* ";
//      else cout << dp[i][j] << " ";
//    }
//    cout << endl;
//  }
}


Measured memory_bytes: 256
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        ans += max(0, bisect.bisect_left(L, L[i]+L[j]) - j - 1)
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <array>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <uint64_t N>
class Combination {
  using _Tp = long long;
public: 
  array<_Tp, N> fac, finv, inv;

  constexpr
  Combination() {
    init();     
  }

  constexpr
  void init() {
    fac[0] = fac[1] = 1;        
    finv[0] = finv[1] = 1;      
    inv[1] = 1; 
    for(int i = 2; i < N; i++){    
      fac[i] = fac[i-1] * i % MOD;      
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;        
      finv[i] = finv[i-1] * inv[i] % MOD;       
    }
  }

  // n!! * k!^(-1) * ((n - k)!)^(-1)   
  constexpr
  _Tp comb(_Tp n, _Tp k) const {
    if (n < k) return 0;        
    if (n < 0 || k < 0) return 0;       
    return fac[n] * (finv[k]* finv[n - k] % MOD) % MOD; 
  }

  constexpr
  _Tp operator ()(_Tp n, _Tp k) const {
    return comb(n, k);
  }
};

template <class T, class U>
void add(T & a, const U b) {
  a = (a + b) % MOD;
}

template <class T, class U>
void mul(T & a, const U b) {
  a = (a * b) % MOD;
}

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  Combination<3000100> comb;

  int64_t ans1 = 0, ans2 = 0;
  for (int i = 1; i < n; ++i) {
    add(ans1, i * (n - i));
  }
  mul(ans1, m * m % MOD);
  
  for (int i = 1; i < m; ++i) {
    add(ans2, i * (m - i));
  }
  mul(ans2, n * n % MOD);
  
  add(ans1, ans2);
  
  mul(ans1, comb(n * m - 2, k - 2));
  // debug(comb(n * m - 2, k - 2));
  cout << ans1 << endl;
}


Measured memory_bytes: 70528
//
//  main.cpp
//  project for C++
//
//  Created by 伊藤博隆 on 2020/04/17.
//  Copyright © 2020 伊藤博隆. All rights reserved.
//

#include <iostream>

using namespace std;
int S,W;

int main(){
    

    cin >> S >> W ;
    if (W >= S) {
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
}
   
    return 0;
}



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

int main(void){
    int n,r=0;

    cin >> n >> r;
    if(n<1||100<n||r<0||4111<r)
        return 0;
    else if(1<=n&&n<=9){
        cout << 100*(10-n)+r << endl;
    }
    else if(10<=n&&n<=100){
        cout << r << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
#define mod 1000000007
#define PI 3.141592653589793238462643383279
#define P pair<int,int>
#define F first
#define S second
#define pq priority_queue
#define prique pq<int,vector<int>,greater<int>>
using namespace std;
int pa[100010];//親
int ra[100010];//木の高さ
int si[100010];//木のノ-ドの数
int x[100010],y[100010],z[100010];
void init(int x){//初期化
	f(i,x){
		pa[i]=i;
		ra[i]=0;
		si[i]=1;
	}
}
int find(int x){//根を求める
	if(pa[x]==x) return x;
	else return pa[x]=find(pa[x]);
}
void unite(int x,int y){//木の併合
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(ra[x]<ra[y]){
		pa[x]=y;
		si[y]+=si[x];
	}
	else{
		pa[y]=x;
		if(ra[x]==ra[y]) ra[x]++;
		si[x]+=si[y];
	}
}
bool same(int x,int y){
	return find(x)==find(y);
}
signed main(){
	int n,m;
	cin>>n>>m;
	init(n);
	f(i,m){
		cin>>x[i]>>y[i];
		x[i]--,y[i]--;
	}
	int ans=n*(n-1)/2;
	for(int i=m-1;i>=0;i--){
		z[i]=ans;
		if(!same(x[i],y[i])){
			ans+=si[find(x[i])]*(si[find(x[i])]-1)/2;
			ans+=si[find(y[i])]*(si[find(y[i])]-1)/2;
			ans-=(si[find(y[i])]+si[find(x[i])])*(si[find(x[i])]+si[find(y[i])]-1)/2;
		}
		unite(x[i],y[i]);
	}
	f(i,m) cout<<z[i]<<endl;
	return 0;
}


Measured memory_bytes: 6016
# https://atcoder.jp/contests/agc007/tasks/agc007_a
# よく考えてみれば最短距離で進むということは、横にW-1回、縦にH-1回移動するのだから
# #に成るマス目は最初の1マスも含めてH+W-1個であるはずである。
# いま最初と最後は連結であることがわかっているのだから、個数だけ確かめれば良い
# https://atcoder.jp/contests/agc007/tasks/agc007_a
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_ints(): return list(map(int, read().split()))


def read_map_as(H, replace={'#': 1, '.': 0}, pad=None):
    '''
    文字列のmapを置換して読み込み。デフォでは#→1,.→0
    '''
    if pad is None:
        ret = []
        for _ in range(H):
            ret.append([replace[s] for s in read()[:-1]])
            # 内包表記はpypyでは若干遅いことに注意
            # #numpy使うだろうからこれを残しておくけど
    else:  # paddingする
        ret = [[pad] * (W + 2)]  # Wはどっかで定義しておくことに注意
        for _ in range(H):
            ret.append([pad] + [replace[s] for s in read()[:-1]] + [pad])
        ret.append([pad] * (W + 2))

    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

# 常に右、下に動いていたなら、経路は一つに決まる。
# →#をたどってそれ以外に#があるかを判別すれば良い
H, W = read_ints()
A = read_map_as(H)
n_sharp = reduce(add, reduce(add, A))
print('Possible' if n_sharp == H + W - 1 else 'Impossible')


Measured memory_bytes: 68360
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

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

template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v) {os << " [" << i++ << "]" << x; if (i % 10 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp) {os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string s;
  std::cin >> s;

  std::map<char, ll> mc;
  mc['C'] = -1;
  mc['F'] = -1;
  for (ll i = 0; i < (ll)s.size(); i++) {
    if (s[i] == 'C' && mc['C'] >= 0) continue;
    mc[s[i]] = i;
  }

  std::string judge = (mc['C'] >= 0 && mc['F'] >= 0 && mc['C'] < mc['F']) ? "Yes" : "No";

  print(judge);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
string s;
int a;
int func();//+-
int num();
int func2();//*/
int func3();//()
int num(){
	int out=0;
	while(isdigit(s[a])){
		out*=10;out+=s[a]-'0';
		a++;
	}
	return out;
}
int func3(){
	int out;
	if(s[a]=='('){
		a++;
		out=func();
		a++;
	}else out=num();
	return out;
}
int func2(){
	int out=func3();
	while(1){
		if(s[a]=='*'){
			a++;
			out*=func3();
		}else if(s[a]=='/'){
			a++;
			out/=func3();
		}else break;
	}
	return out;
}	
int func(){
	int out=func2();
	while(1){
		if(s[a]=='+'){
			a++;out+=func2();
		}else if(s[a]=='-'){
			a++;out-=func2();
		}else break;
	}
	return out;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		a=0;
		cin>>s;
		//s="0+"+s;
		cout<<func()<<endl;
	}
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long int
#define pb push_back
int main(){
    ll a, cnt=0;
    cin>>a;
    for (ll i=1; i<=a; i++){
        cnt+=a/i;
        if (a%i==0) cnt--;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
    long long n, s; cin >> n >> s;
    if (s == n) { cout << n+1 << endl; return 0; }
    for (int b = 2; (long long)b * b <= n; b++) {
        int sum = 0;
        for (long long x = n; x > 0; x /= b) sum += x%b;
        if (sum == s) { cout << b << endl; return 0; }
    }
    long long ans = 1LL << 60;
    for (long long x = 1; x * x < n; x++) {
        long long y = s - x;
        if ((n - y) % x == 0) {
            long long b = (n - y) / x;
            if (x < b && 0 <= y && y < b) ans = min(ans, b);
        }
    }
    cout << (ans == 1LL << 60 ? -1 : ans) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a[10];
  int i;
  int j;
  int b;
  for(i=0; i<10; i++){
    scanf("%d", &a[i]);
  }
  for(i=1; i<10; i++){
    for(j=0; j<i; j++){
      if (a[i]>a[j]){
        b=a[i];
        a[i]=a[j];
        a[j]=b;
      }
    }
  }
  for(i=0; i<3; i++){
    printf("%d\n", a[i]);
  }
  return 0;
}

Measured memory_bytes: 600
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.numeric;
import std.math;

ulong[] primeFactoring(ulong target)
{
  ulong s = target.to!float.sqrt().floor.to!ulong;
  ulong num = target;
  ulong[] primes;
	for (ulong i = 2; i <= s; i++) {
    if (num % i != 0) continue;

		while (num%i == 0) num /= i;
    primes ~= i;
	}
  if (num > s) primes ~= num;

  debug writeln(primes);
	return primes;
}

void main() {
  ulong N, M; readf("%d %d\n", &N, &M);
  ulong[] commonDiviers;
  ulong greatest = gcd(N, M);

  auto answerDivisers = primeFactoring(greatest);
  writeln(answerDivisers.length + 1);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    String strFront = sc.next();
    String strBlue = sc.next();
    String strRed = sc.next();
    long Front = Long.parseLong(strFront);
    long Blue = Long.parseLong(strBlue);
    long Red = Long.parseLong(strRed);
    
    if(Blue == 0) {
    	System.out.println(0);
    	return;
    }
    long cycle = Front / (Blue + Red);
    long remainder = Front % (Blue + Red);
    if(remainder > Blue) {
    	remainder = Blue;
    }
    
    System.out.println(cycle * Blue + remainder);

}
}

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

using namespace std;

int main()
{
	int arr[4]={0,300000,200000,100000};
	int x,y;
	cin >> x >> y;
	int ans=0;
	if(x<=3) ans+=arr[x];
	if(y<=3) ans+=arr[y];
	if(x==1&&y==1) ans+=400000;
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>

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

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

  int sum = 0;
  int a = n / 500;
  int b = (n % 500) / 5;
  sum += 1000 * a + 5 * b;

  std::cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = [0, 0, 0, 0]
strings = ['AC', 'WA', 'TLE', 'RE']
for _ in range(N):
    curr = input()
    if curr == 'AC':
        ans[0] += 1
    elif curr == 'WA':
        ans[1] += 1
    elif curr == 'TLE':
        ans[2] += 1
    else:
        ans[3] += 1

for i in range(4):
    print(strings[i] + ' x ' + str(ans[i]))

Measured memory_bytes: 9212
while (h, w = gets.split().map(&:to_i)) != [0, 0]
  if w % 2 == 0
    h.times{|i|
      puts i%2==0 ? "#."*(w/2) : ".#"*(w/2)
    }
  else
    for i in 0...h
      for j in 0...w
        if i % 2 == 0
          if j % 2 == 0 then print "#" else print "." end
        else
          if j % 2 == 0 then print "." else print "#" end
        end
      end
      puts
    end
  end
  puts
end

Measured memory_bytes: 8728
import sys
input = sys.stdin.readline


def main():
    r, g, b, n = map(int, input().split())
    ans = 0
    for i in range(n//r + 1):
        for j in range(n//g + 1):
            residue = n - i*r - g*j
            if residue >= 0 and residue % b == 0:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9112
// '
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef unsigned short sint;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
const ld TAU=2*acos(-1);
const ld eps=1e-8;
const int inf=1e9+99;
const ll linf=1e18+99;





int32_t main() {
	int n; scanf("%d",&n);
	static int a[300<<10];
	for(int i=0;i<n+n+n;i++) scanf("%d",a+i);
	sort(a,a+3*n);
	reverse(a,a+3*n);
	ll Z=0;
	for(int i=1,j=0;j<n;++j,i+=2) Z+=a[i];
	printf("%lld\n",Z);
}








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

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

  int max = 1;
  for (int b = 1; b <= 100; b++) {
    for (int q = 2; q <= 50; q++) {
        int x = (int)pow(b, q);
        // cout << x << endl;
        if (x <= X && max < x) {
          max = x;
        }
        if (x > X) {
          break;
        }
    }
  }

  cout << max << endl;

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int k,a,b; cin >> k >> a >> b;
  bool f=0;
  for(int i=a;i<=b;i++){
    if(i%k==0) f=1;
  }
  if(f) cout << "OK" << endl;
  else cout << "NG" << endl;
}

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

int main()
{
  int n;
  cin>>n;
  int a[n],x[n];
  int i,j,sum=0,sub=0;
  for(i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  for(i=1;i<=n-2;i+=2){
    sub+=a[i];
  }
  x[0]=sum-2*sub;
  cout<<x[0]<<' ';
  for(i=1;i<n;i++){
    x[i]=2*a[i-1]-x[i-1];
    cout<<x[i]<<' ';
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ff first
#define ss second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;


int32_t main()
{
    fast

   int test=1;
  // cin>>test;

  while(test--)
  {
  
 int n;
 cin>>n;
vvi dp(n,vi (n,0));
int a[n];
for(int i=0;i<n;i++)cin>>a[i];

  for(int l=n-1;l>=0;l--)
    for(int r=l;r<n;r++)
    {
      if(l==r)dp[l][r]=a[l];
      else dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
    }

    cout<<dp[0][n-1];

  //while loop ending 
  }



return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
	ll a, b, k;
	cin >> a >> b >> k;
	ll x = 0;
	for(int i = a; i <= b; i++){
		if(x < k || x > (b - a ) - k){
			cout << i << endl;
		}
		x++;
	}
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>
#define endl '\n'
#define FIO ios_base::sync_with_stdio(0); cin.tie(NULL)
#define pb push_back
#define pii pair<int,int>
#define ll long long int 
#define ui unsigned int
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>  
#define mp make_pair
#define F first
#define S second
#define sz size()
#define all(x) (x).begin(),(x).end() 
#define SORT(v) sort(all(v))
#define SORTD(v) sort(all(v),greater<int>())
#define SET(a,b) for(ui i=0;i<size(a);++i){a[i]=b;} 
#define test() int t; cin>>t ; while(t--)
#define FOR(i,a,b) for(int i=a;i<b;++i)  
#define cerr if(0)cerr
#define watch(x) cerr<<#x<<" is "<<x<<endl;
#define print(x) cout<<x<<endl
#define readv(v) FOR(i,0,n){cin>>v[i];}
#define printv(v) for(auto i : v){cout<<i<<" ";}cout<<endl;
const ll MOD=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


//_________________________________________________________________________________

using namespace std;


int main()
{
	FIO;
	int n;
	cin>>n;
	
	vector<int> v(n);
	readv(v);
	SORT(v);
	
	stack<double> s;
	s.push(v[0]);
	for(int i=1;i<n;++i)
	{
		double temp=(double)s.top();
		s.pop();
		
		temp+=v[i];
		temp/=2;
		s.push(temp);
	}
	
	cout<<setprecision(8)<<s.top();

}
	
	






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

int main(){
  int N; cin >> N;
  vector<string> S(N);
  rep(i,N){
    cin >> S[i];
  }
  sort(S.begin(),S.end());
  int count,ans;
  count = 0;
  ans = 0;
  rep(i,N-1){
    if(S[i] == S[i+1]){
      count++;
      ans = max(count , ans);
    }
    else{
      
      count = 0;
    }
  }
    count = 0;
    rep(i,N-1){
    if(S[i] == S[i+1]){
      count++;
     // cout << count << endl;
      if(count == ans){
        cout << S[i] << endl;
      }
    }
    else{
      count = 0;
    }
  }
  if(ans == 0){
    rep(i,N){
      cout << S[i] << endl;
    }
  }
}

Measured memory_bytes: 14208
import itertools
H, W, K = map(int, input().split())

base = []
for _ in range(H):
    cs = list(input())
    base.append(cs)

ans = 0
for i in range(H+1):
    for j in range(W+1):
        for a in itertools.combinations(list(range(H)), i):
            for b in itertools.combinations(list(range(W)), j):
                count = 0
                for n in a:
                    for m in b:
                        if base[n][m] == "#":
                            count += 1
                        else:
                            pass
                if count == K:
                    ans += 1
print(ans)

Measured memory_bytes: 9140
#include <stdio.h>

#define MAX 2000001
#define VMAX 10000

void CountingSort();

int MAX1[MAX],MAX2[MAX];
int MAX3[VMAX+1];


int main()
{
  int a,i;

  scanf("%d", &a);

  for (i=1;i<=a;i++){
    scanf("%d",&MAX1[i]);
  }
    CountingSort(VMAX,a);

    for(i = 1; i<=a; i++){
    if ( i > 1 ) printf(" ");
    printf("%d", MAX2[i]);
  }
    printf("\n");

    return 0;
}


void CountingSort(int a,int b)
{
  int i,j;

  for (i=0;i<=a;i++){
    MAX3[i] = 0;
  }
  
  //C[i]に iの出現数を記録する
  for (j=1;j<=b;j++){
    MAX3[MAX1[j]]++;
  }

  //C[i]に i以下の数の出現数を記録する
  for (i=1;i<=a;i++){
    MAX3[i]=MAX3[i]+MAX3[i-1];
  }
  
  for (j=b;j>0;j--){
    MAX2[MAX3[MAX1[j]]] = MAX1[j];
    MAX3[MAX1[j]]--;
  }
}



Measured memory_bytes: 17368
import heapq

n,m=map(int,input().split())
l=sorted([list(map(int,input().split())) for i in range(n)])

hp=[]
ans=0
d=0
for i in range(1,m+1):
    while d<n:
        if l[d][0]<=i:
            heapq.heappush(hp,-l[d][1])
            d+=1
        else:
            break
    if hp!=[]:
         ans+=-heapq.heappop(hp)
print(ans)

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

#define fi first
#define se second

const int N = 111100;
const int MAGIC = 1000;
const long long mod = 998244353;

using namespace std;

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        int n;
        cin >> n;
        cout << (n - 2) * 180 << "\n";
}


Measured memory_bytes: 764
// !Start && !End 
//  0 se divide
//https: //www.youtube.com/watch?v=6Nb-prB-4P0&list=RD6Nb-prB-4P0&start_radio=1

// https: //www.youtube.com/watch?v=eYDI8b5Nn5s
// Electrify my OOOoooooOOOoooOOOOOoooooOOOooo!
#pragma optimise GCC(-O2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(int a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define forstl(i,v) for(auto &i: v)
#define ln endl
#define Endl endl
#define dbg(x) cout<<#x<<" = "<<x<<ln;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<ln;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it<<ln;} cout<<ln;
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cout<<ln;
#define dbgarr(v,s,e) cout<<#v<<" = "; f(i,s,e) cout<<v[i]<<", "; cout<<ln;
#define addEdge(tr,k) f(i,0,k) { ll x,y; cin>>x>>y, tr[x].push_back(y), tr[y].push_back(x);}
#define all(v) v.begin(),v.end()

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }

//														GLOBAL VARS
ll INF =LLONG_MAX;
const ll M= 1000000007;

//														USEFUL FUNCTIONS
ll powm(ll ,ll);

// 														MAIN
int main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    //It gets easier day by day, but the hard part is to........
    read(n)
    readarr(a,n)
    read(m)
    ll su = 0;
    f(i,0,n) su += a[i];
    while(m--)
    {
        read(p) read(t)
        p--;
        cout<< su - a[p] +t<<endl;

    }
}










//													FUNCTIONS DECLARATIONS
ll powm(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%M;
		a=(a*a)%M;
		b>>=1;
	}
	return res;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B=MI()
    for i in range(100000):
        if(int(i*0.08)==A and int(i*0.1)==B):
            print(i)
            return
    print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 66156
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int h, w;
    cin >> h >> w;
    string s;
    vector<string> v(h);
    for (int i = 0; i < h; i++) {
        cin >> s;
        v[i] = s;
    }
    int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1};
    int dy[8] = {1, -1, 0, -1, 1, 0, 1, -1};
    int x, y, cnt;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cnt = 0;
            if (v[i][j] != '#') {
                for (int k = 0; k < 8; k++) {
                    x = j + dx[k];
                    y = i + dy[k];
                    if (x >= 0 && x < w && y >= 0 && y < h) {
                        if (v[y][x] == '#') {
                            cnt++;
                        }
                    }
                }
                v[i][j] = cnt + '0';
            }
        }
    }
    for (int i = 0; i < h; i++) {
        cout << v[i] << endl;
    }
    return 0;
}


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

int main(void){
	int i,j,k,z;
	int n=0;
	int count = 0;

	char s[100];
	scanf("%s", &s);
	while (s[n]!='\0'){
		n++;
	}
	if (n % 2 == 0) {
		j = n / 2;
		z = j - 1;
	}
	else {
		j = (n / 2) + 1;
		z = j - 2;
	}
	for (i = 0; i <= z; i++) {
		if (s[i] != s[n-1-i]) {
			count++;
		}
	}
	//printf("n=%d\nj=%d\nz=%d\n", n, j, z);
	printf("%d\n", count);
	return 0;
}


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

set<vector<long long> >done;

vector<long long> getvec(long long a, long long b, long long c){
	vector<long long>vec;
	vec.push_back(a);
	vec.push_back(b);
	vec.push_back(c);
	sort(vec.begin(), vec.end());
	return vec;
}

int main(){
	long long a, b, c;
	cin >> a >> b >> c;
	if(a%2 == 1 || b % 2 == 1 || c%2 == 1){
		cout << 0 << endl;
		return 0;
	}

	done.insert(getvec(a, b, c));
	for(long long i = 1; i >= 0; i++){
		long long tmpa = a/2;
		long long tmpb = b/2;
		long long tmpc = c/2;
		a = tmpb + tmpc;
		b = tmpa + tmpc;
		c = tmpa + tmpb;
		if(a%2 == 1 || b % 2 == 1 || c%2 == 1){
			cout << i << endl;
			return 0;
		}
		if(done.count(getvec(a, b, c)) == 1){
			cout << -1 << endl;
			return 0;
		}
		done.insert(getvec(a, b, c));
	}
}


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

template <typename T,typename E>
struct SegmentTree{
private:
    typedef std::function<T(T,T)> F;
    typedef std::function<T(T,E)> G;
    int n;
    std::vector<T> init;
    F f;//function for merge
    G g;//function for update
    std::vector<T> node;

public:
    explicit SegmentTree(
            int sz,
            F cal,
            G upd,
            std::vector<T> initv=std::vector<T>(1,std::numeric_limits<T>::max())
    ){
        n=1;
        init=initv;
        f=cal;
        g=upd;
        while(n<sz)n=n*2;
        node.resize(static_cast<unsigned int>(2 * n - 1), init[0]);
        for (int i = 0; i <sz ; ++i) node[i+n-1]=init[0];
        for (int i = n-2; i >= 0 ; --i) node[i]=f(node[2*i+1],node[2*i+2]);
    }

    void update(int x, E val){//x:0-indexed
        x+=n-1;
        node[x]=g(node[x],val);
        while(x>0){
            x=(x-1)/2;
            node[x]=f(node[2*x+1],node[2*x+2]);
        }
    }

    T query(int p,int q,int k=0,int l=0,int r=-1){//[p,q):0-indexed
        if(r<0)r=n;
        if(r<=p||l>=q)return init[0];//out of range
        if(p<=l&&r<=q)return node[k];

        return f(query(p,q,2*k+1,l,(l+r)/2),query(p,q,2*k+2,(l+r)/2,r));
    }
};

int main(){
    int n;
    std::cin>>n;
    std::vector<int> a(n);
    std::vector<int> pos(n);
    SegmentTree<int,int> st(n+1,[](int a,int b){return std::min(a,b);},[](int a,int b){return b;});
    for (int i = 0; i < n; ++i) {
        std::cin>>a[i];
        --a[i];
        st.update(i,a[i]);
        pos[a[i]]=i;
    }

    std::vector<long long> llesslen(n,-1);
    std::vector<long long> rlesslen(n,-1);

    for (int i = 0; i < n; ++i) {
        int ok=0,ng=pos[i]+1;
        int mid=(ok+ng)/2;
        while(ng-ok!=1){
            int t=st.query(pos[i]-mid,pos[i]+1);
            if(t==i)ok=mid;
            else ng=mid;
            mid=(ok+ng)/2;
        }
        llesslen[i]=mid;

        ok=0;ng=n-1-pos[i]+1;mid=(ok+ng)/2;
        while(ng-ok!=1){
            if(st.query(pos[i],pos[i]+mid+1)==i)ok=mid;
            else ng=mid;
            mid=(ok+ng)/2;
        }
        rlesslen[i]=mid;
    }

    long long ans=0;
    for (int i = 0; i < n; ++i) {
        ans+=(llesslen[i]+1)*(rlesslen[i]+1)*(i+1);
    }
    std::cout<<ans<<std::endl;
    return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c,d,e;
  cin>>a>>b;
  c=max(a,b);
  d=min(a,b);
  e=c+d;
  if(e%2==0)cout<<(c+d)/2;
  else cout<<"IMPOSSIBLE";
}

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

int main(){
	vector<int> s(3);
  for(int i = 0; i < 3; ++i){
  	cin >> s[i];
  }
  sort(s.begin(), s.end());
  cout << (s[2] - s[1]) + (s[1] - s[0]) << endl;

}

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

#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)

using ll = long long;
#define INF 1e9

int main(){
  ll N;
  cin >> N;
  ll ans = 0;
  for(ll i = 1; i*i <= N; i++){
    if(N % i != 0 ) continue;
    ll x = i-1;
    if(x != 0 && N/x == N%x){
      ans += x;
    }
    x = N/i -1;
    if(x != 0 && N/x == N%x){
      ans += x;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools
n = int(input())

answers = []
for i in range(n):
	a = int(input())
	answers.append((i, []))
	for j in range(a):
		(x, y) = [int(k) for k in input().split()]
		answers[i][1].append((x, y))

lst = []
combi_lst = [i for i in range(n)]
for i in range(n, -1, -1):
	for balls in itertools.combinations(combi_lst, i):
		lst = [True if j in balls else False for j in range(n)]
		success = True
		for i, ans in enumerate(answers):
			if lst[i] == False:
				continue
			for x, y in ans[1]:
				if y == 1 and lst[x - 1] == False:
					success = False
				if y == 0 and lst[x - 1] == True:
					success = False
		if success:
			print(sum(lst))
			exit()

Measured memory_bytes: 9092
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int q;
ll p3[35];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int q;
    cin >> q;
    p3[0] = 1;
    FOR(i,1,30) p3[i] = p3[i-1] * 3;
    while (q--) {
        ll X1, Y1, X2, Y2;
        cin >> X1 >> Y1 >> X2 >> Y2;
        X1--; X2--; Y1--; Y2--;
        ll res = abs(X1 - X2) + abs(Y1 - Y2);
        FORE(i,29,0) {
            ll x1 = X1 / p3[i];
            ll y1 = Y1 / p3[i];
            ll x2 = X2 / p3[i];
            ll y2 = Y2 / p3[i];
            if (x1 == x2 && x1 % 3 == 1 && abs(y1 - y2) >= 2) {
                res = abs(Y1 - Y2) + min(X1 % p3[i] + 1 + X2 % p3[i] + 1, p3[i] - X1 % p3[i] + p3[i] - X2 % p3[i]);
                break;
            }
            if (y1 == y2 && y1 % 3 == 1 && abs(x1 - x2) >= 2) {
                res = abs(X1 - X2) + min(Y1 % p3[i] + 1 + Y2 % p3[i] + 1, p3[i] - Y1 % p3[i] + p3[i] - Y2 % p3[i]);
                break;
            }
        }
        cout << res << "\n";
    }
    return 0;
}


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

int main(){
  int N,Alice=0,Bob=0;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  sort(a.begin(), a.end(), greater< int >());

  for(int i=0;i<N;i++){
    if(i%2==0)
      Alice+=a.at(i);
    else
      Bob+=a.at(i);
  }
  cout<<Alice-Bob<<endl;
}


Measured memory_bytes: 256