akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

int main() {
    char c;
    int intset = 0, ans = 0;
    while((c = getchar()) != EOF) {
        if('0' <= c && c <= '9') {
            intset *= 10;
            intset += c - '0';
        }
        else {
            ans += intset;
            intset = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1120
import math
Point = []
 
def calcAngle(p1,p2):   
    ang = math.atan2(p2[0]-p1[0],p2[1]-p1[1])
    if(ang<0):
        ang += 2*math.pi
    return ang
 
def distance(p1,p2):
    d2 = pow(p2[0]-p1[0],2)+pow(p2[1]-p1[1],2)
    d = math.sqrt(d2)
    return d
 
def CoversM(r,N,M):
    M0 = 0
    for i in xrange(N):
        Arr = []
        for j in xrange(N):
            if(i==j): continue
            d = distance(Point[i],Point[j])
            if(d <= r*2.00):
                t0 = calcAngle(Point[i],Point[j])
                ph = math.acos(float(d)/(2.000*r))
                t1 = t0-ph+2*math.pi
                t2 = t0+ph+2*math.pi
                Arr.append((t1,1))
                Arr.append((t2,-1))
        Arr.sort(key=lambda x: x[0])
        s = 0
        for x in Arr:
            s += x[1]
            M0 = max(M0,s)
    return M0+1 >= M
 
EPS = 1e-7
def Solve(N,M):
    L,H = 0.000,1000000000
    itr = 0
    while(H > L+EPS and ++itr <= 1000):
        R = (L+H)/2.000000
        if(CoversM(R,N,M)==True):
            H = R
        else:
            L = R
    return R
 
if __name__ == "__main__":
    N = input()
    M = N
 
    for i in range(N):
        xi,yi = map(float,raw_input().split())
        Point += [(xi,yi)]
 
    print Solve(N,M)


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

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> pii;
typedef vector< vector<int> > vvi;

int mf(string s) {
	rep(i, s.length()) {
		if( s[i] == '+' ) {
			return mf(s.substr(0,i)) + mf(s.substr(i+1));
		}
	}
	rep(i, s.length()) {
		if( s[i] == '*' ) {
			return mf(s.substr(0,i)) * mf(s.substr(i+1));
		}
	}
	return atoi(s.c_str());
}

int ltr(string s) {
	for(int i=s.length()-1; i>=0; i--) {
		if( s[i] == '+' ) {
			return ltr(s.substr(0,i)) + ltr(s.substr(i+1));
		}
		else if( s[i] == '*' ) {
			return ltr(s.substr(0,i)) * ltr(s.substr(i+1));
		}
	}
	return atoi(s.c_str());
}

int main() {
	string in;
	cin >> in;
	int ans;
	cin >> ans;
	int m = mf(in);
	int l = ltr(in);
	if( m==ans && l==ans ) {
		cout << "U" << endl;
	} else if( m == ans ) {
		cout << "M" << endl;
	} else if( l == ans ) {
		cout << "L" << endl;
	} else {
		cout << "I" << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<cmath>
#include<algorithm>
#define LONG long long int
using namespace std;


int main() {
	LONG n, max,sum;
	max = 0;
	sum = 0;
	cin >> n;
	int tmp;
	for (int i = 0; i < n; i++)
	{
		cin >> tmp;
		if (tmp >= max)
		{
			sum++;
			max = tmp;
		}
	}
	cout << sum << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

enum Pat { A = 0, G = 1, C = 2, T = 3 };

ll N;
ll dp[MAX_N][4][4][4];


ll dfs(ll i, ll c1, ll c2, ll c3) {
    if(i >= N) { return 1; }

    ll& ret = dp[i][c1][c2][c3];
    if(~ret) { return ret; }
    ret = 0;

    // A を入れる
    ret += dfs(i+1, A, c1, c2);
    ret %= MOD;

    // G を入れる
    if( !(c2 == A && c1 == C) ) {
        ret += dfs(i+1, G, c1, c2);
        ret %= MOD;
    }

    // C を入れる
    if( !( (c1 == A && c2 == G) ||
           (c1 == G && c2 == A) ||
           (c1 == G && c3 == A) ||
           (c3 == A && c2 == G)
         ) )
    {
        ret += dfs(i+1, C, c1, c2);
        ret %= MOD;
    }

    // T を入れる
    ret += dfs(i+1, T, c1, c2);
    ret %= MOD;

    return ret;
}

signed main()
{
    cin >> N;
    MINUS(dp);
    ll ans = dfs(0, T, T, T);
    printf("%lld\n", ans);
    return 0;
}


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

int main() {
	long long N, M, P, Y, B[100000], count = 1, NOW = 1;
	static pair<long long, int> A[100000];
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> P >> Y;
		A[i].first = P * pow(10, 10) + Y, A[i].second = i;
	}
	sort(A, A + M);
	for (int i = 0; i < M; i++) {
		long long F = A[i].first / 10000000000, S = A[i].first % 10000000000;
		if (NOW == F) {
			B[A[i].second] = NOW * 1000000 + count;
			count++;
		}
		else {
			count = 1;
			NOW = F;
			B[A[i].second] = NOW * 1000000 + count;
			count++;
		}
	}
	for (int i = 0; i < M; i++) {
		cout << setfill('0') << setw(12) << B[i] << endl;
	}
}

Measured memory_bytes: 3968
n = int(input())
I = input()
P = []

for i in range(n):
    P.append(int(I.split()[i]))
    

count = 0

for w in range(n-2):
    A = P[w]-P[w+1]
    B = P[w+1]-P[w+2]
    
    if A*B>0:
        count+=1
    
print(count)

Measured memory_bytes: 3064
/**
 *    author:  morato
 *    created: 19.09.2020 17:25:37
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (s.back() == 's') {
    cout << s << "es\n";
  } else {
    cout << s << 's' << '\n';
  } 
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll              long long 
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
using namespace std;

//int a[307][307];
int main()
{
    FIO;
//    ll t; cin>>t;
//	while(t--)
//	{
    int a,ans;
    for(int i=1;i<=5;i++){
    	cin>>a;
    	if(a==0){
    		ans = i;
		}
	}
	cout<<ans;
return 0; 
}

Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#define MAX 1000001
#include <cmath>
using namespace std;

bool a[MAX];

int main(){
  int i,j,n,m,ans;
  for(i=1;i<MAX;i*=2) a[i] = true;
  for(i=1;i<MAX;i*=3) a[i] = true;
  for(i=1;i<MAX;i*=5) a[i] = true;
  for(i=1;i<MAX;i++){
    if(a[i]){
      if(i * 2 < MAX) a[i*2] = true;
      if(i * 3 < MAX) a[i*3] = true;
      if(i * 5 < MAX) a[i*5] = true;
    }
  }

  while(1){
    cin >> n;
    if(n == 0) break;
    cin >> m;
    ans = 0;
    for(i=n;i<=m;i++){
      if(a[i]){
	ans++;
      }
    }
    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 1816
# coding: utf-8

def is_easy(S):
    for i, s in enumerate(S):
        if i % 2 == 0 and s == 'L':
            return 'No'
        elif i % 2 == 1 and s == 'R':
            return 'No'
    return 'Yes'

def main():
    S = input()
    print(is_easy(S))   

main()

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
static const int N = 36;

struct card
{
	char suit;
	int value;
};

bool compare(card T[], card _T[], int _n)
{
	for (int i = 0; i < _n; i++)
	{
		if (T[i].suit != _T[i].suit)
			return false;
	}

	return true;
}

int main()
{
	card C[N], _C[N], temp;
	int n, minj;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> C[i].suit >> C[i].value;
		_C[i] = C[i];
	}
		

	for (int i = 0; i < n; i++)
	{
		for (int j = n - 1; j > i; j--)
		{
			if (C[j].value < C[j - 1].value)
			{
				temp = C[j];
				C[j] = C[j - 1];
				C[j - 1] = temp;
			}
		}
	}

	for (int i = 0; i < n-1; i++)
		cout << C[i].suit << C[i].value << " ";
	cout << C[n - 1].suit << C[n - 1].value << endl;
	cout << "Stable" << endl;

	for (int i = 0; i < n; i++)
	{
		minj = i;
		for (int j = i; j < n; j++)
		{
			if (_C[j].value < _C[minj].value)
				minj = j;
		}
		temp = _C[i];
		_C[i] = _C[minj];
		_C[minj] = temp;
	}

	for (int i = 0; i < n - 1; i++)
		cout << _C[i].suit << _C[i].value << " ";
	cout << _C[n - 1].suit << _C[n - 1].value << endl;

	if(compare(C,_C,n))
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
	
	return 0;
}



Measured memory_bytes: 3080
package main

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

var sc = bufio.NewScanner(os.Stdin)

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


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


func main() {
	hw := strings.Split(nextLine(), " ")
	h, _ := strconv.Atoi(hw[0])

	for i := 0; i < h; i++ {
		c := nextLine()
		fmt.Println(c)
		fmt.Println(c)
	}
	 

}


Measured memory_bytes: 640
import statistics

N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A_med = statistics.median(A)
B_med = statistics.median(B)

if N % 2 == 0:
    ans = int((B_med - A_med) * 2 + 1)
else:
    ans = int((B_med - A_med) + 1)

print(ans)



Measured memory_bytes: 28840
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
using ll = long long;

using namespace std;
int main()
{/*三日目*/
	int n, m; cin >> n >> m;
	int sum = 0;
	int pop=0;
	double oo;
	vector<int> hyou(n);
	for (int i = 0;i < n;i++) {
		cin >> hyou[i];
		sum += hyou[i];
	}
	for (int i = 0;i < n;i++) {
		if (hyou[i]*4*m >= sum)
			pop++;
	}if (pop >= m)
		cout << "Yes";
	else
		cout << "No";

}

Measured memory_bytes: 3596
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

int main() {
  int a,b,t;
  cin>>a>>b>>t;
  
  cout<<(t/a)*b<<endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
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 INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;

ll solve(ll i){
   if(i & 1){
      return (i+1)/2 % 2;
   }
   else return ((i+2)/2 % 2) ^ (i+1);
}

int main(){
   ll A,B; cin >> A >> B;
   if(A == 0) cout << solve(B) << endl;
   else cout << (solve(A-1) ^ solve(B)) << endl;
}



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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long N;
    cin >> N;
    --N;
    int L = 1;
    long long power = 26;
    while (N >= power) {
        ++L;
        N -= power;
        power *= 26;
    }
    vector<char> ans(L);
    for (int i = L - 1; i >= 0; --i) {
        ans[i] = 'a' + (N % 26);
        N /= 26; 
    }
    cout << string(ans.begin(), ans.end()) << '\n';
    return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b,x;cin>>a>>b>>x;
  flag3func(!(x<a ||x>a+b));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL b[2001][2001];
LL x;
LL now[20001];
int main(){
	cin>>N>>x;
	LL ans=0;
	REP(i,N){
		cin>>b[0][i];
		ans+=b[0][i];
	}
	REP(i,N){
		if(i==0)continue;
		REP(j,N){
			b[i][j]=min(b[i-1][j],b[0][(j-i+N)%N]);
		}
		LL c=0;
		REP(j,N){
			c+=b[i][j];
		}
		c+=i*x;
		ans=min(ans,c);
	}
	cout<<ans<<endl;
	return(0);
}

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

using namespace std;
using ll = long long;
const int INF = 1001001001;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    --x; --y;
    vector<int> ans(n);
    for (int sv = 0; sv < n; ++sv) {
        vector<int> dist(n, INF);
        queue<int> q;
        auto push = [&](int v, int d) {
            if(dist[v] != INF) return;
            dist[v] = d;
            q.push(v);
        };
        push(sv, 0);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            int d = dist[v];
            if (v-1 >= 0) push(v-1, d+1);
            if (v+1 < n) push(v+1, d+1);
            if (v == x) push(y, d+1);
            if (v == y) push(x, d+1);
        }
        for (int i = 0; i < n; ++i) ++ans[dist[i]];
    }
    for (int i = 0; i < n; ++i) ans[i] /= 2;
    for (int i = 1; i <= n-1; ++i) cout << ans[i] << endl; 
    return 0;
}

Measured memory_bytes: 256
X = int(input())

#nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

for i in range(X,X+1000000):
  if(is_prime(i) == True): 
    ans = i
    break
print(ans)

Measured memory_bytes: 3188
use std::cmp::Ordering;
use std::collections::{BTreeSet, BinaryHeap};
#[derive(Clone, Eq, PartialEq)]
struct State {
    s: String,
    i: usize,
}

impl Ord for State {
    fn cmp(&self, other: &State) -> Ordering {
        other.s.cmp(&self.s)
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

fn main() {
    let mut sc = Scanner::new();
    let x: Vec<char> = sc.read::<String>().chars().collect();
    let k: usize = sc.read();
    let n = x.len();
    let mut set = BTreeSet::new();
    let mut q = BinaryHeap::new();
    for i in 0..n {
        let mut t = String::new();
        t.push(x[i]);
        q.push(State { s: t, i: i });
    }
    while let Some(State { s, i }) = q.pop() {
        if set.len() >= k {
            break;
        }
        let mut t = s.clone();
        set.insert(s);
        let l = t.len();
        if i + l < n {
            t.push(x[i + l]);
            q.push(State { s: t, i: i });
        }
    }

    let t: Vec<String> = set.iter().map(|s| s.to_owned()).collect();
    println!("{}", t[k - 1]);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int nxt=1,ans=0;
    rep(i,n){
        if(nxt==a[i]){
            ++nxt;
        }
        else{
            ++ans;
        }
    }
    if(ans==n)ans=-1;
    cout<<ans<<endl;
}


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




int main()
{
    char s[101] = {'\0'};

    cin>>s;
    for(unsigned int i = 0;i < strlen(s);i ++)
    {
        cout<<'x';
    }
}


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


#define O_O ios_base::sync_with_stdio(0); cin.tie(NULL)
#define endl '\n'
#define PI acos(-1.0)
#define CASE(n) cout << "Case " << n << ": "
#define CASE_(n) cout << "Case " << n << endl
#define FIXED(n) cout << fixed << setprecision(n)
#define MOD 1000000007

inline void normal(long long &a) { a %= MOD; (a < 0) && (a += MOD); }
inline long long modMul(long long a, long long b) { normal(a), normal(b); return (a*b)%MOD; }
inline long long modAdd(long long a, long long b) { normal(a), normal(b); return (a+b)%MOD; }
inline long long modSub(long long a, long long b) { normal(a), normal(b); a -= b; normal(a); return a; }
inline long long modPow(long long b, long long p) { long long r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline long long modInverse(long long a) { return modPow(a, MOD-2); }
inline long long modDiv(long long a, long long b) { return modMul(a, modInverse(b)); }


int main()
{
    O_O;
#ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
#endif
    long long t=1;
    //cin >> t;
    long long T = t;
    while(t--)
    {
        //write your code here
        int n;
        cin >> n;
        map<int,int>mp;
        for(int i=0;i<n;i++)	
        {
        	int x;
        	cin >> x;
        	x--;
        	mp[i]=x;
        }
        std::vector<int> a,b;
    	for(int i=0;i<n;i++)
    	{
    		a.push_back(i+1);
    		b.push_back(n-i);
    	}
    	int lastSum = 0;
    	for(int i=0;i<n;i++)
    	{
    		int pos = mp[i];
    		for(int j=pos;j>=0;j--)	b[j]+=i+10;
    		for(int j=pos;j<n;j++)	a[j]+=i+10;
    					
    	}
    	for(int i=0;i<n;i++)	cout << a[i] << ' ';
    	cout << endl;
    	for(int i=0;i<n;i++)	cout << b[i] << ' ';
    	cout << endl;
    }
    return 0;
}




Measured memory_bytes: 4700
# -*- coding: utf-8 -*-
h,w = list(map(int,input().split()))
d = [list(map(int,input().split())) for i in range(h)]

ret=[]
ra = ret.append
for hi in range(h):
    for wi in range(w):
        if d[hi][wi]%2==1:
            if wi!=w-1:
                d[hi][wi]-=1
                d[hi][wi+1]+=1
                ra([hi,wi,hi,wi+1])
            else:
                if hi!=h-1:
                    d[hi][wi]-=1
                    d[hi+1][wi]+=1
                    ra([hi,wi,hi+1,wi])
                else:
                    pass

print(len(ret))
for i in ret:
    i = list(map(lambda x:x+1,i))
    print(" ".join(list(map(str,i))))

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

#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int N;
    string S, pluss;
    bool p[26];
    int s[26];
    int tmp, tmp2;
    string SS;

    rep(i,26) p[i]=false;

    cin >> S;
    N = S.length();

    if(N<26){
        rep(i,N){
            tmp = static_cast<int>(S[i]) - 97;
            p[tmp] = true;
        }
        rep(i,26){
            if(p[i]==false){
                SS = static_cast<char>(i+97);
                break;
            }
        }
        cout << S << SS << endl;
    }else{
        rep(i,N){
            s[i] = static_cast<int>(S[i]) -97;
        }
        tmp=N-1;
        for(int i=N-1; i>0; i--){
            if(s[i-1]>s[i]){
                tmp=i-1;
            }else{
                //cout << tmp << endl;
                break;
            }
        }
        if(tmp==0){
            cout << "-1" << endl;
        }else{
            tmp2=30;
            for(int i=tmp; i<N; i++){
                if(tmp2 > s[i] && s[tmp-1] < s[i]){
                    tmp2 = s[i];
                }
            }
            for(int i=0; i<tmp-1; i++){
                cout << S[i];
            }
            cout << static_cast<char>(tmp2+97) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def calc(A):
    n = len(A)
    ans = 0
    for i in range(n):
        a = A[i]-1
        for x in A[:i]:
            if x<A[i]:
                a -= 1
        fr = 1
        for i in range(1,n-i):
            fr *= i
        ans += a * fr
    return ans


def main():
    N = I()
    P = LI()
    Q = LI()

    print(abs(calc(P)-calc(Q)))
    

if __name__ == "__main__":
    main()



Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int MOD = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  string s;
  cin >> s;
  
  for (int i = 0; i < s.length(); i++)
  {
    if (i % 2 == 0)	// 偶数
    {
      if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D')	continue;
      else 
      {
        cout << "No";
        return 0;
      }
    }
    else
    {
      if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D')	continue;
      else 
      {
        cout << "No";
        return 0;
      }    
    }
  }
  
  cout << "Yes";
  
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;

void main(){

    while(true){
	auto i = readln();
	if(stdin.eof()) break;
	auto s = split(i).to!(int[]);
	int y = s[0];
	int m = s[1];
	int d = s[2];
	string era = "pre-meiji";
	int yy = 0;
	if(1869<=y||(1868==y&&(9<m||(9==m&&8<=d)))){
	    era = "meiji";
	    yy = y - 1867;
	}
	if(1913<=y||(1912<=y&&(7<m||(7==m&&30<=d)))){
	    era = "taisho";
	    yy = y - 1911;
	}
	if(1927<=y||(1926<=y&&(12<m||(12==m&&25<=d)))){
	    era = "showa";
	    yy = y - 1925;
	}
	if(1990<=y||(1989==y&&(1<m||(1==m&&8<=d)))){
	    era = "heisei";
	    yy = y - 1988;
	}
	if(era=="pre-meiji") writeln(era);
	else writef("%s %d %d %d\n",era,yy,m,d);
    }
}

Measured memory_bytes: 2472
#include<bits/stdc++.h>
#define int long long
#define dd second
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define pp pair<int,int>
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    int w,h,k; cin >> w >> h >> k;
    for(int i = 0; i <= w; ++i)
        for(int j = 0; j <= h; ++j)
        {
            if(i*h+j*w-2*i*j == k)
            {
                cout << "Yes" << endl; exit(0);
            }
        }
    cout << "No" << endl;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		char []a = s.toCharArray();
		Arrays.sort(a);
		char b = a[0];
		int count = 0;
		for(int i = 1; i < 4; i++) {
			if(b == a[i]) {
				count++;
			}
			if(b != a[i]) {
				b = a[i];
			}
		}
		if(count == 2) {
		System.out.println("Yes");
		}
		if(count != 2)
			System.out.println("No");
		

	}

}


Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}
int main(){
    long long n,a[100010];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long sum1 = 0,sum2 = 0;
    for(int i = 0; i < n; i++){
        sum1 ^= a[i];
        if (i == 0){
            sum2 ^= (a[1]^a[n-1]);
        } else if (i == n-1){
            sum2 ^= (a[n-2]^a[0]);
        } else {
            sum2 ^= (a[i-1]^a[i+1]);
        }
    }
    if(sum1 == sum2){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
  



Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt(), X = sc.nextInt(), Y = sc.nextInt();
        Integer[] x = new Integer[n + 1];
        int[] y = new int[m + 1];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            y[i] = sc.nextInt();
        }
        x[n] = X; y[m] = Y;
        Arrays.sort(x, Collections.reverseOrder());
        Arrays.sort(y);
        if (x[0] < y[0]) System.out.println("No War");
        else System.out.println("War");
    }
}

Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(10**9)
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
N, T = inpl()
A = [None]*N
B = [None]*N
for i in range(N):
    A[i], B[i] = inpl()

dp_intime = [[0]*T for _ in range(N+1)]
dp_total = [[0]*T for _ in range(N+1)]
for n in range(1,N+1):
    for t in range(T):
        if A[n-1] > t:
            dp_intime[n][t] = dp_intime[n-1][t]
            dp_total[n][t] = max(B[n-1]+dp_intime[n-1][t], dp_total[n-1][t])
        else:
            dp_intime[n][t] = max(dp_intime[n-1][t], B[n-1]+dp_intime[n-1][t-A[n-1]])
            dp_total[n][t] = max(B[n-1]+dp_intime[n-1][t],
                                 B[n-1]+dp_total[n-1][t-A[n-1]],
                                 dp_total[n-1][t])
print(dp_total[-1][-1])

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

s_dict = {}
for _ in range(n):
    s = input()
    if s not in s_dict:
        s_dict[s] = 0
    s_dict[s] += 1
# print(s_dict)

count_max = sorted(s_dict.values())[-1]
# print(count_max)

s_list = []
for s, count in s_dict.items():
    if count == count_max:
        s_list.append(s)
s_list.sort()
# print(s_list)

for s in s_list:
    print(s)

Measured memory_bytes: 32096
n = int(input())
d = list(map(int, input().split()))
d.sort()

mid1 = d[n//2-1]
mid2 = d[n//2]

mid_num = mid2 - mid1
res = mid_num
mid1c = d.count(mid1)
mid2c = d.count(mid2)

if mid1 == mid2:
    res = 0
print(max(0, res))


Measured memory_bytes: 14396
N = int(input())
A = [int(input()) for _ in range(N)]

if A[0] !=0:
  print(-1)
else:
  ans = 0
  for i in range(1,N):
    if A[i] > A[i-1]+1:
      ans = -1
      break
    elif A[i] == A[i-1]+1:
      ans += 1
    else:
      ans += A[i]
  print(ans)
  

Measured memory_bytes: 11052
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll dp[3020][3020][4];
ll grid[3020][3020];
void solve(){
    ll r,c,k;
    cin >> r >> c >> k;
    rp(i,k){
        ll R,C,V;
        cin >> R >> C >> V;
        grid[R][C]=V;
    }
    
    repi(i,1,r+1){
        repi(j,1,c+1){
            if(grid[i][j]==0){
                rp(k,4){
                    if(k==0) dp[i][j][0]=max(dp[i-1][j][3],dp[i][j-1][0]);
                    else {
                        dp[i][j][k]=max(dp[i][j-1][k],dp[i][j][k-1]);
                    }
                }
            }else{
                rp(k,4){
                    if(k==0) dp[i][j][0]=max(dp[i-1][j][3],dp[i][j-1][0]);
                    else{
                        if(k==1)
                        dp[i][j][k]=max(max(dp[i][j-1][k-1]+grid[i][j],dp[i-1][j][3]+grid[i][j]),max(dp[i][j-1][1],dp[i][j][0]));
                        else{
                            dp[i][j][k]=max(max(dp[i][j-1][k-1]+grid[i][j],dp[i][j][k-1]),dp[i][j-1][k]);
                        }
                    }
                }
            }
        }
    }
    
    print(dp[r][c][3]);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 357520
//
// Created by 刘晴瑞 on 2020/8/30.
//
#include "cstdio"
#include "cstring"
#define MAXN 10000
char s[MAXN],t[MAXN];
int f = -MAXN;

int max(int a,int b){
    return a > b ? a : b;
}

int main(){
    scanf("%s%s",s,t);
    int n = strlen(s);
    int m = strlen(t);
    for (int i = 0; i <= n - m; ++i) {
        int tot = m;
        for (int j = 0; j < m; ++j) {
            if (s[i + j] != t[j]){
                tot--;
            }
        }
        f = max(f,tot);
    }
    printf("%d",m - f);
    return 0;
}

Measured memory_bytes: 1736
loop do
  n, w = gets.split.map(&:to_i)
  break if n == 0
  v = n.times.map{ gets.to_i }
  max = v.max / w
  count = [0.0] * (max + 1)
  v.each{ |i| count[i / w] += 1 }
  puts count.map{ |c| c / count.max }
      .map.with_index{ |c, i| c * (max - i) / max }.reduce(:+) + 0.01
end

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

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

  bool ans = false;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == N) {
        ans = true;
        break;
      }
    }
  }

  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
a = intl()

cnt = 0
for i in range(n):
    if i%2 == 0 and a[i]%2 == 1:
        cnt += 1

print(cnt)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)
#define long long long
const long MOD = 1000000007;

long mPow(long a, long n){
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mPow(a, n-1)) % MOD;
    long t = mPow(a, n/2) % MOD;
    return (t * t) % MOD; 
}

long mFact(long s, long n){
    long ans=1;
    F(i,s,n+1){
        ans = ans * i % MOD;
    }
    return ans;
}

long mComb(long n, long a){
    long X = mFact(n - a + 1, n) % MOD;
    long Y = mFact(1, a) % MOD;
    Y = mPow(Y, MOD - 2) % MOD;
    return X * Y % MOD;
}

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

    cout << (mPow(2, n) - 1 - mComb(n, a) - mComb(n, b) + MOD*3) % MOD << endl;

    return 0;
}

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

struct Rectangle {
    int height;
    int pos;
};

int main()
{
    int H, W;
    cin >> H >> W;
    int color;
    int Table[H + 1][W + 1];
    for(int i = 0; i <= W; i++)
        Table[0][i] = 0;

    for(int i = 1; i <= H; i++)
    {
        for(int j = 1; j <= W; j++)
        {
            cin >> color;
            Table[i][j] = (color == 0 ? Table[i - 1][j] + 1 : 0);
        }
    }

    /*
    for(int i = 1; i <= H; i++)
    {
        cout << Table[i][1];
        for(int j = 2; j <= W; j++)
        {
            cout << " " << Table[i][j];
        }
        cout << endl;
    }
     */

    int max_area = 0;
    for(int i = 1; i <= H; i++)
    {
        stack<Rectangle> S;
        for(int j = 1; j <= W + 1; j++)
        {
            Rectangle rect{};
            rect.height = (j == W + 1 ? 0 : Table[i][j]);
            rect.pos = j;
            if(S.empty())
                S.push(rect);
            else
            {
                if(S.top().height < rect.height)
                    S.push(rect);
                else if(S.top().height > rect.height)
                {
                    int target = j;
                    while(!S.empty() && S.top().height >= rect.height)
                    {
                        Rectangle pre = S.top();
                        S.pop();
                        max_area = max(max_area, pre.height * (j - pre.pos));
                        target = pre.pos;
                    }
                    rect.pos = target;
                    S.push(rect);
                }
            }
        }
    }

    cout << max_area << endl;
}


Measured memory_bytes: 10788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(x) x.begin(), x.end()
#define lp(i, n) for (int i = 0; i < n; i++)
#define mem(a, v) memset(a, v, sizeof(a))
#define X real()
#define Y imag()
#define angle(a) (atan2(a.Y, a.X))
#define vec(a, b) ((b) - (a))
//#define length(a) (hypot(a.Y , a.X))
#define normalize(a) (a) / length(a)
#define dotP(a, b) ((conj(a) * b).X)
#define crossP(a, b) ((conj(a) * b).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(a) dotP(a, a)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(v, m) conj(v / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll n, ll x) {
  if (!x)
    return 1;
  if (x % 2)
    return n * fastpow(n, x - 1);
  ll p = fastpow(n, x / 2);
  p %= mod;
  p *= p;
  p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll ret = num % mod;
  while (ret < 0)
    ret += mod;
  return ret;
}

ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
long double dist(pair<ll, ll> &a, pair<ll, ll> &b) {
  return sqrt(
      ((a.f - b.f) * (a.f - b.f) * 1.0 + (a.se - b.se) * (a.se - b.se)));
}
/*vector<int> ap;
bool np[MX];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <MX; j+=i) np[j] = 0;
        }
    }
    for(ll i = 2 ; i< MX ; i++) if(np[i]) ap.pb(i);
}*/
const ll MX = 1e5+5;
void add(int &a, int b){
	a +=b;
	if(a>=mod) a-=mod;
}
void sub(int &a, int b){
	a -=b;
	if(a<0) a+=mod;
}

int main()
{
    IO;
    int n,k;
    cin>>n>>k;
    vector<int> dp(k+1,0);
    dp[0] = 1;
    for(int i = 0 ; i< n ; i++){
		int current;
		cin>>current;
		vector<int> temp(k+1,0);
		for(int used = k ; used >=0 ; used--){
			int l = 1 + used;
			int r = used + min(current,k-used);
			if(l > r)continue;
			add(temp[l],dp[used]);
			if(r+1 <= k)
			sub(temp[r+1] ,dp[used]); 
		}
		int csum = 0;
		for(int i = 0 ; i<= k ;i++){
			add(csum,temp[i]);
			add(dp[i],csum);
		}
	}
	cout<<dp[k];
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

struct oresen{
    vvl v;
    ll m;
    oresen(vl &x, vl &y){
        m = x.size() - 1;
        v.resize(4);
        rep(i,4) v[i].resize(m);
        rep(j,m){
            if(x[j]==x[j+1]){
                if(y[j+1] - y[j] < 0) v[3][j] = y[j] - y[j+1];
                else v[1][j] = y[j+1] - y[j];
            }else{
                if(x[j+1] - x[j] < 0) v[2][j] = x[j] - x[j+1];
                else v[0][j] = x[j+1] - x[j];
            }
        }
    }

    void update(ll id, ll dir, ll val){
        v[dir][id] = val;
    }
};

bool same(oresen a, oresen b){
    if(a.m != b.m) return false;
    ll m = a.m;
    rep(z,4){
        bool flag = true;
        rep(j,m){
            rep(i,4){
                if(a.v[(i+z)%4][j] != b.v[i][j]) flag = false;
            }
        }
        if(flag) return true;
    }
    rep(z,4){
        bool flag = true;
        rep(j,m){
            rep(i,4){
                if(a.v[(i+z)%4][m-1-j] != b.v[i][j]) flag = false;
            }
        }
        if(flag) return true;
    }
    return false;
}

int main(){
    while(1){
        ll n; cin >> n;
        if(!n) break;
        vector<oresen> a;
        rep(i,n+1){
            ll m; cin >> m;
            vl x(m),y(m);
            rep(j,m){
                cin >> x[j] >> y[j];
            }
            a.push_back(oresen(x,y));
        }
        vl ans;
        REP(i,1,n+1){
            if(same(a[0],a[i])) ans.push_back(i);
        }
        for(auto i : ans) cout << i << "\n";
        cout << "+++++" << "\n";
    }
}


Measured memory_bytes: 3136
// ------------------------------------
// Date:2018/ 3/17
// Problem:bichrome cells d c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1;

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

  CIN(N, A);
  cout << N * N - A << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main(){
  int i,j,cnt;
  int n;
  cin>>n;
  int h[n];
  cnt=0;
  for(i=0;i<n;i++)cin>>h[i];
  for(i=0;i<n-1;i++){
    if(cnt){
      if(h[i+1]-h[i]<=-1){
        cout<<"No";
        return 0;
      }
      if(h[i+1]-h[i]!=0)cnt--;
    }
    if(h[i+1]-h[i]<-1){
      cout<<"No";
      return 0;
    }
    if(h[i+1]-h[i]==-1){
      cnt++;
    }
  }
  cout<<"Yes";
}

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int i,j, ans = 1e9;
    for(i=0;i+m-1<n;i++){
        int cr = 0;
        for(j = i; j <= i+m-1;j++){
            if(s[j] != t[j-i]) cr++;
        }
        ans = min(ans , cr);
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll a,b,c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << "\n";

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)

S = int(input())
MOD = 10**9+7

from functools import lru_cache
@lru_cache(maxsize=10**8)
def rec(n):
    if n < 3: return 0
    ret = 1
    for i in range(3, n-3+1):
        ret += rec(i)
    return ret%MOD

print(rec(S))


Measured memory_bytes: 9696
#include<stdio.h>
#define N 2000
int solve(int,int);
int n;
int A[N];
int main(){
  int q,m,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if( solve(0,m) ) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}
int solve(int i,int m){
  int res1,res2;
  if( m==0 ) return 1;
  if( i >= n ) return 0;
  res1 = solve(i+1,m);
  res2 = solve(i+1,m-A[i]);
  if ( res1 == 1 || res2 == 1 ) return 1;
  else return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  int ans = 0;
  if (A > B) {
    ans += A;
    A--;
  } else {
    ans += B;
    B--;
  }
  if (A > B) {
    ans += A;
    A--;
  } else {
    ans += B;
    B--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System.IO;
using System;

class Program
{
    static void Main()
    {
        var time = int.Parse(Console.ReadLine());
        var h = time / 3600;
        var mtime = time % 3600;
        var m = mtime / 60;
        var s = mtime % 60;
        Console.WriteLine("{0}:{1}:{2}", h, m, s);
    }
}


Measured memory_bytes: 9240
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <cctype>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<long long>
#define vvl vector<vector<long long>>

using namespace std;

typedef long long ll;

int main()
{
  int Q;
  cin >> Q;
  REP(i, Q)
  {
    ll a, b;
    ll res = 0;
    cin >> a >> b;

    //a < bを仮定する
    ll tmp = max(a, b);
    a = min(a, b);
    b = tmp;

    res = a - 1;
    auto sq = (ll)sqrt(a * b);
    if (sq * sq == a * b && a != b)
    {
      res--;
    }
    if ((sq + 1) * sq >= a * b)
    {
      res += sq;
    }
    else
    {
      res += sq + 1;
    }
    res += sq - a - 1;
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n, p = map(int, input().split())
s = list(map(int, list(input())))

ans = 0

if p == 2:
    for i in range(n):
        if s[i] % 2 == 0:
            ans += i + 1
    print(ans)
    exit()

if p == 5:
    for i in range(n):
        if s[i] == 0 or s[i] == 5:
            ans += i + 1
    print(ans)
    exit()

num = 1
l = [0]
for i in range(n-1, -1, -1):
    l.append((num * s[i] + l[-1]) % p)
    num *= 10
    num %= p

from collections import Counter

dic = Counter(l)
for i in dic.values():
    ans += i * (i - 1) // 2

print(ans)

Measured memory_bytes: 67144
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val list = mutableListOf<String>()
    var count = 1
    repeat(n) {
        list.add(readLine()!!)
    }
    val sortedList = list.sorted()
    for (i in 1 until list.size) {
        if (sortedList[i-1] != sortedList[i]) count++
    }
    println(count)
}


Measured memory_bytes: 70816
import sys

#+++++
		
def main():
	n, k = map(int, input().split())
	sl = input()
	ss=0
	for cp, cn in zip(sl, sl[1:]):
		#print(cp,cn)
		if cp == cn and cp == 'L':
			ss+=1
			
	for cp, cn in zip(sl, sl[1:]):
		#print(cp,cn)
		if cp == cn and cp == 'R':
			ss+=1	
			
	nh=n-ss
	#print(nh,k,ss)
	ss += min(nh-1,k*2)
	
	
	print(ss)
	
	
#+++++


if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int N,H;
    cin >> N >> H;
    vector<int>a(N);
    vector<int>b(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    int MAX = a[N-1];
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(b[i] >= MAX) {
            ans++;
            H-=b[i];
        }
        if(H <= 0) {
            cout << ans << endl;
            return 0;
        }
    }
    cout << ans+(H+MAX-1)/MAX << endl;
}


Measured memory_bytes: 1792