akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}

signed main(){
	int N;cin>>N;
	vint A(N);rep(i,N)cin>>A[i];

	vint pre(N+1),suf(N+1);
	rep(i,N)pre[i+1]=gcd(pre[i],A[i]);
	for(int i=N-1;i>=0;i--)suf[i]=gcd(suf[i+1],A[i]);
	int ans=0;
	rep(i,N){
		chmax(ans,gcd(pre[i],suf[i+1]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2688
class Integer
  def pow(y, m)
    return 1 if y == 0
    res = self.pow(y/2, m)
    res * res % m * (y.odd? ? self : 1) % m
  end
end

L = gets.chomp
# L = ?1 * 100001
MOD = 10**9+7

bases = [0] * 100002
bases[0] = 1
(1...bases.size).each{|i|
  bases[i] = (bases[i - 1] * 3 - 1) % MOD
}

cnt = 0
ans = 0
L.chars.each_with_index{|c, i|
  if c != ?0
    ans += bases[L.size - i - 1] * 2.pow(cnt, MOD)
    cnt += 1
  end
}
p (ans*2+1) % MOD

Measured memory_bytes: 10748
N = int(input())

march = 'MARCH'
c = [0]*5
for _ in range(N):
    s = input()
    for i in range(5):
        if s.startswith(march[i]):
            c[i] += 1
            break

s = 0
for i in range(5):
    for j in range(i + 1, 5):
        for k in range(j + 1, 5):
            s += c[i]*c[j]*c[k]

print(s)


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

const int MX=100005;

int main()
{
    char c;
    cin>> c;
    if(c>='a' && c<='z') cout<< "a" <<endl;
    else cout<< "A" <<endl;
    return 0;
}

Measured memory_bytes: 3636
object Main {
  import java.io.PrintStream

  def main(args: Array[String]): Unit = {
    val s = new Main()
    val ps = new PrintStream(Console.out)
    Console.withOut(ps) {
      s.solve()
    }
    ps.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag
  import scala.Console

  val MOD = 1000000007

  val pow2 = Array.ofDim[Int](10)
  pow2(0) = 1
  rep(pow2.length - 1)(i => pow2(i + 1) = pow2(i) * 2)

  def solve(): Unit = {
    val H, W, K = ni()

    val dp = Array.ofDim[Int](H + 1, W)
    dp(0)(0) = 1
    rep(H, 1) { i =>
      rep(pow2(W - 1)) { bit =>
        if ((bit & bit << 1) == 0) {
          rep(W) { j =>
            val l = (1 << j - 1 & bit) > 0
            val r = (1 << j & bit) > 0
            if (!l && !r) {
              dp(i)(j) += dp(i - 1)(j)
            } else if (l && !r) {
              dp(i)(j) += dp(i - 1)(j - 1)
            } else if (!l && r) {
              dp(i)(j) += dp(i - 1)(j + 1)
            }
            if (dp(i)(j) >= MOD) dp(i)(j) -= MOD
          }
        }
      }
    }

    println(dp(H)(K - 1))
  }


  class InputReader(reader: BufferedReader) {
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(Console.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    rep(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    rep(n) { i =>
      rep(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Int](as.length + 1)
    rep(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 27300
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;

struct UnionFind {
  // 要素に対応する値は自分の根。根は要素数の-1倍したものを代入する。
  // 根ならそのグループの要素数(負)が、子であれば親の番号が入る。初期値-1。
  vector<int> uni;
  UnionFind(){
    uni = vector<int>(100100, -1);
  }

  // 頂点aの所属するグループを調べる。
  int root(int a)
  {
    // uni[a]が負の値なら親はa自身
    if (uni[a] < 0) return a;
    // 正の値であれば、親ルートを調べ戻り値で根に直接つなぐ。
    else {
      uni[a] = root(uni[a]);
      return uni[a];
      // return uni[a] = root(uni[a]);
    }
  }

  // 頂点aとbをつなぐ、もともと同じグループの場合falseを返す。
  bool connect(int a, int b)
  {
    a = root(a);
    b = root(b);
    if (a == b) return false;

    // aを大きなグループにしたいので、逆であれば入れ替える。
    if (uni[a] > uni[b])
    {
      int hoge = a;
      a = b;
      b = hoge;
    }

    //aとbを結合し、bをaの親とする。
    uni[a] += uni[b];
    uni[b] = a;
    return true;
  }

  //  頂点a, bが同じグループか
  bool isConnect(int a, int b)
  {
    return root(a) == root(b);
  }

  // 頂点aを含むグループの頂点数を調べる
  int size(int a)
  {
    return -uni[root(a)];
  }

};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<p> friends(m), block(k);
  vector<int> dir(n);
  map<int, vector<int>> mp;
  rep(i, m){
    cin >> friends[i].first >> friends[i].second;
    friends[i].first--; friends[i].second--;
    dir[friends[i].first]++;
    dir[friends[i].second]++;
  }
  rep(i, k){
    cin >> block[i].first >> block[i].second;
    block[i].first--; block[i].second--;
    mp[block[i].first].push_back(block[i].second);
    mp[block[i].second].push_back(block[i].first);
  }

  UnionFind uf;
  UnionFind uf2;

  rep(i, m){
    uf.connect(friends[i].first, friends[i].second);
  }

  rep(i, k){
    uf2.connect(block[i].first, block[i].second);
  }

  rep(i, n){
    int count = 0;
    for(auto a : mp[i]){
      // cout << a << endl;
      count += (uf2.isConnect(i, a) && uf.isConnect(i, a));
    }
    // cout << count << endl;
    cout << max(0, uf.size(i)-1 - dir[i] - count) << ' ';
  }
  cout << endl;
}


Measured memory_bytes: 15744
#include <iostream>
#include <cstring>
using namespace std;
int main()
{  string S;
  cin>>S;
  for(int i=0;i<S.size();i++){
    S[i]= 'x';
  }

  for(int i=0;i<S.size();i++){
    cout<<S[i];
  }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstdlib>

#define SWAP(a,b) (a += b,b = a - b,a -= b)

int main(){
  int i,j,N, *arr, flag = 1, count = 0,tmp;
  scanf("%d",&N);
  arr = (int *)malloc(sizeof(int) * N);
  for(i = 0; i < N; i++){
    scanf("%d",&arr[i]);
  }
  #ifdef D
  for(i = 0; i < N; i++){
    printf("%d ",arr[i]);
  }
  SWAP(count, flag);
  printf("%d\n",count);
  #endif

  // babbleSort
  i = 0; // first unsorted array index
  while(flag){
    flag = 0;
    for(j = N - 1; j > i; j--){
      if(arr[j - 1] > arr[j]){
	//SWAP(arr[j-i],arr[j]);
	tmp = arr[j];
	arr[j] = arr[j-1];
	arr[j-1] = tmp;
	flag = 1;
	count++;
      }
    }
    i++;
  }
  for(i = 0; i < N; i++){
    printf("%d",arr[i]);
    if(i == N-1){
      printf("\n");
      break;
    }
    printf(" ");
  }
  printf("%d\n",count);
  

  return 0;
}



Measured memory_bytes: 2704
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] arr = new int[n];
		for(int i=0; i<n; i++) {
			arr[i] = scan.nextInt();
		}
		int k = 2;
		int flag = 1; //0???????´???°??§????????????1???????´???°
		int cnt = 0; //?´???°?????°???????????????
		for(int i=0; i<arr.length; i++){
			while(k <= Math.sqrt(arr[i])+1){
			//while(arr[i] != k){
			//wh1ile(list.hasnext()){
				//System.out.println("arr[i]:" + arr[i] + ",k:" + k + ",??????:" + arr[i] % k);
				if(arr[i] % k == 0 && arr[i] != 2){
					flag = 0;
					break;
				}
				k++;
			}
			if(flag == 1){cnt++;}
			flag = 1;
			k = 2;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 41620
#include<bits/stdc++.h>
#include<atcoder/dsu>
using namespace std;
using namespace atcoder;
int main()
{
    int n, m;
    cin >> n >> m;
    dsu d(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        d.merge(a, b);
    }
    cout << d.groups().size() - 1 << endl;
}


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

#define float double
#define debug(x) (cerr << #x << ": " << (x) << endl)

typedef long long ll;

using namespace std;

int32_t main() {

    string s;
    cin >> s;
    ll price = 700;

    if(s[0] == 'o'){
        price += 100;
    }
    if(s[1] == 'o'){
        price += 100;
    }
    if(s[2] == 'o'){
        price += 100;
    }

    cout << price << endl;

}


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

using namespace std;

using LL = long long;           using PII = pair<int, int>;
using ll = long long;           using DBL = double;
using VI = vector<int>;         using VD = vector<DBL>;
using VVI = vector<VI>;         using VVD = vector<VD>;
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)
#define SZ(a) ((int)((a).size()))
#define ALL(x) (x).begin(), (x).end()
#define SET(a,v) memset((a), (v), sizeof(a))
#define EB emplace_back #define PB push_back
#define MP make_pair  #define ST first  #define ND second

// #define trace(...) {__f(#__VA_ARGS__, __VA_ARGS__);}
// template<typename Arg> void __f(const char* name, Arg&& arg) {
//   cerr << name << " = " << arg << std::endl;
// } template <typename Arg1, typename... Args>
// void __f(const char* names, Arg1&& arg1, Args&&... args) {
//   const char* comma = strchr(names + 1, ',');
//   cerr.write(names, comma - names) << " = " << arg1<<" | ";__f(comma+1, args...); }
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds; // OST: find_by_order, order_of_key
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// #pragma GCC optimize("Ofast")
// optimize("unroll-loops")
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// /*** RNGS ***/
// SEED=chrono::steady_clock::now().time_since_epoch().count();
// // or high_resolution_clock
// mt19937 rng(SEED); /*or*/ random_device rd; mt19937 rng(rd());
// uniform_int_distribution<> dis(MIN, MAX);// usage: dis(rng)
// struct chash {int operator()(int x) const {return x^SEED;}};
// gp_hash_table<int,int,chash>m;//use cc if very less updates
// /*** FAST IO ***/
// inline int scan(){ bool y=0; int x=0; char c=getchar_unlocked();
// while(c<'0'||c>'9'){ if(c=='-')y=1; c=getchar_unlocked();} 
// while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar_unlocked();}
// return y?-x:x; }

vector<LL> calc(int n, LL k) {
	vector<LL> y(n, (n-1) + k/n);
	for(int i=0; i<(k%n); ++i) {
		y[i] += (n + 1);
		for(auto&z: y) {
			z -= 1;
		}
	}
	return y;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	LL k;
	cin >> k;
	for(int n=2; n<=50; ++n) {
		auto v = calc(n, k);
		bool valid = true;
		for(auto&z: v) {
			if(z < 0 or z > 10000000000000000LL + 1000) valid = false;
		}
		if(valid) {
			cout << SZ(v) << endl;
			for(auto&z: v) {
				cout << z << ' ';
			}
			cout << '\n';
			return 0;
		}
	}
	assert(0);
	return 0;
}

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

int N, x[111111], y[111111], t[111111];

int main(){
	
	cin >> N; 
	for (int i = 1; i <= N; i ++){
		cin >> t[i] >> x[i] >> y[i];
	}
	for (int i = 1; i <= N; i ++){
		if (((t[i] - t[i - 1]) % 2 == 0) && (((x[i] - x[i - 1] + y[i] - y[i - 1]) % 2 == 1) || (x[i] - x[i - 1] + y[i] - y[i - 1] > t[i] - t[i - 1]))){
				cout << "No";
				return 0;
		}
		if (((t[i] - t[i - 1]) % 2 == 1) && (((x[i] - x[i - 1] + y[i] - y[i - 1]) % 2 == 0) || (x[i] - x[i - 1] + y[i] - y[i - 1] > t[i] - t[i - 1]))){
				cout << "No";
				return 0;
		}
	}

	cout << "Yes";

}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;
void solve(){
  int a, b;
  char op;
  cin >> a >> op >> b;
  if(op == '+') cout << a + b << endl;
  else cout << a - b << endl;

  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
def solve():
    from sys import stdin
    from itertools import combinations
    file_input = stdin
    
    N = int(file_input.readline())
    hw = [tuple(map(int, file_input.readline().split())) for i in range(N)]
    goal = (line.rstrip() for line in file_input)
    goal = ''.join(goal)
    
    R = 0
    G = 0
    B = 0
    b = 1
    for c in goal[:]:
        if c == 'R':
            R += b
        elif c == 'G':
            G += b
        else:
            B += b
        b <<= 1
    c_m = (R, G, B) # color mask
    g_m = (1 << 16) - 1 # goal mask
    
    stamps = []
    for r1, r2 in combinations(range(5), 2):
        rw = r2 - r1
        for c1, c2 in combinations(range(5), 2):
            cw = c2 - c1
            for h, w in hw:
                if (rw == h and cw == w) or \
                ((r1 == 0 or r2 == 4) and rw < h and cw == w) or \
                ((c1 == 0 or c2 == 4) and cw < w and rw == h) or \
                ((r1 == 0 or r2 == 4) and (c1 == 0 or c2 == 4) and \
                 rw < h and cw < w):
                    m = 1
                    for i in range(cw - 1):
                        m <<= 1
                        m += 1
                    m <<= c1
                    r_m = m
                    for i in range(rw - 1):
                        m <<= 4
                        m += r_m
                    m <<= (r1 * 4)
                    for c in c_m:
                        s = c & m
                        if s:
                            stamps.append((m ^ g_m, s))
                    break
    
    picture = [0]
    generated_picture = [False] * (2 ** 16)
    generated_picture[0] = True
    step = 0
    while True:
        t_picture = picture[:]
        picture = []
        step += 1
        for p in t_picture:
            for m, s in stamps:
                n_p = p & m | s
                if generated_picture[n_p]:
                    continue
                if n_p == g_m:
                    return step
                generated_picture[n_p] = True
                picture.append(n_p)

print(solve())


Measured memory_bytes: 8424
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, m, tx, ty, ss, st, tot;
int f[MAXN], s[MAXN], t[MAXN];
bool colour[MAXN], is[MAXN], it[MAXN];
vector <int> a[MAXN];
long long ans, tmp[MAXN];
void work(int pos, int fa) {
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (a[pos][i] != fa) work(a[pos][i], pos);
	s[fa] += s[pos];
	t[fa] += t[pos];
	if (fa != 0) ans += abs(s[pos] - t[pos]);
}
void Work(int pos, int fa) {
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (a[pos][i] != fa) Work(a[pos][i], pos);
	s[fa] += s[pos];
	t[fa] += t[pos];
	is[fa] |= is[pos];
	it[fa] |= it[pos];
	if (fa != 0) {
		if (is[pos] == it[pos]) ans += abs(s[pos] - t[pos]);
		else if (is[pos] && !it[pos]) tmp[++tot] = s[pos] - t[pos];
		else tmp[++tot] = t[pos] - s[pos];
	}
}
long long solve() {
	ans = 0;
	work(1, 0);
	return ans;
}
void Colour(int pos, int fa) {
	colour[pos] = !colour[fa];
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (a[pos][i] != fa) Colour(a[pos][i], pos);
}
int F(int x) {
	if (f[x] == x) return x;
	else return f[x] = F(f[x]);
}
int main() {
	read(n), read(m);
	if (n & 1) {
		printf("-1\n");
		return 0;
	}
	for (int i = 1; i <= n; i++)
		f[i] = i;
	for (int i = 1; i <= m; i++) {
		int x, y;
		read(x), read(y);
		if (F(x) == F(y)) tx = x, ty = y;
		else {
			f[F(x)] = F(y);
			a[x].push_back(y);
			a[y].push_back(x);
		}
	}
	Colour(1, 0);
	ss = 0, st = 0;
	for (int i = 1; i <= n; i++)
		if (colour[i]) ss++, s[i] = 1;
		else st++, t[i] = 1;
	if (tx == 0 && ty == 0) { /*Tree Case*/
		if (ss == st) cout << solve() << endl;
		else printf("-1\n");
		return 0;
	}
	if (colour[tx] == colour[ty]) { /*Odd Circle Case*/
		int delta = ss - st;
		if (delta <= 0) s[tx] += abs(delta / 2), s[ty] += abs(delta / 2);
		else t[tx] += abs(delta / 2), t[ty] += abs(delta / 2);
		cout << solve() + abs(delta / 2) << endl;
		return 0;
	}
	if (colour[tx] != colour[ty]) { /*Even Circle Case*/
		if (ss != st) {
			printf("-1\n");
			return 0;
		}
		if (colour[tx]) is[tx] = true;
		else it[tx] = true;
		if (colour[ty]) is[ty] = true;
		else it[ty] = true;
		tmp[++tot] = 0;
		Work(1, 0);
		sort(tmp + 1, tmp + tot + 1);
		long long x = tmp[(tot + 1) / 2];
		for (int i = 1; i <= tot; i++)
			ans += abs(x - tmp[i]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 13824
n,m = map(int, input().split())
a = list(map(int, input().split()))

bc = []

for i in range(m):
    b,c=map(int,input().split())
    bc.append([b,c])

bc = sorted(bc, key=lambda x: x[1],reverse=True)
a = sorted(a)

itr = 0 
for i in bc:
    b, c = i[0], i[1]
    for j in range(b):
        if a[itr]>=c:
            print(sum(a))
            exit()
        else:
            a[itr]=c
            itr +=1
            if itr == n:
                print(sum(a))
                exit()
print(sum(a))

Measured memory_bytes: 26444
#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() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int a, b;
  cin >> a >> b;
  cout << max(0, a - 2 * b) << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC087
{
    public class QuestionC
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Enumerable.Range(0, 2).Select(i => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
            var max = Enumerable.Range(0, n).Select(i => Enumerable.Range(0, i).Select(x => a[0][x]).Sum() + a[0][i] + a[1][i] + Enumerable.Range(i + 1, n - i - 1).Select(x => a[1][x]).Sum()).Max();
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 28332
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func ni() (val int) {
	sc.Scan()
	val, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return val
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ni()
	c := make([]int, n)
	s := make([]int, n)
	f := make([]int, n)
	for i := 0; i+1 < n; i++ {
		c[i] = ni()
		s[i] = ni()
		f[i] = ni()
	}

	best := make([]int, n)
	for i := 0; i < n; i++ {
		best[i] = 1000000000
	}
	best[0] = s[0]
	// ans := make([]int, n)
	for i := 0; i < n; i++ {
		t := best[i]
		if s[i] < t {
			t = s[i]
		}
		for j := i; j+1 < n; j++ {
			k := (t - s[j] + f[j] - 1) / f[j] // t<=s+f*k となる最小のk>=0
			if k < 0 {
				k = 0
			}
			t = s[j] + f[j]*k + c[j]
			if t < best[j+1] {
				best[j+1] = t
			}
		}
		fmt.Println(t)
	}
}


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

int main(){
  char s[12],t[12];
  scanf("%s",s);
  scanf("%s",t);
  int lens = strlen(s);
  int lent = strlen(t);

  int ans=1;
  for(int i=0;i<lens;i++){
    if(s[i]!=t[i]) ans=0;}
  if(lens+1!=lent) ans=0;

  if(ans){
    printf("Yes\n");}
  else{
    printf("No\n");}
  
  return 0;
}


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

int A, B, C, D;

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

    if (A * B > C * D) {
        cout << A * B << endl;
    } else {
        cout << C * D << endl;
    }
}

Measured memory_bytes: 256
# print('input >>')
N = input()
As = list(map(int,(input().split())))

ans = 0
for i in range(len(As) - 1):
    if As[i] > As[i+1]:
        ans += As[i] - As[i+1]
        As[i+1] += As[i] - As[i+1]

# print('-----output-----')
print(ans)
# print(As)

Measured memory_bytes: 32232
n, m = map(int, input().split())
arr = [input().split() for _ in range(m)]

bigin = 10 ** (n-1)
if bigin == 1:
    bigin = 0
end = 10 ** n
for x in range(bigin, end):
    num = str(x)
    for s, c in arr:
        if num[int(s)-1] != c:
            break
    else:
        print(num)
        break
else:
    print(-1) 

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#include<cmath>
#include<map>
#include<set>
#define int long long int
#define mod 1000000007
int32_t main()
{
	int n;
	cin>>n;
	int arr[n+1][3];
	arr[0][0]=0;
	arr[0][1]=0;
	arr[0][2]=0;
	int j;
	for(j=1;j<=n;j++)
	    cin>>arr[j][0]>>arr[j][1]>>arr[j][2];
	bool result=true;
	for(j=1;j<=n;j++)
    {
		int time=arr[j][0]-arr[j-1][0];
		int dist=abs(arr[j][1]-arr[j-1][1])+abs(arr[j][2]-arr[j-1][2]);
		if(time>=dist&&(time-dist)%2==0)
		    continue;
		else
		{
			result=false;
			break;
		}
	}
	cout<<(result?"Yes":"No")<<endl;
}


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

int main(){
	
	int a[3];
	
	for(int i=0;i<3;i++)
		cin>>a[i];
	
	sort(a,a+3);
	
	cout<<a[0];
	for(int i=1;i<3;i++)
		cout<<" "<<a[i];
	cout<<endl;
	
}

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

int main(){
  int a;
  int b;
  int c;
  cin>>a>>b>>c;
  
  if (a==b) {
  	cout<<c<<endl;
  }
  else if (a==c) {
  	cout<<b<<endl;
  }
  else if (b==c) {
  	cout<<a<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int flg = 0;
    int x;
    for(int i=0;i<n;i++){
        cin >> x;
        if(x%2==0){
            if(x%3 != 0 &&x%5 != 0){
                flg =1;
                break;
            }
        }
    }
    if(flg == 0){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
ll A, B, Q;
vl s;
vl t;

void solve() {

	cin >> A >> B >> Q;

	for (int i = 0; i < A; i++) {
		ll tmp;
		cin >> tmp;
		s.eb(tmp);
	}

	for (int i = 0; i < B; i++) {
		ll tmp;
		cin >> tmp;
		t.eb(tmp);
	}

	for (int i = 0; i < Q; i++) {
		ll x;
		cin >> x;

		bool snf = true, tnf = true, sn1f = true, tn1f = true;

		auto sn = lower_bound(s.begin(), s.end(), x);
		auto tn = lower_bound(t.begin(), t.end(), x);
		if (sn == s.end()) snf = false;
		if (tn == t.end()) tnf = false;
		auto sn1 = (sn != s.begin() ? sn - 1 : sn);
		if (sn == s.begin()) sn1f = false;
		auto tn1 = (tn != t.begin() ? tn - 1 : tn);
		if (tn == t.begin()) tn1f = false;

		ll ans = 1e20;

		if (sn1f == true && tn1f == true && *tn1 > *sn1) ans = min(abs(x - *sn1), ans);
		if (sn1f == true && tn1f == true && *sn1 > *tn1)ans = min(abs(x - *tn1), ans);
		if (sn1f==true&&tnf==true) {
			ans = min(abs(2 * *tn - x - *sn1), ans);
			ans = min(abs(x + *tn - 2 * *sn1), ans);
		}
		if (snf == true && tn1f == true) {
			ans = min(abs(2 * *sn - x - *tn1), ans);
			ans = min(abs(x + *sn - 2 * *tn1), ans);
		}
		if (snf == true && tnf == true && *tn > *sn)ans = min(abs(*tn - x), ans);
		if (snf == true && tnf == true && *tn < *sn)ans = min(abs(*sn - x), ans);

		cout << ans << endl;

	}


	return;

}

int main() {

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

	solve();

	return 0;

}

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

#define STACK_SIZE 200

struct Stack {
    int operand[STACK_SIZE];
    int top;
};

static void pushOperand(struct Stack* s, int operand) {
    s->operand[s->top] = operand;
    s->top++;
    return;
}

static int popOperand(struct Stack* s) {
    s->top--;
    return s->operand[s->top];
}

int main(int argc, char* argv[]) {
    struct Stack stack;
    char buf[100];

    memset(&stack, 0x00, sizeof(stack));

    while ( scanf("%s", buf) != EOF ) {
        if ( buf[0] == '+' ) {
            int op1, op2, result;
            op1 = popOperand(&stack);
            op2 = popOperand(&stack);
            result = op2 + op1;
            pushOperand(&stack, result);
        } else if ( buf[0] == '-' ) {
            int op1, op2, result;
            op1 = popOperand(&stack);
            op2 = popOperand(&stack);
            result = op2 - op1;
            pushOperand(&stack, result);
        } else if ( buf[0] == '*' ) {
            int op1, op2, result;
            op1 = popOperand(&stack);
            op2 = popOperand(&stack);
            result = op2 * op1;
            pushOperand(&stack, result);
        } else {
            int op = atoi(buf);
            pushOperand(&stack, op);
        }
    }

    int result = popOperand(&stack);

    printf("%d\n", result);
    
    return 0;
}





Measured memory_bytes: 2036
x = int(input())
if x in range(400, 600): print(8)
elif x in range(600, 800): print(7)
elif x in range(800, 1000): print(6)
elif x in range(1000, 1200): print(5)
elif x in range(1200, 1400): print(4)
elif x in range(1400, 1600): print(3)
elif x in range(1600, 1800): print(2)
else: print(1)

Measured memory_bytes: 9188
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = Io.Read<int>();
            var i = X;
            while (true)
            {
                var isSosu = true;
                for (var j = 2; j < Math.Sqrt(i); j++)
                {
                    if (i % j == 0)
                    {
                        isSosu = false;
                        break;
                    }
                }

                if (isSosu)
                {
                    Io.Write(i.ToString());

                    break;
                }

                i++;
            }
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }

        class Io
        {
            public static string Read()
            {
                return Console.ReadLine();
            }

            public static IEnumerable<string> ReadRepeat(int count)
            {
                return Enumerable.Range(0, count).Select(_ => Read());
            }

            public static T Read<T>()
            {
                return (T)Convert.ChangeType(Read(), typeof(T));
            }

            public static IEnumerable<T> ReadRepeat<T>(int count)
            {
                return Enumerable.Range(0, count).Select(_ => Read<T>());
            }

            public static string[] ReadList(char devide = ' ')
            {
                return Read().Split(devide);
            }

            public static T[] ReadList<T>(char devide = ' ')
            {
                return ReadList(devide)
                    .Select(s => (T)Convert.ChangeType(s, typeof(T)))
                    .ToArray();
            }

            public static IEnumerable<T[]> ReadListRepeat<T>(int count, char devide = ' ')
            {
                return Enumerable.Range(0, count).Select(_ => ReadList<T>(devide));
            }

            public static void Write(string value)
            {
                Console.WriteLine(value);
            }
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 500+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
LL max(LL a,LL b,LL c){
    return max(a,max(b,c));
}
LL min(LL a,LL b,LL c){
    return min(a,min(b,c));
}
int main(){
    LL h,w;
    scanf("%lld%lld",&h,&w);

    LL res=INF;
    LL pos;
    LL a,b,c;
    LL maxx,minn;
    for(LL i=1;i<h;i++){
        pos=(h-i)/2;
        a=pos*w;
        b=(h-i-pos)*w;
        c=i*w;
        maxx=max(a,b,c);
        minn=min(a,b,c);
        res=min(maxx-minn,res);

        pos=w/2;
        a=pos*(h-i);
        b=(w-pos)*(h-i);
        c=i*w;
        minn=min(a,b,c);
        maxx=max(a,b,c);
        res=min(maxx-minn,res);
    }

    for(LL i=1;i<w;i++){
        pos=(w-i)/2;
        a=pos*h;
        b=(w-i-pos)*h;
        c=i*h;
        minn=min(a,b,c);
        maxx=max(a,b,c);
        res=min(maxx-minn,res);

        pos=h/2;
        a=pos*(w-i);
        b=(h-pos)*(w-i);
        c=i*h;
        minn=min(a,b,c);
        maxx=max(a,b,c);
        res=min(maxx-minn,res);
    }

    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int in,m=1;
	cin>>in;
	for(int a=1;a<=1000;a++)
	{
		m=m*2;
		if(m>in)
		{
			cout<<m/2<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
N, M = map(int,input().split())
X = list(map(int, input().split()))
X.sort()
diff = []
if M != 1:
  for i in range(M-1):
    diff.append(X[i+1]-X[i])
else:
  diff = [0]

sorted_diff = sorted(diff)
sorted_diff.reverse()

ans = sum(sorted_diff)
for i in range(min([N,M])-1):
  ans -= sorted_diff[i]
print(ans)

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

int main() {
	string a;
	int r,l,tx,ans=0,i;
	int ss[32];
	for(i=0;i<32;i++){
		ss[i]=0;
	}
	
	while(1){
		cin >> a;
		if(a=="#") break;
		tx=a.length();
		for(i=0;i<tx;i++){
			if(a[i]=='q') ss[i]=1;
			if(a[i]=='w') ss[i]=1;
			if(a[i]=='e') ss[i]=1;
			if(a[i]=='r') ss[i]=1;
			if(a[i]=='t') ss[i]=1;
			if(a[i]=='a') ss[i]=1;
			if(a[i]=='s') ss[i]=1;
			if(a[i]=='d') ss[i]=1;
			if(a[i]=='f') ss[i]=1;
			if(a[i]=='g') ss[i]=1;
			if(a[i]=='z') ss[i]=1;
			if(a[i]=='x') ss[i]=1;
			if(a[i]=='c') ss[i]=1;
			if(a[i]=='v') ss[i]=1;
			if(a[i]=='b') ss[i]=1;
		}
		for(i=0;i<tx-1;i++){
			if(ss[i]!=ss[i+1]) ans++;
		}
		cout << ans << endl;
		for(i=0;i<tx;i++){
			ss[i]=0;
		}
		ans=0;
	}
	return 0;
}

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

using ll = long long;
static const ll MOD = 1e9 + 7;

// 繰り返し自乗法(x^nをmで割った余り) O(logn)
ll power(ll x, ll n, ll m) {
  ll res = 1;
  if (n > 0) {
    res = power(x, n / 2, m);
    if(n % 2 == 0) res = (res * res) % m;
    else res = (((res * res) % m) * x) % m;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> c(n);
  for (int i = 0; i < n; i++) cin >> c.at(i);
  
  sort(c.rbegin(), c.rend());
  
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (((i + 2) * c.at(i)) % MOD * power(4, n - 1, MOD)) % MOD;
    ans %= MOD;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,m,a,b;
    cin>>n>>m;
    bool ans[n],maki=0;
    memset(ans,0,sizeof(ans));
    for(int i=0;i<m;i++){
        cin>>a>>b;
        ans[a-1]^=1;
        ans[b-1]^=1;
    }
    for(int i=0;i<n;i++){
        maki|=ans[i];
    }
    cout << ((maki)?"NO":"YES")<<endl;
    return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

type UnionFind struct {
	Par map[int]int
}

// NewUnionFind returns *UnionFind
func NewUnionFind(n []int) *UnionFind {
	par := make(map[int]int)
	for i := 0; i < len(n); i++ {
		par[n[i]] = -1
	}
	return &UnionFind{
		Par: par,
	}
}

// Root
func (u *UnionFind) Root(x int) int {
	c := u.Par[x]
	if c < 0 {
		return x
	}
	u.Par[x] = u.Root(u.Par[x])
	return u.Par[x]
}

func (u *UnionFind) Unite(x, y int) bool {
	x = u.Root(x) //xの根をrx
	y = u.Root(y) //yの根をry
	if x == y {
		return false
	} //xとyの根が同じ(=同じ木にある)時はそのまま
	if u.Par[x] > u.Par[y] {
		tmp := x
		x = y
		y = tmp
	}
	u.Par[x] += u.Par[y]
	u.Par[y] = x
	return true
}

func (u *UnionFind) Same(x, y int) bool { // 2つのデータx, yが属する木が同じならtrueを返す
	rx := u.Root(x)
	ry := u.Root(y)

	// fmt.Println("(x, y)", x, y)
	// fmt.Println("(rx, ry)", rx, ry)
	// fmt.Println(u.Par)
	return rx == ry
}

func (u *UnionFind) Size(x int) int {
	n := u.Root(x)
	return -u.Par[n]
}

func main() {
	var n, q int
	fmt.Scanf("%d %d", &n, &q)

	ts := make([]int, q)
	v1s := make([]int, q)
	v2s := make([]int, q)
	hist := make([]int, 0)

	for i := 0; i < q; i++ {
		fmt.Scanf("%d %d %d", &ts[i], &v1s[i], &v2s[i])
		hist = append(hist, v1s[i])
		hist = append(hist, v2s[i])

	}
	union := NewUnionFind(hist)

	for i := 0; i < q; i++ {
		t, v1, v2 := ts[i], v1s[i], v2s[i]
		if t == 1 {
			if union.Same(v1, v2) {
				fmt.Println(1)
			} else {
				fmt.Println(0)
			}
		} else {
			union.Unite(v1, v2)
		}
	}
}


Measured memory_bytes: 21340
import collections

N = int(input())
A_list = [int(e) for e in input().split()]

#import random
#N = 2 * 10**5
#A_list = [random.randrange(1,10**6) for _ in range(N+1)]

A_counter = collections.Counter(A_list)

max_A = max(A_list)

A_list.sort(reverse=False)
OK_set = set(A_list)

ans = list()

#入力のうち、小さい方から倍数を生成。その倍数に引っかかったらアウト

for i in range(0,N):
    A = A_list[i]

    if A*2 <= max_A:
        multiple_set = {A*j for j in range(2,1+max_A//A)}
        #print(multiple_set)
        OK_set -= multiple_set

    if A_counter[A] != 1:
        OK_set -= {A}
    
    #print(OK_set)

print(len(OK_set))              

Measured memory_bytes: 100236
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll a, b, c;

	cin >> a >> b >> c;

	cout << min(b / a, c) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>

int main() {
    constexpr double pi{acos(-1)};
    double a{}, b{}, c{};
    std::cin >> a >> b >> c;
    const double h{b*sin(pi*c/180.0)};
    const double s{a*h/2.0};
    const double l{a + b + pow(pow(h, 2.0) + pow(a-b*cos(pi*c/180.0), 2.0), 0.5)};
    printf("%.8lf\n%.8lf\n%.8lf\n", s, l, h);
}



Measured memory_bytes: 3656
from collections import defaultdict as dict
d = dict(int)
N, M = map(int,input().split())
A = [int(i) for i in input().split()]
sumA = [0 for i in range(N + 1)]
for i in range(N):
    sumA[i + 1] = (A[i] + sumA[i]) % M
ans = 0

for j in range(len(sumA)):
    ans += d[sumA[j]]
    d[sumA[j]] += 1

print(ans)

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

int main(){
    while(1){
        int r, n; cin>>r>>n;
        if(r == 0) return 0;

        vector<int> height(130, 0);

        for(int i=0; i<n; i++){
            int xl, xr, h; cin>>xl>>xr>>h;
            xl += 100;
            xr += 100;

            for(int j=xl; j<xr; j++){
                height[j] = max(height[j], h);
            }
        }

        vector<int> fheight(130, 0);
        for(int i=75; i<=125; i++){
            fheight[i] = min(height[i], height[i-1]);
        }

        double ans = 1e9;
        for(int i=100-r+1; i<100+r; i++){
            double sum = fheight[i] + 1. * (r - sqrt(r * r - abs(100 - i) * abs(100 - i)));
            ans = min(ans, sum);
        }

        printf("%.10f\n", ans);
    }
}


Measured memory_bytes: 3232
import java.util.*;

public class Main {
    public static void main (String[] args) {
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                System.out.println(i + "x" + j + "=" + (i*j));
            }
        }
    }
}

Measured memory_bytes: 15008
//扫描线段,只有0---0  0---0的情况需要再多一座桥。
#include<bits/stdc++.h>
using namespace std;
struct node{int l,r;} a[120000];
bool cmp(node a,node b) {return a.r<b.r;}
int main() {
	int n,l=0,ans=0;
	cin>>n>>n;
	for(int i=1;i<=n;i++) cin>>a[i].l>>a[i].r;
	sort(a,a+n+1,cmp);
	for(int i=1;i<=n;i++)	
		if(a[i].l>=l) {
			l=a[i].r;
			ans++;	
		}
	cout<<ans<<'\n';
	return 0;
}

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

main(){
  int count;
  cin >> count;
  int plus = count;
  int ans = 0 ;
  int mager_box = 0;
  int minor_box = 0;
  
  vector<int> board(count);
  for (int i = 0; i < count; i++){
  cin >> board.at(i);
  }
  
  //並び替え
  sort(board.begin(),board.end());
  
    //先に答えを計算してしまう
  for (int i = 0; i < count; i++){
    if(i == 0){
      ans -= board.at(i);
    }else if(i == count -1){
      ans += board.at(i);
    }else{
      ans += abs(board.at(i));
    }
  }
  cout << ans << endl;
  
  minor_box = board.at(0);
  mager_box = board.at(count - 1);
  
  //board.at(plus)以降は正の数
  for (int i = 0; i < count; i++){
  if(board.at(i) > 0){
    plus = i;
    break;
  }
  }
  
  //最大以外の正の数を統合
  for (int i = plus; i < count; i++){
  if(i == 0){
    continue;
  }
  if(i == count - 1){
    break;
  }
    cout << minor_box << " " << board.at(i)<< endl;
    minor_box -= board.at(i);
  }
  
  //最小以外の負の数を統合
  for (int i = 1; i < count; i++){
    
  if(i > plus - 1){
    break;
  }
  if(i == count - 1){
    break;
  }
    cout << mager_box << " " << board.at(i)<< endl;
    mager_box -= board.at(i);
  }
  
    cout << mager_box << " " << minor_box << endl;
  
  
  //for (int i = 0; i < count; i++){
  //cout << board.at(i);
  //}
  
}

Measured memory_bytes: 2304
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], m = tmp[1], x = tmp[2], y = tmp[3];
    int[] a = readln.split.to!(int[]);
    int[] b = readln.split.to!(int[]);
    a ~= x;
    b ~= y;
    writeln(a.reduce!max < b.reduce!min ? "No War" : "War");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

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

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

  for (int i = 1; i <= 9; i++)
  {
    for (int j = 1; j <= 9; j++)
    {
      if(i*j == n){
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    int n[3];
    cin>>n[0]>>n[1]>>n[2];
    sort(n,n+3);
    cout<<(n[0]==5&&n[1]==5&&n[2]==7?"YES":"NO")<<endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
using namespace std;

int main()
{
	int n; cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int count = 0;
	for (int i = 0; i < n; i++) {
		int minj = i;
		for (int j= i; j < n; j++) {
			if (a[j] < a[minj]) {
				minj = j;
				
			}
		}
		swap(a[i], a[minj]);
		if(i!=minj)count++;
	}
	for (int i = 0; i < n; i++) {
		cout << a[i];
		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
	cout << count << endl;
}




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

const int Nmax=200010;

int main() {
	int A,B;
	int mac=0;
	cin >> A >> B;
	mac = max(A+B, A-B);
	mac = max(mac,A*B);
	cout << mac << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for(int i = 0; i < a; i++)
#define arep(i, x) for(auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
    int n;
    cin >> n;
    string a;
    cin >> a;
    int ans = 0;
    int max = 0;
    rep(i, n) {
        if(a[i] == 'I')
            ans++;
        else
            ans--;
        if(max < ans) max = ans;
    }
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;


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

  map<pii,int> C;
  rep(i,n) rep(j,n) {
    if(i == j) continue;
    C[mp(x[i]-x[j],y[i]-y[j])]++;
  }

  int cnt = 0;
  for(auto c : C) {
    chmax(cnt, c.second);
  }

  cout << n-cnt << endl;
}


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

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

	int N = 0, K = 0, Q = 0;
	cin >> N >> K >> Q;

	vector<int> SANKASYA(N);
	for (int i = 0; i < N; i++)
	{
		SANKASYA[i] = K - Q;
	}

	vector<int> SeikaisyaList(Q);
	for (int i = 0; i < Q; i++)
	{
		int seikaisya = 0;
		cin >> seikaisya;
		seikaisya--;
		SANKASYA[seikaisya]++;
	}

	for (int i = 0; i < N; i++)
	{
		if (SANKASYA[i] <= 0)
			cout << "No";
		else
			cout << "Yes";
		cout << "\n";
	}
	return 0;
}

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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

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

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 1;

int A, B;

int main(){
	cin>>A>>B;
	for(int i=1; i<=max(A, B); i++){
		cout<<min(A, B);
	}cout<<endl;
	return 0;
}


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

const int INF = 1e+10;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    vector<set<int>> pls;
    pls.assign(26,set<int> ({INF}));
    for ( int i = 0; i < S.size(); ++i){
        pls[S[i]-'a'].insert(i);
    }
    
    int Q;
    cin >> Q;
    
    
    for ( int i = 0; i < Q; ++i){
        int type;
        cin >> type;
        if ( type == 1 ){
            int i;
            char c;
            cin >> i >> c;
            --i;
            char s = S[i];
            S[i] = c;
            pls[s-'a'].erase(i);
            pls[c-'a'].insert(i);
        } else {
            int l,r;
            cin >> l >> r;
            --l;
            int res = 0;
            for ( int j = 0; j < 26; ++j){
                if ( pls[j].empty() ) continue;
                int lid = *pls[j].lower_bound(l);
                int rid = *pls[j].lower_bound(r);
                if ( rid > lid ) ++res;
            }
            cout << res << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 24196
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
LL Q, A, B, C, D;
LL _max(LL x, LL y) { return x > y ? x : y; }
LL _min(LL x, LL y) { return x < y ? x : y; }
int main() {
	LL i, j, k;
	scanf("%lld", &Q);
	while(Q--){
		scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
		LL L = 0, R = A+B, ret = -1;
		k = (_max(A, B)-1)/(_min(A, B)+1)+1;
		while(L <= R){
			LL mid = L+R>>1;
			LL sa = A-mid/(k+1)*k-mid%(k+1), sb = B-mid/(k+1);
			if(sa*k >= sb){ ret = mid; L = mid+1; }
			else R = mid-1;
		}
		ret++;
		A -= ret/(k+1)*k+ret%(k+1); B -= ret/(k+1);
		LL l = ret, r = ret+B-A*k+1;
		for(i = C; i <= _min(D, l); i++) printf("%c", i%(k+1) ? 'A' : 'B');
		for(i = _max(C, l+1); i <= D; i++) printf("%c", (i-r)%(k+1) ? 'B' : 'A');
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256