akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,dp[maxn][maxn];
struct node{ll val,id;}p[maxn];

inline bool operator < (node a,node b)
{
	if(a.val==b.val) return a.id<b.id;
	return a.val>b.val;
}

int main()
{
	n=read(); rep(i,1,n) p[i].val=read(),p[i].id=i;
	sort(p+1,p+n+1); dp[1][n]=0;
	for(int x=n-1;x>=0;x--)
	{
		for(int l=1;l+x-1<=n;l++)
		{
			int r=l+x-1;
			if(l>1) dp[l][r]=max(dp[l][r],dp[l-1][r]+p[n-x].val*abs(p[n-x].id-(l-1)));
			if(r<n) dp[l][r]=max(dp[l][r],dp[l][r+1]+p[n-x].val*abs(p[n-x].id-(r+1)));
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++) ans=max(ans,dp[i][i-1]); cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 26268
#include <stdio.h>

using namespace std;
#define MAX 100000

struct Card {
    char suit;
    int value;
};
Card tempCard[MAX];

void swap(Card A[], int index1, int index2) {
    int temp;
    char c;
    temp = A[index1].value;
    c = A[index1].suit;

    A[index1].value = A[index2].value;
    A[index1].suit = A[index2].suit;

    A[index2].value = temp;
    A[index2].suit = c;
}

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

void quickSort(Card A[], int p, int r) {
    if(p >= r) return;
    int index = partition(A, p, r);
    quickSort(A, p, index-1);
    quickSort(A, index+1, r);
}

void bubbleSort(Card A[], int n) {
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n-i-1; j++) {
            if(A[j].value > A[j+1].value) swap(A, j, j+1);
        }
    }
}

void merge(Card A[], int lo, int mid, int hi) {
    for(int i = lo; i <= hi; i++) {
        tempCard[i] = A[i];
    }
    int i = lo, j = mid+1;
    for(int k = lo; k <= hi; k++) {
        if(i > mid) A[k] = tempCard[j++];
        else if(j > hi) A[k] = tempCard[i++];
        else if(tempCard[i].value <= tempCard[j].value) A[k] = tempCard[i++];
        else A[k] = tempCard[j++];
    }
}

void mergeSort(Card A[], int lo, int hi) {
    if(lo >= hi) return;
    int mid = (lo+hi)/2;
    mergeSort(A, lo, mid);
    mergeSort(A, mid+1, hi);
    merge(A, lo, mid, hi);
}

int main()
{
    int n, temp;
    Card A[MAX], B[MAX];
    char s[10];
    scanf("%d", &n);

    for(int i = 0; i < n; i++) {
       scanf("%s %d", s, &temp);
       A[i].suit = B[i].suit = s[0];
       A[i].value = B[i].value = temp;
    }

    quickSort(A, 0, n-1);
    //bubbleSort(B, n);
    mergeSort(B, 0, n-1);


    int stable = 1;
    for(int i = 0; i < n; i++) {
        if(A[i].suit != B[i].suit) stable = 0;
    }
    if(stable == 1)
        printf("Stable\n");
    else
        printf("Not stable\n");


    for(int i = 0; i < n; i++) {
        printf("%c %d\n", A[i].suit, A[i].value);
    }
    return 0;
}

Measured memory_bytes: 4932
import sys
from collections import deque
sys.setrecursionlimit(10**7)
inf=10**7


def BFS():
    color=[["white" for _ in range(w+2)] for _ in range(h+2)]
    D=[[inf for _ in range(w+2)] for _ in range(h+2)]

    queue=deque([])
    for i in range(1,h+1):
        for j in range(1,w+1):
            if A[i][j]=="#":
                queue.append([i,j])
                D[i][j]=0
                color[i][j]="gray"

    cnt=0
    while len(queue)!=0:
        a,b=queue.popleft()
        for c,d in ((1,0),(0,1),(-1,0),(0,-1)):
            X,Y=a+c,b+d
            if A[X][Y]=="." and color[X][Y]=="white":
                color[X][Y]="gray"
                D[X][Y]=D[a][b]+1
                cnt=max(cnt,D[X][Y])
                queue.append([X,Y])
        color[a][b]="black"

    return cnt


h,w=map(int,input().split())
A=[["#"]+list(input())+["#"] for _ in range(h)]
A.insert(0,["#"]*(w+2))
A.append(["#"]*(w+2))
print(BFS())

Measured memory_bytes: 187868
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program{
	public static void Main(){
      var x = ReadLine().Split(' ').Select(int.Parse).ToArray();
      if(x[0] <= x[1]){
        var result1 = new string(x[0].ToString()[0],x[1]);
        Write(result1);
      }else{
        var result2 = new string(x[1].ToString()[0],x[0]);
        Write(result2);
      }
    }	
}

Measured memory_bytes: 13268
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  x <- getInt
  if x >= 30
    then putStrLn "Yes"
    else putStrLn "No"


Measured memory_bytes: 3672
import java.util.*;

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

		while(true){
			int ans=0;
			int n=sc.nextInt(), m=sc.nextInt();
			ArrayList<State> al = new ArrayList<State>();

			if(n==0 && m==0) break;
			for(int i=0;i<n;i++)
				al.add(new State(sc.nextInt(), sc.nextInt()));
			Collections.sort(al);

			while(!al.isEmpty()){
				State st = al.remove(0);
				m -= st.d;
				if(m <= 0){
					ans -= m * st.p;
					break;
				}
			}

			while(!al.isEmpty()){
				State st = al.remove(0);
				ans += st.d * st.p;
			}
			System.out.println(ans);
		}
	}
}

class State implements Comparable<State>{
	int d, p;

	public State(int d, int p){
		this.d = d;
		this.p = p;
	}

	public int compareTo(State st){
		return st.p - this.p;
	}
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int cost[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};

template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

    int N, M;
    cin >> N >> M;
    vector<int> count(M, 0);
    for (int i = 0; i < N; i++)
    {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++)
        {
            int a;
            cin >> a;
            a--;
            count[a]++;
        }
    }
    int ret = 0;
    for (int i = 0; i < M; i++)
        if(count[i]==N) ret++;
    cout << ret << endl;

    /*
    int N, M;
    cin >> N >> M;
    vector<int> use(10, 0);
    while (M--)
    {
        int a;
        cin >> a;
        use[a] = 1;
    }
    vector<string> dp(N + 1);
    vector<int> dig(N + 1, -1);
    dp[0] = "";
    dig[0] = 0;
    for (int i = 0; i <= N; i++)
    {
        if (dig[i] == -1)
            continue;
        for (int j = 9; j >= 1; j--)
        {
            if (!use[j])
                continue;
            int next = i + cost[j];
            if (next > N)
                continue;
            if (dig[next] > dig[i] + 1)
                continue;
            if (dig[next] == -1 || dig[next] < dig[i] + 1)
            {
                dp[next] = dp[i] + (char)('0' + j);
                dig[next] = dp[next].size();
            }
            else
            {
                dp[next] = max(dp[next], dp[i] + (char)('0' + j));
            }
        }
    }
    cout << dp[N] << endl;
*/
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int main ()
{
  int A,B;cin>>A>>B;
  if(A>B){
    cout<<A+A-1<<endl;
  }else if(A==B){
    cout<<A+A<<endl;
  }else{
    cout<<B+B-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(0, 0); }
	V<V<pin>> qab(2);
	int sz = ab.size();
	qab[0].reserve(sz);
	qab[1].reserve(sz);
	for (pin& x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	int c = 0;
	for (pin& x : qab[0]) {
		int qc = (2 * x.first + x.second) % 3;
		c ^= (qc + 1);
	}
	if (!c) {
		pin ans = solve(qab[1], ex - 1);
		ans.first *= 2; ans.second *= 2; ans.second++;
		return ans;
	}
	pin ans = solve(qab[0], ex - 1);
  	c=0;
  	for (pin& x : qab[1]) {
		int qc = (2 * x.first + x.second) % 3;
		c ^= (qc + 1);
	}
  	if (!c) {
		ans.first *= 2; ans.second *= 2;
		return ans;
	}
	c = 0;
	for (pin& x : qab[1]) {
		int w = ans.second - x.second-1;
		if ((w & x.first) == w) { c ^= 1; }
	}
	ans.first *= 2; ans.first++; ans.second *= 2; ans.second -= c;
	return ans;
}
signed main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long inf = 1e17;
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 59);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}


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

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vp;
const int inf = 1e9;
const ll INF = 1e18;
const db eps = 1e-10;

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
#define mem(a) memset(a, 0, sizeof(a))
#define copy(a, b) memcpy(a, b, sizeof(b))
#define PA cout << "pass\n"
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define TM cout << db(clock()) / CLOCKS_PER_SEC << '\n'

const int maxn = 1e5 + 233;
pii a[maxn], b[maxn];
int n;
int suf[maxn];

int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    int res = 0;
    for(int i = 1; i <= n; i++) cin >> a[i].fi >> a[i].se, res = max(res, a[i].se - a[i].fi + 1);
    int lp = 1, rp = 1;
    for (int i = 1; i <= n; ++i) {
        if(a[i].fi > a[lp].fi) lp = i;
        if(a[i].se < a[rp].se) rp = i;
    }
    res = res + max(0, a[rp].se - a[lp].fi + 1);
    if(lp == rp) {
        cout << res << '\n';
    }
    else {
        int m = 0;
        for (int i = 1; i <= n; i++) {
            if (i == lp || i == rp) continue;
            b[++m] = a[i];
        }
        sort(b + 1, b + m + 1);
        suf[m + 1] = a[lp].se;
        for (int i = m; i; i--) suf[i] = min(suf[i + 1], b[i].se);
        int tmp = a[rp].fi;
        for (int i = 0; i <= m; i++) {
            tmp = max(tmp, b[i].fi);
            res = max(res, a[rp].se - tmp + 1 + suf[i + 1] - a[lp].fi + 1);
        }
        cout << res << '\n';
    }
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
int n,a[3030],dp[3030][3030];

int f(int i,int j){
    if(i==j)dp[i][j]=a[i];
    if(dp[i][j]==-1)dp[i][j]=max(a[i]-f(i+1,j),a[j]-f(i,j-1));
    return dp[i][j];
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]=-1;
        }
    }
    //dp[i][j]:ai~ajでゲームをした時のスコア
    cout<<f(0,n-1)<<endl;
}

Measured memory_bytes: 72064
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  bool flag=1;
  if(S.find("a")>=3)flag=0;
  if(S.find("b")>=3)flag=0;
  if(S.find("c")>=3)flag=0;
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

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

int main(){
  int N,K;
  scanf("%d%d",&N,&K);
  int h[N];
  for(int i = 0;i < N;i++){
    scanf("%d",&h[i]);
  }
  if(K >= N)K = N-1;
  int C[N];
  for(int i = 0;i < K;i++){
    C[i] = abs(h[0]- h[i]);
  }
  for(int i = K;i < N;i++){
    int min;
    min = C[i-K] + abs(h[i] - h[i-K]);
    for(int j = K-1;j > 0;j--){
      if(min > C[i-j] + abs(h[i] - h[i-j]))min = C[i-j] + abs(h[i] - h[i-j]);
    }
    C[i] = min;
  }
  printf("%d\n",C[N-1]);
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
using namespace std;

int main(){
  ll N,K;
  cin>>N>>K;
  
  ll A[N+1];
  for(int i=1; i<=N; ++i) cin>>A[i];
  
  ll DP[300000];
  REP(i,300000) DP[i]=0;
  DP[0]=1;
  
  for(int i=1; i<=N; ++i){
    DP[i]=A[DP[i-1]];
  }
  
  if(K<=N) cout<<DP[K]<<endl;
  else{
    ll COUNT[300000],S,G;
    REP(i,300000) COUNT[i]=INF;
    COUNT[1]=0;
    
    for(int i=1; i<=N; ++i){
      if(COUNT[DP[i]]!=INF){
        S=COUNT[DP[i]];
        G=i;
        break;
      }
      else COUNT[DP[i]]=i;
    }
    
    cout<<DP[(K-S)%(G-S)+S]<<endl;
  }
  
  return 0;
}

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

typedef long long int lli;
typedef long long ll;
typedef long double ld;

int main(){
    int t=1;
    //cin>>t;
    while(t--){
        int l,r,k;
        cin>>l>>r>>k;
        int c=0;
        for(int i=l;i<=r;i++){
            if(i%k==0)
                c++;
        }
        cout<<c<<endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <stdio.h>
#include <deque>

using namespace std;

const int INF = 0x3f3f3f3f;
typedef pair<int, int> P;
int h, w, n;
int sx, sy;
int gx, gy;
char cmap[1000][1000];
int goalSum;
int goal[10];
int d[1000][1000];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int bfs() {
    int res = 0;
    deque<P> que;
    for (int ci = 0; ci < n; ci++) {  //要?行n次循?，?找n次?点，?次?数?入goal[i], 最后累加起来是res 
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                d[i][j] = INF;
            }
        }
        
        que.push_back(P(sx, sy));
        d[sx][sy] = 0;
        
        while(que.size()) {            
            int x = que.front().first;
            int y = que.front().second;
                        
            if ((int)cmap[x][y] == 49 + ci) {
                goal[ci] = d[x][y];
                sx = x;
                sy = y;
                break;
            }
            
            for (int i = 0; i < 4; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (nx >=0 && nx < h && ny >= 0 && ny < w && cmap[nx][ny] != 'X' && d[nx][ny] == INF) {
                    que.push_back(P(nx, ny));
                    d[nx][ny] = d[x][y] + 1;
                }
            }    
            que.pop_front();        
        }
        que.clear(); 
        res += goal[ci];
    }
    return res;
}

int main() {
    cin >> h >> w >> n;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> cmap[i][j];
            if (cmap[i][j] == 'S') {
                sx = i;
                sy = j;
            }
        }
    }
    goalSum = bfs();
    cout << goalSum << endl;
    return 0;
}

Measured memory_bytes: 7976
//#pragma GCC optimize "-O3"
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#include"bits/stdc++.h"

using namespace std;

#define MAX 1002

int h;
int w;

char buf[MAX];

vector<string> v;

queue<pair<int, int> > q;
int dist[MAX][MAX];

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

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		scanf("%s", buf);
		v.push_back(buf);
	}
	memset(dist, -1, sizeof(dist));
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			if (v[i][j] == '#') {
				q.push(make_pair(i, j));
				dist[i][j] = 0;
			}
		}
	}
	int las = -1;
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		las = dist[x][y];
		q.pop();
		for (int k = 0; k < 4; k++) {
			int xx = x + dx[k];
			int yy = y + dy[k];
			if (xx >= 0 && yy >= 0 && xx < h&&yy < w) {
				if (dist[xx][yy] == -1) {
					dist[xx][yy] = dist[x][y] + 1;
					q.push(make_pair(xx, yy));
				}
			}
		}
	}
	cout << las << endl;
	return 0;
}

Measured memory_bytes: 13328
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main() {
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,0,n+1){
        rep(j,0,m+1){
            if(i*j+(n-i)*(m-j)==k || i*j+(n-i)*(m-j)==m*n-k){
                cout<<"Yes"<<endl;
                return  0;
            }
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

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

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

    int N; cin >> N;
    int A[100100]; rep(i, N) cin >> A[i];

    int L[100100], R[100100];
    L[0] = A[0]; R[N - 1] = A[N - 1];

    rep(i, N - 1) {
        L[i + 1] = gcd(L[i], A[i + 1]);
    }
    rep(i, N - 1) {
        R[N - i - 2] = gcd(R[N - i - 1], A[N - i - 2]);
    }

    int ans = max(L[N - 2], R[1]);
    rep(i, N - 2) {
        int G = gcd(L[i], R[i + 2]);
        ans = max(ans, G);
    }

    cout << ans << "\n";

    return 0;
}

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

int main() {
  int n,ans;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  cin >> a[0];
  for(int i = 1;i < n;i++){
    int t;
    cin >> t;
    a[i] = a[i-1]+t;
  }
  cin >> b[0];
  for(int i = 1;i < n;i++){
    int t;
    cin >> t;
    b[i] = b[i-1]+t;
  }
  //for(int i=0;i<n;i++)cout<<a[i]<<" ";
  //cout<<endl;
  //for(int i=0;i<n;i++)cout<<b[i]<<" ";
  
  ans = a[0]+b[n-1];
  for(int i = 1;i < n;i++){
    if(a[i]+b[n-1]-b[i-1] > ans) ans = a[i]+b[n-1]-b[i-1];
  }
  cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  
  bool a = false;
  
  for (int i = 1; i < 10; i++){
    if (n%i == 0 && 1 <= n/i && n/i <= 9){
      a = true;
      break;
    }
  }
  if (a == true){
    cout << "Yes" << endl;
  }
  else {
    cout <<"No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define pll pair<ll,ll> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
int inf=1000001000;
ll INF=100000000000000000;
ll MOD=1000000007;
//g++ code.cpp   ./a.out 

int main() {
   ll n,k;
   cin >> n >> k;
   ll a=n%k;
   n=min(a,abs(a-k));
   cout << n << endl;
}



Measured memory_bytes: 256
// In The Name Of Allah
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e10;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
const ll mod = 1e9 + 7;

 
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll M = 500 + 10;
const ll N = 100 * 1000 + 10;

vector <pair <char, char>> tc;

int main()	
{
	faster();
	int n, q;
	string s;
	cin >> n >> q >> s;
	for (int i = 0; i < q; i++)
	{
		char a, b;
		cin >> a >> b;
		tc.push_back({a, b});
	}
	int low = -1, high = n;
	for (int p = 0; p < 80; p++)
	{
		int mid = (low + high) / 2;
		int pos = mid;
		bool is_val = true, vulvul = false;
		for (int i = 0; i < q; i++)
		{
			char a = tc[i].first, b = tc[i].second;
			if(s[pos] == a && b == 'R')
			{
				pos++;
			}
			else if(s[pos] == a)
			{
				pos--;
			}
			if(pos == n)
			{
				is_val = false;
				break;
			}
			if(pos == -1)
			{
				vulvul = true;
				break;
			}
		}
		if(!is_val || !vulvul)
		{
			high = mid;
		}
		else
		{
			low = mid;
		}
	}
	int ans = low + 1;
	if(low == n)
		ans = 0;
	low = -1, high = n;
	for (int p = 0; p < 80; p++)
	{
		int mid = (low + high) / 2;
		int pos = mid;
		bool is_val = true, vulvul = false;
		for (int i = 0; i < q; i++)
		{
			char a = tc[i].first, b = tc[i].second;
			if(s[pos] == a && b == 'R')
			{
				pos++;
			}
			else if(s[pos] == a)
			{
				pos--;
			}
			if(pos == n)
			{
				vulvul = true;
				break;
			}
			if(pos == -1)
			{
				is_val = false;
				break;
			}
		}
		if(!is_val || !vulvul)
		{
			low = mid;
		}
		else
		{
			high = mid;
		}
	}
	cout << high - ans << endl;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    ii(n); ii2(d, x); int s = 0;
    rep(i, n){
        ii(a); s += (d+a-1)/a;
    }
    out(s+x);
}

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

using namespace std;

int d[1000], c[1000];

int n, m; // n = ???????????°???m = ??\??°
int memo[1000][1000];

int rec(int day, int now)
{
	if (now == n) return 0;

	if (memo[day][now] >= 0) return memo[day][now];

	int res;

	if (m - day <= n - now) {
		res = rec(day + 1, now + 1) + d[now] * c[day];
	} else {
		res = min(rec(day + 1, now + 1) + d[now] * c[day], rec(day + 1, now));
	}

	return memo[day][now] = res;
}

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

	for (int i = 0; i < n; ++i) cin >> d[i];
	for (int i = 0; i < m; ++i) cin >> c[i];

	memset(memo, -1, sizeof(memo));

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

Measured memory_bytes: 5108
#include <iostream>
typedef long long ll;
using namespace std;
int c;
int x[100005];
int ans = 1e9;
int main() {
  int n,k;
  cin >> n >> k;
  for(int i = 0; i < n; i++) {
    cin >> x[i];
    if(x[i] < 0) c++;
  }

  int l,r;

  if(c >= k) {
    r = c - 1;
    l = c - k;
  }
  else {
    l = 0;
    r = l + k - 1;
  }

  for(; r < n; l++,r++) {
    if(x[l] <= 0 && x[r] >= 0) {
      int ll = -x[l];
      int rr = x[r];
      int ss = min(ll,rr);
      ans = min(ans,max(ll,rr) + 2 * ss);
    }
    else if(x[l] <= 0 && x[r] <= 0) {
      ans = min(ans,-x[l]);
    }
    else {
      ans = min(ans,x[r]);
    }
  }

  cout << ans << endl;
}
  


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

using namespace std;

typedef long long lint;

int main()
{
	int n, d;
	int dp[256][256]; //i日目に服jを着た時の最大値
	int heat[256];
	int mi[256], ma[256], val[256];
	
	memset(dp, 0, sizeof(dp));
	
	scanf("%d %d", &d, &n);
	
	for (int i = 1; i <= d; i++){
		scanf("%d", heat + i);
	}
	
	for (int i = 0; i < n; i++){
		scanf("%d %d %d", mi + i, ma + i, val + i);
	}
	
	for (int i = 2; i <= d; i++){
		for (int j = 0; j < n; j++){
			if (!(mi[j] <= heat[i] && heat[i] <= ma[j])) continue;
			for (int k = 0; k < n; k++){
				if (!(mi[k] <= heat[i - 1] && heat[i - 1] <= ma[k])) continue;
				dp[i][j] = max(dp[i][j], dp[i - 1][k] + abs(val[j] - val[k]));
			}
		}
	}
	
	int ans = -1;
	for (int i = 0; i < n; i++) ans = max(ans, dp[d][i]);
	
	printf("%d\n", ans);
	
	return (0);
}

Measured memory_bytes: 1296
#include <iostream>

using namespace std;

int main() {
	char X, Y;
	int x, y;
	cin >> X >> Y;
	int A=10, B=11, C=12, D=13, E=14, F = 15;
	int i;
	switch (X) {
	case 'A':
		x = A;
		break;
	case 'B':
		x = B;
		break;
	case 'C':
		x = C;
		break;
	case 'D':
		x = D;
		break;
	case 'E':
		x = E;
		break;
	case 'F':
		x = F;
		break;
	default:
		break;
	}
	switch (Y) {
	case 'A':
		y = A;
		break;
	case 'B':
		y = B;
		break;
	case 'C':
		y = C;
		break;
	case 'D':
		y = D;
		break;
	case 'E':
		y = E;
		break;
	case 'F':
		y = F;
		break;
	default:
		break;
	}
	if (x > y) {
		cout << ">" << endl;
	}
	else if (x < y) {
		cout << "<" << endl;
	}
	else {
		cout << "=" << endl;
	}
	
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    if (K - vec.at(i) < vec.at(i)) ans += (K - vec.at(i)) * 2;
    else ans += vec.at(i) * 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
A = list(input())
B = list(input())
C = list(input())
x = 'a'
while True:
    if x == 'a':
        if len(A) == 0:
            print('A')
            break
        x = A[0]
        A.remove(x)
    elif x == 'b':
        if len(B) == 0:
            print('B')
            break
        x = B[0]
        B.remove(x)
    else:
        if len(C) == 0:
            print('C')
            break
        x = C[0]
        C.remove(x)



Measured memory_bytes: 3064
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int N, M; cin >> N >> M;
	vector<int> k(M), p(M);
	vector<vector<int>> s(M);
	for (int i = 0; i < M; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			int x; cin >> x;
			s[i].push_back(x);
		}
	}
	for (int i = 0; i < M; i++)cin >> p[i];
	int ans = 0;
	for (int i = 0; i < (1<<N); i++) {
		bool x = 1;
		for (int j = 0; j < M; j++) {
			int c = 0;
			for (int l = 0; l < k[j]; l++) {
				c ^= ((i>>(s[j][l]-1))&1);
			}
			if (c != p[j])x = 0;
		}
		if (x == 1)ans++;
	}
	cout << ans << endl;
}





Measured memory_bytes: 256
import java.util.Scanner;

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

    int yen500 = sc.nextInt();
    int yen100 = sc.nextInt();
    int yen50 = sc.nextInt();
    int total = sc.nextInt();
    
    sc.close();

    int count = 0;

    for (int i = 0; i <= yen500; i++) {
      for (int j = 0; j <= yen100; j++) {
        for (int k = 0; k <= yen50; k++) {
          if (total == (i * 500 + j * 100 + k * 50)) {
            count++;
          }
        }
      }   
    }

    System.out.println(count);
  
  }
}

Measured memory_bytes: 21844
N = int(input())

def factorization(n):
    arr, temp = [], n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

fac = factorization(N)
ans = 0

for k, v in fac:
    cnt = 1
    if k != 1:
        while True:
            v -= cnt
            if v < 0:
                break
            ans += 1
            cnt += 1

print(ans)

Measured memory_bytes: 9492
#include <iostream>

using namespace std;

int main()
{

    int n=0;
    int a=0;
    int b=0;
    int temp=0;
    cin>>n>>a>>b;
    temp=n*a;
    if(temp<b)
    {
        cout<<temp;
    }
    else
    {
        cout<<b;
    }
    return 0;
}


Measured memory_bytes: 256
from functools import lru_cache

def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = 0
    for a in A[2:]:
        x ^= a
    a, b = A[0], A[1]
    if (a ^ b ^ x) & 1 != 0:
        return -1

    @lru_cache(None)
    def helper(a, b, x):
        if a == 0:
            return 0 if a ^ b == x else None
        if (a ^ b) & 1 != x & 1:
            return None
        t1 = helper(a // 2, b // 2, x // 2)
        t2 = helper((a - 1) // 2, (b + 1) // 2, x // 2)
        if t1 is None and t2 is None:
            return None
        if t1 is None:
            return t2 * 2 + 1
        if t2 is None:
            return t1 * 2
        t1 = t1 * 2
        t2 = t2 * 2 + 1
        return min(t1, t2)
    r = helper(a, b, x)
    if r is None or r >= a:
        return -1
    return r

print(main())


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    double n, m;
    ll d;
    cin >> n >> m >> d;
    cout << fixed << setprecision(9);
    if(d == 0) {
        cout << ((n-d)/n) * ((m-1)/n) << endl;
    }
    else {
        cout << 2 * ((n-d)/n) * ((m-1)/n) << endl;
    }

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3756
X = int(input())
Xdiv100 = X // 100
if Xdiv100 == 0:
    print(0)
elif Xdiv100 < 20:
    if Xdiv100 * 5 < X % 100:
        print(0)
    else:
        print(1)
else:
    print(1)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int i,j,k,m,n;
	cin>>n;
	int ans=0;
	for(register int i=sqrt(n);i>=1;i--){
		if(n%i==0){
			ans=i-1+n/i-1;
			cout<<ans<<endl;
			return 0;
		}
	}
	return 0;
}


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

const int kN = 500 + 5;

int mat[kN][kN];

int main() {
	int H, W, h, w, s = 0; scanf("%d%d%d%d", &H, &W, &h, &w);
	for(int i = 1; i <= H; ++i)
		for(int j = 1; j <= W; ++j) mat[i][j] = 1000;
	for(int i = 1; i <= H; ++i)
		for(int j = 1; j <= W; ++j) {
			if(i % h == 0 && j % w == 0)
				mat[i][j] = -h * w * 1000 + 999;
		}
	for(int i = 1; i <= H; ++i)
		for(int j = 1; j <= W; ++j)
			s += mat[i][j];
	if(s > 0) {
		printf("Yes\n");
		for(int i = 1; i <= H; ++i) {
			for(int j = 1; j <= W; ++j) printf("%d ", mat[i][j]);
			printf("\n");
		}
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 4844
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define int long long
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B, class C> A power ( A x, B n, C mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A> A lcm ( A x, A y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A> inline boolean chmax ( A &a, const A &b ) { return b > a ? a = b, true : false; }
    template<class A> inline boolean chmin ( A &a, const A &b ) { return b < a ? a = b, true : false; }
    inline boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int b[32];
    int ans = 0;

    signed call_of_Cthulhu( signed datum ) {

        int n, m, c;
        read n >> m >> c;
        for ( int i = 0; i < m; i++ ) {
            read b[i];
        }
        for ( int i = 0; i < n; i++ ) {
            int tmp = 0;
            for ( int j = 0; j < m; j++ ) {
                int a;
                read a;
                tmp += a*b[j];
            }
            if ( tmp+c > 0 ) ans++;
        }
        echo ans fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
int table[100000];
int main() {
	int N, L = 0;
	scanf("%d", &N);
	vector<int> A(N + 2);
	A[0] = A[N + 1] = 0;
	rep(i, 1, N + 1)scanf("%d", &A[i]);
	rep(i, 0, N + 1) {
		L += abs(A[i] - A[i + 1]);
	}
	rep(i, 1, N + 1) {
		printf("%d\n", L - abs(A[i] - A[i + 1]) - abs(A[i] - A[i - 1]) + abs(A[i - 1] - A[i + 1]));
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
using namespace std;
void ABC130(void);
void ABC131(void);
void ABC132(void);
void ABC133(void);
void ABC134(void);
void ABC135(void);
void ABC136(void);
void ABC137(void);
void ABC138(void);
void ABC139(void);

int main(void){
    ABC136();
}

void ABC136(){
    int a,b,c;
    cin>>a>>b>>c;
    if(c<=(a-b))cout<<0<<endl;
    else cout<<c-(a-b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> books(n, vector<int>(m));
  rep(i, n) {
    cin >> c[i];
    rep(j, m) {
      cin >> books[i][j];
    }
  }
  ll cost = INF;
  for (int i = 0; i < (1 << n); i++) {
    vector<ll> calc(m);
    ll tmp = 0;
    rep(j, n) {
      if ((i >> j) & 1) {
        tmp += c[j];
        rep(k, m) {
          calc[k] += books[j][k];
        }
      }
    }
    bool ok = true;
    rep(j, m) {
      if (calc[j] < x) {
        ok = false;
        break;
      }
    }
    if (ok) cost = min(tmp, cost);
  }
  ll ans = (cost >= 2000000) ? -1 : cost;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<ll,ll> P;

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

int main() {
    string S;
    int need=1<<20;
    cin >> S;

    int ssize=S.size();

    string p1="",p2="";
    for(int i=0; i<S.size(); i++){
        if(i%2==0){
            p1+='0';
        }else{
            p1+='1';
        }
    }

    for(int i=0; i<S.size(); i++){
        if(i%2==0){
            p2+='1';
        }else{
            p2+='0';
        }
    }

    int temp=0;
    rep(i,ssize){
        if(S[i]!=p1[i]){
            temp++;
        }
    }
    need=min(need,temp);

    temp=0;
    rep(i,ssize){
        if(S[i]!=p2[i]){
            temp++;
        }
    }
    need=min(need,temp);

    cout << need << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;


int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int x,a[200005],b=1,n,res=0, u[200000], v[200000], w[200000];
	
	string str, str2;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	while (b != 2) {
		b = a[b];
		res++;
		if (res > 1000000) { cout << -1 << endl; return 0; }
	}
	cout << res++;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

signed main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, p[50]; cin >> N;
  int cnt = 0;
  REP(i, N){
    cin >> p[i];
    if(p[i] != i+1) cnt++;
  }
  if(cnt == 2 or cnt == 0){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int powm(int x) {
    int sum = 1;
    for(int i = 1; i <= x; i ++) {
        sum *= 2;
    }return sum;
}
signed main()
{
    int n, m;
    cin >> n >> m;
    cout << 1800 * m * powm(m) + 100 * n * powm(m) << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> data(n);
  for(int i = 0; i < n; i++){
    cin >> data.at(i);
  }
  int count = 0;

  for(int i  = 0; i < n-2; i++){
    int a = max(data.at(i), data.at(i + 2));
    int b = min(data.at(i), data.at(i + 2));
    
    if(data.at(i + 1) < a && data.at(i + 1) > b){
      count++;
    }
  } 
  cout << count <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <utility>
#include <string>
#include <queue>
#include <cmath>
#include <array>

int main(int argc, char *argv[])
{
    int n;
    std::vector<std::pair<int,int>> a;
    std::vector<long long> ans;
    std::vector<long long> count;

    std::cin >> n;
    a.resize(n);
    ans.resize(n);
    count.resize(n + 1);

    for (int i = 0; i < n; i++) {
        std::cin >> a[i].first;
        a[i].second = i;
    }

    for (int i = 0; i <= n; i++) {
        count[i] = 0;
    }

    std::sort(a.begin(), a.end());

    long long all = 0;
    long long p = 1;
    for (int i = 1; i < n; i++) {
        if (a[i - 1].first == a[i].first) {
            p++;
        } else {
            all += p * (p - 1) / 2;
            count[a[i - 1].first] = p;
            p = 1;
        }
    }
    count[a[n - 1].first] = p;
    all += p * (p - 1) / 2;

    for (int i = 0; i < n; i++) {
        const int num = a[i].first;
        const int target = a[i].second;
        const long long c = count[num];
        ans[target] = all;
        ans[target] += (c - 1) * (c - 2) / 2 - c * (c - 1) / 2;
    }

    for (int i = 0; i < n; i++) {
        std::cout << ans[i] << std::endl;;
    }

    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int ji[252];

int main(){
  int _s,_t;
  while(~scanf("%d%d",&_s,&_t)){
    REP(i,252)ji[i]=0;
    ji[_s]++;
    ji[_t]++;
    while(true){
      int s,t;
      cin>>s>>t;
      if(!s && !t)break;
      ji[s]++;
      ji[t]++;
    }
    int cnt = 0;
    REP(i,252) cnt += (ji[i]%2);
    if((cnt==2 && ji[1]%2==1 && ji[2]%2==1)){
      cout<<"OK"<<endl;
    }else{
      cout<<"NG"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1240