akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
a,b,n = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに

if n < b:
    print(int(n*a//b))
else:
    print(int((b-1)*a//b))


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

int main()
{
    long long int n;
    long long int num[5] = {};
    cin >> n;
    for (long long int i = 0; i < n; i++) {
        string str;
        cin >> str;
        switch (str[0]) {
            case 'M':
                num[0]++;
                break;
            case 'A':
                num[1]++;
                break;
            case 'R':
                num[2]++;
                break;
            case 'C':
                num[3]++;
                break;
            case 'H':
                num[4]++;
                break;
            default:
                break;
        }
    }
    long long int sum = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = i + 1; j < 4; j++) {
            for (int k = j + 1; k < 5; k++) {
                sum += num[i] * num[j] * num[k];
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <string.h>

using namespace std;

int main (void)
{
	for (int u = 0; u < 100; u++)
	{
		string n;
		char si;
		si = 'A';

		cin >> n;
		if (n == "#")
		{
			break;
		}
		int k = 0;
		k = n.size();

		for (int i = 0; i < k; i++)
		{
			string q;
			q = n.substr(i,1);

			if (si == 'A')
			{
				if (q == "0")
				{
					si = 'X';
				}
				else
				{
					si = 'Y';
				}
			}
			else if (si == 'X')
			{
				if (q == "1")
				{
					si = 'Z';
				}
				else
				{
					si = '?';
					break;
				}
			}
			else if(si == 'Y')
			{
				if (q == "0")
				{
					si = 'X';
				}
				else
				{
					si = '?';
					break;
				}
			}
			else if (si == 'Z')
			{
				if (q == "0")
				{
					si = 'W';
				}
				else
				{
					si = 'B';
				}
			}
			else if (si == 'W')
			{
				if (q == "0")
				{
					si = 'B';
				}
				else
				{
					si = 'Y';
				}
			}
			else
			{
				if (q == "0")
				{
					si = 'Y';
				}
				else
				{
					si = 'X';
				}
			}
		}

		if (si == 'B')
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
}



Measured memory_bytes: 3140
#include <stdio.h>
int main(void)

{

	int H,W;

	int i,j;


	while(1){
		scanf("%d %d",&H,&W);

		if(H==0 && W==0){

			break;
		}

		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				if((i%2==1 && j%2==1)||(i%2==0 && j%2==0)){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}

		printf("\n");

	}

	return 0;

}


Measured memory_bytes: 2048
W=[]
K=[]
for i in range(10):
    s=int(input())
    W.append(s)
for j in range(10):
    t=int(input())
    K.append(t)
W=sorted(W)
K=sorted(K)
print(f'{sum(W[7:10])} {sum(K[7:10])}')


Measured memory_bytes: 5612
import math
import statistics

n = int(input())
a = [int(x) for x in input().split()]
a2 = [0] * n
for i in range(n):
    a2[i] = a[i] - (i+1)
median = int(statistics.median(a2))
for i in range(n):
    a2[i] = abs(a2[i]-median)
print(sum(a2))


Measured memory_bytes: 27248
import java.util.*

fun main(args: Array<String>) {
    val read = Scanner(System.`in`)

    val s = read.next()

    when(s) {
        "SUN" -> println(7)
        "MON" -> println(6)
        "TUE" -> println(5)
        "WED" -> println(4)
        "THU" -> println(3)
        "FRI" -> println(2)
        "SAT" -> println(1)
    }
}


Measured memory_bytes: 29604
N = int(input())
in_num = []
for i in range(N):
    in_num.append(list(map(str,input().split())))

res = 0

for x,u in in_num:
    if u == 'JPY':
        res+=float(x)
    else:
        res+= float(x)*380000.0

print(res)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
	static final int MAX = 100;
	static final int INF = 1 << 21;
	static final int WHITE = 0;
	static final int GRAY = 1;
	static final int BLACK = 2;
	static int n;
	static int[][]M = new int[MAX][MAX];
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				int e = scan.nextInt();
				if(e == -1) M[i][j] = INF;
				else M[i][j] = e;
			}
		}
		scan.close();
		System.out.println(prim());
	}
	static int prim() {
		int u, minV;
		int[]d = new int[MAX];
		int[]p = new int[MAX];
		int[]color = new int[MAX];
		for(int i = 0; i < n; i++) {
			d[i] = INF;
			p[i] = -1;
			color[i] = WHITE;
		}
		d[0] = 0;
		while(true) {
			minV = INF;
			u = -1;
			for(int i = 0; i < n; i++) {
				if(minV > d[i] && color[i] != BLACK) {
					u = i;
					minV = d[i];
				}
			}
			if(u == -1) {
				break;
			}
			color[u] = BLACK;
			for(int v = 0; v < n; v++) {
				if(color[v] != BLACK && M[u][v] != INF) {
					if(d[v] > M[u][v]) {
						d[v] = M[u][v];
						p[v] = u;
						color[v] = GRAY;
					}
				}
			}
		}
		int sum = 0;
		for(int i = 0; i < n; i++) {
			if(p[i] != -1) {
				sum += M[i][p[i]];
			}
		}
		return sum;
	}
}


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

int main(){
  int N,K,x;
  int c=0;
  cin >> N >> K;

  for(int i=0;i<N;i++){
    cin >> x;
    if(K<=2*x){
      c+=2*(K-x);
    }
    else{
      c+=2*x;
    }
  }
  cout << c << endl;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;

string s;
bool flag1, flag2;

int main(){
  cin >> s;
  int tmp1 = stoi(s.substr(0,2));
  int tmp2 = stoi(s.substr(2,2));

  if(1<=tmp1 && tmp1<=12){
    if(1<=tmp2&&tmp2<=12)cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }else{
    if(1<=tmp2&&tmp2<=12)cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define MAX 10000001

bool prime[MAX];
int n;

void primeSieve(){
    std::fill(prime, prime + MAX, true);
    prime[0] = prime[1] = true;

    for(int i = 2; i * i <= MAX; i++){
        for(int j = 2; i * j <= MAX; j++){
            if(!prime[i * j]) continue;
            prime[i * j] = false;
        }
    }
}

int main(){
    primeSieve();
    while(1){
        scanf("%d", &n);

        if(n == 0) break;

        int ans = 0;
        for(int i = n; i >= 8; i--){
            if(prime[i] && prime[i - 2] && prime[i - 6] && prime[i - 8]){
                ans = i;
                break;
            }
        }

        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 12344
a,b,c,x,y=map(int,input().split())

#全部ABピザで買う
ans1=c*max(x,y)*2

#AピザX個、BピザをY個、それぞれ買う
ans2=a*x+b*y

#X、Yの少ない方までABピザを買い、足りない分を買う
if(x<=y):
  ans3=c*x*2+(y-x)*b
else:
  ans3=c*y*2+(x-y)*a

print(min(ans1,ans2,ans3))


Measured memory_bytes: 2940
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)


n, m, k = map(int, input().split())
u = UnionFind(n + 1)
already = [0] * (n + 1)

for i in range(m):
    a, b = map(int, input().split())
    u.union(a, b)
    already[a] += 1
    already[b] += 1
for i in range(k):
    c, d = map(int, input().split())
    if u.same(c, d):
        already[c] += 1
        already[d] += 1

for i in range(1, n + 1):
    print(u.size(i) - already[i] - 1)


Measured memory_bytes: 8604
object Main extends App {

  import scala.io.StdIn._

  val s = '\0' + readLine.trim
  val t = '\0' + readLine.trim
  val maxLength = Array.tabulate(s.length){_ ⇒ Array.tabulate(t.length){_ ⇒ 0}}
  for (i ← 1 until s.length){
    for (j ← 1 until t.length){
      if (s(i) == t(j)){
        maxLength(i)(j) = List(maxLength(i - 1)(j - 1) + 1, maxLength(i)(j - 1), maxLength(i - 1)(j)).max
      }else {
        maxLength(i)(j) = List(maxLength(i - 1)(j), maxLength(i)(j - 1)).max
      }
    }
  }
  println(makeString(maxLength, s))
  def makeString(maxLength: Array[Array[Int]], s: String): String = {
    var string: List[Char] = Nil
    var i = maxLength.length - 1
    var j = maxLength.head.length - 1
    while (i != 0 && j != 0){
      if (maxLength(i)(j) == maxLength(i - 1)(j)){
        i -= 1
      }else if (maxLength(i)(j) == maxLength(i)(j - 1)) {
        j -= 1
      }else {
        string ::= s(i)
        i -= 1
        j -= 1
      }
    }
    string.mkString
  }
  implicit class Extend[T](value: T){
    def also(func: T ⇒ Unit): T = {func(value); value}
    def let[A](func: T ⇒ A): A = func(value)
  }
}

Measured memory_bytes: 163624
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<vector<int>> x(n, vector<int>(26, 0));
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < (int)s[i].size(); j++) {
      x[i][s[i][j]-'a']++;
    }
  }
  vector<int> ans(26, 100);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      ans[j] = min(ans[j], x[i][j]);
    }
  }
  for (int i = 0; i < 26; i++) {
    while (ans[i]--) {
      printf("%c", 'a'+i);
    }
  }
  dump("");
  return 0;
}


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

int main(){
	long long ans=0;
	long long N,M,an=1,am=1;
	cin>>N>>M;

	for(int i=1;i<=N;++i)an=(an*i)%1000000007;
	for(int i=1;i<=M;++i)am=(am*i)%1000000007;
	if(N==M+1||N+1==M)ans=(an*am)%1000000007;
	if(N==M)ans=(an*am*2)%1000000007;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false INT_MAX INT_MIN insert erase clear pop push compare INT64_MAX INT64_MIN  reverse replace stringstream string::npos length substr front priority_queue
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 7 ;
const int inf =
 1e9 + 5 ;
 //1e18L + 5;
const int nax = 2e5 + 5;
void min_self(int&a , int b){a=min(a,b);}
void max_self(int&a , int b){a=max(a,b);}
void add_self(int&a , int b){a=(a+b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int k ; string s ; 
cin >> k >> s ;

int K = s.length() ; 
for(int i = 0 ; i<min(k,K) ; i++)
	cout<<s[i];
if(K>k)cout<<"...";


	
}

Measured memory_bytes: 3656
n = int(input())
import math
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0  # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
primeslist = primes(55556)
l_n_str = [str(n) for n in primeslist]
pl1 = []
for i in range(len(primeslist)):
    if l_n_str[i][-1] == "1":
        pl1.append(primeslist[i])

for i in range(n):
    print(pl1[i], "" , end = "")

Measured memory_bytes: 5272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
int main(){
    string n;
    string ans="No";
    cin>>n;
    if (n[0]=='7'||n[1]=='7'||n[2]=='7')ans="Yes";
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3624
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

int main() {
	int n, t;
	cin >> n >> t;
	VI a(n);
	rep(i, n) cin >> a[i];

	ll sum = 0;
	rep(i, n - 1) {
		if (a[i + 1] - a[i] < t) {
			sum += a[i + 1] - a[i];
		} else {
			sum += t;
		}
	}
	sum += t;
	cout << sum << endl;
}


Measured memory_bytes: 1024
use std::collections::HashSet;

fn main() {
    let _ = read::<usize>();
    let s = read::<String>();
    let mut rset: HashSet<usize> = HashSet::new();
    let mut gset: HashSet<usize> = HashSet::new();
    let mut bset: HashSet<usize> = HashSet::new();
    for (i, c) in s.clone().char_indices() {
        if c == 'R' {
            rset.insert(i+1);
        } else if c == 'G' {
            gset.insert(i+1);
        } else {
            bset.insert(i+1);
        }
    }

    let mut ret = rset.len() * gset.len() * bset.len();
    for r in rset.iter() {
        for g in gset.iter() {
            let h;
            let l;
            if r > g {
                h = *r;
                l = *g
            } else {
                h = *g;
                l = *r;
            }
            let d = h - l;

            if l < d {
                if bset.contains(&(h + d)) {
                    ret -= 1;
                }
            } else {
                if bset.contains(&(l - d)) {
                    ret -= 1;
                }
                if bset.contains(&(h + d)) {
                    ret -= 1;
                }
            }
            if (h + l) % 2 == 0 {
                if bset.contains(&((h + l) / 2)) {
                    ret -= 1;
                }
            }
        }
    }

    println!("{}", ret);
}

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


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

int main() {
  string S;
  char a, b, c, d;
  cin >> S;
  a = S.at(0);
  b = S.at(1);
  c = S.at(2);
  d = S.at(3);
  if ((a == b && c == d) or (a == c && b == d) or (a == d && b == c)) {
    if (a == b && a == c) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;
using Graph=vector<vector<int>>;
Graph c(10,vector<int>(10));

int main()
{
  int h,w;
  cin>>h>>w;
  for (int i = 0; i < 10; ++i)
  {
    for (int j = 0; j < 10; ++j)
    {
      cin>>c[i][j];
    }
  }
  //1への最短路のコストを求める
  //Bellman-Ford
  std::vector<vector<int>> vec(10,vector<int>(10,10000));
  for (int i = 0; i < 10; ++i)
  {
    vec[i][i]=0; 
  }
  for (int s = 0; s < 10; ++s)//始点
  {
    for (int g = 0; g < 10; ++g)//終点
    {
      //各辺を走査する
      for (int i = 0; i < 10; ++i)
      {
        for (int j = 0; j < 10; ++j)
        {
          if(vec[s][j]>vec[s][i]+c[i][j]){
            vec[s][j]=vec[s][i]+c[i][j];
          }
        }
      }
    }
  }
  
  
  int64_t cost=0;
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      int tmp;
      cin>>tmp;
      if(abs(tmp)==1) continue;
      //コストをたしていく
      cost+=vec[tmp][1];
    }
  }
  cout<<cost;
}

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

using namespace std;

int n,i;
vector <int> a;

int main(){
	scanf("%d", &n);
	
	for(i = 0; i < 3 * n; i++){
		int x;
		scanf("%d", &x);
		a.push_back(x);
	}	
	
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	
	for(i = 0; i < n; i++)
	a.pop_back();
	
	long long res = 0;
	
	for(i = 1; i < a.size(); i += 2)
	res += a[i];
	
	printf("%lld\n", res);
}


Measured memory_bytes: 2420
#pragma GCC optimize ("Ofast")
#include"bits/stdc++.h"
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << "  ";
    __f(comma + 1, args...);
}

#define ll long long
#define pii pair<int,int>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i)
#define int long long int
#define all(n) n.begin(),n.end()
#define mem(n,i) memset(n,i,sizeof n)
#define em(a) emplace_back(a)
#define pb(a) push_back(a)
#define srep(it,vv) for(auto &it : vv)
#define prep(it,vv) for(auto it : vv)
//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));

typedef vector<int> vii;
typedef vector<string> vss;
/*

*/
signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    set<int>ss;
    int n = 3;
    rep(i, n)
    {
        int a; cin >> a;
        ss.insert(a);
    }
    if (ss.size() == 2) cout << "Yes" << endll;
    else cout << "No" << endll;
}

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

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  for(int i = a ; i < min(a + k, b + 1) ; ++i){
    cout << i << endl;
  }
  for(int i = max(a + k, b - k + 1) ; i <= b ; ++i){
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
using P = pair<int,int>;

int main(void) 
{
   ll a, b, c, k;
   cin >> a >> b >> c >> k;

    ll ans = k;
   if(k <= a) {
       cout << ans << endl;
       return 0;
   }

   k = k - a;

   if(k <= b){
       cout << a << endl;
       return 0;
   }
   k = k - b;

   cout << a - k << endl;
}

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

int main()
{
    int X,Y,Z,A,B;
    scanf("%d %d %d",&X,&Y,&Z);
    A=X;
    X=Y;
    Y=A;
    B=X;
    X=Z;
    Z=B;
    printf("%d %d %d",X,Y,Z);
    return 0;
}


Measured memory_bytes: 128
N,W = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(N)]
import numpy as np
dp = np.zeros(W+1,dtype=np.int64)
for w,v in wv:
    np.maximum(dp[w:],dp[:-w]+v,out=dp[w:])
print(dp.max())

Measured memory_bytes: 14264
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	int D,G;
	cin>>D>>G;
	
	vector<pair<int,int>> X(D);
	
	vector<int> A;
	
	for(int i=0;i<D;i++){
		cin>>X[i].first>>X[i].second;
		A.push_back(i);
	}
	
	int ans = Inf;
	
	do{
		int now = G;
		int cnt = 0;
		
		
		for(int i=0;i<D;i++){
			int point = (A[i]+1)*100;
			int num = X[A[i]].first;
			int bonus = X[A[i]].second;
			
			if(point*num<=now){
				now-=point*num;
				now-=bonus;
				cnt+=num;
			}
			else{
				cnt += (now+point-1)/point;
				now=0;
			}
			
			if(now<=0)break;
		}
		
		ans = min(ans,cnt);
		
	}
	while(next_permutation(A.begin(),A.end()));
	
	cout<<ans<<endl;
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200105],sum=0;
int d[200105][35],n;
inline ll read()
{
	char c=getchar();ll a=1;ll ans=0;
	for(;c<'0'||c>'9';c=getchar())if(c=='-')a=-1;
	for(;c>='0'&&c<='9';c=getchar())ans=ans*10+ll(c)-48;
	return a*ans;
}
int aaaa(int s,int v)
{
	int k=log((v-s+1)*1.0)/log(2.0);
	if(a[d[s][k]]<a[d[v-(1<<k)+1][k]])
	{
		return d[s][k];
	}
	else 
	{
		return d[v-(1<<k)+1][k];
	}
}
void dfs(int l,int r)
{
	if(l==r)
	{
		sum+=a[l];
		return;
	}
	int minn=aaaa(l,r);
	sum=sum+(ll)(minn-l+1)*(r-minn+1)*a[minn];
	if(l<=minn-1)
	{
		dfs(l,minn-1);
	}
	if(r>=minn+1)
	{
		dfs(minn+1,r);
	}
}
int main()
{
	n=read();
	for(int i=0;i<n;i++)
	{
		a[i]=read();
	}
	for(int i=0;i<n;i++)
	{
		d[i][0]=i;
	}
	for(int j=1;(1<<j)<=n;j++)
	{
		for(int i=0;i+(1<<j)-1<n;i++)
		{
			if(a[d[i][j-1]]<a[d[i+(1<<(j-1))][j-1]])
			{
				d[i][j]=d[i][j-1];
			}
			else 
			{
				d[i][j]=d[i+(1<<(j-1))][j-1];
			}
		}
	}
	dfs(0,n-1);
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 38528
n,w = map(int,input().split())
inf = float("inf")
dp = [[-inf]*(w+1) for _ in range(n+1)]
for j in range(w+1):
    dp[0][j] = 0
for i in range(n):
    s,t = map(int,input().split())
    for l in range(w+1):
        if l-s >=0:
            dp[i+1][l] = max(dp[i][l],dp[i][l-s]+t)
        else:
            dp[i+1][l] = dp[i][l]
print(dp[-1][w])        

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

bool Prime(int num){
  for (int i = 2; i * i <= num; i++){
    if (num % i == 0) return false;
  }
  return true;
}

int main(){
  ll X; cin >> X;
  for (int i = X; i <= int(1e6); i++){
    if (Prime(i)){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin>>N;
    vector<ll> as(N);
    rep(i, N) cin>>as[i];

    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1));
    int i, j;
    rep(i, N) {
        rep(j, N - i) {
            int l = j;
            int r = j + i;
            if ((N + i) % 2 == 0) {  // jiro
                dp[i + 1][j] = min(dp[i][j + 1] - as[l], dp[i][j] - as[r]);
            }
            else {  // taro
                dp[i + 1][j] = max(dp[i][j + 1] + as[l], dp[i][j] + as[r]);
            }
        }
    }
    cout<<dp[N][0]<<endl;
}

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

int n,c0,c1,c2,c3;
string s;
int main()
{
	scanf("%d\n",&n);
	for (int i=1 ; i<=n ; i++)
	{
		cin>>s;
		if (s=="AC") c0++;
		if (s=="WA") c1++;
		if (s=="TLE") c2++;
		if (s=="RE") c3++;
	}
	
	printf("AC x %d\n",c0);
	printf("WA x %d\n",c1);
	printf("TLE x %d\n",c2);
	printf("RE x %d\n",c3);
	return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N, X, Y, Z;
	map<string, set<int>> m;

	cin >> N;
	int in;
	cin >> X;
	for(int i = 0; i < X; i++){
		cin >> in;
		m["a"].insert(in);
	}
	cin >> Y;
	for(int j = 0; j < Y; j++){
		cin >> in;
		m["b"].insert(in);
		if(m["a"].count(in))
			m["ab"].insert(in);
	}
	cin >> Z;
	for(int k = 0; k < Z; k++){
		cin >> in;
		m["c"].insert(in);
		if(m["a"].count(in))
			m["ac"].insert(in);
		if(m["b"].count(in))
			m["bc"].insert(in);
		if(m["a"].count(in) && m["b"].count(in))
			m["abc"].insert(in);
	}

	cout << m["c"].size() - m["ac"].size() + m["abc"].size() << endl;

	return 0;
}


Measured memory_bytes: 3236
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTA(a,n) sort(a,a+n)
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int n;
    cin >> n;
    int a[110];
    int ans = 0;
    REP(i,0,n){
        cin >> a[i];
    }
    //処理
  	SRTAG(a,n);
  	REP(i,0,n){
  	if(i%2==0) ans += a[i];
    else ans -= a[i];
    }
    //出力
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include<stdio.h>

unsigned long long int factorial(int n)
{
	unsigned long long int result = 1;
	while(n != 0){
		result = result * n;
		--n;
	}
	return result;
}

int main(){
	int n;
	scanf("%d",&n);
    printf("%lld\n", factorial(n));
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
    int x,y,cot=0;
    char cloud[102][102];
    cin>>y>>x;
    for(int i=0;i<y;i++){
        for(int j=0;j<x;j++){
            cin>>cloud[i][j];
        }
    }
    for(int i=0;i<y;i++){
        for(int j=0;j<x;j++){
            if(cloud[i][j]=='c'){
                cot=1;
                cout<<"0";
            }
            else if(cot!=0){
                cout<<cot;
                cot++;
            }
            else cout<<"-1";
            if(j!=x-1)cout<<" ";
        }
        cot=0;
        cout<<endl;
    }
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    cin>>k;
    string s="ACL";
    string s1=s;
    for(int i=1;i<k;i++)
    {
        s+=s1;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3640
#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++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll dp[5][100010];
int main(){
    int n;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    rep(i,2){
        rep(j,n) dp[i][j]=-inf;
    }
    dp[0][0]=v[0]+v[1];
    dp[1][0]=-v[0]-v[1];
    rep(j,n-2){
        dp[0][j+1]   =   max(dp[0][j]+v[j+2] , dp[0][j+1]);
        dp[1][j+1]   =   max(dp[0][j]-2*v[j+1]-v[j+2],dp[1][j+1]);
        dp[0][j+1]   =   max(dp[0][j+1],dp[1][j]+v[j+2]);
        dp[1][j+1]   =   max(dp[1][j+1],dp[1][j]+2*v[j+1]-v[j+2]);
    }
    /*
    rep(i,2){
        rep(j,n-1) cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<max(dp[0][n-2],dp[1][n-2])<<endl;
    return 0;
}

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

// study

int main(){
    int n, x[16][16], y[16][16], a[16];
    cin >> n;
    rep(i, n){
        cin >> a[i+1];
        rep(j, a[i+1]){
            cin >> x[i+1][j+1];
            cin >> y[i+1][j+1];
            x[i+1][j+1] --; 
        }
    }

    int ans = 0;
    for (int bit = 1; bit < (1<<n); bit++) {
        bool flag = true;
        for (int i = 1; i <= n; i++){
            if (!(bit & (1 << (i - 1)))) continue;
            for (int j = 1; j <= a[i]; j++){
                if((bit & (1LL << x[i][j])) ^ (y[i][j]<<x[i][j])) flag = false;
//              if(((bit >> x[i][j]) & 1) ^ y[i][j]) flag = false;
            }
        }
        if(flag) ans = max(ans, __builtin_popcount(bit));
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define ull unsigned long long
using namespace std;

ull f(ull n)
{
    ull  cnt = 0;
    for (int i = 5; n>=i; i *= 5)
        cnt += (ull)n/(ull)i;
    return cnt;
}

int main()
{
       ull n;
       cin>>n;
       //ull ans = f(n);
       ull ans = 0 ;
        if(n%2!=0)
        {
            cout<<0<<endl;
        }
        else
        {
            ull cnt2 =0; ull cnt5 = 0 ;
            for(ull i = 2;  i<=n ; i*=2)
            {
                cnt2+=n/i;
            }
            for(ull i = 5;  i<=n ; i*=5)
            {
                cnt5+=(n/i)/2;
            }

            cout<<min(cnt2,cnt5)<<endl;
        }
        return 0;
}


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


void solve(long long A, long long B, long long C, long long D){
  cout << min(A, B) + min(C, D) << "\n";

}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  vi v(5 , 0);
  rep(i,6) {ini(x); v[x]++;}
  int m = -1;
  rep(i,5) amax(m , v[i]);
  out(m == 3 ? "NO" : "YES");
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize,
        x: [u64; n],
    }

    let mut ans = 0;
    for x_ in x {
        ans += 2 * min(x_, k as u64 - x_);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <deque>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;


int solve() {
  ll n;
  string s;
  cin >> n >> s;
  ll r,l;
  r = 0;
  l = 0;
  for(ll i = 0;i < n; i++){
    if(s[i] =='('){
      r++;
    }else{
      if(r == 0){
        l++;
      }else{
        r--;
      }
    }
  }
  string res = "";
  for(ll i = 0;i < l; i++){
    res += '(';
  }
  res += s;
  for(ll i = 0;i < r; i++){
    res += ')';
  }
  cout << res << endl;

  return 0;
}

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


Measured memory_bytes: 256
#endocing: utf-8

n = gets.rstrip.to_i
map = []
n.times { map << [0] * n}
(1..n).each do |node|
  arr = gets.rstrip.split(/\s/).map(&:to_i)
  u, k = arr[0], arr[1]
  node = arr[2..-1]
  node.each { |v| map[u - 1][v - 1] = 1}
end

map.each do |row|
  puts row.join(" ")
end

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

int main()
{
  int K, N;
  long long int sum=0;
  cin>>K>>N;
  unsigned int A[N], x[N];
  for(int i=0; i<N; i++)
    cin>>A[i];
  for(int j=0; j<N; j++)
  { if(j!=N-1) 
      x[j]=A[j+1]-A[j];
    else
      x[j]=(K-A[j])+A[0];      
  }
  sort(x, x+N);
  for(int k=0; k<N-1; k++)
    sum+=x[k];
  cout<<sum;
  return 0;
}

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

signed main() {
  string O, E;
  cin >> O >> E;
  
  string ans;
  for( int i = 0; i < E.size(); i++ ){
    ans.push_back(O.at(i));
    ans.push_back(E.at(i));
    if( O.size() > E.size() && i == E.size()-1){
      ans.push_back(O.at(i+1));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int answer =0;
    for(int i=A;i<=B;i++){
      if(isParin(i)){
        answer++;
      }
    }
    System.out.println(answer);
  }
  
  public static boolean isParin(int n){
    boolean res=false;
    if(n/10000==n%10&&(n/1000)%10==(n/10)%10){
      return true;
    }
    return res;
  }
  

  
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <map>
#define N 200005
#define PI pair<int, int>
#define F first
#define S second
using namespace std;

int n, m1, m2, a1[N], a2[N];
map<PI, int> v;
int f(int p) {
	if (a1[p] == p) return p;
	return a1[p] = f(a1[p]);
}

int g(int p) {
	if (a2[p] == p) return p;
	return a2[p] = g(a2[p]);
}

int main()
{
	int i, t1, t2;
	cin >> n >> m1 >> m2;
	for (i = 1; i <= n; i++) a1[i] = i;
	for (i = 1; i <= n; i++) a2[i] = i;
	while (m1--) {
		scanf ("%d %d", &t1, &t2);
		t1 = f(t1);
		t2 = f(t2);
		if (t1 != t2) a1[t1] =t2;
	}
	while (m2--) {
		scanf ("%d %d", &t1, &t2);
		t1 = g(t1);
		t2 = g(t2);
		if (t1 != t2) a2[t1] =t2;
	}
	for (i = 1; i <= n; i++) {
//			printf("%d %d\n", a1[i], a2[i]);
		t1 = f(a1[i]);
		t2 = g(a2[i]);
		v[PI(t1, t2)]++;
	}
	for (i = 1; i <= n; i++) {
		t1 = f(a1[i]);
		t2 = g(a2[i]);
		printf("%d ", v[PI(t1, t2)]);
	}
    return 0;
}


Measured memory_bytes: 13568
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ConsoleApp1
{
    class Program
    {
        static bool solve(string s)
        {
            // AABB ABAB ABBA の３パターンしかない

            // AAAA　AAABの除外
            if (s[0] == s[1] && s[0] == s[2]) return false;

            //AABB
            if (s[0] == s[1] && s[2] == s[3]) return true;

            //ABAB
            if (s[0] == s[2] && s[1] == s[3]) return true;

            //ABBA
            if (s[0] == s[3] && s[1] == s[2]) return true;

            return false;
        }
        static void Main(string[] args)
        {
          
            string s = Console.ReadLine();

            bool ans = solve(s);

            if (ans)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }


    }
}

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

using namespace std;
int main()
{
    // 整数の入力
    int a, b, c;
    cin >> a >> b >> c;
    
    int max = a * c;
    if( max <= b ) {
        cout << c << endl;
    } else {
        cout << (b / a) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
# A - Remaining Time

# 現在時刻はA時で、コンテストはB時間後に始まる
# コンテストの開始時刻は、24時間表記で何時か？


A,B = map(int,input().split())

answer = A + B

if answer < 24:
    print(answer)
else:
    print(answer - 24)


Measured memory_bytes: 8984
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

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

  vector<pair<int, int>> ab;
  for (int i = 1; i < N; i++)
  {
    for (int j = i + 1; j <= N; j++)
    {
      if (i + j == N / 2 * 2 + 1) continue;
      ab.push_back(make_pair(i, j));
    }
  }
  
  cout << ab.size() << endl;
  for (int i = 0; i < ab.size(); i++)
  {
    cout << ab.at(i).first << " " << ab.at(i).second << endl;
  }
}

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

using namespace std;

int main(){
    long long int N,sum=0;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N+1);
    vector<int> C(N+1);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    B[0] = abs(A[0]);
    B[N] = abs(A[N-1]);

    sum += B[0];
    sum += B[N];

    for(int i=1;i<N;i++){
        B[i] = abs(A[i]-A[i-1]);
        sum += B[i];
    }

    C[0] = abs(A[1]);
    C[N-1] = abs(A[N-2]);

    for(int i=1;i<N-1;i++){
        C[i] = abs(A[i+1]-A[i-1]);
    }

    for(int i=0;i<N;i++){
        cout << sum - B[i] - B[i+1] + C[i] << endl;
    }

}

Measured memory_bytes: 2432
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

int main()
{
  int n;
  scanf("%d",&n);
  if (__builtin_popcount(n) == 1)
  {
    puts("No");
    return 0;
  }
  puts("Yes");
  if (n % 2 == 1)
  {
    FORN(i,2,n)
    {
      printf("%d %d\n",1,i);
      printf("%d %d\n",i,(i^1)+n);
    }
    printf("%d %d\n",3+n,1+n);
  } else 
  {
    FORN(i,2,n-1)
    {
      printf("%d %d\n",1,i);
      printf("%d %d\n",i,(i^1)+n);
    }
    printf("%d %d\n",3+n,1+n);
    FORN(i,2,n-1)
    {
      int x = (n + 1) ^ i;
      if (2 <= x && x < n && x != i)
      {
        printf("%d %d\n",i,n);
        printf("%d %d\n",x,n+n);
        return 0;
      }
    }
    assert(false);
  }
  return 0;
}











Measured memory_bytes: 2304
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 114
	// https://atcoder.jp/contests/abc114/tasks
	static long n;
	static int count = 0;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		n = sc.nextLong();
		dfs(3, true, false, false);
		dfs(5, false, true, false);
		dfs(7, false, false, true);
		System.out.println(count);
	}
	
	private static void dfs(long num, boolean san, boolean go, boolean nana) {
		if (num > n) { return ; }
		dfs(num * 10 + 3, true, go, nana);
		dfs(num * 10 + 5, san, true, nana);
		dfs(num * 10 + 7, san, go, true);
		
		if (san && go && nana) {
			count++;
		}
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


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

const int MAXN = 1000 * 1000 + 10;
const long long INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;

long long mod = 1000 * 1000 * 1000 + 7;

int n, w;
long long weight[200], value[200];

long long dp[200][MAXN]; // dp [number of items][total value]
long long sum;


void update(int items)
{
    //cerr << "item " << items << endl;

    for(int i = 0; i < value[items]; i++) dp[items][i] = dp[items - 1][i];

    for(int i = value[items]; i <= sum; i++){
        long long ans1, ans2;
        ans1 = weight[items] + dp[items - 1][i - value[items]];
        ans2 = dp[items - 1][i];

        if(ans2 == -1) ans2 = INF;
        if(dp[items - 1][i - value[items]] == -1) ans1 = INF;
        dp[items][i] = min(ans1, ans2);

        //cerr << "i " << i << ' ' << ans1 << ' ' << ans2<< endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //cout << fixed << setprecision(15);


    cin >> n >> w;
    sum = 0;

    for(int i = 0; i < n; i++){
        cin >> weight[i] >> value[i];
        sum += value[i];
    }

    for(int j = 0; j < n; j++){
        for(int i = 0; i <= sum; i++) dp[j][i] = INF;
    }


    dp[0][value[0]] = weight[0];
    dp[0][0] = 0;

    for(int i = 1; i < n; i++) update(i);

    long long ans = 0;

    for(int i = sum; i >= 0; i--){
        if(dp[n - 1][i] != INF and dp[n - 1][i] <= w){
            ans = i;
            break;
        }
    }

    cout << ans << endl;


    return 0;
}



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

int main() {
  int N;
  cin >> N;
  
  vector<string> blue(N);
  for(int i=0; i<N; i++)
    cin >> blue.at(i);
  
  int M;
  cin >> M;
  
  vector<string> red(M);
  for(int i=0; i<M; i++)
    cin >> red.at(i);
  
  int max=0;
  
  for(int i=0; i<N; i++){
    int x=0;
    
    for(int j=0; j<N; j++)
      if(blue.at(j)==blue.at(i))
         x++;
    for(int j=0; j<M; j++)
      if(red.at(j)==blue.at(i))
         x--;
    
    if(max<x) max=x;
  }
  cout << max << endl;
}

Measured memory_bytes: 256