akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

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

	for (int i = n - 1; i >= 0; i--) {
		if (i) cout << a[i] << " ";
		else cout << a[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3012
N, M = map(int, input().split())
shops = list(list(map(int, input().split())) for _ in range(N))
shops.sort()
ans = 0
for value, count in shops:
    tmp_M = max(M - count , 0)
    ans += (M - tmp_M) * value
    M = tmp_M
    if M == 0:
        break
print(ans)


Measured memory_bytes: 27752
import math

A = list(map(int,input().split()))
a = A[0]
b = A[1]
h = A[2]
m = A[3]

c = (h - 11 / 60 * m) / 6 * math.pi

C = math.sqrt(a**2 + b**2 - 2*a*b* math.cos(c))
print(C)


Measured memory_bytes: 9336
n,l = map(int,input().split())
ls=[]
for i in range(n):
    ls.append(i+l)
s = sum(ls)

cnt = 10**9
ans = 0
for i in range(n):
    a = s-ls[i]
    if abs(s-a)<cnt:
        cnt = abs(s-a)
        ans = a

print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 5999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

int s[114514];
int main() {
	ll n,now = 0,ans = 0;
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		if (a == 0) {
			ans += now / 2;
			now = 0;
		}
		else now += a;
	}
	ans += now / 2;

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	int n; cin >> n;
	cout << (1000 - n % 1000) % 1000;

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
int main(){
  ll H,W,ans=0,c[10][10];
  cin>>H>>W;
  rep(i,10) rep(j,10) cin>>c[i][j];
  rep(k,10) rep(i,10) rep(j,10) c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
  rep(i,H) rep(j,W){
    ll a;cin>>a;
    if(a>=0) ans+=c[a][1];
  }
  cout<<ans<<endl;
}

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

int main(void) {
    int N;
    cin >> N;
    vector<long long> x(N), y(N);
    vector<long long> h(N);
    int H_candidate;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] >= 1) H_candidate = i;
    }

    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            bool flag = true;
            long long H = h[H_candidate] + abs(x[H_candidate] - cx) +
                          abs(y[H_candidate] - cy);
            for (int i = 0; i < N; i++) {
                if (h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0LL)) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
queue<int> q;
vector<int> ga[2001];
int dist[2001][2001];
pair<int,int> e[2001];
int n,k;
void BFS(int id){
	q.push(id);
	dist[id][id]=0;
	while(!q.empty()){
		int cur=q.front();
		q.pop();
		for(int i=0;i<ga[cur].size();i++)
		{
			int nxt=ga[cur][i];
			if(dist[id][nxt]>1e9){
				dist[id][nxt]=dist[id][cur]+1;
				q.push(nxt);
			}
		}
	}
} 
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	for(int i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		ga[a].push_back(b);
		ga[b].push_back(a);
		e[i]=make_pair(a,b);
	}
	memset(dist,0x3f,sizeof(dist));
	for(int i=1;i<=n;i++)
		BFS(i);
	int res=1e9;
	if(k%2==0){
		for(int i=1;i<=n;i++){
			int ans=0;
			for(int j=1;j<=n;j++){
				if(dist[i][j]>k/2)
					ans++;
			}
			res=min(res,ans);
		}
	}
	if(k%2==1){
		for(int i=1;i<n;i++){
			int ans=0;
			for(int j=1;j<=n;j++){
				if(dist[e[i].first][j]>k/2&&dist[e[i].second][j]>k/2)
					ans++;
			}
			res=min(res,ans);
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 16000
package main
 
import (
	"fmt"
)
 
func main() {
 
	var A,B int
	fmt.Scanf("%d %d\n", &A, &B)

  var c int = -1
  for i := 0; i < 3000; i ++ {
      if int(float64(i) * 0.08) != A {
        continue
      }
     if int(float64(i) * 0.1) != B {
        continue
     }
		c = i
    	break
    }
  fmt.Println(c)
 
}

Measured memory_bytes: 512
import java.util.Scanner;
class Main{
  public static void main(String[] args){
  	
    Scanner scan = new Scanner(System.in);
    
    int n = scan.nextInt();
    int k = scan.nextInt();
    
    String res = Integer.toString(n, k);
      
    System.out.println(res.length());
 
  }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll a[100005],b[100005];
priority_queue<ll>que;
ll sum_minus,sum_plus;
int ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
	for(int i=1;i<=n;i++){
		if(a[i] < b[i]){
			sum_minus += b[i]-a[i];
			ans++;
		}
		else if(a[i] > b[i]){
			sum_plus += a[i]-b[i];
			que.push(a[i]-b[i]);
		}
	}
	if(sum_minus > sum_plus){
		//can not construct C_i
		puts("-1");
		return 0;
	}
	if(sum_minus == 0){
		//already OK
		puts("0");
		return 0;
	}
	while(!que.empty()){
		ll x = que.top(); que.pop();
		sum_minus -= x;
		ans++;
		if(sum_minus <= 0){
			printf("%d\n",ans);
			return 0;
		}
	}
	assert(0);
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

struct UnionFind{
	vector<int> par,rnk;

	UnionFind(int n) : par(n), rnk(n,0){
		REP(i,n){
			par[i] = i;
		}
	}
	
	int find(int x){
		if(par[x]==x){
			return x;
		}else{
			return par[x]=find(par[x]);
		}
	}
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x==y) return;
		if(rnk[x] < rnk[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rnk[x]==rnk[y]) rnk[x]++;
		}
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
};

int main(){
	int n,m;
	cin >> n >> m;
	UnionFind uf(n);
	REP(i,m){
		int x,y,z;
		cin >> x >> y >> z;
		uf.unite(x-1, y-1);
	}
	
	set<int> s;
	REP(i,n){
		s.insert(uf.find(i));
	}
	
	int ans = s.size();
	
	cout << ans << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 8744
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
  ll n;cin>>n;
  vp h(n);
  rep(i,0,n){
    cin>>h[i].first;
    h[i].second=i;
  }
  sort(h.begin(),h.end());
  vp x(n);
  rep(i,0,n){
    x[h[i].second]=make_pair(h[i].first,i);
  }
  rep(i,0,n){
    if(x[i].second+1<=n/2){
      cout<<h[n/2].first<<endl;
    }
    else{
      cout<<h[n/2-1].first<<endl;
    }
  }
}








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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

struct SegmentTree{
    SegmentTree(int n){
        size = 1;
        while(size < n){
            size *= 2;
        }
    }
    void propagate(int k){
        if(data2[k] != 0){
            data[k] += data2[k];
            if(k < size){
                data2[k*2] += data2[k];
                data2[k*2+1] += data2[k];
            }
            data2[k] = 0;
        }
    }
    void update(int l, int r, ll x){
        _update(1, 0, size, l, r, x);
    }
    inline void _update(int k, int a, int b, int l, int r, ll x){
        propagate(k);

        if(b <= l || r <= a){return;}
        if(l <= a && b <= r){
            data2[k] = x;
            propagate(k);
        }else{
            int mid = (a + b) / 2;
            _update(k * 2, a, mid, l, r, x);
            _update(k * 2 + 1, mid, b, l, r, x);
            data[k] = std::min(data[k*2], data[k*2+1]);
        }
    }
    ll minimum(int l, int r){
        return _minimum(1, 0, size, l, r);
    }
    inline ll _minimum(int k, int a, int b, int l, int r){
        propagate(k);

        if(b <= l || r <= a){return D;}
        if(l <= a && b <= r){return data[k];}
        int mid = (a + b) / 2;
        ll vl = _minimum(k * 2, a, mid, l, r),
            vr = _minimum(k * 2 + 1, mid, b, l, r);
        return std::min(vl, vr);
    }
    
    int size;
    ll data[400100], data2[400100];
    const ll D = numeric_limits<ll>::max() / 2;
};

int N, Q;
SegmentTree segtree(100000);

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

    std::cin >> N >> Q;

    for(int i=0;i<Q;++i){
        int type, s, t;

        std::cin >> type >> s >> t;

        if(type == 0){
            ll x;
            std::cin >> x;

            segtree.update(s, t + 1, x);
        }else{
            std::cout << segtree.minimum(s, t + 1) << std::endl;
        }
    }
}



Measured memory_bytes: 6296
x = int(input())
 
if 1 <= x <= 6:
  print(1)
elif 7<= x < 12:
  print(2)
else:
  a = x//11 * 2
  if x%11 != 0:
    if x%11 < 7:
      a += 1
    else:
      a += 2
  print(a)

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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
	ll x, y, ans;
	cin >> x >> y;
	if (x <= y) {
		if (abs(x) <= y) {
			ans = min(y - x, y - abs(x) + 1);
		}
		else {
			ans = min(y - x, abs(x) - y + 1);
		}
	}
	else {
		if (-x >= y) {
			ans = min(abs(y) - x + 1, abs(y) - abs(x) + 2);
		}
		else {
			ans = 1 + y - (-x);
		}
	}
	ans = min(ans, abs(abs(x) - abs(y)) + 2);
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 256
import sys

r, c = map(int, raw_input().split())
table = {}

for i in range(r):
    a = map(int, raw_input().split())
    for j in range(c):
        table[(i,j)] = a[j]

for i in range(r+1):
    for j in range(c+1):
        if(i != r and j != c):
            sys.stdout.write(str(table[(i,j)]))
            sys.stdout.write(' ')
        elif(i != r and j == c):
            print sum(table[(i,l)] for l in range(c))
        elif(i == r and j != c):
            sys.stdout.write(str(sum(table[(k,j)] for k in range(r))))
            sys.stdout.write(' ')
        elif(i == r and j == c):
            total = 0
            for k in range(r):
                for l in range(c):
                    total += table[(k,l)]
            print total

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

int n; 
long long a[200005];
long long b[200005];

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) { scanf("%lld",&a[i]); b[i]=b[i-1]^a[i]; a[i]+=a[i-1]; }
    long long ans=0;
    int l=1;
    for(int i=1;i<=n;i++)
    {
	    while((a[i]-a[l-1])!=(b[i]^b[l-1])) l++;
	    ans+=i-l+1;	    
	}
	printf("%lld",ans);
	return 0;
}


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

int n, A, B, C;
vector<int> l;

int dfs(int curr, int a, int b,int c){
	if(curr == n){
		return min({a, b, c}) > 0 ?
		abs(a - A) + abs(b - B) + abs(c - C) - 30 : 1e9 + 5;
	}
	int res1 = dfs(curr + 1, a, b, c);
	int res2 = dfs(curr + 1, a + l[curr], b, c) + 10;
	int res3 = dfs(curr + 1, a, b + l[curr], c) + 10;
	int res4 = dfs(curr + 1, a, b, c + l[curr]) + 10;
	return min({res1, res2, res3, res4});
}

int main(){
	cin >> n >> A >> B >> C;
	l.resize(n);
	for(int i = 0;i < n;i++)cin >> l[i];
	cout << dfs(0, 0, 0, 0);
}
// make pair, tuple
// make pair, tuple
// 
// __gcd(int, int);
// lcm = a * b / __gcd(a, b);
// 
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }
// int countSubString(string s, string temp){
//       int ans = 0;
//       size_t f = s.find(temp);
//       while(f != string::npos){
//             ans++;
//             f = s.find(temp, f + 1);
//       }
//       return ans;
// }
// 
// #Count leading & trailing zero of an integer bits
// __builtin_clz(n);
// __builtin_clzll(n);
//
// #Count 1s bits of an integer
// __builtin_popcount(n);
// __builtin_popcountll(n);
//
// #Error checking
// assert(n == 3);
// 
// #Error Printing
// cerr << "Some thing";

// #binary exponentiation
// long long binpow(long long a, long long b) {
//     long long res = 1;
//     while (b > 0) {
//         if (b & 1)
//             res = res * a;
//         a = a * a;
//         b >>= 1;
//     }
//     return res;
// }


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

typedef struct node{
	struct node*oya;
	struct node*ko[2];
	int val;
}node;

int push(node*v,node*oya,int dir,int val){
	if(!v){
		v=(node*)calloc(1,sizeof(node));
		(*v).oya=oya;
		(*v).val=val;
		(*oya).ko[dir]=v;
	}else{
		int d=(*v).val<val;
		push((*v).ko[d],v,d,val);
	}
}

node*find(node*v,int val){
	if(!v)return 0;
	if((*v).val==val)return v;
	int d=(*v).val<val;
	return find((*v).ko[d],val);
}
node*nxt(node*v){
	if((*v).ko[0])return nxt((*v).ko[0]);
	if((*v).ko[1])return nxt((*v).ko[1]);
	return v;
}

void del(node*v){
	if(!v)return;
	if((*v).ko[0]){
		if((*v).ko[1]){
			node*nnn=nxt((*v).ko[1]);
			(*v).val=(*nnn).val;
			del(nnn);
		}else{
			if((*(*v).oya).ko[0]==v)(*(*v).oya).ko[0]=(*v).ko[0];
			else (*(*v).oya).ko[1]=(*v).ko[0];
			(*(*v).ko[0]).oya=(*v).oya;
			free(v);
		}
	}else{
		if((*v).ko[1]){
			if((*(*v).oya).ko[0]==v)(*(*v).oya).ko[0]=(*v).ko[1];
			else (*(*v).oya).ko[1]=(*v).ko[1];
			(*(*v).ko[1]).oya=(*v).oya;
			free(v);
		}else{
			if((*(*v).oya).ko[0]==v)(*(*v).oya).ko[0]=0;
			else (*(*v).oya).ko[1]=0;
			free(v);
		}
	}
}

void f(node*v,int mode){
	if(!v)return;
	if(mode==0)printf(" %d",(*v).val);
	f((*v).ko[0],mode);
	if(mode==1)printf(" %d",(*v).val);
	f((*v).ko[1],mode);
}


node root;
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		char s[10];
		scanf("%s",s);
		if(s[0]=='p'){
			f(root.ko[0],1);
			puts("");
			f(root.ko[0],0);
			puts("");
		}else if(s[0]=='i'){
			int t;
			scanf("%d",&t);
			push(root.ko[0],&root,0,t);
		}else if(s[0]=='f'){
			int t;
			scanf("%d",&t);
			puts(find(root.ko[0],t)?"yes":"no");
		}else if(s[0]=='d'){
			int t;
			scanf("%d",&t);
			del(find(root.ko[0],t));
		}
	}
}


Measured memory_bytes: 20540
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val b = read()[0] 

    val ans = when(b) {
        'A' -> 'T'
        'T' -> 'A'
        'C' -> 'G'
        else -> 'C'
    }
    println(ans)
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 29660
n=int(input())

ans=-10**9
f=[[0 for i in range(10)] for j in range(n)]
p=[[0 for i in range(11)] for j in range(n)]

for i in range(n):
  f[i]=[int(i) for i in input().split()]
for i in range(n):
  p[i]=[int(i) for i in input().split()]


for i1 in range(2):
  for i2 in range(2):
    for i3 in range(2):
      for i4 in range(2):
        for i5 in range(2):
          for i6 in range(2):
            for i7 in range(2):
              for i8 in range(2):
                for i9 in range(2):
                  for i10 in range(2):
                    sumi=i1+i2+i3+i4+i5+i6+i7+i8+i9+i10
                    count=[0 for i in range(n)]
                    for ii in range(n):
                        if i1==f[ii][0] and i1==1:
                          count[ii]=count[ii]+1
                        if i2==f[ii][1] and i2==1:
                          count[ii]=count[ii]+1
                        if i3==f[ii][2] and i3==1:
                          count[ii]=count[ii]+1
                        if i4==f[ii][3] and i4==1:
                          count[ii]=count[ii]+1   
                        if i5==f[ii][4] and i5==1:
                          count[ii]=count[ii]+1
                        if i6==f[ii][5] and i6==1:
                          count[ii]=count[ii]+1
                        if i7==f[ii][6] and i7==1:
                          count[ii]=count[ii]+1
                        if i8==f[ii][7] and i8==1:
                          count[ii]=count[ii]+1
                        if i9==f[ii][8] and i9==1:
                          count[ii]=count[ii]+1   
                        if i10==f[ii][9] and i10==1:
                          count[ii]=count[ii]+1                          
                    
                    if sumi>0:
                      ans_0=0
                      #print(count)
                      for i in range(n):
                         ans_0=ans_0+p[i][count[i]]
                      ans=max(ans,ans_0)
                          
                                                                            
print(ans)                     
                      
                      
                      
                      
                      
                      
                      
                      
                      

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll i,j,a[1010][1010],mi;
int main()
{
//	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	for(i=1;i<=3;i++)
		for(j=1;j<=3;j++)
			cin>>a[i][j];
	for(i=1;i<=3;i++)
	{
		mi=10e17;
		for(j=1;j<=3;j++)
			mi=min(mi,a[i][j]);
		for(j=1;j<=3;j++)
			a[i][j]-=mi;
	}
	for(i=1;i<=3;i++)
	{
		mi=10e17;
		for(j=1;j<=3;j++)
			mi=min(mi,a[j][i]);
		for(j=1;j<=3;j++)
			a[j][i]-=mi;
	}
	for(i=1;i<=3;i++)
		for(j=1;j<=3;j++)
			if(a[i][j]!=0)
			{
				cout<<"No\n";
				return 0;
			}
	cout<<"Yes\n";
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (H, W) = nextIntList()
    val C = Array(H) { next() }
    for (c in C) {
        println(c)
        println(c)
    }
}

Measured memory_bytes: 38064
#include<bits/stdc++.h>
using namespace std;
long long a, b, v, w, t;
int main()
{
  scanf("%lld%lld%lld%lld%lld", &a, &v, &b, &w, &t);
  if(v <= w) return printf("NO\n"), 0;
  long long d = abs(a - b);
  if(t * (v - w) >= d) printf("YES\n");
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int a[52];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		a[x]++,a[y]++;
	}for(int i=1;i<=n;i++){
		cout<<a[i]<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  string s;
  cin >> s;
  int ans = 0;
  int res = 0;
  rep(i,3){
    if(s[i]=='R')res++;
    else{
      chmax(ans,res);
      res=0;
    }
  }
  chmax(ans,res);
  cout << ans << endl;
  return 0;
}

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

#define REP(i,n) for(int i=1;i<n;i++)

using namespace std;


int main()
{
	int N,M,X;
	cin>>N>>M>>X;
	
	int A[M+10];
	
	for(int i=1;i<M+1;++i){
		cin>>A[i];
	}
	
	int cu=0,cd=0;
	int now=X;
	
	for(now;now<=N;++now){
		REP(i,M+1){
			if(now==A[i]){
				++cu;
			}
		}
	}

	now=X;
	for(now;now>=0;--now){
		REP(i,M+1){
			if(now==A[i]){
				++cd;
			}
		}
	}
	
	int Ans=min({cd,cu});
	cout<<Ans<<endl;
	
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n, total = 0;
    cin>>n;
    vector<long long> v(n), ans(n);
    map<long long, long long> m;
    for(int i=0; i<n; i++){
        cin>>v[i];
        m[v[i]] ++;
    }
    for(auto a:m){
        total += (a.second*(a.second - 1))/2;
    }
    for(int i = 0; i<n; i++){
        cout<<total - (m[v[i]]*(m[v[i]]-1))/2 + ((m[v[i]]-1)*(m[v[i]]-2))/2 <<"\n";
    }
    return 0;
}



Measured memory_bytes: 12672
n = int(input())
a = list(map(int,input().split()))
dp = [[0] * (n+1) for i in range(n+1)]
dp[0][0] = 0
for j in range(1,n+1):
  for i in range(n+1-j):
    if (n-j) %2 == 0:
      dp[i][i+j] = max(dp[i+1][i+j] + a[i],dp[i][i+j-1]+a[i+j-1])
    else:
      dp[i][i+j] = min(dp[i+1][i+j] - a[i],dp[i][i+j-1]-a[i+j-1])
print(dp[0][n])

Measured memory_bytes: 114268
#include <cstdint>

#include <iostream>

template <std::uint_fast64_t MOD> class ModInt {
  using u64 = std::uint_fast64_t;

public:
  ModInt(const u64 val = 0) { value = val % MOD; }

  bool operator==(const ModInt &rhs) const { return value == rhs.value; }
  bool operator!=(const ModInt &rhs) const { return !(*this == rhs); }
  bool operator<(const ModInt &rhs) const { return value < rhs.value; }
  bool operator>(const ModInt &rhs) const { return value > rhs.value; }
  bool operator<=(const ModInt &rhs) const { return !(*this > rhs); }
  bool operator>=(const ModInt &rhs) const { return !(*this < rhs); }

  ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }

  ModInt &operator+=(const ModInt rhs) {
    value += rhs.value;
    if (value >= MOD) {
      value -= MOD;
    }
    return *this;
  }

  ModInt &operator-=(const ModInt rhs) {
    if (value < rhs.value) {
      value += MOD;
    }
    value -= rhs.value;
    return *this;
  }

  ModInt &operator*=(const ModInt rhs) {
    value = value * rhs.value % MOD;
    return *this;
  }

  ModInt &operator/=(ModInt rhs) {
    *this *= rhs.inv();
    return *this;
  }

  ModInt &operator++(int n) {
    value++;
    if (value >= MOD) {
      value -= MOD;
    }
    return *this;
  }

  ModInt &operator--(int n) {
    if (value == 0) {
      value += MOD;
    }
    value--;
    return *this;
  }

  ModInt inv() { return ModInt::pow(*this, MOD - 2); }

  static ModInt pow(ModInt base, long long int n) {
    ModInt res = ModInt(1);
    while (n) {
      if (n & 1) {
        res *= base;
      }
      base *= base;
      n /= 2;
    }
    return res;
  }

  static ModInt comb(ModInt n, ModInt r) { return comb(n.value, r.value); }

  static ModInt comb(int n, int r) {
    if (n < r)
      return ModInt(0);
    ModInt res = ModInt(1);
    ModInt el = ModInt(1);
    for (int i = 1; i < n + 1; i++) {
      res *= el;
      el++;
    }

    ModInt inv = ModInt(1);
    el = ModInt(1);
    for (int i = 1; i < r + 1; i++) {
      inv *= el;
      el++;
    }
    el = ModInt(1);
    for (int i = 1; i < n - r + 1; i++) {
      inv *= el;
      el++;
    }
    res *= inv.inv();
    return res;
  }

  u64 getValue() const { return value; }

private:
  u64 value;
};

// ここを問題ごとのMODに書き換える
using mint = ModInt<1000000007>;

std::ostream &operator<<(std::ostream &out, const mint &m) {
  out << m.getValue();
  return out;
};

std::istream &operator>>(std::istream &in, mint &m) {
  uint_fast64_t i;
  in >> i;
  m = mint(i);
  return in;
}

int main() {
  mint n, m, k;
  std::cin >> n >> m >> k;
  mint ans = mint(0);
  mint kumi = mint::comb(n * m - mint(2), k - mint(2));
  for (int d = 1; d < n.getValue(); d++) {
    ans += (mint(d) * (n - mint(d)) * m * m * kumi);
  }
  for (int d = 1; d < m.getValue(); d++) {
    ans += (mint(d) * (m - mint(d)) * n * n * kumi);
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ff first
// #define mp make_pair
#define ss second
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repp(i,a,b) for(int i = a; i <= b; i++)
#define endl '\n'
#define mod 1000000007
#define mod_in(a) bin(a, mod - 2)
#define ncr(n, r) (n >= r ? ((ft[n] * mod_in((ft[r] * ft[(n)-(r)]) % mod)) % mod) : (int)0)
#define pi 3.14159265358979323
#define INF 1e15
#define lb(v, a) lower_bound(v.begin(), v.end(), a)
#define ub(v, a) upper_bound(v.begin(), v.end(), a)

int power(int x, int n){
    int res=1;
    while(n>0){
        if(n&1)
            res=res*x;
        x*=x;
        n>>=1;
    }
    return res;
}

int bin(int x, int n){
    int res=1; x%=mod;
    while(n){
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res%mod;
}
// vector<int> ft;

// int ncr(int n, int r){
//     if(n>=r){
//         return (ft[n] * mod_in((ft[r] * ft[(n)-(r)]) % mod)) % mod;
//     }
//     else return 0;
// }

bool prime(int n){
    if(n==3)return 1;
    repp(i,2,sqrt(n)){
        if(n%i==0)return 0;
    }
    return 1;
}

// vector<int> adj[100001];
// int flag=0, x, y, f=0;
// int vis[100001]={0}, par[200001]={0}, top[500001], pop[100001]={0}, g[100001], b[100001];
// int p[100001], h[100001];

// void dfs(int n){
//     vis[n] = 1;
//     pop[n]=p[n];
//     for(auto i: adj[n]){
//         if(!vis[i]){ 
//             dfs(i);
//             pop[n] += pop[i];
//         }
//     }
// }


// vector<int> pr(2000005, 1), xx[2000005];
// void sieve(int n){ 
//     for(int p=2; p<n; p++){ 
//         if(pr[p]){ 
//             for(int i=p; i<n; i += p){
//                 pr[i]=0;
//                 xx[i].pb(p);
//             }
//         } 
//     } 
// }  

void solve(){
    int n, res=0; cin>>n;
    int arr[n];
    rep(i,0,n) cin>>arr[i];
    sort(arr, arr+n);
    rep(i,0,n){
        rep(j,i+1,n){
            rep(k,j+1,n){
                if(arr[i]==arr[j] or arr[j]==arr[k] or arr[k]==arr[i]) continue;
                if(arr[i]+arr[j] > arr[k]) res++;
            }
        }
    }
    cout<<res<<endl;
}

signed main(){
    fast
    // ft.pb(1);
    // rep(i,1,2000005) ft.pb((ft[i-1]*i)%mod);
    int t=1;
    // cin>>t;
    while(t--) solve();
}

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

#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<ll,ll>
#define vi vector<ll>
#define vpi vector< pi >
const int N=100010;

int main()
{
	ll k,a,b,xx;
	cin>>k>>a>>b;xx=k;
	if(a>=b||k<=a)
	{
		cout<<k+1;
		return 0;
	}
	ll res=b;
	k-=a+1;
	if(k%2) res++;
	k/=2;
	//cout<<<<"\n";
	cout<<max(xx+1,res+k*(b-a));
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  for(int i = 0; i < n; ++i){
    cin >> w[i];
  }
  int res = 1000000;
  int c1,c2;
  for(int i = 0; i < n; ++i){
    c1 = 0;
    c2 = 0;
    for(int j = 0; j < n; ++j){
      if(j <= i){
        c1 += w[j];
      }else{
        c2 += w[j];
      }
    }
    res = min({res,abs(c1-c2)});
  }
  cout << res;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
using namespace std;
int main() {
	int N;
	cin >> N;
	for (int i = N;i <= N*2;i += N) {
		if (i % 2 == 0) {
			cout << i << endl;
			return 0;
		}
	}
  return 0;
}

Measured memory_bytes: 384
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 2e5 + 5, M = N << 1 ;
using namespace std ;

bool flg = true ;
int n, e, ter[M], nxt[M], lnk[N], opt[N], mex[N], d[N], pre[N] ;
map <int, bool> h[N] ;

void add(int x, int y) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e ;
}

bool cmp(int x, int y) {
	return mex[x] < mex[y] ;
}

void solve(int x) {
	if (d[pre[x]]) {
		if (mex[pre[x]] > mex[x]) ; else solve(pre[x]) ;
	} 
	if (mex[pre[x]] == mex[x]) ++ mex[x] ;
	d[x] = 0 ;
}

int main() {
	scanf("%d", &n) ;
	int x ;
	rep(i, 1, n) scanf("%d", &x), add(x, i), add(i, x), ++ d[x] ;
	int he = 0, ta = 0 ;
	rep(i, 1, n) if (!d[i]) opt[++ ta] = i  ;
	for ( ; he != ta ; ) {
		++ he ;
		int u = opt[he] ;
		for ( ; h[u][mex[u]] ; ++ mex[u]) ;
		for (int i = lnk[u] ; i; i = nxt[i]) if (!(i & 1)) {
			int v = ter[i] ;
			-- d[v] ;
			h[v][mex[u]] = true ;
			if (!d[v]) opt[++ ta] = v ;
		}
	}
	ta = 0 ;
	rep(i, 1, n) if (d[i]) {
		for ( ; h[i][mex[i]] ; ++ mex[i]) ;
		for (int j = lnk[i]; j; j = nxt[j]) if (j & 1) if (d[ter[j]]) pre[i] = ter[j] ;
		opt[++ ta] = i ;
	}
	sort(opt + 1, opt + ta + 1, cmp) ;
	if (mex[opt[1]] == mex[opt[ta]]) {
		if (ta & 1) flg = false ;
	} else {
		rep(i, 1, ta) solve(opt[i]) ;
	}
	if (flg) puts("POSSIBLE") ; else puts("IMPOSSIBLE") ; 
	return 0 ; 
}

Measured memory_bytes: 34048
import std.stdio, std.string, std.array, std.conv, std.range;

class Dice6 {
    int[string] dice6;
    int[] _dice6 = new int[6];

    this(int[] _dice6) {
        dice6["top"] = _dice6[0];
        dice6["front"] = _dice6[1];
        dice6["right"] = _dice6[2];
        dice6["left"] = _dice6[3];
        dice6["back"] = _dice6[4];
        dice6["bottom"] = _dice6[5];
    }

    void roll(char c) {
        int tmp = dice6["top"];
        if (c == 'E') {
            dice6["top"] = dice6["left"];
            dice6["left"] = dice6["bottom"];
            dice6["bottom"] = dice6["right"];
            dice6["right"] = tmp;
        } else if (c == 'N') {
            dice6["top"] = dice6["front"];
            dice6["front"] = dice6["bottom"];
            dice6["bottom"] = dice6["back"];
            dice6["back"] = tmp;
        } else if (c == 'S') {
            dice6["top"] = dice6["back"];
            dice6["back"] = dice6["bottom"];
            dice6["bottom"] = dice6["front"];
            dice6["front"] = tmp;
        } else {
            dice6["top"] = dice6["right"];
            dice6["right"] = dice6["bottom"];
            dice6["bottom"] = dice6["left"];
            dice6["left"] = tmp;
        }
    }

    void clockwise() {
        int tmp = dice6["front"];
        dice6["front"] = dice6["right"];
        dice6["right"] = dice6["back"];
        dice6["back"] = dice6["left"];
        dice6["left"] = tmp;
    }

    int surface(string dir) {
        int result;
        if (dir == "top") {
            result = dice6["top"];
        } else if (dir == "front") {
            result = dice6["front"];
        } else if (dir == "right") {
            result = dice6["right"];
        } else if (dir == "left") {
            result = dice6["left"];
        } else if (dir == "back") {
            result = dice6["back"];
        } else {
            result = dice6["bottom"];
        }
        return result;
    }
}

bool areIdentical(Dice6 x, Dice6 y) {
    string[] dirs = ["top", "front", "right", "left", "back", "bottom"];
    foreach (dir; dirs) {
        if (x.surface(dir) != y.surface(dir)) return false;
    }
    return true;
}

void main() {
    int n = readln.chomp.to!int;
    Dice6[] dices;
    foreach (i; 0 .. n) {
        int[] _dices = readln.chomp.split.to!(int[]);
        dices ~= new Dice6(_dices);
    }
    bool ok = true;
    foreach (i; 0 .. n-1) {
        Dice6 dice1 = dices[i];
        foreach (j; i+1 .. n) {
            Dice6 dice2 = dices[j];
            foreach (k; 0 .. 6) {
                foreach (l; 0 .. 4) {
                    if (areIdentical(dice1, dice2)) ok = false;
                    dice2.clockwise;
                }
                k % 2 == 0 ? dice2.roll('E') : dice2.roll('N');
            }
        }
    }
    writeln(ok ? "Yes" : "No");
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long  N,W,w,v,dp[100001];
    fill(dp,dp+100001,0);
    dp[0] = 0;
    cin >> N >> W;
    for (int i=0;i<N;i++){
        cin >> w >> v;
        for (int j=W;j >= w; j--){
            dp[j] = max(dp[j-w]+v,dp[j]);
        }
    }
    cout << dp[W] << endl;
}


Measured memory_bytes: 1024
import Control.Applicative
import Control.Monad
import System.IO.Unsafe
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete


main = getLine >> getInts >>= print . sum . map (\xs -> let x = head xs in let l = length xs in if x<=l then l-x else l) . group . sort 

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

void trace(int a[], int n){
    int i;
    
    for (i = 0; i < n; i++){
        printf("%d", a[i]);
        if (i < n-1) printf(" ");
    }
    printf("\n");
}

void insertionSort(int a[], int n){
    int i, v, j;
    
    for (i = 1; i < n; i++){
        v = a[i];
        j = i - 1;
        while (j >= 0 && a[j] > v){
            a[j+1] = a[j];
            a[j] = v;
            j--;
        }
        trace(a, n);
    }
}

int main(void){
    int n, a[100], i;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    trace(a, n);
    insertionSort(a, n);
    return 0;
}

Measured memory_bytes: 2760
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]


def dfs(i, a, b, c):
    if i == N:
        if min(a, b, c) != 0:  # いずれかが0だと竹を1本も使っていないことになる
            return abs(A - a) + abs(B - b) + abs(C - c)
        else:
            return float('inf')
        
    res1 = dfs(i+1, a, b, c)
    
    # 竹をつなぎ合わせる時は10MP消費する
    mp2 = 10 if a > 0 else 0
    mp3 = 10 if b > 0 else 0
    mp4 = 10 if c > 0 else 0
    
    res2 = dfs(i+1, a+L[i], b, c) + mp2
    res3 = dfs(i+1, a, b+L[i], c) + mp3
    res4 = dfs(i+1, a, b, c+L[i]) + mp4
    
    return min(res1, res2, res3, res4)

print(dfs(0, 0, 0, 0))

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

int k,x,y,nowx,nowy,a=-1;
struct r2{int x,y;};
vector<r2> ans;
void move(int x,int y){
  nowx+=x;nowy+=y;
  ans.push_back({nowx,nowy});
}

int main(){
  cin>>k>>x>>y;
  int X=abs(x),Y=abs(y);
  if(X>Y)swap(X,Y);

  if(!(k&1)&&((X+Y)&1)){
    cout<<-1<<endl;
    return 0;
  }
  if(X+Y==k){
    cout<<1<<endl<<x<<" "<<y<<endl;
    return 0;
  }

  for(int i=k*2-(X+Y);a<0;i+=k)if(!(i&1))a=i/2;

  while(a>=k)move(0,-k),a-=k;
  move(-a,k-a);
  while(nowx+k<=X)move(k,0);
  while(nowy+k<=Y)move(0,k);
  if(nowx!=X||nowy!=Y)ans.push_back({X,Y});

  cout<<ans.size()<<endl;
  for(r2 p:ans){
    int ansx=p.x,ansy=p.y;
    if(abs(x)>abs(y))swap(ansx,ansy);
    if(x<0)ansx*=-1;
    if(y<0)ansy*=-1;
    cout<<ansx<<" "<<ansy<<endl;
  }
}


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

#define PrintLn(X) cout << X << endl
int main(void)
{
	int A, B, C;
	cin >> A >> B >> C;

	int n = 0;
	while(1){
		if((A * n) % B == C){
			PrintLn("YES");
			return 0;
		}else if(n == B){
			PrintLn("NO");
			return 0;
		}
		n++;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  long int n;
  cin>>n;
  
  unsigned long long int m;
  int n1;
  n-=1;
  if(n%2==0)
  m=(n/2)*(n+1);
  else
    m=((n+1)/2)*n;
  
  cout<<m;
  
 return 0; 
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		if(N%2==0) {
			System.out.println(N);
		}else {
			System.out.println(2*N);
		}
	}
}

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

using namespace std;

int N, a[100005], sol, fcv[100005];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
        
        ++fcv[a[i]];
    }
    
    for (int i = 0; i <= 100000 - 2; ++i) {
        sol = max(sol, fcv[i] + fcv[i + 1] + fcv[i + 2]);
    }
    
    cout << sol << '\n';
    return 0;
}

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

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


Measured memory_bytes: 3080
#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() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<pair<string, int>> v;
    for(int i = 0; i < 52; i++) {
        if(i <= 12){
            v.push_back(make_pair("S",i+1));
        } else if(i >= 13 && i<= 25){
            v.push_back(make_pair("H",i+1-13));
        } else if(i >= 26 && i <= 38){
            v.push_back(make_pair("C",i+1-26));
        } else if(i >= 39 && i <= 51){
            v.push_back(make_pair("D",i+1-39));
        }
        // cout << v[i].first << " " << v[i].second << endl;
    }

    map<string, int> mp;
    for(int i = 0; i < N; i++) {
        string x;
        string y;
        cin >> x >> y;
        mp[x+y] = 1;
    }

    for(int i = 0; i < 52; i++) {
        string j = v[i].first + to_string(v[i].second);
        if(mp.count(j)) {
            continue;
        }
        cout << v[i].first << " " << v[i].second << endl;
    }
}



Measured memory_bytes: 3252
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int L, R, D;
	cin >> L >> R >> D;

	int kotae = R / D - (L - 1) / D;
	co(kotae);



	Would you please return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b)+min(c,d) << endl;


    return 0;
}


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

int main()
{
    int n,cnt=0;
    cin>>n;
    vector<int> v(n+1,0);
    for(int i=1;i<=n;i++)
        cin>>v[i];
    for(int i=0;i<=n;i++)
        if(i%2 && v[i]%2)
            cnt++;
    cout<<cnt;
}


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

using namespace std;

int calc_dist(int fx, int fy, int tx, int ty) {
  return abs(fx - tx) + abs(fy - ty);
}

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

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

  for (int i = 0; i < n; ++i) {
    int min_dist = INT_MAX;
    int min_chk = -1;
    for (int j = 0; j < m; ++j) {
      int dist = calc_dist(a[i], b[i], c[j], d[j]);
      if (dist < min_dist) {
        min_dist = dist;
        min_chk = j;
      }
    }
    cout << (min_chk + 1) << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws java.io.IOException {

		BufferedReader input = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder str = new StringBuilder();

		int i = 0;

		while (true) {
			i++;
			String tmp = input.readLine();
			int x = Integer.parseInt(tmp);

			if (x == 0)
				break;

			str.append("Case " + i + ": " + x + "\n");

		}

		System.out.print(str);

	}
}

Measured memory_bytes: 26832
<?php
	$S=str_split(fgets(STDIN));
	$N=count($S)-1;
	$u=$v=0;
	for($i=0;$i<$N;$i++)
	{
		if($S[$i]=="B")$u++;
		else $v+=$u;
	}
	echo $v,"\n";


Measured memory_bytes: 39468
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

#define ll long long
const int N = 18;

int data[N],ans = 0,a[N],b[N][N][2];
int n;

bool check(){
	for(int i = 1; i <= n; i++){
		if(!data[i]) continue;
		for(int j = 1; j <= a[i]; j++)
			if((b[i][j][1] && !data[b[i][j][0]]) || (!b[i][j][1] && data[b[i][j][0]]))
				return false;
	}
	return true;
}

void dfs(int now,int sum){
	if(now > n){
			if(check()) ans = max(ans,sum);
			return;
	}
	data[now] = 1;
	dfs(now+1,sum+1);
	data[now] = 0;
	dfs(now+1,sum);
}

void in(){
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		scanf("%d",&a[i]);
		for(int j = 1; j <= a[i]; j++)
			scanf("%d%d",&b[i][j][0],&b[i][j][1]);
	}
	dfs(1,0);
}

int main(){
	in();
	printf("%d",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;	
int n;
ll a[200010],x[200010];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i];
		a[x[i]]++;
	}
	ll ans=0;
	for(int i=1;i<=n;i++)ans+=a[i]*(a[i]-1)/2;
	for(int i=1;i<=n;i++){
		cout<<ans-a[x[i]]+1<<endl;
	}
} 

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


int main(){

  ll N,M;
  cin >> N >> M;
  int G[N][N]={};
  FOR(i,0,M){
    ll a,b;
    cin >> a >> b;
    a--;b--;
    G[a][b] = G[b][a] = 1;
  }

  vector<ll> path(N);
  FOR(i,0,N)path[i] = i;

  ll ans = 0;
  do{
    bool ok = true;
    if(path[0] != 0)break;
    FOR(i,1,N){
      if(G[path[i]][path[i-1]] == 0){
        ok = false;
      }
    }
    ans += ok;
  }while(NEXTP(path));
  cout << ans << endl;
}


Measured memory_bytes: 256