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

int main(void){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (d >= abs(a - c) || (d >= abs(a - b) && d >= abs(b - c))) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define ll long long
using namespace std;

int main(void){
    long long n,s[101],b[101],sum=0,k=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s[i];
        sum += s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;i++){
        if(sum % 10 == 0){
            sum -= s[i];
            b[k++] = s[i];
        }
    }
    for(int i=0;i<k;i++){
    	int tmp = sum + b[i];
    	if(tmp % 10 != 0){
    		sum += b[i];
    	}
    }
    cout << sum << endl;
    return 0;
}

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

namespace AirportName
{
    class AirportCode 
    {
        private static string EditName(string name, int k)
        {
            var nameChar = name.ToCharArray();
            var vowels = new List<char>() { 'a', 'i', 'u', 'e', 'o' };
            string editName = nameChar[0].ToString();

            for(int i= 1; i < nameChar.Length && editName.Length < k; i++)
            {
                if (vowels.Contains(nameChar[i - 1]))
                    editName += nameChar[i];
            }

            return editName;

        }

        private static bool notOptimalNames(string[] portNames)
        {
            var distinctPort = portNames.Distinct().ToArray();
            if (distinctPort.SequenceEqual(portNames))
                return false;
            else
                return true;
        }

        private static int GetOpNum(string[] portNames)
        {
            int longestLg = portNames.Select(name => name.Length).Max();
            var editNames = new string[portNames.Length];
            int l = 0;

            while (notOptimalNames(editNames))
            {
                l++;
                if (l > longestLg)
                    return -1;

                editNames = portNames.Select(name => EditName(name, l)).ToArray();
            }

            return l;
        }
        public static void Main(string[] args)
        {
            var opNums = new List<int>();
            int portCount;
            while(0!= (portCount=int.Parse(Console.ReadLine())))
            {
                var portNames = new string[portCount];
                for (int i= 0; i< portCount; i++)
                {
                    portNames[i] = Console.ReadLine();
                }

                opNums.Add(GetOpNum(portNames));


            }

            foreach(var k in opNums)
            {
                Console.WriteLine(k);
            }
        }
    }
}

Measured memory_bytes: 10628
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int(): return int(input())

def map_int_input(): return map(int, input())

MII = map_int_input

def MII_split(): return map(int, input().split())

def MII_to_index(): return map(to_index, input())

def MII_split_to_index(): return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs(): return list(map(int, input()))

LII = list_int_inputs

def LII_split(): return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

N = input_int()
S, T = input().split()
ans = ''
for i in range(N):
    ans += S[i] + T[i]
print(ans)

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << 1. * w * h / 2 << " ";
    if (2 * x == w && 2 * y == h)cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  ll ans=0;
  rep(i,0,2){
    if(a>b) {
      ans+=a;
      a--;
    }
  else{
      ans+=b;
      b--;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	long long int n;
	cin >> n;
	long long int ans = 0;
	for(int i=1;i<=n;i++){
		if(i%3 != 0 && i%5 != 0){
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int m=0, cnt=0;
  for(int i=0; i<n; i++){
    int h;
    cin >> h;
    if(h>=m){
      cnt++;
      m=h;
    }
  }
  cout << cnt;
  return 0;
}

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

namespace ABC_prac
{
    public class Program
    {
        #region templete

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }
        /// <summary>
        /// 最小公約数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
        public static void Main(string[] args)
        {
            new Program().Solve();
            Read();
        }

        #endregion

        public void Solve()
        {
            var s = Read();
            var t = Read();

            var ss = s;

            for (int i = 0; i < s.Length; i++)
            {
                if (ss == t)
                {
                    WriteLine("Yes");return;
                }
                ss = ss.Substring(s.Length - 1, 1) + ss.Substring(0, s.Length - 1);
            }

            WriteLine("No");
        }
    }
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

template<class T> void YES(T condition){ if(condition) OUT("YES"); else OUT("NO"); }
template<class T> void Yes(T condition){ if(condition) OUT("Yes"); else OUT("No"); }
template<class T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

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

const int MOD=1e9+7;

int main() {
  int N,T;cin>>N>>T;
  vector<P> dishes,dishes_rev;
  REP(i,N) {
    int A,B;cin>>A>>B;
    dishes.push_back({A,B});
    dishes_rev.push_back({A,B});
  }
  reverse(ALL(dishes_rev));

  // 最初からi番目までの皿まで選べる時、jまでの間に食べれる最大値
  // T-1が最大
  // N=0~N-1までわかればいい
  vector<vector<ll>> dp1(N+1,vector<ll>(T,0));
  // i番目から最後までの皿まで選べる時、jまでの間に食べれる最大値
  // N=2~N+1までわかればいい
  vector<vector<ll>> dp2(N+2,vector<ll>(T,0));
  // dp1の1~Nを埋める
  REP(i,N) {
    int a,b;
    tie(a,b) = dishes[i];
    REP(t,T) {
      dp1[i+1][t] = dp1[i][t];
      if (t>=a) mmax(dp1[i+1][t],dp1[i][t-a]+b);
    }
  }
  REP(i,N) {
    int a,b;
    tie(a,b) = dishes_rev[i];
    REP(t,T) {
      dp2[i+1][t] = dp2[i][t];
      if (t>=a) mmax(dp2[i+1][t],dp2[i][t-a]+b);
    }
  }
  reverse(ALL(dp2));
  
  vector<ll> maxs(N,0);
  REP(i,N) {
    REP(t,T) {
      mmax(maxs[i],dp1[i][t]+dp2[i+2][T-1-t]);
    }
  }

  ll ans = 0;
  REP(i,N) {
    mmax(ans, maxs[i]+dishes[i].second);
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 141312
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void RatedforMe() {
	int R;
	cin >> R;
	if (R < 1200) {
		cout << "ABC";
	}
	else if (R < 2800) {
		cout << "ARC";
	}
	else {
		cout << "AGC";
	}
}
int main() {
	RatedforMe();
	return 0;
}

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

int main() {
  int N, d[109];
  set<int> values;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> d[i];
    values.insert(d[i]);
  }
  
  cout << values.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<queue>
#include<set>
#include<vector>
#include<cmath>
#include<ctime>
#include<locale>
using namespace std;
int main()
{
    long a,b,c;
    cin>>a>>b>>c;
    c=c+a*100+b*10;
    if(c%4==0)cout<<"YES";
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;

int main() {
	string s;
	cin >> s;
	s[5] = ' ';
	s[13] = ' ';
	print(s);
}

Measured memory_bytes: 256
k=int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[k-1])

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

using namespace std;

int main(int argc,char* argv[]){
	string S;
	bool flag = true;
	cin >> S ;
	for(int i=0;i<S.length();i++){
		if(i%2==0) {
			if(S[i]=='R'||S[i]=='U'||S[i]=='D') continue;
			else flag = false;
		}else {
			if(S[i]=='L'||S[i]=='U'||S[i]=='D') continue;
			else flag = false;
		}
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

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

  if(N == 1){
    std::cout << "Hello World" << std::endl;
  }
  else if(N == 2){
    int A, B;
    std::cin >> A;
    std::cin >> B;

    std::cout << A+B << std::endl;
  } else{
    return 1;
  }

  return 0;
}


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

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))


using namespace std;


typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 
typedef long double LD;


LL gcd(LL x, LL y){
	if(x<y) swap(x,y);
	if(!y) return x;
	return gcd(y, x%y);
}


int main(){
	LL N, ans = 1;
	cin>>N;
	for(LL i=0;i<N;++i){
		LL T;
		cin>>T;
		LL m = gcd(ans, T);
		ans = (ans/m)*T;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	if (s.length() == 2) {
		cout << s << endl;
	}
	else {
		for (int i = s.length() - 1; i >= 0; i--) {
			cout << s[i];
		}
		cout << endl;
	}


	return 0;
}

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

using namespace std;
#define ll long long
const int maxn = 1e5 + 100;
ll s[maxn][8];
ll cum[maxn];
vector < pair < ll , ll > > arr;
ll dp[maxn][8];
ll n , p , k;

ll solve(int i , int d){
    if(d == p){
        ll nei = abs(i-d+1);
        ll d = n - (p+k);
        if(nei>d)
            return (-1e18);
        ll hm = abs(nei-d);
        cout << i << " " << d << " " << p << endl;
        return cum[n-1]-cum[i+hm-1];
    }
    if(i == n){
        return (-1e18);
    }
    ll &ret = dp[i][d];
    if(ret != -1)return ret;
    ret = max( s[arr[i].second][d] + solve(i+1,d+1) , solve(i+1,d) );
    return ret;
}

int main()
{
    ll n, m, k, a = 0, b = 0;
    cin>>n>>a>>b;
    if(n <= a) cout<<n<<"\n";
    else cout<<a*(n/(a + b)) + min(n % (a + b), a)<<"\n";
    return 0;
}


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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n;
    cin >> n;
    ll res = n-1;
    for(ll i=1; i*i<=n; i++){
        if(n%i == 0){
            res = min(res, n/i+i-2);
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
	int N, M;
	int a, b;
	int road[50][50];
	for(int i = 0; i < 50; i++){
		for(int j = 0; j < 50; j++) road[i][j] = 0;
	}
	scanf("%d %d", &N, &M);
	for(int i = 0; i < M; i++){
		scanf("%d %d", &a, &b);
		a--, b--;
		road[a][b]++, road[b][a]++;
	}
	for(int i = 0; i < N; i++){
		int ans = 0;
		for(int j = 0; j < N; j++){
			ans += road[i][j];
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

int compare_int(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}

int main()
{
    int n, k, p[2000], ans = 0;

    cin >> n >> k;
    rep(i, n) cin >> p[i];

    qsort(p, n, sizeof(int), compare_int);

    rep(i, k) ans += p[i];

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

ll A, B;

int main() {
    cin >> A >> B;
    
    ll ans = (A+B)/2;
    if ((A+B)%2==1) {
        cout << "IMPOSSIBLE" << endl;
        return 0;        
    }
    if (ans ==(A+B)/2) {
        cout << ans << endl;
        return 0;
    }    
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = Array.new(60, 0)
b = gets.split.map(&:to_i)
n.times do |i|
  60.times do |j|
    a[j] += b[i][j]
  end
end
sum = 0
60.times do |i|
  sum += a[i] * (n - a[i]) * 2 ** i
  sum %= 1_000_000_007
end
puts sum

Measured memory_bytes: 37148
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <sstream>
using namespace std;

#define LL long long
const LL MOD = 1000000007;
const int maxn = 1000 + 100;
int n, m;
int row[maxn], col[maxn];
bool visr[maxn * maxn], visc[maxn * maxn];

int main() {
    #ifdef Dmaxiya
    freopen("test.txt", "r", stdin);
    #endif // Dmaxiya
    ios::sync_with_stdio(false);

    while(scanf("%d%d", &n, &m) != EOF) {
        bool flag = true;
        memset(visr, 0, sizeof(visr));
        memset(visc, 0, sizeof(visc));
        for(int i = 0; i < n; ++i) {
            scanf("%d", &row[i]);
            if(visr[row[i]]) {
                flag  = false;
            }
            visr[row[i]] = true;
        }
        for(int j = 0; j < m; ++j) {
            scanf("%d", &col[j]);
            if(visc[col[j]]) {
                flag = false;
            }
            visc[col[j]] = true;
        }
        if(!flag) {
            printf("0\n");
            continue;
        }
        sort(row, row + n);
        sort(col, col + m);
        LL ans = 1;
        for(int i = n * m; i >= 1; --i) {
            if(visr[i] && visc[i]) {
                continue;
            }
            LL r, c;
            r = n - (upper_bound(row, row + n, i) - row);
            c = m - (upper_bound(col, col + m, i) - col);
            if(visc[i]) {
                ans = ans * r % MOD;
//                cout << "i = " << i << " ans = " << ans << endl;
                continue;
            }
            if(visr[i]) {
                ans = ans * c % MOD;
//                cout << "i = " << i << " ans = " << ans << endl;
                continue;
            }
            ans = ans * (r * c - (n * m - i)) % MOD;
//            cout << "i = " << i << " ans = " << ans << endl;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2688
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize,
        v: [[usize; n]; n]
    }
    let d = 1000000007;
    let ans = matpow_m(&v, k, d).iter().map(|x| x.iter().fold(0, |ac, y| (ac + y) % d)).fold(0, |ac, x| (ac + x) % d);
    println!("{}", ans);
}

fn matpow_m(m: &Vec<Vec<usize>>, mut p: usize, d: usize) -> Vec<Vec<usize>> {
    let n = m.len();
    let mut ret = vec![vec![0; n]; n];
    let mut r = m.to_vec();
    for i in 0..n {
        ret[i][i] = 1;
    }
    while p > 0 {
        if p % 2 == 0 {
            r = matmat_m(&r, &r, d);
            p /= 2;
        } else {
            ret = matmat_m(&ret, &r, d);
            p -= 1;
        }
    }
    ret
}

fn matmat_m(a: &Vec<Vec<usize>>, b: &Vec<Vec<usize>>, d: usize) -> Vec<Vec<usize>> {
    let l = a.len();
    let m = b.len();
    let n = b[0].len();
    let mut c = vec![vec![0; l]; n];
    for i in 0..l {
        for j in 0..m {
            for k in 0..n {
                c[i][k] = (c[i][k] + a[i][j] * b[j][k]) % d;
            }
        }
    }
    c
}


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

int main(){					

	int x, y, w, h, r;

	cin >> w >> h >> x >> y >> r;

	if ((x <= w - r) && (x >= r) && (y <= h - r) && (y >= r)) cout << "Yes" << endl;

	else cout << "No" << endl;

	return 0;
}


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

long solve(int k, int a, int b) {
    int diff = b - a;
    if (diff <= 2) {
        return 1 + k;
    }
    return 1 + k + ((k - a + 1) / 2) * ((long) diff - 2);
}

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    cout << solve(k, a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int [] d = new int [N];
        for(int i=0;i<N;i++){
            d[i] = scan.nextInt();
        }
        quick_sort(d,0,N-1);
        if(d[(N/2)-1]==d[N/2]){
            System.out.println("0");
        }else{
            System.out.println(d[N/2]-d[(N/2)-1]);
        }
    }
    static void quick_sort(int[] d, int left, int right) {
        if (left >= right) {
            return;
        }
        int p = d[(left + right) / 2];
        int l = left, r = right, tmp;
        while (l <= r) {
            while (d[l] < p) {
                l++;
            }
            while (d[r] > p) {
                r--;
            }
            if (l <= r) {
                tmp = d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++;
                r--;
            }
        }
        quick_sort(d, left, r);
        quick_sort(d, l, right);
    }
}

Measured memory_bytes: 50484
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;

int main()
{
    string x;
    cin >> x;
    bool res = true;
    for (int i = 0; i < x.size(); i += 2) {
        if (x[i] == 'L' || x[i + 1] == 'R') {
            res = false;
            break;
        }
    }
    if (res) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
    var n int
    fmt.Scan(&n)
    
    sc.Split(bufio.ScanWords)
    a := []int{}
    for i := 0; i < n; i++ {
        tmp := nextInt()
        a = append(a, tmp)
    }

    a_sum := 0
    b_sum := 0
    sort.Sort(sort.Reverse(sort.IntSlice(a)))
    for i := 0; i < n - 1; i += 2 {
        a_sum += a[i]
        b_sum += a[i + 1]
    }
    if n % 2 != 0 {
        a_sum += a[n - 1]
    }

    fmt.Println(a_sum - b_sum)
}

Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    K = int(input())
    ans = 10**18
    for i in range(1 << N):
        val = 1
        for j in range(N):
            if i & (1 << j):
                val *= 2
            else:
                val += K
        ans = min(ans, val)
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	ll ans = 0;
	vector<ll> a(n + 1), b(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, n - 1)cin >> b[i];
	rep(i, 0, n - 1)
	{
		ll x, y, z;
		x = a[i];
		y = b[i];
		z = b[i] - a[i];
		ans += min(x, y);
		if (z > 0)
		{
			ans += min(a[i + 1], z);
			a[i + 1] = max(0LL, a[i + 1] - z);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <complex.h>
#include <fenv.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	if(n==1) n=14;
	if(m==1) m=14;
	if(n>m)
	{
		cout<<"Alice"<<endl;
		return 0;
	}else if(m>n){
		cout<<"Bob"<<endl;
		return 0;
	}
	cout<<"Draw"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dl cout<<"LINE"<<__LINE__<<endl;
#define dbg(x) cout<<#x<<" = "<<x<<endl; 
using namespace std;
int main(){
	int a=0,b=0;
	for(int i=1;i<=3;i++){
		char c;
		cin>>c;
		if(c=='A')a=1;else b=1;
	}
	if(a==b==1)cout<<"Yes"<<endl;else cout<<"No"<<endl;
	return 0;
}

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

const int N = 200005;

int n, m;
vector<int> G[N];

bool vis[N];
int dis[N];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }

  queue<int> q;
  q.push(1);
  vis[1] = true;
  dis[1] = 0;
  while (!q.empty()) {
    int v = q.front(); q.pop();
    for (int i = 0; i < G[v].size(); i++) {
      int u = G[v][i];
      if (!vis[u]) {
        vis[u] = true;
        dis[u] = dis[v] + 1;
        q.push(u);
      }
    }
  }

  if (dis[n] == 2) puts("POSSIBLE");
  else puts("IMPOSSIBLE");

  return 0;
}


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

int main() {
  // Failed to predict input format
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  cout << a[0] * a[1] / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{

     public static void main(String []args){
        
        Scanner scan = new Scanner(System.in) ;
        int n =scan.nextInt();
        int x = scan.nextInt();
        int arr[] = new int[n];
        int sum = 0 ;
        int min = 99999 ;
        for(int i = 0 ; i<n ; i++){
            arr[i] = scan.nextInt();
            sum+=arr[i] ;
            if(arr[i] < min){
                min = arr[i] ;
            }
        }
        
        int rest = x - sum ;
        int possible = rest/min ;
        System.out.println(possible+n);
        
     }
}

Measured memory_bytes: 22740
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        //Solution sol = new Solution();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        List<Integer> adj[] = new List[n+1];
        for(int i=0; i<=n; i++) {
            adj[i] = new ArrayList();
        }
        for(int i=1; i<n; i++) {
            int boss = sc.nextInt();
            adj[boss].add(i);
        }

        for(int i=1; i<=n; i++) {
            System.out.println(adj[i].size());
        }
    }
}



Measured memory_bytes: 80140
#include <bits/stdc++.h>
#define ll long long


using namespace std;

const ll mod = 1e9 + 7;

vector<int> filho[100005];
ll dp[100005][2];


ll dfs(int pai, int cor, int pos)
{

	if(dp[pos][cor] > 0)
		return dp[pos][cor];

	for (int i = 0; i < (int)filho[pos].size(); ++i)
	{
		int viz = filho[pos][i];
		ll valor = 0;
		if(viz != pai)
		{
			if(cor == 0) // put color = white
			{
				valor += (dfs(pos, 0, viz) % mod);
				valor += (dfs(pos, 1, viz) % mod);
			}
			else if(cor == 1) // put color = black
			{
				valor += (dfs(pos, 0, viz) % mod);
			}

			if(dp[pos][cor] == 0)	
				dp[pos][cor] = valor;
			else
				dp[pos][cor] = (dp[pos][cor] * valor) % mod;
		}
		
	}

	if(dp[pos][cor] == 0)
		return dp[pos][cor] = 1;
	
	return dp[pos][cor];

}



	

int main()
{

	int n, u, v;
	cin >> n;

	
	memset(dp, 0, sizeof(dp));

	for (int i = 0; i < n - 1; ++i)
	{
		cin >> u >> v;

		filho[u].push_back(v);
		filho[v].push_back(u);
	}

	ll resp = (dfs(-1, 0, 1) + dfs(-1, 1, 1)) % mod;

	

	cout << resp << endl;





    return 0;
}

Measured memory_bytes: 20280
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;


class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    List<int>[] es;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int A = cin.nextInt();

        long[] dp = new long[10000];
        dp[5000] = 1;
        for (int i = 0; i < N; i++)
        {
            int diff = cin.nextInt() - A;
            long[] nextdp = (long[])dp.Clone();
            for (int j = 0; j < 10000; j++)
            {
                if (dp[j] == 0) continue;
                nextdp[j + diff] += dp[j];
            }
            dp = nextdp;
        }
        Console.WriteLine(dp[5000] - 1);
    }

}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 15072
n,m = map(int,input().split())
ac = [0] * (n+1)
wa = [0] * (n+1)
lst = []
for _ in range(m):
    p,s = map(str,input().split())
    lst.append([p,s])
    
for i in range(m):
    result = lst[i][1]
    q = int(lst[i][0])
    if result == 'AC' and ac[q] == 0:
        ac[q] += 1
    elif result == 'WA' and ac[q] == 0:
        wa[q] += 1
        
for i in range(n+1):
    if ac[i] != 1:
        wa[i] = 0
        
print(sum(ac),sum(wa))

Measured memory_bytes: 25844
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

D = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for _ in range (D)]
M = 26
INF = 10**20

ans = [0]*D
lasts = [0]*(M+1)

score = 0
for i in range(D):
    contest = 0
    max_score = -INF
    for m in range(M):
        new_score = score
        new_score += S[i][m]
        for m2 in range(M):
            if m==m2:continue
            new_score -= C[m2]*(i+1-lasts[m2])
        if new_score>max_score:
            contest = m+1
            max_score = new_score
    
    ans[i] = contest
    lasts[contest-1] = i+1
    score = max_score

for a in ans:
    print(a)

Measured memory_bytes: 68768
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI acos(-1) 
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define eb(a) emplace_back(a)
#define print(x) for(auto it:x) cout<<it<<' '; cout<<"\n";

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

int main()
{
	FAST_IO ;
	ll i,j,k,n;
	ll count = 0;
	double d;
	cin >> n >> d;
	for(i=0;i<n;++i)
	{
		cin >> j >> k;
		double dis ;
		dis = sqrt(j*j + k*k) ;
		if(dis<=d)
			count++ ;
	}
	cout << count endl ;
	return 0;
}

/*
If u haven't come up with an approach yet ,skip this one
  Try this when feeling stuck -
  1. Int overflow, array bounds
  2. Special cases (n=1?)
  3. Prove your approach to yourself(mathematical induction,counter-intuitive or stronger test cases)
  4. Calm down and don't look at standings and stop thinking about rating and think about the question
  5. Just do it! 
*/ 

//Benq's advice - 
/* 
	And following advices are must for me -
	* do something instead of nothing and stay organized
	* WRITE STUFF DOWN 
*/

//#define _GLIBCXX_DEBUG 
// It will convert WA verdict to runtime error if that error is caused due to out of bound excess , declare it at the top
//#pragma GCC optimize "trapv" 
// It will convert WA to runtime error if WA was caused due to int overflow error,declare it anywhere

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<string> a(n);
    REP(i,n)cin >> a[i];
    int32 ans = inf;
    vector<bool> isAllBlack(n); //列jが全て黒かどうか
    REP(j,n){
        bool flg = true;
        REP(i,n){
            if(a[i][j] == '.')flg = false;
        }
        isAllBlack[j] = flg;
    }
    bool allWhite = true;
    REP(i,n)REP(j,n){
        if(a[i][j] == '#')allWhite = false;
    }
    if(allWhite){
        ANS(-1);
        return 0;
    }
    REP(i,n){   //最初に全部黒くする行
        int32 cand = 0;
        bool flg = false;
        REP(k,n){   //a[i][j]を黒くするのに使う行
            if(a[k][i] == '#'){
                flg = true;
            }
        }
        if(!flg){
            ++cand;
        }
        REP(j,n){
            if(isAllBlack[j])continue;
            if(a[i][j] == '.'){
                ++cand;
            }
        }
        REP(j,n){
            if(!isAllBlack[j])++cand;
        }
        chmin(ans, cand);
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int64_t hoge(int64_t n) {
    return n >= 0 ? n : n * (-1);
}

int main(void) {
    int N;
    cin >> N;
    std::vector<int> num(N + 1, 0);
    int m1;
    for (int i = 1; i <= N; i++) {
        cin >> m1;
        num[i] = m1 - i;
    }
    std::sort(++num.begin(), num.end());
    int mid = (N + 1) / 2;
    int b   = num[mid];

    int64_t result = 0;
    for (int i = 1; i <= N; i++) {
        result += hoge(num[i] - b);
    }

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 1024
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll a[3001];
ll n;
pair<ll,ll> dp[3001][3001][2];
pair<ll,ll> solve(ll i,ll j,ll f)
{
	if(i>j) return mp(0,0);
	if(dp[i][j][f].fi!=-1) return dp[i][j][f];
	pair<ll,ll> ans1=solve(i+1,j,(f+1)%2);
	if(f==0) ans1.fi+=a[i];
	else ans1.se+=a[i];
	pair<ll,ll> ans2=solve(i,j-1,(f+1)%2);
	if(f==0) ans2.fi+=a[j];
	else ans2.se+=a[j];
	if(f==0&&ans1.fi-ans1.se<=ans2.fi-ans2.se) return dp[i][j][f]=ans2;
	if(f==0&&ans1.fi-ans1.se>=ans2.fi-ans2.se) return dp[i][j][f]=ans1;
	if(f==1&&ans1.fi-ans1.se<=ans2.fi-ans2.se) return dp[i][j][f]=ans1;
	if(f==1&&ans1.fi-ans1.se>=ans2.fi-ans2.se) return dp[i][j][f]=ans2;
}
int main()
{
	boost
	for(ll i=0;i<3001;i++)
	{
		for(ll j=0;j<3001;j++)
		{
			for(ll k=0;k<2;k++)
			{
				dp[i][j][k]=mp(-1,-1);
			}
		}
	}
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	pair<ll,ll> tmp = solve(0,n-1,0);
	cout<<tmp.fi-tmp.se<<endl;
	return 0;
}

Measured memory_bytes: 281984
#![allow(dead_code, unused_imports, deprecated)]
 
use std::collections::HashMap;
use std::cmp::Reverse;
 
use proconio::input;
use proconio::marker::*;

fn main() {
  input!{
    n: usize,
    s: Bytes,
  };

  let mut res = 0;
  if n > 3 {
    let mut dp: HashMap<_, _> = HashMap::new();
    dp.entry(b'R').or_insert(vec![0usize; n]);
    dp.entry(b'G').or_insert(vec![0usize; n]);
    dp.entry(b'B').or_insert(vec![0usize; n]);

    dp.entry(s[n - 1]).and_modify(|e|
      e[n - 1] += 1
    );

    for i in (0..(n - 1)).rev() {
      for &c in ([b'R', b'G', b'B']).into_iter() {
        dp.entry(c)
          .and_modify(|e|
            e[i] = e[i + 1] + if c == s[i] { 1 } else { 0 }
          );
      }
    }

    let rest = |ca: u8, cb: u8| -> u8 {
      let s = b'R' as usize + b'G' as usize + b'B' as usize;
      (s - ca as usize - cb as usize) as u8
    };
    for i in 0..(n - 1) {
      for j in i..n {
        if s[i] != s[j] && j + 1 < s.len() {
          res += dp[&rest(s[i], s[j])][j + 1];
          if j + (j - i) < s.len() && rest(s[i], s[j]) == s[j + (j - i)] {
            res -= 1;
          }
        }
      }
    }
  }
  
  println!("{}", res);
}

Measured memory_bytes: 2240
/* ex6_2
   kohei_suzuki */
/*足したり引いたり*/
#include <stdio.h>
#include <string.h>

#define SIZE 256

int main(void){
    int lenth; //i,単語の長さ
    char word[SIZE]; //単語の文字型配列

    scanf("%s",word); //入力受取
    lenth = strlen(word);

    putchar(word[0]);
    printf("%d",lenth-2);
    putchar(word[lenth-1]);

    putchar('\n');
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int rd(){
    int x=0,fl=1;char ch=gc();
    for (;ch<48||ch>57;ch=gc())if(ch=='-')fl=-1;
    for (;48<=ch&&ch<=57;ch=gc())x=(x<<3)+(x<<1)+(ch^48);
    return x*fl;
}
int a[10002],b[10001],i,j,cnt,n;
int main(){
	n=rd();
	if (n&1){
		for (i=1;i<=n;i++)
			for (j=i+1;j<=n;j++)
				if (j!=n-i) a[++cnt]=i,b[cnt]=j;
	}else{
		for (i=1;i<=n;i++)
			for (j=i+1;j<=n;j++)
				if (j!=n+1-i) a[++cnt]=i,b[cnt]=j;
	}
	printf("%d\n",cnt);
	for (i=1;i<=cnt;i++) printf("%d %d\n",a[i],b[i]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) 				for(int i=0; i<(n); ++i)
#define all(c) 					(c).begin(),(c).end()
#define sortall(x)              sort(all(x))
#define tr(c,i) 				for( typeof( (c).begin() ) i = (c).begin();  i != (c).end(); ++i)
#define pb 						push_back
#define sz(a) 					int((a).size())
#define mp                      make_pair
#define ll                      long long
#define F                       first
#define S                       second
#define PI                      3.1415926535897932384626
// Input macros
#define s(n)                    scanf("%d",&n)
#define sc(n)                   scanf("%c",&n)
#define sl(n)                   scanf("%lld",&n)
#define sf(n)                   scanf("%lf",&n)
#define ss(n)                   scanf("%s",n)

// Others
#define test(t) 				int t; cin>>t; while(t--)
#define endl 					"\n"

using namespace std;

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

// const int mod = 1000000007;
// const int INF = 1e9+5;

void Ginput(vector<int>* G, int noOfEdges){
	while(noOfEdges--){
		int u,v;
		scanf("%d%d",&u,&v);
		G[u-1].push_back(v-1); 
	}
}

int DFS(int u, vector<int>* G, vector<int>& height, vector<bool>& vis){

	if(height[u] != -1){
		return height[u];
	}

	if(!G[u].size()){
		return 0;
	}

	vis[u] = true;
	int curr_height;
	for( int v : G[u] ){
			curr_height = DFS(v, G, height, vis);
			height[u] = max(height[u], curr_height + 1);
	}
	
	return height[u];
}
		

	

int main(){
	
     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
     
     int n,m;
     scanf("%d%d",&n,&m);
     
     // adjacency list
     
     vector<int>* G = new vector<int>[n];
     
     Ginput(G, m);
     
     vector<int> height(n,-1);
     vector<bool> vis(n, false);
     
     for(int i=0 ; i<n ; i++){
		 if(!vis[i])
			DFS(i, G, height, vis);
	 }
	 
	 int ans = 0;
	 for(int h : height){
		 ans = max(ans, h);
	 }
	 
	 printf("%d\n", ans);
          

     return 0;

}
	
	









Measured memory_bytes: 12028
import java.io.IOException;
import java.util.InputMismatchException;

public class Main {
	void run() {
		MyScanner sc = new MyScanner();

		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if ((n | m) == 0) {
				break;
			}
			int[] a = sc.nextIntArray(n);
			int[] b = sc.nextIntArray(m);

			int[] ha = new int[21];
			int[] hb = new int[21];
			for (int i = 0; i < n; i++) {
				ha[a[i]]++;
			}
			for (int i = 0; i < m; i++) {
				hb[b[i]]++;
			}
			int[] h = new int[21];
			for (int i = 0; i < 21; i++) {
				h[i] = Math.max(ha[i], hb[i]);
			}
			int sum = 0;
			for (int i = 0; i < 21; i++) {
				sum += i * h[i];
			}
			System.out.println(sum);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 17028
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll inf = (1 << 29);
template<typename T>
T GCD(T a, T b) {
	while (max(a, b) % min(a, b)) {
		if (a > b)a = a % b;
		else b = b % a;
	}
	return min(a, b);
}
template<typename T>
T LCM(T a, T b) {
	return a / GCD(a, b)*b;
}
bool prime(ll a) {
	for (int i = 2; i <= sqrt(a); i++) {
		if (!(a%i))return false;
	}
	return true;
}
bool f[10][10];
int n, m, a, b, v[10], answer = 0;
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++)v[i] = i;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		f[a][b] = true;
		f[b][a] = true;
	}
	do {
		bool ans = true;
		for (int i = 2; i <= n; i++) {
			if (!f[v[i - 1]][v[i]])ans = false;
		}
		if (ans)answer++;
	} while (next_permutation(v + 2, v + n + 1));
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  long long int H;
  long long int ans=0LL,c=1LL;
  scanf("%lld",&H);
  while(H>0){
    H/=2LL;
    ans+=c;
    c*=2LL;
  }
  printf("%lld\n",ans);
  return 0;
}

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

int main(){
	int n; scanf("%d", &n);
	vector<ll> a(n);
	for(int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
	}
	ll ans = 0, num = a[0];
	for(int i = 1; i < n; i++){
		if(a[i] >= num) num = a[i];
		else ans += (num - a[i]); 
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4816