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

int main()
{
    while (true) {
        int m, f, r;
        
        cin >> m >> f >> r;
        
        if (m == -1 && f == -1 && r == -1) {
            break;
        }
        
        if (m == -1 || f == -1) {
            cout << "F" << endl;
        } else if (m + f >= 80) {
            cout << "A" << endl;
        } else if (m + f >= 65 && m + f < 80) {
            cout << "B" << endl;
        } else if (m + f >= 50 && m + f < 65) {
            cout << "C" << endl;
        } else if (m + f >= 30 && m + f < 50) {
            if (r >= 50) {
                cout << "C" << endl;
            } else {
                cout << "D" << endl;
            }
        } else if (m + f < 30) {
            cout << "F" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
int n;
cin>>n;
vector<int> a(n,0);
int alice=0;
int bob=0;

for(int i=0; i<n; i++)
{
    cin >> a[i];
}
    sort(a.begin(),a.end(),greater<int>());

for(int i=0; i<n; i++)
{
    if(i%2==0) alice+=a[i];
    else bob+=a[i];
}

cout<<alice-bob<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>

using namespace std;

int n, m;

int main() {

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

	cin >> n;

	if (n == 3 || n == 5 || n == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  intll n , a , b ;
  cin >> n >> a >> b;
  intll ans  ;
  
  if((b-a) % 2 == 0) ans = (b-a)/2 ; 
  else               ans = ((b-a+1)/2) + min((n-b),a-1)   ;
    

  
  
  
  cout << ans << endl ;

}


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

int main(){
  int k,s;
  cin >> k >> s;
 
  int cnt = 0;
  
  for (int x=0; x<=k; x++){
    for (int y=0; y<=k; y++){
      int sum = x+y;
      if (s-sum >=0 && s-sum<=k) cnt++;
    }
  }
  
  cout << cnt << endl;
  
}

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

int main() {
  int64_t N;
  cin >> N;
  
  int64_t max = sqrt(N) + 1;

  int64_t a = N, b = N;
  for (int64_t i = 1; i <= max; i++) {
    if (i * (N / i) != N) continue;
    if ((i + (N / i)) < (a + b)) {
      a = i;
      b = (N / i);
    }
  }
  
  cout << a + b - 2 << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int INF = 1001001009;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i]= sc.nextInt();
        }
        
        int min = INF;
        for (int i = 0; i < n; i++) {
            int count = 0;
            while (array[i] % 2 == 0) {
                count++;
                array[i] /= 2;
            }
            
            min = Math.min(min, count);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
vector<int> a;
int solve(int k, int x) {
	if (k == 0) {
		if (x == 0)return 1;
		else return 0;
	}
	int cnt = 0;
	for (int i = 0; i <= 1; i++) {
		cnt += solve(k - 1, x - a[k - 1]*i);
	}
	return cnt;
}

int main() {
	int n;
	cin>>n;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int m; cin >> m;
		if (solve(n, m)) cout << "yes" << endl;
		else cout << "no" << endl;
	}
}



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

using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	vector<complex<long double>> p(n);
	for(int i=0;i<n;i++){
		long double x,y;
		cin >> x >> y;
		complex<long double> c(x,y);
		p[i]=c;
	}
	
	long double res=1LL<<50;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				complex<long double> &a=p[i],&b=p[j],&c=p[k];
				complex<long double> num=(a-b)*norm(c)+(b-c)*norm(a)+(c-a)*norm(b);
				complex<long double> den=(a-b)*conj(c)+(b-c)*conj(a)+(c-a)*conj(b);
				
				complex<long double> cent=num/den;
				
				long double naga=0;
				for(int ii=0;ii<n;ii++){
					complex<long double> dif=p[ii]-cent;
					naga=max(naga,abs(dif));
				}
				res=min(res,naga);
			}
		}
	}
	
	complex<long double> t(2,0);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			complex<long double> &a=p[i],&b=p[j];
			complex<long double> cent=(a+b)/t;
			long double naga=0;
			for(int ii=0;ii<n;ii++){
				complex<long double> dif=p[ii]-cent;
				naga=max(naga,abs(dif));
			}
			res=min(res,naga);
		}
	}
	cout.precision(20);
	cout << res << "\n";
	return 0;
}

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



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

	int N;
	cin >> N;

	int odd = 0;
	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if(a % 2) odd++;
	}

	if(odd % 2) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}

Measured memory_bytes: 256
<?php
/*
  http://abc044.contest.atcoder.jp/tasks/abc044_b
*/

function is_even($value) {
  return $value % 2 === 0 ? true : false;
}

$stdin = trim(fgets(STDIN));
$str_hash = [];

foreach (str_split($stdin) as $key => $value) {
  if (isset($str_hash[$value])) {
    $str_hash[$value] += 1;
  } else {
    $str_hash[$value] = 1;
  }
}

$is_beautiful = true;
foreach ($str_hash as $key => $value) {
  if (!is_even($value)) {
    $is_beautiful = false;
    break;
  }
}

echo $is_beautiful ? "Yes" : "No";

?>


Measured memory_bytes: 2812
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

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

int main(){
    ll x; cin >> x;
    ll ans = x-1;
    REP(i,2,sqrt(x)+1){
        ll tmp = i;
        ll p = 2;
        while(power(tmp,p)<=x){
            ans = min(ans, x-power(tmp,p));
            p++;
        }
    }
    cout << x-ans << endl;
}

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

using namespace std;

int main(){
int H,W; cin >> H >> W;
  vector<vector<char>> A(H+2,vector<char>(W+2));
  for(int i = 0; i <= H + 1; i++){
    if( i == 0 || i == H + 1){ 
      for(int j = 0; j <= W+1; j++){A[i][j] ='#';}}
    else{ A[i][0] = '#'; A[i][W+1] = '#';
         for(int j = 1; j <= W ; j++){
           cin >> A[i][j];}} }
  
  for(int i = 0; i <= H + 1; i++){
    for(int j = 0; j <= W + 1; j++){
      cout << A[i][j];}
    cout << endl;}
  
  return 0;
}
     

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

        using namespace std;

        #define pb push_back
        #define mp make_pair
        #define fr first
        #define sc second

        typedef long long int lli;

        lli n, m;
        string s, ans;

        int main(){
            cin>>n>>m;
            if(m == n)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
            return 0;
        }


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

using namespace std;

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

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

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

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

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int n, q;
ll a[114514], x;
ll sum[114514], sum2[114514];

bool is_ok(int y){
	int ind=2*y-n+2;
	if(ind>0){
		return abs(x-a[y])<abs(x-a[ind-1]);
	}
	else{
		return y<n/2;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>q;
	REP(i, n){
		cin>>a[i];
		sum[i+1]=sum[i]+a[i];
		if(i&1){
			sum2[i+1]=sum2[i-1]+a[i];
		}
	}
	REP(i, q){
		cin>>x;
		int lb=0, ub=n-1;
		while(ub-lb>1){
			int mid=(lb+ub)/2;
			if(is_ok(mid)){
				lb=mid;
			}
			else{
				ub=mid;
			}
		}
		// DEBUG(lb);
		ll ans=sum[n]-sum[lb+1];
		int ind=2*lb-n+2;
		if(ind>0){
			if(ind&1){
				ans+=sum[ind]-sum2[ind-1];
			}
			else{
				ans+=sum2[ind];
			}
		}
		cout<<ans<<'\n';
	}
	return 0;
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	int n;
	cin >> n;
	vector<int> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	cout << s[n / 2] - s[n / 2 -1];
}

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

int main() {
  char c;
  cin >> c;
  if(c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a;
  c = a;
  for(;a > 0 ; a = a/10){
    b += a%10;
  }
  if (c % b == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {

    sc.Split(bufio.ScanWords)
    n := nextInt()

    var min_val int = 10e12
    for i := 1; i*i <= n; i++ {
        if n % i == 0 {
            j := n / i
            min_val = min(min_val, i+j-2)
        }
    }
    fmt.Println(min_val)

}



//==================================================
//
// Library
//
//==================================================

//===========================
//  round(12.54, 0) -> 13.0
//  round(12.54, -1) -> 12.5
//===========================

func round(num float64, digit uint) float64 {
    d := float64(digit)
    return float64(int(num * math.Pow(10, d) + 0.5)) / math.Pow(10, d)
}

func abs(n int) int {
    return int(math.Abs(float64(n)))
}

func max(a, b int) int {
    return int(math.Max(float64(a), float64(b)));
}

func min(a, b int) int {
    return int(math.Min(float64(a), float64(b)));
}

func gcd(x, y int) int {
    if y == 0 {
        return x
    }

    return gcd(y, x%y)
}

//===========================
//  var q Queue
//  q.Enqueue(n)
//  n := q.Dequeue()
//===========================
type Queue struct {
    data []int
}

func (q *Queue) Enqueue(n int) {
    q.data = append(q.data, n)
}

func (q *Queue) Dequeue() int {
    tmp := q.data[0]
    q.data = q.data[1:]
    return tmp
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}

func strReverse(s string) string {
    runes := []rune(s)
    for i := 0; i < len(s)/2; i++ {
        runes[i], runes[len(s)-1-i] = runes[len(s)-1-i], runes[i]
    }
    return string(runes)
}

func nextInt() int {
    sc.Scan()
    i, _ := strconv.Atoi(sc.Text())
    return i
}

func nextStr() string {
    sc.Scan()
    return sc.Text()
}

func swap(a, b int) (int, int) {
    return b, a
}

func mySort(list []int, start int, end int) {
    var l []int
    for i := start; i < end; i++ {
        l = append(l, list[i])
    }
    sort.Ints(l)

    j := 0
    for i := start; i < end; i++ {
        list[i] = l[j]
        j++
    }
}

func mySortRev(list []int, start int, end int) {
    var l []int
    for i := start; i < end; i++ {
        l = append(l, list[i])
    }

    sortIntsRev(l)

    j := 0
    for i := start; i < end; i++ {
        list[i] = l[j]
        j++
    }
}

func nextPermutation(array []int) bool {
    n := len(array)

    for i:= n - 2; i >= 0; i-- {
        if array[i] < array[i+1] {
            j := n;
            for {
                j--;
                if (array[i] < array[j]) {
                    break
                }
            }
            array[i], array[j] = swap(array[i], array[j])
            mySort(array, i + 1, n)
            return true
        }
        if i == 0 {
            mySortRev(array, 0, n)
        }
    }
    return false
}



Measured memory_bytes: 640
using System;

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            int count = 0;
            int x = 0, y = x;
            int pad = 1;
            int[,] cell = null;
            Action move = () => {
                if(++x >= count) {
                    x = 0;
                }
                if(++y >= count) {
                    y = 0;
                }
                while(cell[y, x] != 0) {
                    if(--x < 0) {
                        x = count - 1;
                    }
                    if(++y >= count) {
                        y = 0;
                    }
                }
            };
            while((count = int.Parse(Console.ReadLine())) != 0) {
                y = (x = count / 2) + 1;
                cell = new int[count, count];
                cell[y, x] = 1;
                pad = 1;
                int max = count * count;
                while(pad != max) {
                    move();
                    cell[y, x] = ++pad;
                }
                for(int i=0; i < count; ++i) {
                    for(int l = 0;l < count;++l){
                        Console.Write("{0,4}", cell[i,l]);
                    }
                    Console.WriteLine();
                }
            }
        }
    }
}

Measured memory_bytes: 5832
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
	    Scanner s = new Scanner(System.in);
	    while(s.hasNext()){
		String a = s.next();
		String out = "";
   		for(int i=0 ; i<a.length() ; i++){
		    if(a.charAt(i) == '@'){
			for(int j=0 ; j<Integer.parseInt("" + a.charAt(i+1)) ; j++)
			    out += String.valueOf(a.charAt(i+2));
			i+=2;
		    }
		    else
			out+=String.valueOf(a.charAt(i));
		}
		System.out.println(out);
	    }
      	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int A,B;
  cin>>A>>B;
  int ans = 0;
  while(A>0){
    A -= B;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
PROGRAM-ID.                      ABC_042_A.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP     PIC X(33).
    01 maxlen  PIC 9(1) VALUE 3.
    01 cur     PIC 9(33) VALUE 1.
    01 i       PIC 9(18) VALUE 1.
    01 j       PIC 9(18).
    01 len     PIC 9(33).
    01 ans     PIC X(8).
    01 five    PIC 9(1) VALUE ZERO.
    01 seven   PIC 9(1) VALUE ZERO.
    01 ABC1.
        03 ABC11 OCCURS 3.
            05 ABC PIC 9(2).

PROCEDURE                        DIVISION.
    ACCEPT INP.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO ABC(i)

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    PERFORM VARYING i FROM 1 BY 1 UNTIL 3 < i
        IF ABC(i) = 5 THEN
            ADD 1 TO five
        ELSE IF ABC(i) = 7
            ADD 1 TO seven
        END-IF
    END-PERFORM.

    IF five = 2 AND seven = 1 THEN
        DISPLAY "YES"
    ELSE
        DISPLAY "NO"
    END-IF.

    STOP RUN.


Measured memory_bytes: 384
use strict;
use warnings;

my $in = <>;
chomp $in;
my ($a,$b,$c,$d) = split(/ /, $in);

my $result = $a * $c;

if ($result < $a * $d){
	$result = $a * $d;
}
if ($result < $b * $c){
	$result = $b * $c;
}
if ($result < $b * $d){
	$result = $b * $d;
}

print $result;

exit;


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

a = list(map(int,input().split()))
li = []
c = 0
for i in range(len(a)):
    if a[i] % 2 == 0:
        li.append(a[i])

for i in range(len(li)):
    if li[i] % 3 != 0 and li[i] % 5 != 0:
        c =1
        break


if c ==0:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	

	int b[n];
	b[0]=0;
	if(a[1]>=a[0])
	b[1]=a[1]-a[0];
	else
	b[1]=a[0]-a[1];
	
	
	for(int i=2;i<n;i++)
	{
		int k;
	//	cout<<" * "<<a[i]-a[i-1]<<" *  # "<<a[i]-a[i-2]<<" * # ";
		if(a[i]>=a[i-1])
		k=a[i]-a[i-1];
		else
		k=a[i-1]-a[i];
		
	//	cout<<k<<"  ";
		
		int q;
		if(a[i]>=a[i-2])
		q=a[i]-a[i-2];
		else
		q=a[i-2]-a[i];
		
	//	cout<<q<<"  ";
		
		
		if((b[i-1]+k)<=(b[i-2]+q))
		b[i]=b[i-1]+k;
		else
		b[i]=b[i-2]+q;
		
	//	cout<<b[i]<<endl;
		
	}
	
	cout<<b[n-1];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  cin >> s;
  stack<char> d;
  for(ll i=0;i<s.size();i++) {
    if(s[i]=='B') {
      if(d.size()) d.pop();
    }
    else {
      d.push(s[i]);
    }
  }
  string ans;
  while(d.size()) {
    ans=d.top()+ans;
    d.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  vector<string> key = {"dream", "dreamer", "erase", "eraser"};
  reverse(s.begin(), s.end());
  for (int i = 0; i < key.size(); i++) reverse(key[i].begin(), key[i].end());
  int now = 0;
  while (now < s.length()) {
    bool can = false;
    for (int i = 0; i < 4; i++) {
      string t = s.substr(now, key[i].length());
      if (t == key[i]) {
        now += key[i].length();
        can = true;
      }
    }
    if (can == false) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

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


int main (void){
        int A,B;
        char box[100][100];
        scanf("%d %d",&A,&B);
        for (int i = 0; i < 50; i++) {
                for (int j = 0; j < 100; j++) {
                        box[i][j]='.';
                }
        }
        for (int i = 50; i < 100; i++) {
                for (int j = 0; j < 100; j++) {
                        box[i][j]='#';
                }
        }
        for (int i = 0; i < B-1; i++) {
                box[(i/50)*2][(i*2)%100]='#';
        }
        for (int i = 0; i < A-1; i++) {
                box[100-((i/50)*2)-1][(i*2)%100]='.';
        }
        printf("100 100\n");
        for (int i = 0; i < 100; i++) {
                for (int j = 0; j < 100; j++) {
                        printf("%c",box[i][j]);
                }
                printf("\n");
        }
        return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct E{
	int x,y;
	bool operator<(E a)
	{
		if(x*x+y*y!=a.x*a.x+a.y*a.y)return x*x+y*y<a.x*a.x+a.y*a.y;
		else return x<a.x;
	}
};
main()
{
	int h,w;
	while(cin>>h>>w,h)
	{
		E a,b,c;
		a.x=h,a.y=w;
		b.x=b.y=150;
		for(int i=1;i<150;i++)for(int j=i+1;j<150;j++)
		{
			c.x=i,c.y=j;
			if(a<c&&c<b)b=c;
		}
		cout<<b.x<<" "<<b.y<<endl;
	}
}


Measured memory_bytes: 3080
import math

N = int(input())

num_p = 1
P = [int(num) for num in input().split(' ')]
nums = [num+1 for num in range(N)]
for i, Pi in enumerate(P):
	nums.remove(Pi)
	num_small = len([num for num in nums if num < Pi])
	num_p += math.factorial(N-i-1)*num_small
        
num_q = 1
Q = [int(num) for num in input().split(' ')]
nums = [num+1 for num in range(N)]
for i, Qi in enumerate(Q):
	nums.remove(Qi)
	num_small = len([num for num in nums if num < Qi])
	num_q += math.factorial(N-i-1)*num_small

print(abs(num_p-num_q))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int n,a,b;
vector<int> h;

bool enough(ll mid) {
  ll k = b * mid;
  REP(i,n) {
    ll nh = h[i]-k;
    if (nh > 0) mid -= nh/(a-b) + (nh%(a-b) > 0);
  }
  return 0 <= mid;
}

int main() {
  IOS;
  cin >> n >> a >> b;
  h.resize(n);
  REP(i,n) cin >> h[i];

  sort(ALL(h));

  int ng = 0, ok = h[n-1]/b+1;
  while(abs(ok-ng) > 1) {
    ll mid = (ok+ng)/2;

    if (enough(mid)) ok = mid;
    else ng = mid;
  }

  COUT(ok);
  return 0;
}

Measured memory_bytes: 3684
// J4180449 三宅亮輔
// 問題名
// - Parallelism
// 問題URL
// - https://onlinejudge.u-aizu.ac.jp/#/problems/0021
// 所要時間
// - 45分
// 学んだこと
//
//
//

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

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

int n;

vector<P> p;

const double eps = 1e-10;

void solve() {
    P a1, a2, a3, a4;
    cin >> a1.first >> a1.second >> a2.first >> a2.second >> a3.first >>
        a3.second >> a4.first >> a4.second;
    P b1 = P(a2.first - a1.first, a2.second - a1.second);
    P b2 = P(a4.first - a3.first, a4.second - a3.second);
    if(abs(b1.second) < eps || abs(b2.second) < eps) {
        if(abs(b1.second - b2.second) < eps)
            puts("YES");
        else
            puts("NO");
    } else if(abs((b1.first / b1.second) - (b2.first / b2.second)) < eps) {
        puts("YES");
    } else {
        puts("NO");
    }
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++)
        solve();
}



Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}
 
int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  vector<int> l(n), r(n);
  rep(i,n-1) l[i+1] = gcd(l[i], a[i]);
  for (int i = n-1; i >= 1; --i) r[i-1] = gcd(r[i], a[i]);
  int ans = 1;
  rep(i,n) ans = max(ans, gcd(l[i],r[i]));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
    ll n,k,ans=0,cnt=0;cin>>n>>k;
    string s;cin>>s;
    
    rep(i,n-1){
        if(s[i]==s[i+1])ans++;
        else{
            cnt++;
        }
    }

    ans+=min(2*k,cnt);
    cout<<ans<<endl;

}

Measured memory_bytes: 512
#include <iostream>
#define int long long
using namespace std;
signed main() {
	int a, b, k; cin >> a >> b >> k;
	for (int i = 0; i < k; i++) {
		if (i % 2) {
			if (b > 0 && b % 2 == 1)b--;
			b /= 2; a += b;
		}
		else {
			if (a > 0 && a % 2 == 1)a--;
			a /= 2; b += a;
		}
	}
	cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int[] a = new int[5];
	int[] b = new int[5];

	for(int i = 0; i<5; i++) {
	    a[i] = sc.nextInt();
	    b[i] = a[i];
	}
	int k = sc.nextInt();
	for(int i = 0; i<5; i++) {
            for(int j = 0; j<5; j++) {
		if(Math.abs(a[i]-b[j]) > k) {
		    System.out.println(":(");
		    return;
		}
            }
        }
	System.out.println("Yay!");
    }
}

Measured memory_bytes: 23764
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<cctype>
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;

inline ll read()
{
	ll f=1,sum=0;char c=getchar();
	while (!isdigit(c)) {if (c=='-') f=-1;c=getchar();}
	while (isdigit(c)) {sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}
const int MAXN=100010;
struct Node{
	int w,t;
	bool operator < (Node b) const {return (t==b.t)?w>b.w:t>b.t;}
}a[MAXN];
priority_queue <int,vector<int>,greater<int> > q;
int main()
{
	int n=read(),m=read();
	for (int i=1;i<=n;i++) a[i].t=read(),a[i].w=read();
	sort(a+1,a+1+n);
	int nowday=0,ans=0;
	for (int i=1;i<=n;i++)
	{
		if (nowday+a[i].t<=m) ans+=a[i].w,nowday++,q.push(a[i].w);
		else
		{
			if (q.empty()) continue;
			int now=q.top();
			if (a[i].w>now) 
			{
				ans-=now,ans+=a[i].w;
				q.pop();q.push(a[i].w);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1660
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        int ans = 0;
        ans = Math.min(b, d) - Math.max(a, c);

        System.out.println(ans > 0 ? ans : 0);
    }
}


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

int main(void){
    int S;
    int zenhan,kouhan;
    bool YYMM,MMYY;
    cin>>S;
    zenhan=S/100;
    kouhan=S%100;
    if(1<=kouhan and kouhan<=12) YYMM=true;
    else YYMM=false;
    if(1<=zenhan and zenhan<=12) MMYY=true;
    else MMYY=false;
    if(MMYY and YYMM) cout<<"AMBIGUOUS"<<endl;
    else if(MMYY) cout<<"MMYY"<<endl;
    else if(YYMM) cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x <<": "<<x<<"\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> using vec = std::vector<T>;
template <class T = int> T in(){T x; cin>>x;return(x);}
template <class T > void print(T& x){cout<<x<<"\n";}
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N=in<int>();
  vec<int>a(N);
    REP(i,N){
        cin>>a[i];
    }
    sort(ALL(a));
    double ans=0.5*(a[0]+a[1]);
    FORS(i,2,N-1){
        ans=0.5*(ans+a[i]);
    }
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    string s; cin>>s;
    int n=s.size();
    int cnt[100010]={};
    int r=0;
    int rcnt=0, lcnt=0;

    for(int i=0; i<n; i++){
        if(s[i]=='R') rcnt++;
        else lcnt++;
        if(s[i]=='R') r=i;
        if(s[i]=='L' && (s[i+1]=='R' || i==n-1)){
            cnt[r]+=(rcnt+1)/2;
            cnt[r]+=lcnt/2;
            cnt[r+1]+=(lcnt+1)/2;
            cnt[r+1]+=rcnt/2;
            r=0, rcnt=0, lcnt=0;
        }
    }
    for(int i=0; i<n; i++){
        cout<<cnt[i];
        if(i<n-1) cout<<" ";
    }
    cout<<endl;
    return 0;
}

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

using namespace std;

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

    }

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

    vector<int> res;
    set_union(vta.begin(), vta.end(), vtb.begin(), vtb.end(),
              back_inserter(res));

    for (auto x:res) cout << x << endl;
    return 0;
}


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

using namespace std;

#define int long long

const int N = 1e5 + 100;

int a[N];
int n, mx, dis = 1e9, num;

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
	cin >> a[i];
	mx = max(mx, a[i]);
    }
    for (int i = 0; i < n; i++)
	if ((dis >= abs(a[i] - mx / 2) || dis >= abs(a[i] - (mx + 1) / 2)) && a[i] != mx) {
	    dis = min(abs(a[i] - mx / 2), abs(a[i] - (mx + 1) / 2));
	    num = a[i];
	}
    return cout << mx << " " << num, 0;
}

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

int n;
string s;

bool check() {
	int i, j;
	
	for (i = 0; i < n; i++) {
		if (s[i] != 'B') continue;
		for (j = i + 1; j < n; j++) {
			if (s[j] != 'W') break;
		}
		if (j < n && s[j] == 'B' && j - i - 1 > 0) return false;
	}
	return true;
}

int calc() {
	int i, j;
	int ret = 0;
	
	for (i = 0; i < n; i++) {
		if (s[i] != 'W') continue;
		for (j = i + 1; j < n; j++) {
			if (s[j] != 'B') break;
		}
		if (j < n && s[j] == 'W') ret = max(ret, j - i - 1);
	}
	return ret;
}

int main() {
	int i, j, k, l;
	
	cin >> n >> s;
	
	int ans = 0;
	for (i = 0; i < n; i++) {
		if (s[i] != '.') continue;
		s[i] = 'W';
		if (!check()) { s[i] = '.'; continue; }
		int res = calc();
		ans = max(ans, res);
		s[i] = '.';
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3212
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int DP[45];

void fibonacci(int n){
    if(DP[n-1]==0){
        fibonacci(n-1);
    }
    if(DP[n-2]==0){
        fibonacci(n-2);
    }
    DP[n] = DP[n-1] + DP[n-2];
}

int main() {
    int n;
    cin>>n;
    DP[0] = 1;
    DP[1] = 1;
    if(n>=2){
        fibonacci(n);
    }
    cout<<DP[n]<<endl;
}




Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
int main()
{
    ll n;
    cin>>n;
    ll x,y,val,val1;
    map<pair<ll,ll>,ll>m;
    for(int i=1;i<=n;i++)
    {
        val=i;
        x=val%10;
        while(val!=0)
        {
            val1=val%10;
            val/=10;
        }
        y=val1;
        m[{x,y}]++;
    }
    ll ans=0;
    for(auto itr=m.begin();itr!=m.end();itr++)
    {
        x=itr->fi.fi;
        y=itr->fi.se;
        val=itr->se;
        if(x==y)
        {
            ans+=val*val;
        }
        else
        {
            if(m.find({y,x})!=m.end())
            {
                val1=m[{y,x}];
                ans+=val*val1;
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

ll gcd(ll a,ll b ){
    if(a<b) swap(a,b);
    if(b == 0) return a;
    return gcd(a%b,b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll i, j;
  ll n;
  cin >> n;
  n *= 2;
  VP v;
  for (i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      v.pb(P(i, n / i));
      v.pb(P(n / i, i));
    }
  }
  ll ans = INF;
  for(i=0;i<v.size();i++){
      ll g = gcd(v[i].fi,v[i].se);
      if(g > 1) continue;
      ll y = inv_mod(v[i].fi,v[i].se);
      if(y > INF/v[i].fi) continue;
      if(v[i].fi * y <= 1) y+=v[i].se;
      chmin(ans,v[i].fi * y - 1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3896
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 600005
#define MOD 1000000007
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
char s[1005];
int main()
{
    int n,i;
    int d[2];
    scanf("%d",&n);
    bool pos=false;
    int cur=0;
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&d[0],&d[1]);
        if(d[0]==d[1]) cur++;
        else cur=0;
        pos=pos||(cur>=3);
    }
    if(pos)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define max(a,b) a < b ? b : a
#define min(a,b) a > b ? b : a
using namespace std;

int main(){
    string str;
    cin >> str;
    int len = str.length();
    vector<int> cnt(len);
    vector<int> pos;
    rep(i,len-1){
        if(str[i] == 'R' && str[i+1] == 'L'){
            cnt[i]++;
            cnt[i+1]++;
            pos.push_back(i);//
            pos.push_back(i+1);//
        }
    }
    
    int l = 0,r = pos[0];
    int lcnt = -1,rcnt = 0;
    int tmp = 0;

    rep(i,len){
        if(str[i] == 'R'){
            if(str[i+1] == 'L'){
                rcnt += 2;
                r = pos[rcnt];
            }else{
                tmp = r - i;
                if(tmp % 2 == 0)cnt[r]++;
                else cnt[r+1]++;
            }
        }else if(str[i] == 'L'){
            if(str[i-1] == 'R'){
                lcnt += 2;
                l = pos[lcnt];
            }else{
                tmp = i - l;
                if(tmp % 2 == 0)cnt[l]++;
                else cnt[l-1]++;
            }
        }
    }

    rep(i,len){
        cout << cnt[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1528
#include<stdio.h>
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	long long int i;
	long long int sum=0;
	cin >> i;

	for (int n = 0; n <= i; n++) {
		if (n % 3 == 0 || n % 5 == 0) {
			continue;
		}
		else {
			sum += n;
		
		}
	}
	cout << sum;


	return 0;
}

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

typedef long long LL;

const int N = 200005;
LL a[N], v[N], ans; int bit[N], n, k;
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		std::cin >> a[i], a[i] += a[i - 1] - k;
	for (int i = 0; i <= n; ++i) v[i] = a[i];
	std::sort(v, v + n + 1);
	for (int i = 0; i <= n; ++i) a[i] = std::lower_bound(v, v + n + 1, a[i]) - v + 1;
	for (int i = 0; i <= n; ++i) {
		for (int j = a[i]; j; j &= j - 1) ans += bit[j];
		for (int j = a[i]; j <= n + 1; j += j & -j) ++bit[j];
	}
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			String st[]=in.next().split(",");
			int d[]=new int[10];
			int v1,v2;
			int di=0,di2=0;
			for(int i=0;i<10;i++)
			{
				d[i]=Integer.valueOf(st[i]);
				di+=d[i];
			}
			v1=Integer.valueOf(st[10]);
			v2=Integer.valueOf(st[11]);
			double ti=(double)di/(v1+v2);//すれ違う時の時間
			double sure=(double)ti*v1;//すれ違う時の左からの距離
			int i;
			for(i=0;;i++)
			{
				di2+=d[i];
				if(di2>=sure)
					break;
			}
			System.out.println(i+1);
		}
	}
}

Measured memory_bytes: 12000
import fractions
k = int(input())

l = [[-1 for _ in range(k+1)] for _ in range(k+1)]

for i in range(1,k+1):
  for j in range(1,k+1):
     if l[i][j] == -1:
        ans = fractions.gcd(i,j)
        l[i][j] = ans
        l[i][i] = ans
sum = 0
#1種類
for i in range(1,k+1):
  sum += i
#２種類
for i in range(1,k):
  for j in range(i+1,k+1):
    sum += l[i][j]*6

#3種類
for i in range(1,k-1):
  for j in range(i+1,k):
    for m in range(j+1,k+1):
      sum += l[l[i][j]][m]*6

print(sum)

Measured memory_bytes: 11012
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<pii>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
const int MX = 200005;
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
void Main(){
  int n;
  cin>>n;
  vl a(n);
  rep(i,n){
    cin>>a[i];
    a[i]-=(i+1);
  }
  sort(rng(a));
  ll b = a[n/2];
  ll ans = 0;
  rep(i,n){
    ans+= abs(a[i]-b);
  }
  cout<<ans<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e3+10;
int n,m,q;
char s[maxn];
int a[maxn][maxn];
int b[maxn][maxn];
int c[maxn][maxn];
int geta(int x1,int y1,int x2,int y2){
    if(x1>x2||y1>y2) return 0;
    return a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1];
}
int getb(int x1,int y1,int x2,int y2){
    if(x1>x2||y1>y2) return 0;
    return b[x2][y2]-b[x1-1][y2]-b[x2][y1-1]+b[x1-1][y1-1];
}
int getc(int x1,int y1,int x2,int y2){
    if(x1>x2||y1>y2) return 0;
    return c[x2][y2]-c[x1-1][y2]-c[x2][y1-1]+c[x1-1][y1-1];
}
int main()
{
    cin>>n>>m>>q;int i,j;
    for(i=1;i<=n;i++){
        scanf("%s",s+1);
        for(j=1;j<=m;j++){
            a[i][j]=s[j]=='1';
            b[i][j]=a[i][j]&a[i][j-1];
            c[i][j]=a[i][j]&a[i-1][j];
        }
    }
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++){
            a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
            b[i][j]+=b[i-1][j]+b[i][j-1]-b[i-1][j-1];
            c[i][j]+=c[i-1][j]+c[i][j-1]-c[i-1][j-1];
        }
    int x1,x2,y1,y2;
    while(q--){
        scanf("%d%d",&x1,&y1);
        scanf("%d%d",&x2,&y2);
        printf("%d\n",geta(x1,y1,x2,y2)-getb(x1,y1+1,x2,y2)-getc(x1+1,y1,x2,y2));
    }
    return 0;
}

Measured memory_bytes: 49024
MOD=1000000007

def log_n_power(m,n,mod):
    if n==0:
        return 1
    elif n%2:
        k=log_n_power(m,n//2,mod)
        return k*k*m%mod
    else:
        k=log_n_power(m,n//2,mod)
        return k*k%mod

def main():
    m,n=map(int,input().split())
    print(log_n_power(m,n,MOD))

main()


Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;

int n,m,r;
const int INF=1e7;
int land[200][200],sea[200][200],z[1000];
typedef pair<int,int> P;

int main(){


	while(scanf("%d %d",&n,&m),n){
		
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++) land[i][j]=sea[i][j]=INF;
			land[i][i]=sea[i][i]=0;
		}
		
		for(int i=0;i<m;i++){
			int x,y,t;
			char c;
			scanf("%d %d %d %c",&x,&y,&t,&c);
			x--; y--;
			if(c=='S'){
				sea[x][y]=min(sea[x][y],t);
				sea[y][x]=min(sea[y][x],t);
			}else{
				land[x][y]=min(land[x][y],t);
				land[y][x]=min(land[y][x],t);			}
		}
		
		for(int k=0;k<n;k++){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					sea[i][j]=min(sea[i][j],sea[i][k]+sea[k][j]);
					land[i][j]=min(land[i][j],land[i][k]+land[k][j]);
				}
			}
		}
		
		scanf("%d",&r);
		for(int i=0;i<r;i++){
			scanf("%d",&z[i]);
			z[i]--;
		}
		
		vector<vector<int> > dp(1001,vector<int>(201,INF));
		dp[0][z[0]]=0;

		int res=INF;
		for(int i=1;i<r;i++){
			for(int j=0;j<n;j++){
				
				//z[i]???????????????????????¨??°???z[i-1]
				
				for(int k=0;k<n;k++){
					//????????????j?????§?§???????j??????k????????????k??????z[i]?????????				
					dp[i][k]=min(dp[i][k],dp[i-1][j]+land[z[i-1]][j]+sea[j][k]+land[k][z[i]]);
					if(i==r-1 && res>dp[i][k]) res=dp[i][k];
				}
				
				//????????§?§????
				dp[i][j]=min(dp[i][j],dp[i-1][j]+land[z[i-1]][z[i]]);
				if(i==r-1 && res>dp[i][j]) res=dp[i][j];
			}
		}

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

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

#define INF 1000000010
#define EPS 1e-9

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
//#define int long long
#define endl "\n"

int op(int a, int b) { return max(a, b); }
int e() { return -1; }

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  
  segtree<int, op, e> seg(300010);

  int ans=0;
  
  rep(i,n){
    int x;
    cin>>x;
    int l=max(0,x-k);
    int r=min(300010,x+k+1);
    int g=seg.prod(l,r);
    int d=g+1;
    seg.set(x,d);
    if(ans<d) ans=d;
  }
  cout<<ans+1<<endl;


  return 0;
}


Measured memory_bytes: 8508
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int func(int n)
{
	if(n%100 != 0)
		return 0;
	else
		return func(n/100) + 1;
}

int main(void)
{
	int D, N;
	cin >> D >> N;

	int cnt = 0;
	for(int i=1; ; i++){
		if(func(i) == D)
			cnt++;

		if(cnt == N){
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}


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

int main(){
    int N, K;
    cin>>N>>K;
    int D[K];
    rep(i, K){
        cin>>D[i];
    }
    int c=0;
    for(int i=N;i<=99999;i++){
        c=0;
        rep(j, K){
            if(i%10==D[j]){
                c=1;
                break;
            }
        }
        if(i>=10){
            rep(j, K){
                if((i%100-i%10)/10==D[j]){
                    c=1;
                    break;
                }
            }
        }
        if(i>=100){
            rep(j, K){
                if((i%1000-i%100)/100==D[j]){
                    c=1;
                    break;
                }
            }
        }
        if(i>=1000){
            rep(j, K){
                if((i%10000-i%1000)/1000==D[j]){
                    c=1;
                    break;
                }
            }
        }
        if(i>=10000){
            rep(j, K){
                if((i%100000-i%10000)/10000==D[j]){
                    c=1;
                    break;
                }
            }
        }
        if(c==1){
            continue;
        }
        else{
            cout<<i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int a,b,sum,counter,i;
  while(scanf("%d %d",&a,&b)!=-1){
    sum = a + b;
    for(i=0;sum!=0;i++)
      sum = sum / 10;
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 1028
MB_AC = 0
MB_WA = 0
MB_TLE = 0
MB_RE = 0
n = int(input())
for i in range (n):
    ch = input ()
    if (ch =="AC") :
     MB_TLE += 1
    if (ch =="WA") :
     MB_WA += 1
    if (ch =="TLE") : 
     MB_RE += 1
    if (ch =="RE") :
     MB_AC += 1
print('AC x ',MB_TLE)
print('WA x ',MB_WA)
print('TLE x ',MB_RE)
print('RE x ',MB_AC)



Measured memory_bytes: 9060