akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
#define fs first
#define sd second
#define couts(x) cout << (x) << (" ")
#define coutn(x) cout << (x) << ("\n")
#define endl "\n"
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T1, typename T2> std::istream &operator>>(std::istream &is, std::pair<T1,T2> &p){is >> p.first >> p.second; return is; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::deque<T> &vec){ os << "deque["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;
template<class T> using V3 = V<V2<T>>;
constexpr ll MOD = 1000000007;


void solve(){
  string s; cin >> s;
  int n;
  n = (int)s.size();
  reverse(ALL(s));
  ll modu = 1;
  V<ll> dp(13,0);
  dp[0] = 1;
  FOR(i,0,n){
    V<ll> dp_pre(13,0);
    swap(dp, dp_pre);
    char c = s[i];
    if(c=='?'){
      FOR(j,0,13){
        FOR(k,0,10){
          (dp[(j+modu*k)%13] += dp_pre[j])%=MOD;
        }
      }
    }else{
      FOR(j,0,13){
        (dp[(j+modu*(c-'0'))%13] += dp_pre[j])%=MOD;
      }
    }
    (modu*=10)%=13;
  }
  coutn(dp[5]);
}


int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=2e9+7;
const long double PI = acos(0);
// }}} End Header
int main() {
	ll n;
	cin >> n;
	vector<ll> ans(n+1);
	for(ll x=1; x*x<n; x++){
		for(ll y=1; y*y<n; y++){
			for(ll z=1; z*z<n; z++){
				ll k = x*x+y*y+z*z+x*y+y*z+z*x;
				if(k <= n) ans[k]++;
			}
		}
	}
	loop(i, 1, n+1) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int t[n],x[n],y[n];
    int nx,ny,ti;
    ti=0;nx=0;ny=0;
    for(int i=0;i<n;++i){
        cin>>t[i]>>x[i]>>y[i];
        if(t[i]-ti>=abs(nx-x[i])+abs(ny-y[i])&&(t[i]-ti-abs(nx-x[i])-abs(ny-y[i]))%2==0){}else{cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1408
K = int(input())
#AB = list(map(int, input().split()))
#s = input().split()

#S = input()

sK = str(K)
fK = 0
if (len(sK) == 1):
    fK = K
elif (len(sK) == 2):
    fK = int(sK[1])
else:
    fK = int(sK[2])

if (fK == 3):
    print("bon")
elif (fK == 0 or fK == 1 or fK == 6 or fK == 8):
    print("pon")
else:
    print("hon")


Measured memory_bytes: 61688
readline = open(0).readline
N, M = map(int, readline().split())
A = [list(map(int, readline().split())) for i in range(N)]
B = [int(readline()) for i in range(M)]
print(*map((lambda Ai: sum(a*b for a, b in zip(Ai, B))), A), sep='\n')


Measured memory_bytes: 6032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<int> R[N];
  int num[N];
  int c[N];
  int ans[N];
  ll score = 0;
  for (int i = 0; i < N; i++) {
    num[i] = 0;
  }
  for (int i = 0; i < N - 1; i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    R[a].push_back(b);
    R[b].push_back(a);
    num[a]++;
    num[b]++;
  }
  for (int i = 0; i < N; i++) {
    cin >> c[i];
  }
  sort(c,c+N);
  for (int i = 0; i < N; i++) {
    int mxpoint = 99999;
    int mx = 99999;
    for (int j = 0; j < N; j++) {
      if (num[j] < mx) {
        mx = num[j];
        mxpoint = j;
      }
    }
    ans[mxpoint] = c[i];
    num[mxpoint] = 100000;
    score += c[i] * mx;
    for (int j = 0; j < R[mxpoint].size(); j++) {
      num[R[mxpoint][j]]--;
    }
  }
  cout << score << endl;
  for (int i = 0; i < N; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}

Measured memory_bytes: 1024
use std::str::FromStr;
use std::io::stdin;
use std::collections::HashSet;

fn main() {
    let n: usize = read();
    let set: HashSet<u64> = read_vec().into_iter().collect();
    println!("{}", if n == set.len() { "YES" } else { "NO" });
}

fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).err();
    line.trim().split_whitespace().
        map(|x| x.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(a);i>(b);i--)
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define mp make_pair
#define pb push_back
#define gap " "
//memset(dp,-1,sizeof(dp)) sets value to -1 of everything in dp
//vector < vector<int > > vec(n,vector<int>(m,0)) here n are rows(top to down ) and m columns all with m vectors initialised with values 0
//ARRAY OF VECTORS --> vector<int> ar[size] and to pass it in a function we use foo(vector<int>(&ar)[size])

typedef long long ll;
using namespace std;


int solve(){string s;
cin>>s;
int n=s.size();
if(s[n-1]=='s') cout<<s+"es";
else  cout<<s+'s';
    return 0;
}
int main(){
int t=1;
while(t--){
      solve();
}
return 0;
}


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

const int N = 1e5 + 10;
int n , a[N];

int main(){
  cin >> n;
  rep(i,0,n) cin >> a[i];
  ll ans = a[0] - 1 , cur = 2;
  rep(i,1,n) {
    if(a[i] <= cur) {
      if(a[i] == cur)
        cur++;
      continue;
    }
    ans += a[i] / cur - (a[i] % cur == 0);
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };

const int MAX_V = 200000;
const ll INF = 1LL<<60;

int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep(i,G[v].size()) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    cin >> V;
    int a, b;
    rep(i, V - 1) {
        cin >> a >> b;
        G[a - 1].push_back({b - 1, 1});
        G[b - 1].push_back({a - 1, 1});
    }
    dijkstra(0);
    int dmax = -1;
    a = 0;
    rep(i, V) {
        if (d[i] > dmax) {
            dmax = d[i];
            a = i;
        }
    }
    dijkstra(a);
    dmax = -1;
    rep(i, V) {
        if (d[i] > dmax) {
            dmax = d[i];
        }
    }
    if (dmax % 3 == 1) cout << "Second\n";
    else cout << "First\n";
}

Measured memory_bytes: 23092
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int h,w;
  cin>>h>>w;
  vector<string> t(h);
  for(auto&& e:t)cin>>e;
  vector<vecll> dp(h,vecll(w,0));
  dp[0][0] = 1;
  constexpr ll MOD = 1000000007;
  for(auto&& i:irange(0,h)) {
    for(auto&& j:irange(0,w)) {
      if (t[i][j] == '#') continue;
      if (i<h-1) {
        dp[i+1][j] += dp[i][j];
        dp[i+1][j] %= MOD;
      }
      if (j<w-1) {
        dp[i][j+1] += dp[i][j];
        dp[i][j+1] %= MOD;
      }
    }
  }
  cout<<dp.back().back()<<endl;
  return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

int main()
{
    int n,t;
    cin >> n;
    int c[n],s[n],f[n];
    rep(i, n - 1){
        cin >> c[i] >> s[i] >> f[i];
    }
    rep(i, n - 1){
        t = 0;
        nfor(j, i, n - 1){
            if(t < s[j]){
                t = s[j];
            }else if (t % f[j] == 0){
            }else{
                t = t + f[j] - t % f[j];
            }
            t += c[j];
        }
        cout << t << endl;
    }
    cout  << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int[] p = new int[N];
		for (int i = 0; i < N; i++)
			p[i] = scanner.nextInt();
		scanner.close();

		int cnt = 0;
		for (int i = 0; i < N; i++)
			if (p[i] != i + 1)
				cnt++;

		switch (cnt) {
		case 0:
		case 2:
			System.out.println("YES");
			break;
		default:
			System.out.println("NO");
			break;
		}
	}
}

Measured memory_bytes: 23892
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val len = input.next().length
    val ans = StringBuilder()
    
    for (i in 1..len) {
      ans.append('x')
    }
    
    println(ans)
  }
}

Measured memory_bytes: 36184
/// Solution No.:

/// Approach:

/// Comment:

/// Verdict:

/// Report:


#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <string.h>
#include <climits>
#include <set>
#include <cassert>
#include <cfloat>
#include <stack>

///using namespace std;         /// Recommended not to use

#define p(x) std::cout<<#x<<" = "<<x<<"\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define absolute(x) (((x)<0)?(-(x)):(x))
/// #define _DEBUG

typedef long long int ll;
typedef unsigned long long llu;
typedef long double lld;

/// lld pi = 2 * acos(0.0);   /// precision error
lld pi = 2 * acosl(0.0);

int test_case_number, test_case=1;

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
/// Direction Array
/// int dx[]={0, 0, 1, -1, -1, 1, -1, 1};
/// int dy[]={-1, 1, 0, 0, 1, 1, -1, -1};

///place for problem specific functions


void function_name()
{
    ll a, b, c;
    scanf("%lld %lld.%lld",&a,&b,&c);
    printf("%lld\n", a*b+ (a*c)/100);
}
void function_name(int v1, int v2, int v3)
{

}
void function_name(std::string line)
{

}
class initial_works
{
public:

    void with_test_case_number()
    {
        scanf("%d", &test_case_number);
        ///getchar();
        while(test_case <= test_case_number)
        {
            function_name();
            test_case++;
        }
    }

    void single_iteration()
    {
        function_name();
    }

    void without_test_case_number()
    {
        int v1, v2, v3;
        while(scanf("%d %d %d", &v1, &v2, &v3)==3 && v1!=0)
        {
            function_name(v1, v2, v3);
            test_case++;
        }
    }

    void eoof()
    {
        char dummy_char_array[100];
        while(scanf("%[^\n]", dummy_char_array)!=EOF)
        {
            ///it only takes the absence of one getchar to ruin your life. Don't understand remove the getchar below and then input the sample input
            getchar();
            ///if not given getchar. the dummu_char_array will not take new input as there is newline after the first input is taken. It will continue with the previous value.
            /// So, the function will run with same argument.
            std::string line = dummy_char_array;
            function_name(line);
            test_case++;
        }
    }
};


int main()
{
    //std::ios_base::sync_with_stdio(false);
    initial_works a;
    a.single_iteration();

    return 0;
}



Measured memory_bytes: 3816
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int ans = 0;
	int tmp = 0;

	int nowh; cin >> nowh;

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

		if (nowh >= h) {
			tmp++;
			nowh = h;
		}
		else {
			ans = max(ans, tmp);

			tmp = 0;
			nowh = h;
		}

	}
	ans = max(ans, tmp);

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>
#include<numeric>
#include<stdlib.h>

using namespace std;

int main()
{

  long long int a, b, x;
  cin >> a >> b >> x;

  if(a==0){
    cout << b/x + 1<< endl;
  }
  else
    cout << b/x - (a-1)/x << endl;

  return 0;
}


Measured memory_bytes: 3608
n, l = map(int, input().split())
s = n*(l-1) + n*(n+1)/2
c = abs(s)
j = 1
for i in range(n):
  t = s - (l+i)
  T = abs(s-t)
  if T < c:
    c = T
    j = i
ans = s -(l+j)
print(int(ans))

  

Measured memory_bytes: 9188
N, M = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
num_b = Array.new(N+1, 0)
num_r = Array.new(N+1, 0)
as.each do |a|
    num_b[a] += 1
    num_r[a-num_b[a]] += 1 if a-num_b[a] >= 0
end
ans = N.times.count{|i| num_r[i] == 0}

M.times do
    x, y = gets.split.map(&:to_i)
    a = as[x-1]

    pos = a-num_b[a]
    if pos >= 0
        num_r[pos] -= 1
        ans += 1 if num_r[pos] == 0
    end
    num_b[a] -= 1

    as[x-1] = y
    num_b[y] += 1
    pos = y-num_b[y]
    if pos >= 0
        num_r[pos] += 1
        ans -= 1 if num_r[pos] == 1
    end
    
    puts ans
end


Measured memory_bytes: 25132
import java.lang.Exception

fun main(args: Array<String>) {
    val reader = System.`in`.bufferedReader()

    val (w, h, n) = reader.readLine().split(" ").map(Integer::parseInt)

    val area = (0 until h).map { (0 until w).map { 1 }.toMutableList() }.toList()

    (1..n).forEach {
        val (x, y, a) = reader.readLine().split(" ").map(Integer::parseInt)

        when(a) {
            1 -> paint(area, 0, x, 0, h)
            2 -> paint(area, x, w, 0, h)
            3 -> paint(area, 0, w, 0, y)
            4 -> paint(area, 0, w, y, h)
            else -> throw Exception()
        }
    }

    println(area.map { it.sum() }.toList().sum())
}

fun paint(area: List<MutableList<Int>>, sw: Int, ew: Int, sh: Int, eh: Int) {
    (sh until eh).forEach { i -> (sw until ew).forEach { j -> area[i][j] = 0 } }
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x,y;
    x=max(a*c,a*d);
    x=max(x,b*c);
    x=max(x,b*d);
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))
total = sum(A)

def solver(k):
    global ans
    ans = [k]
    for i in range(N - 1):
        ans.append(2 * A[i] - ans[i])
    if not ans[0] + ans[-1] == 2 * A[-1]:
        x = (2 * A[-1] - ans[0] - ans[-1]) // 2
        for i in range(N):
            if i % 2 == 0:
                ans[i] += x
            else:
                ans[i] -= x
solver(0)
print(" ".join(map(str, ans)))

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

int ans=0;

void dfs(int x, int y, int b,int ice[94][95]) {
	if (ice[x - 1][y] == 0 && ice[x + 1][y] == 0 && ice[x][y - 1] == 0 && ice[x][y + 1] == 0) {
		if (ans < b)ans = b;
		return ;
	}
	else b++;

	ice[x][y] = 0;

	for (int i = -1;i <= 1;i += 2) {
		int ax = x + i;
		int ay = y + i;
		if (ice[ax][y] == 1) {
			ice[x][y] = 0;
			dfs(ax, y, b,ice);
		}
		if (ice[x][ay] == 1) { 
			ice[x][y] = 0;
			dfs(x, ay, b,ice);
		}

	}
	ice[x][y] = 1;
	return;
}

int main() {
	int m, n;
	while (cin >> m >> n, m, n) {
		ans = 0;
		int ice[95][95];
		for (int i = 0;i < n+2;i++) {
			for (int j = 0;j < m+2;j++) {
				if (i == 0 || i == n + 1)ice[i][j] = 0;
				else if (j == 0 || j == m + 1)ice[i][j] = 0;
				else cin >> ice[i][j];
			}
		}

		for (int i = 1;i <= n;i++) {
			for (int j = 1;j <= m;j++) {
				if (ice[i][j] == 1)dfs(i, j, 1,ice);
			}
		}
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 3128
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

ll ans,x;

void zzz(ll p,ll q){
  ans=min(ans,abs(p-x)+abs(p-q));
}

void vvv(ll p,ll q){
  zzz(p,q);
  zzz(q,p);
}

int main(){
  ll n;
  ll a,b,q;
  cin>>a>>b>>q;
  vector<ll>v1(a,0);
  vector<ll>v2(b,0);
  for(ll i=0;i<a;i++){
    cin>>v1[i];
  }
  for(ll i=0;i<b;i++){
    cin>>v2[i];
  }
  v1.push_back(-1*(1e+11));
  v1.push_back((1e+11));
  v2.push_back(-1*(1e+11));
  v2.push_back((1e+11));
  sort(v1.begin(),v1.end());
  sort(v2.begin(),v2.end());
  for(ll i=0;i<q;i++){
    ans=(1e+12);
    cin>>x;
    auto u1=lower_bound(v1.begin(), v1.end(), x);
    auto u2=lower_bound(v2.begin(), v2.end(), x);
    ll a2=*u1;
    u1--;
    ll a1=*u1;
    ll b2=*u2;
    u2--;
    ll b1=*u2;
    vvv(a1,b1);
    vvv(a1,b2);
    vvv(a2,b1);
    vvv(a2,b2);
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 4576
open System
let readInt () = stdin.ReadLine() |> int

let A = readInt ();
let B = readInt ();
let C = readInt ();
let X = readInt ();

seq {for i in 0..A do
         for j in 0..B do
              for k in 0..C do
                  yield i * 500 + j * 100 + 50 * k}
|> Seq.sumBy (fun v -> if v = X then 1 else 0)
|> printfn "%d"


Measured memory_bytes: 14044
N, M, Q = map(int, input().split())
A = []

for i in range(Q):
  A.append(list(map(int, input().split())))

def calc(B, n):
  ans = 0
  #not enough length
  if len(B) < N:
    for i in range(n, M + 1):
      ans = max(ans, calc(B + [i], i))
  #enough length
  else:
    #print("B:", B)
    for j in range(Q):
      if B[A[j][1]-1] - B[A[j][0]-1] == A[j][2]:
        ans += A[j][3]
    #print("ans:", ans)
  return ans



print(calc([], 1))


Measured memory_bytes: 9112
#include<iostream>
#include<cmath>
using namespace std;
int main(void)
{
  int n, k;
  int ans=0;
  cin>>n>>k;
  for(int i=0; i<n; i++)
    {
      int x;
      cin>>x;
      ans+=2*min(x, abs(k-x));
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define ALL(x) (x).begin(),(x).end()
const char* LF = "\n";
template <class T> void chmin(T& a, const T& b) { if (b < a) a = b; }
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

int n;
int abc[3];
vector<int> li;
vector<int> mplist;
int minmp = 1e7;

void find(int depth, vector<int> v) {
    if (depth == n) {
        int mp = 0, cnt[3] = {0,0,0};
        REP(i, 3) {
            cnt[i] = count(ALL(v), i);
            if (cnt[i] == 0) return;
            mp += 10 * (cnt[i] - 1);
        }
        int res[3] = {0,0,0};
        REP(i, n) {
            if (v[i] == 3) continue;
            res[v[i]] += li[i];
        }
        REP(i, 3) {
            mp += abs(res[i] - abc[i]);
        }
        chmin(minmp, mp);
        return;
    }
    REP(i, 4) {
        v[depth] = i;
        find(depth + 1, v);
    }
}

signed main() {
    cin >> n >> abc[0] >> abc[1] >> abc[2];
    li.resize(n);
    REP(i, n) {
        cin >> li[i];
    }
    find(0, vector<int>(n, 0));
    cout << minmp << LF;
    return 0;
}


Measured memory_bytes: 256
N, T = map(int, input().split())
res = -1

for i in range(N):
  t1, t2 = map(int, input().split())
  if t2 <= T and (t1 < res or res < 0):
    res = t1

if res >= 0:
  print(res)
else:
  print("TLE")

Measured memory_bytes: 3060
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{
  ll n;
  cin >> n;

  ll ans = -1;
  rep(i,50000)
  {
    ll x = i * 1.08;
    if(x == n)
    {
      ans = i;
      break;
    }
  }

  if(ans == -1)
  {
    cout << ":(" << endl;
  }
  else
  {
    cout << ans << endl;
  }
  


  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include<iostream>
    #include<cmath>
    using namespace std;
    void solution()
    {
    	long long int n, x, t,res; 
      cin >> n >> x >> t;
    	res = ceil(n * 1.0 / x);
    	cout << res*t<<"\n";
    	
    	
    }
    int main()
    {
      int t = 1; 
    	while (t--)
    		solution();
    	return 0;
    }

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    string n; cin >> n;

    bool seven = false;

    for (int i = 0; i < n.length(); ++i) {
        if (n[i] == '7') seven = true;
    }

    if (seven) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 3628
n = int(input())
a = list(map(int,input().split()))
now = 1000
kab = 0
for i in range(n-1):
    if a[i] < a[i+1]:
        kab += now//a[i]
        now = now%a[i]
    if a[i+1] < a[i]:
        now += a[i]*kab
        kab = 0
now += a[-1]*kab
print(now)

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    if(n % 2 == 0){
        cout << n * (n - 2) / 2 << "\n";
        for(int i = 1; i <= n; ++i){
            for(int j = i + 1; j <= n; ++j){
                if(i + j == n + 1) continue;
                cout << i << " " << j << "\n";
            }
        }
        return 0;
    }
    else{
        cout << (n - 1) * (n - 3) / 2 + n - 1 << "\n";
        for(int i = 1; i <= n - 1; ++i){
            cout << i << " " << n << "\n";
        }
        --n;
        for(int i = 1; i <= n; ++i){
            for(int j = i + 1; j <= n; ++j){
                if(i + j == n + 1) continue;
                cout << i << " " << j << "\n";
            }
        }
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
//prepared by dumb
#include<bits/stdc++.h>
using namespace std;
#define   ll long long int
#define   dl double
#define   llu unsigned long long int
#define   scll(x) scanf("%lld",&x)
#define   scld(x) scanf("%lf",&x)
#define   scull(x) scanf("%llu",&x)
#define   scch(x) scanf(" %c",&x)
#define   pb(x) push_back(x)
#define   pf(x) push_front(x)
#define   ppb() pop_back()
#define   ppf() pop_front()
#define   Pi acos(-1.0)
#define   INF 1000000000000000000
#define   mod 1000000007
#define   ff first
#define   ss second
#define   mpr make_pair
#define   debug(x) cout<<x<<'\n';
//sin((x*pi)/180.0)[x in degree]
//sin(x)[x in radian]
//asin(x)[radian]
//(asin(x)*180)/pi[degree]
//or(|)//and(&)//xor(^)//not(~)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n,m;
char  arr[100][100],brr[100][100];
void renew( )
{
  ll i,j;
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
       brr[i][j]=arr[i][j];     
  }
}
bool check(ll k) 
{
  ll cnt=0,i,j;
   for(i=0;i<n;i++)
   {
    for(j=0;j<m;j++)
    {
      if(brr[i][j]=='#')
        cnt++;
    }
   }
   if(cnt==k)
   return true;
 else
  return false;
}
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ll a, b, c = 1, d, e, f = 0, g, h, i, j, k, l, o, p, q, r, s, t, u, v, w, x, y, z;
  ll cnt = 0, ans = 0, l1, l2, l3, c1 = 0, c2 = 0, c3 = 0, mx = 0, mn = 0;
  ll prevsum = 0, ans1 = 0, ans2 = 0, odd = 0, even = 0, hh, mm;
  string  str1, str2, str;
   scll(n);
   scll(m);
   scll(x);
       for(i=0;i<n;i++)
       {
        for(j=0;j<m;j++){
          scch(arr[i][j]);
        }
       }
       for(i=0;i<(1LL<<n);i++)
       {
        for(j=0;j<(1LL<<m);j++)
        {
          renew( );
           
           for(k=0;k<n;k++)
           {
            if(i&(1LL<<k))
            {
              for(l1=0;l1<m;l1++)
                brr[k][l1]='R';
            }
           }
           for(k=0;k<m;k++)
           {
            if(j&(1LL<<k))
            {
           for(l1=0;l1<n;l1++)
            brr[l1][k]='R';
            }
           }
           if(check(x))
              ans++;
        }
      }

        cout<<ans;   
          

  return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#define N 10000
#define Q 500
#define NOT_FOUND -1

int LinearSearch(int, int [], int );

int main(){
    int n, q; //number of data
    int S[N], T[Q]; //universe of data
    int cnt = 0; //count of same data
    int i;
    
    //input num of data and actual data
    scanf("%d", &n);
    for (i = 0; i<n; i++)
	scanf("%d", &S[i]);
    scanf("%d", &q);
    for (i = 0; i<q; i++)
	scanf("%d", &T[i]);

    //count the same data
    for (i = 0; i<q; i++){
	if (LinearSearch(n, S, T[i]) != NOT_FOUND)
	    cnt++;
    }
    
    //display the result
    printf("%d\n", cnt);

    return 0;
}

int LinearSearch( int n,int S[], int key ){
    int i = 0;

    S[n] = key;//as a sentinel
    while (S[i] != key)
	i++;
    if (i == n)
	return NOT_FOUND;
    return i;
}



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

int main(){
  string s;
cin >> s;
bool ans =false;
for(int i=0;i<s.size();i++){
for(int j=i;j<s.size();j++){
if(s.at(i) == 'C'&& s.at(j) == 'F'){
ans =true;
break;
}
}
if(ans) break;
}

if(ans) cout << "Yes" << endl;
else cout << "No" << endl;
}

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

switch ($s) {
    case 'SUN':
        echo "7\n";
        break;
    case 'MON':
        echo "6\n";
        break;
    case 'TUE':
        echo "5\n";
        break;
    case 'WED':
        echo "4\n";
        break;
    case 'THU':
        echo "3\n";
        break;
    case 'FRI':
        echo "2\n";
        break;
    case 'SAT':
        echo "1\n";
        break;
}

?>

Measured memory_bytes: 4728
W=str(input())
cnt=[0 for i in range(26)]
ans="Yes"
for i in range(len(W)):
    for j in range(26):
        if ord(W[i])==97+j:
            cnt[j]+=1

for s in range(26):
    if cnt[s]%2!=0:
        ans="No"
print(ans)

Measured memory_bytes: 8948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[101][10001];


	
int main (){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	//input
	int n,w;
	cin >> n >> w;
	vector<int> W(n);
	vector<int> V(n);
	for(int i=0;i<n;i++)cin >> V[i] >> W[i];

	//algorithm
	for(int i=1;i<=n;i++){
		for(int j=1;j<=w;j++){
			if(j<W[i-1])dp[i][j]=dp[i-1][j];
			else dp[i][j]=max(dp[i-1][j],dp[i][j-W[i-1]]+V[i-1]);
		}
	}
	/*for(int i=0;i<=n;i++){
		for(int j=0;j<=w;j++)cout << dp[i][j]<<' ';
		cout << endl;
	}*/

	cout << dp[n][w] << endl;
	
}





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

#define ll long long

ll dp[3][100001],n,a,b,c;

int main()
{
//    freopen("a.in","r",stdin);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a>>b>>c;
        dp[0][i]=a+max(dp[1][i-1],dp[2][i-1]);
        dp[1][i]=b+max(dp[0][i-1],dp[2][i-1]);
        dp[2][i]=c+max(dp[0][i-1],dp[1][i-1]);
    }
    cout<<max(dp[0][n],max(dp[1][n],dp[2][n]));
}




Measured memory_bytes: 2560
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC diagnostic error "-std=c++14"

#define isNum(a) (a>='0'&&a<='9')
#define SP putchar(' ')
#define EL putchar('\n')
#define ri register int

template<class T>
inline void in(T&);
template<class T>
inline void out(const T&);

typedef long long ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
using namespace std;

int a,b; 

int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    in(a);in(b);
    int ans=a-2*b;
    if (ans<0) ans=0;
    out(ans);EL;
    return 0;
}

template<class T>
void in(T &Re)
{
    T k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch))
	{
        if (ch=='-')
		{
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch))
	{
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    Re=flag*k;
}

template<class T>
void out(const T &Wr)
{
    if (Wr<0)
	{
        putchar('-');
        out(-Wr);
    }
	else
	{
        if (Wr<10)
		{
            putchar(Wr+'0');
        }
		else
		{
            out(Wr/10);
            putchar((Wr%10)+'0');
        }
    }
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;

long long powerMod(long long number,long long power,long long mod)
{
    LL ret=0;

    if(power==0) return 1LL%mod;
    if(power==1) return number%mod;
    if(power%2==0)
    {
        ret=powerMod(number,power/2,mod);
        ret=(ret%mod*ret%mod)%mod;
        return ret%mod;
    }
    else
    {
        ret=powerMod(number,power/2,mod);
        ret=(ret%mod*ret%mod*number%mod)%mod;
        return ret%mod;
    }
}

int main()
{

    int n;
    cin>>n;

    int a[n];
    int count=0,dount=0;;

    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%2==0)
            count++;

    }

    for(int i=0;i<n;i++)
    {
        if(a[i]%2==0)
            {
                if(a[i]%3==0 || a[i]%5==0)
                    dount++;
            }

    }

    if(count==dount)
        cout<<"APPROVED";
    else
        cout<<"DENIED";


    return 0;
}

/*

*/


Measured memory_bytes: 256
N,C=map(int,input().split())
XV=[list(map(int,input().split())) for i in range(N)]

RIGHTSUM=[0]

for x,v in XV:
    RIGHTSUM.append(RIGHTSUM[-1]+v)

LEFTSUM=[0]

for x,v in XV[::-1]:
    LEFTSUM.append(LEFTSUM[-1]+v)

RIGHT=[]

for i in range(N):
    RIGHT.append(RIGHTSUM[i+1]-XV[i][0])

LEFT=[]

for i in range(N):
    LEFT.append(LEFTSUM[i+1]-(C-XV[-i-1][0]))


RIGHTMAX=[RIGHT[0]]

for i in range(1,N):
    RIGHTMAX.append(max(RIGHTMAX[i-1],RIGHT[i]))

LEFTMAX=[LEFT[0]]

for i in range(1,N):
    LEFTMAX.append(max(LEFTMAX[i-1],LEFT[i]))

ANS=max(max(RIGHT),max(LEFT),0)
#print(ANS)
for i in range(N-1):
    #print(i,RIGHTSUM[i+1]-XV[i][0]*2+LEFTMAX[N-i-2],LEFTSUM[i+1]-(C-XV[-i-1][0])*2+RIGHTMAX[N-i-2])
    if ANS<(RIGHTSUM[i+1]-XV[i][0]*2)+LEFTMAX[N-i-2]:
        ANS=RIGHTSUM[i+1]-XV[i][0]*2+LEFTMAX[N-i-2]
    if ANS<LEFTSUM[i+1]-(C-XV[-i-1][0])*2+RIGHTMAX[N-i-2]:
        ANS=LEFTSUM[i+1]-(C-XV[-i-1][0])*2+RIGHTMAX[N-i-2]

print(ANS)
    


Measured memory_bytes: 48344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    ll m = 0;
    rep(i, 0, n+1) {
        if (i*(i+1)/2 >= n) {
            m = i;
            break;
        }
    }
    rep(i, 1, m+1) {
        if (i == m*(m+1)/2 - n) continue;
        cout << i << endl;
    }
}

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

using namespace std;
using ll = long long;


int main(){
    ll N = 0;
    cin >> N;
    vector<ll> A(N,0);
    for(ll i = 0; i < N; i++) {
    cin >> A.at(i);
    }
    ll ans = 0;
    ll ansa;
    vector<ll> sum(N,0);
    vector<ll> suma(N,0);
    if (A.at(0))
    {sum.at(0) = A.at(0);
    ansa= abs(A.at(0)+(abs(A.at(0))/A.at(0)));
    suma.at(0) = -1*(abs(A.at(0))/A.at(0));
    }
    else
    {
        ans = 1;
        ansa = 1;
        sum.at(0) = 1;
        suma.at(0) = -1;
    }
    
    for (size_t i = 1; i < N; i++)
    {
        sum.at(i) = sum.at(i-1)+A.at(i);
        if (sum.at(i)*sum.at(i-1)<0)
        {
            continue;
        }else
        {
            ans += abs(sum.at(i)+(abs(sum.at(i-1))/sum.at(i-1)));
            sum.at(i)=-1*(abs(sum.at(i-1))/sum.at(i-1));
        }
        
        
    }
    for (size_t i = 1; i < N; i++)
    {
        suma.at(i) = suma.at(i-1)+A.at(i);
        if (suma.at(i)*suma.at(i-1)<0)
        {
            continue;
        }else
        {
            ansa += abs(suma.at(i)+(abs(suma.at(i-1))/suma.at(i-1)));
            suma.at(i)=-1*(abs(suma.at(i-1))/suma.at(i-1));
        }
    }
    //cout << ans << endl;
    cout << min(ans,ansa) << endl;
    /*
    cout << 42123432 << endl;
    cout << sum.at(0) << endl;
    cout << suma.at(0) << endl;
    cout << sum.at(1) << endl;
    cout << suma.at(1) << endl;
*/
    return 0;
}

/*int main() {
    int N = 0;
    cin >> N;
    vector<int> A(N,0);
    for(int i = 0; i < N; i++) {
    cin >> A.at(i);
    }
    int ans = abs(A.at(0)-1);
    int ansa = abs(A.at(0)+1);

    for (size_t i = 1; i < N; i++)
    {
        ans +=abs(A.at(i)-(pow(-1,i)*(2)));
    }
    for (size_t i = 1; i < N; i++)
    {
        ansa +=abs(A.at(i)-(pow(-1,i)*(-2)));
    }
    cout << min(ans,ansa) << endl;
    

    return 0;
}
*/

Measured memory_bytes: 5612
def f():
    return int(raw_input())
def f2():
    return map(int, raw_input().split())

def merge(left, mid, right):
    L = S[left:mid]
    R = S[mid:right]
    lp, rp, xp = 0, 0, 0
    a, b = L[0], R[0]
    c = right - left
    x = [0] * c
    while xp < c:
        while xp < c and a <= b:
            x[xp] = a
            lp += 1
            xp += 1
            try:
                a = L[lp]
            except:
                for e in R[rp:]:
                    x[xp] = e
                    xp += 1
#                    rp += 1
                break
        while xp < c and a >= b:
            x[xp] = b
            rp += 1
            xp += 1
            try:
                b = R[rp]
            except:
                for e in L[lp:]:
                    x[xp] = e
                    xp += 1
#                    lp += 1
                break
    S[left:right] = x
    return c

def mergesort(left, right):
    c = 0
    if left + 1 < right:
        mid = (left + right)/2
        c += mergesort(left, mid)
        c += mergesort(mid, right)
        c += merge(left, mid, right)
    return c

global S
n = f()
S = f2()

c = mergesort(0, n)
print " ".join(map(str,S))
print c

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

struct MedianFinder {
  priority_queue<int> small;
  priority_queue<int, vector<int>, greater<>> large;
  int64_t s1 = 0, s2 = 0;
  void addNum(int num) {
    small.push(num);
    s1 += num;
    large.push(small.top());
    s2 += small.top();
    s1 -= small.top();
    small.pop();
    if (small.size() < large.size()) {
      s1 += large.top();
      small.push(large.top());
      s2 -= large.top();
      large.pop();
    }
  }

  int findMedian() {
    return small.top();
  }
};

void solve(std::istream &in, std::ostream &out) {
  int Q;
  in >> Q;
  MedianFinder median;
  int64_t sumb = 0;
  for (int i = 0; i < Q; ++i) {
    int a, b;
    in >> a;
    if (a == 1) {
      in >> a >> b;
      sumb += b;
      median.addNum(a);
    } else {
      int m = median.findMedian();
      out  << m << ' ' << sumb - median.s1 + median.s2 + (int64_t) m * ((int)median.small.size() - (int)median.large.size()) << '\n';
    }
  }
}

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

int main(){
  int N,r,q;
  cin >> N;
  r = 0;
  q = N;
  while (q > 0){
    r += q%10;
    q = q/10;
  }
  if (N%r == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("Yes")
#define p_no() p("No")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N; 
    cin >> N;

    FOR(i, 1, 10){
      FOR(j, 1, 10){
        if(i*j==N) yes();
      }
    }
    no();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int sum = 0, tmp = n;
  while(tmp>0){
    sum += tmp % 10;
    tmp /= 10;
  }
  if(n % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256