akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-funroll-loops")
#pragma GCC target("avx,sse4")
 
#define mms(a,n) memset(a,0,sizeof((a)[0])*(n))
#define mmp(a,b,n) memcpy(a,b,sizeof((b)[0])*(n))
#define lowbit(x) ((x)&-(x))
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++)
#define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--)
#define fos(i,l,r,d) for(register int i=l,_lim_=r;i<=r;i+=d)
#define fol(i,l,r) for(register ll i=l,_lim_=r;i<=_lim_;i++)
#define fdl(i,r,l) for(register ll i=r,_lim_=l;i>=_lim_;i--)
#define fosl(i,l,r,d) for(register ll i=l,_lim_=r;i<=r;i+=d)
#define Clear(a) memset(a,0,sizeof(a))
#define Copy(a,b) memcpy(a,b,sizeof(b))
#define ALL(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())

using namespace std;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ldb;
typedef double db;
typedef pair<int,int> pi;
typedef vector<int> VI;
typedef vector<VI> VII;

const int N=16666,P=998244353;

struct Div{
	ull m,x;
	int s;
	Div(){}
	Div(ull mo):m(mo){
		s=__lg(mo-1);
		x=((__uint128_t(1)<<(s+64))+m-1)/m;
	}
	friend ull operator/(ull a,Div d){
		return ((__uint128_t(a)*d.x)>>d.s)>>64;
	}
	friend ull operator%(ull a,Div d){
		return a-a/d*d.m;
	}
}mod(P);

uint fpow(uint a,int t){
	uint r(1);
	for(;t;t>>=1,a=(ull)a*a%mod)if(t&1)r=(ull)r*a%mod;
	return r;
}

int n,m,k;
uint fac[N],ifac[N],inv[N],tx[N],ty[N],tz[N],dp[N],ret;
uint *ww[20],*iww[20],pol[N<<2],*pl=pol;
void init(int n){
	int i,p,l;uint w;
	for(l=2,p=0;l<=n;l<<=1,p++){
		ww[p]=pl;w=fpow(3,(P-1)/l);
		for(i=*pl=1;i<l>>1;i++)pl[i]=(ull)pl[i-1]*w%mod;pl+=l>>1;
		iww[p]=pl;w=fpow(w,P-2);
		for(i=*pl=1;i<l>>1;i++)pl[i]=(ull)pl[i-1]*w%mod;pl+=l>>1;
	}
}
void fft(uint a[],int n,int dft){
	int i,j,k,l,p;uint t,*w;
	for(i=1,j=n>>1;i<n-1;i++){
		if(i<j)swap(a[i],a[j]);
		for(k=n>>1;(j^=k)<k;k>>=1);
	}
	for(l=2,p=0;l<=n;l<<=1,p++){
		w=dft==1?ww[p]:iww[p];
		for(j=0,i=l>>1;j<n;j+=l)for(k=0;k<i;k++){
			uint&y=a[j+k];
			t=(ull)a[j+k+i]*w[k]%mod;
			(a[j+k+i]=y+P-t)<P?:a[j+k+i]-=P; 
			(y+=t)<P?:y-=P;
		}
	}
	if(dft==-1)for(i=0,t=fpow(n,P-2);i<n;i++)a[i]=(ull)a[i]*t%mod;
}

uint C(int n,int m){
	if(n<m)return 0;
	return (ull)fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
 
int main(){
	scanf("%d%d",&n,&m);
	fac[0]=fac[1]=ifac[0]=ifac[1]=inv[1]=1;
	fo(i,2,(n<<1)+2){
		fac[i]=(ull)fac[i-1]*i%mod;
		inv[i]=P-(ull)(P/i)*inv[P%i]%mod;
		ifac[i]=(ull)ifac[i-1]*inv[i]%mod;
	}
	dp[0]=1;
	for(k=1;k<=n<<1;k<<=1);
	init(k);
	fo(i,1,m){
		mms(tx,k);mms(ty,k);
		fo(j,0,n)tx[j]=(ull)dp[j]*ifac[j]%mod;
		fo(j,1,n)ty[j]=ifac[j+2];
		fft(tx,k,1);fft(ty,k,1);
		fo(j,0,k-1)tz[j]=(ull)tx[j]*ty[j]%mod;
		fft(tz,k,-1);
		fo(j,0,k-1)dp[j]=((ull)dp[j]*((j+1)*j/2+1)+(ull)tz[j]*fac[j+2])%mod;
	}
	fo(i,0,n)ret=(ret+(ll)dp[i]*C(n,i))%mod;
	printf("%u\n",ret);
	return 0;
}

Measured memory_bytes: 896
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << (x) << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
const ll inf = 1e18;
struct Segment {
  int n;
  pair<ll,int> mn[N << 2];
  ll add[N << 2];
  void Add(int c,int l,int r,int L,int R,ll x) {
    if(L <= l && r <= R) {
      add[c] += x;
      mn[c].fi += x;
    } else {
      int m = (l + r) >> 1;
      if(L <= m) Add(c << 1 , l , m , L , R , x);
      if(R > m) Add(c << 1 | 1 , m + 1 , r , L , R , x);
      mn[c] = min(mn[c << 1] , mn[c << 1 | 1]);
      mn[c].fi += add[c];
    }
  }
  pair<ll,int> Query(int c,int l,int r,int L,int R) {
    if(L <= l && r <= R) {
      return mn[c];
    } else {
      int m = (l + r) >> 1;
      pair<ll,int> res(inf,-1);
      if(L <= m) res = min(res , Query(c << 1 , l , m , L , R));
      if(R > m) res = min(res , Query(c << 1 | 1 , m + 1 , r , L , R));
      res.fi += add[c];
      return res;
    }
  }
  void Build(int c,int l,int r) {
    add[c] = 0;
    if(l == r) {
      mn[c] = mp(0 , l);
    } else {
      int m = (l + r) >> 1;
      Build(c << 1 , l , m);
      Build(c << 1 | 1 , m + 1 , r);
      mn[c] = min(mn[c << 1] , mn[c << 1 | 1]);
    }
  }
  void Add(int L,int R,ll x) {
    Add(1 , 0 , n - 1 , L , R , x);
  }
  pair<ll,int> Query(int L,int R) {
    return Query(1 , 0 , n - 1 , L , R);
  }
  void init(int _n) {
    n = _n;
    Build(1 , 0 , n - 1);
  }
};
Segment A , B;
int n;
ll a[N] , b[N];

int main(){
  scanf("%d",&n);
  rep(i,0,n) scanf("%lld",a+i);
  rep(i,0,n) scanf("%lld",b+i);
  A.init(n);
  B.init(n);
  ll del = 0;
  ll ans = 0;
  rep(i,0,n) {
    del += a[i] - b[i];
    ans += abs(del);
    A.Add(0 , i , del > 0 ? -1 : 1);
    B.Add(i , i , del > 0 ? del : inf);
  }
  while(del) {
    pair<ll,int> x = A.Query(0 , n - 1);
    pair<ll,int> y = B.Query(x.se , n - 1);
    ll way = min(del , y.fi);
    ans += x.fi * way;
    del -= way;
    B.Add(x.se , n - 1 , -way);
    for(int i = x.se;i < n;) {
      pair<ll,int> z = B.Query(i , n - 1);
      if(z.fi) break;
      A.Add(0 , z.se , 2);
      B.Add(z.se , z.se , inf);
      i = z.se + 1;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 19456
import numpy as np

d = int(input())
C = np.array(list(map(int, input().strip().split())))
S = np.array([list(map(int, input().strip().split())) for i in range(d)])
D = np.zeros(26)

t = 0
for i in range(d):
    day = i + 1
    temp_score = 0
    con = 0
    d_l = [day]*26
    for j in range(26):
        score = S[i][j]
        score -= sum((d_l - D) * C)
        score += (day - D[j]) * C[j]
        if score > temp_score:
            con = j
            temp_score = score
    print(con + 1)
    D[con] = i + 1
    t += temp_score


Measured memory_bytes: 27424
H, W = gets.split.map(&:to_i)
board = H.times.map { gets.chomp.chars.take(W) }
board = board.reject { |row| row.all? { |c| c == '.'} }
board = board.transpose.reject { |row| row.all? { |c| c == '.'} }
ans = board.transpose.map { |row| row.join('') }.join("\n")
puts ans

Measured memory_bytes: 2556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] str = br.readLine().split(" ");
    int x = Integer.parseInt(str[0]);
    int y = Integer.parseInt(str[1]);
    int z = Integer.parseInt(str[2]);
    
    int tempX = x;
    x = z;
    int tempY = y;
    y = tempX;
    z = tempY;
    
    System.out.println(x + " " + y + " " + z);
  }
}


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

public class Main {
	static final int MOD = 1_000_000_007;

	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		
		long l = lcm(c,d);
		
		long x = (b/c) - ((a-1)/c);
		long y = (b/d) - ((a-1)/d);
		long z = (b/l) - ((a-1)/l);
		
		out.println((b-a+1) - (x+y-z));
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}

	public static long min(long... a) {
		long min = Long.MAX_VALUE;
		for(int i = 0; i < a.length; i++) {
			if(a[i] < min) min = a[i];
		}
		return min;
	}

	public static long max(long... a) {
		long max = Long.MIN_VALUE;
		for(int i = 0; i < a.length; i++) {
			if(a[i] > max) max = a[i];
		}
		return max;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 25044
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b;
    cin>>a>>b;
    string ans;
    if(a.length()==b.length()){
        int i = 0;
        while(i<a.length()){
            if(i!= a.length()-1){
                if(a[i]>b[i]){
                ans = "GREATER";
                break;
                }
                if(a[i]<b[i]){
                ans = "LESS";
                break;
                }
            } else {
                if(a[i]>b[i]){
                ans = "GREATER";
                break;
                }
                else if(a[i]<b[i]){
                ans = "LESS";
                break;
                } else ans = "EQUAL";
            }
            i++;
        }
    } else if(a.length()>b.length()) ans = "GREATER";
    else ans = "LESS";
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#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;
  int c,d=1;
  cin>>a>>b;
  a=a-b;
  rep(i,b)d*=2;
  cout<<b*d*1900+a*d*100;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
p = []
S = []
for _ in range(M):
    temp = input().rstrip().split()
    p.append(int(temp[0]))
    S.append(temp[1])
dic = {}
for i in range(N):
    dic[i + 1] = []
for i, j in zip(p, S):
    dic[i].append(j)
AC = 0
WA = 0
for k in dic.keys():
    temp = dic[k]
    WA_count = 0
    for j in temp:
        if j == "WA":
            WA_count += 1
        else:
            AC += 1
            WA += WA_count
            break
print(AC, WA)



Measured memory_bytes: 33624
#include<stdio.h>
int selectionsort(int A[],int N)
{
	int i,j,t,sw=0,minj;
	for(i=0;i<N;i++)
	{
		minj=i;
		for(j=i;j<N;j++)
		{
			if(A[j]<A[minj])
			minj=j;
		}
		t=A[i];
		A[i]=A[minj];
		A[minj]=t;
		if(i!=minj)
		sw++;
	}
	return sw;
}
int main()
{
	int A[100],N,i,sw;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	scanf("%d",&A[i]);
	sw=selectionsort(A,N);
	for(i=0;i<N;i++)
	{
		if(i>0)
		printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",sw);
	return 0;
}

Measured memory_bytes: 604
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);
ll h, w;
vector<string> grid;
ll dx[] = {1, -1, 0, 0};
ll dy[] = {0, 0, 1, -1};
bool ok(ll x, ll y) {
	if(x < h and x >= 0 and y < w and y >= 0 and grid[x][y] == '.') return true;
  return false;
}
ll dist(pll a, pll b) {
	queue<pll> q;
	vector<vll> visited(40, vll(40, 0));
	vector<vll> dist(40, vll(40, inf));
	dist[a.ff][a.ss] = 0;
	visited[a.ff][a.ss] = 1;
	q.push(a);
	while(!q.empty()) {
		pll gv = q.front();
		q.pop();
		if(gv == b) break;
		for(ll i = 0; i < 4; i++) {
			ll nx = gv.ff + dx[i];
			ll ny = gv.ss + dy[i];
			if(ok(nx, ny) and visited[nx][ny] == 0) {
				visited[nx][ny] = 1;
				dist[nx][ny] = 1 + dist[gv.ff][gv.ss];
				// cout << nx << " " << ny << endl;
				q.push(mp(nx, ny));
			}
		}
	}
	return dist[b.ff][b.ss];
}
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  cin >> h >> w;
  grid.resize(h);
  for(ll i = 0; i < h; i++) {
  	cin >> grid[i];
  }
  vector<pll> times;
  for(ll i = 0; i < h; i++) {
  	for(ll j = 0; j < w; j++) {
  		if(grid[i][j] == '.') times.pb(mp(i, j));
  	}
  }
  ll ans =  0;
  for(auto it: times) {
  	for(auto et : times) {
  		ans = max(ans, dist(it, et));
  	}
  }
  cout << ans << endl;
  return 0;
} //good night.

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

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();

        StringBuilder sb = new StringBuilder();

        int pre = 0;
        int post = k;

        for (int i=0; i<n-k; i++) {
            if (arr[pre]<arr[post]) {
                sb.append("Yes" + "\n");
            } else {
                sb.append("No" + "\n");
            }
            pre++;
            post++;
        }

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

    }

}



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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VI xs(N);
  cin >> xs;

  int s = accumulate(ALL(xs), 0);
  int ans = 0;
  for(int i=0;i<N;++i){
    if(abs(N * xs[i] - s) < abs(N * xs[ans] - s))
      ans = i;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define f(i,a,n) for(i=a;i<n;i++)
#define fast() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define test() ll tc;cin>>tc;while(tc--)

using namespace std;

const int MAXV = 1e5 + 10;
const int MAXN = 1e3 + 10;
const ll INF = 1e13;


/*ll fact(ll n);

ll comb(ll n, ll r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

ll fact(ll n)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
        res = ((res%mod * i%mod)%mod)%mod;
    return res;
}


ll power(ll x, ll y)
{
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

*/



int main()
{
        fast();
        ll n,m,i,j;
        cin>>n>>m;
        string s[n];
        for(ll i=0;i<n;i++)
        {
            cin>>s[i];
        }
        ll a[n][m];
        for(i=0;i<n;i++)
        {
            if(s[i][0]=='.')
            {
                a[i][0]=1;
            }
            else{
                a[i][0]=0;
                for(j=i+1;j<n;j++)
                {
                    a[j][0]=0;
                }
                break;
            }

        }

        for(i=1;i<m;i++)
        {
            if(s[0][i]=='.')
            {
                a[0][i]=1;
            }
            else{
                a[0][i]=0;

                for(j=i+1;j<m;j++)
                {
                    a[0][j]=0;
                }
                break;
            }

        }

        for(i=1;i<n;i++)
        {
            for(j=1;j<m;j++)
            {
                if(s[i][j]=='.')
                {
                    a[i][j]=(a[i-1][j]%mod+a[i][j-1]%mod)%mod;
                }
                else{
                    a[i][j]=0;
                }
            }
        }
        cout<<a[n-1][m-1];

        return 0;
}


Measured memory_bytes: 9088
#include<iostream>
#include<string>

using namespace std;

int main(){
  int i, j, Awin[3], Bwin[3];
  string game;

  while(1){
    for(i=0; i<3; ++i){
      cin >> game;
      if(game == "0") break;

      Awin[i] = 0;
      Bwin[i] = 0;
      for(j=1; j<game.size(); ++j){
	if(game[j] == 'A')
	  ++Awin[i];
	else
	  ++Bwin[i];
      }
      if(game[game.size()-1] == 'A')
	++Awin[i];
      else
	++Bwin[i];
    }

    if(game == "0") break;
    for(i=0; i<3; ++i)
      cout << Awin[i] << " " << Bwin[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
long long num[200005];
int main()
{
    long long ans=10000000000000000;
    long long n;
    scanf("%lld",&n);
    long long i;
    long long sum=0;
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&num[i]);
        sum=sum+num[i];
    }
    long long tempn=0;
    long long temps;
    for(i=1;i<=n-1;i++)
    {
        tempn=tempn+num[i];
        if(2*tempn<=sum)
        {
            temps=sum-tempn-tempn;
        }
        else
        {
            temps=tempn-(sum-tempn);
        }
        if(temps<ans)
            ans=temps;
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main()
{
  int a, b, c, d, l;
  
  cin >> l >> a >> b >> c >> d;
  if (a % c == 0){
    a = a / c;
  }
  else {
    a = a / c + 1;
  }
  if (b % d == 0){
    b = b / d;
  }
  else {
    b = b / d + 1;
  }
  cout << l - max(a, b) << endl;
  return (0);
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>


int main (void){
        int ans;
        int A[100002];
        int N;
        int all=0;
        scanf("%d",&N);
        A[0]=0;
        A[N+1]=0;
        for (int i = 1; i <= N; i++) {
                scanf("%d",&A[i]);
        }
        for (int i = 0; i <= N; i++) {
                all+=abs(A[i+1]-A[i]);
        }

        for (int i = 1; i <=N; i++) {
                ans=all;
                ans-=abs(A[i+1]-A[i]);
                ans-=abs(A[i]-A[i-1]);
                ans+=abs(A[i+1]-A[i-1]);
                printf("%d\n",ans);
        }

        return 0;
}


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

int cnt = 0;

void bubbleSort(vector<int> &a, int n)
{
  bool flag = true;
  while (flag)
  {
    flag = false;
    for (int i = n - 1; i > 0; --i)
    {
      if (a[i] < a[i - 1])
      {
        swap(a[i], a[i - 1]);
        flag = true;
        cnt++;
      }
    }
  }
}

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &e : a)
    cin >> e;
  bubbleSort(a, n);
  for (int i = 0; i < n; ++i)
    cout << a[i] << (i + 1 == n ? "\n" : " ");
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3076
#include <algorithm>
#include <cstdio>
using std::scanf;
using std::printf;

struct Node { int parent, left, right; };

void SetDepth(Node tree[], int cur_i, int cur_dep, int depth[]) {
  depth[cur_i] = cur_dep;
  int left = tree[cur_i].left;
  int right = tree[cur_i].right;
  if (left != -1) { SetDepth(tree, left, cur_dep + 1, depth); }
  if (right != -1) { SetDepth(tree, right, cur_dep + 1, depth); }
}

void SetHeight(Node tree[], int cur_i, int height[]) {
  int left = tree[cur_i].left;
  int right = tree[cur_i].right;
  // ?????????0
  if ((left == -1) && (right == -1)) {
    height[cur_i] = 0;
    return;
  }
  // ????????????????????????2??????height???max
  int left_height = -1;
  int right_height = -1;
  if (left != -1) {
    SetHeight(tree, left, height);
    left_height = height[left];
  }
  if (right != -1) {
    SetHeight(tree, right, height);
    right_height = height[right];
  }
  height[cur_i] = std::max(left_height, right_height) + 1;
}

int GetSibling(Node tree[], int i) {
  if (tree[i].parent == -1) { return -1; }
  Node parent_node = tree[tree[i].parent];
  if (parent_node.left == i) { return parent_node.right; }
  if (parent_node.right == i) { return parent_node.left; }
  return -100;
}

int GetDegree(Node tree[], int i) {
  int left = tree[i].left;
  int right = tree[i].right;
  if ((left != -1) && (right != -1)) { return 2; }
  if ((left != -1) || (right != -1)) { return 1; }
  return 0;
}

int main() {
  // ??¨?????\???
  int n;
  scanf("%d", &n);
  Node tree[n];
  for (int i = 0; i < n; ++i) { tree[i].parent = -1; }
  for (int i = 0; i < n; ++i) {
    int id, left, right;
    scanf("%d %d %d", &id, &left, &right);
    tree[id].left = left;
    tree[id].right = right;
    if (left != -1) { tree[left].parent = id; }
    if (right != -1) { tree[right].parent = id; }
  }

  // ??????
  int root;
  for (int i = 0; i < n; ++i) {
    if (tree[i].parent == -1) {
      root = i;
      break;
    }
  }
  int depth[n], height[n];
  SetDepth(tree, root, 0, depth);
  SetHeight(tree, root, height);
  for (int i = 0; i < n; ++i) {
    int p, s, deg, dep, h;
    p = tree[i].parent;
    s = GetSibling(tree, i);
    deg = GetDegree(tree, i);
    dep = depth[i];
    h = height[i];
    printf(
      "node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
      i, p, s, deg, dep, h
    );
    if (i == root) {
      printf("root\n");
    } else if (tree[i].left == -1 && tree[i].right == -1) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }

  return 0;
}

Measured memory_bytes: 2684
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define each(i, n) for(auto&& i: n)

int main() {
  int N;
  cin >> N;
  st a = "No";
  rep(i, 10) {
    rep(j, 10) {
      if(N == i * j) {
        a = "Yes";
      }
    }
  }
  cout << a << endl;
}  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, char* argv[])
{

	string S;
	int sum = 700;

	cin >> S;

	for(int i=0;i<S.length();i++){
		if(S[i]=='o') sum+=100;
	}

	cout << sum << endl;

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 a,rsum=0LL,ssum=0LL,rmin=llinf,smin=llinf;
    for(i64 i=0LL;i<4LL;++i){
        scanf("%lli",&a);
        if(a<rmin) rmin=a;
        rsum+=a;
    }
    for(i64 i=0LL;i<2LL;++i){
        scanf("%lli",&a);
        if(a<smin) smin=a;
        ssum+=a;
    }
    printf("%lli\n",rsum+ssum-rmin-smin);
    return 0;
}



Measured memory_bytes: 2104
//  C/C++ program to convert n into negative base form
#include <bits/stdc++.h>
using namespace std;

//  Utility method to convert integer into string
string toString(int n)
{
    string str;
    stringstream ss;
    ss << n;
    ss >> str;
    return str;
}

// Method to convert n to base negBase
string toNegativeBase(int n, int negBase)
{
    //  If n is zero then in any base it will be 0 only
    if (n == 0)
        return "0";

    string converted = "";
    while (n != 0)
    {
        // Get remainder by negative base, it can be
        // negative also
        int remainder = n % negBase;
        n /= negBase;

        // if remainder is negative, add abs(base) to
        // it and add 1 to n
        if (remainder < 0)
        {
            remainder += (-negBase);
            n += 1;
        }

        // convert remainder to string add into the result
        converted = toString(remainder) + converted;
    }

    return converted;
}

//  Driver code to test above methods
int main()
{
    int n;
    cin>>n;
    int negBase = -2;

    cout << toNegativeBase(n, negBase);

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    set<int> s;
    rep(i,3){
        cin>>A;
        s.insert(A);
    }
    cout<<s.size()<<endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn solve(n: usize) {
    let mut ans = 0;
    for i in 1..n+1 {
        if i % 2 == 0 {
            continue
        }
        let mut m = 0;
        for j in 1..i+1 {
            if i % j == 0 {
                m += 1;
            }
        }
        if m == 8 {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn main() {
    input!{
        n: usize
    }
    solve(n)
}

Measured memory_bytes: 4352
import java.util.*;

class Main {

    private void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] A = new int[N];
        int[] B = new int[N];
        int[] C = new int[N];

        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
            C[i] = sc.nextInt();
        }

        int[] dpa = new int[N];
        int[] dpb = new int[N];
        int[] dpc = new int[N];
        dpa[N-1] = A[N-1];
        dpb[N-1] = B[N-1];
        dpc[N-1] = C[N-1];

        for (int i = N-2; i >= 0; i--) {
            dpa[i] = Math.max(dpb[i+1], dpc[i+1]) + A[i];
            dpb[i] = Math.max(dpa[i+1], dpc[i+1]) + B[i];
            dpc[i] = Math.max(dpa[i+1], dpb[i+1]) + C[i];
        }

        int a = dpa[0];
        int b = dpb[0];
        int c = dpc[0];

        int max = a > b 
                  ? a > c 
                    ? a 
                    : c
                  : b > c
                    ? b
                    : c;
        System.out.println(max);
    }

    public static void main(String[] args) {
        Main solver = new Main();
        solver.run();
    }
}


Measured memory_bytes: 93808
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
 
sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7
 
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
 
 
def main():
    n = I()
    r = 0
    for _ in range(n):
        a,b = LI()
        r += b-a+1
 
    return r
 
print(main())

Measured memory_bytes: 70636
#include<iostream>
#define PI 3.141592653589
using namespace std;

int main(){
	while(1){
		int H,W;
		cin >> H >>W;
		
		if(H==0 && W==0)break;
		for(int x=0;x<W;x++){
			printf("#");
		}
		printf("\n");
		
		for(int y=0+1;y<H-1;y++){
			printf("#");
			for(int x=0+1;x<W-1;x++){
				printf(".");
			}
			printf("#");
			printf("\n");
		}
		for(int x=0;x<W;x++){
			printf("#");
		}
		printf("\n");
		printf("\n");
	}
	
	return 0;
}

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

int main() {
	// your code goes here
	long long small;
	long long big;
	long long range;
	long long d;
	cin>>small>>big>>d;
	long long f= small%d;
	if (f) small+=d-f;
	f=big%d;
	big-=f;
	if(small>big){
		cout<<0<<endl;
		return 0;
	}
	range= big-small;
	long long ans= range/d;
	ans++;
	cout<<ans<<endl;
	return 0;
}

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;
typedef pair<ll,ll> P;
typedef complex<double> C;
 
const double EPS = 1e-10;
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
const ll INF = 100000000;
const ll MOD = 1000000007;
C p[3];

double cross(C a, C b) {
    return (a.real() * b.imag() - a.imag() * b.real());
}

C intersection_l(C a1, C a2, C b1, C b2) {
  C a = a2 - a1; C b = b2 - b1;
  return a1 + a * cross(b, b1-a1) / cross(b, a);
}

void solve() {
    double l = min(abs(p[0]-p[1]), abs(p[0]-p[2]));

    double lef = 0.0, rig = l;
    C r1, r2, r3;
    double d1, d2, d3;
    rep(_,100) {
        
        double mid = (lef + rig) / 2.0;
        C mp1 = p[0] + (p[1] - p[0]) / abs(p[1]-p[0]) * mid;
        C mp2 = p[0] + (p[2] - p[0]) / abs(p[2]-p[0]) * mid;
        C mp1t = mp1 + (p[1]-p[0])*C(0,1);
        C mp2t = mp2 + (p[2]-p[0])*C(0,1);
        r1 = intersection_l(mp1, mp1t, mp2, mp2t);
        d1 = abs(r1 - mp1);

        double l_2 = min(abs(p[1]-p[0]), abs(p[1]-p[2]));
        double lef_2 = 0.0, rig_2 = l_2;
        rep(__,100) {
            double mid_2 = (lef_2 + rig_2) / 2.0;
            C mp1_2 = p[1] + (p[0]-p[1]) / abs(p[0]-p[1]) * mid_2;
            C mp2_2 = p[1] + (p[2]-p[1]) / abs(p[2]-p[1]) * mid_2;
            C mp1t_2 = mp1_2 + (p[0]-p[1])*C(0,1);
            C mp2t_2 = mp2_2 + (p[2]-p[1])*C(0,1);
            r2 = intersection_l(mp1_2, mp1t_2, mp2_2, mp2t_2);
            d2 = abs(r2 - mp1_2);
            if (abs(r1-r2) < d1+d2) {
                rig_2 = mid_2;
            } else {
                lef_2 = mid_2;
            }
        }

        l_2 = min(abs(p[2]-p[0]), abs(p[2]-p[1]));
        lef_2 = 0.0, rig_2 = l_2;
        rep(__,100) {
            double mid_2 = (lef_2 + rig_2) / 2.0;
            C mp1_2 = p[2] + (p[0]-p[2]) / abs(p[0]-p[2]) * mid_2;
            C mp2_2 = p[2] + (p[1]-p[2]) / abs(p[1]-p[2]) * mid_2;
            C mp1t_2 = mp1_2 + (p[0]-p[2])*C(0,1);
            C mp2t_2 = mp2_2 + (p[1]-p[2])*C(0,1);
            r3 = intersection_l(mp1_2, mp1t_2, mp2_2, mp2t_2);
            d3 = abs(r3 - mp1_2);
            if (abs(r1-r3) < d1+d3) {
                rig_2 = mid_2;
            } else {
                lef_2 = mid_2;
            }
        }
        if (abs(r2-r3) < d2+d3) {
            lef = mid;
        } else {
            rig = mid;
        }
    }
    printf("%.9f %.9f %.9f\n", d1, d2, d3);
}

int main() {
    int _x[3], _y[3];
    while (cin >> _x[0] >> _y[0] >> _x[1] >> _y[1] >> _x[2] >> _y[2]) {
        bool end = true;
        rep(i,3) {
            if (_x[i] || _y[i]) end = false;
        }
        if (end) break;
        rep(i,3)  p[i] = C(_x[i], _y[i]);
        solve();
    }
}




Measured memory_bytes: 3140
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

int main(){
    int n;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", s);
    int x=0, y=0, p;
    p=0;
    rep(i, 0, n){
        if(s[i] == ')'){
            p++;
        }else{
            p--;
        }
        if(p > 0){
            x++;
            p--;
        }
    }
    p=0;
    rep(i, 0, n){
        if(s[n-1 - i] == '('){
            p++;
        }else{
            p--;
        }
        if(p > 0){
            y++;
            p--;
        }
    }
    rep(i, 0, x){
        printf("(");
    }
    printf("%s", s);
    rep(i, 0, y){
        printf(")");
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll int
const ll inf=1e9;
const int N=1e5+7;

ll dp[N][3],v[N];
ll n;
ll solve(ll cur,int p)
{
    if(cur==n) return 0;
    if(cur>n)return inf;
    //cout<<cur<<" "<<p<<endl;
    if(dp[cur][p]!=-1)
        return dp[cur][p];
        dp[cur][p]=solve(cur+1,1)+abs(v[cur+1]-v[cur]);
        dp[cur][p]=min(solve(cur+2,2)+abs(v[cur+2]-v[cur]),dp[cur][p]);
    return dp[cur][p];
}
int main()
{
    cin>>n;
    for(ll i=1;i<=n;i++)
        cin>>v[i];
    memset(dp,-1,sizeof dp);
    int ans=solve(1,1);
    cout<<ans<<endl;
    return 0;
}  


Measured memory_bytes: 6528
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M := sc.nextInt(), sc.nextInt()
	un := NewUnionFind(N)
	for i := 0; i < M; i++ {
		x, y, _ := sc.nextInt()-1, sc.nextInt()-1, sc.nextInt()
		un.unite(x, y)
	}
	set := make(map[int]int)
	for i := 0; i < N; i++ {
		set[un.root(i)]++
	}

	fmt.Fprintln(wtr, len(set))
}

type UnionFind struct {
	parent []int
	size   []int
}

func NewUnionFind(n int) *UnionFind {
	p := make([]int, n)
	s := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = i
		s[i] = 1
	}
	return &UnionFind{p, s}
}

func (a *UnionFind) root(x int) int {
	if a.parent[x] == x {
		return x
	} else {
		a.parent[x] = a.root(a.parent[x])
		return a.parent[x]
	}
}

func (a *UnionFind) isSame(x, y int) bool {
	return a.root(x) == a.root(y)
}

func (a *UnionFind) unite(x, y int) {
	x = a.root(x)
	y = a.root(y)
	if x == y {
		return
	} else {
		a.parent[x] = y
		a.size[y] += a.size[x]
	}
}

func (a *UnionFind) getSize(x int) int {
	return a.size[a.root(x)]
}


Measured memory_bytes: 8064
#include<iostream>
using namespace std;
int a,b;
int main()
{ 
  cin >> a >> b;
  if((a+11)%13<(b+11)%13)printf("Bob");
  if((a+11)%13>(b+11)%13)printf("Alice");
  if((a+11)%13==(b+11)%13)printf("Draw");
}

Measured memory_bytes: 256
n, k = map(int, input().split())
if n%k == 0:
    print(0)
else:
    a = n//k
    if a != 0:
        n -= a*k
        b = abs(k - n)
        print(min(b, abs(k - b)))
    else:
        print(min(n, abs(k - n)))

Measured memory_bytes: 61660
#include <stdio.h>

int main(void) {
	int count ,i , j,  k, n, x;

	while (1){
		scanf("%d %d", &n, &x);
			if (n == 0 && x == 0)
			break;
		count = 0;
		for (i = 1;i <= n;i++) {
			for (j = i + 1; j <= n; j++) {
				for (k = j + 1; k <= n; k++) {
					if (i + j + k == x)
					count++;
				}
			}
		}
		printf("%d\n", count);
	}
	
	return 0;
}


Measured memory_bytes: 2052
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109311;
const long double pi = 3.1415926535897932384626433;
typedef pair<int, int> P;
struct edge { int to, cost; };

int gcd(int a, int b) {
	if (!b)return a; return gcd(b, a%b);
}
int pow_(int x, int y) {
	int res = 1;
	rep(i, y)res *= x;
	return res;
}
map<int,int>M;
signed main() {
	int n, p; cin >> n >> p;
	for (int j = 2; j*j <= p; j++) {
		while(p%j == 0) {
			p /= j;
			M[j]++;
		}
	}
	if (p != 1)M[p]++;
	int ans = 1;

	for (auto itr = M.begin(); itr != M.end(); itr++) {
		int f = itr->first, s = itr->second;
		if(s/n)ans *= pow(f,(s/n));
		//cout << f << ' ' << s << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define deb(x) cout << #x << "=" << x << endl
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
int M=1e9+7,N=205001;

int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M




void solve() {
	string s;
	cin>>s;
	int n=0;
	for(char i:s){
		n+=(i-'0');
	}
	if(n%9) cout<<"No";
	else cout<<"Yes";
		
}


signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}





Measured memory_bytes: 3744
#include<stdio.h>
#include <math.h>
int main(void){
int N;
int counter,num[210];
int min=10000;
scanf("%d",&N);
for (counter=1; counter<=N; counter++) {

		scanf("%d",&num[counter]);
      int d=0;
      while(num[counter] %2 ==0){
        num[counter] /=2;
        ++d;
      }
   if(min>d)
      min=d;

		}
printf("%d\n", min);
return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

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

		int N = Integer.parseInt(sc.next());

		long[] A = new long[N + 1];
		long LENG = 0;
		for(int i = 1;i <= N;i++) {
			A[i] = Long.parseLong(sc.next());
			LENG += A[i];
		}

		sc.close();

		long leng = 0;
		for(int i = 1;i <= N;i++) {
			leng += A[i];
			if(leng * 2 == LENG) {
				System.out.println(0);
				return;
			}
			if(leng * 2 > LENG) {
//				System.out.println(leng);
				long ans1 = leng - (LENG - leng);
//				System.out.println(leng - (LENG - leng));
				leng -= A[i];
//				System.out.println((LENG - leng) - leng);
				long ans2 = (LENG - leng) - leng;
				System.out.println(Math.min(ans1, ans2));


				break;
			}
		}



//		System.out.println(N);
//		for(int i = 1;i <= N;i++) {
//			System.out.print(a[i]);
//		}

//		FastScanner fs = new FastScanner();
//		int N = fs.nextInt();


	}
}



Measured memory_bytes: 51024
#include <bits/stdc++.h>
using namespace std;
int main(){

  for(;;){
    int n;
    cin>>n;
    if(!n) break;

    int r=0,pre=0,a[2][2]={1,1};
    for(int i=0;i<n;i++){
      string s;
      cin>>s;

      if(s=="lu"){
	a[1][0]=1;
	a[0][0]=0;
      }
      else if(s=="ru"){
	a[1][1]=1;
	a[0][1]=0;
      }
      else if(s=="ld"){
	a[1][0]=0;
	a[0][0]=1;
      }
      else if(s=="rd"){
	a[1][1]=0;
	a[0][1]=1;
      }

      if(pre==0 && a[1][0] && a[1][1]){
	pre=1;
	r++;
      }
      else if(pre==1 && a[0][0] && a[0][1]){
	pre=0;
	r++;
      }

    }
    cout<<r<<endl;

  }
  return 0;

}



Measured memory_bytes: 3100
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define NAME ""

const int INF = 1e9;
const long long INFLL = 1e18;

string s;
int dp[500000];
int nxt[26][500000];
int fxd[26];
int ok[500000];

signed main()
{
    if (NAME != "") { freopen(NAME ".in", "r", stdin); freopen(NAME ".out", "w", stdout); }
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    cin >> s;
    s = " " + s;
    fill(dp, dp + s.size() + 1, INF);
    for (int i = 0; i < 26; i++) fxd[i] = s.size();
    for (int i = s.size() - 1; i >= 0; i--)
    {
        for (int j = 0; j < 26; j++) nxt[j][i] = fxd[j];
        if (i) fxd[s[i] - 'a'] = i;
    }
    dp[0] = 0;
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 0; j < 26; j++)
        {
            dp[nxt[j][i]] = min(dp[nxt[j][i]], dp[i] + 1);
        }
    }
    ok[s.size()] = 1;
    //cout << dp[s.size()] << endl;
    for (int i = s.size() - 1; i >= 0; i--)
    {
        for (int j = 0; j < 26; j++)
        {
            if (ok[nxt[j][i]] && dp[i] + 1 == dp[nxt[j][i]])
            {
                ok[i] = 1;
            }
        }
    }
    for (int i = 0; i < s.size(); )
    {
        for (int j = 0; j < 26; j++)
        {
            if (ok[nxt[j][i]] && dp[i] + 1 == dp[nxt[j][i]])
            {
                cout << (char)(j + 'a');
                i = nxt[j][i];
                break;
            }
        }
    }
}


Measured memory_bytes: 52928
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K <= A) {
    cout << K << endl;
    return 0;
  }

  ll ans = A;
  ll remain = K - A;
  if (remain <= B) {
    cout << ans << endl;
    return 0;
  }

  remain -= B;
  cout << ans - remain << endl;

  return 0;
}


Measured memory_bytes: 3652
n=int(input())

a=list(map(int,input().split()))
  
b=[]
if n>1:
  for j in range (n-1):
    c=a[j]-a[j+1]
    if c>-1:
      b.append(c)
      a[j+1]=a[j+1]+c
    else:
      b.append(0)
      
   
  if max(b)>-1:
    print(sum(b))
  else:
    print(0)
    
else:
  print(0)

Measured memory_bytes: 32292