akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
const int inf = 1e9;

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

struct edge{
	int to, cost;
	edge(){}
	edge(int a, int b){
		to = a, cost = b;
	}
};

int A, B;
int d[15][15];
int f[105][105];
vector<edge> G[305];
int dist[305];
int S, T;

void dijkstra(int x, int y)
{
	for(int i = 1; i <= T; i++) dist[i] = inf;
	
	priority_queue< P, vector<P>, greater<P> > Q;
	dist[S] = 0;
	Q.push(make_pair(0, S));
	
	int v, d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			int c = G[v][i].cost;
			if(G[v][i].cost == -1) c = x;
			if(G[v][i].cost == -2) c = y;
			if(dist[G[v][i].to] > d + c){
				dist[G[v][i].to] = d + c;
				Q.push(make_pair(dist[G[v][i].to], G[v][i].to));
			}
		}
	}
}

int main(void)
{
	cin >> A >> B;
	for(int x = 1; x <= A; x++){
		for(int y = 1; y <= B; y++){
			cin >> d[x][y];
		}
	}
	
	for(int a = 0; a <= 100; a++){
		for(int b = 0; b <= 100; b++){
			int val = 0;
			for(int x = 1; x <= A; x++){
				for(int y = 1; y <= B; y++){
					val = max(val, d[x][y] - a*x - b*y);
				}
			}
			f[a][b] = val;
		}
	}
	
	/*for(int a = 0; a <= 2; a++){
		for(int b = 0; b <= 2; b++){
			cout << f[a][b] << " ";
		}
		cout << endl; 
	}*/
	
	S = 201, T = 202;
	G[S].push_back(edge(1, -1)), G[101].push_back(edge(T, -2));
	for(int i = 1; i < 100; i++) G[i].push_back(edge(i+1, -1));
	for(int i = 200; i > 101; i--) G[i].push_back(edge(i-1, -2));
	for(int a = 0; a <= 100; a++){
		for(int b = 0; b <= 100; b++){
			int s = a, t = b+100;
			if(s == 0) s = S;
			if(t == 100) t = T;
			G[s].push_back(edge(t, f[a][b]));
		}
	}
	
	for(int x = 1; x <= A; x++){
		for(int y = 1; y <= B; y++){
			dijkstra(x, y);
			if(dist[T] != d[x][y]){
				cout << "Impossible" << endl;
				return 0;
			}
		}
	}
	
	cout << "Possible" << endl;
	cout << 202 << " " << 200+101*101 << endl;
	for(int i = 1; i <= T; i++){
		for(int j = 0; j < G[i].size(); j++){
			cout << i << " " << G[i][j].to << " ";
			if(G[i][j].cost == -1) cout << "X" << endl;
			else if(G[i][j].cost == -2) cout << "Y" << endl;
			else cout << G[i][j].cost << endl;
		}
	}
	cout << S << " " << T << endl;
	return 0;
}

Measured memory_bytes: 512
N, K = map(int, input().split())
A = input().split()
count = 0
if N == K:
    print(1)
else:
    count += 1
    rem = N-K
    add = 1 if (N-K)%(K-1) else 0
    count += (N-K)//(K-1) + add
    print(count)

Measured memory_bytes: 10420
N=int(input())
dic={"M":0,"A":1,"R":2,"C":3,"H":4}
S=[0,0,0,0,0]

for i in range(N):
    si=str(input())
    if si[0] in dic:
        S[dic[si[0]]]+=1
result=S[0]*S[1]*S[2]+S[0]*S[1]*S[3]+S[0]*S[1]*S[4]+S[0]*S[2]*S[3]+S[0]*S[2]*S[4]+S[0]*S[3]*S[4]+\
    S[1]*S[2]*S[3]+S[1]*S[2]*S[4]+S[1]*S[3]*S[4]+S[2]*S[3]*S[4]

print(result)

Measured memory_bytes: 3064
s = gets.chomp.split('').map(&:to_i)
MOD = 2019

s.reverse!

mods = Array.new(MOD, 0)

k = 1
memo = 0
s.each do |ss|
  sss = memo + ss * k
  mod = sss % MOD
  mods[mod] += 1
  memo = mod
  k = (k * 10) % MOD
end

p mods[0] + mods.inject(0) {|result, mod| result + (mod * (mod-1)) / 2}


Measured memory_bytes: 26528
#include<iostream>
#define INF 1000000000
using namespace std;

int cnt = 0;
void merge(int a[], int left, int mid, int right);
void mergeSort(int a[], int left, int right);

int main() {
	int i, n, a[500001];
	cin >> n;
	for (i = 0; i < n; i++)cin >> a[i];
	mergeSort(a, 0, n);
	for (i = 0; i < n; i++) {
		cout << a[i];
		if (i != n - 1)cout << " ";
	}
	cout << endl << cnt << endl;
	return 0;
}

void merge(int a[], int left, int mid, int right) {
	int i, j, k, n1, n2, l[250001], r[250001];
	n1 = mid - left;
	n2 = right - mid;
	for (i = 0; i < n1; i++) {
		l[i] = a[left + i];
	}
	for (i = 0; i < n2; i++) {
		r[i] = a[mid + i];
	}
	l[n1] = INF;
	r[n2] = INF;
	i = 0;
	j = 0;
	for (k = left; k < right; k++) {
		if (l[i] <= r[j]) {
			a[k] = l[i];
			i++;
			cnt++;
		} else {
			a[k] = r[j];
			j++;
			cnt++;
		}
	}
}

void mergeSort(int a[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(a, left, mid);
		mergeSort(a, mid, right);
		merge(a, left, mid, right);
	}
}

Measured memory_bytes: 6992
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  ll h, w; cin >> h >> w;

  if (h == 1 || w == 1) outl(1);
  else if (w % 2 == 0) outl(h * w / 2);
  else {
    ll d = (h + 1) / 2;
    ll e = h - d;
    outl(d * ((w + 1) / 2) + e * ((w - 1) / 2));
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    var (A, B, K) = readInputLine().split(" ").map { it.toLong() }

    if (A <= K) {
        val tmp = A
        A = 0L
        K -= tmp
    } else {
        A -= K
        K = 0L
    }

    if (B <= K) {
        val tmp = B
        B = 0L
        K -= tmp
    } else {
        B -= K
        K = 0L
    }

    println("$A $B")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37868
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int n,ans = 0;
    cin >> n;
    vector<int> a(n),b(n),c(n-1);
    for(int i = 0;i < n; ++i){
        cin >> a[i];
        a[i] --;
    } 
    for(int i = 0;i < n; ++i){
        cin >> b[i];
    }
    for(int i = 0;i < n-1; ++i) cin >> c[i];
    for(int i = 0;i < n; ++i){
        ans += b[a[i]];
        if(i && a[i] == a[i - 1] + 1){
            ans += c[a[i-1]];
        }
    }
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  lli A,B,N;
  cin >> A >> B >> N;
  if(N<B-1){
  cout << N*A/B << endl;
  } 
  else
  {
  cout << (B-1)*A/B << endl;
  }
}

Measured memory_bytes: 3632
import java.util.Scanner;

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

        int n = sc.nextInt();
        boolean no = false;
        for (int i = 0; i < n; i++) {
            int s = sc.nextInt();
            if (s % 2 == 0) {
                if (s % 5 != 0 && s % 3 != 0) {
                    no = true;
                }
            }
        }
        if (no)
            System.out.println("DENIED");
        else
            System.out.println("APPROVED");
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int answer = 1000000000;
	for(int i = 0; i <= max(x, y); ++i){
		const int xx = max(0, x - i);
		const int yy = max(0, y - i);
		int sum = (c + c) * i;
		sum += xx * a;
		sum += yy * b;
		answer = min(answer, sum);
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int x, y; cin >> x >> y;

    ll p[3] = {300000, 200000, 100000};

    ll ans = 0;
    if(x <= 3){
        ans += p[x-1];
    }
    if(y <= 3){
        ans += p[y-1];
    }

    if(x == 1 && y == 1){
        ans += 400000;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n'&&c!=EOF;)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

using P = complex<double>;

int main() {
	vector<P> v((int) in), t;
	for (P &i: v) {
		int x {in}, y {in};
		i = P(x, y);
	}
	sort(begin(v), end(v), [](P a, P b) {return imag(a) == imag(b) ? real(a) < real(b) : imag(a) < imag(b);});
	auto f {[&](auto i, auto e, size_t s) {
		for (;i != e; i++) {
			while (t.size() > s && imag((t.back() - *(end(t) - 2)) * conj(*i - t.back())) > 0)
				t.pop_back();
			t.push_back(*i);
		}
	}};
	f(begin(v), end(v), 1);
	f(rbegin(v) + 1, rend(v), t.size());
	t.pop_back();
	outl(t.size());
	for (auto i: t)
		outl((int) real(i), ' ', (int) imag(i));
}


Measured memory_bytes: 5492
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream &operator << (ostream &os, const vector<T> &);
template<size_t n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, const tuple<T...> &){}
template<size_t n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream &os, const tuple<T...> &t){
    os << (n == 0 ? "" : " ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T> ostream &operator << (ostream &os, const tuple<T...> &t){
    _ot<0>(os, t); return os;
}
template<class T, class U> ostream & operator << (ostream &os, const pair<T,U> &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T> ostream &operator << (ostream &os, const vector<T> &v){
    for(size_t i = 0; i < v.size(); i++) os << v[i] << (i + 1 == v.size() ? "" : ", "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << make_tuple(__VA_ARGS__) \
                   << " (L : " << __LINE__ << ")" << endl)
#else
#define dump(...)
#endif
#define all(c) begin(c), end(c)
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using ll = long long;
// #define int ll
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
void fastios(){ ios_base::sync_with_stdio(0); cin.tie(0); }
int const mod = 1000000007;
auto const inf = numeric_limits<int>::max()/8;


using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

int chinesePostman(const Graph &g) {
    Weight total = 0;
    int n = g.size();
    vector<int> odds;
    static Weight dist[17][17];
    for(int i = 0; i < n; ++i){
        fill(dist[i], dist[i]+n, inf);
        for(auto &e : g[i]){
            int s = e.src, d = e.dst; Weight w = e.weight;
            total += w;
            dist[s][d] = min(dist[s][d], w);
        }
        if(g[i].size() % 2 == 1) odds.push_back(i);
    }
    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    static Weight dp[1<<17];
    int k = odds.size();
    fill(dp, dp+(1<<k), inf);
    dp[0] = 0;
    for(int S = 0; S < 1<<k; ++S){
        for(int i = 0; i < k; ++i){
            if(S >> i & 1) continue;
            for(int j = 0; j < i; j++){
                if(S >> j & 1) continue;
                dp[S|1<<i|1<<j] = min(dp[S|1<<i|1<<j], dp[S] + dist[odds[i]][odds[j]]);
            }
        }
    }
    return total/2 + dp[(1<<k)-1];
}

int main(){
    int n,m;
    while(cin >> n >> m){
        Graph g(n);
        rep(i,m){
            int a,b,c;
            cin >> a >> b >> c;
            g[a].eb(a,b,c);
            g[b].eb(b,a,c);
        }
        cout << chinesePostman(g) << endl;
    }
}

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

int main()
{
  int n,x,i;
  cin>>x>>n;
  if(n==0)
  {
     cout<<x<<'\n';
     return 0;
  }
  int a;
  vector<int>v;
  for(i=0;i<n;i++)
   {
       cin>>a;
       v.push_back(a);
   }
   int k=0,p=0,q=0;
  while(1)
  {
    p=x-k;
    q=x+k;

    auto it1=find(v.begin(),v.end(),p);
    if(it1==v.end())
    {
        cout<<p<<'\n';
        return 0;
    }
    auto it2=find(v.begin(),v.end(),q);
    if(it2==v.end())
    {
        cout<<q<<'\n';
        return 0;
    }
    k++;
  }
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> dp(k + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp[0] = 0;
  for (int i = 1; i <= k; i++) {
    int win = 0;
    for (int j = 0; j < n; j++) {
      if (i >= a[j]) {
        if (dp[i - a[j]] == 0) {
          win++;
        }
      }
    }
    if (win > 0) {
      dp[i] = 1;
    } else {
      dp[i] = 0;
    }
  }
  if (dp[k] == 1) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int N, Q;
char s[202020];
char t[202020];
char d[202020];
int f[202020];
int check(int p){
    for(int i = 0; i < Q; i++){
        if(s[p] == t[i]){
            if(d[i]=='L')p--;
            else p++;
        }
        if(p < 1)return 1;
        if(p > N)return 3;
    }
    return 2;
}

int main(){

    cin >> N >> Q;
    for(int i = 1; i <= N; i++)cin >> s[i];
    for(int i = 0; i < Q; i++)cin >> t[i] >> d[i];
    f[0] = 1;
    f[N+1] = 3;
    int notR = 0, R = N + 1;
    while(notR + 1 < R){
        int p = (notR + R) / 2;
        if(check(p) == 3)R = p;
        else notR = p;
    }
    int L = 0, notL = N + 1;
    while(L + 1 < notL){
        int p = (L + notL) / 2;
        if(check(p) == 1)L = p;
        else notL = p;
    }
    cout << max(0, notR - notL + 1) << endl;

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <math.h>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	vi a(3);
	rep(i, 3)cin >> a.at(i);
	sort(all(a));
	cout << a.at(0) + a.at(1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<string.h>
#include<math.h>

using namespace std;

bool check(string in){
    for(int i=0; i<3; i++){
        if(in[i*3]!='s'&&in[i*3]==in[i*3+1]&&in[i*3+2]==in[i*3+1]){
            cout<<in[i*3]<<endl;
            return 1;
        }
        if(in[i]!='s'&&in[i]==in[i+3]&&in[i+3]==in[i+6]){
            cout<<in[i]<<endl;
            return 1;
        }
    }
    if(in[0]!='s'&&in[0]==in[4]&&in[4]==in[8]){
        cout<<in[0]<<endl;
        return 1;
    }
    if(in[2]!='s'&&in[2]==in[4]&&in[4]==in[6]){
        cout<<in[2]<<endl;
        return 1;
    }
    cout<<"d"<<endl;
    return 1;
}

int main(){
    string in;
    while(cin>>in){
        check(in);
        
    }
}

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

int main() {
	string s;
	cin>> s;
	int a=0;
	for(int i=0;i<s.size();i++){
		for(int j=0;j<i;j++){
			if(s.at(i)==s.at(j)){
				a=1;
			}
		}
	}
	if(a==0){
		cout<<"yes"<<endl;
		
	}
	else{
		cout<<"no"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
// use std::str::FromStr;

// struct Scanner<R: Read> {
//     reader: R,
// }

// #[allow(dead_code)]
// impl<R: Read> Scanner<R> {
//     fn new(reader: R) -> Scanner<R> {
//         Scanner { reader: reader }
//     }

//     fn safe_read<T: FromStr>(&mut self) -> Option<T> {
//         let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
//             .skip_while(|c| c.is_whitespace())
//             .take_while(|c| !c.is_whitespace())
//             .collect::<String>();
//         if token.is_empty() {
//             None
//         } else {
//             token.parse::<T>().ok()
//         }
//     }

//     fn read<T: FromStr>(&mut self) -> T {
//         if let Some(s) = self.safe_read() {
//             s
//         } else {
//             writeln!(stderr(), "Terminated with EOF").unwrap();
//             std::process::exit(0);
//         }
//     }
// }

fn main() {
    // let cin = stdin();
    // let cin = cin.lock();
    // let mut sc = Scanner::new(cin);

    let s = stdin();
    let mut buf = BufReader::new(s.lock());
    let mut b: [u8; 2000] = [0; 2000];
    let len = buf.read(&mut b).unwrap();
    let ans: String = b[0..len].iter().map(|c| {
        let c = match *c {
            b'A'...b'Z' | b'a'...b'z' => c ^ 32,
            _ => *c,
        };
        c as char
    }).collect();
    print!("{}", ans);
}



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

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

  if (x <= 599) {
    cout << "8" << endl;
  }

  else if (x <= 799) {
    cout << "7" << endl;
  }

  else if (x <= 999) {
    cout << "6" << endl;
  } 
  
   else if (x <= 1199) {
    cout << "5" << endl;
  }
  
   else if (x <= 1399) {
    cout << "4" << endl;
  }
  
   else if ( x <= 1599) {
    cout << "3" << endl;
  }
  
   else if ( x <= 1799) {
    cout << "2" << endl;
  }
  
   else if (x <= 1999) {
    cout << "1" << endl;
  }

}

Measured memory_bytes: 3616
import sys
from heapq import heappush, heappop

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    Q = int(readline())

    hi = []
    lo = []
    hi_sum = lo_sum = 0
    b_sum = 0

    ans = []
    for _ in range(Q):
        A = list(map(int, readline().split()))
        if len(A) == 3:
            a, b = A[1], A[2]
            b_sum += b

            if not lo:
                lo.append(-a)
                lo_sum += a
            else:
                if a <= -lo[0]:
                    heappush(lo, -a)
                    lo_sum += a
                else:
                    heappush(hi, a)
                    hi_sum += a

            if len(hi) > len(lo):
                x = heappop(hi)
                hi_sum -= x
                heappush(lo, -x)
                lo_sum += x
            elif len(hi) + 1 < len(lo):
                x = -heappop(lo)
                lo_sum -= x
                heappush(hi, x)
                hi_sum += x
        else:
            x = -lo[0]
            val = x * (len(lo) - len(hi)) - lo_sum + hi_sum + b_sum
            ans.append((x, val))

    for x, val in ans:
        print(x, val)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 27964
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int h,w,n,a[10010];
int main(){
	std::cin>>h>>w>>n;
	REP(i,n)std::cin>>a[i];
	int cnt=1;
	rep(i,h){
		std::vector<int> vec;
		if(i%2==0){
			rep(j,w){
				vec.emplace_back(cnt);
				a[cnt]--;
				if(a[cnt]==0)cnt++;
			}
		}
		else{
			rep(j,w){
				vec.emplace_back(cnt);
				a[cnt]--;
				if(a[cnt]==0)cnt++;
			}
			std::reverse(all(vec));
		}
		printArray(vec);
	}
	return 0;
}


Measured memory_bytes: 3644
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		ArrayDeque<String> deque = new ArrayDeque<String>();
		StringBuilder sb = new StringBuilder();
		String s = sc.next();
		
		int q = Integer.parseInt(sc.next());
		int top = 1;
		deque.add(s);
		
		for(int i = 0 ;i < q ;i++) {
			int p = Integer.parseInt(sc.next());
			if(p == 1) {
				top *= -1;
			}
			else {
				int r = Integer.parseInt(sc.next());
				String c = sc.next();
				if(r == 1) {
					if(top > 0) {
						deque.addFirst(c);
					}
					else {
						deque.addLast(c);
					}
				}
				else {
					if(top > 0) {
						deque.addLast(c);
					}
					else {
						deque.addFirst(c);
					}
				}
			}
		}
	
		int m = deque.size();
			for(int i = 0 ;i < m ; i++) {
				sb.append(deque.pollFirst());
			}
		if(top < 0) { 
			sb.reverse();
			}
		
		System.out.println(sb.toString());
		
		
		
	}
}


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

int main(){
    int n;
    string s;
    cin>>n>>s;
    if(s[0]=='W'){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1;
    int cnt=1;
    for(int i=1;i<2*n;i++){
        int num;
        if(s[i]=='B')num=1;
        else num=0;
        num=(num+cnt)&1;
        if(num)cnt++;
        else{
            if(cnt==0){
                cout<<0<<endl;
                return 0;
            }
            ans=(ans*cnt)%MOD;
            cnt--;
        }
    }
    if(cnt!=0){
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<=n;i++){
        ans=(ans*i)%MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;
vector<pii> ta;

void input() {
  cin >> N;
  ta.resize(N);
  rep(i, 0, N - 1) { cin >> ta[i].first >> ta[i].second; }
}
void solve() {
  int now_A = 1, now_T = 1;

  for (auto x : ta) {
    int da = x.first;
    int dt = x.second;
    // while (now_A > x.first or now_T > x.second) {
    //   x.first += da;
    //   x.second += dt;
    // }
    now_A--, now_T--;
    int bai = max(now_A / x.first, now_T / x.second) + 1;
    x.first *= bai, x.second *= bai;
    now_A = x.first;
    now_T = x.second;
  };
  cout << now_A + now_T << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
//AOJ DSL_2_A
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
typedef long long ll;
//const ll INF = 10000000000;
//const ll MOD = 1000000007;

struct segtree {
    int size;
    vector<ll> node;
    
    segtree(int n) {
        size = 1;
        while (size<n) size *= 2;
        node.resize(2*size-1);
        //ここ単位元にする
        fill(node.begin(), node.end(), 2147483647);
    }
    
    //k番目(0-indexed)の値をaにする
    void update(int k, int a) {
        k += size-1;
        node[k] = a;
        while (k>0) {
            k = (k-1)/2;
            //ここ変える
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }
    
    ll query(int a, int b, int k, int l, int r) {
        //ここ単位元にする
        if (r<=a || b<=l) return 2147483647;
        if (a<=l && r<=b) return node[k];
        else {
            int vl = query(a, b, 2*k+1, l, (l+r)/2);
            int vr = query(a, b, 2*k+2, (l+r)/2, r);
            //ここ変える
            return min(vl, vr);
        }
    }
    
    //[a, b)に対するクエリ
    ll get(int a, int b) {
        return query(a, b, 0, 0, size);
    }
};

int main() {
    int n, q; cin >> n >> q;
    segtree st(n);
    
    rep(i, q) {
        int f; cin >> f;
        if (f==0) {
            int x, y; cin >> x >> y;
            st.update(x, y);
        }
        else {
            int x, y; cin >> x >> y;
            cout << st.get(x, y+1) << endl;
        }
    }
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  string s[n];
  rep(i, n) cin >> s[i];
  rep(i, n){
    cout << s[i] << endl << s[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;

int main() {
    int n; cin >> n;
    vector<int> vec(1000000);
    for(int i = 0;i < n;i++){
        int z; cin >> z;
        if(z == 0){
            vec.at(z)++;
            vec.at(z+1)++;
        }else{
            vec.at(z)++;
            vec.at(z-1)++;
            vec.at(z+1)++;
        }
    }
    sort(vec.begin(),vec.end(),greater<int>());
    cout << vec[0];
}



Measured memory_bytes: 4096
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d,in;
  cin>>in;
  a=(in-in%1000)/1000;
  b=(in-in%100)/100-a*10;
  c=(in-in%10)/10-b*10-a*100;
  d=in-c*10-b*100-a*1000;
  if(a+b+c+d==7)cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a+b+c-d==7)cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a+b-c+d==7)cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a-b+c+d==7)cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a+b-c-d==7)cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a-b+c-d==7)cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a-b-c+d==7)cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a-b-c-d==7)cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
S=input()
switch=0
temp=[0]
j=0
ans=[0]*(len(S))
for i in range(len(S)):
    if S[i]=="L" and switch==0:
        switch=1
        temp.append(i)
        j=j+1
        ans[i-1]=ans[i-1]+(i-1-temp[j-1])//2+1
        ans[i]=ans[i]+(i-temp[j-1])//2+1
    elif S[i]=="R" and switch==1:
        switch=0
        temp.append(i)
        j=j+1
        ans[temp[j-1]-1]=ans[temp[j-1]-1]+(i-1-(temp[j-1]-1))//2
        ans[temp[j-1]]=ans[temp[j-1]]+(i-1-temp[j-1])//2
if temp[j]!=len(S)-1:
    if (len(S)-1-temp[j])%2!=0:
        ans[temp[j]-1]=ans[temp[j]-1]+(len(S)-1-temp[j])//2+1
        ans[temp[j]]=ans[temp[j]]+(len(S)-1-temp[j])//2
    else:
        ans[temp[j]-1]=ans[temp[j]-1]+(len(S)-1-temp[j])//2
        ans[temp[j]]=ans[temp[j]]+(len(S)-1-temp[j])//2
print(" ".join([str(i) for i in ans]))

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

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

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

  int n; cin >> n;
  map<string,int> M;
  int grt = 0;
  for (int i = 0; i < n; ++i) {
    string s; cin >> s;
    M[s]++;
    grt = max(grt, M[s]);
  }

  for (auto i : M)
    if (i.se == grt)
      cout << i.fi << ende;

  return 0;
}


Measured memory_bytes: 23808
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		for(int i=0;i<N;++i){
			int x = sc.nextInt();
			while(x%2==0){
				x/=2;
				ans++;
			}
		}
		System.out.println(ans);
		return;
	}
}

Measured memory_bytes: 35876
a=list(input())
m=['A','C','G','T']
result=['']
for i in range(len(a)+1):
    for j in range(i):
        n=a[j:i]
        ans=0
        for k in range(len(n)):
            if n[k]=='A' or n[k]=='C' or n[k]=='G' or n[k]=='T':
                continue
            else:
                ans+=1
        if ans==0:
            result.append(n)
print(len(max(result,key=len)))    





Measured memory_bytes: 8820
'use strict';

function Main(input) {
    const N = parseInt(input.split("\n")[0], 10);
    const x = 800 * N;
    let y = 0;
    if (N >= 15) {
        y = Math.floor(N / 15) * 200;
    }
    console.log(x - y);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <stdio.h>

int main(void)
{
    int n;
    int a[4][13] = {0};
    char egara[5] = "SHCD";
    char c;
    int en;
    int rank;

    scanf("%d\n", &n);

    for ( int i = 0; i < n; i++ ) {
        scanf("%c %d\n", &c, &rank);
        switch ( c ) {
            case 'S':
                en = 0;
                break;
            case 'H':
                en = 1;
                break;
            case 'C':
                en = 2;
                break;
            case 'D':
                en = 3;
                break;
        }
        a[en][rank - 1] = 1;
    }

    for ( int i = 0; i < 4; i++ ) {
        for ( int j = 0; j < 13; j++ ) {
            if ( a[i][j] == 0 ) {
                printf("%c %d\n" ,egara[i], j + 1);
            }
        }
    }

    return 0;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
   string str;
   cin >> str;
   int count9 = count(str.begin(), str.end(), '9');
   if(count9 >= 1){
    cout << "Yes" << endl;
   }
   else{
    cout << "No" << endl;
   }
    return 0;
}


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

ab_sorted = sorted(ab, key = lambda x:x[0], reverse = True)
cd_sorted = sorted(cd, key = lambda x:x[0], reverse = True)


for i in range(len(ab_sorted)):
    candidate = -10e+10
    minimum_size = 10e+10
    for j in range(len(cd_sorted)):
        if cd_sorted[j][0] > ab_sorted[i][0] and cd_sorted[j][1] > ab_sorted[i][1] and minimum_size > cd_sorted[j][1]:
            candidate = j
            minimum_size = cd_sorted[j][1]
    if candidate != -10e+10:
        del cd_sorted[candidate]
print(len(ab_sorted) - len(cd_sorted))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int limit=120*60;
    
    int t,h,s;
    while(cin>>t>>h>>s && t!=-1){
        int tim=t*3600+h*60+s;
        int diff1=limit-tim;
        
        printf("%02d:%02d:%02d\n",diff1/3600,(diff1%3600)/60,diff1%60);
        int diff2=diff1*3.0;
        printf("%02d:%02d:%02d\n",diff2/3600,(diff2%3600)/60,diff2%60);
    }
    
    return 0;
}



Measured memory_bytes: 3132
S = input()
N = len(S)


i = 0
ans = 0
pre_s = ''
while i < N:
    if pre_s != S[i]:
        pre_s = S[i]
        i += 1
    elif i + 1 < N:
        pre_s = S[i: i + 2]
        i += 2
    else:
        i += 1
        ans -= 1

    ans += 1

print(ans)

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;

    Scd(N);
    vl a(N);
    ll to = 0; ll tt = 0;
    Rep(i,N) Scll(a[i]), to += a[i];

    ll ans = to;
    tt = a[0];
    Repe(i,N,1){
        ans = min( ans, abs(to-tt*2) );
        tt += a[i];
    }

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

    return 0;
}





Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include <utility>      // std::swap
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 200000000000;


    ll W,H,N,M;
    ll sum=0;
    ll A[300000];
    ll back=0;
    bool f=false;
    ll ans=INF;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        sum+=A[i];
    }
    for(int i=N-1;0<i;i--){
        sum-=A[i];
        back+=A[i];
        ans=min(abs(sum-back),ans);
    }
    cout<<ans;
    return 0;
}
//https://youtu.be/m0uWO0ngzbs?t=14m14s


Measured memory_bytes: 1792
N=int(input())
AB=[]


for i in range(N):
    a,b=map(int,input().split())
    AB.append([b,a])
AB.sort()

for i in range(N-1):
    AB[i+1][1]+=AB[i][1]

for i in range(N):
    if AB[i][1]>AB[i][0]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 36388
# -*- coding: utf-8 -*-
from pprint import pprint
import itertools

N, K = map(int, input().split())
an = list(map(int, input().split()))

rui = [0]
tmp = 0
for a in an:
    rui.append(tmp+a)
    tmp += a

sum_list = [] 

for l in range(1,N+1):
    for r in range(l,N+1):
        tmp = rui[r] - rui[l-1]
        sum_list.append(tmp)

max_val = max(sum_list)
max_2pow = len(bin(max_val)[2:])
ans = 0
# print(ans,max_2pow)
while max_2pow > 0:
    tmp = ans + 2**(max_2pow-1)
    if sum([1 for v in sum_list if v & tmp == tmp]) >= K:
        ans += 2**(max_2pow-1)
    max_2pow -= 1

print(ans)


Measured memory_bytes: 25684
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let a: i64 = sc.read();
    let b: i64 = sc.read();
    let n: i64 = sc.read();

    println!("{}", f(std::cmp::min(b - 1, n), a, b));
}

fn f(x: i64, a: i64, b: i64) -> i64 {
    a * x / b - a * (x / b)
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 2124
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	long long n,m,k;
	cin>>n>>m>>k;
	vector<long long>a(n+1,0),b(m+1,0);
	for(int i=1;i<n+1;++i){
		long long t;
		cin>>t;
		a[i]=a[i-1]+t;
	}
	for(int i=1;i<m+1;++i){
		long long t;
		cin>>t;
		b[i]=b[i-1]+t;
	}
	if(k>=a[n]+b[m]){
		cout<<n+m<<endl;
		return 0;
	}
	a.push_back(a[n]+k);
	b.push_back(b[m]+k);
	int ai=upper_bound(a.begin(),a.end(),k)-a.begin()-1;
	int bi=upper_bound(b.begin(),b.end(),k-a[ai])-b.begin()-1;
	int u=ai+bi;
	while(ai>0){
		--ai;
		bi=upper_bound(b.begin(),b.end(),k-a[ai])-b.begin()-1;
		u=max(u,ai+bi);
	}
	cout<<u<<endl;
	return 0;
}

Measured memory_bytes: 7532
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	string s;
	cin >> s;
	
	string t = s;
	reverse(t.begin(),t.end());
	
	int cnt = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != t[i]){
			cnt++;
		}
	}
	cout << cnt/2 << endl;

	return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int m=0;
    for(int i=0;i<n;i++){
      int a=sc.nextInt();
      m+=Math.min(a,k-a);
    }
    System.out.println(m+m);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	string S;
	int K;
	cin >> S >> K;
	int N =S.length();
	for(int i =0; i < N; i++) {
		int minc =S[i]-'a';
		for(int j =0; j <= min(26,K); j++) minc =min(minc,(S[i]-'a'+j)%26);
		int op =(minc+26*3-(S[i]-'a'))%26;
		K -=op;
		S[i] ='a'+minc;
	}
	int x =(S[N-1]-'a'+K)%26;
	S[N-1] =x+'a';
	cout << S << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    set<string> Set;
    int n; cin >> n;
    int cnt = 0;
    rep (i, n) {
        string s; cin >> s;
        // cout << (Set.find(s) == Set.end()) << endl;
        if (Set.find(s) == Set.end()) {
            cnt++;
            Set.insert(s);
        } 
    } 
    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 19120
#include <stdio.h>

int a[55];
int b[55];
int c[55];
int d[55];

int max(int a,int b);

int main() {

	int N, M;

	scanf("%d %d",&N,&M);

	int i,j;

	for (i = 0; i < N; i++) {
		scanf("%d %d",&a[i],&b[i]);
	}
	for (i = 0; i < M; i++) {
		scanf("%d %d", &c[i], &d[i]);
	}

	for (i = 0; i < N; i++) {
		int ma = 1000000000;
		int ans = -1;
		for (j = 0; j < M; j++) {
			if (ma > max(a[i] - c[j], c[j] - a[i]) + max(b[i] - d[j], d[j] - b[i])) {
				ma = max(a[i] - c[j], c[j] - a[i]) + max(b[i] - d[j], d[j] - b[i]);
				ans = j + 1;
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}
int max(int a, int b) {
	if (a >= b) { return a; }
	else { return b; }
}

Measured memory_bytes: 128
#include <stdio.h>
#define N 10000
int main()
{
  int mat[N];
  int i,x,count;

  count=0;

  for(i=0;i<N;i++)
  {
    scanf("%d",&x);
    if(x==0) {
      break;
    }
    mat[i]=x;
    count++;
  }

  for(i=0;i<count;i++)
  {
    printf("Case %d: %d\n",i+1,mat[i]);
  }

  return 0;
}

Measured memory_bytes: 632
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

class Enumeration {
public:
  explicit Enumeration(int n, uint64_t mod)
    : mod(mod), fact(n), inv(n), finv(n) {
    fact[0] = finv[0] = inv[1] = 1;
    for (int i = 2; i < n; ++i) inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    for (int i = 1; i < n; ++i) {
      fact[i] = fact[i - 1] * i % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }
  uint64_t operator()(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return fact[n] * finv[n - k] % mod * finv[k] % mod;
  }
  uint64_t modpow(uint64_t x, uint64_t e) {
    uint64_t res = 1;
    while (e > 0) {
      if (e & 1) res = res * x % mod;
      x = x * x % mod;
      e >>= 1;
    }
    return res;
  }

private:
  uint64_t mod;
  vector<uint64_t> fact, inv, finv;
};

constexpr ll MOD = 1000000007;

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

  unordered_map<int, int> mp;
  for (int i = 2; i * i <= m; ++i) {
    while (m % i == 0) {
      m /= i;
      ++mp[i];
    }
  }
  if (m != 1) ++mp[m];

  Enumeration c(n + 32, MOD);
  ll ans = 1;
  for (auto p : mp) ans = ans * c(n - 1 + p.second, n - 1) % MOD;

  cout << ans << '\n';
  return 0;
}

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

int S(int n){
	int cur=1e9;
	int num=0;
	int sum=0;
	while(cur>=1){
		if(n-cur<0){
			cur/=10;
			sum+=num;
			num=0;
			continue;
		}
		n-=cur;
		num++;
	}
	return sum;
}

int main(){
	int n;
	cin >> n;
	bool flag = false;
	if(n%S(n)==0) flag = true;
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256