akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int s;
    cin >> s;
    vector<int> a(1000000, 0);
    a.at(0) = s;
    rep(i, 0, 1000000 - 1)
    {
        if (a.at(i) % 2 == 0)
        {
            a.at(i + 1) = a.at(i) / 2;
        }
        else
        {
            a.at(i + 1) = 3 * a.at(i) + 1;
        }
        if ((a.at(i) == 4) || (a.at(i) == 2) || (a.at(i) == 1))
        {
            cout << i + 4 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		Main main = new Main();
		int ans = main.bubbleSort(a, n);

		for (int i = 0; i < a.length; i++) {
			if (i != a.length - 1) {
				System.out.print(a[i] + " ");
			} else {
				System.out.println(a[i]);
			}

		}
		System.out.println(ans);

	}

	private int bubbleSort(int[] a, int n) {
		boolean hasSwapped = true; // 要素の入れ替えを行った
		int cnt = 0;
		// 未ソート部分の先頭を表す i を持つ外側のループ
		for (int i = 0; hasSwapped; i++) {
			hasSwapped = false;
			// 末尾の要素からi+1まで入れ替え処理を行う
			for (int j = n - 1; j >= i + 1; j--) {
				if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					cnt++;
					hasSwapped = true;
				}
			}

		}
		return cnt;
	}

}



Measured memory_bytes: 26344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n, k;
    cin >> n >> k;
    if(n % k == 0) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

template <class Monoid> struct SegmentTree {
  using F = function<Monoid(Monoid, Monoid)>;

  int sz;
  vector<Monoid> seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; --k) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1){
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[] (const int &k) const {
    return seg[k + sz];
  }
};

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

  int n;
  cin >> n;
  vt<int> a(n);
  rep(i, 0, n) cin >> a[i];

  SegmentTree<int> seg(n, [](int a, int b){return gcd(a, b);}, 0);
  rep(i, 0, n) seg.update(i, a[i]);
  int ans = 0;
  rep(i, 0, n) ans = max(ans, (int)gcd(seg.query(0, i), seg.query(i + 1, n)));
  cout << ans << endl;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main(void){
  int n,k;

  while(cin >> n >> k){
    if((n|k) == 0) break;
    int s[k];
    int b[n][k];
    for(int i=0;i<k;i++) cin >> s[i];
    for(int i=0;i<n;i++){
      for(int j=0;j<k;j++){
	cin >> b[i][j];
      }
    }
    bool isok = true;
    for(int i=0;i<k;i++){
      int tmp=0;
      for(int j=0;j<n;j++){
	tmp += b[j][i];
      }
      if(tmp > s[i]){
	isok = false;
      }
    }
    isok?cout << "Yes" << endl:cout << "No" << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <vector>
using namespace std;

typedef vector<long long int> Row;
typedef vector<Row> Matrix;

vector<Row> scan_matrix(int n, int m)
{	
	vector<Row> matrix;
	
	for(int i = 0; i < n; i++){
		Row row;		
		for(int j = 0; j < m; j++){
			int a;
			scanf("%d", &a);
			row.push_back(a);
		}
		matrix.push_back(row);
	}
	return matrix;
}
long long int get_answer(vector<Row> matrixA, vector<Row> matrixB, int r, int c)
{
	int m = matrixA[0].size();
	long long int sum = 0;
	for(int i = 0; i < m; i++){
		sum += matrixA[r][i] * matrixB[i][c];
	}
	return sum;
}
vector<Row> keisan(vector<Row> matrixA, vector<Row> matrixB)
{
	int n = matrixA.size();
	int l = matrixB[0].size();
	
	Matrix matrixC(n, Row(l));
	
	for(int i = 0; i < n; i++){	
		for(int j = 0; j < l; j++){
			matrixC[i][j] = get_answer(matrixA, matrixB, i, j);
		}
	}
	return matrixC;
}
void print_matrix(vector<Row> matrix)
{
	int n = matrix.size();
	for(int i = 0; i < n; i++){	
		Row row = matrix[i];
		int l = row.size();
		for(int j = 0; j < l; j++){
			if(j == 0){
				printf("%lld", row[j]);
			}
			else{
				printf(" %lld", row[j]);
			}
		}
		printf("\n");
	}
}

int main(void)
{
	int n, m, l;//??????A????????°?????????A????????°????????????B????????°?????????B????????°
	scanf("%d %d %d", &n, &m, &l);
	
	vector<Row> matrixA;
	vector<Row> matrixB;
	
	matrixA = scan_matrix(n, m);
	matrixB = scan_matrix(m, l);
	
	vector<Row> matrix;
	matrix = keisan(matrixA, matrixB);
	
	print_matrix(matrix);
	
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define ll long long

using namespace std;


int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    bool flag = true;
    if(A == 0) flag = false;
    ll count = 0;
    count = N / (A + B);
    ll ans = A * count;
    if((N - (A + B)*count) > A) ans += A;
    else ans += N - (A + B)*count;
    
    cout << (flag ? ans : 0) << endl;
}

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

class Program {
    static Scanner cin = new Scanner();

    internal static void Main(string[] args) {
        var N = cin.nextInt();
        var a = cin.ArrayLong(N);
        var lst = new List<long>();
        long sum1 = a.Take(N-1).Sum();
        long sum2 = a.Skip(N - 1).First();
        lst.Add(Math.Abs(sum1 - sum2));
        for (int i = N-2; i > 0; i--) {
            sum1 -= a[i];
            sum2 += a[i];
            lst.Add(Math.Abs(sum1 - sum2));
        }

        WriteLine(lst.Min());
    }
}




class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 34012
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>
#include<stack>
#include<math.h>
#include <utility>
#include <tuple>
 
#define rep(i,f,n) for(int i=f;i<(n);i++)
#define Rep(i,n) for(int i=1;i<=(n);i++)
#define LL long long int
 
 /* 
 greater<int>() 
 sortの第三因数に入れて降順 
sqrt(double) √を求める 
pair<int,int> x=make_pair(a,b)
x.first
tuple
get<番目>(変数名)
 */
using namespace std;
 
LL lcm(LL n, LL m)
{
	LL u;
	LL ansl = 0;
	for(u=m; u>=m; u++){
		if(u%n == 0){
			if(u%m == 0){
				ansl = u;
				break;
			}
		}
	}
	return ansl;
}
 
int main(){

    int n,k;
    cin>>n;
    vector<pair<int,int>>a(n);
    int ans=0;
    rep(i,0,n){
        cin>>a[i].first;
        a[i].second=i+1;
    }
    sort(a.begin(),a.end());
    rep(i,0,n){
    cout <<a[i].second;
    if(i==n-1)break;
    cout <<" ";
    }
    cout<<endl;
    return 0;

}

Measured memory_bytes: 1664
#include <iostream>
#include <sstream>

std::string f(int S) {

    int s = S % 60;
    int m = S / 60;
    int h = m / 60;
    m = m % 60;

    std::stringstream ss;
    ss << h << ":" << m << ":" << s;
    return ss.str();
}

int main() {

    int S;
    std::cin >> S;

    std::string result = f(S);
    std::cout << result << std::endl;

    return 0;
}



Measured memory_bytes: 3216
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int n;
  string s;

  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i <= n - 3; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;
const int INF=1001001001;

int main(){
   int a,b; cin>>a>>b;
   int ans=max(a+b,max(a-b,a*b));
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
import sys

# 文字の読み込み
st = input().split()
i = [ int(x) for x in st]

del0 = abs(i[0]-i[1])
del1 = abs(i[1]-i[2])
del2 = abs(i[2]-i[0])

if del0 == del1+del2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int fa[N];
int num[N];

int getfa(int x)
{
    return fa[x]==x?x:(fa[x]=getfa(fa[x]));
}
int main()
{
    int n,m,x,y,fx,fy,res=1;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)fa[i]=i,num[i]=1;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        if(x>y)swap(x,y);
        fx=getfa(x),fy=getfa(y);
        if(fx!=fy)
        {
            num[fx]+=num[fy];
            res=max(res,num[fx]);
            fa[fy]=fx;
        }
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 5376
from math import factorial
n = int(input())
dice = [list(map(int, input().split())) for _ in range(n)]
ans = [1 for _ in range(n)]
for i in range(1, n):
    j = len({v: k for k, v in enumerate(dice[i])})
    j = factorial(6) if j == 6 else factorial(6)//factorial(6-j)
    d = [v for v in dice[i]]
    tmp = {tuple(dice[i])}
    while j > 0:
        for h in "NWSE":
            if h == "N":
                tmp = tmp.union({(d[1],d[5],d[2],d[3],d[0],d[4])})
                d[0],d[1],d[2],d[3],d[4],d[5] = d[1],d[5],d[2],d[3],d[0],d[4]
            elif h == "S":
                tmp = tmp.union({(d[4],d[0],d[2],d[3],d[5],d[1])})
                d[0],d[1],d[2],d[3],d[4],d[5] = d[4],d[0],d[2],d[3],d[5],d[1]
            elif h == "E":
                tmp = tmp.union({(d[0],d[3],d[1],d[4],d[2],d[5])})
                d[0],d[1],d[2],d[3],d[4],d[5] = d[0],d[3],d[1],d[4],d[2],d[5]
            else:
                tmp = tmp.union({(d[0],d[2],d[4],d[1],d[3],d[5])})
                d[0],d[1],d[2],d[3],d[4],d[5] = d[0],d[2],d[4],d[1],d[3],d[5]
        if tuple(dice[0]) in tmp:
            ans[i] = 0
            break
        j -= 1
print("No" if 0 in ans else "Yes")

Measured memory_bytes: 7908
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n - 1):
        for m in range(s + 1, n):
            for e in range(m + 1, n + 1):
                if x == sum([s, m, e]):
                    count += 1

    print(count)

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



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

	if(x < a)cout << 0 << endl;
	else cout << 10 << endl;
    return 0;
}

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

int main()
{
    int n; cin>>n;
    int a[101];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0){
            cout<<"DENIED"<<endl; return 0;
        }
    }
  puts("APPROVED");
}


Measured memory_bytes: 3592
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353


h, w = LI()
A = LIR(h)
B = LIR(h)
dp = [[0] * w for _ in range(h)]
n = 80 * 160
dp[0][0] = 1 << n + abs(A[0][0] - B[0][0]) | 1 << n - abs(A[0][0] - B[0][0])
for y in range(h):
    for x in range(w):
        if y + 1 < h:
            dp[y + 1][x] |= dp[y][x] >> abs(A[y + 1][x] - B[y + 1][x]) | dp[y][x] << abs(A[y + 1][x] - B[y + 1][x])
        if x + 1 < w:
            dp[y][x + 1] |= dp[y][x] >> abs(A[y][x + 1] - B[y][x + 1]) | dp[y][x] << abs(A[y][x + 1] - B[y][x + 1])


ans = INF
for i in range(n * 2):
    if dp[h - 1][w - 1] >> i & 1:
        ans = min(ans, abs(i - n))

print(ans)




Measured memory_bytes: 65496
#include<cstdio>

int main() {
	int n;
	int i = 0;
	int j;
	int a[10001];
	while(scanf("%d",&n)==1) {
		if (n == 0)
			break;
		a[i] = n;
		i++;
	}
	for (j = 0;j < i;j++) {
		printf("Case %d: %d\n", j + 1, a[j]);
	}

}

Measured memory_bytes: 2616
import sys
input = sys.stdin.readline
class SegmentTree():
    def __init__(self,size,unit,f):
        self.size=size
        self.data=[unit for _ in range(2*size)]
        self.unit=unit
        self.f=f
    def update(self,i,x):
        c=self.data
        f=self.f
        i+=self.size
        c[i]=x
        while i>1:
            i//=2
            c[i]=f(c[i*2],c[i*2+1])
    def add(self,i,x):
        c=self.data
        f=self.f
        i+=self.size
        c[i]=f(c[i],x)
        while i>1:
            i//=2
            c[i]=f(c[i*2],c[i*2+1])
    def query(self,l,r):
        c=self.data
        f=self.f
        x=self.unit
        y=self.unit
        l+=self.size
        r+=self.size
        while l<r:
            if l%2:
                x=f(x,c[l])
                l+=1
            if r%2:
                r-=1
                y=f(c[r],y)
            l//=2
            r//=2
        return f(x,y)
def main():
    N = int( input())
    S = list( input())
    Q = int( input())
    Query = [ tuple( input().split()) for _ in range(Q)]
    for i in range(40):
        if N < pow(2,i):
            n = pow(2,i)
            break
    A = [SegmentTree(n, 0, lambda a,b : a+b) for _ in range(26)]
    a = ord('a')
    for i in range(N):
        A[ord(S[i]) - a].update(i, 1)
    ANS = []
    for t, i, c in Query:
        if t == '1':
            i = int(i)
            A[ord(S[i-1])-a].update(i-1, 0)
            A[ord(c)-a].update(i-1,1)
            S[i-1] = c
        else:
            i, c = int(i), int(c)
            ans = 0
            for j in range(26):
                if A[j].query(i-1, c) > 0:
                    ans += 1
            ANS.append(ans)
    print('\n'.join( map(str, ANS)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 446188
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll mod = 1e9 + 7;

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

  string s, t = "CODEFESTIVAL2016";
  cin >> s;
  int ans = 0;
  REP(i, s.size()){
    if(s[i] != t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

pair<ll,ll> solve(ll digit, ll num)
{
    vector<ll> tmp;
    ll ans = 0;
    while(num > 1){
        if(num%2){
            tmp.push_back(digit);
            --num;
            if(tmp.size() == 2){
                ll tmpdigit = tmp.at(0) + tmp.at(1);
                ++ans;
                if(tmpdigit >= 10){
                    tmpdigit = 1 + tmpdigit%10;
                    ++ans;
                }
                tmp.clear();
                tmp.push_back(tmpdigit);
            }
        }
        digit = 2*digit;
        num /= 2;
        ans += num;
        if(digit >= 10){
            digit = 1 + digit%10;
            ans += num;
        }
    }
    if(tmp.size() == 0){
        return make_pair(digit, ans);
    }else{
        digit += tmp.at(0);
        ++ans;
        if(digit >= 10){
            digit = 1 + digit%10;
            ++ans;
        }
        return make_pair(digit, ans);
    }
}

int main()
{
    ll i,j;
    ll m;
    cin >> m;
    vector<ll> d(m);
    vector<ll> c(m);
    ll ans = 0;
    stack<ll> last;
    for(i = 0;i < m;++i){
        cin >> d.at(i) >> c.at(i);
        auto x = solve(d.at(i), c.at(i));
        ans += x.second;
        last.push(x.first);
    }
    while(last.size() > 1){
        ll digit = 0;
        digit += last.top();
        last.pop();
        digit += last.top();
        last.pop();
        ++ans;
        if(digit >= 10){
            digit = 1 + digit%10;
            ++ans;
        }
        last.push(digit);
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
    string s;
    int a[4];
    cin >> s;
    
    rep(i, 4) {
        a[i] = s[i] - '0';
    }
    
    for (int i = 0; i < (1 << 3); i++) {
        bitset<3> b(i);
        int ans = 0;
        
        rep(ii, 4) {
            if (ii == 0) {
                ans += a[ii];
                continue;
            }
            
            if (b[ii - 1]) {
                ans += a[ii];
            }
            else {
                ans -= a[ii];
            }
        }
        
        if (ans == 7) {
            rep(ii, 4) {
                cout << a[ii] << ((ii == 3) ? "=7" : (b[ii] ? "+" : "-"));
            }
            
            cout << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
N = int(input())
a = list(map(int, input().split()))
b = sum(a)
c = 0
minimum = float('inf')
for tmp in range(0,N-1):
    c += a[tmp]    
    d = abs(c-(b-c))
    minimum = min(minimum, d)
print(minimum)

Measured memory_bytes: 24828
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll n, m;
	cin >> n >> m;
	ll time = 1900LL * m + 100LL * (n - m);
	ll mul = 1;
	rep(i, m) {
		mul *= 2;
	}
	ll ans = time * mul;
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}


Measured memory_bytes: 3708
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)


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

int main()
{
	cin >> m >> f >> b;

	if (b - m <= 0) {
		cout << 0 << endl;
		return 0;
	}
	else if (b - m - f <= 0) {
		cout << b - m << endl;
		return 0;
	}
	else {
		cout << "NA" << endl;
	}

}


Measured memory_bytes: 3112
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int complete(int c) {
	if (c < 3) return 0;
	int r = 1, a = 1 << c, b = complete(c - 1);
	while (c-- > 0) r *= 3;
	return r - 3 * a + 3 + b;
}
 
static int tenpower[10];
 
int calc(int n, int c, char f[], int t) {
	if (c == 1 && (f[0] + f[1] + f[2] < 2)) return 0;
	if (c == 0 && (f[0] + f[1] + f[2] == 3)) return 1;
	if (c == 0) return 0;
	int max = 0, i, r = 0;
	if (t == 0) {
		for (i = 0; i < c; i++) max += 7 * tenpower[i];
		if (n > max) return complete(c);
		r = complete(c - 1);
	}
	char backup;
	if (n >= t + 3 * tenpower[c - 1]) {
		backup = f[0];
		f[0] = 1;
		r += calc(n, c - 1, f, t + 3 * tenpower[c - 1]);
		f[0] = backup;
	}
	if (n >= t + 5 * tenpower[c - 1]) {
		backup = f[1];
		f[1] = 1;
		r += calc(n, c - 1, f, t + 5 * tenpower[c - 1]);
		f[1] = backup;
	}
	if (n >= t + 7 * tenpower[c - 1]) {
		backup = f[2];
		f[2] = 1;
		r += calc(n, c - 1, f, t + 7 * tenpower[c - 1]);
		f[2] = backup;
	}
	return r;
}
 
int main(int argc, char *argv[]) {
	int n;
	scanf("%d", &n);
	int r, c;
	char f[3] = {};
	if (n < 357) {
      printf("0\n");
      return 0;
    }
	for (r = n, c = 0; r > 0; c++) r /= 10;
	tenpower[0] = 1;
	for (r = 1; r < 10; r++) tenpower[r] = 10 * tenpower[r - 1];
	printf("%d\n", calc(n, c, f, 0));
	return 0;
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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 ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll n, a, b;

int main(){
    cin >> a >> b >> n;
    double ans=0;
    if(n<b)
    {
        cout << floor(a*n/b)-a*floor(n/b) << endl;
        return 0;
    }
    else{
        ans=floor(a*(b-1)/b)-a*floor((b-1)/b);
        double tmp=floor(a*b/b)-a*floor(b/b);
    FOR(i,b-1,n+1)
    {
        if(tmp<floor(a*i/b)-a*floor(i/b))
            tmp=floor(a*i/b)-a*floor(i/b);
        else
        {
            break;
        }
    }
    chmax(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

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

int main () {
  int N, b, c, d, e, j;
  d = 0, e = 0;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < N; i++) {
    b = 0, c = 0;
    for (j = 0; j < N; j++) {
      if (b < a.at(j)) {
        b = a.at(j);
        c = j;
      }
    }
    if (i % 2 == 0) {
      d += b;
    }
    else if (i % 2 == 1) {
      e += b;
    }
    a.at(c) = -1;
  }
  cout << d - e << endl;
}

Measured memory_bytes: 3596
l, r = map(int, input().split())

ans = 10 ** 5
for i in range(l, r):
    for j in range(i + 1, r+1):
        n = (i * j) % 2019
        ans = min(ans, n)
        if n == 0:
            print(0)
            exit()
print(ans)


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

int main()
{
       int a, b, height = 0, i;

       scanf("%d %d", &a, &b);

       for( i = 1; i <= b-a; i++ )
       {
              height += i;
       }
       printf("%d\n", height - b);

       return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0360
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ab = RArInt();
            int n = RInt();

            bool overlap = false;
            for (int i = 0; i < n; i++)
            {
                int[] sf = RArInt();
                if (IsOverlap(ab, sf))
                {
                    overlap = true;
                    break;
                }
            }
            Console.WriteLine(overlap ? 1 : 0);
        }

        private static bool IsOverlap(int[] ab, int[] sf)
        {
            if (ab[1] <= sf[0] || sf[1] <= ab[0]) return false;
            else return true;
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



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

bool ok(int a,int b){
	int ta[26];
	fill(ta,ta+26,0);
	for(int i=0;i<26;i++){
		ta[(a*i+b)%26]++;
	}
	for(int i=0;i<26;i++)if(ta[i]>=2)return 0;
	return 1;
}
char ango(char n,int a,int b){
	int y=n-'0';
	int next=(y*a+b)%26;
	char tmp='a';
	for(int i=0;i<next;i++)tmp++;
	return tmp;
}
int main(){
	int ccc;
	cin>>ccc;
	cin.ignore();
	for(int cc=0;cc<ccc;cc++){
		string tn,n;
		getline(cin,n);
		for(int a=0;a<=26;a++){
			for(int b=0;b<=26;b++){
				tn=n;
				if(ok(a,b)){
					for(int i=0;i<(int)tn.size();i++){
						if(tn[i]!=' ')tn[i]=ango(tn[i],a,b);
					}
					bool f=0;
					for(int i=0;i<(int)tn.size()-3;i++){
						string tmp="aaaa";
						for(int j=0;j<4;j++)tmp[j]=tn[i+j];
						if(tmp=="this"||tmp=="that"){cout<<tn<<endl;goto next;}
					}
				}
			}
		}
		
		next:;
	}
	
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;

int main()
{
	int n, w, h;
	cin >> n >> w >> h;
	vi x(w + 1);
	vi y(h + 1);
	REP(i, n)
	{
		int a, b, c;
		cin >> a >> b >> c;
		x[max(0, a - c)]++;
		x[min(w, a + c)]--;
		y[max(0, b - c)]++;
		y[min(h, b + c)]--;
	}

	bool f1 = true, f2 = true;
	int cnt = 0;
	REP(i, w)
	{
		cnt += x[i];
		if (cnt == 0) f1 = false;
	}
	cnt = 0;
	REP(i, h)
	{
		cnt += y[i];
		if (cnt == 0) f2 = false;
	}
	if (f1 || f2) puts("Yes");
	else puts("No");

}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  string S,ans="TBD";
  cin>>S;
  if(S[6]<='4' && S[5]=='0') ans="Heisei";
  cout<< ans <<endl;
}


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

using namespace std;

int main(void)
{
	string s;

	cin >> s;

	int num = 0;

	for (int i = 0; i < 4; i++)
	{
		if (s[i] == '+')
			num++;
		else
			num--;
	}

	cout << num << endl;

	return 0;
}

Measured memory_bytes: 256
//QWsin
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=next[i])
using namespace std;

const int INF=1<<22;

namespace MaxFlow{
	const int maxn=5000+10;//*****
	const int maxm=300000+10;//*****
	
	int first[maxn],next[maxm],ecnt;
	
	inline void clear(){ecnt=0;memset(first,-1,sizeof first);}
	
	struct Edge{
		int u,v,cap,flow;
		Edge(){}
		Edge(int u,int v,int c,int f):u(u),v(v),cap(c),flow(f){}
	}e[maxm];
	
	inline void add_edge(int u,int v,int c,int f){
//		printf("(%d,%d,%d)\n",u,v,c);
		next[ecnt]=first[u];first[u]=ecnt;e[ecnt++]=Edge(u,v,c,f);
		next[ecnt]=first[v];first[v]=ecnt;e[ecnt++]=Edge(v,u,0,0);
	}
	
	int S,T;
	
	int d[maxn];
	queue<int>q;
	inline int BFS()
	{
		rep(i,1,T) d[i]=0;//T编号一定要最大 
		q.push(S);d[S]=1;
		while(!q.empty())
		{
			int u=q.front();q.pop();
			
			out(i,u)
			{
				int v=e[i].v;
				if(e[i].cap > e[i].flow && !d[v]){
					d[v]=d[u]+1;q.push(v);	
				}
			}
		}
		return d[T];
	}
	
	int cur[maxn];
	int dfs(int u,int a)
	{
		if(u==T || !a) return a;
		int flow=0,f;
		for(int &i=cur[u];i!=-1;i=next[i])
		{
			int v=e[i].v;
			if(d[v]==d[u]+1 && (f=dfs(v,min(e[i].cap-e[i].flow,a))))	
			{
				e[i].flow+=f;e[i^1].flow-=f;
				flow+=f;a-=f;
				if(!a) break;
			}
		}
		return flow;
	}
	
	inline int MF()
	{
		int ret=0;
		while(BFS())
		{
			rep(i,1,T) cur[i]=first[i];
			ret+=dfs(S,INF);
		}
		return ret;
	}
}

const int maxn=100+10;

char mx[maxn][maxn];

namespace init{
	
	inline void init()
	{
		using namespace MaxFlow;
		clear();
		int a,b;cin>>a>>b;

		S=a+b+1,T=S+1;
		rep(i,1,a) scanf("%s",mx[i]+1);

		int sx,sy,tx,ty;

		rep(i,1,a) rep(j,1,b)
		{
			if(mx[i][j]=='S') sx=i,sy=j,add_edge(S,i,INF,0),add_edge(S,a+j,INF,0);
			else if(mx[i][j]=='T') tx=i,ty=j,add_edge(i,T,INF,0),add_edge(a+j,T,INF,0);
			else if(mx[i][j]=='o') add_edge(i,a+j,1,0),add_edge(a+j,i,1,0);
		}

		if(sx==tx || sy==ty) {cout<<-1<<endl;return ;}

		cout<<MF()<<endl;
	}
} 

int main()
{
	init::init();
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


void trans(int a, size_t &aa, int &sa)
{
    if (a >= 0)
    {
        aa = static_cast<size_t>(a);
        sa = 1;
    }
    else
    {
        aa = static_cast<size_t>(-a);
        sa = -1;
    }
}

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

    size_t aa, bb, cc, dd;
    int sa, sb, sc, sd;

    trans(a, aa, sa);
    trans(b, bb, sb);
    trans(c, cc, sc);
    trans(d, dd, sd);

    vector<size_t> pos, neg;

    if (sa * sc == 1) { pos.push_back(aa * cc); }
    else { neg.push_back(aa * cc); }

    if (sa * sd == 1) { pos.push_back(aa * dd); }
    else { neg.push_back(aa * dd); }

    if (sb * sc == 1) { pos.push_back(bb * cc); }
    else { neg.push_back(bb * cc); }

    if (sb * sd == 1) { pos.push_back(bb * dd); }
    else { neg.push_back(bb * dd); }

    if (!pos.empty())
    {
        cout << *max_element(pos.begin(), pos.end()) << endl;
    }
    else
    {
        cout << "-" << *min_element(neg.begin(), neg.end()) << endl;
    }


    return 0;
}


Measured memory_bytes: 3628
//abc177-b
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <stack>

using namespace std;
typedef long long ll;
string a,b;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b;
	ll cnt=b.size();
	if (a==b)
	cout<<"0"<<endl;
	else 
	{
		for (ll i=0;i<a.size();i++)
		{
			ll ans=b.size();
			if (i+b.size()<=a.size())
			{
				for (ll j=i;j<i+b.size();j++)
				{
					//cout<<a[j]<<' '<<a[i]<<endl; 
					if (a[j]==b[j-i])
					ans--;
				}
			}
			//cout<<ans<<endl;
			cnt=min(cnt,ans);
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const int INF = 2100100100;


int main() {
    string s;
    cin >> s;
    vector<bool> backet = vector<bool>(26);
    
    
    for (int i=0;i<s.size();i++){
        backet.at(s.at(i) -'a') = true;
    }
    // char a = 'a' + 25 ;
    for (int i=0;i<26;i++){
        if (backet.at(i)==false){
            cout << char( i +'a') << endl;
            return 0;
        }

    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd

#define CIN(x) int x;cin>>x;
#define SCIN(x) string x;cin>>x;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end());

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){


    ll n;cin>>n;
    pair<ll,ll> p;
    for(ll i=1;i<sqrt(n)+1;++i)if(n%i==0){p.first=i;p.second=n/i;}
    int fdig=log10(p.first)+1;
    int sdig=log10(p.second)+1;

    COUT(max(fdig,sdig));
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int n,m,ans = 0;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; ++i) {
        int a,b;
        cin >> a >> b;
        a--,b--;
        uf.merge(a,b);
    }
    set<int> se;
    for (int i = 0; i < n; ++i) {
        int tmp;
        tmp = uf.root(i);
        //cout << tmp << endl;
        if(se.count(uf.root(i)) == 0){
            ans = max(ans,uf.size(i));
            //cout << uf.size(i) << endl;
            //cout <<ans << endl;
        }
        se.insert(uf.root(i));
    }
    cout << ans << endl;
    return 0;
}

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

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}


int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    a *= 100; b *= 100;

    double max_conc = 0.0;
    int SUM = 0, SUGAR = 0;

    rep(s, 32){
        rep(t, 32){
            int water = s*a + t*b;
            int max_sugar = water * e / 100;
            
            if(water > f || water == 0) continue;

            int sugar = 0;
            int max_u = max_sugar / c;
            rep(u, max_u + 1){
                sugar = u * c;
                if(water + sugar > f) continue;

                int v = min(f - water - sugar, max_sugar - u*c) / d;
                sugar += v * d;
            
                double conc = (double)(100 * sugar) / (double)(water + sugar);
                if(chmax(max_conc, conc)){
                    SUM = water + sugar;
                    SUGAR = sugar;
                }
            }
        }
    }

    if(SUM == 0) SUM = a;

    cout << SUM << " " << SUGAR << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<string>

using namespace std;

bool dp[101000];

int main(){
int N,K; cin >> N >> K;
  vector<int> a(N);
  for(int i = 0; i < N; i++){ cin >> a[i];}
  
  sort(a.begin(),a.end());
  
  for(int i = 0; i < 101000; i++){ dp[i] = false;}
  
  dp[0] = false;
  
  for(int i = 0; i <= K + 10; i++ ){
    for(int j = 0; j < N; j++){
      if( i >= a[j]){ 
        dp[i] |= !dp[i-a[j]];}
    }} //
  
  if(dp[K] == false){ cout << "Second" << endl;}
  else{ cout << "First" << endl;}

  return 0;}
          


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
unsigned sourui(int r_, int d_, int x2000_){
    return r_*x2000_ - d_;
}

int main(){
    unsigned r, d, x2000, ans;
    cin >> r >> d >> x2000;
    cout << sourui(r, d, x2000) << endl;
    ans = sourui(r, d, x2000);
    for (int i=1; i<10; ++i){
        ans = sourui(r, d, ans);
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long H = sc.nextLong();
		long W = sc.nextLong();
		
		System.out.println((H==1 || W==1) ? 1 : (H*W+1)/2);

		sc.close();
	}
}


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

typedef long long ll;

string A[2];
ll Q;
vector<ll> X[2];

int main() {
  cin >> A[0] >> A[1] >> Q;
  for (ll k : {0, 1}) {
    string &a = A[k];
    vector<ll> &x = X[k];
    x.push_back(0);
    for (char c : a) x.push_back(x.back() + (c == 'A' ? 1 : 2));
  }
  for (ll q = 0; q < Q; ++q) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    --a;
    --c;
    bool ok = abs((X[0][b] - X[0][a]) - (X[1][d] - X[1][c])) % 3 == 0;
    cout << (ok ? "YES" : "NO") << endl;
  }
  return 0;
}


Measured memory_bytes: 2872
N = int(input())
A = [int(input()) for _ in range(N)]
MAX = max(A)
AA = A[:]
AA.pop(A.index(MAX))
SECOND = max(AA)
for a in A:
    if a == MAX and a == SECOND:
        print(MAX)
    elif a == MAX and a != SECOND:
        print(SECOND)
    else:
        print(MAX)

Measured memory_bytes: 14164
#include <stdio.h>

int main( void ) {
  int i, j, k, l, m, n;
  char ch[ 100000 ], pre[ 100000 ];
  int count, c, cur;
  
  while( 1 ) {
    scanf( "%d", &n );
    if( !n ) break;

    scanf( "%s", ch );

    for( i = 0; i < n; i++ ) {
      for( j = 0, l = 0; ch[ j ]; ) {
        count = 1;
        cur = ch[ j ] - '0';

        for( k = j + 1; ch[ k ] == ch[ j ]; k++ )
          count++;

        j = k;

        c = count;
        for( k = 0; c >= 10; k++ )
          c /= 10;

        for( m = l + k; count; m--, count /= 10 )
          pre[ m ] = ( count % 10 ) + '0';

        pre[ l + k + 1 ] = cur + '0';
        
        l += 2 + k;
      }
      pre[ l ] = 0;
      
      for( j = 0; pre[ j ]; j++ )
        ch[ j ] = pre[ j ];
      ch[ j ] = 0;
    }

    printf( "%s\n", ch );
  }

  return ( 0 );
}

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

using namespace std;

int main()
{
    int n,sum=0,var;
    cin>>n;
    var = n;
    while (n)
    {
        sum += n % 10;
      n/=10;
    }
    if(var % sum == 0)
    {
        cout<<"Yes";

    }else cout<<"No";
    return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

string s;

signed main() {
    cin >> s;
    rep(i,2) {
        if (s[i] != s[i+1]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};
 
char ara[25][25];
int color[25][25],dis[25][25];
 
bool valid(int i,int j,int n,int m)
{
	return i>=0 && i<n && j>=0 && j<m && ara[i][j]=='.';
}
 
void bfs(int r,int c,int n,int m)
{
	color[r][c]=1;
	queue<pii>q;
	q.push({r,c});
	
	while(!q.empty())
	{
		pii u=q.front();
		q.pop();
		
		for(int i=0;i<4;i++)
		{
			int x=u.first+dx[i];
			int y=u.second+dy[i];
			
			if(valid(x,y,n,m) && !color[x][y])
			{
				q.push({x,y});
				dis[x][y]=dis[u.first][u.second]+1;
				color[x][y]=1;
			}
		}
	}
}
 
int get_max(int &mx,int n,int m)
{
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) mx=max(mx,dis[i][j]);
	return mx;
}
	
void solve()
{
	int n,m;
	cin>>n>>m;
 
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>ara[i][j];
 
	int ans=-1;
 
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(ara[i][j]=='.')
			{
				memset(color,0,sizeof color);
				memset(dis,0,sizeof dis);
 
				bfs(i,j,n,m);
				get_max(ans,n,m); 
			}
		}
	}
	
	cout<<ans;
}
	
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int n, z, w;
int a[2000];

int main() {
	cin >> n >> z >> w;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = abs(a[n - 1] - w);
	if (n > 1) ans = max(ans, abs(a[n - 1] - a[n - 2]));
	cout << ans << endl;
}

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

typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const int N = 2e5+5;
const ll M = 1e6+5;

struct LiChao_min
{
	struct line
	{
		ll a, b;
		line() { a = 0; b = 0; }
		line(ll _a, ll _b) { a = _a; b = _b; }
		ll eval(ll x) { return a*x+b; }
	};

	struct node
	{
		node *l, *r; line f;

		node() { f = line(); l = nullptr; r = nullptr; }
		node(ll a, ll b) { f = line(a, b); l = nullptr; r = nullptr; }
		node(line v) { f = v; l = nullptr; r = nullptr; }
	};

	typedef node* pnode;

	pnode root; int sz;
	void init(int _sz) { sz = _sz + 1; root = nullptr; }

	void add_line(ll a, ll b) { line v = line(a, b); insert(v, -sz, sz, root); }
	ll query(ll x) { return query(x, -sz, sz, root); }

	void insert(line &v, ll l, ll r, pnode &nd)
	{
		if(!nd) { nd = new node(v); return; }

		ll trl = nd->f.eval(l), trr = nd->f.eval(r);
		ll vl = v.eval(l), vr = v.eval(r);

		if(trl <= vl && trr <= vr) return;
		if(trl > vl && trr > vr) { nd->f = v; return; }

		ll mid = (l + r) >> 1LL;
		if(trl > vl) swap(nd->f, v);
		if(nd->f.eval(mid) < v.eval(mid)) insert(v, mid + 1, r, nd->r);
		else swap(nd->f, v), insert(v, l, mid, nd->l);
	}

	ll query(ll x, ll l, ll r, pnode &nd)
	{
		if(!nd) return INF;
		if(l == r) return nd->f.eval(x);

		ll mid = (l + r) >> 1LL;
		if(mid >= x) return min(nd->f.eval(x), query(x, l, mid, nd->l));
		return min(nd->f.eval(x), query(x, mid + 1, r, nd->r));
	}
};


LiChao_min tree;
int n;
ll c,h[N],dp[N];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>c;

    for(int i=1;i<=n;i++)cin>>h[i];

    dp[1]=0LL;
    tree.init(M);
    tree.add_line(-2LL*h[1],1LL*h[1]*h[1]);
    //tree.Set(-2LL*h[1],1LL*h[1]*h[1]);

    for(int i=2;i<=n;i++){
        //dp[i]=tree.Get(h[i])+h[i]*h[i]+c;
        dp[i]=tree.query(h[i])+h[i]*h[i]+c;
        //tree.Set(-2LL*h[i],dp[i]+1LL*h[i]*h[i]);
        tree.add_line(-2LL*h[i],dp[i]+1LL*h[i]*h[i]);
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 12800
def maxHeapify(i):
    global n, h
    l = i * 2
    r = i * 2 + 1
    if l <= n and h[l-1] > h[i-1]:
        largest = l
    else:
        largest = i
    if r <= n and h[r-1] > h[largest-1]:
        largest = r

    if largest != i:
        h[i-1], h[largest-1] = h[largest-1], h[i-1]
        maxHeapify(largest)

def buildMaxHeap():
    global n
    for i in range(n // 2, 0, -1):
        maxHeapify(i)

n = int(input())
h = list(map(int, input().split()))
buildMaxHeap()
print('', *h)



Measured memory_bytes: 63696