akhauriyash/Code-Regression huggingface dataset:
#include <iostream>//bit DP
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>PP;
int main(){
  string s;cin>>s;
  if(s=="ABC") cout<<"ARC" <<endl;
  else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <tuple>

template <typename Tp>
Tp gcd(Tp a, Tp b, Tp& x, Tp& y) {
  x = Tp(0);
  y = Tp(1);
  for (Tp u = y, v = x; a;) {
    Tp q = b/a;
    std::swap(x -= q*u, u);
    std::swap(y -= q*v, v);
    std::swap(b -= q*a, a);
  }
  return b;
}

template <typename Tp>
Tp modinv(Tp a, Tp mod) {
  Tp x, y;
  gcd(a, mod, x, y);
  x %= mod;
  if (x < 0) x += mod;
  return x;
}

template <typename Tp>
Tp modadd(Tp a, Tp b, Tp mod) {
  a += b % mod;
  if (a < 0) a += mod;
  if (a >= mod) a -= mod;
  return a;
}

template <typename Tp>
Tp modadd(std::initializer_list<Tp> const& adds, Tp mod) {
  Tp res = 0;
  for (auto const& add: adds) {
    res += add % mod;
    if (res < 0) res += mod;
    if (res >= mod) res -= mod;
  }
  return res;
}

template <typename Tp>
Tp modsub(Tp a, Tp b, Tp mod) {
  a -= b % mod;
  if (a < 0) a += mod;
  if (a >= mod) a -= mod;
  return a;
}

template <typename Tp>
Tp modmul(std::initializer_list<Tp> const& muls, Tp mod) {
  Tp res = 1;
  for (auto const& mul: muls) (res *= mul) %= mod;
  return res;
}

template <typename Tp>
Tp modpow(Tp base, intmax_t iexp, Tp mod) {
  Tp res = 1;
  for (Tp dbl = base; iexp; iexp >>= 1) {
    if (iexp & 1) res = res * dbl % mod;
    dbl = dbl * dbl % mod;
  }
  return res;
}

class poly {
  intmax_t mod;
  std::vector<intmax_t> c{1};

public:
  poly() = default;
  poly(intmax_t mod): mod(mod) {}

  void multiply(intmax_t x) {
    auto d = c;
    c.insert(c.begin(), 0);
    for (size_t i = 0; i < d.size(); ++i)
      (d[i] *= mod-x) %= mod;
    for (size_t i = 0; i < d.size(); ++i)
      (c[i] += d[i]) %= mod;
  }

  void scale(intmax_t x) {
    for (auto& ci: c) (ci *= x) %= mod;
  }

  void divide_by(intmax_t x) {
    std::vector<intmax_t> d(c.size()-1);
    d.back() = c.back();
    for (size_t i = d.size()-1; i--;) {
      (d[i] = c[i+1] + d[i+1]*x) %= mod;
    }
    c = std::move(d);
  }

  intmax_t operator [](size_t i) const { return c[i]; }

  void inspect() const {
    fprintf(stderr, "degree: %zu\n", c.size()-1);
    for (size_t i = 0; i < c.size(); ++i)
      fprintf(stderr, "%jd%c", c[i], i+1<c.size()? ' ': '\n');
  }
};

int main() {
  intmax_t p;
  scanf("%jd", &p);

  std::vector<intmax_t> x(p);
  for (auto& xi: x) scanf("%jd", &xi);

  poly y(p);
  for (intmax_t i = 0; i < p; ++i) y.multiply(i);

  std::vector<poly> ys(p, y);
  for (intmax_t i = 0; i < p; ++i) {
    ys[i].divide_by(i);
    intmax_t s = 1;
    for (intmax_t j = 0; j < p; ++j)
      if (j != i) (s *= p+i-j) %= p;
    ys[i].scale(modinv(s, p));
  }

  std::vector<intmax_t> res(p);
  for (intmax_t i = 0; i < p; ++i)
    for (intmax_t j = 0; j < p; ++j)
      (res[j] += x[i] * ys[i][j]) %= p;

  for (intmax_t i = 0; i < p; ++i)
    printf("%jd%c", res[i], i+1<p? ' ': '\n');
}


Measured memory_bytes: 72832
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    int count = 0;
    int ap = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        if(A[i]%2 == 0){
            count++;
            if(A[i]%3==0 || A[i]%5==0){
                ap++;
            }
        }
    }
    if(ap == count){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int n1000 = n / 500 * 1000;
		int n5 = (n - (n / 500) * 500) / 5 * 5;

		System.out.println(n1000 + n5);
		sc.close();

	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <queue>
#include <cstring>
#include <map>
using namespace std;
typedef pair<int,int> P;
int dx[] = {0,1,1,0,-1,-1};
int dy[] = {1,1,0,-1,-1,0};
int t, n;
bool used[200][200], block[200][200];

struct State {
  int x, y, t;
  State(){}
  State(int ax, int ay, int at):
  x(ax), y(ay), t(at)
  {}
};

void solve() {
  memset(block, 0, sizeof block);
  memset(used, 0, sizeof used);
  for(int i=0;i<n;i++) {
    int tx, ty;
    cin>>tx>>ty;
    tx += 100; ty += 100;
    block[ty][tx] = true;
  }

  int sx, sy;
  cin>>sx>>sy;
  sx += 100; sy += 100;
  
  int res = 0;
  queue<State> que;
  que.push(State(sx, sy, t));
  while (!que.empty()) {
    State s = que.front(); que.pop();
    if (used[s.y][s.x] || block[s.y][s.x]) continue;
    used[s.y][s.x] = true;
    res++;
    
    if (s.t <= 0) continue;
    for (int z = 0; z < 6; z += 1) {
      int tx = s.x + dx[z];
      int ty = s.y + dy[z];
      
      if (used[ty][tx] || block[ty][tx]) continue;
      que.push(State(tx, ty, s.t-1));
    }
  }
  /*
  queue<pair<int,P> > que;
  que.push(make_pair(t, P(sx, sy)));
  while (!que.empty()) {
    pair<int,P> p = que.front(); que.pop();
    int tt = p.first;
    int x = p.second.first, y = p.second.second;
    
    if (used[y][x] || block[y][x]) continue;
    used[y][x] = true;
    res++;
    
    if (tt == 0) continue;
    
    for (int z = 0; z < 6; z += 1) {
      int tx = x + dx[z], ty = y + dy[z];
      if (used[ty][tx] || block[ty][tx]) continue;
      que.push(make_pair(tt-1, P(tx, ty)));
    }
  }
  */
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>t>>n, t||n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
N = int(input())
s_list = {}
for i in range(N):
  S = input()
  if S in s_list.keys():
    s_list[S] += 1
  else:
    s_list[S] = 0
max = 0
maxs = []
for s,c in s_list.items():
  if c > max:
    maxs = [s]
    max = c
  elif c == max:
    maxs.append(s)
maxs.sort()
for m in maxs:
  print(m)

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

// 愚直なシミュレート
int main(){
    int n, l;
    while(cin >> n >> l, n+l){
        vector<vector<int>> v(2, vector<int>(l+1, 0));
        for(int i = 0; i < n; i++){
            char c; int p;
            cin >> c >> p;
            if(c == 'L')    v[0][p] = i+1;
            else            v[1][p] = i+1;
        }
        int tim = -1, exit = 0, id = -1;
        while(exit < n){
            tim++;
            for(int j = l; j >= 0; j--){
                if(v[1][j] == 0)    continue;
                if(j == l){
                    exit++, id = v[1][j];
                    v[1][j] = 0;
                }else{
                    swap(v[1][j], v[1][j+1]);
                }
            }
            for(int j = 0; j <= l; j++){
                if(v[0][j] == 0)    continue;
                if(j == 0){
                    exit++, id = v[0][j];
                    v[0][j] = 0;
                }else{
                    swap(v[0][j-1], v[0][j]);
                }
            }
            for(int j = 0; j <= l; j++){
                if(v[0][j] != 0 && v[1][j] != 0){
                    swap(v[0][j], v[1][j]);
                }
            }
        }
        cout << tim << " " << id << endl;
    }
    return 0;
}


Measured memory_bytes: 3060
S = input()
a = int(S[0]+S[1])
b = int(S[2]+S[3])
isyymm = 0
ismmyy = 0
if a>=0 and b>=0:
    if a<=12 and a>0:
        ismmyy = 1
    if b<=12 and b>0:
        isyymm = 1

ans = ['NA','YYMM','MMYY','AMBIGUOUS']
print(ans[isyymm+ismmyy*2])


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <iomanip>

#define _USE_MATH_DEFINES
#include <math.h>

#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	int a = 0;
	int b = 0;
	int C = 0;
	double h = 0;
	double r = 0;
	double theta = 0;

#if INPUT_FROM_FILE
	ifs >> a >> b >> C;
#else
	std::cin >> a >> b >> C;
#endif

	r = C * M_PI / 180.0;
	h = b * sin(r);

	theta = atan2(a - b * cos(r), h);

	std::cout << std::fixed << std::setprecision(5) << 0.5 * a * h << std::endl; 
	std::cout << std::fixed << std::setprecision(5) << a + b + h / cos(theta) << std::endl; 
	std::cout << std::fixed << std::setprecision(5) << h << std::endl; 
	
	return 0;
}

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

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b,max;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            max = a + b;
            if (max < a - b) max = a - b;
            if (max < a * b) max = a * b;

           
            Console.WriteLine(max);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int inN = stdin.nextInt();
		Map<Character, Integer> nameMap = new HashMap<>();
		for (int i = 0; i < inN; i++) {
			char first = stdin.next().charAt(0);
			int count = nameMap.getOrDefault(first, 0) + 1;
			nameMap.put(first, count);
		}

		char[][] firstArray = {
			{
				'M', 'A', 'R'
			}, {
				'M', 'A', 'C'
			}, {
				'M', 'A', 'H'
			}, {
				'M', 'R', 'C'
			}, {
				'M', 'R', 'H'
			}, {
				'M', 'C', 'H'
			}, {
				'A', 'R', 'C'
			}, {
				'A', 'R', 'H'
			}, {
				'A', 'C', 'H'
			}, {
				'R', 'C', 'H'
			}
		};

		long count = 0;
		for (char[] array : firstArray) {
			long pattern = 1;
			for (char first : array) {
				if (nameMap.containsKey(first)) {
					pattern *= nameMap.get(first);
				}
				else {
					pattern = 0;
					break;
				}
			}
			count += pattern;
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 46548
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
  FIN
    int n;
    string s, t, r = "";
  	cin >> n;
  	cin >> s >> t;
  	for (int i = 0; i < n; i++) {
      r += s[i];
      r += t[i];
    }
  	cout << r << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

// GCD,LCMを求める関数
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}

signed main(){
	int n; cin>>n;
	string s; cin>>s;
	VI r,g,b;
	rep(i,n){
		if(s[i]=='R') r.PB(i);
		if(s[i]=='G') g.PB(i);
		if(s[i]=='B') b.PB(i);
	}
	ll ans = r.size()*g.size()*b.size();

	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			int k=2*j-i;
			if(k>=n) continue;
			if(s[i]!=s[j]&&s[j]!=s[k]&&s[k]!=s[i]) ans--;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
		
		
		ll x,y;
		cin>>x>>y;
		
		if(x<y){
			if(x*y>0){
				ce(y-x)
			}else{
				if(abs(x)<abs(y)){
                  if(x!=0)
					ce(abs(y)-abs(x)+1)
                    else
                      ce(abs(y)-abs(x))
				}else{
                  if(abs(x)>abs(y)){
                    ce(min(abs(x)-abs(y)+1,y-x))
                  }else{
                    ce(1)
                    }
				}
			}
		}else if(x>y){
			if(x*y>0){
				if(x>0){
					ce(x-y+2)
				}else{
					ce(x-y+2)
				}
			}else{

				ce(abs(abs(y)-abs(x))+1)


			}
		}else{
			ce(0)
		}
		
		
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,t,i,res=0;
  cin >> n;
  for(i=1;i<=n;i++){
    cin >> t;
    if(t!=i)
      res++;
    if(res>2){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "2 2" ].solve == 2 );
	assert( [ "2 3" ].solve == 18 );
	assert( [ "141421 356237" ].solve == 881613484 );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s"( n, m );
	
	const M = 10L ^^ 9 + 7;
	
	// as[i]!=as[j]かつbs[i]!=bs[j]になるパターン数を計算
	auto ans = m.permutation!M( n ) ^^ 2;
	
	// 包除原理を使ってas[i]==bs[i]になるパターンを除外
	foreach( i; 1L .. n + 1 )
	{
		auto x = n.combination!M( i ) * m.permutation!M( i );		// as[i]==bs[i]になる箇所のパターン数
		auto y = ( m - i ).permutation!M( n - i ) ^^ 2;				// それ以外の箇所のパターン数
		if( i % 2 ) ans -= x * y;
		else        ans += x * y;
	}
	return ans;
}

// モジュラ整数型（n mod M）
struct ModWorld( long M )
{
	long n;
	
	void opUnary( string OP )() if( OP == "++" ){ this.n = ( this.n + 1 ) % M; }
	void opUnary( string OP )() if( OP == "--" ){ this.n = ( this.n + M - 1 ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "+"  ){ this.n = ( this.n + r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "-"  ){ this.n = ( this.n + M - r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "*"  ){ this.n = ( this.n * r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "/"  ){ this *= r ^^ ModWorld( M - 2 ); }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "^^" )
	{
		auto a = this.n;
		this.n = 1L;
		for( auto i = r.n; 0 < i; i >>= 1 )
		{
			if( i & 1 ) this.n = ( this.n * a ) % M;
			a = ( a * a ) % M;
		}
	}
	auto opBinary( string OP )( ModWorld r ){ auto l = this; l.opOpAssign!OP( r ); return l; }
	
	void opAssign( long r ){ this.n = r; }
	void opOpAssign( string OP )( long r ){ this.opOpAssign!OP( ModWorld( r ) ); }
	auto opBinary( string OP )( long r ){ return this.opBinary!OP( ModWorld( r ) ); }
	auto opBinaryRight( string OP )( long l ){ return ModWorld( l ).opBinary!OP( this ); }
	auto opEquals( long r ){ return this.n == r; }
	
	auto toString(){ return this.n.to!string; }
}

// 階乗
auto factorial( long M )( long x )
{
	static memo = [ ModWorld!M( 1L ) ];
	if( memo.length <= x )
	{
		auto i = memo.length.signed;
		memo.length = x + 1;
		for( ; i <= x; i++ ) memo[ i ] = memo[ i - 1 ] * i;
	}
	return memo[ x ];
}

// 組み合わせ数
auto combination( long M )( long n, long k )
{
	if( n < k ) return ModWorld!M( 0L );
	else        return n.factorial!M / ( k.factorial!M * ( n - k ).factorial!M );
}

// 順列数
auto permutation( long M )( long n, long k )
{
	if( n < k ) return ModWorld!M( 0L );
	else        return n.factorial!M / ( n - k ).factorial!M;
}


Measured memory_bytes: 6680
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <fstream>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

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

ll facmemo[200000] = {};

ll factorial(ll n) {//階乗
	if (facmemo[n] != 0) return facmemo[n];
	if (n == 0) return 1;
	ll ret = n * factorial(n - 1);
	ret %= MODU;
	return facmemo[n] = ret;
}

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b, ll m) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b, m - 2, m)) % m;
}
ll ncr(ll n, ll r) {
	if (r == 0) return 1;
	if (n < r) return 1;
	return divmod(factorial(n), (factorial(r) * (factorial(n - r))) % MODU, MODU);
}

bool sankaku(int a, int b, int c) {
	return a <= b + c && b <= a + c && c <= b + a;
}
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}

signed main() {
	int n;
	cin >> n;
	vector<int> p(n);
	int Min = INT_MAX;
	int ans = 0;
	REP(i, n) {
		cin >> p[i];
		if (Min >= p[i]) ans++;
		Min = min(Min, p[i]);
	}

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


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
typedef pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

int main() {
   int N, M;
   cin >> N >> M;
   int tmp1, tmp2;
   vector<ipair> AB;
   for(int i = 0; i < M; i++){
      cin >> tmp1 >> tmp2;
      AB.push_back(ipair(tmp1, tmp2));
   }
   sort(AB.begin(), AB.end(), lessPair);
   int ans = 0;
   int btmp = 0;
   for (vector<ipair>::iterator it = AB.begin(); it != AB.end(); ++it) {
      if (it->first >= btmp) {
         btmp = it->second;
         ans++;
      }
   }

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


Measured memory_bytes: 1400
import java.util.Scanner;
public class Main{
public static void main(String[] args){
	int i=1;
	int x;
	Scanner input = new Scanner(System.in);
 while(true){
				x=input.nextInt();
					if(x==0){
						break;
					}
					System.out.println("Case "+i+": "+x);
					i++;
				}
}
}


Measured memory_bytes: 41416
from collections import Counter
n, k = map(int, input().split())
*a, = map(int, input().split())

c = Counter(a)
kv = sorted(c.items(), key=lambda x: x[1], reverse=True)

if n <= k:
    print(0)
else:
    ans = n
    for i in range(k):
        try:
            ans -= kv[i][1]
        except:
            pass
    print(ans)


Measured memory_bytes: 39344
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, d, x, ans;

	cin>>n>>d>>x;

	vi a(n);

	ans=x;
	rep(i, n){
		cin>>a[i];
		ans+=(d-1)/a[i]+1;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  vector<vector<char>> a(n, vector<char>(n));
  rep(i, n) rep(j, n) cin >> a[i][j];

  vector<vector<char>> ng(n, vector<char>(n, '.'));
  if (a == ng) {
    cout << -1 << '\n';
    return 0;
  }
  int ans = inf;
  rep(i, n) {
    int res = 1;
    rep(j, n) {
      if (a[i][j] == '.') res++;
    }
    rep(j, n) {
      if (a[j][i] == '#') {
        res--;
        break;
      }
    }
    chmin(ans, res);
  }
  rep(j, n) {
    rep(i, n) {
      if (a[i][j] == '.') {
        ans++;
        break;
      }
    }
  }
  cout << ans << '\n';


  




  
  return 0;
}

Measured memory_bytes: 4032
//inlclude前用define 
#define _USE_MATH_DEFINES

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

using namespace std;

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

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

  int sum=0;
  if(k>=a) sum+=a,k-=a;
  else sum+=k,k=0;

  //cout<<k<<endl;
  if(k>=b) k-=b;
  else k=0;

  //cout<<k<<endl;
  if(k>=0) sum-=k;

  cout<<sum<<endl;

}


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

#define PI 3.14159265359

using namespace std;

int main(int argc,char *argv[])
{
  int n=0,m=0;
  cin>>n;
  cin>>m;
  
  vector<int> ai;
  ai.resize(m);
  
  int judge=n;
  
  for(int i=0;i<m;i++){
    cin>>ai[i];
    judge-=ai[i];
  }
  
  if(judge>=0){
    cout<<judge<<endl;
  }
  else cout<<"-1"<<endl;
}

Measured memory_bytes: 3668
#include<iostream>
#include<cstdio>
#define md 1000000007
using namespace std;

int n,i;
long long ans=1,cnt[505];

char rc;
char get()
{
	rc=getchar();
	while(rc<'a'||rc>'z')
		rc=getchar();
	return rc;
}

int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
		cnt[get()]++;
	for(i='a';i<='z';i++)
		ans=ans*(cnt[i]+1)%md;
	cout<<ans-1;
	return 0;
}

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

ll b0(ll p){
  return 1-(p%2);
}
 
ll b1(ll p){
  if(p==0) return 2;
  return p%2;
}

ll co(ll p,ll j){
  if(j==2) return b0(p);
  if(j==1||j==3) return b1(p);
  return p;
}

int main(){
  ll l,a[200010],dp[200010][5],k[5]={};
  cin>>l;
  fr(i,l) cin>>a[i];
  fr(j,5) dp[0][j]=0;
  fr(i,l){
    k[0]=dp[i][0];
    fr(j,4) k[j+1]=min(k[j],dp[i][j+1]);
    fr(j,5) dp[i+1][j]=k[j]+co(a[i],j);
  }
  ll ans=dp[l][4];
  fr(j,4) ans=min(ans,dp[l][j]);
  cout<<ans<<endl;
}

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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h){
        cin >> s[i];
    }
    int ans = h+w;
    rep(n,1<<(h-1)){
        int cut = __builtin_popcount(n);
        int count = cut;
        bool cutable = true;
        vector<vector<int>> white(cut+1,vector<int>(w,0));
        int l = 0;
        rep(i,h){
            rep(j,w){
                white[l][j] += s[i][j]-'0';
            }
            if(n>>i&1){
                l++;
            }
        }

        /*rep(l,cut+1){
            rep(j,w){
                cout << white[l][j];
            }
            cout << endl;
        }
        cout << endl;*/

        vector<int> v(cut+1);
        rep(i,cut+1){
            v[i] = white[i][0];
            if(v[i] > k){
                cutable = false;
                break;
            }
        }
        if(!cutable) continue;

        for(int j = 1; j < w; j++){
            bool ct = false;
            rep(i,cut+1){
                if(white[i][j] > k){
                    cutable = false;
                    break;
                }
                else{
                    v[i] += white[i][j];
                    if(v[i] > k) ct = true;
                }
            }
            if(!cutable) break;
            if(ct){
                rep(i,cut+1){
                    v[i] = white[i][j];
                }
                count++;
            }
        }
        if(!cutable) continue;
        ans = min(ans,count);
    }

    cout << ans << endl;
    
}


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

int main(){
  string s,ans;
  cin >> s;
  rep(i,s.size()) ans+='x';
  cout << ans << endl;
}

Measured memory_bytes: 3636
import math

H = int(input())
A = [None] + list(map(int, input().split()))
for i in range(1, H+1):
    print(f"node {i}: key = {A[i]}, " 
          + (f"parent key = {A[math.floor(i/2)]}, " if (math.floor(i/2) >= 1) else "")
          + (f"left key = {A[2*i]}, " if 2*i <= H else "")
          + (f"right key = {A[2*i+1]}, " if (2*i + 1) <= H else "")
          )


Measured memory_bytes: 5696
n = input()
array = []
base = 0
for i in range(n):
	inst = raw_input().split()
	if inst[0][0] == 'i':
		array.append(int(inst[1]))
	elif inst[0] == "delete":
		if int(inst[1]) in array:
			x = array[::-1].index(int(inst[1]))
			if x != -1 and int(inst[1]):
				del array[-x-1]
	elif inst[0][6] == 'F':
		array.pop()
	else:
		base += 1
print (" ".join(map(str,array[base:][::-1])))

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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

int cnt[2001];

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int n;
	cin>>n;
	cnt[1]=cnt[2]=0;
	cnt[3]=cnt[4]=cnt[5]=1;
	cnt[6]=2;
	forn(i,7,n+1)
		cnt[i]=(cnt[i-1]+cnt[i-3])%1000000007;
	cout<<cnt[n]<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    ll n,k;cin>>n>>k;
    vector<ll> x(n),mn(1,0),pl(1,0);
    for(int i=0;i<n;i++){
        cin>>x[i];
        if(x[i]<0) mn.push_back(x[i]);
        else pl.push_back(x[i]);
    }
    sort(mn.rbegin(),mn.rend());
    ll msz=mn.size()-1,psz=pl.size()-1;
    ll res = 1e15;
    if(msz>=k) res=abs(mn[k]);
    if(psz>=k) res=min(res,pl[k]);
    for(int i=1;i<=min(psz,k-1);i++){
        if(k-i>msz) continue;
        ll tmp=pl[i];
        tmp += pl[i]-mn[k-i];
        res=min(res,tmp);
    }
    for(int i=1;i<=min(msz,k-1);i++){
        if(k-i>psz) continue;
        ll tmp=abs(mn[i]);
        tmp += pl[k-i]-mn[i];
        res=min(res,tmp);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 2424
from enum import Enum

def main():
  initialStones = readProblem()
  minOperationCount = getMinOperationCount(initialStones)
  print(minOperationCount)

def getMinOperationCount(initialStones):
  whiteOnLeft = 0
  redOnRight = 0  # count just bellow
  for stone in initialStones:
    if Color[stone] == Color.R:
      redOnRight += 1
  minOperationCount = len(initialStones)  # effectively infinite
  for separator in range(len(initialStones) + 1):
    operationCount = max(whiteOnLeft, redOnRight)
    if minOperationCount > operationCount:
      minOperationCount = operationCount
    
    if separator < len(initialStones):
      if Color[initialStones[separator]] == Color.R:
        redOnRight -= 1
      else:
        whiteOnLeft += 1
    else:
      pass  # already we have min value
  return minOperationCount

def readProblem():
  input()  # not use
  return input()

class Color(Enum):
  R = 'Red'
  W = 'White'
  
if __name__ == '__main__':
  main()


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

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    set<int>s;
    for(int i=a;i<a+k;i++){
        if(i<=b){
            s.insert(i);
        }
    }
    for(int i=b;i>b-k;i--){
        if(i>=a)s.insert(i);
    }
    for(auto i=s.begin();i!=s.end();i++)cout<<*i<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
        static List<int> t = new List<int>();
    static decimal result;
static StringBuilder sb = new StringBuilder();
static int N,M,K;
    static void Main()
    {
Read5();
K=s[0];N=s[1];
int max=0;
for(int i=0;i<N-1;i++){if(t[i+1]-t[i]>max){max=t[i+1]-t[i];}}
if(t[0]+K-t[N-1]>max){max=t[0]+K-t[N-1];}
result=K-max;
                  Console.WriteLine(result.ToString());

    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < 2; i++) { s.Add(int.Parse(tmp[i])); }
                string[] tmp2 = Console.ReadLine().Split(' ');
        for (int i = 0; i < s[1]; i++) { t.Add(int.Parse(tmp2[i])); }
 
    }


}

Measured memory_bytes: 34524
a1_list = list(map(int, input().split()))
a2_list = list(map(int, input().split()))
a3_list = list(map(int, input().split()))
# a = [a1_list, a2_list, a3_list]
n = int(input())
b_list = []
for i in range(n):
    b_list.append(int(input()))


def is_bingo(a_coor):
    if a_coor[0][0] + a_coor[1][0] + a_coor[2][0] == 0:
        return True
    elif a_coor[0][1] + a_coor[1][1] + a_coor[2][1] == 0:
        return True
    elif a_coor[0][2] + a_coor[1][2] + a_coor[2][2] == 0:
        return True
    elif a_coor[0][0] + a_coor[0][1] + a_coor[0][2] == 0:
        return True
    elif a_coor[1][0] + a_coor[1][1] + a_coor[1][2] == 0:
        return True
    elif a_coor[2][0] + a_coor[2][1] + a_coor[2][2] == 0:
        return True
    elif a_coor[0][0] + a_coor[1][1] + a_coor[2][2] == 0:
        return True
    elif a_coor[2][0] + a_coor[1][1] + a_coor[0][2] == 0:
        return True
    return False


for b in b_list:
    a1_list = [0 if a==b else a for a in a1_list]
    a2_list = [0 if a==b else a for a in a2_list]
    a3_list = [0 if a==b else a for a in a3_list]
if is_bingo([a1_list, a2_list, a3_list]):
    print('Yes')
else:
    print('No')

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

using namespace std;

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

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

    long long res = 1000;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] < a[i + 1]) {
            res = res / a[i] * a[i + 1] + res % a[i];
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n,a = 0,b = 0;
    cin >> n;
    vector<int>v(n);

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

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

    cout << a - b << endl;

    return 0;
}

Measured memory_bytes: 256
import math
def inv(a,mod=10**9+7):
    return(pow(a,mod-2,mod))

x,y = map(int,input().split())
mod = 10**9+7
reuslt = 0
if (x+y) %3 == 0:

    n = (2*x-y)//3
    m = (2*y-x)//3
    r = min(n,m)
    result = 1
    if n < 0 or m < 0:
        print(0)
        exit()
    for i in range(r):
        result = result*(n+m-i)*inv(i+1,mod)%mod
    
else :
    result = 0

print(result)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a > b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a < b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////


int main() {
	int m1, d1, m2, d2;
	cin >> m1 >> d1;
	cin >> m2 >> d2;
	if (m1 != m2)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = scn.nextInt();
		}
		selectionSort(A, N);
	}

	public static void selectionSort(int[] A, int N) {
		int swap = 0;

		for (int i = 0; i < N; i++) {
			int minj = i;
			for (int j = i; j < N; j++) {
				if (A[j] < A[minj]) {
					minj = j;
				}
			}
			if (minj != i) {
				int buf = A[minj];
				A[minj] = A[i];
				A[i] = buf;
				swap++;
			}
		}
		printArray(A);
		System.out.println(swap);
	}

	public static void bubbleSort(int[] A, int N) {
		boolean flag = true;
		int swap = 0;
		while (flag) {
			flag = false;
			for (int i = N - 1; i > 0; i--) {
				if (A[i - 1] > A[i]) {
					int buf = A[i];
					A[i] = A[i - 1];
					A[i - 1] = buf;
					flag = true;
					swap++;
				}
			}
		}
		printArray(A);
		System.out.println(swap);
	}

	public static void insertionSort(int[] A, int N) { // N個の要素を含む0-オリジンの配列A
		for (int i = 0; i < N; i++) {
			int v = A[i];
			int j = i - 1;
			while (j >= 0 && A[j] > v) {
				A[j + 1] = A[j];
				j--;
				A[j + 1] = v;
			}
			printArray(A);
		}
	}

	public static void printArray(int[] A) {
		for (int i = 0; i < A.length; i++) {
			System.out.print(((i == 0) ? "" : " ") + A[i] + ((i == A.length - 1) ? "\n" : ""));
		}
	}

}



Measured memory_bytes: 26376
#include <bits/stdc++.h>
#define INF 1000000
#define watch(x) cout << setw(10) << "[" << (#x) << ":] " << (x) 
#define FORE(i,v,n) for(int i=v;i<n;i++)
#define FORI(i,v,n) for(int i=v;i<=n;i++)
       
using namespace std;

int const MOD = 1000000007;

int test_case(){             
    int n,k;
    cin >> k >> n;
    vector<int> house,diff(n,0);
    int value;
    FORE(i,0,n){
        cin >> value;
        house.emplace_back(value);
    }
    house.emplace_back(k+house[0]);
    int sum = 0;
    FORE(i,0,n){
        diff[i] = house[i+1] - house[i];
        //watch(diff[i]);
    }
    
    FORE(i,0,n) sum += diff[i];
    int max = *max_element(diff.begin(), diff.end());
    //watch(max);
    cout << sum - max;   
             
    return 0;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int test=1;
	//cin >> test;
	for(int i=0;i<test;i++){
		//cout << "Case " << i << endl;
		test_case();
	}
	return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int main() {
	string s;
	cin >> s;
	if( s[2] == s[3] && s[4] == s[5] )
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
		int a = scan.nextInt();
		int b = scan.nextInt();
		
        out.println(a <= 9 && b <= 9 ? a * b : -1);
        out.close();
        
    }
}

Measured memory_bytes: 35904
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  ll n; cin >> n;
  ll cn = n;
  int sn = 0;
  while(n > 0) {
    sn += n%10;
    n /= 10;
  }
  cout << (cn%sn == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long n, k;

	std::cin >> n >> k;

	std::cout << std::min(n % k, (n / k + 1) * k - n) << std::endl;

	return 0;
}

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

using namespace std;

int main(){
  int N;
  int O = 0;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  
  sort(A,A+N);
  
  int X[A[N-1]+1];
  
  for(int i=0;i<A[N-1]+1;i++){
    X[i] = 0;
  }
  
  
  for(int i=0;i<N;i++){
    X[A[i]]++;
    if(X[A[i]]==1){
      for(int j=2;j*A[i]<A[N-1]+1;j++){
          X[j*A[i]]++;
      }
    }
  }
  
//  for(int i=0;i<N;i++){
//    cout << A[i] << ":" <<X[A[i]] << endl;
//  }
  
  for(int i=0;i<N;i++){
    if(X[A[i]]==1){
      O++;
    }
  }
  
  cout << O;
  return 0;
}


Measured memory_bytes: 8308
import java.util.*;
public class Main{
  public static void main(String[] args){
    if(Atcoder.getValue() >= 30)
      System.out.println("Yes");
    else
      System.out.print("No");
  }
}
class Atcoder {
    public static int getValue(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        return n;
    }
    public static int[] getValues(int size){
        Scanner sc = new Scanner(System.in);
        int[] values = new int[size];
        for(int i = 0; i < size; i++){
            values[i] = sc.nextInt();
        }
        return values;
    }
}

Measured memory_bytes: 35712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		long e = Math.max(a,b) * Math.max(c, d);
		long f = Math.max(a,b) * Math.min(c, d);
		long g = Math.min(a,b) * Math.max(c, d);
		long h = Math.min(a,b) * Math.min(c, d);
		System.out.println(Math.max(Math.max(e,f),Math.max(g, h)));

	}

}


Measured memory_bytes: 35664
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <math.h>
using namespace std;
int main()
{
    long long int n, m;
    cin >> n >> m;
    if (n > m) swap (n, m);
    if(n==1){
        if(m==1) cout << 1;
        else cout << m-2;
    }
    else cout << (m-2)*(n-2);
    return 0;
}


Measured memory_bytes: 256
//URL

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

const int PRIME_MAX = 200000;

int M(int N, int P, vector<int> &prime)
{
	vector<int> matsu;	

	int border=0;
	rep(i,prime.size()){
		if(prime[i] > N){ border = i; break; }
	}
	
	REP( i, border, border+101 ){
		REP( j, i, i+101 ){
			matsu.push_back(prime[i] + prime[j]);
		}
	}

	sort( ALL(matsu) );

	return matsu[P-1];
}

int main()
{
	bool is_prime[PRIME_MAX];
	is_prime[0] = false;
	is_prime[1] = false;
	REP(i,2,PRIME_MAX) is_prime[i] = true;
	REP(i,2,PRIME_MAX) {
		if (is_prime[i]) {
				for (int j=i+i; j<PRIME_MAX; j+=i) is_prime[j] = false;
		}
	}

	vector<int> prime;
	rep(i,PRIME_MAX){
		if(is_prime[i]){ prime.push_back(i); }
	}

	int N,P;

	while(true)
	{
		cin >> N >> P;
		if(N == -1){ break; }
		
		cout << M(N,P,prime) << endl;
	}
	return 0;
}

Measured memory_bytes: 1540
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,a,b) 	for(int i=(a);i<(b);i++)
using ll = long long;
using namespace std;

int main(){
	ll a,b,c,n;
	cin >> a >> b >> c >> n;
	if(n%2==0){
		if(abs(b-a)>=1e18)	cout << "Unfair\n";
		else	cout << a-b << endl;
	}
	else{
		if(abs(b-a)>=1e18)	cout << "Unfair\n";
		else	cout << b-a<< endl;
	}
	return 0;
}

Measured memory_bytes: 256
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
P=list(map(int,input().split()))  
for i in range(0,200):
  if (X-i) not in P:
    ans=X-i
    break
  if (X+i) not in P:
    ans=X+i
    break
print(ans)

Measured memory_bytes: 9124
/////////////////////////////////////////////////
//                                             //
//                 _ooOoo_                     //
//                o8888888o                    //
//                88" . "88                    //
//                (| -_- |)                    //
//             ____/`---'\\____                //
//           .'  \|     |//  `.                //
//           /  \|||  :  |||// \               //
//          /  _||||| -:- |||||- \             //
//          |   | \\  -  /// |   |             //
//          | \_|  ''\---/''  |  |             //
//          \  .-\__  `-`  ___/-. /            //
//         ___`. .'  /--.--\  `. . __          //
//      ."" '<  `.___\_<|>_/___.'  >'"".       //
//     | | :  `- \`.;`\ _ /`;.`/ - ` : | |     //
//     \  \ `-.   \_ __\ /__ _/   .-` /  /     //
//=====`-.____`-.___\_____/___.-`____.-'=======//
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
//.............................................//
/////////////////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct mat{
    __int128 m[2][2];
};
ll modn;
mat operator *(const mat &a,const mat &b){
    mat ans;

    for(int i=0;i<2;i++)for(int j=0;j<2;j++){
        ans.m[i][j]=0;
        for(int k=0;k<2;k++){
            ans.m[i][j]+=a.m[i][k]*b.m[k][j];
            ans.m[i][j]%=modn;
        }
    }
    return ans;
}
mat powmod(mat a,ll p){
    mat ans;
    ans.m[0][0]=ans.m[1][1]=1;
    ans.m[1][0]=ans.m[0][1]=0;
    while(p){
        if(p%2){
            ans = ans*a;
        }
        p/=2;
        a = a * a;
    }
    return ans;
}
int main(){
    int n;
    cin>>n;
    cout<<(n-1)/2<<endl;
    return 0;
}



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

int main()
{
        int n,m;
        cin>> n>>m;
        int ans = 0;
        for(int i = 0; i< m;i++)
        {
                int a;
                cin >> a;
                ans += a;
        }
        if(ans <= n)
        {
                int b = n-ans;
                cout << b<< endl;
        }
        else
        {
                cout <<"-1" << endl;
        }


        
}


Measured memory_bytes: 3636