akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int n;
    scanf("%d", &n);
    ll sum1 = 0, sum2 = 0;
    ll ans1 = 0, ans2 = 0;
    for(int i = 0; i < n; i++){
        ll a;
        scanf("%lld", &a);
        sum1 += a;
        sum2 += a;
        if(i % 2){
            if(sum1 >= 0){
                ans1 += sum1 + 1;
                sum1 = -1;
            }
            if(sum2 <= 0){
                ans2 += sum2 * (-1) + 1;
                sum2 = 1;
            }
        }else{
            if(sum1 <= 0){
                ans1 += sum1 * (-1) + 1;
                sum1 = 1;
            }
            if(sum2 >= 0){
                ans2 += sum2 + 1;
                sum2 = -1;
            }
        }
    }
    printf("%lld\n", min(ans1, ans2));
}


Measured memory_bytes: 256
from collections import deque


def main():
    N = int(input())
    ans = [0] * N
    adj = [set() for _ in range(N)]
    edge = [None] * (N-1)
    for i in range(N-1):
        a, b = map(int, input().split())
        adj[a-1].add(b-1)
        adj[b-1].add(a-1)
        edge[i] = (a-1, b-1)
    C = list(map(int, input().split()))
    C.sort()
    q = deque()
    for i in range(N):
        if len(adj[i]) == 1:
            q.append(i)
    x = 0
    while len(q):
        n = q.popleft()
        ans[n] = C[x]
        x += 1
        for a in adj[n]:
            adj[a].remove(n)
            if len(adj[a]) == 1:
                q.append(a)
    total = 0
    for i in range(N-1):
        a, b = edge[i]
        total += min(ans[a], ans[b])
    print(total)
    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 53720
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

LL a[100005];

int main()
{
    int n,q;
    LL k;
    cin>>n>>k>>q;
    rer(i,1,n)a[i]=k-q;
    rer(i,1,q)
    {
        int c;
        cin>>c;
        a[c]++;
    }
    rer(i,1,n)if(a[i]>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

struct Point{
	double px;
	double py;
};

Point Minus(Point a, Point b){
	Point c;
	c.px=a.px-b.px;
	c.py=a.py-b.py;
	return c;
}

double dot(Point a, Point b){
	return a.px*b.px+a.py*b.py;
}

int crs(Point a, Point b){
	double t=a.px*b.py-a.py*b.px;
	if(abs(t)<(1e-08))return 0;
	if(t<0)return -1;
	return 1;
}

int con(vector<Point> V, Point p){
	bool in=false;
	for(int i=0;i<V.size();i++){
		Point a = Minus(V[i],p);
		Point b = Minus(V[(i+1)%(V.size())],p);
		if(a.py>b.py)swap(a,b);
		if(a.py<=0 && 0<b.py){
			if(crs(a,b)<0)in=!in;
		}
		if(crs(a,b)==0 && dot(a,b)<=0)return 1;
	}
	return in ? 2 : 0;
	
}

int main(){
	vector<Point>v;
	Point P;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>P.px>>P.py;
		v.push_back(P);
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>P.px>>P.py;
		cout<<con(v,P)<<endl;
	}
	
	
	return 0;
}


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

#define endl ("\n")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SQ (a)*(a)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define deb(x) cout<<#x<<" "<<x<<endl;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll mod = 1e9L+7;
int n;
vector<ll> inp;
vector<int> dp;

int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    /*freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    #ifndef ONLINE_JUDGE
    #endif*/
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        int r,c,m;
        cin>>r>>c>>m;

        set<pii> pts;
        vi row(r+1,0);
        vi col(c+1,0);
        rep(i,0,m)
        {
            int a,b;
            cin>>a>>b;
            pts.insert(MP(a,b));
            row[a]++;
            col[b]++;
        }

        int a = *max_element(row.begin(),row.end());
        int b = *max_element(col.begin(),col.end());

        vi m_r;
        rep(i,1,r+1) if(row[i] == a) 
        {
            m_r.push_back(i);
            //cout<<i<<endl;
        }

        vi m_c;
        rep(i,1,c+1) if(col[i] == b) 
        {
            m_c.push_back(i);
            //cout<<i<<endl;
        }
        
        for(auto ele:m_r)
        {
            for(auto elec:m_c)
            {
                if(pts.find(MP(ele,elec)) == pts.end())
                {
                    cout<<a+b<<endl;
                    return 0;
                }
            }
        }
        cout<<a+b-1<<endl;
    }
}


Measured memory_bytes: 23812
#include <stdio.h>
#include <map>
using namespace std;


main(){
	map<pair<int,int>,int> cnt;
	long long h,w;
	int n;
	scanf("%lld%lld%d",&h,&w,&n);
	for(int i=0;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);a--;b--;
		for(int di=-1;di<=1;di++){
			for(int dj=-1;dj<=1;dj++){
				int aa=a+di,bb=b+dj;
				if(1<=aa&&aa<h-1&&1<=bb&&bb<w-1){
					cnt[make_pair(aa,bb)]++;
				}
			}
		}
	}
	long long ans[10]={};
	ans[0]=(h-2)*(w-2);
	for(map<pair<int,int>,int>::iterator ite=cnt.begin();ite!=cnt.end();ite++){
		int mul=ite->second;
		ans[mul]++;ans[0]--;
	}
	for(int i=0;i<=9;i++)printf("%lld\n",ans[i]);
}

Measured memory_bytes: 56448
from collections import deque

n = int(input())
A = list(map(int, input().split()))

b = deque()

for i in range(1, n + 1):
    if i % 2 == 1:
        b.append(A[i - 1])
    else:
        b.appendleft(A[i - 1])

if n % 2 == 1:
    for i in range(n - 1, -1, -1):
        print(b[i], end='')
        if i != 0:
            print(' ', end='')
else:
    for i in range(n):
        print(b[i], end='')
        if i != n - 1:
            print(' ', end='')

Measured memory_bytes: 32516
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <string>
#include <set>


using namespace std;


int main() {
	int N, M; cin >> N;
	map<string, int> m;
	for (int i = 0; i < N; i++) {
		string s; cin >> s;
		m[s] += 1;
	}

	cin >> M;
	for (int i = 0; i < M; i++) {
		string s; cin >> s;
		m[s] -= 1;
	}

	int total = 0;
	for (auto p : m) total = max(total, p.second);
	cout << total << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[110000];

char c[110000];
int n;
int sa_k;
int Rank[110000];
int tmp[110000];
int sa[110000];
int lcp[110000];
bool compare_sa(int i,int j){
	if(Rank[i]!=Rank[j])return Rank[i]<Rank[j];
	else{
		int ri=i+sa_k<=n?Rank[i+sa_k]:-1;
		int rj=j+sa_k<=n?Rank[j+sa_k]:-1;
		return ri<rj;
	}
}
void construct_sa(){
	for(int i=0;i<=n;i++){
		sa[i]=i;
		Rank[i]=i<n?c[i]:-1;
	}
	for(sa_k=1;sa_k<=n;sa_k*=2){
		sort(sa,sa+n+1,compare_sa);
		tmp[sa[0]]=0;
		for(int i=1;i<=n;i++){
			tmp[sa[i]]=tmp[sa[i-1]]+(compare_sa(sa[i-1],sa[i])?1:0);
		}
		for(int i=0;i<=n;i++){
			Rank[i]=tmp[i];
		}
	}
}

int rev[110000];
int ijk[110000];
int v[110000];
int main(){
	int a;
	scanf("%d%s",&a,in);
	n=strlen(in);
	for(int i=0;i<n;i++)c[i]=in[i];
	construct_sa();
	for(int i=0;i<=n;i++){
		rev[sa[i]]=i;
	}
	int r=n/(a+1)+!!(n%(a+1));
	int left=0;
	int right=n+1;
	while(left+1<right){
		int M=(left+right)/2;
		for(int i=0;i<=n;i++){
			ijk[i]=mod;
			v[i]=0;
		}
		deque<pair<int,int> > Q;
		Q.push_back(make_pair(0,0));
		while(Q.size()){
			int cost=Q.front().first;
			int at=Q.front().second;
			Q.pop_front();
			if(v[at])continue;
			v[at]=1;
			int to=min(n,at+r-1);
			if(v[to]==0&&ijk[to]>cost+1){
				ijk[to]=cost+1;
				Q.push_back(make_pair(cost+1,to));
			}
			if(at&&!v[at-1]&&ijk[at-1]>cost){
				ijk[at-1]=cost;
				Q.push_front(make_pair(cost,at-1));
			}
			if(rev[at]<=M){
				to=min(n,at+r);
				if(v[to]==0&&ijk[to]>cost+1){
					ijk[to]=cost+1;
					Q.push_back(make_pair(cost+1,to));
				}
			}
		}
	//	printf("%d: %d\n",M,ijk[n]);
		if(ijk[n]<=a+1){
			right=M;
		}else left=M;
	}
	int st=sa[right];
	for(int i=0;i<r;i++)printf("%c",in[st+i]);
	printf("\n");
}

Measured memory_bytes: 3264
#include<stdio.h>
#include<string.h>
#define MAX 2000000

int H,A[MAX+1];

void  swap(int *x, int *y)
{
    int  work;        /* ????\???¨ */

    work = *x;        /* x????????????????????? */
    *x = *y;          /* x?????????y???????????????????????? */
    *y = work;        /* y?????????x???????????????????????? */
}

void maxHeapify(int i) {
  int l,r,largest;
  l = 2*i;
  r = 2*i+1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i){
    swap(&A[i], &A[largest]);
    maxHeapify(largest);
  }
}

int extract() {
  int maxv;
  if(H < 1) return -1;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i,int key) {
  if(key < A[i]) return;
  A[i] = key;
  while(i>1&&A[i/2] <A[i]) {
  swap(&A[i],&A[i/2]);
  i = i/2;
  }
}

void insert(int key) {
  H++;
  A[H] = -1;
  increaseKey(H,key);
}

int main() {
  int key,i;
  char com[10];

  while(1) {
    scanf("%s\n",com );
    if(strcmp(com,"end") == 0) break;
    if(strcmp(com,"insert") == 0){
      scanf("%d\n", &key);
      insert(key);
    } else {
      printf("%d\n",extract() );
    }
  }

  return 0;
}

Measured memory_bytes: 4700
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	r := getNextInt(scanner)
	c := getNextInt(scanner)
	maze := make([][]byte, r)
	steps := make([][]int, r)
	queue := make([][]int, 0)
	for y := 0; y < r; y++ {
		maze[y] = make([]byte, c)
		steps[y] = make([]int, c)
		s := getNextString(scanner)
		for x := 0; x < c; x++ {
			maze[y][x] = s[x]
			if s[x] == '.' {
				continue
			}
			steps[y][x] = 1
			queue = append(queue, []int{
				y, x, 0,
			})
		}
	}

	dy := [4]int{-1, 0, 0, 1}
	dx := [4]int{0, -1, 1, 0}
	ans := -1
	for len(queue) > 0 {
		p := queue[0]
		queue = queue[1:]
		ans = p[2]
		for i := 0; i < 4; i++ {
			if p[0]+dy[i] < 0 || p[0]+dy[i] >= r {
				continue
			}
			if p[1]+dx[i] < 0 || p[1]+dx[i] >= c {
				continue
			}
			if maze[p[0]+dy[i]][p[1]+dx[i]] == '#' {
				continue
			}
			if steps[p[0]+dy[i]][p[1]+dx[i]] > 0 {
				continue
			}
			steps[p[0]+dy[i]][p[1]+dx[i]] = 1
			queue = append(queue, []int{
				p[0] + dy[i],
				p[1] + dx[i],
				p[2] + 1,
			})
		}
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}


Measured memory_bytes: 127744
n,s = list(map(int,input().split())); arr = list(map(int,input().split()))

mod = 998244353
ans = 0
dp = [0]*(s+1)

for i in range(n):
    dp[0] += 1
    tmp = arr[i]
    for j in range(s,tmp-1,-1):
        dp[j] += dp[j-tmp]
    ans += dp[s]
    ans %= mod
print(ans)

Measured memory_bytes: 3444
#include<stdio.h>
int main(int argc, char const *argv[])
{
    char str[3];
    scanf("%s",str);
    for (int i = 0; i < 3; i++)
    {
        if (str[i]=='1')
        {
            str[i]='9';
        }else{
            str[i]='1';
        }
    }
    printf("%s\n",str);
    return 0;
}

Measured memory_bytes: 128
f = true;
e = false;
 
while (s = gets) && !e do
  if f then
    f = false;
  else
    puts;
  end
  a = s.split(" ").map(&:to_i);
  s1 = ("#." * (a[1] / 2)) + (a[1].even? ? "" : "#");
  s2 = (".#" * (a[1] / 2)) + (a[1].even? ? "" : ".");
  a[0].times{|i|
    if i.even? then
      puts s1;
    else
      puts s2;
    end
  }
end

Measured memory_bytes: 8564
#include<bits/stdc++.h>
using namespace std;
#define int long long
int q[100000000];
signed main(){
  int b=0,c=0,d=0,e,f,a;
  cin>>a;
  for(int i=0;i<a;i++) cin>>q[i];
  for(int i=a-1;i>0;i--){
    if(q[i]-c>=q[i-1]) c=0;
      else {
        if(q[i]-c>=q[i-1]-1) c=1;
        else{ 
          d=1;
          break;
        }
      }
    }
if(d) cout<<"No";
else cout<<"Yes";
cout<<"\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main () {

    int N, K;
    while (cin >> N >> K) {
        int price[1000] = {0};
        for (int i = 0; i < N; i++) {
            cin >> price[i];
        }
        sort(price, price + N);
        int sum = 0;
        for (int i = 0; i < K; i++) {
            sum += price[i];
        }
        cout << sum << endl;
    }
    return 0;
}

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


int main(int argc, char *argv[]){
  int n;
  cin >> n;
  for (int r = 0; r < n; r++) {

    string x, y;
    cin >> x >> y;
    int dp[y.length() + 1][x.length() + 1];
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < y.length(); i++) {
      for (int j = 0; j < x.length(); j++) {
        if(y[i] == x[j]){
          dp[i + 1][j + 1] = dp[i][j] + 1;
        }else{
          dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
        }
      }
    }
    cout << dp[y.length()][x.length()] << endl;
  }
  return 0;
}


Measured memory_bytes: 6972
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

ll a[100001] = {};
ll s[100001] = {};
ll b[100001] = {};
ll w[100001] = {};

int main() {
	ll n, k; cin >> n >> k;
	repe(i, 1, n) {
		cin >> a[i];
		s[i] += s[i - 1] + a[i];

		if (a[i] > 0) {
			b[i] += b[i - 1] + a[i];
			w[i] += w[i - 1];
		}
		else {
			w[i] += w[i - 1] + a[i];
			b[i] += b[i - 1];
		}
	}
	ll ans = 0;
	repe(i, 1, n - k + 1) {
		ll minW = b[i - 1] - b[0]
			+ b[n] - b[i + k - 1];
		ll minB = s[i + k - 1] - s[i - 1]
			+ minW;

		ans = max(max(minW, minB), ans);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#define  MOD 1000000007
#define int long long
using namespace std;

int mod_inv(int X){
	int a = X, b = MOD, u = 1, v = 0;
	while(b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if(u < 0) u += MOD;
	return u;
}

signed main(){
	int n,a,b,c,d,dp[1001][1001] = {},comb[1001][1001] = {},fact[1001] = {1,1};
	for(int i = 2;i <= 1000;i++) fact[i] = fact[i - 1] * i % MOD;
	for(int i = 0;i <= 1000;i++) {
		comb[i][0] = 1;
		comb[i][i] = 1;
		for(int j = 1;j < i;j++) comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % MOD;
	}
	cin >> n >> a >> b >> c >> d;
	dp[a - 1][0] = 1;
	for(int i = a;i <= b;i++){
		for(int j = 0;j <= n;j++){
			dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
			int now = dp[i - 1][j];
			for(int k = 1;k <= c - 1 && j + i * k <= n;k++) now = now * comb[n - j - ((k - 1) * i)][i] % MOD;
			for(int k = c;k <= d && j + i * k <= n;k++){
				now = now * comb[n - j - ((k - 1) * i)][i] % MOD;
				dp[i][j + i * k] = (dp[i][j + i * k] + now * mod_inv(fact[k]) % MOD) % MOD;
			}
		}
	}
	cout << dp[b][n] << endl;
	return 0;
}

Measured memory_bytes: 15872
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  ll n;
  cin >> n;
  for(ll i = 1; i < 3501; i++){
    for(ll j = 1; j < 3501; j++){
      ll w = (4 * i * j - n * i - n * j);
      if(w <= 0 || (n * i * j) % w != 0)continue;
      cout << i << " " << j << " " << (n * i * j) / w << endl;
      return 0;
    }
  }
	return 0;
}


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


int main() {
  int N; cin >> N;
  vector<string> S(N);
  vector<long long> sum(5);
  long long ans = 0;
  for(int i=0; i<N; i++){
    cin >> S[i];
    switch(S[i][0]){
      case 'M': sum[0]++; break;
      case 'A': sum[1]++; break;
      case 'R': sum[2]++; break;
      case 'C': sum[3]++; break;
      case 'H': sum[4]++; break;
    }
  }

  for(int i=0; i<3; i++){
    for(int j=i+1; j<4; j++){
      for(int k=j+1; k<5; k++){
        ans += sum[i]*sum[j]*sum[k];
      }
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

typedef long long ll;

using namespace std;

int main(void) {
  int D, G, p[11], c[11];
  cin >> D >> G;
  for (int i = 0; i < D; i++) {
     cin >> p[i] >> c[i];
  }

  int ans = 1e9;
  for (int mask = 0; mask < (1 << D); mask++) {
    int s = 0, num = 0, rest_max = -1;
    for (int i = 0; i < D; i++) {
      if (mask >> i & 1) {
        s += 100 * (i + 1) * p[i] + c[i];
        num += p[i];
      } else {
        rest_max = i;
      }
    }
    if (s < G) {
      int s1 = 100 * (rest_max + 1);
      int need = (G - s + s1 - 1) / s1;
      if (need >= p[rest_max]) {
        continue;
      }
      num += need;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int a = 0, b = 0;

    scanf("%d %d", &a, &b);
    if ((a*b) % 2 == 0) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

vector<string> split(const string &s, const string& seps) {
  vector<string> res;
  int pos = 0, sz = seps.size();
  size_t find_pos = string::npos;
  while (true) {
    for (int i = 0; i < sz; i++) {
      size_t tmp = s.find(seps[i], pos);
      if (find_pos == string::npos || tmp < find_pos) find_pos = tmp;
    }
    if (find_pos == string::npos) break;
    res.emplace_back(s.substr(pos, find_pos - pos));
    pos = find_pos + 1;
    find_pos = string::npos;
  }
  if (pos < (int)s.size()) res.emplace_back(s.substr(pos));
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  getline(cin, s);
  vector<string> a = split(s, " .,"), ans;
  for (auto &i : a) {
    int iz = i.size();
    if (iz >= 3 && iz <= 6) ans.emplace_back(i);
  }
  int ansz = ans.size();
  for (int i = 0; i < ansz; i++) {
    cout << ans[i] << " \n"[i + 1 == ansz];
  }

  return 0;
}


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

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

    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int sum = 0;
    for(int i=0; i<n; i++){
        if(i%2 == 0){
            sum += a[n-1-i];
        }else{
            sum -= a[n-1-i];
        }
    }
    cout << sum << endl;
  
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace abc131_e
{
    class Program
    {
        static void Main(string[] args)
        {
            var items = Console.ReadLine().Split(' ');
            // 頂点数
            var n = int.Parse(items[0]);
            // 長さ2のペア
            var k = int.Parse(items[1]);

            // すべての頂点を1に連結した時のkは(n-1)*(n-2)/2。この時のkが最大
            var max = (n - 1) * (n - 2) / 2;

            if (max < k)
            {
                // kが最大より大きいときは成立しない
                Console.WriteLine($"{-1}");
            }
            else
            {
                // グラフ内の距離は、頂点間の最短距離のことである。
                // a-b-cがV字の場合はa-b、b-cが距離1でa-cが距離2。
                // a-b-cが三角形の場合は、a-b、b-c、c-aのいずれも距離1。
                // つまり、V字に辺を張って三角形にしていけば、距離2の頂点をひとつづつ減らすことができる
                // すべての頂点がつながっているグラフは、距離1のみ→kの最小値はこれ(mの最大値でもある)

                // Vから三角にするために張らなければいけない辺の数
                var sub = max - k;
                // すべての辺の数(1に連結した頂点+Vから三角の辺)
                var m = (n - 1) + sub;

                Console.WriteLine($"{(m)}");
                var count = 0;
                for (int u = 1; u <= n; u++)
                {
                    for (int v = u + 1; v <= n; v++)
                    {
                        Console.WriteLine($"{u} {v}");
                        count++;
                        if (count >= m)
                        {
                            break;
                        }
                    }
                    if (count >= m)
                    {
                        break;
                    }
                }
            }
        }
    }
}



Measured memory_bytes: 13140
#include<iostream>

using namespace std;

int main() {
	int N, M, T, a[100], ans = 0, sa;
	while (1) {
		cin >> N;
		cin >> M;
		cin >> T;
		for (int lop = 0;lop < N;lop++) {
			cin >> a[lop];
		}
		ans = T;
		ans -= M*N * 2;
		if (T < a[N - 1] + M) {
			ans = ans + ((a[N - 1] + M) - T);
		}
		for (int lop = 0;lop < N - 1;lop++) {
			if ((a[lop + 1] - a[lop]) < M * 2) {
				ans = ans + ((M * 2) - (a[lop + 1] - a[lop]));
			}
		}


		cout << ans << endl;
		for (int lop = 0;lop < N;lop++) {
			a[lop] = 0;
		}
		ans = 0;
		break;
	}

	return 0;
}

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

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

  int res;

  if(a%2 == 1 && b%2 == 0){
    res = (a + b) / 2 + 1;
  } else if(a%2 == 0 && b%2 == 1) {
    res = (a + b) / 2 + 1;
  } else {
    res = (a + b) /2;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


int main(){
    int n ;
    cin >> n  ;
    vector<char> s(n+1,'.') ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> s.at(i) ;
    }
    
    vector<int> r(n+1,0) ;
    vector<int> g(n+1,0) ;
    vector<int> b(n+1,0) ;
    for (size_t i = 0; i < n; i++)
    {
        if (s.at(i) == 'R')
        {
            r.at(i+1) ++ ;
        }else if (s.at(i) == 'G')
        {
            g.at(i+1) ++ ;
        }else if (s.at(i) == 'B')
        {
            b.at(i+1) ++ ;
        }
        r.at(i+1) += r.at(i) ;
        g.at(i+1) += g.at(i) ;
        b.at(i+1) += b.at(i) ;
    }
    int64_t ans = 0;
    int k ;
    for (size_t i = 0; i < n-2; i++)
    {
        for (size_t j = i+1; j < n-1; j++)
        {
            if (s.at(i) == s.at(j) )
            {
                continue ;
            }
            if ((s.at(i) == 'R' && s.at(j) == 'B') || (s.at(i) == 'B' && s.at(j) == 'R'))
            {
                k = min(2*j-i,n);
                ans += g.at(n) - g.at(j+1) ;
                if (s.at(k) == 'G')
                {
                    ans -- ;
                }
                
            }else if ((s.at(i) == 'G' && s.at(j) == 'B') || (s.at(i) == 'B' && s.at(j) == 'G'))
            {
                k = min(2*j-i,n) ;
                ans += r.at(n) - r.at(j+1) ;
                if (s.at(k) == 'R')
                {
                    ans -- ;
                }
            }else if ((s.at(i) == 'R' && s.at(j) == 'G') || (s.at(i) == 'G' && s.at(j) == 'R'))
            {
                k = min(2*j-i,n) ;
                ans += b.at(n) - b.at(j+1) ;
                if (s.at(k) == 'B')
                {
                    ans -- ;
                }
            }
            
        }
        
    }
    cout << ans << endl ;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define pb push_back
#define ppb pop_back
#define F frist
#define S second

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int N = 1e5 + 667;

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

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

    int n, ans = 0;
    cin >> n;
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=n;j++){
            for(int h = 1;h<=n;h++){
                int g = gcd(j, i);
                g = gcd(g, h);
                ans += g;
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3648
import java.util.ArrayList;

import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	static class Tree{
		List<Tree> children;
		long add;
		public Tree() {
			children = new ArrayList<Tree>();
		}
		void propagate(){
			for(Tree child : children){
				child.add += add;
				child.propagate();
			}
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		Tree nodes[] = new Tree[N];		
		for(int i = 0 ; i < N - 1 ; ++i){
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			if(nodes[a] == null){
				nodes[a] = new Tree();
			}
			if(nodes[b] == null){
				nodes[b] = new Tree();
			}
			nodes[a].children.add(nodes[b]);
		}
		for(int i = 0 ; i < Q ; ++i){
			int p = sc.nextInt() - 1;
			int x = sc.nextInt();
			nodes[p].add += x;
		}
		nodes[0].propagate();
		StringBuilder sb = new StringBuilder();
		for(int i = 0 ; i < N ; ++i){
			if(i > 0){
				sb.append(' ');
			}
			sb.append(nodes[i].add);
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 202872
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N, M;
    cin >> N >> M;
    int ans = 0;

    for(int i = 1; i < N; i++) {
        ans += i;
    }

    for(int i = 1; i < M; i++) {
        ans += i;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
/*
                    NAYEEM
    Information and Communication Engineering ,
            University of Rajshahi
*/
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define uu first
#define vv second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define scd(x) scanf("%lf",&x)

#define pfi(x) printf("%d",x)
#define pfl(x) printf("%lld",x)
#define pfd(x) printf("%lf",x)
#define pfc(x) printf("Case %d: ",x)
#define ps printf(" ")
#define pn printf("\n")
#define pb(x) push_back(x)
#define ppb(x) pop_back(x)
#define pf(x) push_front(x)
#define ppf(x) pop_front(x)
#define in(x,y) insert({x,y})
#define sv(a) sort(a.begin(),a.end())
#define zero(arr,a) memset(arr,a,sizeof arr)
#define mx 1005
#define TestCase int t,cs=1;sci(t);while(t--)

//ll modPower(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
//ll power(ll a,ll b){if(b==0)return 1;ll x=power(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}

int fx[]={0,1,1,1,0,-1,-1,-1};
int fy[]={1,1,0,-1,-1,-1,0,1};



int main()
{
    //IOS
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    /*
        Check Contains Limit && Declear Counter in Long Long
        Check Array Size
    */
    ll a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;



    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define pi acos(-1)
#define eps 0.00000001
using namespace std;
int main(void){
    int a,b,x;
    cin >> a >> b >> x;
    if(x<=a*a*b/2.0){
        printf("%.10f\n",180.0*atan((a*b*b)/(2.0*x))/pi);
    }else{
        printf("%.10f\n",180.0*atan(2.0*(a*a*b-x)/(a*a*a))/pi);
    }
}


Measured memory_bytes: 512
#include<iostream>

int main(){
    
    char c;

    std::cin >> c;

    if(c == 'A'){
        std::cout << 'T' << std::endl;
    }else if(c == 'T'){
        std::cout << 'A' << std::endl;
    }else if(c == 'C'){
        std::cout << 'G' << std::endl;
    }else{
        std::cout << 'C' << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

ll dp[55][55][2610];

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

int main(){
  int N,K;
  cin>>N>>K;

  dp[0][0][0]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=i;j++){
      for(int k=0;k<=K;k++){
        if(dp[i][j][k]==0) continue;

        if(k+2*j<=K) add(dp[i+1][j][k+2*j],dp[i][j][k]);//i-i
        if(j+1<=N&&k+2*(j+1)<=K) add(dp[i+1][j+1][k+2*(j+1)],dp[i][j][k]);//x-x
        if(j>0&&k+2*j<=K) add(dp[i+1][j][k+2*j],2*j*dp[i][j][k]%MOD);//o-x or x-o
        if(j>0&&k+2*(j-1)<=K) add(dp[i+1][j-1][k+2*(j-1)],j*j*dp[i][j][k]%MOD);//o-o
      }
    }
  }

  cout<<dp[N][0][K]<<endl;

  return 0;
}


Measured memory_bytes: 55552
/**
 *   @FileName	d.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.02 21:21:35
**/

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

int main() {
    int n;cin >> n;
    string s;cin >> s;
    int ans = n+1;
    vector<int> sum_r(n+1,0),sum_w(n+1,0);
    for (int i = n; i >= 1; i--) {
        sum_r[i-1] = sum_r[i];
        if (s[i] == 'R') sum_r[i - 1]++;
    }
    for (int i = 0; i < n; i++) {
        sum_w[i + 1] = sum_w[i];
        if (s[i] == 'W') sum_w[i + 1]++;
    }
    for (int i = 0; i <= n; i++) {
        ans = min(ans,sum_r[i]+abs(sum_r[i] - sum_w[i]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5236
#include<iostream>
#include<string>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define repm(i, m, n) for (int i = (m); i < (n); i++)
#define rep_rev(i, n) for (int i = int (n); i >= 0; i--)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	int ans;
	if (n < 10)ans = n;
	else if (10 <= n && n < 100)ans = 9;
	else if (100 <= n && n < 1000)ans = n - 90;
	else if (1000 <= n && n < 10000)ans = 909;
	else if (10000 <= n && n < 100000)ans = n - 9090;
	else if (n == 100000)ans = 90909;
	cout << ans << endl;

	return 0;
}

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

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt();
        final int k = in.nextInt();
        in.nextLine();
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < k; i++) {
            int d = in.nextInt();
            in.nextLine();
            for (int j = 0; j < d; j++) {
                set.add(in.nextInt());
            }
            in.nextLine();
        }
        int res = 0;
        for (int i = 1; i <= n; i++) {
            if (!set.contains(i)) {
                res++;
            }
        }
        System.out.println(res);
    }
}


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

int main(){
    int n,m;
    cin >> n >> m;
    if(m == 0){
        if(n == 1) cout << "0";
        if(n == 2) cout << "10";
        if(n == 3) cout << "100";
    }
    else{
    vector<int> v(n+1);
    rep(i,n+1) v[i] = 100;
    int ans = true;
    rep(i,m){
        int key,vlue;
        cin >> key >> vlue;
        if(v[key] == 100) v[key] = vlue;
        else if(v[key] != vlue){
            ans = false;
        }
    }
    
    if(ans == false) cout << "-1";
    else if(v[1] == 0 && n > 1) cout << "-1";
    else{
        if(v[1] == 100) cout << '1';
        else cout << v[1];
        for(int i = 2;i < n+1;i++){
            if(v[i] == 100) cout << '0';
            else cout << v[i];
        }
    }
  }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

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

    vector<bool> V(1000000, true);
    V[0] = false;
    V[1] = false;

    reps(2, i, sqrt(V.size())+1) {
        skip(j, V.size(), i) {
            if (i == j) continue;
            if (V[j] && j % i != 0) {
                V[j] = true;
            } else {
                V[j] = false;
            }
        }
    }

    rep(i, V.size()) {
        if (V[i] && i >= x) {
            cout << i << endl;
            exit(0);
        }
    }
}


Measured memory_bytes: 384
import sys,math,collections,itertools
input = sys.stdin.readline
graph = []
cnt = 0

N=int(input())
if N%2 == 0:
    
    for i in range(1,N):
        for j in range(i+1,N+1):
            if i+j == N+1:
                continue
            else:
                cnt+=1
                graph.append([i,j])
                
else:
    for i in range(1,N):
        for j in range(i+1,N+1):
            if i + j == N:
                continue
            else:
                cnt+=1
                graph.append([i,j])
print(cnt)
for gr in graph:
    print(*gr)
                


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

int main() {
  
  string S;
  
  cin >> S;
  
  if( S == "Sunny" ) {
    
    cout << "Cloudy" << endl;
    
  } else if( S == "Cloudy" ) {
    
    cout << "Rainy" << endl;
    
  } else if( S == "Rainy" ) {
    
    cout << "Sunny" << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
from math import *
PI = 3.1415926535898
x = "this"
z = "that"
def f(c, n, d):
	k = ((ord(c) - ord('a')) * n + d ) % 26
	return chr(ord('a') + k)
while True:
    try:
    	n = input()
    	for i in range(n):
	        s = str(raw_input())
	        res = ""
	        ans = ""
	        for i in range(26):
	        	for j in range(26):
		            res = ""
		            for a in s:
		                if a.isalpha():
		                    res += f(a, i, j)
		                else:
		                    res += a
		            if res.find(x) >= 0 or res.find(z) >= 0:
		                ans = res
	        print ans
    except EOFError:
        break

Measured memory_bytes: 6376
S = input()

def test(s, count):
    group = set(S[:count+1])
    b = False
    for g in group:
        if all([g in S[i:i+count+1] for i in range(len(S)-count)]):
            b = True
    return b     

# 二分探索
up = 51 # 可能
low = -1 # 不可能
while up > low + 1:
    mid = (up + low) // 2
    if test(S, mid):
        up = mid
    else:
        low = mid
print(up)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

// var rdr = bufio.NewReaderSize(os.Stdin, 100000)
var rdr *bufio.Reader

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	// ABC051B
	k, s := nextInt(), nextInt()

	cnt := 0
	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			z := s - x - y
			if 0 <= z && z <= k {
				cnt++
			}
		}
	}

	ans := cnt
	fmt.Println(ans)
}

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

func readLine() string {
	buf := make([]byte, 0, 100000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextI64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func maxi64(a int64, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func updateMax(a *int, b int) {
	if *a < b {
		*a = b
	}
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func mini64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func updateMin(a *int, b int) {
	if *a > b {
		*a = b
	}
}

func absi64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>L(N); rep(i, 0, N) { cin >> L[i]; }
	auto m = max_element(all(L))-L.begin();
	int s = 0;
	rep(i, 0, N) {
		if (i != m)s += L[i];
	}
	Yes(L[m] < s);

	return 0;
}


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

int main(){
    int k,n; cin >> k >> n;
    vector<int> A(n);

    rep(i,n){
        cin >> A[i];
    }
    int m = 0;
    sort(A.begin(),A.end());
    for(int i=n; i>0;i--){
        m = max(m,A[i]-A[i-1]);
    }

    m = max(m,k+A[0]-A[n-1]);

    cout << k-m << endl;
    
}


Measured memory_bytes: 1152
import java.util.*;

public class Main {
    public static void main(String[] args) {
//        test();
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] arrayA = new long[N];
        long[] arrayB = new long[N];

        for (int i = 0; i < N; i++) {
            arrayA[i] = sc.nextLong();
            arrayB[i] = sc.nextLong();
        }

        System.out.println(calc(arrayA, arrayB));
    }

    private static long calc(long[] arrayA, long[] arrayB) {
        int ind = arrayA.length - 1;
        long a, b, inc;
        long count = 0;
        while (ind >= 0) {
            a = arrayA[ind] + count;
            b = arrayB[ind];
            if (a % b == 0) {
                inc = 0;
            } else {
                long d = a / b;
                inc = b-(a-b*d);
            }
            count += inc;

            ind--;
        }
        return count;
    }


    private static void test() {
        assert calc(new long[] {3,2,9}, new long[] {5,7,4}) == 7;
        assert calc(new long[] {3,4,5,2,5,5,9}, new long[] {1,1,9,6,3,8,7}) == 22;
    }
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}


template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};




int main(){

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

    int n, m, X, Y;
    cin >> n >> m >> X >> Y;

    int x[n];
    int y[m];
    rep(i, n){
        cin >> x[i];
    }
    rep(i, m){
        cin >> y[i];
    }

    bool war = true;
    for(int z = max(X+1,*max_element(x, x+n)+1); z <= Y; z++){
        bool ok = true;
        for(int i = 0; i < m; ++i){
            if(y[i] < z) ok = false;
        }
        if(ok){
            war = false;
            break;
        }
    }


    if(war)
        ppp("War");
    else
        ppp("No War");

    return 0;



}


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

int main(void){
  ll N, Q, S, T; cin >> N >> Q >> S >> T;
  vector<ll> A(N+1);
  vector<ll> B(N);
  for(ll i = 0; i <= N; i++){
    cin >> A[i];
  }

  for(ll i = 1; i <= N; i++){
    B[i-1] = A[i] - A[i-1];
  }
  

  ll ans = 0;
  for(int i = 0; i < N; i++){
    if(B[i] > 0){
      ans -= B[i]*S;
    }else{
      ans -= B[i]*T;
    }
  }

  for(int i = 0; i < Q; i++){
    ll l, r, x;
    cin >> l >> r >> x;
    l--;

    if(B[l] > 0)
      ans += B[l]*S;
    else
      ans += B[l]*T;

    if(r != N){
      if(B[r] > 0)
        ans += B[r]*S;
      else
        ans += B[r]*T;
    }

    B[l] += x;
    if(r != N)
      B[r] -= x;
    if(B[l] > 0){
      ans -= B[l]*S;
    }else{
      ans -= B[l]*T;
    }

    if(r != N){
      if(B[r] > 0){
        ans -= B[r]*S;
      }else{
        ans -= B[r]*T;
      }
    }

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

Measured memory_bytes: 6008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i= 0;i<n;i++){
    cin >> a[i];
    }
  vector<long long> b(n);
 if(n%2 == 0){
  for(int i= 0;i<=n/2 - 1;i++){
      b[i] = a[n-1-2*i];
    }
  for(int i= n/2;i<n;i++){
      b[i] = a[2*i - n];
    }
 }
  else{
    for(int i = 0;i<=n/2;i++){
      b[i] = a[n-1-2*i];
    }
    
    for(int i = n/2 + 1;i<n;i++){
      b[i] = a[2*i - n];
    }
  }
  for(int i= 0;i<n;i++){
    cout << b[i] <<" " ;
  }
}

Measured memory_bytes: 5248