akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define N 300005
int sum[N], cc[N], number[N];

void update(int *pen,int ind,int v) {
    while(ind<N) {
        pen[ind] += v;
        ind += ind&(-ind);
    }
}
int query(int *pen,int ind) {
    int ret = 0;
    while(ind>0) {
        ret += pen[ind];
        ind = ind&(ind-1);
    }
    return ret;
}
void solve() {
    int n;scanf("%d",&n);
    for(int i=0;i<n;++i) {
        int a;scanf("%d",&a);
        number[a]++;
    }
    int numType = 0;
    for(int i=1;i<=n;++i) {
        if(number[i]>0) {
            update(sum,number[i],number[i]);
            update(cc, number[i],1);
            ++numType;
        }
    }
    for(int k=1;k<=n;++k) {
        int l = 0,r = n/k,mid;
        while(l<r) {
            mid = (l+r+1)/2;
            int kCC = query(cc, mid);
            long long qsum = query(sum, mid);
            qsum += (long long)(numType-kCC)*mid;
            if(qsum>= mid*k) {
                l = mid;
            } else {
                r = mid-1;
            }
        }
        printf("%d ",l);
    }
    putchar('\n');
}
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<bitset>
#include<numeric>
using namespace std;
#define rep(i,n) for(int i=1;i<=(n);i++)
int main()
{
    int n,ans=0;
    cin>>n;
    rep(i,n) rep(k,n) rep(j,n)
    {
        ans+=gcd(gcd(i,k),j);
    }
    cout<<ans;
}

Measured memory_bytes: 3532
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <limits.h>

using namespace std;

#define MAX 100001
#define INF INT_MAX

#define WHITE 0
#define GRAY 1
#define BLACK 2

int num_v, num_e, start;

vector<pair<int, int> > adj[MAX];
int color[MAX];
int dis[MAX];

void dijkstra(){
	priority_queue<pair<int, int> > pq;
	for(int i = 0; i < MAX; i++){
		color[i] = WHITE;
		dis[i] = INF;
	}

	dis[start] = 0;
	pq.push(make_pair(0,start));
	color[start] = GRAY;

	while(!pq.empty()){
		pair<int, int> f = pq.top();
		pq.pop();
		int u = f.second;
		color[u] = BLACK;

		if(dis[u] < f.first*(-1)) continue;

		for(int i = 0; i < adj[u].size(); i++){
			int v = adj[u][i].first;
			if(color[v] == 2) continue;
			if(dis[v] > dis[u] + adj[u][i].second){
				dis[v] = dis[u] + adj[u][i].second;
				pq.push(make_pair(dis[v]*(-1), v));
				color[v] = 1;
			}
		}
	}
}

int main(){
	cin >> num_v >> num_e >> start;
	for(int i = 0;i < num_e;i++){
    int s = 0, t = 0, d = 0;
		cin >> s >> t >> d;
		adj[s].push_back(make_pair(t,d));
	}

	dijkstra();

	for(int i = 0;i < num_v;i++) (dis[i] == INF) ? cout << "INF" << endl : cout << dis[i] << endl;

	return 0;
}



Measured memory_bytes: 13380
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        
        if (a%2 == 0)
            System.out.println(a);
        else
            System.out.println(a*2);
    }
}


Measured memory_bytes: 35676
import java.util.Scanner;

public class Main {
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        int w = scanner.nextInt();
        int n = scanner.nextInt(); scanner.nextLine();
        int[] x = new int[30];
        for(int i = 0; i < w; i++)
            x[i] = i;

        for(int i = 0; i < n; i++){
            String s = scanner.nextLine();
            String[] a = s.split(",", 0);

            int tmp = x[Integer.parseInt(a[0]) - 1];
            x[Integer.parseInt(a[0]) - 1] = x[Integer.parseInt(a[1]) - 1];
            x[Integer.parseInt(a[1]) - 1] = tmp;

        }

        for(int i = 0; i < w; i++)
            System.out.println(x[i]+1);
    }
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  string s;
  cin >> s;
  int a = stoi(s.substr(0, 2));
  int b = stoi(s.substr(2, 2));

  if(a == 00 || b == 00) {
    if(0 < a && a <= 12) cout << "MMYY" << endl;
    else if(0 < b && b <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  } else if(a <= 12) {
    if(b <= 12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  } else if(12 < a) {
    if(b <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }

  return 0;
}


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

using namespace std;

using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

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

    int n;
    cin >> n;
    int ans = 0;
    for (int curN = 1; curN <= n; curN++) {
        int ans = 0;
        for (int x = 1; x * x <= curN; x++) {
            for (int y = 1; x * x + y * y <= curN; y++) {
                for (int z = 1; x * x + y * y + z * z + x * y + y * z + x * z <= curN; z++) {
                    if (curN == x * x + y * y + z * z + x * y + y * z + x * z)
                        ans++;
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3536
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	map<int,int>ma;
	rep(i,n){
		int a;cin>>a;ma[a]++;
	}
	if(ma.size()>2)cout<<"No"<<endl;
	else if(ma.size()==1){
		int t=ma.begin()->first;
		if(t==n-1||n>=2*t)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}else{
		auto a=ma.begin(),b=ma.begin();b++;
		if(b->first-a->second>0&&a->first-b->first==-1&&(n-a->second)>=(b->first-a->second)*2)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}







Measured memory_bytes: 4992
N = int(input())
nums = [0, 0, 0]
ans = 0
for i in range(N):
    s = input()
    ans += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        nums[0] += 1
    elif s[0] == 'B':
        nums[1] += 1
    elif s[-1] == 'A':
        nums[2] += 1
if nums[0] == 0:
    ans += min(nums[1:])
else:
    if sum(nums[1:]) > 0:
        ans += nums[0] + min(nums[1:])
    else:
        ans += nums[0] - 1
print(ans)

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

// const int inf=1e9+5;
int main () {
  int n;
  scanf("%d",&n);
  vector<int> dp(3);
  
  for(int k=0;k<n;k++)
  {
      vector<int> dp_n(3,0);
      vector<int> h(3);
      for(int &i:h)scanf("%d",&i);
      
      for(int i=0;i<3;i++){
          for(int j=0;j<3;j++){
              if(i!=j){
                  dp_n[j]=max(dp_n[j],dp[i]+h[j]);
              }
          }
      }
      dp=dp_n;
  }
  
  printf("%d",max({dp[0],dp[1],dp[2]}));
  
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int sum(int n,int m,int i,int k){
	int a,l;
	if(n == 0){
		if(m == 0){return 1;}
		else{return 0;}
	}
	else{
		l = k;
		for(a=i+1;a<10;a++){
			if(m-a>=0){k+=sum(n-1,m-a,a,l);}
		}
	}
	return k;
}
int main(){
	int low[10];
	int k,n,m,i;
	for(;;){
		scanf("%d %d",&n,&m);
		if(n == 0 && m == 0){break;}
		k = 0;
		for(i=0;i<10;i++){
			if(m-i>=0){k += sum(n-1,m-i,i,0);}
		}
		printf("%d\n",k);
	}
	return 0;
}

Measured memory_bytes: 0
package main;

import "fmt"

func bfs(field [][]bool, sx, sy, tx, ty int) string {
	var vec = [][]int{{1, 0}, {-1, 0}, {0, 1}, {0, -1}}

	x := make([]int, 0)
	y := make([]int, 0)

	x = append(x, sx)
	y = append(y, sy)

	checked := make([][]int, 1000 * 2 + 3)
	GETA := 1001

	for i := 0; i <= 1000 * 2 + 2; i++ {
		checked[i] = make([]int, 1000 * 2 + 3)
		for j := 0; j < len(field[i]); j++ {
			if field[i][j] {
				checked[i][j] = 6
			}
		}

	}
	checked[sy + GETA][sx + GETA] = 5
	checked[ty + GETA][tx + GETA] = 0

	func() {
		for i := 0; i < len(x); i++ {
			for k, v := range vec {
				nx := x[i] + v[0]
				ny := y[i] + v[1]
				if !(-GETA <= nx && nx <= GETA && -GETA <= ny &&ny <= GETA) {
					continue
				}
				if checked[ny + GETA][nx + GETA] > 0 {
					continue
				}

				checked[ny + GETA][nx + GETA] = k + 1
				if ny == ty && nx == tx {
					return
				}
				x = append(x, nx)
				y = append(y, ny)
			}
		}
	}()
	cx := tx
	cy := ty
	ans := ""
	for {
		k := checked[cy + GETA][cx + GETA]

		if k == 1 {
			ans += "R"
			cx += -1
		} else if k == 2 {
			ans += "L"
			cx += +1
		} else if k == 3 {
			ans += "U"
			cy += -1
		} else if k == 4 {
			ans += "D"
			cy += 1
		} else if k == 5 {
			break
		} else {
			panic(k)
		}
		field[cy + GETA][cx + GETA] = true
	}
	return ans
}

func main() {
	var sx, sy, tx, ty int
	fmt.Scan(&sx, &sy, &tx, &ty)
	field := make([][]bool, 1000 * 2 + 3)
	for i := 0; i < len(field); i++ {
		field[i] = make([]bool, 1000 * 2 + 3)
	}
	ans := ""
	ans += bfs(field, sx, sy, tx, ty)
	ans += bfs(field, tx, ty, sx, sy)
	ans += bfs(field, sx, sy, tx, ty)
	ans += bfs(field, tx, ty, sx, sy)

	fmt.Println(ans)

}


Measured memory_bytes: 239872
#include <iostream>
#include <string>

bool judge(std::string const& S) {
  static std::string const T("keyence");

  if (S.substr(0, 7) == T) return true;
  if (S.substr(S.size()-7, 7) == T) return true;

  size_t i=0;

  for (; S[i] == T[i]; i++);

  std::cerr << i << std::endl;

  if (i==0) return false;

  size_t j=0;
  for (; S[S.size()-j-1] == T[7-j-1]; j++);

  std::cerr << j << std::endl;

  return i+j>=7;
}

int main() {
  std::string S;
  std::cin >> S;

  std::cout << (judge(S) ? "YES" : "NO") << std::endl;

  return 0;
}


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

int main()
{
	long long a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	
	if(v<=w)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	if(t*(v-w)>=llabs(b-a))
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

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


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

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

	bool flag = false;
	for (int i = 0; i < n - m + 1; i++) {
		for (int j = 0; j < n - m + 1; j++) {
			if (a[i].substr(j, m) == b[0]) {

				if (m == 1) {
					cout << "Yes" << endl;
					return 0;
				}

				for (int ii = 0; ii < m-1; ii++) {
					if (a[i + ii + 1].substr(j, m) != b[ii + 1]) break;
					else if (ii == m - 2) {
						cout << "Yes" << endl;
						return 0;
					}
				}
			}
		}
	}
	
	cout << "No" << endl;
	return 0;
}

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
    	cin>>v[i];
	}
	int dp[n];
	dp[0]=0;
	dp[1]=abs(v[1]-v[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(abs(v[i]-v[i-1])+dp[i-1],abs(v[i]-v[i-2])+dp[i-2]);
	}
	cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 4004
// Created by SAMAN on ۷/۳۱/۲۰۲۰ م..
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops") 
#include <iostream>
#include <algorithm>
#include <map>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> 
#include <vector>
#include <set>
#include <fstream>
#include <cstdlib>
#include <iterator>
#include <cmath>
#include <ctime>
#include <iomanip>
//#warning not there YET
//#error hello
#define lint long long int
#define endl '\n'
#define kill(x) return cout<<x<<'\n', 0;
#define debug(x) cout << #x << " : " << x << '\n'
#define pb push_back
#define ppb pop_back
#define f first
#define se second
#define _ri [i<<1|1]
#define _le [i<<1]  
//# define h m();
typedef long long  ll;
typedef long double ld;

using namespace std;

string s;
ll a,ab,abc,t;
const int mod = 1e9 + 7;
int m(){

}
int main(){
	//freopen("kn.txt","r",stdin);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	cin >> s;
	int n = s.size();
	t = 1;
	for(int i = 0;i < n;i++){
		if(s[i] == 'A' )
			a += t;
		else if(s[i] == 'B' )
			ab += a;
		else if(s[i] == 'C')
			abc += ab;
		if(s[i] == '?'){
			abc *= 3;
			abc += ab;
			ab *= 3;
			ab += a;
			a *= 3;
			a += t;
			t  *= 3;
		}
			a %= mod;
	ab %= mod;
	abc %= mod;
	t %= mod;
	}
	cout<<abc;
	return 0;
}


Measured memory_bytes: 3736
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        x: usize,
        y: usize
    }

    let mut yes = false;
    for i in 0..x + 1 {
        let kame = i;
        let turu = x - i;

        let ashi = kame * 4 + turu * 2;
        if ashi == y {
            yes = true;
        }
    }

    if yes {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2260
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ll long long
using namespace std;

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  cout << a[0] + a[1] << "\n";
}

Measured memory_bytes: 3560
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int r, g, b;
	cin >> r >> g >> b;
	int c = r * 100 + g * 10 + b;
	cout << (c % 4 == 0 ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    rep(i, n) {
        cout << 'x';
    }

    cout << endl;
    re0;
}

Measured memory_bytes: 256
#include <stdio.h>

int mks(int d) {
  int i, s = 0;
  for (i = 0; i < 600; i = i + d)
    s += d * i * i;

  return s;
}

int main(void) {
  int d, s;
  while (scanf("%d", &d) != EOF) {
    s = mks(d);
    printf("%d\n", s);
  }

  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b, c; cin >> a >> b >> c;
    if((a*100 + b*10 + c) % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var n,z,w int
  fmt.Scan(&n,&z,&w)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    fmt.Scan(&a[i])
  }
  if n == 1 {
    fmt.Println(abs(a[0]-w))
  } else {
    fmt.Println(max(abs(a[n-1]-w),abs(a[n-1]-a[n-2])))
  }
}
func abs(n int) int {
  if n < 0 { return -n }
  return n
}
func max(n,m int) int {
  if n > m { return n }
  return m
}

Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

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

    std::vector<int> a(m);
    for (int i = 0; i < m; i++) {
        std::cin >> a[i];
    }

    std::vector<int> num_matches = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

    std::vector<int> dp_digits(n + 1, 0);
    for (int i = 0; i < n; i++) {
        for (auto num : a) {
            if (i + num_matches[num] > n) {
                continue;
            }

            dp_digits[i + num_matches[num]] = std::max(dp_digits[i + num_matches[num]], dp_digits[i] + 1);
        }
    }

    std::vector<std::string> dp(n + 1, "");

    for (auto num : a) {
        if (num_matches[num] > n) {
            continue;
        }

        dp[num_matches[num]] = std::max(dp[num_matches[num]], std::to_string(num));
    }

    for (int i = 0; i < n; i++) {
        if (dp[i] == "") {
            continue;
        }

        for (auto num : a) {
            if (i + num_matches[num] > n) {
                continue;
            }

            if (dp[i + num_matches[num]].length() <= dp[i].length()) {
                dp[i + num_matches[num]] = dp[i] + std::to_string(num);
            } else if (dp[i + num_matches[num]].length() == dp[i].length() + 1) {
                dp[i + num_matches[num]] = std::max(dp[i + num_matches[num]], dp[i] + std::to_string(num));
            }
        }
    }

    std::cout << dp[n] << std::endl;
}


Measured memory_bytes: 33024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int sum = A + B;

		if(sum >= 10){
			System.out.println("error");
		}else{
			System.out.println(sum);
		}


	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

long max(long A, long B, long C) {
    return max(A, max(B, C));
}

long min(long A, long B, long C) {
    return min(A, min(B, C));
}

int main() {
    long ans = 1e18;
    long H, W;
    cin >> H >> W;
    long A, B, C;
    for (long x = 1; x < W; x++) {
        A = H * x;
        B = H * ((W - x) / 2);
        C = H * (W - x - ((W - x) / 2));
        ans = min(ans, max(A, B, C) - min(A, B, C));
        B = (W - x) * (H / 2);
        C = (W - x) * (H - (H / 2));
        ans = min(ans, max(A, B, C) - min(A, B, C));
    }
    
    for (long y = 1; y < H; y++) {
        A = W * y;
        B = W * ((H - y) / 2);
        C = W * (H - y - ((H - y) / 2));
        ans = min(ans, max(A, B, C) - min(A, B, C));
        B = (H - y) * (W / 2);
        C = (H - y) * (W - (W / 2));
        ans = min(ans, max(A, B, C) - min(A, B, C));
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807
signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0;
  std::cin >> x;
  std::vector<int> v(x);
  rep(i,x){
    std::cin >> v[i];
    y += v[i];
  }
  rep(i,x){
        n=i;
    if(z<y/2)z+=v[i];
    else{
      n--;
      break;
    }

  }
  w= ((y-z>z)?y-z-z:z-y+z);
  z-=v[n];
    m=((y-z>z)?y-z-z:z-y+z);
  printf("%d\n",((w<m)?w:m));
}

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <math.h>
#define ll long long int
using namespace std;

ll mod = 998244353;

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

ll modInverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

ll arr[3005];
ll dp[3005][3005];
bool vis[3005][3005];

ll solve(int m,int s,int e)
{
    if(vis[s][e])
        return dp[s][e];
    vis[s][e] = true;
    if(s==e)
    {
        dp[s][e] = arr[s];
        return arr[s];
    }
    m = (m+1)%2;
    if(m%2==1)
        dp[s][e] = max(arr[s] - solve(m,s+1,e) , arr[e] - solve(m,s,e-1));
    else
        dp[s][e] = max(arr[s] - solve(m,s+1,e) , arr[e] - solve(m,s,e-1));
    return dp[s][e];
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    memset(vis,false,sizeof(vis));
    for(int i=1;i<=n;i++)
        cin >> arr[i];
    cout << solve(0,1,n);
}


Measured memory_bytes: 78592
#include<iostream>   
#include<cstdio>  
#include<algorithm>
#include<queue>
#include<map>
#include<string>
using namespace std;
const int row = 3;
const int maxx = 9;

struct Puzzle {
	int f[maxx];
	int space;
	string path;
	bool operator < (const Puzzle &p) const {
		for (int i = 0; i < maxx; i++) {
			if (f[i] != p.f[i])
				return f[i] > p.f[i];
		}
		return false;
	}
};

const int dx[4] = { -1, 0, 1, 0 };
const int dy[4] = { 0, -1, 0 ,1 };
const char dir[4] = { 'u','l','d','r' };

bool isTarget(Puzzle p) {
	for (int i = 0; i < maxx; i++)
		if (p.f[i] != (i + 1))
			return false;
	return true;
}


string bfs(Puzzle s) {
	queue<Puzzle> Q;
	map<Puzzle, bool> V;
	Puzzle u, v;
	s.path = "";
	Q.push(s);
	V[s] = true;

	while (!Q.empty()) {
		u = Q.front(); Q.pop();
		if (isTarget(u))
			return u.path;
		int sx = u.space / row;
		int sy = u.space % row;
		for (int r = 0; r < 4; r++) {
			int tx = sx + dx[r];
			int ty = sy + dy[r];

			if (tx < 0 || ty < 0 || tx >= row || ty >= row)
				continue;
			v = u;
			swap(v.f[u.space], v.f[tx * row + ty]);
			v.space = tx * row + ty;
			if (!V[v]) {
				V[v] = true;
				v.path += dir[r];
				Q.push(v);
			}
		}
	}
	return "unsolveable";
}
int main()
{
	Puzzle in;
	for (int i = 0; i < maxx; i++) {
		cin >> in.f[i];
		if (in.f[i] == 0) {
			in.f[i] = maxx;
			in.space = i;
		}
	}
	string ans = bfs(in);
	printf("%d\n", ans.size());
	return 0;
}


Measured memory_bytes: 30612
#include <stdio.h>
#include <string.h>

const int inf=1<<30;
int memo[1<<16][16], t[17][17], n;

#define min(x, y) ((x)<(y)?(x):(y))

int func(int S, int k)
{
    int i, j, res=memo[S][k];
    if (S==(1<<n)-1) return 0;
    if (res) return res;

    res=inf;
    for(i=0;i<n;++i) if (!(S&(1<<i))) {
        res=min(res, func(S|(1<<i), i)+t[i+1][0]);
        for(j=0;j<n;++j) if (j!=i && (S&(1<<j)))
            res=min(res, func(S|(1<<i), i)+t[i+1][j+1]);
    }
    return memo[S][k]=res;
}

int main(void)
{
    while (scanf("%d", &n), n) {
        int i, j, res;
        for(i=1;i<=n;++i) for(j=0;j<=n;++j) scanf("%d", &t[i][j]);
        res=inf;
        memset(memo, 0, sizeof(memo));
        res=min(res, func(0, 0));
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 4704
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cctype>
using namespace std;

int n;
string str[53];
int cnt[53][30];
int res[30];

int main(){
    cin>>n;
    memset(cnt,0,sizeof(cnt));
    for(int i=0;i<=26;i++) res[i]=99999;
    for(int i=0;i<n;i++){
        cin>>str[i];
        for(int j=0;j<str[i].size();j++){
            cnt[i][str[i][j]-'a']++;
        }
    }
    for(int j=0;j<26;j++){
        for(int i=0;i<n;i++){
            res[j]=min(res[j],cnt[i][j]);
        }
        if(res[j]) while(res[j]) { printf("%c",'a'+j);res[j]--;};
    }
    cout <<endl;
    
    return 0;
}


Measured memory_bytes: 256
import math
import sys
from collections import deque
import copy
def mi() : return map(int,input().split())
a,b=mi()
l=[list(input()) for _ in range(a)]
count=0
for i in range(a):
  for _ in range(b):
    if l[i][_]==".":
      count+=1
l[0][0]=1
q=deque([[0,0]])
while q:
  x,y=q.popleft()
  if x==a-1 and y==b-1:
    print(count-l[x][y])
    sys.exit()
  for e,f in [[0,1],[0,-1],[1,0],[-1,0]]:
    if 0<=x+e<a and 0<=y+f<b and l[x+e][f+y]==".":
      l[x+e][f+y]=l[x][y]+1
      q.append([x+e,y+f])
print(-1)

Measured memory_bytes: 41584
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e6 + 7;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int f = 0;
	for (int i = 1; i <= 1000000; i++)
	{
		if (a * i % b == c)f = 1;
	}
	if (f)cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

using namespace std;

int main(){
  double a,b,x; cin >> a >> b >> x;
  double radian=0;
  double ans=0;
  if(2*x<=a*a*b){
    ans=atan2(a*b*b,2*x)*(180/M_PI);
    cout << fixed << setprecision(10);
    cout << (double)ans << endl;
  }
  else
  {
    ans=atan2(2*b*a*a-2*x,a*a*a)*(180/M_PI);
    cout << fixed << setprecision(10);
    cout << (double)ans << endl;
  }
  
}


Measured memory_bytes: 256
// Problem : C - Repsept
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define Sort(a)	sort(a.begin(),a.end())
#define rev(a)	reverse(a.begin(),a.end())
#define all(a)	(a).begin(),(a).end()
#define vll vector<long long int>
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 2000005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli power(lli a,lli b,lli m){if(b==0)	return 1;if(b==1)	return a%m;lli res=1;a=a%m;while(b){if(b&1){res=(res*a)%m;}a=((a%m)*(a%m))%m;b>>=1;}return res;}
lli Ceil(lli a,lli b){lli res=a/b;if(a%b!=0)	res++;return res;}

template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

lli dxx[]={1,1,0,-1,-1,-1,0,1};
lli dyy[]={0,1,1,1,0,-1,-1,-1};
lli dx[]={1,0,-1,0};
lli dy[]={0,1,0,-1};

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> n;
    str="";
    m=0;
    for(i=1;i<MAX;i++){
    	m=m*10+7;
    	m%=n;
    	if(m==0){
    		cout << i << endl;
    		return;
    	}
    }
    cout << -1 << endl;
    
    
}















int main()
{
	long long int t=1,c=1;
	// scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

Measured memory_bytes: 3600
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int, int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[] = { 1, 0, -1, 0 }, DY[] = { 0, -1, 0, 1 };

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

	int cnt[26] = { 0 };
	int ans[26] = { 0 };

	string anss = "AIDUNYAN";
	REP(i, anss.size()){
		ans[anss[i]-'A']++;
	}

	cnt[str[0] - 'A']++;
	int i = 0, j = 0;
	while (true){
		if (j == str.size() - 1){
			break;
		}

		if (i + 8 == j){
			cnt[str[i]-'A']--;
			i++;
		}
		else{
			j++;
			cnt[str[j]-'A']++;
		}

		bool flag = true;
		REP(k, 26){
			if (cnt[k] != ans[k]) flag = false;
		}
		if (flag){
			REP(k, 26){
				cnt[k] = 0;
			}
			REP(k, anss.size()){
				str[i + k] = anss[k];
			}
			str[i + 2] = 'Z';
			i = j + 1;
		}
	}

	cout << str << endl;
}

Measured memory_bytes: 1192
N = int(input())
S = ['0'] * N
for i in range(N):
    S[i] = input()
import collections
c = collections.Counter(S)
li = list(c.values())
ca = c.keys()
li.sort()
max = li[-1]
from collections import deque
lia = deque()
for i in ca:
    if c[i] == max:
        lia.append(i)
liaa = list(lia)
liaa.sort()
n = len(lia)
for i in range(n):
    print(liaa[i])

Measured memory_bytes: 36580
#include<iostream>

using namespace std;

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

    int ans = 1;
    bool asc = N == 1 ? false : A[0] < A[1];
    bool des = N == 1 ? false : A[0] > A[1];
    for (int i = 2; i < N; ++i) {
        asc = asc || A[i - 1] < A[i];
        des = des || A[i - 1] > A[i];
        if (asc && des) {
            asc = false;
            des = false;
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long ll;

int main() {
	string str; getline(cin, str);
	for (int i = 0; i < str.size(); ++i) {
		char c = str[i];
		if ('a' <= c && c <= 'z') cout << (char)(c-'a'+'A');
		else if ('A' <= c && c <= 'Z') cout << (char)(c-'A'+'a');
		else cout << c;
	}
	cout << endl;
}

Measured memory_bytes: 1172
#include <stdio.h>

using namespace std;

int main(){
	int n,taro_point = 0,hanako_point = 0,j;
	char taro_card[101],hanako_card[101];
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%s %s",taro_card,hanako_card);
		for(j = 0; taro_card[j] != '\0' && hanako_card[j] != '\0' && taro_card[j] == hanako_card[j];j++);
		if(taro_card[j] == '\0'){
			if(hanako_card[j] == '\0'){
				taro_point += 1;
				hanako_point += 1;
			}else{
				hanako_point += 3;
			}
		}else if(hanako_card[j] == '\0'){
			taro_point += 3;
		}else if(hanako_card[j] > taro_card[j]){
			hanako_point += 3;
		}else{
			taro_point += 3;
		}
	}
	printf("%d %d\n",taro_point,hanako_point);
}


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

int main() {
	int A, B, C, D;
cin>>A>>B>>C>>D;
int x=max(A,C) ;
int y=min(B,D) ;
if((y-x)<=0 ) {
cout<<0 ;
} else {
cout<<y-x;
} 
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var NL = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NL[0];
        var L = NL[1];
        var A = new int[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = L + i;
        }
        var a = 0;
        var m = int.MaxValue;
        for (int i = 0; i < N; i++)
        {
            if(m>Abs(A[i]))
            {
                m = Abs(A[i]);
                a = i;
            }
        }
        WriteLine(A.Sum()-A[a]);
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int n;
vector<int> a,b;

main(){
  cin>>n;
  rep(i,n){
    int c;
    cin>>c;
    if(c>0) a.PB(c);
    else b.PB(c);
  }

  sort(all(a));
  sort(all(b));

  if(a.size()&&b.empty()){
    int res=0;

    int r=a[0];
    vector<P> ans;
    FOR(i,1,a.size()-1){
      ans.PB(P(r,a[i]));
      r-=a[i];
    }
    ans.PB(P(a[a.size()-1],r));
    r=a[a.size()-1]-r;
    cout<<r<<endl;
    rep(i,ans.size()){
      cout<<ans[i].F<<' '<<ans[i].S<<endl;
    }
  }else if(a.empty()&&b.size()){
    int res=0;
    reverse(all(b));
    int r=b[0];
    vector<P> ans;
    FOR(i,1,b.size()){
      ans.PB(P(r,b[i]));
      r-=b[i];
    }

    cout<<r<<endl;
    rep(i,ans.size()){
      cout<<ans[i].F<<' '<<ans[i].S<<endl;
    }
  }else{
    int r=a[a.size()-1];
    vector<P> ans;
    FOR(i,1,b.size()){
      ans.PB(P(r,b[i]));
      r-=b[i];
    }
    int s=b[0];
    rep(i,a.size()-1){
      ans.PB(P(s,a[i]));
      s-=a[i];
    }
    ans.PB(P(r,s));
    r-=s;
    cout<<r<<endl;
    rep(i,ans.size()){
      cout<<ans[i].F<<' '<<ans[i].S<<endl;
    }
  }

}



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

// 素因数分解unordered_map版　O(√n)
template <typename T>
unordered_map<T, T> pf_um(T n) {
    unordered_map<T, T> res;
    for (long long i = 2; i * i <= n; i++)
        while (n % i == 0) res[i]++, n /= i;
    if (n != 1) res[n]++;
    return res;
}

lint solve(lint k) {
    lint ok = 1, no = 1e9;
    while (abs(ok - no) > 1) {
        lint mid = (ok + no) / 2;
        if (k - mid * (mid - 1) / 2 >= mid) {
            ok = mid;
        } else {
            no = mid;
        }
    }
    return ok;
}

int main() {
    lint n;
    cin >> n;
    auto pf = pf_um(n);
    lint ans = 0;
    for (auto e : pf) {
        ans += solve(e.second);
    }
    cout << ans << endl;
}

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

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

	ll n;
	cin >> n;
	ll a[n];
	ll res = 0;
	for(ll i=0; i<n; i++){
		cin >> a[i];
		res += a[i]-1;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3668
N = int(input())
count = 0
if int(N/2)-N/2 == 0:
    for i in range(1,int(N/2)):
        if int(N/i)-N/i == 0:
            count += int(N/i)-1
        else:
            count += int(N/i)
else:
    for i in range(1,int(N/2)+1):
        if int(N/i)-N/i == 0:
            count += int(N/i)-1
        else:
            count += int(N/i)

count += int(N/2)
print(count)

Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>


using namespace std;

using i32 = int;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;

#define rep(i, n) for (u32 i = 0; i < (n); ++i)
#define repr(i, n) for (u32 i = ((n)-1); i >= 0; --i)

struct task {
	u32 cost;
	u32 deadline;
};

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

	u32 N;
	cin >> N;
	vector<task> tasks(N);
	rep(i, N) {
		cin >> tasks[i].cost >> tasks[i].deadline;
	}
	sort(tasks.begin(), tasks.end(), [](auto&a, auto &b) {
		return a.deadline < b.deadline;
	});

	u32 current = 0;
	rep(i, N) {
		current += tasks[i].cost;
		if (tasks[i].deadline < current) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");

	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
    int x,y;
    scanf("%d %d",&x,&y);
  if(x>y){
    printf("a > b\n");
    }else if(x<y){
    printf("a < b\n");
    }else if(x==y){
    printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b;
    cin>>a>>b;
    ll temp = max(a+b,a-b);
    ll ans = max(temp,a*b);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

bool left(const std::string S, const std::vector<char> ts, const std::vector<char> ds, int pos)
{
  // std::cout << pos << std::endl;

  if (pos < 0)
  {
    return true;
  }

  if (pos >= S.size())
  {
    return false;
  }

  for (int i = 0; i < ts.size(); i++)
  {
    if (S[pos] == ts[i])
    {
      pos += (ds[i] == 'L' ? -1 : +1);
    }

    // std::cout << pos << std::endl;

    if (pos < 0)
    {
      return true;
    }

    if (pos >= S.size())
    {
      return false;
    }
  }

  return false;
}

bool right(const std::string S, const std::vector<char> ts, const std::vector<char> ds, int pos)
{
  // std::cout << pos << std::endl;

  if (pos < 0)
  {
    return false;
  }

  if (pos >= S.size())
  {
    return true;
  }

  for (int i = 0; i < ts.size(); i++)
  {
    if (S[pos] == ts[i])
    {
      pos += (ds[i] == 'L' ? -1 : +1);
    }

    // std::cout << pos << std::endl;

    if (pos < 0)
    {
      return false;
    }

    if (pos >= S.size())
    {
      return true;
    }
  }

  return false;
}

int main()
{
  int N, Q;
  std::string S;

  std::cin >> N >> Q >> S;

  std::vector<char> ts(Q, 0), ds(Q, 0);

  for (int i = 0; i < Q; i++)
  {
    std::cin >> ts[i] >> ds[i];
  }

  // for (int i = 0; i < S.size(); i++)
  // {
  //   std::cout << (left(S, ts, ds, i) ? 'x' : 'o') << " " << (right(S, ts, ds, i) ? 'x' : 'o') << std::endl;
  // }

  int lm = -1, rm = N;

  for (int l = -1, r = N; r - l > 1;)
  {
    int mid = l + (r - l) / 2;

    if (left(S, ts, ds, mid))
    {
      l = mid;
    }
    else
    {
      r = mid;
    }

    lm = l;
  }

  for (int l = -1, r = N; l + 1 != r;)
  {
    int mid = l + (r - l) / 2;

    if (right(S, ts, ds, mid))
    {
      r = mid;
    }
    else
    {
      l = mid;
    }

    rm = r;
  }

  std::cout << rm - lm - 1 << std::endl;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

void solve(long long N){
    double n=RUP(N,2);
    double ans=n/(double)N;
    cout << fixed << setprecision(10) << ans << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007 
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

ll po(ll x,ll n){
    if(n==0) return 1;
    else if(n%2 == 0) return po((x*x)%MOD,n/2);
    else return (x*po((x*x)%MOD,(n-1)/2))%MOD;
}

void solve(){
    ll r,g,rc,gc,cc;
    cin>>r>>g>>rc>>gc>>cc;
    ll cnt = 0;
    ll sum = 0;
    pair< ll, ll> p[rc+gc+cc];
    for( ll i=0;i<rc;i++ ){
        cin>>p[i].ff;
        p[i].ss = 1;
    }
    for( ll i=rc;i<rc+gc;i++ ){
        cin>>p[i].ff;
        p[i].ss = 2;
    }
    for( ll i=rc+gc;i<rc+gc+cc;i++ ){
        cin>>p[i].ff;
        p[i].ss = 0;
    }
    
    sort( p, p+rc+gc+cc );
    for( ll i=rc+gc+cc - 1;i>=0;i-- ){
        //cout<<i<<endl;
        if( p[i].ss == 1 && r == 0 ) continue;
        if( p[i].ss == 2 && g == 0 ) continue;
        sum += p[i].ff;
        if( p[i].ss == 1 ) r--;
        else if( p[i].ss == 2 ) g--;
        else cnt++;
        //cout<<rc<<" "<<gc<<endl;
        if( cnt == r+g ) break;
    }
    cout<<sum<<endl;
}

int main(){
    FAST;
    //init();
    ll t = 1;
    //cin>>t;
    while( t-- ) solve();
    return 0;
} 

Measured memory_bytes: 4992
n = raw_input()
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a%b)

def g(ais): return reduce(gcd, ais) == 1

def f(ais):
	seen = set()
	for ai in ais:
		factor =2
		oi = ai
		while(ai != 1 and factor * factor <= oi):
			if ai % factor == 0:
				if factor in seen:
					return False
				while(ai % factor == 0):
					ai /= factor
				seen.add(factor)
			factor +=1
		if ai != 1:
			if ai in seen: return False
			seen.add(ai) 
	return True

ais = map(int, raw_input().split())

if f(ais):
	print 'pairwise coprime'
elif g(ais):
	print 'setwise coprime'
else:
	print 'not coprime'

Measured memory_bytes: 158160