akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
	ll a,b;
};
vector<node> c;
vector<ll> d;
ll dp[200005][40]={0};
bool cmp(struct node a1,struct node a2)
{
	return (a1.b+1)*a2.a<(a2.b+1)*a1.a; 
}
int main(void)
{
	ll sum=0;
	ll n,t;
	ll nc=0;
	scanf("%lld%lld",&n,&t);
	c.push_back((struct node){0,0});
	for(ll i=0;i<n;i++)
	{
		ll a1,b1;
		scanf("%lld%lld",&a1,&b1);
		if(a1==0)
		{
			d.push_back(b1);
		}
		else
		{
			c.push_back((struct node){a1,b1});
		}
	}
	sort(d.begin(),d.end());
	sort(c.begin()+1,c.end(),cmp);
	for(ll i=1;i<40;i++)
	{
		dp[0][i]=t+1;
	}
	for(ll i=1;i<c.size();i++)
	{
		for(ll j=1;j<40;j++)
		{
			dp[i][j]=min(dp[i-1][j],dp[i-1][j-1]+1+(dp[i-1][j-1]+1)*c[i].a+c[i].b);
//			printf("%lld ",dp[i][j]);
		}
//		printf("\n");
	}
	ll ans=0;
	for(ll i=0;i<40;i++)
	{
//		printf("%lld ",dp[c.size()-1][i]);
		if(dp[c.size()-1][i]<=t)
		{
			ans=max(ans,i);
			sum=0;
			for(ll j=0;j<d.size();j++)
			{
				sum+=d[j]+1;
	//			printf("%lld %lld\n",d[j],sum);
				if(dp[c.size()-1][i]+sum<=t)
				{
					ans=max(ans,i+j+1);
				}
			}
		}
	}
	printf("%lld",ans);
}

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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'




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


const int MOD = 1000000007;

//////////////////////////////////////////


double w, h, x, y;
void Input() {

    cin >> w >> h >> x >> y;
}



void Solve() {


    cout << (w * h) / 2 << " " << (x+x == w && y+y == h) << endl;

}

int main() {

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


  return 0;

}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#define all(x) x.begin(),x.end()

using namespace std;

int main()
{  
   long long a,b;cin>>a>>b;
   if((a+b)%2==0)cout<<(a+b)/2<<endl;
   else cout<<"IMPOSSIBLE";
  
   
} 

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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}

string tmp;
int N;
ll people[5];

int main(){
  cin>>N;
  REP(N){
    cin>>tmp;
    switch (tmp[0]) {
      case 'M':
        people[0]++;
        break;
      case 'A':
        people[1]++;
        break;
      case 'R':
        people[2]++;
        break;
      case 'C':
        people[3]++;
        break;
      case 'H':
        people[4]++;
        break;
    }
  }
  ll ans=0;
  for (int i = 0; i < 5; i++) {
    for (int j = i+1; j < 5; j++) {
      for (int k = j+1; k < 5; k++) {
        ans+=people[i]*people[j]*people[k];
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX
#define MAX_N 1000000001

int n, m;
P treasure[5000];

int main(){
    cin.sync_with_stdio(false);
    cin >> n >> m;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        treasure[i] = P(x, y);
    }
    sort(treasure, treasure + n);

    rep(i, m) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int up = upper_bound(treasure, treasure + n, P(x2, INF)) - treasure;
        int low = lower_bound(treasure, treasure + n, P(x1, -INF)) - treasure;
        int cnt = 0;
        repl(j, low, up) {
            if (y1 <= treasure[j].se && treasure[j].se <= y2) cnt++;
        }
        cout << cnt << endl;
    }

    return 0;
}

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

const int sz=20;
int n;
vector<vector<pair<int, int > > > g(sz);

template<typename T> inline void chmax(T &a, T b){if(a<b)a=b;}

main()
{
    int ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int a;
        scanf("%d",&a);

        while(a--)
        {
            int b,c;
            scanf("%d%d",&b,&c);
            g[i].emplace_back(make_pair(b,c));

        }
    }

    for(int mask=0;mask<(1<<n);mask++)
    {
        bool ok=1;

        int cnt=0;
        for(int i=0;i<n;i++)if((mask >> i)&1)cnt++;

        for(int i=0;i<n;i++)
        {
            if((mask >> i) & 1)
            {
                for(int j=0;j<g[i].size();j++)
                {
                    int x=g[i][j].first - 1,y=g[i][j].second;

                    if(((mask >> x) & 1) != y)
                    {
                        ok=0;
                        break;
                    }
                }
            }
        }

        if(ok)chmax(ans,cnt);
    }

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

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

int main()
{
	int N,M,X,Y,i,temp;
	cin>>N>>M>>X>>Y;
	vector<int> x,y;
	for(i=0;i<N;i++){
		cin>>temp;
		x.push_back(temp);
	}
	for(i=0;i<M;i++){
		cin>>temp;
		y.push_back(temp);
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	if(x.at(N-1)>=y.at(0)){
		cout<<"War";
	}else if((x.at(N-1)<Y)&&(y.at(0)>X)){
		cout<<"No War";
	}else{
		cout<<"War";
	}
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

ans =''
ans += 'R'*dx + 'U'*dy
ans += 'L'*dx + 'D'*dy
ans += 'D' + 'R'*(dx+1) + 'U'*(dy+1) + 'L'
ans += 'U' + 'L'*(dx+1) + 'D'*(dy+1) + 'R'

print(ans)

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

using namespace std;

#define debug(x) cout << #x << "::" << x << endl;
#define debug2(x, y) cout << #x << "::" << x << " " << #y << "::" << y << endl;
#define debug3(x, y, z) cout << #x << "::" << x << " " << #y << "::" << y <<" "<< #z << "::" << z << endl;

#define For(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
const ll mod = 1e9 + 7;
const int MAX = 5 * 1e3 + 5;
typedef pair<int, int> pii;

void add(ll &a, ll b)
{
    a = (a + b) % mod;
    if (a < 0) a += mod;
}

int main() {

    int n,k;
    cin>>n>>k;

    vector<int> a(n+1);
    For(i,1,n+1) cin>>a[i];

    vector<ll> dp(k+1);
    dp[0] = 1;
    For(child,1,n+1){
        
        vector<ll> temp(k+1);
        for(int used=k;used>=0;used--){
            int l = used + 1;
            int r = used + min(k-used,a[child]);

            if(l <= r) {
                temp[l] = dp[used];
                if(r+1<=k) add(temp[r+1],-dp[used]);
            }
        }
        ll preSum = 0;
        For(i,0,k+1){
            add(preSum,temp[i]);
            add(dp[i],preSum);
        }
    }

    cout<<dp[k]<<endl;

    return 0;

}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  bool flag = true;
  rep(i, n) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0) {
        flag = false;
      }
    }
  }
  if (flag)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
  return 0;
}


Measured memory_bytes: 256
from sys import stdin
n = int(stdin.readline().rstrip())
b = list(map(int, stdin.readline().rstrip().split()))
b.append(float('inf'))
res = []
for i in range(n-1, -1, -1):
    if i != 0:
        res.append(min(b[i], b[i-1]))
    else:
        res.append(b[i])
print(sum(res))

Measured memory_bytes: 3060
#include <stdio.h>
int n;
long long a[80];
long long xx, yy, zz, x, y, z;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
	}
	x = 1000;
	y = 1000;
	for (int i = 0; i < n; i++) {
		xx = x; yy = y; zz = z;
		if (x < yy + zz * a[i])x = yy + zz * a[i];
		if (xx / a[i] > zz) {
			z = xx / a[i];
			y = xx - z * a[i];
		}
		if (xx / a[i] == zz && xx - zz * a[i] > yy) {
			y = xx - zz * a[i];
		}
	}
	printf("%lld\n", x);
}

Measured memory_bytes: 1732
package main

import (
	"bufio"
	"fmt"
	"os"
	"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
	}
}

// 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
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	indx := partition(A, 0, N-1)

	for i := 0; i < N; i++ {
		if i != 0 {
			fmt.Fprint(wtr, " ")
		}
		if i == indx {
			fmt.Fprint(wtr, "[", A[i], "]")
		} else {
			fmt.Fprint(wtr, A[i])
		}
	}
	fmt.Fprintln(wtr)
	wtr.Flush()
}

func partition(A []int, p, r int) int {
	x := A[r]
	i := p - 1
	for j := p; j < r; j++ {
		if A[j] <= x {
			i = i + 1
			A[i], A[j] = A[j], A[i]
		}
	}
	A[i+1], A[r] = A[r], A[i+1]
	return i + 1
}



Measured memory_bytes: 3164
#include <iostream>

using namespace std;

int main(){

  int N, C[500]={} ,S[500]={},F[500]={};

  cin >> N;

  for(int i = 0; i < N-1; i++){
    cin >> C[i] >> S[i] >> F[i];
  }

  for(int i = 0; i < N-1; i++){
    int sum = S[i]+C[i];
    for(int j = i+1; j < N-1;j++){
      if(sum < S[j]){
	sum = S[j];
      }
      else if(sum%F[j]!=0){
	sum += F[j] - sum%F[j];
      }
      sum += C[j];
    }
    cout << sum << "\n";
  }

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


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()

import collections
d = collections.Counter(a)

if -(-max(a)//2) != min(a):
    print("Impossible")
    exit()

if max(a)%2==0:
    if d[min(a)]!=1:
        print("Impossible")
        exit()
else:
    if d[min(a)]!=2:
        print("Impossible")
        exit()

for num in range(min(a)+1,max(a)+1):
    if d[num]<2:
        print("Impossible")
        exit()

print("Possible")

Measured memory_bytes: 38448
import com.sun.org.apache.xpath.internal.operations.Bool

fun main(args: Array<String>) {
    val N = nextInt()
    fun c753(s: String): Int {
        if (s.length > 0 && s.toLong() > N) return 0
        val f = BooleanArray(10)
        s.forEach { f[it - '0'] = true }
        var count = if (f[7] && f[5] && f[3]) 1 else 0
        for (c in "753") count += c753(s + c)
        return count
    }
    val ans = c753("")
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map(String::toLong)
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta

fun number2Array(N: Int): IntArray {
    var n = N
    val result = mutableListOf<Int>()
    if (n <= 0) {
        result.add(0)
        return result.toIntArray()
    }
    while (n > 0) {
        result.add(n % 10)
        n /= 10
    }
    return result.reversed().toIntArray()
}

Measured memory_bytes: 38540
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void){
    int A,B,X;
    scanf("%d %d %d",&A,&B,&X);
    if(A<=X&&X<=A+B){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void){
  int x,y;
  int k=4;
  int t=2;
  int i,j;
  int n=5;
  scanf("%d",&x);
  scanf("%d",&y);

  for(i=0;i<26;i++){
    for(j=0;j<51;j++){
      
      if(i*k+j*t==y&&i+j==x){
        printf("Yes");
        n=1;
        break;
      }
      }
  }
  if(n!=1){
    n=0;
  }
  if(n==0)
   printf("No");
  return 0;
  }

Measured memory_bytes: 1700
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,L[100],ans=0;
	bool flag;
	cin>>N;
	for(int i=0;i<N;i++)cin>>L[i];
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			for(int k=j+1;k<N;k++){
				flag=true;
				flag&=L[i]!=L[j];
				flag&=L[j]!=L[k];
				flag&=L[k]!=L[i];
				flag&=L[i]+L[j]>L[k];
				flag&=L[j]+L[k]>L[i];
				flag&=L[k]+L[i]>L[j];
				if(flag)ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;

namespace ALDS1_5A
{
    class Program
    {
        static void Main()
        {
            Console.ReadLine();

            var a = Array.ConvertAll(
                Console.ReadLine().Split(' '),
                e => int.Parse(e)
            );

            Console.ReadLine();

            var b = Array.ConvertAll(
                Console.ReadLine().Split(' '),
                e => int.Parse(e)
            );

            for (var i = 0;; i++)
            {
                var pat = Convert.ToString(i, 2)
                    .PadLeft(a.Length, '0');
                if (pat.Length > a.Length) break;
                var sum = 0;
                for (var j = 0; j < pat.Length; j++)
                    sum += pat[j] == '0' ? 0 : a[j];
                
                while (Array.Exists(b, delegate(int t) { return t == sum; }))
                    b[Array.IndexOf(b, sum)] = -1;
            }

            foreach (var c in b)
                Console.WriteLine(c < 0 ? "yes" : "no");
        }
    }
}


Measured memory_bytes: 9684
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;
int n;
vector<long long> a(100100, 0);

int main() {
    cin >> n;
    int mcnt = 0;
    int mno = 0;
    int mmm = INF;
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
        if(a.at(i) < 0) mcnt++;
        if(abs(a.at(i) - 0) < mmm) {
            mno = i;
            mmm = abs(a.at(i) - 0);
        }
    }

    long long ans = 0;
    for(int i = 0; i < n; ++i) {
        ans += abs(a.at(i) - 0);
    }

    if(mcnt % 2 != 0) {
        ans -= abs(a.at(mno) - 0) * 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
#define MAX 20
#define H 5
#define N 10

int n, minw;
char P[H][MAX], B[H][MAX*N];

bool invalid(int p){
    rep(i, H) rep(j, n){
	if ( P[i][j] == 'X' && B[i][j+p] != '.' ) return true;
    }
    return false;
}

void setTask(int p, char ch){
    rep(i, H) for ( int j = p; j < p+n; j++ ){
	if ( P[i][j-p] == 'X' )	B[i][j] = ch;
    }
}

void rec( int pos, int last){
    if ( pos == N ){ minw = min(minw, last+n); return; }
    if ( minw <= last+n-1 + (n-pos) ) return;
    for ( int j = last+1; j <= last+n; j++ ){
	if ( invalid(j) ) continue;
	setTask(j, 'X');
	rec(pos+1, j);
	setTask(j, '.');
    }
}

void init(){
    minw = (1<<21);
    rep(i, H) rep(j, MAX*N) B[i][j] = '.';
}

main(){
    while ( cin >> n && n ){
	rep(i, H) rep(j, n) cin >> P[i][j];
	init();
	rec(0, -1);
	cout << minw << endl;
    }
}

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

#define int ll
#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define pb push_back
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
constexpr int inf = 1ll<<61;

struct edge {
  ll to, d;
  edge(ll _to, ll _d):to(_to),d(_d){}
};
class dijkstra{
public:
  ll ans;

  dijkstra(ll s,ll t,vector<vector<edge>> &g,vector<vector<edge>> &f){ // sからtへの最短経路
    vector<vector<vector<edge>>> G(2);
    G[0] = move(g);
    G[1] = move(f);
    vvi dist(2,vi(G[0].size(),inf));
    vector<vector<bool>> visit(2,vector<bool>(G[0].size(),false));
  
    vector<priority_queue<pii,vector<pii>,greater<pii>>> que(2);
    que[0].push(pii(0,s));
    que[1].push(pii(0,t));
    dist[0][s] = 0;
    dist[1][t] = 0;
    ll mu = inf;

    while(!que[0].empty() and !que[1].empty()){
      if(que[0].top().first + que[1].top().first >= mu) break;
      ll k = (que[0].top().first > que[1].top().first)?0:1; 
      ll v = que[k].top().second, d = que[k].top().first;
      que[k].pop();

      if(visit[k^1][v]) goto L;
      visit[k][v] = true;

      rep(i, G[k][v].size()){
	auto n = G[k][v][i];
	ll tmp = d + n.d;
	if(dist[k][n.to] > tmp){
	  mu = min(mu, dist[k][v] + n.d + dist[k^1][n.to]);
	  dist[k][n.to] = tmp;
	  que[k].push(pii(tmp,n.to));
	}
      }
    }
  L:
    g = move(G[0]);
    f = move(G[1]);

    ans = inf;
    rep(i,g.size()) ans = min(ans, dist[0][i]+dist[1][i]);
  }
};

main(){
  int k; cin >> k;
  vector<vector<edge>> g(k),f(k);
  rep(i,k){
    g[i].pb(edge((i+1)%k,1));
    g[i].pb(edge((i*10)%k,0));
    
    f[(i+1)%k].pb(edge(i,1));
    f[(i*10)%k].pb(edge(i,0));
  }
  dijkstra d(1,0,g,f);
  cout << d.ans+1 << endl;
}

Measured memory_bytes: 18416
import math


# 最大公約数gcd,
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


# 最小公倍数lcm
def lcm(a, b):
    return (a * b) // gcd(a, b)


a, b, c, d = (int(i) for i in input().split())

cd = lcm(c, d)
r = b - a + 1

min_c = a // c + (1 if a % c != 0 else 0)
max_c = b // c
min_d = a // d + (1 if a % d != 0 else 0)
max_d = b // d
min_cd = a // cd + (1 if a % cd != 0 else 0)
max_cd = b // cd

c_num = max_c - min_c + 1
d_num = max_d - min_d + 1
cd_num = max_cd - min_cd + 1

print(r - c_num - d_num + cd_num)

Measured memory_bytes: 38512
n = int(input())
a = [0] + [int(i) for i in input().split()] + [0]
d1a = [abs(a[i + 1] - a[i]) for i in range(n + 1)]
d2a = [abs(a[i + 1] - a[i - 1]) for i in range(1, n + 1)]
sum_a = sum(d1a)
for i in range(1, n + 1):
    print(sum_a + d2a[i - 1] - (d1a[i - 1] + d1a[i]))

Measured memory_bytes: 16704
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.Caddi2018
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            bool first = false;
            for(int i = 0; i < n; i++)
            {
                int a = ReadInt();
                if (a % 2 == 1)
                {
                    first = true;
                }
            }
            if (first)
            {
                Console.WriteLine("first");
            }
            else
            {
                Console.WriteLine("second");
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 15184
//#pragma GCC optimize ("O3")
//#pragma GCC target ("tune=native")
//#pragma GCC target ("avx")
//#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);

#define N 100010
ll n;
ll a[N];

int main(){
	INIT;
	cin>>n;
	rep(i, n) cin>>a[i+1];
	ll sum = 0;
	rep(i, n+1) sum += abs(a[i+1]-a[i]);
	rep(i, n){
		ll res = sum-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i+2]-a[i]);
		cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 2048
import sys
from itertools import accumulate

input = sys.stdin.readline


def solve(H, W, D, A, Q, LR):
    position = [None] * (H * W + 1)
    for h in range(H):
        for w in range(W):
            position[A[h][w]] = (h, w)

    mp = [0] * (H * W + 1)

    for i in range(1, H * W + 1 - D):
        h, w = position[i]
        y, x = position[i + D]
        mp[i + D] = abs(x - w) + abs(y - h)

    for d in range(1, D + 1):
        mp[d::D] = list(accumulate(mp[d::D]))

    ans = [mp[r] - mp[l] for l, r in LR]
    ans = "\n".join(map(str, ans))
    return ans


def main():
    H, W, D = map(int, input().split())
    A = [None] * H
    for i in range(H):
        A[i] = tuple(map(int, input().split()))
    Q = int(input())
    LR = [None] * Q
    for i in range(Q):
        LR[i] = tuple(map(int, input().split()))

    ans = solve(H, W, D, A, Q, LR)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 48140
n,k,rest=map(int,input().split())
s=input()

last=-3000000
l1=[]
l2=set()
for i,c in enumerate(s):
    if last+rest<i and c=="o":
        last=i
        l1.append(i)
last=6000000
for i,c in enumerate(reversed(s)):
    if n-1-i<last-rest and c=="o":
        last=n-1-i
        l2.add(n-1-i)

if len(l1)!=k:
    print()
else:
    for i in l1:
        if i in l2:
            print(i+1)

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

int main(){
  ll a, b;
  cin >> a >> b;
  if((a+b)%2) cout << "IMPOSSIBLE" << endl;
  else cout << (a+b)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/**************************************************************************/
signed main()
{
    int n;
    cin>>n;
    ld ans = 0;
    for(int i=0;i<n;i++)
    {
        ld x;
        cin>>x;
        ans+=((ld)1/x);
    }
    ans = (ld)1/ans;
    cout<<fixed<<setprecision(12)<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    sort(h,h+n);
    long long ans=0;
    for(int i=0;i<n-k;i++)
        ans+=h[i];
    cout<<ans<<endl;
}

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

int main(){
    int r;
    double ans;
    cin >> r;
    ans = r * 2.0 * 3.14;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3760
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long LL;

#define y0 Sword_Art_Online
#define y1 Your_lie_in_April
#define yn Darling_in_the_Franxx
#define tm Plastic_Memories
#define lr Charlotte
#define norm Weathering_with_you
#define left Violet_Evergarden
#define have Date_a_live
#define ends Your_name
#define prev Five_centimeters_per_second
#define hash Slient_voice

#define ordered_set tree<LL, null_type, less<LL>, rb_tree_tag, tree_order_statistics_node_update>
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

LL Rand(LL l, LL h){
    return uniform_int_distribution<LL>(l, h)(rng);
}

template <typename T> void read(T &t){
    t = 0; char ch = getchar(); int f = 1;
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    do { (t *= 10) += ch - '0'; ch = getchar(); } while (isdigit(ch)); t *= f;
}

const LL MaxN = 1 + 1e5;

LL n, a[MaxN], m;

LL GCD(LL x, LL y){
    if(x < y) swap(x, y);
    while(y){
        LL tg = y;
        y = x % y;
        x = tg;
    }
    return x;
}

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    cout << n * m / GCD(n, m) << endl;

    return 0;
}

Measured memory_bytes: 256
local mod = 1000000007
local mfl = math.floor

local function bmul(x, y)
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  local x0, y0 = x - x1 * 31623, y - y1 * 31623
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res
end

local function modinv(src)
  return modpow(src, mod - 2)
end


local fact = {1}
local invs = {1}
local invfact = {1}
for i = 2, 100010 do
  fact[i] = bmul(fact[i - 1], i)
  invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])
  invfact[i] = bmul(invfact[i - 1], invs[i])
end

local function getPerm(n, k)
  if n == 0 then return 1 end
  if k == n then return fact[n] end
  return bmul(fact[n], invfact[n - k])
end

local function comp(a, b)
  return a < b
end

local function lower_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if not comp(ary[1], x) then return 1 end
  if comp(ary[num], x) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if comp(ary[mid], x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local function upper_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if comp(x, ary[1]) then return 1 end
  if not comp(x, ary[num]) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if not comp(x, ary[mid]) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local n, x = io.read("*n", "*n")
local s = {}
local tbl = {}
for i = 1, n do
  s[i] = io.read("*n")
  tbl[i] = {}
end
table.sort(s)
for i = n, 1, -1 do
  local rem = x % s[i]
  if 0 < rem then
    tbl[i][rem] = getPerm(n - 1, n - i)
  end
end
local ret = 0
for src = n, 2, -1 do
  for val, cnt in pairs(tbl[src]) do
    local ub = upper_bound(s, val)
    if ub == 1 then
      ret = badd(ret, bmul(val, bmul(fact[src - 1], cnt)))
    else
      local skipfact = getPerm(src - 1, src - ub)
      cnt = bmul(cnt, skipfact)
      for dst = ub - 1, 1, -1 do
        local vc = bmul(cnt, getPerm(ub - 2, ub - 1 - dst))
        local rem = val % s[dst]
        if 0 < rem then
          if tbl[dst][rem] then
            tbl[dst][rem] = badd(tbl[dst][rem], vc)
          else
            tbl[dst][rem] = vc
          end
        end
      end
    end
  end
end
for val, cnt in pairs(tbl[1]) do
  ret = badd(ret, bmul(val, cnt))
end
print(ret)


Measured memory_bytes: 9712
from collections import deque

h,w = map(int,input().split())
INF = 114514191981036436433-4

c = [None]*h
for i in range(h):
    c[i] = input()
            
dx = [1,0,-1,0]
dy = [0,1,0,-1]

ans = 0
for i in range(h):
    for j in range(w):
        if c[i][j] == "#":
            continue
        
        d = [[INF for i in range(w)] for j in range(h)]
        e = [[0 for i in range(w)] for j in range(h)]

        dx = [1,0,-1,0]
        dy = [0,1,0,-1]

        d[i][j] = 0
        que = deque([[i,j]])

        while que:
            y,x = que.popleft()

            for k in range(4):
                nx = x + dx[k]
                ny = y + dy[k]

                if 0<=nx and nx<w and 0<=ny and ny<h and c[ny][nx] != '#':
                    if d[ny][nx] > d[y][x]+1:
                        d[ny][nx]=d[y][x]+1
                        e[ny][nx] = d[ny][nx]
                        que.append([ny,nx])
                        
        tmax = 0
        for l in range(h):
            tmax = max(tmax,max(e[l]))
        ans = max(ans,tmax)
        
print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  int b = 0 ;
  for(int i=0;i<N;i++){
    
    if(i%2==0){
      b += a.at(i);
    }else
      b -= a.at(i);
  }
  cout << b << endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d %d",$m,$d);

$cnt=0;

if($d<20 || $m<4){
	
}else{
	for($i=4;$i<=$m;$i++){
		for($j=21;$j<=$d;$j++){
			$a=intval(substr($j,0,1));
			$b=intval(substr($j,1,1));
			//echo $atai."\r\n";
			if($i==$a*$b && $a<>1 && $b<>1){
				//echo $i."-".$a."-".$b."\r\n";
				$cnt++;
			}
		}
	}
}
echo $cnt;
?>

Measured memory_bytes: 4728
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

s,t,u = input().split()
ans = s[0].upper() + t[0].upper() + u[0].upper()
print(ans)

Measured memory_bytes: 3316
#include<iostream>
using namespace std;
int b[4];
int main(){
	int a;
	for(int i=0;i<6;i++){
		cin>>a;
		b[a-1]++;
	}
	for(int i=0;i<4;i++){
		if(b[i]==0 || b[i]==3){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  int sum=0,res=0;
  rep(i,n){
    cin>>a[i];
    b[i]=abs(a[i]);
    if(a[i]<0) res++;
    sum+=b[i];
  }

  sort(all(b));

  if(res%2==0||b[0]==0){
    cout<<sum<<endl;
  }else{
    cout<<sum-b[0]*2<<endl;
  }

}


Measured memory_bytes: 1792
S = input()
flag = True
if S[0] != 'A':
  flag = False
elif S[2:-1].count('C') != 1:
  flag = False
else:
  for s in S[1:]:
    if s not in 'abcdefghijklmnopqrstuvwxyzC':
      flag = False
      break
if flag:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n, ans = 0;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 1; i < n; ++i) {
        string x = s.substr(0, i), y = s.substr(i, n-i+1);
        int k = 0;
        for (char j = 'a'; j <= 'z'; ++j) {
            if(x.find(j) != string::npos && y.find(j) != string::npos) k++;
        }
        ans = max(k, ans);
    }
    cout << ans << "\n";
    return 0;
}


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

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

using namespace std;

class union_find{
	int n;
	vector<int> a;
public:
	union_find(int N):a(N,-1),n(N){}
	int find(int x){
		if(a[x]<0) return x;
		return a[x]=find(a[x]);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x!=y){ a[x]+=a[y]; a[y]=x; n--; }
	}
	int size(){ return n; }
	int size(int x){ return -a[find(x)]; }
};

int main(){
	int n,m; scanf("%d%d",&n,&m);

	union_find U(n);
	rep(i,m){
		int u,v; scanf("%d%d%*d",&u,&v); u--; v--;
		U.unite(u,v);
	}

	printf("%d\n",U.size());

	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>

int N, aver, sum = 0, result = 0;

int main() {
    scanf("%d", &N);
    int a[N];
    for(int i=0; i<N; i++) {
    	scanf("%d", &a[i]);
    	sum += a[i];
    }
    aver = round(1.0 * sum / N);
    for(int i=0; i<N; i++) {
    	result += pow(aver-a[i], 2);
    }
    printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 384
#include <cmath>
#include <fstream>
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

#define REP(i, x, n) for(int i = x, i##_len=(n); i < i##_len; i++)
#define rep(i,n) REP(i,0,n)
// #define DEBUG 3

void run() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (s.at(i) == ',') s.at(i) = ' ';
	}

	cout << s << endl;
}

int main() {
#ifdef DEBUG
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
	rep(i, DEBUG) {
		cout << "cnt:" << i << " ------------" << endl;
		run();
	}
#else
	run();
#endif
	return 0;
}


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

using namespace std;
#define int            long long
#define f(i,n)        for(int i=0;i<(n);++i)
#define fa(i,a,n)     for(int i=a;i<=(n);++i)
#define fd(i,a,n)     for(int i=a;i>=(n);--i)
#define tc 			  int t;cin>>t;f(testcase,t)
#define pii             pair<int,int>
void c_p_c() {

	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

}
#define M 1000000007
int modexp(int x, int n)
{
	if (n == 0)
		return 1;
	else if (n % 2 == 0)
		return modexp((x * x) % M, n / 2);
	else
		return (x * modexp((x * x) % M, (n - 1) / 2)) % M;

}

int ha[100001];
int32_t main() {

	c_p_c();
	int n;
	cin >> n;
	int a[n];
	memset(ha, 0, sizeof(ha));
	f(i, n)
	{
		cin >> a[i];
		ha[a[i]]++;
	}
	if (n % 2 == 0) {
		bool flag = 1;
		f(i, n)
		if (ha[a[i]] != 2)
		{
			flag = 0;
			break;
		}
		if (flag == 0)
			cout << "0";
		else
			cout << modexp(2, n / 2);
	}

	else {
		if (ha[0] != 1)
		{
			cout << "0";
			ha[0] = 2;
			return 0;
		}
		else
			ha[0] = 2;
		bool flag = 1;
		f(i, n) {
			if (ha[a[i]] != 2)
			{
				flag = 0;
				break;
			}
		}
		if (flag == 0)
			cout << "0";
		else
			cout << modexp(2, (n - 1) / 2);

	}



	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main (){
  int a,b,c,i,j,v,N;
  
    
    scanf("%d",&N);
    int A[N];
    for(b=0;b<N;b++){
      scanf("%d",&A[b]);
    }
 for(a=0;a<N;a++){
    if(a==N-1){  
      printf("%d\n",A[a]);
    }
    else{
      printf("%d ",A[a]);
 }
 }
  
    for(i=1;i<N;i++){
      v=A[i];
      j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
    for(c=0;c<N;c++){
    if(c==N-1){
printf("%d\n",A[c]);
    }
    else{
      printf("%d ",A[c]);
	   
    }
    }
    }
    return 0;
  }

 
  
  
    
  



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
const int maxn = 210;
int n, ans = 0, a[maxn];
bool mrk;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	while (1) {
		mrk = true;
		for (int i = 1; i <= n; i++) {
			if (a[i] % 2) {
				mrk = false;
				break;
			} 
			a[i] /= 2;
		}
		if (mrk) ans++;
		else break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func scanLine(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&r[i])
	}
	return r
}

func main() {
	var N, M, C int
	fmt.Scanln(&N, &M, &C)

	b := scanLine(M)

	result := 0
	for i := 0; i < N; i++ {
		a := scanLine(M)

		total := 0
		for j := range a {
			total += a[j] * b[j]
		}
		total += C
		if total > 0 {
			result++
		}
	}

	fmt.Println(result)
}


Measured memory_bytes: 512
N=int(input())
aalist=list(map(int,input().split()))
alist=sorted(aalist, reverse=True)
ans=alist[0]
s=0
if N%2==0:
    for i in range(1,(N-2)//2+1):
        ans+=2*alist[i]
elif N==3:
    ans+=alist[1]
else:
    for i in range(1,(N-3)//2+1):
        ans+=2*alist[i]
    ans+=alist[(N-3)//2+1]
print(ans)


Measured memory_bytes: 31600
#include<stdio.h>
#include<string.h>
int a[4][2]={1,0,0,1,-1,0,0,-1};
int b[500][500];
int sum=0;
char s[500][500];
int c[15];
int n,m;
bool check(int x,int y)
{
    if(x<0||y<0||x>=n||y>=m)
        return false;
    return true;
}
void dfs(int deep)
{

}
int main()
{


    while(~scanf("%d",&n))
    {
        while(n--)
        {
            for(int i=0;i<10;i++)
                scanf("%d",&c[i]);
            int ani=0,ans=0;
            int i=0;
            int temp=0;
            while(i!=10)
            {
                if(c[i]>ani)
                {
                    ani=c[i];
                }
                else if(c[i]>ans)
                {
                    ans=c[i];
                }
                else
                {
                    temp=1;
                }
                i++;
            }
            if(temp==0)
                puts("YES");
            else
                puts("NO");
        }
    }
    return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int mod = 1e9 + 7;
const int inf = 2e9 + 5;
const int N = 1e4 + 5;



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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int sum;
    if (k <= a) sum = k;
    else {
        sum = a;
        k -= a;
        k -= b;
        if (k > 0)
            sum -= k;
    }

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

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
const int maxn = 10010;


int main(){
	long long n,a,b;
	long long cnt = 0;
	cin >> n >> a >> b;
	//scanf("%lld%lld%lld",&n,&a,&b);
	if(a > b) cnt = 0;
	else if(n==1&& a != b) cnt = 0;
	//else if(n==1&& a == b) cnt = 1;
	else{
		long long l = (n-1)*a+b;
		long long r = a+(n-1)*b;
		cnt = r-l+1; 
		//cnt = (n-2)*(b-a)+1;
	}
	//printf("%lld\n",cnt);
cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  int last;
  vi n(3000, -1), x(3000, -1);
  for(int i = 0;; i++){
    cin >> n.at(i) >> x.at(i);
    if(n.at(i) == 0 && x.at(i) == 0){
      last = i-1;
      break;
    }
  }
  for(int i = 0; i <= last; i++){
    int result = 0;
    for(int j = 1; j <= n.at(i); j++){
      for(int k = j + 1; k <= n.at(i); k++){
        if(x.at(i) - j - k > k && x.at(i) - j - k >= 1 && x.at(i) - j - k <= n.at(i)) result++;
      }
    }
    cout << result << endl;
  }
}



Measured memory_bytes: 3128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

import numpy as np
from itertools import product

n, m, x = map(int, readline().split())
ca = np.array(read().split(), np.int64).reshape((n, m + 1))
INF = 10 ** 9

c = ca[:, 0]
a = ca[:, 1:].T

ans = INF
for p_li in product([1, 0], repeat=n):
    p = np.array(p_li)
    rikai = a * p
    sm = rikai.sum(axis=1)
    if sm.min() >= x:
        cost = (c * p).sum()
        ans = min(ans, cost)

if ans == INF:
    ans = -1

print(ans)


Measured memory_bytes: 27232
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

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

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int n, m, p;

	while(cin >> n >> m >> p, n) {
		vi player(n, 0);
		int sum = 0;

		REP(i, n) {
			cin >> player[i];
			sum += player[i];
		}

		sum *= (100-p);

		if(player[m-1]) {
			cout << sum/player[m-1] << endl;
		} else {
			cout << 0 << endl;
		}
	}


}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  vector<pair<int, int>> v;
  for (int i = 0; i < n; i++) {
    int x; cin >> x;
    v.emplace_back(x, i);
  }
  sort(v.begin(), v.end());
  vector<int> r(n);
  for (int i = 0; i < n; i++) {
    int j = v[i].second;
    if (i < n / 2) r[j] = v[n/2].first;
    else r[j] = v[n/2-1].first;
  }
  for (auto x : r) cout << x << endl;
}

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

int main() {
  int n,m,X,Y;
  cin >>n>>m>>X>>Y;
  vector<int> x(n);
  for (int i=0; i<n; ++i ) cin >> x.at(i);
  sort(x.begin(), x.end());
  vector<int> y(m);
  for (int i=0; i<m; ++i ) cin >> y.at(i);
  sort(y.begin(), y.end());
  
  int z = x.at(n-1)+1;
  
  if (y.at(0)<z) cout << "War";
  else {
    if (X<z && z<=Y) cout << "No War";
    else cout << "War";
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define wtr(a) cout<<(a)<<" "
//#define wtr(a,b) cout<<(a)<<" "<<(b)<<" "
//#define wtr(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wtrl(a) cout<<(a)<<endl
//#define wtrl(a,b) cout<<(a)<<" "<<(b)<<endl
//#define wtrl(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int main() {
  //input
  int n,m,x;
  //r3(n,m,x);
  cin >> n >> m >> x;
  
  int c[n];
  int a[n][m];
  rep(i,n) {
    cin >> c[i];
    rep(j,m) {
      cin >> a[i][j];
    }
  }

  int sum = -1;
  
  //全組合せパターンにおいて
  for(int bit = 0; bit < (1<<n); bit++) {
    int sumc=0;
    int suma[m]={0};
    
    //各パターンについて、0-nの数値を全部チェックし
    rep(i,n) {
      //bitパターンに含まれるiであれば
      if(bit & (1 << i)) {
        //足していく
        sumc += c[i];
        rep(j,m) suma[j] += a[i][j];
      }
    }
    
    //check
    int flag = 1;
    rep(i,m) {
      if(suma[i] < x) {
        flag = 0;
        break;
      }
    }
    
    //条件を満たしていた場合
    if(flag == 1) {
      if(sum > sumc || sum == -1) sum = sumc;
    }
    
  }
  cout << sum << endl;
}

Measured memory_bytes: 3572
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	int fib[50];
	fib[0] = 1;
	fib[1] = 1;

	for (int i = 2; i < 50; i++)
	{
		fib[i] = fib[i - 1] + fib[i - 2];
	}

	int n;
	cin >> n;

	cout << fib[n] << endl;

	return 0;
}


Measured memory_bytes: 3084
while True:
   n,m = map(int, input().split())
   if n==0 and m==0:
      break
   a = list(map(int, input().split()))
   s = []
   for p in range(n):
      for q in range(n):
         if p >= q:
            pass
         else:
            if a[p] + a[q] <= m:
               s.append(a[p] + a[q])
   s.sort()
   if s == []:
      print('NONE')
   else:
      print(s[len(s)-1])


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

int main(){
    int N;
    cin >> N;
    std::vector<int> value(N);

    for(int i=0; i < N; i++){
        cin >> value.at(i);
    }
    int cost;
    for(int i=0; i < N; i++){
        cin >> cost;
        value.at(i) -= cost;
    }
    int res = 0;
    for(int i=0; i < N; i++){
        if(value.at(i) > 0){
            res +=value.at(i);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256