akhauriyash/Code-Regression huggingface dataset:
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    bool solve() {
        int N; readf("%d\n", &N);
        if (N == 0) return false;
        auto A = readln.chomp.split(" ").map!(to!int).array;
        A.sort;
        int ans = int.max;
        foreach (i, e; A[0 .. $ - 1]) {
            int d = A[i + 1] - A[i];
            ans = min(ans, d);
        }
        writeln(ans);
        return true;
    }
    while (solve()) {}
}

Measured memory_bytes: 3268
#include<stdio.h>

int main(){

	int i,n;
	int a[111];

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d", &a[i]);


	}
	for (i = n-1; i > 0; i--){
		printf("%d ",a[i]);
	}
	printf("%d\n", a[0]);
	return 0;
}


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

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

int main()
{
    int n, w_limit;
    std::cin >> n >> w_limit;
    std::vector<int> w(n), v(n);
    for (int i = 0; i < n; ++i)
    {
        std::cin >> w[i] >> v[i];
    }
    int v_max = std::accumulate(v.begin(), v.end(), 0);
    std::vector<std::vector<int>> dp(n, std::vector<int> (v_max + 1, inf));
    dp[0][0] = 0;
    dp[0][v[0]] = w[0];
    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j <= v_max; ++j)
        {
            dp[i][j] = dp[i - 1][j];
            if (j >= v[i])
            {
                dp[i][j] = std::min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
            }
        }
    }
    for (int i = v_max; i >= 0; --i)
    {
        if (dp[n - 1][i] <= w_limit)
        {
            std::cout << i << std::endl;
            break;
        }
    }
    return 0;
}


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

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

  string n1 =n;

  int s = 3;

  rep(i,s){
    n1.at(i) = n.at(s - i - 1);
    if(n1.at(i) != n.at(i)){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}


Measured memory_bytes: 3632
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

const long long PRIME = 1000000007;
const double mpi = 3.14159265358979323846;

using namespace std;


int main() {
  int h, w;
  cin >> h >> w;
  vector<string> mp(h), red(h), blue(h);
  for(int i = 0; i < h; i++) cin >> mp[i];
  for(int i = 0; i < w; i++) red[0].push_back('#');
  for(int i = 0; i < w; i++) red[h - 1].push_back('.');
  for(int i = 1; i < h - 1; i++) for(int j = 0; j < w; j++) red[i].push_back((j % 2 == 0) ? '#' : '.');
  for(int i = 0; i < w; i++) blue[0].push_back('.');
  for(int i = 0; i < w; i++) blue[h - 1].push_back('#');
  for(int i = 1; i < h - 1; i++) for(int j = 0; j < w; j++) blue[i].push_back((j % 2 == 0) ? '.' : '#');

  for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) if(mp[i][j] == '#') {
    red[i][j] = '#';
    blue[i][j] = '#';
  }

  for(int i = 0; i < h; i++) cout << red[i] << endl;
  cout << endl;
  for(int i = 0; i < h; i++) cout << blue[i] << endl;

  return 0;
}


Measured memory_bytes: 1536
fun main(args: Array<String>) {
    val N = readLine()!!.toLong()
    val n = Math.sqrt(N.toDouble()).toLong()
    var ans = Long.MAX_VALUE
    (1L..n).forEach { a ->
        if (N % a != 0L) return@forEach
        val b = N / a
        ans = Math.min(ans, a + b - 2)
    }
    println(ans)
}

Measured memory_bytes: 33792
import sys
input = sys.stdin.readline
def print_ans(input_line):
    """Test Case
    >>> print_ans("10")
    Yes
    >>> print_ans("50")
    No
    >>> print_ans("81")
    Yes
    """
    N = int(input_line)
    for i in range(1,10):
        q, mod= divmod(N,i)
        if mod == 0 and 0 < q < 10:
            print("Yes")
            break
        elif i == 9:
            print("No")


if __name__ == '__main__':
    print_ans(input())


Measured memory_bytes: 3060
#define RUN
#ifdef RUN
#include <iostream>
#include <algorithm>
using namespace std;

int N;
int D[111111];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int d;
        cin >> d;
        D[i] = d;
    }
    sort(D, D + N);
    int i = N / 2;
    int ans = D[i] - D[i - 1];
    cout << ans << endl;
    return 0;
}
#endif

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
void A(void);
void B(void);
void C(void);
void D(void);
void E(void);
void F(void);

int main(void){
    A();
}

void A(){
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n'
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int len(int a, int b, int c, int d)
{
	return sqrtl( (a-c)*(a-c) + (b-d)*(b-d));
}
int main()
{
    she_told_me_dont_worry
	int x1, x2, y1, y2;
	cin>>x1>>y1>>x2>>y2;
	int x3, y3, x4, y4;
		x4 = x1 - y2 + y1;
		x3 = x2 - y2 + y1;

			y4 = y1 + x2 - x1;
			y3 = y2+ x2- x1;

	
	cout<<x3<< " " << y3<< " "<<x4<< " "<<y4;
	
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
    int A[10];
    int m=0, n;
    while(!feof(stdin)) {
        scanf("%d",&n);
        if(feof(stdin))break;
        if(n==0) {
            m--;
            printf("%d\n",A[m]);
        } else {
            A[m]=n;
            m++;
        }
    }
    return 0;
}

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

public class Main {
    private static Scanner sc;
    int r,g,b,n;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            r = sc.nextInt();
            g = sc.nextInt();
            b = sc.nextInt();
            n = sc.nextInt();

            int rr = n/r;
            int gg = n/g;
            int bb = n/b;
            int sum = 0;

            for (int i = 0; i <= rr; i++) {
                for (int j = 0; j <= gg; j++) {
                    int tmp = (n - r*i - g*j);

                    if (tmp%b == 0 && tmp >= 0) sum++;
                }
            }

            System.out.println(sum);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    ll d[n];
    rep(i, n) { cin >> d[i]; }
    sort(d, d + n);

    bool memo[25] = {};
    memo[0] = true;
    memo[24] = true;
    rep(i, n) {
        ll num;

        if (i % 2) {
            num = d[i];
        } else {
            num = 24 - d[i];
        }
        if (memo[num]) {
            cout << 0 << endl;
            return 0;
        }
        memo[num] = true;
    }

    ll last = -mod;
    ll ans = 24;
    rep(i, 25) {
        if (memo[i]) {
            ans = min(ans, i - last);
            last = i;
        }
    }
    if (ans == 24) {
        ans = 0;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3616
import Control.Applicative
import Data.Maybe

chessBorad :: Int -> [Int] -> String
chessBorad i l@(h:w:_)
  | h == 0 && w == 0 = "end"
  | i >= h           = "\n"
  | even i           = ((++ "\n") . take w . concat . repeat $ "#.")  ++ chessBorad (i+1) l
  | otherwise        = ((++ "\n") . take w . concat . repeat $ ".#")  ++ chessBorad (i+1) l

main = getContents >>=
       mapM_ (putStr) . takeWhile (/= "end") . map (chessBorad 0 . map read . words) . lines

Measured memory_bytes: 5000
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;


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

  int a[n],b[n],c[n];

  int i;
  for(i=0;i<n;i++){
    cin >>a[i];
  }
  for(i=0;i<n;i++){
    cin >> b[i];
  }
  for(i=0;i<n-1;i++){
    cin >> c[i];
  }

  int ans = 0;
  ans += b[a[0]-1];
  for(i=1;i<n;i++){
    if(a[i]-a[i-1]==1){
      ans += b[a[i]-1]+c[a[i]-2];
    }
    else{
      ans += b[a[i]-1];
    }
  }

  cout << ans << endl;


}


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

struct Problem {
public:

	UL N;
	UL A[200000];
	UL B[200000];

	void Solve() {
		scanf("%u", &N);
		rep(i, N) scanf("%u%u", A + i, B + i);
		sort(A, A + N);
		sort(B, B + N);
		UL ans;
		if (N & 1) {
			ans = B[N / 2] - A[N / 2] + 1;
		}
		else {
			ans = (B[N / 2] + B[N / 2 - 1]) - (A[N / 2] + A[N / 2 - 1]) + 1;
		}
		cout << ans << endl;
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}


Measured memory_bytes: 4664
#include <bits/stdc++.h>
using namespace std;
int R0,W0,C,R;
double calc(int X){return 1.0*(R0+X*R)/C-W0;}

int main(){
  while(1){
  cin>>R0>>W0>>C>>R;
  if(!R0&&!W0&&!C&&!R)break;
  int ans=0;
  while(calc(ans)<0)ans++;
  cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3076
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(100 + " " + 100);
    String[][] grid = new String[100][100];
    for(int i = 0; i < 100; i++) {
      for(int j = 0; j < 100; j++) {
        if(i < 50) {
          grid[i][j] = "#";
        } else {
          grid[i][j] = ".";
        }
      }
    }
    a--;
    b--;
    for(int i = 0; i < 50; i++) {
      for(int j = 0; j < 100; j++) {
        if(a == 0) break;
        if((i % 2 == 0) && (j % 2 == 0)) {
          grid[i][j] = ".";
          a--;
        }
      }
    }
    for(int i = 99; i > 50; i--) {
      for(int j = 0; j < 100; j++) {
        if(b == 0) break;
        if((i % 2 == 1) && (j % 2 == 0)) {
          grid[i][j] = "#";
          b--;
        }
      }
    }
    for(int i = 0; i < 100; i++) {
      for(int j = 0; j < 100; j++) {
        System.out.print(grid[i][j]);
      }
      System.out.println();
    }
  }
}

Measured memory_bytes: 24916
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int d = scan.nextInt();
		int count = 0;
		long[][] arr = new long[n][2];
		for(int i=0;i<n;i++) {
			arr[i][0] = scan.nextLong();
			arr[i][1] = scan.nextLong();
		}
		scan.close();

		for(int i=0;i<n;i++) {
			if(Math.sqrt((arr[i][0])*(arr[i][0])+(arr[i][1])*(arr[i][1])) <= d) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 68568
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int mod = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const int maxn = 100000 + 10;

template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

LL A, B, C, D, N, ans;
int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    cin >> A >> B >> C >> D >> N;

    C = min(4 * A, min (2 * B, C));

    if(2 * C > D) {
        ans = (N / 2) * D + (N & 1) * C;
    }else {
        ans = N * C;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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(){
int n,k;
cin>>n>>k;
V<ll> a(n),d,sum(n+1,0);
for(int i=0;i<n;i++){
    cin>>a[i];
    sum[i+1]=a[i]+sum[i];
}
for(int i=0;i<n;i++){
    for(int j=i+1;j<=n;j++)d.push_back(sum[j]-sum[i]);
}
ll ans=0;
for(int i=60;i>=0;i--){
  //Aimax=10e9だが累積和の最大値が10e12であるため32では足りないことに気を付ける
    int cnt=0;
      for(int j=0;j<d.size();j++){
            if(d[j]&(1ll<<i))cnt++;
      }
    if(cnt>=k){
          V<ll> tmp;
    for(int j=0;j<d.size();j++){
         if(d[j]&(1ll<<i))tmp.push_back(d[j]);
      }
      d.clear();
      ans+=(1ll<<i);
      d=tmp;
      }
}
cout<<ans<<endl;
}


Measured memory_bytes: 6256
//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <fstream>


using namespace std;


void change(int &n, int i, int j) 
{
    if ((n >> i & 1) ^ (n >> j & 1) == 0) 
    {
        return;
    }
    n ^= (1 << i);
    n ^= (1 << j);
}


vector<int> dfs(int n, int a, int b) 
{
    if (n == 1) 
    {
        return {a, b};
    }
    b ^= a;
    int last;
    if (b)
    {
        last = 31 - __builtin_clz(b);
    }
    else
    {
        last = n - 1;
    }
    change(b, n - 1, last);
    int mask = (1 << (n - 1)) - 1;
    auto first = dfs(n - 1, 0, 1);
    auto second = dfs(n - 1, 1, b & mask);
    vector<int> ans;
    for (auto x : first) 
    {
        ans.push_back(x);
    }
    for (auto x : second) 
    {
        ans.push_back(x | (1 << (n - 1)));
    }
    for (auto& x : ans) 
    {
        change(x, n - 1, last);
    }
    for (auto& x : ans) 
    {
        x ^= a;
    }
    return ans;
}

int main() 
{
    int n, a, b;
    cin >> n >> a >> b;
    int diff = 0;
    for (int i = 0; i < n; i++)
    {
        if ( (a >> i) % 2 != (b >> i) % 2)
        {
            diff++;
        }
    }
    if (!(diff % 2))
    {
        cout << "NO" << endl;
        exit(0);
    }
    cout << "YES" << endl;
    vector<int> ans = dfs(n, a, b);
    for (int i = 0; i < ans.size(); i++) 
    {
        cout << ans[i] << " ";
    }
    cout << endl;
}



Measured memory_bytes: 1628
# -*- coding: utf-8 -*-
import sys
import copy

def main():
	N, M = map(int, input().split(" "))
	
	graph = []
	maps = [[9999999 for _ in range(N)] for _ in range(N)]
	for i in range(N):
		maps[i][i] = 0
	
	for _ in range(M):
		a, b, c = map(int, input().split(" "))
		a, b = a-1, b-1
		maps[a][b] = c
		maps[b][a] = c
	
	ans = 0
	org = copy.deepcopy(maps)
	for k in range(N):
		for i in range(N):
			for j in range(N):
				maps[i][j] = min(maps[i][j], maps[i][k] + maps[k][j])
				maps[j][i] = min(maps[i][j], maps[i][k] + maps[k][j])
			
	for i in range(N):
		for j in range(N):
			if i <= j:
				continue
			if org[i][j] == 9999999:
				continue
			if org[i][j] != maps[i][j]:
				ans += 1
		
	print(ans)
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3828
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

template <typename T> struct Edge {
  T dst, cost;
  Edge(int dst, int cost) : dst(dst), cost(cost) {}
  bool operator>(const Edge<T> &rhs) const { return cost > rhs.cost; }
};

const int INF = 1 << 30;

template <typename T> vector<T> dijkstra(vector<vector<Edge<T>>> tree, T src) {
  size_t V = tree.size();
  vector<T> dist = vector<T>(V, INF);
  priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> queue;

  dist[src] = 0;
  queue.push(Edge<T>(src, 0));
  while (!queue.empty()) {
    Edge<T> t = queue.top();
    queue.pop();
    int v = t.dst, cost = t.cost;

    if (dist[v] < cost) {
      continue;
    }
    for (size_t i = 0; i < tree[v].size(); i++) {
      Edge<T> e = tree[v][i];
      if (dist[v] + e.cost < dist[e.dst]) {
        dist[e.dst] = dist[v] + e.cost;
        queue.push(Edge<T>(e.dst, dist[e.dst]));
      }
    }
  }

  return dist;
}

int main(int argc, char const *argv[]) {
  int V, E, r;
  cin >> V >> E >> r;

  vector<vector<Edge<int>>> tree(V);
  for (size_t i = 0; i < E; i++) {
    int s, t, d;
    cin >> s >> t >> d;
    tree[s].push_back(Edge<int>(t, d));
  }

  vector<int> ret = dijkstra(tree, r);
  for (size_t i = 0; i < V; i++) {
    int d = ret[i];
    if (d >= INF) {
      cout << "INF" << endl;
    } else {
      cout << d << endl;
    }
  }

  return 0;
}




Measured memory_bytes: 20188
#include<bits/stdc++.h>
 using namespace std;
int main(){
  int d;
  cin >> d;
  string res ="Christmas Eve Eve Eve";
  if (d == 23) {
    res = "Christmas Eve Eve";
  } else if (d == 24) {
    res ="Christmas Eve";
  } else if (d == 25) {
    res = "Christmas";
  }


  cout << res << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<long long> a(n), b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}

	long long presses = 0;
	for (int i = n - 1; i >= 0; --i) {
		a[i] += presses;
		long long needed;
		if (a[i] % b[i] == 0) {
			needed = 0;
		} else {
			needed = ((a[i] / b[i]) + 1) * b[i] - a[i];
		}

		presses += needed;
	}

	cout << presses << "\n";

	return 0;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 3e5 + 5;

int n, a[N], b[N];

void end() {
	pp("No\n");
	exit(0);
}

int main() {
	scanf("%d", &n);
	fo(i, 1, n) {
		scanf("%d", &a[i]);
		b[a[i]] = i;
	}
	int la = 1, mi = n, mx = 0;
	fo(i, 1, n) {
		mi = min(mi, a[i]);
		mx = max(mx, a[i]);
		if(mi == 1 && mx == i) {
			if((i - la) % 2 == 1) end();
			for(int j = la + 1; j <= i; j += 2)
				if(a[j] != j) end();
			int x = 0, y = 0;
			for(int j = la; j <= i; j += 2) {
				if(b[j] <= j) {
					if(b[j] < x) end();
					x = b[j];
				}
				if(b[j] >= j) {
					if(b[j] < y) end();
					y = b[j];
				}
			}
			la = i + 1;
		}
	}
	pp("Yes\n");
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>

int main() {
    using namespace std;

    int A, B, K;
    cin >> A >> B >> K;

    for (int i=A; i<=B; i++) {
        if ((A <= i && i < A+K) || (B-K < i && i <= B)) {
            cout << i << endl;
        }
    }

    // for (int i=0; i<K; i++) {
    //     int n = A + i;
    //     if (A <= n && n <= B) {
    //         cout << n << endl;
    //     }
    // }

    // for (int i=K-1; 0<=i; i--) {
    //     int n = B - i;
    //     if (A <= n && n <= B) {
    //         cout << n << endl;
    //     }
    // }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // This will work only for g++ compiler. 


#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based

//short hand for usual tokens
#define pb push_back
#define fi first
#define se second


#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)

// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())

//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())

// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())


using namespace std;

// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int maxn=10001;
vector< vector<int> >g(100001);
int dp[100001]={0};
bool vis[100001]={false};

void dfs(int src){
	vis[src]=true;
	for (int i=0;i<g[src].size();i++){
		if (vis[g[src][i]]==false){
			dfs(g[src][i]);
		}
		dp[src]=max(dp[src],1+dp[g[src][i]]);
	}
		
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
	int n,m;
	cin>>n>>m;
	for (int i=0;i<m;i++){
		int src,dest;
		cin>>src>>dest;
		g[src].pb(dest);
		//g[dest].pb(src);
	}
	for (int i=1;i<=n;i++){
		if (vis[i]==false){
			//cout<<i<<endl;
			dfs(i);
		}
	}
	int res=-1;
	//for (int i=1;i<=n;i++)
	//cout<<vis[i]<<" ";
	for (int i=1;i<=n;i++)
	res=max(res,dp[i]);
	cout<<res<<endl;
    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const int mod = 998244353;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    for (auto &c : a) cin >> c;
    int dp[n + 1][s + 1][2];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= s; j++) {
            dp[i][j][0] = dp[i][j][1] = 0;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= s; j++) {
            for (int k = 0; k < 2; k++) {
                if (k == 0) {
                    dp[i][j][k] = dp[i - 1][j][k];
                    if (a[i - 1] == j) dp[i][j][k] += i;
                    if (a[i - 1] < j) dp[i][j][k] += dp[i - 1][j - a[i - 1]][k];
                    if (dp[i][j][k] >= mod) dp[i][j][k] -= mod;
                } else {
                    if (a[i - 1] < j) dp[i][j][k] = dp[i - 1][j - a[i - 1]][0];
                    if (a[i - 1] == j) dp[i][j][k] = i;
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += (ll)dp[i][s][1] * (ll)(n - i + 1);
        ans %= mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 73988
n = int(input())
lunlun = [[1,2,3,4,5,6,7,8,9]]
 
for _ in range(10):
    tmp = []
    for i in lunlun[-1]:
        if i % 10 == 0 :
            tmp.append(10 * i + i % 10)
            tmp.append(10 * i + i % 10 + 1)
        elif i % 10 == 9:
            tmp.append(10 * i + i % 10 - 1)
            tmp.append(10 * i + i % 10)
        else:
            tmp.append(10 * i + i % 10 - 1)
            tmp.append(10 * i + i % 10)
            tmp.append(10 * i + i % 10 + 1)
    lunlun.append(tmp)
ans = []
for i in lunlun:
    for j in i:
        ans.append(j)
print(ans[n-1])

Measured memory_bytes: 33336
#include<stdio.h>

int calc_digit(int n, int k){
    int cnt = 0;
    while(n != 0){
        cnt ++;
        n /= k;
    }
    return cnt;
}

int main(void){
    int n, k;
    scanf("%d""%d", &n, &k);
    printf("%d\n", calc_digit(n, k));
    return 0;
}

Measured memory_bytes: 128
n,k=map(int,input().split())
p=list(map(int,input().split()))
tp=[]
for i in p:
    tp.append(((i+1)*i/2)/i)
m=sum(tp[:k])
ans=m
for i in range(1,n-k+1):
    m=m-tp[i-1]+tp[i+k-1]
    ans=max(ans,m)
print(ans)

Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string str;
	while (cin >> str)
	{
		int count = 0,total=0;
		int size = (int)str.size();
		if (str == "RRS" || str=="SRR")
		{
			cout << "2\n";
		}
		else if (str == "RRR")
		{
			cout << "3\n";
		}
		else if (str == "SRS" || str == "RSR" || str=="RSS" || str=="SSR")
		{
			cout << "1\n";
		}
		else
		{
			cout << "0\n";
		}
	}
}

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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int main(){

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

    int a,b;
    cin>>a>>b;

    int x = 6 - a - b;

    cout<<x<<endl;


}


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

using namespace std;


int main(){
 int* a = new int[5];
 int k;
 int cont = 0;
 
 for(int i = 0; i < 5; i++){
 	cin>>a[i];
 }
 cin>>k;
 
 for(int i = 1; i < 5; i++){
 	for(int j = 0; j < 5; j++){
 		if(a[i]- a[j] > k && i > j){
 			cont++;
		 }
    }
   }

 
 if(cont == 0){
 	cout << "Yay!";
 }
 else{
 	cout << ":(";
 }

}

Measured memory_bytes: 256
import java.util.*;
import java.util.Comparator;

public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long o1=0;
        long o2=0;
        String s=sc.next();
        String t=sc.next();
        o1=sc.nextLong();
        o2=sc.nextLong();
        String u=sc.next();
        if(s.equals(u)){
        	o1--;
        }else{
        	o2--;
        }
        
      
      System.out.println(o1+" "+o2);
    }
}

Measured memory_bytes: 23508
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil,M_PI

using namespace std;

int main() {

	int N, R;
	cin >> N >> R;

	if (N >= 10) {
		cout << R << endl;
	}
	else {
		cout << R + (100 * (10 - N)) << endl;
	}

	return 0;

}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] l = new long[87];
		l[0] = 2;
		l[1] = 1;

		for(int i=2; i<l.length; i++) {
			l[i] = l[i-1] + l[i-2];
		}

		System.out.println(l[n]);
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;
//なんかよくわからないやつ
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      //入力のやつ
		int X = sc.nextInt();
      //鉄道運賃
		int Y = sc.nextInt();
      //バス運賃
		System.out.println(X + Y / 2);
      //合計運賃を計算して入力
	}
}

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

int main()
{
    string s;
    cin >> s;
    string t;
    cin >> t;
    if (t.length() == s.length()+1 && s == t.substr(0, s.size()))
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
	ll n, k, ans = 0;
	vector<ll> a, b, c, t1, t2;

	scanf("%lld", &n);
	t1.resize(n);
	t2.resize(n);
	for(int i = 0; i < n; i++){
		scanf("%lld", &k);
		a.push_back(k);
	}
	for(int i = 0; i < n; i++){
		scanf("%lld", &k);
		b.push_back(k);
	}
	for(int i = 0; i < n; i++){
		scanf("%lld", &k);
		c.push_back(k);
	}

	sort(a.begin(), a.end());
	sort(c.begin(), c.end());

	for(int i = 0; i < n; i++){
		if(a[0] < b[i] && b[i] < c[n - 1]){
			auto it1 = lower_bound(a.begin(), a.end(), b[i]);
			auto it2 = lower_bound(c.begin(), c.end(), b[i] + 1);

			ans += (it1 - a.begin()) * (n - (it2 - c.begin()));
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 4852
#include<bits/stdc++.h>
#define ll long long int
#define fl(i,x,y) for( int i=x;i<y;i++)
#define w(t) while(t--)
#define vi vector<ll>
#define vvi vector< vi >
#define si set<ll>
#define msi multiset<ll>
#define si_d set<ll, greater<ll> >
#define mii map<ll,ll>
#define pb push_back
#define msi_it  multiset<ll> :: iterator
#define si_it set<ll> :: iterator
#define sort1(v) sort(v.begin(),v.end());
#define F first
#define S second
using namespace std;
#define N 1000000007
#define mod 15000000000031
int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	ll k=a+b;
	ll ans=0,total=0;
	ans=(n/k)*a;
	total=(n%k);
	ans+=min(total,a);
	cout<<ans;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  std::vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  ll res=0;
  bool st=false;
  for(int h=100;h>0;h--){
    for(int i=0;i<n;i++){
      if(v[i]==h){
        st=true;
        v[i]--;
      }else if(st){
        res++;
        st=false;
      }
    }
    if(st){
      res++;
      st=false;
    }
  }

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin >> N;
  vector<long long> vec(N);
  for(long long i = 0; i < N; i++){
    cin >> vec[i];
  }
  bool check = true;
  sort(vec.begin(),vec.end());
  for(long long i = 0; i < N-1; i++){
    if(vec[i]==vec[i+1]){
      check = false;
    }
  }
  if(check){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
} 

Measured memory_bytes: 1792
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

template <class InputIterator, class T>
bool contains(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// =========ここまでテンプレ============

int main()
{
    string s;
    cin >> s;
    ll size = s.size();
    ll count = 0;

    // multiset<ll> xs;
    array<ll, 2019> bucket{0};
    ll last = 0;

    vector<ll> tenpow;
    ll temp = 1;
    for (ll i = 0; i < s.size(); i++)
    {
        tenpow.push_back(temp);
        temp = temp * 10 % 2019;
    }

    for (ll i = 0; i < s.size(); i++)
    {
        last = (last + (s[size - 1 - i] - '0') * tenpow[i]) % 2019;
        // xs.insert(last);
        bucket[last]++;
    }
    bucket[0]++;
    for (ll i = 0; i < 2019; i++)
    {
        count += bucket[i] * (bucket[i] - 1) / 2;
    }
    cout << count;
}

// for (ll i = 0; i < s.size() - 1; i++)
// {
//     ll value = 0;
//     for (ll j = i; j < s.size(); j++)
//     {
//         // string x = s.substr(i, j - i + 1);
//         char x = s[j];
//         ll y = x - '0';
//         value = (value * 10 + y) % 2019;
//         if (value == 0)
//         {
//             count++;
//         }
//     }
// }
// cout << count;

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    bool ok = false;
    int place = 1;
    for (int i = 0; i < N; i++){
        if (place == 2){
            ok = true;
            cout << i << endl;
            break;
        }
        else{
            place = A.at(place - 1);
        }
    }
    if (ok == false){
        cout << -1 << endl;
    }
}

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

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	int n,m,a,b;
	cin >> n >> m;
	vi v[n];
	FOR(i,m){
		cin >> a >> b;
		v[a-1].eb(b-1);
		v[b-1].eb(a-1);
	}
	for(auto x : v[0]){
		for(auto y : v[x]) if(y==n-1){
			cout << "POSSIBLE";
			return 0;
		}
	}
	cout << "IMPOSSIBLE";


	return 0;
}

Measured memory_bytes: 12016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=2019;

int main(){
  ll L,R; cin>>L>>R;
  if(R-L+1>=mod)
    cout<<0;
  else{
    ll l=L%mod;
    ll r=R%mod;
    
    ll res=2019;
    
    for(int i=l;i<r;i++){
      for(int j=i+1;j<=r;j++){
        res=min(res,i*j%mod);
      }
    }
    
    cout<<res;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  
  vector<string> vec(2);
  for(int i=0;i<2;i++){
  	cin >> vec.at(i);
  }
  
  vector<int> vec1(2);
  for(int i=0;i<2;i++){
  	cin >>vec1.at(i);
  }
  string a;
  cin>>a;
  for(int i=0;i<2;i++){
  	if(vec.at(i)==a){
    	vec1.at(i)=vec1.at(i)-1;
    }  
  }
    cout<<vec1.at(0)<<' '<<vec1.at(1)<<endl;
}



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

using namespace std;

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

    int cnt = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                int t = 10001 * i + 1010 * j + 100 * k;
                if (t >= a && t <= b) cnt++;
            }
        }
    }
    cout << cnt << endl;

    return 0;
}


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


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

	map<string,int> t;

	for(int i=0;i<n;i++)
	{
		string s;
		cin >> s;

		t[s];
	};

	cout << t.size() <<endl;

	return 0;
}


Measured memory_bytes: 19252
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main(){
	string s;
	int n;
	int c_pos;
	cin>>n;
	cin.ignore();
	while(n--){
		getline(cin,s);
		while((c_pos=s.find("Hoshino"))!=string::npos){
			s.replace(c_pos,7,"Hoshina");
		}
		cout<<s<<endl;
	}
	
}

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

using ll = long long;
const int INF = 1e9 + 1;

int main() {

	int N;
	cin >> N;

	string s, t;
	cin >> s >> t;

	rep(i, N)
		cout << s[i] << t[i];
	cout << endl;


	return 0;
}

Measured memory_bytes: 256
import sys
from fractions import Fraction
import math
import heapq
input = sys.stdin.readline

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

s = sum(a)

w = [(k * a[i]) // s for i in range(n)]
b = [Fraction((w[i] + 1), a[i]) for i in range(n)]

r = k - sum(w)

heapq.heapify(b)
#print(b)

for i in range(r):
    x = heapq.heappop(b)
    heapq.heappush(b, Fraction(x.numerator+1, x.denominator))

y = heapq.heappop(b)

print(math.ceil(Fraction(y.denominator, y.numerator)))


Measured memory_bytes: 127260
n = int(input())
A = [int(x) for x in input().split()]
q = int(input())
 
for i in range(q):
    com, b, e = [int(x) for x in input().split()]
    if com:
        print(max(A[b:e]))
    else:
        print(min(A[b:e]))


Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int n;
    cin >> n;
    vector<int> b(n+1);
    vector<int> a(n);
    for(int i=1;i<=n;i++){
        cin >> b[i];
    }
    bool ans=true;
    int t=0;
    //a.erase(a.begin()+i);で番目を削除 
    while(b.size()!=1){
        for(int j=b.size()-1;j>=0;j--){
            if(j==0){
                ans = false;
            }
            if(b[j]==j){
                b.erase(b.begin()+j);
                //cout<<j<<endl;
                a[t]=j;
                t++;
                break;
            }
        }
        if(!ans){
            cout<<-1<<endl;
            return 0;
        }
    }
    for(int j=t-1;j>=0;j--){
        cout<<a[j]<<endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	n, k := 0, 0
	fmt.Scan(&n)
	fmt.Scan(&k)

	a := make([]int, n)
	np, nz, nn := 0, 0, 0

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		if a[i] > 0 {
			np++
		} else if a[i] == 0 {
			nz++
		} else {
			nn++
		}
	}

	rnn := nn * np
	rnz := nz*(n-nz) + nz*(nz-1)/2

	if k <= rnn {
		arr1 := []int{}
		arr2 := []int{}
		for _, x := range a {
			if x < 0 {
				arr1 = append(arr1, -x)
			} else if x > 0 {
				arr2 = append(arr2, x)
			}
		}
		sort.Ints(arr1)
		sort.Ints(arr2)
		c1 := len(arr1)
		c2 := len(arr2)

		l := 0
		r := int(math.Pow10(18) + 1)
		k = rnn - k
		for r-l != 1 {
			mid := (l + r) / 2
			cnt := 0
			pos := c2 - 1
			for i := 0; i < c1; i++ {
				for pos != -1 {
					if arr2[pos] > mid/arr1[i] {
						pos--
					} else {
						break
					}
				}
				cnt += pos + 1
			}
			if cnt > k {
				r = mid
			} else {
				l = mid
			}
		}
		fmt.Println(-r)
	} else if k <= rnn+rnz {
		// Zero
		fmt.Print(0)
	} else { // Positive
		arr1 := []int{}
		arr2 := []int{}
		for _, x := range a {
			if x < 0 {
				arr1 = append(arr1, -x)
			} else if x > 0 {
				arr2 = append(arr2, x)
			}
		}
		sort.Ints(arr1)
		sort.Ints(arr2)
		c1 := len(arr1)
		c2 := len(arr2)

		l := 0
		r := int(math.Pow10(18) + 1)
		k -= rnn + rnz
		for r-l != 1 {
			mid := (l + r) / 2
			cnt1 := 0
			pos1 := c1 - 1
			for i := 0; i < c1; i++ {
				tmp := 0
				for pos1 != -1 {
					if arr1[pos1] > mid/arr1[i] {
						pos1--
					} else {
						break
					}
				}
				tmp += pos1 + 1
				if arr1[i]*arr1[i] < mid {
					tmp--
				}
				cnt1 += tmp
			}
			cnt1 = cnt1 / 2
			cnt2 := 0
			pos2 := c2 - 1
			for i := 0; i < c2; i++ {
				tmp := 0
				for pos2 != -1 {
					if arr2[pos2] > mid/arr2[i] {
						pos2--
					} else {
						break
					}
				}
				tmp += pos2 + 1
				if arr2[i]*arr2[i] < mid {
					tmp--
				}
				cnt2 += tmp
			}
			cnt2 = cnt2 / 2
			cnt := cnt1 + cnt2
			if cnt >= k {
				r = mid
			} else {
				l = mid
			}
		}
		fmt.Println(r)
	}

}


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

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

        static void Method(string[] args)
        {
            int n = ReadInt();
            var ab = new int[n][];
            var cd = new int[n][];
            for (int i = 0; i < n; i++)
            {
                int[] input = ReadInts();
                ab[i] = new int[2];
                ab[i][0] = input[0];
                ab[i][1] = input[1];
            }
            for (int i = 0; i < n; i++)
            {
                int[] input = ReadInts();
                cd[i] = new int[2];
                cd[i][0] = input[0];
                cd[i][1] = input[1];
            }
            Array.Sort(ab, (a, b) => a[0] - b[0]);
            Array.Sort(cd, (a, b) => a[0] - b[0]);
            int pairCnt = 0;
            for (int i = 0; i < n; i++)
            {
                int aIndex = n - 1;
                for (int j = 0; j < n; j++)
                {
                    if ( ab[j][0]< cd[i][0])
                    {
                        continue;
                    }
                    else
                    {
                        aIndex = j - 1;
                        break;
                    }
                }
                if (aIndex == -1)
                {
                    continue;
                }
                int redIndex = -1;
                for (int j = aIndex; j >= 0; j--)
                {
                    if (cd[i][1] < ab[j][1])
                    {
                        continue;
                    }
                    else if (redIndex == -1
                            || ab[redIndex][1] < ab[j][1])
                    {
                        redIndex = j;
                    }
                }
                if (redIndex != -1)
                {
                    pairCnt++;
                    ab[redIndex][1] = 3000;
                }
            }
            Console.WriteLine(pairCnt);
        }

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


Measured memory_bytes: 13268
n = int(input())
s = []
for _ in range(n):
    s.append(str(input()))
print('AC x ' + str(s.count('AC')))
print('WA x ' + str(s.count('WA')))
print('TLE x ' + str(s.count('TLE')))
print('RE x ' + str(s.count('RE')))

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

using namespace std;

template <class T>
using lim = numeric_limits<T>;

typedef long long ll;
typedef long double ld;

set<pair<int,int>> tracker;

// solves smallest
int minDistance(int dist[], bool sptSet[], int n) 
{ 
    int min = lim<int>::max(), min_index; 
  
    for (int v = 0; v < n; v++) 
        if (sptSet[v] == false && dist[v] <= min) 
            min = dist[v], min_index = v; 
  
    return min_index; 
} 

// solves shortest path
void dijkstra(vector<vector<int>> graph, int start){
	int n = graph.size();
	int dist[n];
	vector<int> parent(n, -1);
  
    bool sptSet[n];
    
    for (int i = 0; i < n; i++) 
        dist[i] = lim<int>::max(), sptSet[i] = false; 
  
    dist[start] = 0; 
  
    for (int count = 0; count < n - 1; count++) { 
        int u = minDistance(dist, sptSet, n); 
  
        sptSet[u] = true; 
  
        for (int v = 0; v < n; v++){
			if (!sptSet[v] && graph[u][v] && dist[u] != lim<int>::max() && dist[u] + graph[u][v] < dist[v]){
				dist[v] = dist[u] + graph[u][v]; 
				parent[v] = u;
			}
		}
    }
    
    for (int i = 0; i < n; i++){
		if (parent[i] >= 0){
			int smaller = min(parent[i],i);
			int bigger = max(parent[i],i);
			pair<int,int> edge = make_pair(smaller,bigger);
			tracker.insert(edge);
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m; cin >> n >> m;
	vector<vector<int>> aMat(n, vector<int>(n,0));
	for (int i = 0; i < m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		aMat[a-1][b-1] = c;
		aMat[b-1][a-1] = c;
	}
	
	
	for (int i = 0; i < n; i++){
		dijkstra(aMat, i);
	}
	
	int size = tracker.size();
	cout << m-size << endl;
}


Measured memory_bytes: 384
h,w,k=map(int,input().split())
li=[]
for i in range(h):
  li.append(list(input()))
ans=0
for i in range(1<<h):
  for j in range(1<<w):
    cnt=0
    for p in range(h):
      for q in range(w):
        if i>>p&1:
          continue
        if j>>q&1:
          continue
        if li[p][q]=="#":
          cnt+=1
    if cnt==k:
      ans+=1
print(ans)

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

using namespace std;
int main()
{
    int a , b , i , j;
    cin>>a>>b;
    float s= (float)a*25/2 , t = s + 12.5;
    if(floor(t)==ceil(t)) t--;
    for(i=10*b ; i < 10*(b+1) ; i++)
    {
        for(j=ceil(s) ; j <= ceil(t) ; j++)
        {
            if(i==j) 
            {
                cout<<i<<endl;
                return 0;
            }
        } 
    }
    cout<<"-1"<<endl;
}

Measured memory_bytes: 256