akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
	//file();
	fast();
	int n, m; cin >> n >> m;
	cout << (n * (n - 1) + m * (m - 1)) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main() {
	int n;
	int h[22];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int x = 0, count = 0;
	for (int i = 0; i < n; i++) {
		if (x <= h[i]) {
			x = h[i];
			count++;
		}
	}
	cout << count << endl;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MAXN = 1000;
const int MAXS = 10000;
ll dp[MAXN + 5][2 * MAXS + 5];

auto maxx(auto& a, auto b){a = max(a, b);}

void reorder(auto& vec, const auto& mapping) {
  auto vec2 = vec;
  auto n = sz(vec);
  rep(i, 0, n)
    vec[i] = vec2[mapping[i]];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vi w(n), s(n), v(n);
  rep(i, 0, n) {
    cin >> w[i] >> s[i] >> v[i];
  }
  vi ind(n);
  iota(all(ind), 0);
  sort(all(ind), [&](int i, int j) {return s[i] + w[i] < s[j] + w[j];});


  reorder(v, ind);
  reorder(w, ind);
  reorder(s, ind);

  
  rep(i, 0, MAXN + 1) rep(j, 0, 2 * MAXS + 1)
    dp[i][j] = -1;
  dp[0][0] = 0;
  rep(i, 0, n) {
    for (int weight = MAXS; weight >= 0; weight--) {
      if (dp[i][weight] == -1) continue;
      maxx(dp[i + 1][weight], dp[i][weight]);
      if (weight <= s[i]) {
	maxx(dp[i + 1][weight + w[i]], dp[i][weight] + v[i]);
      }
    }
  }
  auto res = 0LL;
  rep(i, 0, n + 1)
    maxx(res, *max_element(all(dp[i])));
  cout << res << '\n';
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

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

int W, H, ans;
string grid[22];

int rec(int x, int y) {
	int res = 1;
	
	grid[y][x] = '#';
	
	for_(d,0,4) {
		int nx = x + dx[d], ny = y + dy[d];
		if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
		if (grid[ny][nx] == '#') continue;
		res += rec(nx, ny);
	}
	
	return res;
}

int main() {
	while (cin >> W >> H, W) {
		for_(i,0,H) cin >> grid[i];
		
		for_(i,0,H) for_(j,0,W) if (grid[i][j] == '@') cout << rec(j, i) << endl;
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
typedef long long lint;
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;
}
/* templates */ /* templates */ /* templates */ /* templates */ /* templates */

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

    string s;
    cin >> s;
    if(s <= "2019/04/30") {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef pair<int, int> P;

P f(int x) {
  // 末尾
  int a = x % 10;
  // 先頭
  int b = 0;
  while (x) {
    b = x;
    x /= 10;
  }
  return P(a, b);
}

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

  map<P, int> freq;
  for (int i = 1; i <= n; i++) {
    P p = f(i);
    freq[p]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    P p = f(i);
    P q(p.second, p.first);
    ans += freq[q];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int A[500005],i,H;
void maxHeapify(int p)
{
    int l=p*2+1;
    int r=p*2+2;
    int lg=p;
    if(l<=H&&A[l]>A[lg])
        lg=l;
    if(r<=H&&A[r]>A[lg])
        lg=r;
    if(lg!=p){
  
        r=A[p];
        A[p]=A[lg];
        A[lg]=r;
        maxHeapify(lg);
    }
}
int main()
{
    scanf("%d",&H);
    for(i=0;i<H;i++)
        scanf("%d",A+i);
    for(i=H/2;i>=0;i--)
        maxHeapify(i);
    for(i=0;i<H;i++)
        printf(" %d",A[i]);
    puts("");
    return 0;
}


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

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  
  for(int i=0;i < k;i++){
    if(a%2==1)a--;

    a/=2;
    b += a;

    swap(a,b);
    /*if(b%2==1) b--;
    b/=2;
    a += b;*/
  }
  if(k%2)cout << b << " " << a << endl;
  else cout << a << " " << b << endl;
  return 0;
}

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

int main() {
	int h, a;
	cin >> h >> a;
	int count = h / a;
	if (h % a == 0) {
		cout << count << endl;
	}
	else {
		cout << count + 1 << endl;
	}
	return 0;
}

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

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    if ((b - a) % 2 == 0)
        cout << (b - a) / 2 << endl;
    else
        cout << min(a - 1, n - b) + 1 + (b - a - 1) / 2 << endl;
}

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


int N; int arr[100000][3];

// STATES  : day / what he did the last day
int dp[100000][3]; 
 
int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2] ;
    }

    for(int i = 0; i < N; i++)
        for(int j = 0; j < 3; j++)  
            dp[i][j] = INT_MIN;

    for(int j = 0; j < 3; j++)
    {
        dp[0][j] = arr[0][j];
    }
    for(int i = 1; i < N; i++)
    {
        dp[i][0] = max(dp[i-1][2] + arr[i][0], dp[i-1][1] + arr[i][0]);
        dp[i][1] = max(dp[i-1][2] + arr[i][1], dp[i-1][0] + arr[i][1]);
        dp[i][2] = max(dp[i-1][0] + arr[i][2], dp[i-1][1] + arr[i][2]); 

        // cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl;
    }

    printf("%d", max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])));


}

Measured memory_bytes: 2560
def Stamina(N, X_list, P):
  stamina = 0
  for i in range(N):
    X = X_list[i]
    stamina += X * X - 2 * P * X
  stamina += N * P * P
  return stamina

N = int(input())
X_list = list(map(int, input().split()))
P1 = int(sum(X_list) / N)
P2 = P1 + 1
stamina1 = Stamina(N, X_list, P1)
stamina2 = Stamina(N, X_list, P2)
print (min(stamina1, stamina2))
  


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
char s[22];
int len,ans,res,pos[22];
inline int calc() {
	int dd=0,sum=0;
	for ( int i=0;i<len-1;i++ ) {
		dd=dd*10+s[i];
		if(pos[i]) {
			sum+=dd;
			dd=0;
		}
	}
	dd=dd*10+s[len-1];
	return dd+sum;
}
inline void dfs(int k) {
	if(k==len-1) {
		ans+=calc();
		return;
	}
	pos[k]=0;
	dfs(k+1);
	pos[k]=1;
	dfs(k+1);
}
signed main() {
	scanf("%s",s);
	len=strlen(s);
	for ( int i=0;i<len;i++ ) s[i]-='0';
	dfs(0);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int r, a;

    while (cin >> r >> a, r || a) {
        int hit, blow;
        bool rf[10], af[10];

        for (int i = 0; i < 10; i++)
            rf[i] = af[i] = false;
        
        hit = blow = 0;
        for (int i = 0; i < 4; i++) {
            if (r % 10 == a % 10)
                hit++;
            else {
                rf[r % 10] = true;
                af[a % 10] = true;
            }
            r /= 10;
            a /= 10;
        }
        for (int i = 0; i < 10; i++)
            if (rf[i] && af[i])
                blow++;
        cout << hit << " " << blow << endl;
    }

    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  string s;
  cin >> s;
  string t = s;
  reverse(all(t));

  int cnt = 0;
  re(i, s.size()/2) {
    if(s[i] != t[i]) cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
#include<iostream>
using namespace std;
int main()
{
	bool ok=0;
	int n,i,j;
	string s;
	cin>>n;
    
    cin>>s;

    if(n&1)
    {
    	cout<<"No"<<endl;
    	return 0;
    }
    else
    {
    	for(i=0,j=n/2;i<n/2,j<n;i++,j++)
    	{
    		if(s[i]!=s[j])
    		{
    			cout<<"No"<<endl;
    			return 0;
    		}
    		else
    			ok = 1;
    	}
    	if(ok)
    	{
    		cout<<"Yes"<<endl;
    	}
}
    
}

Measured memory_bytes: 3076
module IO = struct

  (* @since 4.04.0 *)
  let split_on_char sep s =
    let open String in
    let r = ref [] in
    let j = ref (length s) in
    for i = length s - 1 downto 0 do
      if get s i = sep then begin
        r := sub s (i + 1) (!j - i - 1) :: !r;
        j := i
      end
    done;
    sub s 0 !j :: !r

  let read_ss () = read_line () |> split_on_char ' '

  let read_ns () = read_line () |> split_on_char ' ' |> List.map int_of_string

end

module SegmentTree = struct

  let default_val = ref 0

  let size = ref 0

  let make n init =
    default_val := init;
    let rec pow_of_2 i =
      if i >= n then i
      else pow_of_2 (2 * i) in
    size := pow_of_2 1;
    Array.make (2 * (!size) - 1) init

  let parent i = int_of_float ((float_of_int (i - 1)) /. 2.)

  let left i = 2*i + 1

  let right i = 2*i + 2

  let add s i x =
    let j = !size + i - 1 in
    s.(j) <- x + s.(j);
    let rec doit j =
      if j <= 0 then () else begin
        let p = parent j in
        s.(p) <- s.(left p) + s.(right p);
        doit p
      end in
    doit j

  let sum s a b =
    let rec doit k l r =
      if r < a || b < l then 0
      else if a <= l && r <= b then s.(k)
      else
        let m = (l + r) / 2 in
        doit (left k) l m + doit (right k) (m + 1) r in
    doit 0 0 (!size - 1)

end

module S = SegmentTree

let solve n q =
  let s = S.make n 0 in
  for _ = 0 to q - 1 do
    match IO.read_ns () with
    | c :: x :: y :: _ ->
      if c = 0 then S.add s (x - 1) y
      else begin
        S.sum s (x - 1) (y - 1) |> print_int;
        print_newline ();
      end
    | _ -> assert false
  done

let () =
  match IO.read_ns () with
  | [n; q] -> solve n q
  | _ -> ()

Measured memory_bytes: 6384
#include<iostream>
#include<vector>
using namespace std;
int N,K;string s;
main()
{
	cin>>N>>K>>s;
	vector<int>ans;
	int id=N;
	while(id)
	{
		int nxt=-1;
		for(int j=id<K?id:K;j>0;j--)
		{
			if(s[id-j]=='0')
			{
				nxt=id-j;
				ans.push_back(j);
				break;
			}
		}
		if(nxt<0)
		{
			cout<<-1<<endl;
			return 0;
		}
		id=nxt;
	}
	for(int i=ans.size();i--;)cout<<ans[i]<<endl;
}


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

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

	priority_queue<int>qu;
	string p = "";
	int x;

	while (p != "end")
	{
		cin >> p;
		if (p == "insert")
		{
			cin >> x;
			qu.push(x);
		}
		if (p == "extract")
		{
			cout << qu.top() << endl;
			qu.pop();
		}
	}

	return 0;
}


Measured memory_bytes: 7024
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

ll N,M,Q,B,C,D;
ll A[100010];
std::string S[5];
std::set<int> Union;
std::map<int,int> Hash;

int main(){
    ll ans=1;
    cin>>N>>M;
    if(N==1){
        cout<<M<<endl;
        return 0;
    }
    for(int i=0;i<N;i++){
        if(i==0){
            ans*=M;
        }
        else{
            ans*=(M-1);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    ll A, B, C;
    cin >> A >> B >> C;
    ll S = A+B+C;
    if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
        puts("0");
        return 0;
    }
    ll x[3] = {A+A+A-S, B+B+B-S, C+C+C-S};
    ll ans = LLONG_MAX;
    for (int i = 0; i < 3; i++) {
        if (x[i] == 0) continue;
        ll r = 0;
        while (x[i] % 2 == 0) {
            x[i] /= 2;
            r++;
        }
        ans = min(ans, r);
    }
    if (ans == LLONG_MAX) {
        puts("-1");
        return 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;
import java.util.Arrays;

public class Main
{

	public static void main(String[] args)
	{	Scanner s = new Scanner(System.in);
                String l = s.next();
                String m = s.next();
                int[] a = new int[3];
                int[] b = new int[100];
                int i=0,j=0,t=0;
                float sum1=0;
                int r= l.length();
                int k= m.length();
                if(r==k){
                    for(i=0;i<r;i++){
                       String gf = l.substring(i,i+1);
                       String d = l.substring(0,i);
                       String gg = l.substring(i+1);
                       String c= gf + gg + d;
                       if(c.equals(m)){
                         t=1;
                       }
                      // System.out.println(c);
                    }
                }
                
                if(t==1){
                    System.out.println("Yes");
                }else{
                    System.out.println("No");
                }
               
                
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

void solve(void){
	ll I, O, T, J, L, S, Z;
	cin >> I >> O >> T >> J >> L >> S >> Z;
	ll ans = O + I/2*2 + J/2*2 + L/2*2;
	I--, J--, L--;
	if (I>=0 && J>=0 && L>=0)
	{
		ans = max(ans, O + 3 + I/2*2 + J/2*2 + L/2*2);
	}

	cout << ans << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3", "#.#" ].parse.expand.solve == 1 );
	assert( [ "5", "#.##." ].parse.expand.solve == 2 );
	assert( [ "9", "........." ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

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

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto s = input.front;
	return tuple( s );
}

auto solve( string s )
{
	auto gs = s.group.array;
	if( gs.length == 1 ) return 0L;
	
	// 入力を整形
	if( gs[ 0     ][ 0 ] == '.' ) gs  = gs[ 1 .. $ ];
	if( gs[ $ - 1 ][ 0 ] == '.' ) gs ~= [ Tuple!( dchar, uint )( '#', 0 ), Tuple!( dchar, uint )( '.', 0 ) ];
	else                          gs ~= [ Tuple!( dchar, uint )( '.', 0 ), Tuple!( dchar, uint )( '#', 0 ), Tuple!( dchar, uint )( '.', 0 ) ];
	
	// i番目の黒を境界にした場合を計算（i-1番目までの黒を白にして、i+1番目以降の白を黒にする）
	auto wt = reduce!( ( a, b ) => b[ 0 ] == '.' ? a + b[ 1 ] : a )( 0L, gs );
	auto ans = long.max;
	auto b = 0L;
	auto w = 0L;
	for( auto i = 0L; i < gs.length; i += 2 )
	{
		ans = min( ans, b + ( wt - w ) );
		
		b += gs[ i ][ 1 ];
		w += gs[ i + 1 ][ 1 ];
	}
	
	return ans;
}


Measured memory_bytes: 7420
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int a[10][10];

int main(void) {
  int n;
  cin >> n;
  rep(i,10)rep(j,10){
    a[i][j] = 0;
  }
  rep2(i,1,n+1){
    int p = i%10;
    int q = i;
    while(q>=10){
      q/=10;
    }
    a[p][q] +=1;
  }
  ll cnt = 0;
  rep(i,10)rep(j,10){
    cnt += a[i][j]*a[j][i];
  }
  cout << cnt << endl;
    
  
}


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

namespace atcoder
{
	class Program
	{
		static int In => int.Parse(Console.ReadLine());
		static int[] Ins => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		static void Out(bool b) => Console.WriteLine(b ? "YES" : "NO");

		static void Main(string[] args)
		{
			var a = Ins;
			Array.Sort(a);
			if (a[0] == a[1]) Console.WriteLine(a[2]);
			else Console.WriteLine(a[0]);
			//Console.ReadLine();
		}
	}
}

Measured memory_bytes: 11348
module ABC102

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_A

  ! variables for this <module>
  integer(INT32) :: integer_target

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_A

    ! variables for this <subroutine>
    integer :: iter

    ! STEP.01
    ! read out the target integer
    read(unit=INPUT_UNIT, fmt=*) integer_target

    ! STEP.02
    ! calculate the least multiple of `2` and `integer_target`
    if (mod(integer_target, 2_INT32) .ne. 0_INT32) integer_target = integer_target + integer_target

    ! STEP.03
    ! output the least multiple of `2` and `integer_target`
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') integer_target

    ! STEP.END
    return

  end subroutine task_A

end module ABC102


program main

  ! <module>s to import
  use, non_intrinsic :: ABC102

  ! require all variables to be explicitly declared
  implicit none

  call task_A

end program main

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	if(a > 8 or b > 8){
		cout << ":(" << endl;
	}else{
		cout << "Yay!" << endl;
	}
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

bool upper(vector<int> &x) {
  bool ret = true;
  rep(i, 1, x.size()) {
    if (x[i] < x[i - 1]) {
      ret = false;
      break;
    }
  }
  return ret;
};

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  rep(i, 0, N) {
    cin >> p[i];
  }
  if (upper(p)) {
    cout << "YES" << endl;
    return 0;
  }

  bool flag = false;
  rep(i, 0, N) {
    rep(j, i + 1, N) {
      vector<int> tmp = p;
      swap(tmp[i], tmp[j]);
      if (upper(tmp)) {
        flag = true;
        break;
      }
    }
    if (flag) {
      break;
    }
  }

  if (flag) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

};


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            String s = Console.ReadLine();
            String[] strInputList = s.Split();
            var divisorList = new List<int>();
            var ListAtoC = new List<int>();
            int divisorCount = 0;

            int a = int.Parse(strInputList[0]);
            int b = int.Parse(strInputList[1]);
            int c = int.Parse(strInputList[2]);

            for(int i = 1; i <= c; i++)
            {
                int j = c % i;
                if(j == 0)
                {
                    divisorList.Add(i);                  
                }
            }

            for (int i = a; i <= b; i++)
            {
                if (i <= b)
                {
                    ListAtoC.Add(i);                 
                }
            }

            for (int i = 0; i < ListAtoC.Count(); i++)
            {
                int AtoC = ListAtoC[i];
               
                for (int j = 0; j < divisorList.Count(); j++)
                {
                    int divisor = divisorList[j];                    

                    if (AtoC == divisor)
                    {
                        divisorCount++;                       
                    }
                }
            }
            Console.WriteLine(divisorCount);
        }
    }
}



Measured memory_bytes: 18212
from operator import itemgetter
N = int(input())

A = []
for i in range(N):
  A.append(list(map(int, input().split())))
  
A.sort(key=itemgetter(1))

now = 0
for a in A:
  now += a[0]
  if now > a[1]:
    print('No')
    exit(0)
    
print('Yes')

Measured memory_bytes: 53720
#!python3

import sys

from bisect import bisect, insort_left

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    S = list(input())
    Q = int(input())

    c0 = ord('a')
    S1 = [[] for i in range(26)]
    for i, c1 in enumerate(S):
        ci = ord(c1) - c0
        S1[ci].append(i)

    ans = []
    for cmd, i, j in (line.split() for line in sys.stdin):
        i = int(i) - 1
        if cmd == "1":
            if S[i] == j:
                continue

            c1 = ord(S[i]) - c0
            s1 = S1[c1]
            s1.pop(bisect(s1, i)-1)
            S[i] = j
            c1 = ord(j) - c0
            insort_left(S1[c1], i)
        elif cmd == "2":
            j = int(j) - 1
            num = 0

            for s1 in S1:
                ls = len(s1)
                k = bisect(s1, i-1, 0, ls)

                if k == ls:
                    continue
                if i <= s1[k] <= j:
                    num += 1

            ans.append(num)

    print(*ans, sep="\n")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 29320
#include<bits/stdc++.h>
using namespace std;
struct qs{
	int a,b,c,d;
};
vector<qs> queries;
int ans = 0;
void solve(int n,int m, int lastbig,vector<int>& cur){
		
	if(cur.size()==n){
		int curans =0;
		for(auto e:queries){
			if(cur[e.b-1] - cur[e.a-1]==e.c)
				curans+=e.d;
		}
		ans = max(curans,ans);
	}

	else{
		for(int i =lastbig;i<=m;i++){
			cur.push_back(i);
			solve(n,m,i,cur);
			cur.pop_back();
			// solve(n,m,lastbig)
		}
	}

}

int main(){
	
	int n,m,q;
	cin >> n>> m >> q;
	// create all ways to get a n sized array in sorted order
	queries = vector<qs>(q);
	for(int i=0;i<q;i++){
		cin >> queries[i].a >> queries[i].b >> queries[i].c >> queries[i].d;
	}
	vector<int> cur;
	solve(n,m,1,cur);

	cout << ans << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    int ans = INF;
    rep(div,1<<h-1) {
        int g = 0;
        vector<int> id(h);
        rep(i,h) {
            id[i] = g;
            if (div>>i&1) g++;
        }
        g++;
        vector<vector<int>> c(g, vector<int>(w));
        rep(i,h)rep(j,w) c[id[i]][j] += s[i][j] - '0';
        bool ok = true;
        rep(i,g)rep(j,w) {
            if (c[i][j] > k) ok = false;
        }
        if (!ok) continue;

        int num = g-1;
        vector<int> now(g);
        auto add = [&](int j) {
            rep(i,g) now[i] += c[i][j];
            rep(i,g) if (now[i] > k) return false;
            return true;
        };
        rep(j,w) {
            if (!add(j)) {
                num++;
                now = vector<int>(g);
                add(j);
            }
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N;
	
	cin >> N;
	
	long long int A[N], divide = 0;
	
	for(int i=0; i<N; i++)
		cin >> A[i];
	
	for(int i=0; i<N; i++){
		while(A[i] == A[i+1])
			i++;
		if(i+1<N && A[i]<A[i+1]){
			while(i+1<N && A[i]<=A[i+1]) 
				i++;
		}
		else if(i+1<N && A[i+1]<A[i]){
			while(i+1<N && A[i+1]<=A[i]) 
				i++;
		}
		divide++;
	}
	
	cout << divide;
	
	return 0;
}

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

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

  // n???0???1?????£?????????????????????
  if(n <= 1){ cout << 1 << endl; }
  else{
    // n???2??\????????£??????dp??????
    vector<int> dp(n + 1);
    dp[0] = dp[1] = 1;
    for(int i = 2; i <= n; i++)
      dp[i] = dp[i - 1] + dp[i - 2];

    cout << dp[n] << endl;
  }

  return 0;
}

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

int N;
typedef pair<string,int>P;

bool cmp(P p1,P p2){
  if(p1.first.size() == p2.first.size()){
    return p1.first < p2.first;
  }
  return p1.first.size() < p2.first.size();
}

int main(){
  cin >> N;
  
  map<string,int>mp;
  vector<P>vec;

  for(int i = 0 ; i < N ; i++){
    string tmp;
    int num;
    cin >> tmp >> num;
    if(mp.find(tmp) == mp.end()){
      mp[tmp] = vec.size();
      vec.push_back(P(tmp,num));
    }
    else {
      vec[mp[tmp]].second += num;
    }
  }

  sort(vec.begin(),vec.end(),cmp);

  for(int i = 0 ; i < vec.size() ; i++){
    cout << vec[i].first << ' ' << vec[i].second << endl;
  }

  return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    string s;
    cin >> s;
    REP(i, 4) s[i] -= '0';
    ll a = s[0]*10 + s[1], b = s[2]*10 + s[3];
    bool ok1 = false, ok2 = false;
    if(1 <= a && a <= 12) ok1 = true;
    if(1 <= b && b <= 12) ok2 = true;
    if(ok1 && ok2) cout << "AMBIGUOUS";
    else if(ok1 && !ok2) cout << "MMYY";
    else if(!ok1 && ok2) cout << "YYMM";
    else cout << "NA";
    return 0;
}

Measured memory_bytes: 3568
#include<iostream>
using namespace std;
int t,k,s;
int out(){
while(1){
cin>>t>>k>>s;
if(t==-1&&k==-1&&s==-1)
break;
if(t==-1||k==-1)
cout<<"F"<<endl;
else if(t+k>=80)
cout<<"A"<<endl;
else if(t+k>=65)
cout<<"B"<<endl;
else if(t+k>=50)
cout<<"C"<<endl;
else if(t+k>=30){
if(s>=50)
cout<<"C"<<endl;
else 
cout<<"D"<<endl;
}
else
cout<<"F"<<endl;
}
}
int main(){
out();
return 0;
}

Measured memory_bytes: 1156
#include <iostream>
using namespace std;
int main(){
	int a, b;
	cin>>a>>b;
	if(a>=1 && a<=13 && b>=1 &&b<=13)
	
	if(a==b)
		cout<<"Draw";
	else if(a==1 || (a>b && b>1))
	    cout<<"Alice";
	else
	    cout<<"Bob";
	return 0;
}

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

int main(){
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\User\\Documents\\input.txt","r",stdin);
#endif
	int T,i,j;
	int n,k;
	cin>>n>>k;

	vector<bool> dp(k+1,0);
	vector<int> a(n);

	for(i=0;i<n;++i){
		scanf("%d",&a[i]);
	} 

	for(i=1;i<=k;++i){
		for(int x: a){
			if(x<=i && !dp[i-x]) dp[i]=1;
		}
	}
	printf("%s\n",dp[k] ? "First" : "Second");

return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1)/ (y))
#define MOD 1000000007ULL

int N;
int *p;

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

    cin >> N;

    p = new int[N];
    rep (i, N)
    {
        cin >> p[i];
    }

    int l, r;
    int ret = 0;
    for (l = 0; l < N; ++l)
    {
        for (r = l; r < N - 1 && p[r + 1] > p[r]; ++r);
        if (r - l >= 2)
        {
            ret += r - l - 1;
            l = r - 1;
            continue;
        }
        for (r = l; r < N - 1 && p[r + 1] < p[r]; ++r);
        if (r - l >= 2)
        {
            ret += r - l - 1;
            l = r - 1;
            continue;
        }
    }

    cout << ret << "\n";

    delete[] p;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y,ans;
	cin>>x>>y;
	if(y%2==1){
		y=y/2+0.5;
	}
	else{
		y=y/2;
	}
	ans=x+y;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

ll mod = 1e9 + 7;

ll pow_mod(ll n, ll p)
{
    ll ret = 1;
    ll wk_n = n;
    ll wk_p = p;
    while (wk_p > 0)
    {
        if (wk_p % 2 == 0)
        {
            wk_n *= wk_n;
            wk_p /= 2;
            wk_n %= mod;
        }
        else
        {
            ret *= wk_n;
            wk_p--;
            ret %= mod;
        }
    }
    return ret;
}

ll div_mod(ll n, ll d)
{
    return (n * pow_mod(d, mod - 2)) % mod;
}

int main()
{
    ll n;
    cin >> n;
    vll a(n);
    ll a_max = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        a_max = max(a_max, a[i]);
    }

    vll fc(a_max + 1, 0);
    for (ll i = 2; i <= a_max; i++)
    {
        if (fc[i] != 0)
        {
            continue;
        }
        for (ll j = i; j <= a_max; j += i)
        {
            if (fc[j] == 0)
            {
                fc[j] = i;
            }
        }
    }

    vll lcm_pf(a_max + 1, 0);
    set<ll> primes;
    for (ll i = 0; i < n; i++)
    {
        ll num = a[i];
        ll prime = fc[num];
        ll prime_cnt = 0;
        ll prev_prime = 0;
        while (num > 1)
        {
            prime_cnt++;
            num /= prime;
            prev_prime = prime;
            prime = fc[num];
            if (prev_prime != prime)
            {
                lcm_pf[prev_prime] = max(lcm_pf[prev_prime], prime_cnt);
                primes.insert(prev_prime);
                prime_cnt = 0;
            }
        }
    }

    ll lcm_mod = 1;
    for (auto itr = primes.begin(); itr != primes.end(); itr = next(itr))
    {
        ll prime = *itr;
        lcm_mod *= pow_mod(prime, lcm_pf[prime]);
        lcm_mod %= mod;
    }

    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        ll a_mod = 1;
        ll num = a[i];
        ll prime = fc[num];
        ll prime_cnt = 0;
        ll prev_prime = 0;
        while (num > 1)
        {
            prime_cnt++;
            num /= prime;
            prev_prime = prime;
            prime = fc[num];
            if (prev_prime != prime)
            {
                a_mod *= pow_mod(prev_prime, prime_cnt);
                a_mod %= mod;
                prime_cnt = 0;
            }
        }
        ans += div_mod(lcm_mod, a_mod);
        ans %= mod;
    }

    cout << ans << endl;
}


Measured memory_bytes: 16384
#include <stdio.h>
#include <math.h>

int main(int argc, char** argv)
{
	int n, i, score[1000];

	while (1) {
		double sum = 0.0, result = 0.0;

		scanf("%d", &n);

		if (n == 0) {
			break;
		}

		for (i = 0; i < n; i++) {
			scanf("%d", &score[i]);
			sum += score[i];
		}

		double ave = sum / n;

		for (i = 0; i < n; i++) {
			double tmp = score[i] - ave;
			result += (tmp * tmp);
		}

		result = sqrt(result / n);

		printf("%lf\n", result);
	}
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int64_t H, W;
    cin >> H >> W;
    if(H == 1 || W == 1) {
        cout << 1 << endl;
    } else if(H*W%2) {
        cout << H*W/2 + 1 << endl;
    } else {
        cout << H*W/2 << endl;
    }
    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++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;

int main(){
    int N;
    string s;
    cin>>N;
    cin>>s;
    rep(i,s.length()){
        if(s[i]+N>(int)'Z'){
            s[i]=s[i]+N-26;
        }else{
            s[i]=s[i]+N;
        }
    }
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    long long n,k;
    cin >> n >> k;
    long long a[n];
    rep(i,n) cin >> a[i];
    rep(i,n) a[i]--;
    long long suma[n+1];
    suma[0] = 0;
    rep(i,n) suma[i+1]=(suma[i]+a[i])%k;
    map<long long,int> mp;
    rep(i,min(n+1,k)) mp[suma[i]]++;
    long long ans = 0;
    rep(i,n){
        mp[suma[i]]--;
        ans+=mp[suma[i]];
        if((k+i)<=n)mp[suma[i+k]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
#!/usr/bin/env python3
#ABC66 B

s = input()

ma = 0
for i in range(1,len(s)):
    if len(s[:-i]) % 2 != 0:
        continue
    else:
        n = len(s[:-i])
        n = n//2
        if s[:n] == s[n:-i]:
            ma = max(ma,len(s[:-i]))
print(ma)


Measured memory_bytes: 38256
import java.util.*;

public class Main {
  
 	public static void main(String[] args) {
     
      Scanner sc = new Scanner(System.in);
	  int n = Integer.parseInt(sc.next());
      int m = Integer.parseInt(sc.next());
      
      int max = m*n;
      
      if(max < m+n) {
        max = m+n;
      }
      
      if(max < n-m) {
        max = n-m;
      }
      
      System.out.println(max);
    }
  
}

Measured memory_bytes: 22612
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

int N;
ll A[50];
vector<P> ans;
int maxid,minid;
ll amax=-(1e+9);
ll amin=1e+9;

int main()
{
	cin>>N;
	rep(i,N) cin>>A[i];
	rep(i,N){
		if(amax<A[i]){
			amax=A[i];
			maxid=i;
		}
		if(amin>A[i]){
			amin=A[i];
			minid=i;
		}
	}
	if( (A[maxid]>0&&A[minid]>=0)||( A[maxid]>0&&A[minid]<0&&abs(A[N-1]+A[maxid])>=abs(A[0]+A[minid])   ) ){
		ans.pb(P(maxid,N-1));
		ans.pb(P(maxid,N-1));
		rep1(i,N-1){
			ans.pb(P(N-1,i));
			ans.pb(P(N-1,N-1));
		}
	}
	else if( ( A[maxid]<=0&&A[minid]<0  )|| (     	A[maxid]>0&&A[minid]<0&&abs(A[N-1]+A[maxid])<abs(A[0]+A[minid]))      ){
		ans.pb(P(minid,0));
		ans.pb(P(minid,0));
		rrep(i,N-1){
			ans.pb(P(0,i));
			ans.pb(P(0,0));
		}
	}
	else{
		puts("0");
		return 0;
	}
	cout<<2*N<<endl;
	rep(i,ans.size()){
		cout<<ans[i].fr+1<<" "<<ans[i].sc+1<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int H, W;
int h, w;
int ans;

int main() {
  scanf("%d%d", &H, &W);
  scanf("%d%d", &h, &w);
  ans = H*W;
  ans -= h*W + H*w;
  ans += h*w;
  printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;

int w,h,ans;
int a[51][51];
bool f[51][51][51][51];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

struct cost{
	P tp,kp;
	int cnt;
};

void solve(struct cost c){
	queue<struct cost> q;
	q.push( c );
	ans = -1;
	for(int ty=0 ; ty < h ; ty++ ){
		for(int tx=0 ; tx < w ; tx++ ){
			for(int ky=0 ; ky < h ; ky++ ){
				for(int kx=0 ; kx < w ; kx++ ){
					f[ty][tx][ky][kx] = false;
				}
			}
		}
	}

	while( !q.empty() ){
		struct cost now = q.front(), next;
		q.pop();
		int tx = now.tp.first;
		int ty = now.tp.second;
		int kx = now.kp.first;
		int ky = now.kp.second;
		next.cnt = now.cnt + 1;
		if( f[ty][tx][ky][kx] ){
			continue;
		}else{
			f[ty][tx][ky][kx] = true;
		}
		if( now.cnt == 100 ){
			break;
		}
		if( tx == kx && ty == ky ){
			ans = now.cnt;
			break;
		}

		for(int i=0 ; i < 4 ; i++ ){
			int tmx = tx + dx[i];
			int tmy = ty + dy[i];
			int kmx = kx - dx[i];
			int kmy = ky - dy[i];
			if( tmx < 0 || tmy < 0 || tmx >= w || tmy >= h || a[tmy][tmx] ){
				P tp(tx,ty);
				next.tp = tp;
			}else{
				P tp(tmx,tmy);
				next.tp = tp;
			}
			if( kmx < 0 || kmy < 0 || kmx >= w || kmy >= h || a[kmy][kmx] ){
				P kp(kx,ky);
				next.kp = kp;
			}else{
				P kp(kmx,kmy);
				next.kp = kp;
			}
			q.push( next );
		}
	}
}

int main(){
	while( cin >> w >> h , w||h ){
		int tx, ty, kx, ky;
		cin >> tx >> ty >> kx >> ky;
		tx--; ty--; kx--; ky--;
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				cin >> a[y][x];
			}
		}

		struct cost c;
		P tp(tx,ty), kp(kx,ky);
		c.tp = tp;
		c.kp = kp;
		c.cnt = 0;
		solve( c );
		if( ans == -1 ){
			cout << "NA" << endl;
		}else{
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 0
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    string_code(1, S, C),
*/

main:-
    get_number(H),
    get_number(A),
    R is (H + A - 1) div A,
    writeln(R).


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

#define _overload3(_1, _2, _3, name, ...) name
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define REP(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)

typedef long long int ll;
typedef unsigned long long int ull;

const int MOD=(int)1e9+7;
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};

ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll g=gcd(a,b);return a/g*b;}
ll digitsum(ll a){ll x=0;while(a>0){x+=a%10;a/=10;}return x;}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    double t,x;
    cin>>t>>x;
    double ans=t/x;
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

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

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<pair<int, int>> v;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		v.push_back({a, b});
	}
	int flag = 0;
	for (int i = 0; i < n - 2; i++) {
		if (v[i].first == v[i].second && v[i + 1].first == v[i + 1].second && v[i + 2].first == v[i + 2].second) {
			flag = 1;
			break;
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3632
def palindrome(string):
    return True if string == string[::-1] else False


s = input()
n = len(s)
flag = palindrome(s) and palindrome(
    s[0:((n - 1) // 2)]) and palindrome(s[(n + 3) // 2 - 1:])

print("Yes" if flag else "No")


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;
int main(){
  ll i,j,k,n,m;
  cin >> n >> m;
  ll s[n+1];
  ll t[m+1];
  for(i=1;i<=n;i++)cin >> s[i];
  for(i=1;i<=m;i++)cin >> t[i];
  s[0]=-1;
  t[0]=-5;
  ll dp[n+1][m+1];
  for(i=0;i<=m;i++)dp[0][i]=1;
  for(i=0;i<=n;i++)dp[i][0]=1;
  dp[0][0] = 1; //空文字列
  // dp[x][y] := sのx文字目,tのy文字目まで見たときの共通部分列の数
  for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
      if(s[i]!=t[j])dp[i][j]=(dp[i-1][j]+dp[i][j-1]+MOD-dp[i-1][j-1])%MOD;
      if(s[i]==t[j])dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
      dp[i][j]%=MOD;
    }
  }
  cout << dp[n][m]%MOD << endl;
  return 0;
}


Measured memory_bytes: 31616
n=gets.to_i
ps=Hash.new{|h,k|h[k]=0}
(2..Math.sqrt(n).floor).each{|i|
  if n%i==0
    ps[i]+=1
    n/=i
    redo
  end
}
ps[n] = 1 if n > 1

p ps.map{|_,v|
  i=1
  sum=0
  loop do
    break i-1 if sum + i > v
    sum+=i
	i+=1
  end
}.sum

Measured memory_bytes: 14400
package main

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

var (
	BufferSize = 10 * 10 * 10 * 10 * 10 * 10
)

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}

	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}

	return sc.Text()
}

func getRev(before byte) byte {
	if before == '0' {
		return '1'
	}
	return '0'
}

func cSum() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	k := scanInt(sc)
	s := scanStr(sc)

	// fmt.Printf("n = %+v\n", n)
	// fmt.Printf("k = %+v\n", k)
	// fmt.Printf("s = %+v\n", s)

	csum := make([]int, 0, len(s)+10)

	before := s[0]
	csum = append(csum, 1)
	for i := 1; i < n; i++ {
		if s[i] != before {
			csum = append(csum, csum[len(csum)-1]+1)
		} else {
			csum[len(csum)-1]++
		}
		before = s[i]
	}

	// fmt.Printf("csum = %+v\n", csum)

	max := 0
	rightIndexFunc := zeroRightIndex
	if s[0] != '0' {
		rightIndexFunc = oneRightIndex
	}
	leftIndexFunc := zeroLeftIndex
	if s[0] != '0' {
		leftIndexFunc = oneLeftIndex
	}
	for i := 0; i < len(csum); i += 2 {
		rightIndex := rightIndexFunc(i, k)
		var right int
		if rightIndex > len(csum)-1 {
			rightIndex = len(csum) - 1
		}
		right = csum[rightIndex]

		leftIndex := leftIndexFunc(i)
		var left int
		if leftIndex < 0 {
			leftIndex = -1
			left = 0
		} else {
			left = csum[leftIndex]
		}
		length := right - left
		// fmt.Printf("[%d](%d) - [%d](%d): %d\n", leftIndex, left, rightIndex, right, length)
		if length > max {
			max = length
		}
	}

	fmt.Printf("%d\n", max)
}

func zeroLeftIndex(i int) int {
	return i - 2
}

func oneLeftIndex(i int) int {
	return i - 1
}

func zeroRightIndex(i int, k int) int {
	return i + 2*k - 1
}

func oneRightIndex(i int, k int) int {
	return i + 2*k
}

func main() {
	cSum()
}


Measured memory_bytes: 1664
def resolve():
	ss = list(input())
	t = list(input())
	candidates = []
	for i in range(len(ss) - len(t) + 1):
		s = ss[:]
		ok = True
		for j in range(len(t)):
			if s[i+j] != t[j] and s[i+j] != '?':
				ok = False
				break
		if ok:
			for j in range(len(t)):
				s[i + j] = t[j]
			for j in range(len(s)):
				if s[j] == '?':
					s[j] = 'a'
			candidates.append("".join(s))
	if len(candidates):
		print(min(candidates))
	else:
		print('UNRESTORABLE')
resolve()

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    float n,m,num=0;
    cin>>n>>m;
    vector<int>a(n);
    float sum=0;
    for(int i=0; i<n; i++){
        cin >> a.at(i);
        sum += a.at(i);
    }
    sum = sum*(1.0/(4.0*m));
    for(int i=0; i<n; i++){
        if(a.at(i)>=sum)num++;
    }
    if(num>=m){
        cout<<"Yes";
    }else{ cout<<"No";}
}

Measured memory_bytes: 3760