akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define ll   long long
#define ld   long double
#define N    200256
#define M    1000000007
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() );
using namespace std;
ll n, a[N], sum, sm, ans=I;
void solve()
{
    cin >> n;
    for( int i = 0; i < n; i ++ )
    {
        cin >> a[i];
        sum +=a[i];
    }
    for( int i = 0; i < n; i ++ )
    {
        sm += a[i];
        sum -= a[i];
        ans = min( ans, abs( sum - sm ));
    }
    cout << ans;

}
int main()
{
    ll tt = 1;
    //sc( "%d", &tt );
    for( ll i = 1; i <= tt; i ++ )
    {
        solve();
    }
}












Measured memory_bytes: 1792
# -*- coding: utf-8 -*-


def main():
    from collections import Counter

    n = int(input())
    a = list(map(int, input().split()))
    b = Counter(a)
    ans = 0

    for key, value in b.items():
        if value > key:
            ans += value - key
        elif value < key:
            ans += value

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

const int md = int(1e9) + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

const int N = 100010;

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

  vector<int> fac(N * 2), finv(N * 2);
  fac[0] = finv[0] = 1;
  for (int i = 1; i < 2 * N; i++) {
    fac[i] = mul(fac[i - 1], i);
    finv[i] = inv(fac[i]);
  }

  auto get = [&](int m, int n) {
    int res = fac[m + n];
    res = mul(res, finv[m]);
    res = mul(res, finv[n]);
    return res;
  };

  int ans = 0, l, r;
  for (int i = 0; i < h - a; i++) {
    l = get(i, b - 1);
    r = get(h - i - 1, w - b - 1);
    add(ans, mul(l, r));
  }
  cout << ans << '\n';
  return 0;
}


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

int main()
{
	long long int a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << "0" << endl;
	else cout << min({a * b, b * c, a * c}) << endl;
	return 0;

}


Measured memory_bytes: 256
def warshall_floyd(n,d):
    #d[i][j]: iからjへの最短距離
    r = [[float("inf")]*n for i in range(n)]
    for k in range(n):
        for i in range(n):
            for j in range(n):
                r[i][j] = min(d[i][j],r[i][k] + r[k][j])
    return r

n = int(input())
a = [[] for i in range(n)]
for i in range(n):
    a[i] = list(map(int,input().split()))
for i in range(n):
    if a[i][i] != 0:
        print(-1)
        exit()


war = warshall_floyd(n,a)

res = 0
for i in range(n):
    for j in range(n):
        if war[i][j] < a[i][j]:
            print(-1)
            exit()
        elif war[i][j] == a[i][j]:
            judge = 1
            for h in range(n):
                if h != i and h != j and war[i][h]+war[h][j] == war[i][j]:
                    judge = -1
            if judge == 1:
                res += war[i][j]
print(res//2)


Measured memory_bytes: 96892
n, k = map(int, input().split())
A = list(map(int, input().split()))
count = 0

for i in A:
    if i == 1:
        count += 1
        
if (n - k * count) % (k - 1)  != 0:
    ans =count +  (n - k * count) // (k - 1) + 1
else:
    ans = count + (n - k * count) // (k - 1) 

print(ans)

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

using ll = long long;
using ld = long double;

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());


class BMultipleOf9 {
public:
  
  void solve(std::istream& cin, std::ostream& cout) {
    string s;
    cin >> s;
    ll sum = 0;
    for (char c: s) {
      sum += c - '0';
    }
    cout << (sum % 9 == 0 ? "Yes" : "No") << '\n';
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	BMultipleOf9 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3744
class UnionFind
  attr_reader :id, :sz

  # @param {Integer} n
  def initialize(n)
    @id = Array.new(n)
    @sz = Array.new(n)
    n.times do |i|
      @id[i] = i
      @sz[i] = 1
    end
  end

  def connected?(i, j)
    root(i) == root(j)
  end

  def unite(i, j)
    iroot = root(i)
    jroot = root(j)
    return if iroot == jroot
    if @sz[iroot] < @sz[jroot]
      @id[iroot] = j
      @sz[jroot] += @sz[iroot]
    else
      @id[jroot] = i
      @sz[iroot] += @sz[jroot]
    end
  end

  private

  def root(i)
    if @id[i] == i
      i
    else
      @id[i] = @id[@id[i]] # pass compression
      root(@id[i])
    end
  end
end


n,m = gets.split.map(&:to_i)

uf = UnionFind.new(n)

m.times do |i|
  a,b = gets.split.map(&:to_i)
  uf.unite(a-1,b-1)
end

puts uf.sz.max


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

namespace _0359
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] weekNames = { "sun", "mon", "tue", "wed", "thu", "fri", "sat" };
            DateTime d = new DateTime(2017, 9, RInt());
            Console.WriteLine(weekNames[(int)d.DayOfWeek]);
        }
        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: 19876
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[] for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()
    


Measured memory_bytes: 97160
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// 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();
}

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

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);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

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

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

  int N, M;
  cin >> N >> M;
  UnionFind uf(N);
  vector<int> p(N);
  rep(i, N) cin >> p[i], p[i]--;
  rep(i, M) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    uf.merge(x, y);
  }

  int ans = N;
  rep(i, N) {
    if (!uf.issame(i, p[i])) ans--;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
import java.util.*;
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();
  }
int sum = (int)Math.abs(a[0]) + (int)Math.abs(a[N-1]);
for(int i = 1;i < N;i++){
  sum += (int)Math.abs(a[i] - a[i-1]);
}
System.out.println(sum - (int)Math.abs(a[1]-a[0]) - (int)Math.abs(a[0]) + (int)Math.abs(a[1]));
for(int i = 1;i < N-1;i++){
  System.out.println(sum - (int)Math.abs(a[i]-a[i-1]) - (int)Math.abs(a[i+1]-a[i]) + (int)Math.abs(a[i+1] - a[i-1]));
}
System.out.println(sum - (int)Math.abs(a[N-1]-a[N-2]) - (int)Math.abs(a[N-1]) + (int)Math.abs(a[N-2]));
}}



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

int main(){
  
  int A,B,N;
  cin >> N >> A >> B;
  
  if(A*N < B){
    cout << A*N << endl;    
    
  }
  
  if(A*N > B){
    cout << B << endl;
  
  }
  
  if(A*N == B){
    cout << B << endl;
  }
  
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  
  vector<int> vec(101);
  
  for(int i = 0; i < n; i++) cin >> vec[i];
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int alice = 0;
  int bob = 0;
  
  for(int i = 0; i < n; i+=2) alice += vec[i];
  
  for(int i = 1; i < n; i+=2) bob += vec[i];
  
  cout << alice - bob << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

//5???????????????????????????????????????
public class Main {
	static Scanner sc = new Scanner(System.in);
	private static final int PEOPLE = 5; //?????????????????????????????°

	public static void main(String[] args) {
		while(true) {
			List<Integer> people = new ArrayList<Integer>();
			int[] ans = new int[PEOPLE];
			people.add(sc.nextInt());
			if(people.get(0) == 0) { //1???????????\??????0?????¨???
				break;
			}
			//2?????????????????\??????????´??????????????????°?????????
			for(int $ = 1; $ < PEOPLE; $++) { //PEOPLE - 1?????°?????????
				people.add(sc.nextInt());
			}

			//?????????????????????
			if(people.contains(1) && people.contains(2) && people.contains(3)) { //?????£???????????£?????¨???
				Arrays.fill(ans, 3);
			} else if(people.contains(1) && people.contains(2)) { //??°?????¨?????§??????????????¨???
				ans = jugh(people, 1, 2);
			} else if(people.contains(1) && people.contains(3)) { //??°?????¨?????????????????¨???
				ans = jugh(people, 3, 1);
			} else if(people.contains(2) && people.contains(3)){ //?????§?????¨?????????????????¨???
				ans = jugh(people, 2, 3);
			} else { //????????????????????¨?????????????????¨???
				Arrays.fill(ans, 3);
			}

			for(int $ = 0; $ < PEOPLE; $++) {
				System.out.println(ans[$]);
			}
		}

	}

	public static int[] jugh(List<Integer> list, int win, int lose) {
		int[] ans = new int[list.size()];
		for(int $ = 0; $ < PEOPLE; $++) {
			if(list.get($) == win) {
				ans[$] = 1;
			} else {
				ans[$] = 2;
			}
		}
		return ans;
	}

}

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

using namespace std;

typedef long long ll;

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 (a>b) { a=b; return 1; } return 0; }

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

	int n;
	cin >> n;

	vector<ll> a(n);
	rep(i, n) cin >> a[i];


	ll dp[n+1][6];
	ll INF = 1e18;

	rep(i, n+1) rep(j, 3) dp[i][j] = -INF;
	rep(i, 3) if(i < n) dp[i][i] = a[i];
	
	rep(i, n) rep(j, 3){
		for(int d = 0; j + d < 3; d++){
			int bef = i - 2 - d;
			if(bef < 0) continue;
			chmax(dp[i][j+d], dp[bef][j] + a[i]);
		}
	}

	ll ans = -INF;
	int d = 1 + n%2;
	rep(i, d+1){
		int j = n - 1 - i;
		if(j >= 0) chmax(ans, dp[j][d - i]);
	}

	cout << ans << endl;
}


Measured memory_bytes: 14260
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int n;
	cin >> n;
	vi w(n);
	rep(i,n) cin >> w[i];

	int ans = INF;
	for(int t = 1; t <= 100; t++){
		int lower = 0,upper = 0;
		for(int i = 0; i < n; i++){
			if(i <= t) lower += w[i];
			else upper += w[i];
		}
		ans = min(ans,abs(upper-lower));
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (h * w % 2 == 0)
    {
        cout << h * w / 2 << endl;
    }
    else
    {
        cout << h * w / 2 + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#define re register
using namespace std;
#define gc getchar
#define int long long
inline int read(){
	int t=0,f=0;
	char v=gc();
	while(v<'0')f|=(v=='-'),v=gc();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=gc();
	return f?-t:t;
}
int n,a[200002],b[200002],ans,m,v[1000002],cnt;
char s[200002];
inline int ksm(re int x,re int y){
	re int ans=1;
	while(y){
		if(y&1)ans=ans*x%n;
		x=x*x%n;y>>=1;
	}
	return ans;
}
signed main(){
	n=read();
	scanf("%s",s+1);
	re int l=1,r=n;
	while(1){
		while(s[l]=='R')++l;
		while(s[r]=='W')--r;
		if(l>r)break;
		++ans;
		swap(s[l],s[r]);
	}
	printf("%d",ans);
	}

Measured memory_bytes: 4008
import java.util.*;

public class Main {
  public static void main(String[] args){

    int a,b;
    String op;
    int result=0;
    Scanner sc = new Scanner(System.in);
    while(true){
      a = Integer.parseInt(sc.next());
      op = sc.next();
      b = Integer.parseInt(sc.next());

      if(op.equals("+")){
        result = a + b;
      }else if(op.equals("-")){
        result = a - b;
      }else if(op.equals("*")){
        result = a * b;
      }else if(op.equals("/")){
        result = a / b;
      }else if(op.equals("?")){
        break;
      }
      System.out.println(result);
    }
  }
}



Measured memory_bytes: 26024
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
#define endl '\n'
using namespace std;
int f(string a, string b){
    int c = 0;
    for(int i = 0; i < a.length(); i++){
        if(a[i] != b[i])c++;
    }
    return c;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s, t; cin >> s >> t;
    int ans = 1e9;
    for(int i = 0; i < s.length(); i++){
        int x = i+t.length();
        if(x > s.length())break;
        ans = min(ans, f(t, s.substr(i,t.length())));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  string a, b;
  cin >> a >> b;

  if(a == b) pr("H");
  else pr("D");


  return 0;
}


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

using namespace std;

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

    int n;
    cin >> n;
    long long arr[n + 1], pre[n + 1], ans = 2e18;
    pre[0] = 0;

    for (int i = 1; i <= n; i++)
        cin >> arr[i], arr[i] -= i;

    sort(arr + 1, arr + n + 1);

    for (int i = 1; i <= n; i++)
        pre[i] = arr[i] + pre[i - 1];

    for (int i = 1; i <= n; i++)
        ans = min(ans, 1ll * i * arr[i] - pre[i] + (pre[n] - pre[i]) - (n - i) * arr[i]);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>

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

  int b, f, r, v;
  int room[4][3][10] = {{{}}};

  for(int i=0; i<n; i++){
    std::cin >> b >> f >> r >> v;
    room[b-1][f-1][r+-1] += v;
  }

  for(int i=0; i<4; i++){
    for(int j=0; j<3; j++){
      for(int k =0; k<10; k++){
        std::cout <<  " " << room[i][j][k];
      }
      std::cout << std::endl;
    }
    if( i<3 ){
      std::cout << "####################" << std::endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3112
def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    while True:
        odd_count = [a for a in A if a % 2 != 0]
        if len(odd_count) >= 1:
            break

        ans += 1
        A = [a // 2 for a in A]

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b >= c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = c - a, y = d - b;
    printf("%d %d %d %d\n", c-y, d+x, a-y, b+x);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cost[100002], n;
ll dp[100002];
ll jump(ll pos)
{
    if(dp[pos]!=-1)
    return dp[pos];
    if(pos == n)
    return 0;
    if(pos > n)
    return INT_MAX;

    return dp[pos] = min((abs(cost[pos] - cost[pos+1]) + jump(pos+1)) , (abs(cost[pos] - cost[pos+2]) + jump(pos+2) ));

}



int main(){
    cin >> n;
    memset(dp, -1, sizeof(dp));
    for(int i = 1; i<=n; i++)
        cin >> cost[i];
    ll ans = jump(1);
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll>m(a),n(b),q(c),f1;
    for(ll i=0;i<a;i++)cin>>m[i];
     for(ll i=0;i<b;i++)cin>>n[i];
      for(ll i=0;i<c;i++){
        cin>>q[i];
        f1.push_back(q[i]);
      }
    sort(m.begin(),m.end(),greater<ll>());
     sort(n.begin(),n.end(),greater<ll>());
    ll t=x,i=0;
    while(t--){
        f1.push_back(m[i]);
        i++;
    }
    t=y;i=0;
     while(t--){
        f1.push_back(n[i]);
        i++;
    }
    t=x+y;
    sort(f1.begin(),f1.end(),greater<ll>());
    ll ans=0;
    i=0;
    while(t--){
        ans+=f1[i];
        i++;
    }
    cout<<ans<<endl;

return 0;
}


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

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void solve(){
    int X, N;
    std::unordered_set<int> P;
    cin >> X >> N;
    for(int i = 0 ; i < N ; i++){
        int p;
        cin >> p;
        P.insert(p);
    }
    int distance = 0;
    while(true){
        int test1 = X - distance;
        int test2 = X + distance;
        if( P.find(test1) == P.end()){
            cout << test1 << endl;
            return;
        }else if( P.find(test2) == P.end()){
            cout << test2 << endl;
            return;
        }else{
            distance++;
        }
    }
    
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 3;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
using namespace std;

int main()
{
  int n;

  while (scanf("%d", &n), n){
    int sum = 0;
    for (int i = 0; i < n / 4; i++){
      int ac;
      scanf("%d", &ac);
      sum += ac;
    }
    printf("%d\n", sum);
  }
  return (0);
}

Measured memory_bytes: 1188
n = int(input())
hli = list(map(int, input().split()))

cnt = 0
while not all([x == 0 for x in hli]):
    sIdx = -1
    for i, h in enumerate(hli):
        if h != 0:
            sIdx = i
            break
    eIdx = sIdx + 1
    minNum = hli[sIdx]
    for i in range(sIdx+1, n):
        if hli[i] == 0:
            break
        eIdx = i + 1
        minNum = min(hli[i], minNum)
    for i in range(sIdx, eIdx):
        hli[i] -= minNum

    cnt += minNum
print(cnt)

Measured memory_bytes: 39408
k = int(input())
cur = [[1]*10 for i in range(11)]
if k <= 9:
  print(k)
  exit()
c = 9
i = 0
while c < k:
  i += 1
  for j in range(10):
    cur[i][j] = cur[i-1][j]
    if j != 0:
      cur[i][j] += cur[i-1][j-1]
    if j != 9:
      cur[i][j] += cur[i-1][j+1]
  if c+sum(cur[i][1:]) >= k:
    break
  else:
    c += sum(cur[i][1:])
ans = ''
for j in range(i,-1,-1):
  for l in range(10):
    if j == i and l == 0:
      continue
    if j != i and abs(l-int(ans[-1])) > 1:
      continue
    if c + cur[j][l] >= k:
      ans += str(l)
      break
    else:
      c += cur[j][l]
print(ans)

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

using namespace std;

int N;

int counter(int n) {
	if (n == 0) { return 0; }
	return counter(n >> 1) + (n & 1);
}

void print_bit(int n, int len) {
	if (len <= 0 || len >= 32)return;
	for (int i = len - 1; i >= 0; i--) {
		cout << (1 & (n >> i)) << flush;
	}
	cout << endl;
}

void solve() {
	cin >> N;
	vector<int> A(N);
	vector<vector<int> > x(N);
	vector<vector<int> > y(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		for (int j = 0; j < A[i]; j++) {
			int jx, jy;
			cin >> jx >> jy;
			jx--;
			x[i].push_back(jx);
			y[i].push_back(jy);
		}
	}

	int ans = 0;
	for (int bits = 1; bits < (1 << N); bits++) {
		bool ok = true;
		for (int i = 0; i < N; i++) {
			if (!(bits & (1 << i))) { continue; }
			for (int j = 0; j < A[i]; j++) {
				if (y[i][j] ^ ((bits >> (x[i][j])) & 1)) {
					ok = false;
				}
			}
		}
		if (ok) { 
			ans = max(ans, counter(bits));
		}
	}
	cout << ans << endl;
}

int main() {
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int a, b, k, ans = 0;
	cin >> a >> b >> k;
	chmax(a, b);
	while (k > 0) {
		k -= a;
		ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 764
n=int(input())
p=[]
for i in range(n):
  p.append((int(input()),i))
p.sort()
l=-1
s=0
mx=0
for i in range(n):
  if p[i][1]>l:
    s+=1
    mx=max(mx,s)
  else:
    s=1
  l=p[i][1]
print(n-mx)

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

int maximo(int a, int b){
    if(a > b) return a;
    return b;
}

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

    int red = 0, blue = 0;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '1')
            blue++;
        else red++;
    }

    if(blue == red)
        cout << 2*blue << endl;
    else if(red > blue)
        cout << 2*blue << endl;
    else if(blue > red)
        cout << 2*red << endl;
    
    
    
}

Measured memory_bytes: 512
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect
from fractions import gcd

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N, M = reads()
S = input()
T = input()
g = gcd(N, M)
a = N // g
b = M // g
possible = all(S[a*i] == T[b*i] for i in range(g))
print(N * b if possible else -1)


Measured memory_bytes: 66156
#!/usr/bin/env python3
from collections import deque

n, q = map(int, input().split())

graph = [deque([]) for _ in range(n + 1)]
for _ in range(n-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

a = [0] * -~n
b = [True] * -~n
for i in range(q):
    p, x = map(int, input().split())
    a[p] += x

d = deque([1])

while len(d):
    p = d.popleft()
    for i in graph[p]:
        if b[i]:
            a[i] += a[p]
            d.append(i)
            graph[i].remove(p)
print(*a[1:])


Measured memory_bytes: 164292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000100100;

ll A, B;

int main() {
    cin >> A >> B;

    ll ans = 0;
    for(ll n = A; n <= B; ++n) {
        string ns = to_string(n);
        if(ns[0] == ns[4] && ns[1] == ns[3]) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
int INF = 1e9+7;
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rep(i,b) for(auto i=0;i<(b);i++)
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  double minv, maxv, tmp;
  cin >> tmp;
  maxv = minv = tmp;
  while (cin >> tmp) {
   maxv = max(tmp, maxv);
   minv = min(tmp, minv);
  }
  cout << (maxv - minv) << endl;
  return 0;
}

Measured memory_bytes: 1280
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M= MI()
    works = []
    for _ in range(N):
        date,money = map(int,input().split())
        works.append((-money,date))
    works.sort(key = itemgetter(1),reverse = True)

    ans =0

    pri_queue = []
    for date in range(M):
        while works and works[-1][1] -1 <= date:
            heappush(pri_queue,works.pop())
        if pri_queue:
            ans += -heappop(pri_queue)[0]

    print(ans)
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 18656
#include<iostream>
using namespace std;
#define ll long long
int main(){
  ll x;
  cin >> x;
  ll ans = 0;
  ans = x / 11;
  ans *= 2;
  ll u = x % 11;
  if(u == 0){
    ans += 0;
  }
  else if(u <= 6){
    ans += 1;
  }
  else{
    ans += 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;

int h, w, n;
int sr, sc;
char t[200001];
char a[200001];
int d[4][2] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
char dir[5] = "RLDU";

int main()
{
	scanf("%d %d %d", &h, &w, &n);
	scanf("%d %d", &sr, &sc);
	scanf("%s", t);
	scanf("%s", a);

	int by, bx;
	int flag = 0;

	for (int i = 0; i < 4; i++)
	{
		by = sr;
		bx = sc;
		int temp = i - (i % 2) * 2 + 1;

		for (int j = 0; j < n && flag == 0; j++)
		{
			if (t[j] == dir[i])
			{
				by += d[i][0];
				bx += d[i][1];
			}
			if (by > h || by < 1 || bx > w || bx < 1)
			{
				flag = 1;
				break;
			}		

			if (a[j] == dir[temp])
			{
				if (by + d[temp][0] > h || by + d[temp][0] < 1 || bx + d[temp][1] > w || bx + d[temp][1] < 1)
					continue;

				by += d[temp][0];
				bx += d[temp][1];
			}
		}
	}
	
	if (flag == 0)
		printf("YES");
	else
		printf("NO");

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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 print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N; cin >> N;
    string S; cin >> S;

    int need_left = 0;
    int pointer = 0;
    rep(i,S.size()){
      if(S[i] == '(') ++pointer;
      else{
        if(pointer == 0) ++need_left;
        else --pointer;
      }
    }
    int need_right = pointer;

    string res = "";
    for (int i = 0; i < need_left; ++i) res += '(';
    res += S;
    for (int i = 0; i < need_right; ++i) res += ')';
    cout << res << endl;
}


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

using namespace std;
typedef long long ll;
#define MOD 1000000007
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() {
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];

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

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

    cout << "APPROVED" << endl;

    return 0;
}


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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
constexpr int INF = 0x3f3f3f3f; constexpr ll BINF = 0x3f3f3f3f3f3f3f3fLL;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

// Weighted Graph Template {{{
template <class T>
class WeGraph : public vector<vector<pair<int, T>>> {
	private:
		int n, m;
	public:
		WeGraph(int n, int m) : vector<vector<pair<int, T>>>(n), n(n), m(m) {}

		template <class U>
		friend istream &operator>>(istream &is, WeGraph<U> &g) {
			for (int i=0;i<g.m;i++) {
				int u, v; T l; is >> u >> v >> l;
				g[u].emplace_back(v, l);
				g[v].emplace_back(u, l);
			}
			return is;
		}

		void addDiEdge(int u, int v, const T &w) { (*this)[u].emplace_back(v, w); }
		void addDiEdge(int u, int v, T &&w) { (*this)[u].emplace_back(v, w); }

		void addEdge(int u, int v, const T &w) { addDiEdge(u, v, w), addDiEdge(v, u, w); }
		void addEdge(int u, int v, T &&w) { addDiEdge(u, v, w), addDiEdge(v, u, w); }

};
// }}}

int solve() {
	int n, m; cin >> n >> m;
	WeGraph<ll> g(n, m); cin >> g;

	vi vis(n); vll dist(n, BINF);
	using pli = pair<ll, int>;
	min_queue<pli> q;
	q.emplace(dist[0] = 0, 0);
	while (!q.empty()) {
		int u = q.top().second; q.pop();
		if (vis[u]) continue;
		vis[u] = 1;
		for (auto e : g[u]) {
			int &v = e.first; ll &w = e.second;
			if (!vis[v] && w < dist[v]) q.emplace(dist[v] = w, v);
		}
	}

	cout << accumulate(dist.begin(), dist.end(), 0LL) << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 9012
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <numeric>
#include <stack>
#include <cmath>
#include <queue>
#include <functional>
#include <complex>
#include <cstring>
#include <stdlib.h>
using namespace std;
#define endl '\n'
// #define exp 2.7182818284590452353602874713527
// #define pi acos(-1)
// typedef complex<double> comp;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// #define int long long
void solve()
{
	int n;
	cin >> n;
	int x, y;
	cin >> x >> y;
	if((y-x)%2 == 1)
		cout << "Borys";
	else
		cout << "Alice";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    double t1 = clock();
    int t;
    t = 1;
    // scanf("%d", &t);
    // cin >> t;
    // while(t--)
    for(int i = 1;i <= t;i++)
    {
        // cout << "Case #" << i << ": ";
        solve();
    }
    cerr << setprecision(10) << (clock()-t1)/CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

//return next number
string increment(string s)
{
  if(s.size()==1)
  {
    if(s[0]=='9') return "10";
    else 
    {
      s[0]++;
      return s;
    }
  }
  if(s[s.size()-1]=='9')
  {
    string t=s.substr(0,s.size()-1);
    string inc=increment(t);
    if(inc[inc.size()-1]=='0') inc.push_back('0');
    else inc.push_back(inc[inc.size()-1]-1);
    return inc;
  }
  else if(s[s.size()-1]==1+s[s.size()-2])
  {
    string t=s.substr(0,s.size()-1);
    string inc=increment(t);
    if(inc[inc.size()-1]=='0') inc.push_back('0');
    else inc.push_back(inc[inc.size()-1]-1);
    return inc;
  }
  else
  {
    s[s.size()-1]++;
    return s;
  } 
}

int main()
{
  int k;
  cin>>k;
  string ans="1";
  for (int i = 0; i < k-1; ++i)
  {
    ans=increment(ans);
    // cout<<ans<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n, k = [int(item) for item in input().split()]
v = [int(item) for item in input().split()]

ans = 0
for take in range(min(k, n)+1):
    push = k-take
    for l_take in range(take+1):
        r_take = take - l_take
        jew = v[:l_take] + v[n-r_take:]
        jew.sort()
        val = sum(jew)
        for i in range(min(push, len(jew))):
            if jew[i] < 0:
                val -= jew[i]
            else:
                break
        ans = max(ans, val)
print(ans)

Measured memory_bytes: 3064
mod = 10 ** 6 + 3

W = [1]
for i in range(1, mod):
	W.append((W[-1] * i) % mod)

def rev(a):
	return pow(a, mod - 2, mod)

def f(x, d, n):
	if d == 0:
		return pow(x, n, mod)
	else:
		d_r = rev(d)
		xdr = d_r * x % mod
		if xdr == 0:
			return 0
		elif (xdr + n - 1) >= mod:
			return 0
		else:
			return (W[xdr + n - 1] * rev(W[xdr - 1]) % mod) * pow(d, n, mod) % mod

Q = int(input())
for i in range(Q):
	x, d, n = map(int, input().split())
	print(f(x, d, n))


Measured memory_bytes: 44972
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

class unionFind {
public:
    vector <ll> par; 
    vector <ll> siz; 

    unionFind(ll n): par(n), siz(n, 1LL) {
        for (ll i = 0; i < n; ++i) par[i] = i; 
    }
    void init(ll n) {
        par.resize(n);
        siz.assign(n, 1LL); 
        for (ll i = 0; i < n; ++i) par[i] = i; 
    }

    ll root(ll x) { 
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(ll x, ll y) { 
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

using Gragh = vector<vector<int>>;

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    Gragh friends(n), blocks(n);
    unionFind tree(n);

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        friends[a].push_back(b);
        friends[b].push_back(a);
        tree.unite(a, b);
    }
    rep(i, k) {
        int c, d;
        cin >> c >> d;
        c--; d--;
        blocks[c].push_back(d);
        blocks[d].push_back(c);
    }

    vector<int> ans(n);
    rep(i, n) {
        int block_cnt = 0;
        for(auto x : blocks[i]) {
            if(tree.same(i, x)) block_cnt++;
        }
        ans[i] = tree.size(i) - friends[i].size() - block_cnt - 1;
    }
    
    for(auto x : ans) cout << x << endl;

    return 0;
}

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

class Program
{
  class Vertex
  {
    public int next;//隣接頂点
    public int distance;//隣接頂点との距離
    public int distanceR;
    public Vertex(int next, int distance, int distanceR)
    {
      this.next = next;
      this.distance = distance;
      this.distanceR = distanceR;
    }
  }
  
  static void Main()
  {
    int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    int n = nums[0];
    int m = nums[1];
    int s = nums[2] - 1;
    int t = nums[3] - 1;
    var vertexes = new List<Vertex>[n];
    for (int i = 0; i < n; i++) 
    { 
      vertexes[i] = new List<Vertex>(); 
    }
    for (int i = 0; i < m; i++)
    {
      int[] numsSub = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
      int u = numsSub[0] - 1;
      int v = numsSub[1] - 1;
      int a = numsSub[2];
      int b = numsSub[3];
      vertexes[u].Add(new Vertex(v, a, b));
      vertexes[v].Add(new Vertex(u, a, b));
    }
    foreach (long answer in Solve(n, m, s, t, vertexes))
    {
      Console.WriteLine(answer);
    }
  }

  static IEnumerable<long> Solve(int n, int m, int s, int t, List<Vertex>[] vertexes)
  {
    long[] distanceMemo = Enumerable.Repeat(long.MaxValue, n).ToArray();//9999999円代入
    {
      var que = new Queue<int>();
      que.Enqueue(s);
      distanceMemo[s] = 0;
      while (que.Count > 0)
      {
        int u = que.Dequeue();//queから取り出し
        foreach (var vertex in vertexes[u])
        {
          int v = vertex.next;
          if (distanceMemo[u] + vertex.distance < distanceMemo[v])
          {
            distanceMemo[v] = distanceMemo[u] + vertex.distance;
            que.Enqueue(v);//queに入れる
          }
        }
      }
    }
    long[] distanceMemoR = Enumerable.Repeat(long.MaxValue, n).ToArray();//ゴールからの長さに9999999代入
    {
      var que = new Queue<int>();
      que.Enqueue(t);
      distanceMemoR[t] = 0;
      while (que.Count > 0)
      {
        int u = que.Dequeue();
        foreach (var vertex in vertexes[u])
        {
          int v = vertex.next;
          if (distanceMemoR[u] + vertex.distanceR < distanceMemoR[v])
          {
            distanceMemoR[v] = distanceMemoR[u] + vertex.distanceR;
            que.Enqueue(v);
          }
        }
      }
    }
    var distanceTotal = new long[n];
    distanceTotal[n-1] = distanceMemo[n-1] + distanceMemoR[n-1];
    for (int i = n-2; i >= 0; i--)
    {
      distanceTotal[i] = Math.Min(distanceMemo[i] + distanceMemoR[i], distanceTotal[i+1]);
    }
    return distanceTotal.Select(a => 1000000000000000L - a);
  }
  
}



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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef string str;
typedef vector<char> vc;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define all(a) a.begin(), a.end()

template <typename T>
T Sum(vector<T> n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (accumulate(n.begin() + a, n.end(), 0));
  }
  else
  {
    return (accumulate(n.begin() + a, n.begin() + b, 0));
  }
}
template <>
ld Sum(vector<ld> n, ll a, ll b)
{
  if (b == 0)
  {
    return (accumulate(n.begin() + a, n.end(), 0));
  }
  else
  {
    return (accumulate(n.begin() + a, n.begin() + b, 0));
  }
}

template <typename T>
void Sort(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b));
  }
}

template <typename T>
void Reve(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (reverse(n.begin() + a, n.end()));
  }
  else
  {
    return (reverse(n.begin() + a, n.begin() + b));
  }
}

template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

template <typename T, typename U>
void V2(T &n, U &m)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i];
  }
}

template <typename T, typename U, typename W>
void V3(T &n, U &m, W &p)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i] >> p[i];
  }
}

void fYn(bool a)
{
  if (a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  exit(0);
}

ll mod_pow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//大文字->小文字(+32)
//少数はなるべく整数に

void Main()
{
  ll a;str s;cin >> a >> s;
  if(a < 3200) fin("red")
  else fin(s)
  return;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		int[] data = new int[10];
		final String BR = System.getProperty("line.separator");
		int first = 0, second = 0, third = 0;
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for (int i = 0; i < 10; i++) {
			data[i] = Integer.parseInt(in.readLine());
		}
		for (int datum : data) {
			int temp1 = 0, temp2 = 0;
			for (int j = 1; j <= 3; j++) {
				if (first < datum) {
					temp1 = first;
					temp2 = second;
					first = datum;
					second = temp1;
					third = temp2;
					break;
				}
				if (second < datum) {
					temp2 = second;
					second = datum;
					third = temp2;
					break;
				}
				if (third < datum) {
					third = datum;
				}
			}
		}

		System.out.println(first + BR + second + BR + third);
	}
}

Measured memory_bytes: 24392
a,b,k = map(int,input().split(' '))
i = 0
ans = ''
if k*2 <= (b - a):
    while i < k:
        ans += str(a+i) + '\n'
        i += 1
    while k > 0:
        ans += str(b-k+1) + '\n'
        k -= 1
else:
    while a <= b:
        ans += str(a) + '\n'
        a += 1
print(ans[:-1])

Measured memory_bytes: 3060
# ABC085 C

def main():
    n, Y = map(int, input().split())

    total = 0
    flag = False
    res = [-1] * 3

    for x in range(n+1):
        total = 10000 * x

        if total == Y and x == n:
            res = [x, 0, 0]
            break

        for y in range(n-x+1):
            z = n - x - y
            total = 10000 * x + 5000 * y + 1000 * z

            if total == Y:
                res = [x, y, z]
                flag = True
                break
        
        if flag:
            break

    print(res[0], res[1], res[2])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064