akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cerr << (#x) << " is " << (x) << endl
#define INF 1e13
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
bool check(ll i,ll j,ll n){return (i>=0 && i<n && j>=0 &&  j<n);} //matrix boundary checking
 
 
ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
 
// max({a, b, c, d})
// cout << fixed for removing e notation
 
bool comp(pair<ll, ll>a, pair<ll, ll>b)
{
    if(a.se-a.fi < b.se-b.fi) return true;
    else return false;
}
 
void convert(int arr[], int n) 
{ 
    int temp[n+1];
    for(int i=1;i<=n;i++)
        temp[i] = arr[i]; 
    // memcpy(temp, arr, n*sizeof(int)); 
  
    sort(temp+1, temp+n+1);   
    unordered_map<int, int> umap;
    int val = 1; 
    for (int i = 1; i <= n; i++) 
        umap[temp[i]] = val++;
    for (int i = 1; i <= n; i++) 
        arr[i] = umap[arr[i]]; 
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
}

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

    map<int, int>ans;
    int tc = 0, tp = 0;
    while(m--)
    {
        int x;
        string s;
        cin >> x >> s;

        if(ans[x] != -1)
        {
            if(s == "WA") ans[x]++;
            else
            {
                tp += ans[x];
                tc++;
                ans[x] = -1;
            }
        }
        else
        {
            // if(s == "AC") tc++;
        }
    }

    cout << tc << " " << tp << "\n";
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 5;

int main(){
    long long n , k;
    cin>>n>>k;
    long long a[n] , dp[n];
    for(int i = 0; i < n; i++){
        cin>>a[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    for(long long i = 1; i < n; i++){
        // cout<<i<<" -> ";
        for(long long j = i - 1; j >= max(i - k , (long long)0); j--){
            // cout<<j<<" ";
            dp[i] = min(dp[i] , dp[j] + abs(a[i] - a[j]));
        }
        // cout<<dp[i]<<endl;
    }
    cout<<dp[n - 1];
}

Measured memory_bytes: 5200
n=int(input())
s=[input()[0] for _ in range(n)]
a=['M','A', 'R', 'C', 'H']
import itertools
num=[0]* 5
for i in range(5):
    num[i]=s.count(a[i])
ans=0
if num.count(0)<=2:
    m=[x for x in num if x > 0]
    p=list(itertools.combinations(m, 3))
    for j in range(len(p)):
        ans+=p[j][0]*p[j][1]*p[j][2]
print(ans)

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

int main() {
    ll m; cin >> m;
    ll count = 0;
    while(m/2){
        m/=2;
        count++;
    }
    ll ans = 0;
    for(int i = 0; i <= count; i++){
        ans += pow(2,i);
    }
    cout << ans << endl;
	return 0;
}

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

int main()
{
    int s, w;
    cin >> s >> w;
    if (s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL p=7+1e+9;

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

int W, H;
int xs, ys, xg, yg;
int N, C;
int maze[128][128];

int dfs(int x, int y){
	if(x == xg && y == yg)
		return 1;
	maze[y][x] = 0;
	REP(i,4){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(maze[ny][nx] == C){
			if(dfs(nx, ny))
				return 1;
		}
	}
	return 0;
}

int main(){
	while(cin >> W >> H && (W || H)){
		memset(maze, 0, sizeof(maze));
		cin >> xs >> ys >> xg >> yg >> N;
		int c, d, x, y;
		REP(i,N){
			cin >> c >> d >> x >> y;
			if(d == 0){
				REP(j,2)
					REP(k,4)
						maze[y + j][x + k] = c;
			}
			else{
				REP(j,4)
					REP(k,2)
						maze[y + j][x + k] = c;
			}
		}
		C = maze[ys][xs];
		if(C == 0){
			cout << "NG" << endl;
			continue;
		}
		if(dfs(xs, ys)){
			cout << "OK" << endl;
		}
		else{
			cout << "NG" << endl;
		}
	}
}

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

int main(){

	int n; cin >> n;
	long int vmax=0, rmin=0, r=0;

	//i=0
	cin >> r;
	rmin = r;

	//i=1
	cin >> r;
	vmax = r - rmin;
	if(r<rmin){rmin = r;}
	
	for(int i=2;i<n;++i){
		cin >> r;
		if(r-rmin > vmax){vmax = r-rmin;}
		if(r<rmin){rmin = r;}
	}

	cout << vmax << endl;
	return 0;

}



Measured memory_bytes: 3092
#include <iostream>

using namespace std;

int main()
{
	char a,b;
	char ans;
	cin>>a>>b;
	if(a=='H')
	{
		if(b=='H')
		{
			ans='H';
		}else if(b=='D'){
			ans='D';
		}
	}else if(a=='D'){
		if(b=='H')
		{
			ans='D';
		}else if(b=='D'){
			ans='H';
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using namespace std;
typedef long long ll;
inline ll min(int x, int y) { return x < y ? x : y; }
const int Maxn = 1e5 + 5;
inline int read()
{
	rg int res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, k, f[Maxn];
bool b[Maxn];
int main()
{
	int a;
	cin >> n >> k;
	for (int i = 1; i <= k; i++)
	{
		scanf("%d", &a);
		b[a] = true;
	}
	f[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		if (!b[i - 1])
			f[i] = f[i - 1];
		if (i > 1 && !b[i - 2])
			f[i] = (f[i] + f[i - 2]) % 1000000007;
	}
	cout << f[n] << endl;
	return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt();
    }
    int M = N * (N + 1) / 2;
    long[] s = new long[M];
    int k = 0;
    for (int i = 0; i < N; i++) {
      long sum = 0;
      for (int j = i; j < N; j++) {
        sum += a[j];
        s[k++] = sum;
      }
    }
    long res = 0;
    for (int i = 40; i >= 0; i--) {
      long n = res | (1L << i);
      int count = 0;
      for (int j = 0; j < M; j++) if ((s[j] & n) == n) count++;
      if (count >= K) res = n;
    }
    System.out.println(res);
  }
}


Measured memory_bytes: 28012
s = input()

if s == 'SUN':
  print('7')
elif s == 'MON':
  print('6')
elif s == 'TUE':
  print('5')
elif s == 'WED':
  print('4')
elif s == 'THU':
  print('3')
elif s == 'FRI':
  print('2')
elif s == 'SAT':
  print('1')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main()
{
  ifstream fIn("input.txt");
  if (fIn.is_open())
    cin.rdbuf(fIn.rdbuf());

  int r;
  cin >> r;
  
      cout << r*r << endl;
}


Measured memory_bytes: 256
function main(input) {
  var N = input[0]-0;
  var sum = N.toString().split("").map(v=>v-0).reduce((a,b)=>a+b);
  console.log(N%sum==0?"Yes":"No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))

Measured memory_bytes: 7372
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int modpow(ll a, ll n, ll p){
	if(n==0) return 1;
	if(n%2) return (a*modpow(a, n-1, p))%p;
	if(!(n%2)){
		ll t=modpow(a, n/2, p);
		return (t*t)%p;
	}
}

int main(){
  int n; cin >> n;
  ll igai = (modpow(9, n, mod)*2%mod-modpow(8, n, mod)+mod)%mod;
  cout << (modpow(10, n, mod) - igai + mod)%mod << endl;
}


Measured memory_bytes: 3632
using System;

class ABC163
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        int n = int.Parse(s[0]);
        int m = int.Parse(s[1]);
        s = Console.ReadLine().Split();
        for(int i = 0; i < m; i++)
        {
            n -= int.Parse(s[i]);
        }
        if(n < 0)
        {
            Console.WriteLine("-1");
        }
        else
        {
            Console.WriteLine(n.ToString());
        }
    }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int counter = 1;
    while(1){
        int data;
        cin >> data;
        if(data == 0){
            break;
        }
        cout << "Case " << counter <<  ": " << data << "\n";
        counter++;
    }
}



Measured memory_bytes: 3068
#include<stdio.h>




int main() {
	int N;
	scanf("%d", &N);
	int *H = (int *)malloc(sizeof(int)*(N + 2));
	int hmax = 0;
	H[0] = 0;
	H[N] = 0;
	for (int i = 1; i <= N; i++)
	{
		scanf("%d", &H[i]);
		if (hmax < H[i]) {
			hmax = H[i];
		}
	}

	int cnt = 0;
	int ans = 0;
	for (int i = 1; i <= hmax; i++)
	{
		int tmp = 0;
		for (int j = 1; j <= N + 1; j++)
		{
			if (H[j] >= i && H[j - 1] < i) {
				tmp = 1;
			}
			else if (H[j] < i && H[j - 1] >= i && tmp == 1) {
				cnt++;
			}
		}
	}
	ans = cnt;
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)



void solve()
{
	int n, k, i, j, totalCapacity = 0, people, coins;
	cin>>n>>k;
	vector<int> A(n);
	for(i = 0; i + j < n; i++)
	{
		cin>>A[i];
		totalCapacity += A[i];
	}
	if(totalCapacity<=k)
		cout<<(totalCapacity==k)<<endl;
	else
	{
		vector< vector<int> > dp(n, vector<int> (k+1));
		for(i = 0; i < n; i++)
			dp[i][0] = 1;
		for(i = 0; i <= A[0]; i++)
			dp[0][i] = 1;
		for(; i <= k; i++)
			dp[0][i] = 0;
		for(people = 1; people < n; people++)
		{
			for(coins = 1; coins <= k; coins++)
				dp[people][coins] = (dp[people-1][coins] + dp[people][coins-1])%hell;
			for(coins = k; coins - A[people]-1 >= 0; coins--)
				dp[people][coins] = (dp[people][coins] - dp[people][coins-A[people]-1] + hell)%hell;
		}
		cout<<dp[n-1][k]<<endl;
	}
}


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc;
	tc = 1;
    // cin>>tc;
    while(tc--)
        solve();

    return 0;
}


Measured memory_bytes: 79488
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

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

int main(void){
    int K;
    cin >> K;
    int ans=0;
    for(int i=1; i<=K; ++i){
        for(int j=1; j<=K; ++j){
            for(int k=1; k<=K; ++k){
                ans += gcd(i, gcd(j, k));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((p (read))
         (q (read))
         (r (read)))
    (println (min (+ p q) (+ q r) (+ r p)))))

#-swank(main)


;; For Test
#+swank
(defun io-equal (in-string out-string &optional (func #'main))
  "Passes IN-STRING to *STANDARD-INPUT*, executes FUNC, and checks the string
output to *STANDARD-OUTPUT* is equal to OUT-STRING."
  (labels ((ensure-last-lf (s)
             (if (and (> (length s) 0)
                      (eql (char s (- (length s) 1)) #\Linefeed))
                 s
                 (uiop:strcat s uiop:+lf+))))
    (equal (ensure-last-lf out-string)
           (with-output-to-string (out)
             (let ((*standard-output* out))
               (with-input-from-string (*standard-input* (ensure-last-lf in-string))
                 (funcall func)))))))

#+swank
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

#+swank (defparameter *this-pathname* (uiop:current-lisp-file-pathname))
#+swank (defparameter *dat-pathname* (uiop:merge-pathnames* "test.dat" *this-pathname*))

#+swank
(defun run (&optional thing (out *standard-output*))
  (let ((*standard-output* out))
    (etypecase thing
      (null ; Runs #'MAIN with the string on clipboard
       (with-input-from-string (*standard-input* (delete #\Return (get-clipbrd)))
         (main)))
      (string
       (with-input-from-string (*standard-input* (delete #\Return thing))
         (main)))
      (symbol (5am:run! thing))
      (pathname ; Runs #'MAIN with the string in a text file
       (with-open-file (*standard-input* thing)
         (main))))))

#+swank
(defun gen-dat ()
  (uiop:with-output-file (out *dat-pathname* :if-exists :supersede)
    (format out "")))

#+swank
(defun bench (&optional (out (make-broadcast-stream)))
  (time (run *dat-pathname* out)))


Measured memory_bytes: 15076
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int n, m, x, a[105];

int main()
{
	init_ios();
	cin >> n >> m >> x;
	for (int i = 1; i <= m; ++i) {
		int t;
		cin >> t;
		a[t]++;
	}
	int res = 0, res2 = 0;
	for (int i = 0; i < x; ++i)
		res += a[i];
	for (int i = x+1; i <= n; ++i)
		res2 += a[i];
	cout<<min(res, res2)<<"\n";
}

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

using namespace std;

int main()
{
	int set = 0, s[1001][3];

	cin >> set;
	for(int i = 0; i < set; i++){
		cin >> s[i][0] >> s[i][1] >> s[i][2];
	}

	for(int i = 0; i < set; i++){

		sort(s[i] , s[i] + 3);

		if(s[i][0]*s[i][0] + s[i][1]*s[i][1] == s[i][2]*s[i][2]){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	string s; cin >> s;
	string t=s;
	reverse(all(t));
	string x;
	int i = 0, j = 0, ans = 0;
	while (i <= s.size() && j <= t.size()) {
		char S = s[i], T = t[j];
		if (S==T) {
			i++;
			j++;
		} else if (S=='x' && T!='x') {
			i++;
			ans++;
		} else if (S!='x' && T=='x') {
			j++;
			ans++;
		} else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans/2 << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdlib>
using namespace std;
int *graph[100000],num,stack[200000],top,used[100000],gsize[100000];
void dfs(int x) {
  stack[top++] = x;
  used[x] = num;
  while (top != 0) {
    int y = stack[--top];
    for (int i = 0; i < gsize[y]; ++i) {
      int ver = graph[y][i];
      if (used[ver] == 0) {
	used[ver] = num;
	stack[top++] = ver;
      }
    }
  }
}
int main() {
  int n, m, q; cin >> n >> m;
  int ver1[100000], ver2[100000], size[100000] = {};
  for (int i = 0; i < m; ++i) {
    cin >> ver1[i] >> ver2[i];
    ++size[ver1[i]]; ++size[ver2[i]];
  }
  for (int i = 0; i < n; ++i) graph[i] = (int *)malloc(sizeof(int)*size[i]);
  for (int i = 0; i < m; ++i) {
    graph[ver1[i]][gsize[ver1[i]]++] = ver2[i];
    graph[ver2[i]][gsize[ver2[i]]++] = ver1[i];
  }
  for(int i=0;i<n;++i)
    if (used[i] == 0) {
      ++num; dfs(i);
    }
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int s, t; cin >> s >> t;
    cout << (used[s] == used[t] ? "yes" : "no") << endl;
  }
  for (int i = 0; i < n; ++i) free(graph[i]);
  return 0;
}



Measured memory_bytes: 9012
#include<bits/stdc++.h>
using namespace std;
int n;
int arr[100];
int main()
{
    cin>>n;int mi=1e7,pmi,mx=-1e7,pmx;
    for(int i=1;i<=n;i++)cin>>arr[i],mi=min(mi,arr[i]),mx=max(mx,arr[i]);
    for(int i=1;i<=n;i++) {
        if(arr[i]==mi)pmi=i;
        if(arr[i]==mx)pmx=i;
    }
    if(mi>=0) {//都大于等于0
        cout<<n-1<<endl;
        for(int i=1;i<n;i++)cout<<i<<" "<<i+1<<endl;
    } else if(mx<=0) {//都小于等于
        cout<<n-1<<endl;
        for(int i=n;i>1;i--)cout<<i<<" "<<i-1<<endl;
    } else {//有正有负
        cout<<2*n-1<<endl;
        if(abs(mi)>abs(mx)) {//转化为第二种
            for(int i=1;i<=n;i++)cout<<pmi<<" "<<i<<endl;
            for(int i=n;i>1;i--)cout<<i<<" "<<i-1<<endl;
        } else {//转化为第一种
            for(int i=1;i<=n;i++)cout<<pmx<<" "<<i<<endl;
            for(int i=1;i<n;i++)cout<<i<<" "<<i+1<<endl;
        }
    }
}


Measured memory_bytes: 256
using System;

namespace Aizu
{
    class Program
    {
        static void Main(string[] args)
        {
            var diceValue = Console.ReadLine();
            var n = int.Parse(Console.ReadLine());

            Dice d = new Dice(diceValue);

            for (int i = 0; i < n; i++)
            {
                var diceTopFront = Console.ReadLine();
                d.Rolling(diceTopFront);
                Console.WriteLine(d.Right);
            }
        }
    }

    class Dice
    {
        public int Top { get; private set; }
        public int Bottom { get; private set; }
        public int Right { get; private set; }
        public int Left { get; private set; }
        public int Front { get; private set; }
        public int Back { get; private set; }

        public Dice(string value)
        {
            var temp = value.Split(' ');
            this.Top = int.Parse(temp[0]);
            this.Front = int.Parse(temp[1]);
            this.Right = int.Parse(temp[2]);
            this.Left = int.Parse(temp[3]);
            this.Back = int.Parse(temp[4]);
            this.Bottom = int.Parse(temp[5]);
        }

        public void Rolling(string opCode)
        {
            var temp = opCode.Split(' ');

            this.RollingTop(int.Parse(temp[0]));

            this.RollingFront(int.Parse(temp[1]));
        }

        public void RollingTop(int val)
        {
            for(int i = 0; i < 4; i++)
            {
                if(this.Top == val) { return; }
                this.RollingW();
            }

            for (int i = 0; i < 4; i++)
            {
                if (this.Top == val) { return; }
                this.RollingS();
            }
        }

        public void RollingFront(int val)
        {
            for(int i = 0; i < 4; i++)
            {
                if(this.Front == val) { return; }
                this.RollingHorizontal();
            }
        }

        private void RollingS()
        {
            var temp = this.Top;
            this.Top = this.Back;
            this.Back = this.Bottom;
            this.Bottom = this.Front;
            this.Front = temp;
        }

        private void RollingW()
        {
            var temp = this.Top;
            this.Top = this.Right;
            this.Right = this.Bottom;
            this.Bottom = this.Left;
            this.Left = temp;
        }

        private void RollingHorizontal()
        {
            var temp = this.Front;
            this.Front = this.Right;
            this.Right = this.Back;
            this.Back = this.Left;
            this.Left = temp;
        }
    }
}



Measured memory_bytes: 9160
N, Y = map(int, input().split())

for x in range(N+1):
    for y in range(0, N-x+1):
        z = N - (x + y)
        if 10000*x + 5000*y + 1000*z == Y:
            print(x, y, z)
            exit()

print(-1, -1, -1)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

const int MAXN = 52*2+10;
char a[MAXN];
char str[MAXN];
vector<int> V;
int main()
{
    int N;
    scanf("%d",&N);
    scanf("%s",str);
    string tmp;
    cin>>tmp;
    int i=0;
    while(i<N)
    {
        if(str[i]==str[i+1])    V.pb(2),i+=2;
        else V.pb(1),i++;
    }
    long long ans=0;
    long long MOD = 1000000007;
    if(V[0]==1) ans=3;
    else ans=6;
    for(int i=1;i<V.size();i++)
    {
        if(V[i-1]==1&&V[i]==1)  ans=(ans*2)%MOD;
        if(V[i-1]==1&&V[i]==2)  ans=(ans*2)%MOD;
        if(V[i-1]==2&&V[i]==1)  ans=(ans*1)%MOD;
        if(V[i-1]==2&&V[i]==2)  ans=(ans*3)%MOD;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
from bisect import bisect
s = input()
t = input()
d = defaultdict(list)
for i in range(len(s)):
    d[s[i]].append(i)
for i in range(len(s)):
    d[s[i]].append(d[s[i]][0]+len(s))

ans = 0
idx = -1
for i in range(len(t)):
    if d[t[i]] == []:
        ans = -1
        break
    idx = d[t[i]][bisect(d[t[i]],idx)]
    if idx >= len(s):
        ans += 1
        idx %= len(s)
if ans != -1:
    ans *= len(s)
    ans += idx+1
print(ans)

Measured memory_bytes: 49568
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int  second[MAX],out[MAX];
int num;

void CountingSort(short first[],short con){
  int i,j;
  //初期化
  for(i=0;i<=con;i++){
    out[i]=0;
  }
  for(j=1;j<=num;j++){
    out[first[j]]++;
  }
  for(i=1;i<=con;i++){
    out[i]=out[i]+out[i-1];
  }
  for(j=num;j>=1;j--){
    second[out[first[j]]]=first[j];
    out[first[j]]--;
  }
  //出力
  for(i=1;i<num;i++){
    printf("%d ",second[i]);
  }
  printf("%d\n",second[num]);
}

int main(){
  short first[MAX];
  int i;
  short conv=0;

  scanf("%d", &num);
  //firstは入力配列でsecondは出力配列
  for(i=1;i<=num;i++){
    scanf("%hd",&first[i]);
    if(conv<first[i]){
      conv=first[i];
    }
  }

  CountingSort(first,conv);
  return 0;
}



Measured memory_bytes: 13608
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    x = x - a;
    while(x >= b){
      x = x - b;
    }
    System.out.println(x);
  }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(){
int a,b,c,d,e,f=0,i;
while(1){
scanf("%d\n",&a);
if(a==0){
break;
}
else{
for(i=0;i<a;i++){
scanf("%d %d %d\n",&b,&c,&d);
if(f<c+d){
f=c+d;
e=b;
}
}
printf("%d %d\n",e,f);
f=0;
}
}
return 0;
}


Measured memory_bytes: 1972
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String prm = sc.nextLine();
        int sum = 0;
        for (int i = 0; i < prm.length();) {
            char currentDegit = prm.charAt(i);
            int intCurrentDegit = Character.getNumericValue(currentDegit);
            sum += intCurrentDegit;
            i++;
        };
        
        if (Integer.parseInt(prm) % sum == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
    }
}

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

int main() {
 int n; cin >> n;
 int a[n],b[n],c[n];
 rep(i,n) cin >> a[i];
 rep(i,n) cin >> b[i];
 rep(i,n-1) cin >> c[i];
 int ans = 0;
 for(int i=0;i<n;i++){
   ans+=b[a[i]-1];
   if(i==n-1){
     break;
   }
   if(a[i+1] == a[i]+1){
     ans+=c[a[i]-1];
   }
 }
 cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int a,b;
	cin >> a >> b;
	char ans[100][100];
	REP(i,50)
		REP(j,100)
			ans[i][j] = '#';
	for(int i = 50; i < 100; i++)
		REP(j,100)
			ans[i][j] = '.';
	int cnt = 1;
	for(int i = 0; i < 50; i += 2){
		for(int j = 0; j < 100; j += 2){
			if(cnt < a){
				ans[i][j] = '.';
				cnt++;
			}else{
				break;
			}
		}
	}
	cnt = 1;
	for(int i = 51; i < 100; i += 2){
		for(int j = 0; j < 100; j += 2){
			if(cnt < b){
				ans[i][j] = '#';
				cnt++;
			}else{
				break;
			}
		}
	}
	cout << 100 << " " << 100 << endl;
	REP(i,100){
		REP(j,100){
			cout << ans[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

#define S 6
// right, down, left, up
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int const MOD = 1000000007;

int main() {
    bool board[S][S][4] = {};
    rep(i,0,9) {
        int l, n;
        if(i % 2 == 0) l = 4;
        else l = 5;
        rep(j,0,l) {
            scanf("%1d", &n);
            if(n == 1) {
                if(i % 2 == 0) {
                    board[i/2][j+1][1] = true;
                    board[i/2+1][j+1][3] = true;
                }
                else {
                    board[i/2+1][j][0] = true;
                    board[i/2+1][j+1][2] = true;
                }
            }
        }
    }

    string d = "RDLU";
    string ret;
    int dir = 0;
    int nx = 0, ny = 1;
    for(int i=0; i<150; i++) {
        if(nx == 1 && ny == 0 && dir == 2) break;
        if(nx == 0 && ny == 0 && dir == 3) break;
        int x, y;
        x = nx + dx[dir], y = ny + dy[dir];
        if(board[nx][ny][(dir + 1) % 4] == 0) {
            dir = (dir + 1) % 4;
            nx = nx + dx[dir], ny = ny + dy[dir];
        }
        else if(board[nx][ny][dir] == 1) {
            ret += d[dir];
            dir = (dir - 1 + 4) % 4;
        }
        else {
            ret += d[dir];
            nx = x, ny = y;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define t int t ; cin>>t; while(t--)
#define u(x,a,b) for(int x=a;x<b;x++)
#define d(x,a,b) for(int x=a;x>b;x--)
#define g(A,x,n) for(int x=0;x<n;x++) cin>>A[x]
#define s(A,x,n) for(int x=0;x<n;x++) cout<<A[x]<<" ";cout<<endl
#define lli long long int
#define endl "\n"

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli a,b,k;
    lli l = 1000000000;
    bool flag = true;
    cin>>a>>b;
    for(int i=1;i<=l;i++){
        if(abs(a-i) == abs(b-i)){
            cout<<i<<endl;
            flag = false;
        }
        
    }
    if(flag){
            cout<<"IMPOSSIBLE"<<endl;

    }

    
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
lis = [[] for _ in range(M)]
sum = 0
for i in range(N):
    a,b = map(int,input().split())
    if a-1 < M:
        lis[a-1].append(-b)
import heapq
heap = []
for i in range(M):
    for e in lis[i]:
        heapq.heappush(heap,e)
    if len (heap) > 0:
        tmp = heapq.heappop(heap)
        sum += -tmp


    
print(sum)


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

abc = [list(map(int, input().split())) for _ in range(n)]

# dp[i][j]: i日にj(a,b,c)を選んだときの幸福度
dp = [[0 for _ in range(3)] for _ in range(n)]
# 初日はそれぞれの幸福度
for i in range(3):
    dp[0][i] = abc[0][i]

for i in range(1, n):
    # i日目にaをするならi-1日目はb or c
    dp[i][0] = max(dp[i-1][1], dp[i-1][2])+abc[i][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2])+abc[i][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1])+abc[i][2]
print(max(dp[-1]))

Measured memory_bytes: 76632
#include<stdio.h>
int main(void){
	int n,x,i,j,k,count;
	while(1){
		count = 0;
		scanf("%d %d",&n,&x);
		if(n == 0 && x == 0){
			break;
		}
		for(i = 1;i <= n;i++){
			for(j = i+1;j <= n;j++){
				for(k = j+1;k <= n;k++){
					if(i+j+k == x){
						count++;
					}
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

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

typedef long long ll;
const int N = 2054, mod = 1000000007;

int A, B, K;
int f[N * 2][N], g[N * 2][N];

inline int max(const int x, const int y) {return x < y ? y : x;}
inline int & reduce(int &x) {return x += x >> 31 & mod;}
inline int & add(int &x, const int y) {return x += y - mod, x += x >> 31 & mod;}

int main() {
	int i, j, l, r, limit; ll ans = 0;
	scanf("%d%d%d", &A, &B, &K);
	if (A > B) std::swap(A, B); limit = (A + B - 1) / --K;
	for (**f = i = 1; i <= limit; ++i) {
		for (j = 0; j <= A; ++j)
			add(g[i][j + 1] = g[i][j], add(f[i][j] = f[i - 1][j], g[i - 1][j]));
		for (j = A; j >= K; --j) reduce(g[i][j] -= g[i][j - K]);
		for (l = max(A % K, i * K - B + 1), r = i * K - l + 1; l <= A && r >= 0; l += K, r -= K)
			 ans += g[i][l];
	}
	printf("%d\n", int(ans % mod));
	return 0;
}

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

const int maxn = 1e3+4;

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

int mat[maxn][maxn], comp[maxn][maxn];
bool vis[maxn][maxn];
int h, w, sx, sy, ex, ey;

bool isValid(int x, int y){
    return x >= 0 && x < h && y >= 0 && y < w;
}

void dfs(int cx, int cy, int k){
    comp[cx][cy] = k;
    vis[cx][cy] = true;
    for(int i : {0,1,2,3}){
        int nx = cx + dx[i];
        int ny = cy + dy[i];
        if(!isValid(nx, ny) || vis[nx][ny] || !mat[nx][ny]) continue;
        dfs(nx, ny, k);
    }
}

void solve(){
    
    cin >> h >> w;
    cin >> sx >> sy;
    --sx; --sy;
    cin >> ex >> ey;
    --ex; --ey;
    for(int i = 0; i < h; ++i){
        string s; cin >> s;
        for(int j = 0; j < w; ++j){
            mat[i][j] = (s[j] == '.');
        }
    }
    memset(vis, false, sizeof(vis));
    memset(comp, 0, sizeof(comp));
    int k = 0;
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(!vis[i][j] && mat[i][j]){
                ++k;
                dfs(i, j, k);
            }
        }
    }
    vector< int > adj[k + 1];
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(mat[i][j]){
                int U = i - 2, D = i + 2, L = j - 2, R = j + 2;
                for(int ii = U; ii <= D; ++ii){
                    for(int jj = L; jj <= R; ++jj){
                        if(!isValid(ii, jj) || !mat[ii][jj]) continue;
                        if(comp[ii][jj] != comp[i][j]){
                            adj[comp[i][j]].push_back(comp[ii][jj]);
                            adj[comp[ii][jj]].push_back(comp[i][j]);
                        }
                    }
                }
            }
        }
    }
    int ans = -1;
    vector< int > level(k + 1, -1);
    level[comp[sx][sy]] = 0;
    queue< int > bfs;
    bfs.push(comp[sx][sy]);
    while(!bfs.empty()){
        int u = bfs.front();
        bfs.pop();
        if(u == comp[ex][ey]){
            cout << level[u] << '\n';
            return;
        }
        for(int v : adj[u]){
            if(level[v] == -1){
                bfs.push(v);
                level[v] = level[u] + 1;
            }
        }
    }
    cout << ans << '\n';

}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

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

    int t = 1;
    // cin >> t;


    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}

Measured memory_bytes: 35860
N=int(input())
A=[]
for i in range(N):
  a=int(input())
  A.append(a)
import copy
B=copy.copy(A)
B.sort()
max=B[-1]
max2=B[-2]

if max==max2:
  for i in range(N):
    print(max)
else:
  ind=A.index(max)
  for i in range(N):
    if i==ind:
      print(max2)
    else:
      print(max)

Measured memory_bytes: 19428
n, m = map(int, input().split())
switches = [list(map(int, input().split())) for i in range(m)]
P = list(map(int, input().split()))
ans = 0
for bit in range(2 ** n):
    for switch, p in zip(switches, P):
        count = 0
        for s in switch[1:]:
            if ((bit >> (s - 1)) & 1):
                count += 1
        if count % 2 == p:
            continue
        break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  int a,b,c;
  int cnt=3;
  scanf("%d%d%d",&a,&b,&c);
  if(a==b) cnt-=1;
  if(a==c) cnt-=1;
  if(b==c) cnt-=1;
  
  if(cnt==0) cnt=1;
  
  printf("%d\n",cnt);
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

R, G, B, N = map(int, raw_input().split())

_count = 0

for i in range(N/R+1):
    for j in range((N-i*R)/G+1):
        if (N-i*R-j*G)%B == 0:
            _count += 1

print str(_count)

Measured memory_bytes: 2820
#include <iostream>

using namespace std;

int main()
{
    //cin.tie(nullptr);
    //ios::sync_with_stdio(false);
    
    int m,d;
    cin >> m >> d;
    int cnt = 0;
    for(int i=1; i<=m; i++){
        for(int j=1; j<=d; j++){
            int d1 = j % 10;
            int d10 = j / 10;
            if((d1*d10 == i) && (d1 >= 2) && (d10 >= 2)){
                //cout << i << "/" << j << endl;
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
int main(){loop(i,1,10)loop(j,1,10)cout<<i<<"x"<<j<<"="<<i*j<<endl;}

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

const ll MOD = 1000000007;

const int N = 1000005;

void pairwise()
{
    cout << "pairwise coprime";
}

void setwise()
{
    cout << "setwise coprime";
}

void not_any()
{
    cout << "not coprime";
}

int spf[N];
bool seen[N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //set_file_io("input", "output");
    spf[1] = 1;
    for(int i=2; i<N; i++)
    {
        spf[i] = i;
    }
    for(int i=4; i<N; i+=2)
    {
        spf[i] = 2;
    }
    for(int i=3; i*i<N; i++)
    {
        if(spf[i] == i)
        {
            for(int j=i*i; j<N; j+=i)
            {
                if(spf[j] == j)
                {
                    spf[j] = i;
                }
            }
        }
    }

    int n;
    cin >> n;
    int g = -1;
    bool pr = true;
    for(int i=0; i<n; i++)
    {
        int x;
        cin >> x;
        if(g == -1)
        {
            g = x;
        }
        else
        {
            g = __gcd(g, x);
        }
        while(x != 1)
        {
            if(seen[spf[x]])
            {
                pr = false;
            }
            seen[spf[x]] = true;
            int k = spf[x];
            while(x%k == 0)
                x /= k;
        }
    }
    if(pr)
    {
        pairwise();
    }
    else if(g == 1)
    {
        setwise();
    }
    else
    {
        not_any();
    }
    return 0;
}


Measured memory_bytes: 8520
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Collections;

public class Main {
    static class Cards {
        char suit;
        int number;

        public Cards(char suit, int number) {
            this.suit = suit;
            this.number = number;
        }

    }

    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bf.readLine());
        Cards[] cards = new Cards[n];
        Cards[] cards2 = new Cards[n];
        for (int i = 0; i < n; i++) {
            String[] split = bf.readLine().split(" ");
            Cards car = new Cards(split[0].charAt(0), Integer.parseInt(split[1]));
            cards[i] = car;
            cards2[i] = car;
        }
        mergeSort(cards2, 0, n );
        StringBuilder sb = new StringBuilder();
        quickSort(cards, 0, n-1);
        boolean kk = true;
        for (int i = 0; i < n; i++) {
            if (kk) {
                if (cards2[i].suit != cards[i].suit) {
                    sb.insert(0, "Not stable\n");
                    kk = false;
                }

            }
            sb.append(cards[i].suit + " " + cards[i].number + "\n");
        }
        if (kk) sb.insert(0, "Stable\n");
        System.out.print(sb.toString());
    }

    private static void mergeSort(Cards[] cards2, int a, int b) {
        if (a + 1 < b) {
            int mid = (a + b) / 2;
            mergeSort(cards2, a, mid);
            mergeSort(cards2, mid, b);
            merge(cards2, a, mid, b);
        }
    }

    private static void merge(Cards[] cards2, int a, int mid, int b) {
        int n1 = mid - a;
        int n2 = b - mid;
        Cards l[] = new Cards[n1 + 1];
        Cards r[] = new Cards[n2 + 1];
        for (int i = 0; i < n1; i++) {
            l[i] = cards2[a + i];
        }
        for (int i = 0; i < n2; i++) {
            r[i] = cards2[mid + i];
        }
        l[n1] = new Cards('A', Integer.MAX_VALUE);
        r[n2] = new Cards('A', Integer.MAX_VALUE);
        int m = 0, n = 0;
        for (int k = a; k < b; k++) {
            if (l[n].number <= r[m].number) {
                cards2[k] = l[n];
                n++;
            } else {
                cards2[k] = r[m];
                m++;
            }
        }
    }

    private static void quickSort(Cards[] cards, int a, int b) {
        if (a < b) {
            int mid = partition(cards, a, b);
            quickSort(cards, a, mid-1);
            quickSort(cards, mid+1, b);
        }
    }

    private static int partition(Cards[] cards, int a, int b) {
        int x = cards[b].number;
        int n = a - 1;//记录小的区域
       // int m = b;//记录大的区域
        for (int j = a; j < b; j++) {
            if (cards[j].number <= x) {
                n++;
                exchange(cards, n, j);
            }
        }
        exchange(cards, n + 1, b);
        return n+1;
    }

    private static void exchange(Cards[] a, int i, int j) {
        Cards tep = a[j];
        a[j] = a[i];
        a[i] = tep;
    }

}


Measured memory_bytes: 71484
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

const ll mod = (ll)(1e9) + 7;
ll dp[10][100005][13];
string str;

ll powmod(ll x, ll y);

int main()
{
    cin >> str;

    for (int j = 0; j < 10; j++) {
        if (str[str.size() - 1] - '0' == j ||
            str[str.size() - 1] == '?') {
            dp[j][str.size() - 1][j] = 1;
        }
    }

    ll k = 10;
    for (int i = str.size() - 2; i >= 0; i--) {
        
        for (int j = 0; j < 10; j++) {
            if (str[i] != '?' && str[i] - '0' != j) continue;
            
            ll x = j * k % 13;

            for (int ii = 0; ii < 10; ii++) {
                for (int jj = 0; jj < 13; jj++) {
                    if (str[i + 1] - '0' == ii || str[i + 1] == '?') {
                        
                        dp[j][i][(jj + x) % 13] += dp[ii][i + 1][jj];
                        dp[j][i][(jj + x) % 13] %= mod;
                    }
                }
            }
        }

        k *= 10;
        k %= 13;
    }

    ll ans = 0;
    for (int i = 0; i < 10; i++) {
        if (str[0] == '?' || str[0] - '0' == i) {
            ans += dp[i][0][5];
            ans %= mod;
        }
    }

    cout << ans << endl;

    return 0;
}

ll powmod(ll x, ll y)
{
    ll ret = 1;
    while (y) {
        if (y & 1) {
            ret *= x;
            ret %= 13;
        }
        y = y >> 1;
        x *= x;
        x %= 13;
    }

    return ret;
}


Measured memory_bytes: 102016
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;


int main(){
	int N; cin >> N;
	vector<int> a(N);
	bool flag = false;
	int b , c , d ,e , f , g , h , j ,k,l,m;
	b = c = d = e = f = g = h = j = k = 0;
	rep(i,N){
	cin >> a[i];
	if(a[i] < 400) b++;
	else if(a[i] < 800) c++;
	else if(a[i] < 1200) d++;
	else if(a[i] < 1600) e++;
	else if(a[i] < 2000) f++;
	else if(a[i] < 2400) g++;
	else if(a[i] < 2800) h++;
	else if(a[i] < 3200) j++;
	else k++;
	}
	
		if(b >= 1){ b = 1; flag = true;}
		if(c >= 1) {c = 1; flag = true;}
		if(d >= 1) {d = 1;flag = true;}
		if(e >= 1) {e = 1;flag = true;}
		if(f >= 1) {f = 1;flag = true;}
		if(g >= 1) {g = 1;flag = true;}
		if(h >= 1) {h = 1;flag = true;}
		if(j >= 1) {j = 1;flag = true;}
		if(k > 0){
			if(flag) {l = 0; m = k;}
			else {l = 1; m = k;}
}
		else if (k==0){
			l = m = 0;
		}
		cout << b + c + d + e + f + g + h + j + l<< " " << b + c + d + e + f + g + h + j + m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int a,b,d,r;
    double f;
    cin >> a >> b;
    
    d = a / b;
    r = a % b;
    f = (double)a / (double)b;
    
    printf("%d %d %.8lf\n", d, r, f);
    return 0;
}

Measured memory_bytes: 1196
//

/*
    __          ____  ________       
   / /   ____  / __ \/_  __/ /_  ___ 
  / /   / __ \/ / / / / / / __ \/ _ \
 / /___/ /_/ / /_/ / / / / / / /  __/
/_____/\____/_____/ /_/ /_/ /_/\___/ 
                                     
                                     */

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <list>

using namespace std;

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

#define endl "\n"
#define mp make_pair
#define pb push_back

const int mod = 1000000007;

ll q, h, s, d, n;
ll result = 2e9;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> q >> h >> s >> d >> n;

	result = 4 * q * n;
	result = min(result, 2 * h * n);
	result = min(result, s * n);

	if (n & 1)
		result = min(result, (n / 2) * d + min(q * 4, min(h * 2, s)));
	else
		result = min(result, (n / 2) * d);

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int h,w,a[85][85],b[85][85];
bool dp[85][85][25605];
int main(){
	h=read(),w=read();
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			a[i][j]=read();
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			b[i][j]=read();
	dp[0][1][12800]=dp[1][0][12800]=true;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			for(int k=0;k<25601;k++)
				if(dp[i-1][j][k] or dp[i][j-1][k])
					dp[i][j][k+a[i][j]-b[i][j]]=dp[i][j][k-a[i][j]+b[i][j]]=true;
//				dp[i][j][k-a[i][j]+b[i][j]]=dp[i][j][k+a[i][j]-b[i][j]]=dp[i-1][j][k]|dp[i][j-1][k];
	for(int i=12800;i<25601;i++)
		if(dp[h][w][i] or dp[h][w][25600-i])
			return printf("%d",i-12800),0;
	return 0;
}

Measured memory_bytes: 172416
import java.util.Scanner;

class Main{
	static long mod=1000000007;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			long n=sc.nextLong(),ans=1;
			for(long i=2;i<=n;i++){ ans*=i; ans%=mod; }
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 21972