akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    EGluttony solver = new EGluttony();
    solver.solve(1, in, out);
    out.close();
  }

  static class EGluttony {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int n;
      long k;
      n = in.nextInt();
      k = in.nextLong();

      ArrayList<Long> weak = new ArrayList<>();
      ArrayList<Long> cost = new ArrayList<>();
      for (int i = 0; i < n; i++) {
        weak.add(in.nextLong());
      }
      for (int i = 0; i < n; i++) {
        cost.add(in.nextLong());
      }

      weak.sort(Comparator.naturalOrder());
      cost.sort(Comparator.reverseOrder());
      //　ここからk≦にできるかどうかの二分探索できるかみたいな感じでは
      // N log 10^18だから定数倍重めだけどできなくはなさそう
      out.println(binarySearch(weak, cost, k));
    }

    long binarySearch(ArrayList<Long> a, ArrayList<Long> b, long k) {
      long l = 0;
      long h = (long) 1e12;
      long m;
      while (l < h) {
        m = (l + h) / 2;
        // System.out.println(calc(a, b, m));
        if (calc(a, b, m) > k) {
          // 無理
          // System.out.println(m + " fail");
          l = m + 1;
        } else {
          // 出来た -> 上を固定する
          // System.out.println(m + " success");
          h = m;
        }
      }
      return l;
    }

    private long calc(ArrayList<Long> a, ArrayList<Long> b, long m) {
      long res = 0;
      for (int i = 0; i < a.size(); i++) {
        res += Math.max(0, a.get(i) - m / b.get(i));
      }
      return res;
    }

  }
}



Measured memory_bytes: 118380
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	h, w = map(int, input().strip().split())
	a = [[] for _ in range(h)]
	for i in range(h):
		a[i] = list(map(int, input().strip().split()))
	ans = []
	for i in range(h-1):
		for j in range(w):
			if a[i][j] % 2 == 1:
				a[i][j] -= 1
				a[i+1][j] += 1
				ans.append((i+1, j+1, i+2, j+1))

	for j in range(w-1):
		if a[h-1][j] % 2 == 1:
			a[h-1][j] -= 1
			a[h-1][j+1] += 1
			ans.append((h, j+1, h, j+2))
	n = len(ans)
	print(n)
	for i in range(n):
		print("{} {} {} {}".format(ans[i][0], ans[i][1], ans[i][2], ans[i][3]))
if __name__ == '__main__':
	main()


Measured memory_bytes: 70108
fn main() {
    let n = read::<f64>();
    let nn = (n/1.08).round();
    if (nn*1.08).floor() == n {
        println!("{}", nn);
    }else if ((nn+1.0)*1.08).floor() == n{
        println!("{}", nn+1.0);
    }else if ((nn-1.0)*1.08).floor() == n {
        println!("{}", nn-1.0);
    }else {
        println!(":(");
    }
    
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


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

#include <boost/operators.hpp>

class modint : private boost::operators<modint>, private boost::equivalent<modint> {
  modint(const long long x, const bool y)
      : x(x) {}

 public:
  static long long M;
  long long x;
  modint(const long long x = 0)
      : x((x % M + M) % M) {}
  modint operator-() const { return modint(x ? M - x : 0, true); }
  modint& operator+=(const modint& b) { return ((x += b.x) >= M ? x -= M : 0), *this; }
  modint& operator++() { return (++x >= M ? x -= M : 0), *this; }
  modint& operator-=(const modint& b) { return ((x -= b.x) < 0 ? x += M : 0), *this; }
  modint& operator--() { return (--x < 0 ? x += M : 0), *this; }
  modint& operator*=(const modint& b) { return x = x * b.x % M, *this; }
  modint& operator/=(const modint& b) { return *this *= b.pow(-1); }
  modint pow(long long b) const {
    long long r = 1, a = x;
    b = (b % (M - 1) + (M - 1)) % (M - 1);
    while (b) {
      if (b & 1) r = r * a % M;
      b = b >> 1;
      a = a * a % M;
    }
    return modint(r, true);
  }
  friend bool operator<(const modint& a, const modint& b) { return a.x < b.x; }
  friend std::istream& operator>>(std::istream& s, modint& a) { return s >> a.x, a = a.x, s; }
  friend std::ostream& operator<<(std::ostream& s, const modint& a) { return s << a.x; }
};
long long modint::M = 1000000007;

// #LIB#

using namespace std;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

vector<vector<ll>> g;
ll k;

modint solve(ll p, ll parent) {
  modint res = 1;
  ll cc = 0;
  itr(c, g[p]) {
    if (c == parent) continue;
    res *= solve(c, p);
    ++cc;
  }
  ll cv = parent >= 0 ? k - 2 : k - 1;
  rep(i, cc) res *= cv--;
  return res;
}

int main() {
  ll n;
  cin >> n >> k;
  g.resize(n);
  rep(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  cout << solve(0, -1) * k << endl;
}


Measured memory_bytes: 13324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll>a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  vector<ll>dp(n);
  
  k=min(k,ll(1000));
  for(int i=0; i<k; i++){
    for(int j=0; j<n; j++) dp[j]=0;
    for(int j=0; j<n; j++){
      if(j-a[j]<0)dp[0]++;
      else dp[j-a[j]]++;
      
      if(j+a[j]+1>n-1) continue;
      dp[j+a[j]+1]--;
    }
    a[0]=dp[0];
    for(int j=1; j<n; j++){
      a[j]=a[j-1]+dp[j];
    }
    
  }
  
  for(int i=0; i<n; i++) cout << a[i] <<" ";
  
 
}
  
  
  


Measured memory_bytes: 6428
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>
#include <functional>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define PI 3.14159265358979323846264338327950L

int main() {
	int x, y, ans = 0;
	cin >> x >> y;

	rep(i,x+1){
		rep(j,x+1){
			if (i+j == x) {
				if (y == 2 * i + 4 * j) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;

}

Measured memory_bytes: 3636
#include <stdio.h>
int main(void)
{
	int H, W, height, bottom;
	scanf("%d %d", &H, &W);
	while (H != 0 && W != 0)
	{
		for (height = 1; height <= H; height++)
		{
			for (bottom = 1; bottom <=W ; bottom++)
			{
				if (height == 1 || height == H || bottom == 1 || bottom == W)
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
		scanf("%d %d", &H, &W);
	}
	return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string a,b,c;
  cin >> a >> b >> c;
  vector<vector<int>> s(n,vector<int>(26));
  int sum=0;
  for(int i=0;i<n;i++){
    s[i][a[i]-'a']++;
    s[i][b[i]-'a']++;
    s[i][c[i]-'a']++;
    sum+=3-max({s[i][a[i]-'a'],s[i][b[i]-'a'],s[i][c[i]-'a']});
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class CTravelingSalesmanAroundLake {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll n, k;
	    in >> k >> n;
	    vector<ll> a(n);
	    for(int i=0; i<n; i++){
	        in >> a[i];
	    }

	    sort(a.begin(), a.end());
	    ll mx = 0;
	    for(int i=0; i<n-1; i++){
	        chmax(mx, a[i+1] - a[i]);
	    }
	    chmax(mx, a[0] + k-a[n-1]);

	    out << k - mx << endl;
	}
};


int main() {
	CTravelingSalesmanAroundLake solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1792
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n,m = mi()

    ans = [None] *n

    for i in range(m):
        s,c = mi()
        if((ans[s-1] == c) or (ans[s-1] == None)):
            ans[s-1] = c
        else:
            print('-1')
            return

    if(ans[0] == 0):
        if(len(ans) == 1):
            print(0)
            return
        else:
            print('-1')
            return

    if(len(ans) == 1):
        if(ans[0] == None):
            print(0)
            return
    ans2 = 0
    dec = 1
    for i in range(n-1,-1,-1):
        if(ans[i] == None):
            if(i == 0):
                ans[i] = 1
            else:
                ans[i] = 0
        ans2 += ans[i] * dec
        dec *= 10

    print(ans2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
void print(char* c,int n)
{
    for(int i=0 ; i<n ; i++){
        cout << c;
    }
}
int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    print("U",ty-sy);
    print("R",tx-sx);
    print("D",ty-sy);
    print("L",tx-sx);
    print("L",1);
    print("U",ty-sy+1);
    print("R",tx-sx+1);
    print("D",1);
    print("R",1);
    print("D",ty-sy+1);
    print("L",tx-sx+1);
    print("U",1);
    return 0;
}


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

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

  int index_a = 0, index_z = 0;
  
  for(int i=0; i<(int) str.size(); ++i){
    if(str[i]!='A') ++index_a;
    else break;
  }

  for(int i=(int)str.size(); i>-1; --i){
    if(str[i]!='Z') ++index_z;
    else break;
  }

  cout << ((int)str.size() - index_z) - index_a + 1 << endl;
}

Measured memory_bytes: 640
import java.util.*;
import static java.lang.System.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int[] rabbits = new int[n + 10];
		int cnt = 0;
		for(int i = 1; i <= n; i++) {
			rabbits[i] = sc.nextInt();
			if (rabbits[rabbits[i]] == i)
				cnt++;
		}
			out.println(cnt);
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}

Measured memory_bytes: 22544
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}


int main() {
	cin >> n;
	if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9) {
		s = "hon";
	}
	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
		s = "pon";
	}
	else {
		s = "bon";
	}
	cout << s << endl;
}

Measured memory_bytes: 3724
#include <cstdio>
#include <queue>
#include <map>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int64;
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())

const int N = (int) 1e6 + 10;
int n, m, cnt[N][2], u, v;
bool dead[N];
vector<int> adj[N];
char s[N];
queue<int> q;

int main() {
	scanf("%d%d%s", &n, &m, s);
	for (int i = 0; i < m; ++i) {
		scanf("%d%d", &u, &v), --u, --v;
		adj[u].pb(v), adj[v].pb(u);
	}
	for (int i = 0; i < n; ++i) {
		for (int j : adj[i]) {
			cnt[i][s[j] - 'A']++;
		}
		if ((cnt[i][0] == 0) || (cnt[i][1] == 0)) {
			dead[i] = true;
			q.push(i);
		}
	}
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (int u : adj[v]) {
			if (!dead[u]) {
				cnt[u][s[v] - 'A']--;
				if ((cnt[u][0] == 0) || (cnt[u][1] == 0)) {
					dead[u] = true;
					q.push(u);
				}
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		if (!dead[i]) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 33920
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll N, K;

int main()
{
  std::cin >> N >> K;

  ll ans = 0;

  repi( i, 1, N+1 ) if( i-K >= 0 )
  {
    if( K )
      ans += N/i*(i-K)+(N%i ? std::max( 0ll, N%i-(K-1) ) : 0);
    else
      ans += N;

    //std::cout << N/i*(i-K)+(K ? std::max( 0ll, N%i-(K-1) ) : 0) << std::endl;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
ll mod=1E9+7;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)

ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

ll pow2(ll n){
    ll r=1;
    REP(i,0,n){
        r*=2;
        r%=mod;
    }
    return r;
}

int main(){
    ll N=ii();
    ll zz=0;
    map<pii,ll> m;
    REP(i,0,N){
        ll a=ii();
        ll b=ii();
        if(a==0&&b==0){
            zz++;
            continue;
        }
        if(a==0){
            m[{0,-1}]++;
            continue;
        }
        if(b==0){
            m[{1,0}]++;
            continue;
        }
        if(a<0){
            a=-a; b=-b;
        }
        ll g = gcd(a,b);
        a/=g; b/=g;
        m[{a,b}]++;
    }

    ll r=1;
    for(auto [p,c]:m){
        auto [a,b]=p;
        ll cc;
        if(b<0){
            cc=m[{-b,a}];
            m.erase({-b,a});
        }else{
            cc=m[{b,-a}];
            m.erase({b,-a});
        }
        ll r1 = r * (pow2(c)-1) % mod;
        ll r2 = r * (pow2(cc)-1+1) % mod; 
        r = (r1+r2)%mod;
    }
    oie((r + zz -1 + mod)%mod);

    return 0;
}

Measured memory_bytes: 15948
#include <stdio.h>

int main()
{
	int time;

	int s = 0;
	int m = 0;
	int h = 0;

	scanf("%d", &time);

	h = time / (60 * 60);
	m = (time - h*(60*60)) / 60;
	s = (time - (h * (60 * 60)) - (m * 60));

	printf("%d:%d:%d\n",h,m,s);
}


Measured memory_bytes: 2748
from collections import deque
s = deque(input())
q = int(input())

t = 0
for _ in range(q):
  query = list(input().split())
  query[0] = int(query[0])
  if query[0] == 1: t = 1 - (t)
  else:
    if t == 0:
      if int(query[1]) == 1: s.appendleft(query[2])
      else: s.append(query[2])
    else:
      if int(query[1]) == 1: s.append(query[2])
      else: s.appendleft(query[2])
if t == 0: print(*s, sep = '')
else: print(*reversed(s), sep = '')

Measured memory_bytes: 12272
#include <stdio.h>
int main()
{
    int n;
    long long int r=0,g=0,b=0;
    scanf("%d",&n);
    char s[4005];
    scanf("%s",s);
    for(int i=0;s[i]!='\0';i++)
    {
        if(s[i]=='R')
        r++;
        if(s[i]=='G')
        g++;
        if(s[i]=='B')
        b++;
    }
        int a,d,c;
        long long int count=0;
        for(int i=1;i<=n/2;i++)
        {
            a=0;d=a+i;c=d+i;
            for(;c<strlen(s);a++,d++,c++)
            {
                if(s[a]!=s[d]&s[d]!=s[c]&s[c]!=s[a])
                count++;
            }
        }
        printf("%lld",(r*g*b)-count);
}


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int n, zero = 0, v[114], aa, ans = 0;
	cin >> n >> aa;
	int zz = aa;
	rep(i, n) {
		cin >> v[i];
	}
	for (int i = n; i > max(zero, n - zz)-1;i--){
		for (int j = 0; j <= n - i; j++){
			priority_queue<int, vector<int>, greater<int>>que;
			int st = j, en = j + i - 1, sum = 0;
			aa = zz;
			rep(k, n) {
				if (k < st || en < k) {
					que.push(v[k]);
					sum += v[k];
					aa--;
				}
			}
			while (aa > 0&&!que.empty()){
				int x = que.top(); que.pop();
				if (x >= 0) break;
				aa--;
				sum -= x;
			}
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;

	return 0;
}


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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second
 
Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    int a, b;
    cin >> a >> b;
    if (a > 8 || b > 8) dump(":(");
    else dump("Yay!");
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,s,sum;
vector<int> v;

main() {
    cin >> n;
    rep(i,n) cin >> s,sum+=s,v.pb(s);
    if (sum%10) ct(sum)
    else {
        sort(all(v));
        int tmp=0;
        rep(i,n) if (v[i]%10) {tmp=v[i];break;}
        if (tmp) ct(sum-tmp)
        else ct(0)
    }
}

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

int main(void){
  int a,b,c,x;
  vector<int> vec;
  
  cin >> a >> b >> c;
  vec = vector<int>(b*2);
  fill(vec.begin(), vec.end(),0);
  for (x=a; true; (x+=a)%=b){
    if (vec[x]) break;
    if (x%b==c) break;
    vec[x] = 1;
  }
  cout << (x%b==c?"YES":"NO") << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		Console.WriteLine((GetInt() + GetInt()) * GetInt() / 2);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<iostream>

using namespace std;

int main(void) {

	int n, a, b;

	cin >> n;
	if (n == 1) {

		cout << "Hello World\n";
	}
	else if (n == 2) {
		cin >> a >> b;

		cout << a + b << "\n";
	}
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,k,i;
	scanf("%d%d%d",&a,&b,&k);
	if(2*k>=(b-a+1))
	{
		for(i=a;i<=b;i++)
			printf("%d\n",i);
	}
	else
	{
		for(i=a;i<=a+k-1;i++)
		{
			printf("%d\n",i);
		}
		for(i=b-k+1;i<=b;i++)
		{
			printf("%d\n",i);
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  



int main(){
  char key[5] = {'M', 'A', 'R', 'C', 'H'};

  ll ans=0;
  map<char, ll> mp;
  int n;  cin >> n;
  for(int i=0; i<n; i++){
    string s; cin >> s;
    mp[s[0]] += 1;
  }

  ans += mp[key[0]]*mp[key[1]]*mp[key[2]];
  ans += mp[key[0]]*mp[key[1]]*mp[key[3]];
  ans += mp[key[0]]*mp[key[1]]*mp[key[4]];
  ans += mp[key[0]]*mp[key[2]]*mp[key[3]];
  ans += mp[key[0]]*mp[key[2]]*mp[key[4]];
  ans += mp[key[0]]*mp[key[3]]*mp[key[4]];
  ans += mp[key[1]]*mp[key[2]]*mp[key[3]];
  ans += mp[key[1]]*mp[key[2]]*mp[key[4]];
  ans += mp[key[1]]*mp[key[3]]*mp[key[4]];
  ans += mp[key[2]]*mp[key[3]]*mp[key[4]];
  cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;

long long N, A[1 << 19];
long long cnt[1 << 19], S;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) { cin >> A[i]; cnt[A[i]]++; }
	for (int i = 1; i <= N; i++) S += cnt[i] * (cnt[i] - 1LL) / 2LL;

	for (int i = 1; i <= N; i++) cout << S - cnt[A[i]] + 1LL << endl;
	return 0;
}

Measured memory_bytes: 5248
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());
		Integer a[] = new Integer[num]; 
		int b[] = new int[num];
		for(int i = 0 ; i < num ; i++){
			String[] spl = br.readLine().split(" ");
			a[i] = Integer.parseInt(spl[0]);
			b[i] = Integer.parseInt(spl[1]);
		}
		Arrays.sort(a , Comparator.reverseOrder());
		Arrays.sort(b);
		int disp = a[0];
		disp += b[0];
		System.out.println(disp);
			
	}
}


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

using namespace std;

typedef long long ll;

vector<int> x;

int main(int, char**)
{
	string s;
	ll n = 0, k = 0, ans = 0;
	cin >> n >> k >> s;

  x.resize(n, 0);
	int z = 0;
	bool w = true;
	for (int i = 0; i < s.length();) {
		if (w) {
			if (s[i] == '1') {
				x[z]++; ++i;
          } else {
				w = false;
				z++;
			}
		} else {
			if (s[i] == '0') {
				x[z]++; ++i;
			} else {
				w = true;
				z++;
			}
		}
	}
if (w == false) { z++; x[z] = 0; }
  if ( z % 2 == 1) {z++; x[z] = 0; }
  for (int i = 0; i <= z; ++i)
    cerr << x[i] << ", ";
cerr << "\n-------" << endl;
  if (k >+ (z/2)) k = z / 2;
	for (int i = 0; i <= z; i+=2) {
		ll ima = x[i];
		for(int j = 0; j < k; j++) {
            if ((i + j * 2+ 2) >= n) break;
			ima += x[i+j*2+1];
        ima += x[i+j*2+2];
            if ((i + j * 2+ 2) >= n) break;
		}
      cerr << ima << endl;
		ans = max(ans, ima);
	}
cerr << endl;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
const int maxn = 10005;
const int F = 0x3f;
const int INF = 0x3f3f3f3f;

struct edge{
	int to,dist,cost;
	edge(int a = 0,int b = 0,int c = 0){
		to = a,dist = b,cost = c;
	}
};

vector<edge> graph[maxn];
int dist[maxn],len[maxn],N,M;
bool inque[maxn];

int spfa(int s){
	memset(dist,F,sizeof(dist));
	memset(len,F,sizeof(len));
	memset(inque,false,sizeof(inque));
	dist[s] = len[s] = 0;
	queue<int> que;
	que.push(s);
	inque[s] = true;
	while(que.size()){
		int temp = que.front();
		que.pop();
		inque[temp] = false;
		for(int i = 0;i < graph[temp].size();++i){
			edge& e = graph[temp][i];
			int to = e.to,d = e.dist,c = e.cost;
			if(dist[to] > dist[temp] + d || (dist[to] == dist[temp] + d && len[to] > c)){
				dist[to] = dist[temp] + d;
				len[to] = c;
				if(!inque[to]){
					inque[to] = true;
					que.push(to);
				}
			}
		}
	}
	int ret = 0;
	for(int i = 1;i <= N;++i){
		ret += len[i];
	}
	return ret;
}

int main(){
	while(scanf("%d%d",&N,&M) == 2 && (N + M)){
		for(int i = 1;i <= N;++i) graph[i].clear();
		int u,v,d,c;
		for(int i = 0;i < M;++i){
			scanf("%d%d%d%d",&u,&v,&d,&c);
			graph[u].push_back(edge(v,d,c));
			graph[v].push_back(edge(u,d,c));
		}
		int ans = spfa(1);
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 5076
/*------------------------------------------------,
|  __                                       __    |
| |  |--.-----.---.-.----.----.-----.-----.|  |_  |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _| |
| |_____|_____|___._|____|____|_____|   __||____| |
|                                   |__|          |
`------------------------------------------------*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;
using namespace std;
#define INF 2147483647
#define MOD 10000007
#define REP(count_ver, lower, upper) for (long long count_ver = lower; count_ver < upper; count_ver++)

int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool isPrime(int a) {
  if (a == 1)     return false;
  if (a == 2)     return true;
  if (a % 2 == 0) return false;
  for (int i = 3; i < sqrt(a) + 1; i += 2) if (a != i and a%i==0) return false;
  return true;
}

void execute(){

  int n;
  cin>>n;
  ll sum=0;
  vector<int> a(n);
  map<int,int> dl;
  REP(i,0,n){
    cin>>a[i];
    dl[a[i]]++;
    sum+=a[i];
  }
  int q;
  cin>>q;
  vector<int> b(q),c(q);
  REP(i,0,q){
    cin>>b[i]>>c[i];
  }

  cerr<<sum<<endl;

  REP(i,0,q){
    sum+=((c[i]- b[i])* dl[b[i]]);
    dl[c[i]]+=dl[b[i]];
    dl[b[i]]=0;
    cout<<sum<<endl;
  }


}
int main() {

  cin.tie(0);
  ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  execute();

  return 0;
}


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

int main(int argc, char const *argv[])
{
    int N, M;
    cin >> N >> M;
    vector<int> a(N), b(N);
    vector<int> c(M), d(M);

    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i];
    }

    for(int j = 0; j < M; j++){
        cin >> c[j] >> d[j];
    }
    
    for(int i = 0; i < N; i++){
        int mindist = 1e9;
        int minj = 0;
        for(int j = 0; j < M; j++){
            int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(dist < mindist){
                mindist = dist;
                minj = j;
            }
        }
        cout << minj+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define tin int
#define tni int
typedef long long ll;
ll x,k,d;
int main(){
	cin>>x>>k>>d;
	x=abs(x);
	if(x/d>=k){
		cout<<x-k*d;
	} else {
		ll y=x%d;
		ll i=(x-y)/d;
		if((k-i)%2)	y=abs(y-d);
		cout<<y<<endl;
	}
	return 0;
}


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

typedef unsigned int uint;

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

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


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

    int k;
    cin >> k;

    for(int i = 0; i < k; i++)
	std::cout << "ACL";

    std::cout << "\n";

    return 0;
}


Measured memory_bytes: 3608
from math import factorial as fac


def binomial(x, y):
    try:
        binom = fac(x) // fac(y) // fac(x - y)
    except ValueError:
        binom = 0
    return binom

n = int(input())
arr = []
for i in range(n):
    arr.append("".join(sorted(input())))

dct = {}
for i in range(n):
    if arr[i] not in dct.keys(): 
        dct[arr[i]] = 1
    else:
        dct[arr[i]] += 1
        
cnt = 0
l = len(dct.keys())
dctlist = list(dct.keys())
for i in range(l):
    el = dctlist[i]
    if dct[el] > 1:
        cnt += binomial(dct[el],2)
print(cnt)

Measured memory_bytes: 19412
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;
#define DumpPairs(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i].fi <<"," << cont[__i].se<<")";} cout<<endl;
/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;

int main() {
    cout.precision(15);
    cout << fixed;
    int x[5];
    REP(i,5)
        cin>>x[i];
    REP(i,5) {
        if (x[i]==0)
            cout<<i+1<<endl;
    }

}


Measured memory_bytes: 3580
g(){int x;scanf("%d",&x);return x;}
main(m,v,x){
  for(;;){double s=0,t=0,z=.0174532925199433,e=.000001;
    scanf("%d",&m);if(!m)return 0;
    for(v=360;--m;s+=sin(x*z))v-=(x=g());s+=sin(v*z);
    scanf("%d",&m);
    for(v=360;--m;t+=sin(x*z))v-=(x=g());t+=sin(v*z);
    puts(s>t+e?"1":s+e<t?"2":"0");
  }
}

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


int a, b;
char op;

int main(void) {
  while(1) {
    cin >> a >> op >> b;
    if(op == '?') break;
    if(op == '+') cout << a + b << endl;
    if(op == '-') cout << a - b << endl;
    if(op == '*') cout << a * b << endl;
    if(op == '/') cout << a / b << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
n = int(input())
arr = list(map(int, input().split()))

dp = [0]*(10**6+1)

for i in sorted(arr):
    dp[i] += 1
    if dp[i] == 1:
        for j in range(2*i, len(dp), i):
            dp[j] += 2
print(dp.count(1))

Measured memory_bytes: 32384
N,M,K=map(int,input().split())

array=list(map(int,input().split()))
A=[0]
pre=0
for i in array:
    pre+=i
    A.append(pre)
    
array=list(map(int,input().split()))
B=[0]
pre=0
for i in array:
    pre+=i
    B.append(pre)

ans,j=0,M
for i in range(N+1):
    if A[i]>K:
        break
    while B[j]>K-A[i]:
        j-=1
    ans=max(ans,i+j)

print(ans)

Measured memory_bytes: 53212
#include <iostream>

using namespace std;

int n;
int a[3005];

int main(void)
{
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	
	int ans = 0;
	for(int i = 0; i < n; i++) ans += a[i]-1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import os
import sys
from io import BytesIO, IOBase
from collections import deque as dq

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##############################################################################
from collections import deque as dq
L=dq(list(input()))
C=0
for _ in range(int(input())):
    S=input().split()
    if S == ['1']:
        C+=1
    elif C%2==0:
        if S[1]=='1':
        	L.appendleft(S[2])
        else:
        	L.append(S[2])
    elif C%2!=0:
        if S[1]=='1':
        	L.append(S[2])
        else:
        	L.appendleft(S[2])
if C%2!=0:
    L.reverse()
print(''.join(L))
          
          

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

int n, p[11];
int ans;

int main(){

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

	sort(p, p + n);

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

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from time import time
from random import randint

from numba import njit
from numpy import int64

@njit('i8(i8[:],i8[:])')
def func(s,x):
    last=[0]*26
    score=0
    for i,v in enumerate(x,1):
        last[v]=i
        c=0
        for j in range(26):
            c+=s[j]*(i-last[j])
        score=score+s[i*26+v]-c
    return score

def main():
    start=time()
    d,*s=map(int,open(0).read().split())
    s=int64(s)
    x=int64(([*range(26)]*15)[:d])
    M=func(s,x)
    while time()-start<1.3:
        y=x.copy()
        y[randint(0,d-1)]=randint(0,25)
        t=func(s,y)
        if t>M:
            M=t
            x=y
    print(*x+1,sep='\n')

main()

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

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

  int n = N;
  int fsum = 0;
  
  while (n) {
    fsum += (n % 10);
    n /= 10;
  }
  
  if ((N % fsum) == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

constexpr int MAX_N = 200000;

int A[MAX_N];
int s1[MAX_N];
int s2[MAX_N];


int main() {
  int N; cin >> N;
  for (int i{}; i < N; ++i) {
    cin >> A[i];
  }

  s1[0] = A[0];
  for (int i{1}; i < N; ++i) {
    s1[i] = max(s1[i-1], A[i]);
  }
  s2[N-1] = A[N-1];
  for (int i{N-2}; i >= 0; --i) {
    s2[i] = max(s2[i+1], A[i]);
  }

  cout << s2[1] << endl;
  for (int i{1}; i < N-1; ++i) {
    cout << max(s1[i-1], s2[i+1]) << endl;
  }
  cout << s1[N-2] << endl;

  return 0;
}


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

typedef long long ll;
ll mod = 1e9 + 7;

const int N = 1e3 + 20;
int a[N][N];
ll dp[N][N];

int main()
{
	ll n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		string s;
		cin >> s;
		for (int j = 1; j <= m; j++)
		{
			if (s[j - 1] == '.') a[i][j] = 1;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (i == 1 && j == 1)
			{
				dp[i][j] = a[i][j];
				continue;
			}
			if (i == 1)
			{
				if (a[i][j] == 0) continue;
				dp[i][j] = dp[i][j - 1];
				continue;
			}
			if (j == 1)
			{
				if (a[i][j] == 0) continue;
				dp[i][j] = dp[i - 1][j];
				continue;
			}
			if (a[i][j] == 0) continue;
			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	}
	cout << dp[n][m];
}


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

int main(){
    string a; cin >> a;
    vector<ll> lis(a.size()+2, 0);
    lis[0] = 0;
    int count = 0;
    ll check = 0;
    ll ans = 0;
    for(int i = 0; i < a.size(); i++){
        if(a[i] == '<'){
            count = 0;
            lis[i+1] = lis[i] + 1;
            ans += lis[i+1];
        }else{
            count++;
            if(lis[i] == 0){
                if(check >= count){
                    ans+=count-1;
                }else{
                    ans+=count;
                }
            }else{
                check = lis[i];
            }
            lis[i+1] = 0;
        }
        //cout << a[i] <<count   << "ans is"<< ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4740
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
int main(void)
{
    ll a,b,c;
    scanf("%lld %lld.%lld" ,&a,&b,&c);
    printf("%lld" ,a*(100*b+c)/100);
    return 0;
}


Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;


int n,a[10],b[10],c[10],ans,cnt,Ans,flag,Flag;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		c[i]=a[i];
	}
	for(int i=0;i<n;i++) scanf("%d",&b[i]);
	sort(c,c+n);
	cnt=1;
	do{
		flag=0;
		for(int i=0;i<n;i++){
			if(a[i]!=c[i]){
				flag=1;
				break;
			}
		}
		if(!flag){
			ans=cnt;
			break;
		}
		cnt++;
	}while(next_permutation(c,c+n));
	
	sort(c,c+n);
	cnt=1;
	
	do{
		Flag=0;
		for(int i=0;i<n;i++){
			if(b[i]!=c[i]){
				Flag=1;
				break;
			}
		}
		if(!Flag){
			Ans=cnt;
			break;
		}
		cnt++;
	}while(next_permutation(c,c+n));
	printf("%d",abs(Ans-ans));
	return 0;
} 

Measured memory_bytes: 3752
#include <stdio.h>

int main( void )
{
  	int i, n;
  
  	scanf( "%d", &n );
  
  	int a[n];
  	double sum=0.0;
  
  	for( i = 0; i < n; i++ ) {
    	scanf( "%d", &a[i] );
      	sum += 1.0 / a[i];
    }
  
  	printf( "%lf\n", 1.0 / sum );
  
 	return 0; 
}


Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[2000001];

ll POW[30];
int length;

ll recursive(int left,int right){

	ll ret;

	int depth = 0;
	queue<int> Q;

	for(int i = left; i <= right; i++){
		if(buf[i] == ' ')continue;

		switch(buf[i]){
		case 'S':
			//Do notghin
			break;
		case '<':
			depth++;
			break;
		case '>':
			depth--;
			break;
		case '@':
			if(depth == 0){
				Q.push(i);
			}
			i++;
			break;
		default:
			//Do nothing
			break;
		}
	}

	ll tmp;
	int pre = 0,tmp_left,tmp_right;

	if(Q.empty()){

		int S_loc = -1;

		for(int i = left; i <= right; i++){
			if(buf[i] == 'S'){
				S_loc = i;
				break;
			}
		}

		if(S_loc == -1){
			ret = 0;

			for(int i = left; i <= right; i++){
				if(buf[i] == ' ')continue;
				ret = 10*ret+(buf[i]-'0');
			}

		}else{
			depth = 0;

			for(int i = S_loc; i <= right; i++){
				if(buf[i] == ' ')continue;


				if(buf[i] == '<'){

					if(depth == 0){
						tmp_left = i;
					}
					depth++;
				}else if(buf[i] == '>'){

					depth--;
					if(depth == 0){
						tmp_right = i;
						break;
					}
				}

			}
			tmp = recursive(tmp_left+1,tmp_right-1);

			ret = (tmp*tmp)%MOD;
		}

	}else{

		while(!Q.empty()){
			tmp_right = Q.front();
			Q.pop();

			if(pre == 0){
				ret = recursive(left,tmp_right-1);
			}else{
				tmp = recursive(pre+2,tmp_right-1);
				if(tmp >= 30 || POW[tmp] > ret){
					ret = 0;
				}else{
					ret /= POW[tmp];
				}
			}
			pre = tmp_right;
		}
		tmp = recursive(pre+2,right);

		if(tmp >= 30 || POW[tmp] > ret){
			ret = 0;
		}else{
			ret /= POW[tmp];
		}
	}
	return ret;
}

void func(){

	for(length = 0; buf[length] != '\0' && buf[length] != '\n'; length++);

	bool is_pre_num = false,is_pre_S = false;

	for(int i = length-1; i >= 0; i--){
		if(buf[i] == ' ')continue;

		if(buf[i] == 'S'){
			is_pre_num = false;
			is_pre_S = true;
		}else if(buf[i] >= '0' && buf[i] <= '9'){
			is_pre_num = true;
			is_pre_S = false;
		}else if(buf[i] == '<'){
			is_pre_num = false;
			is_pre_S = false;
		}else if(buf[i] == '>'){
			if(is_pre_num == true || is_pre_S == true){
				buf[i] = '@';
				buf[i-1] = '@';
				i--;
			}
			is_pre_num = false;
			is_pre_S = false;
		}
	}
	printf("%lld\n",recursive(0,length-1));
}


int main(){

	for(int i = 0; i < 30; i++)POW[i] = (ll)pow(2,i);

	while(true){
		fgets(buf,2000000,stdin);
		if(buf[0] == '#')break;

		func();
	}

	return 0;
}

Measured memory_bytes: 30276