akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long n,ans=0,cnt=1,tmp;
int main(){
	cin >> n;
	long long a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(i>0){
			if(a[i-1]==a[i]){
				if(cnt%2==1){
					ans++;
				}
				cnt++;
			}else{
				cnt=1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;

int main() {
    int a, b; cin >> a >> b;
    if (a > 0) cout << "Positive" << endl;
    else if (a <= 0 && b >= 0) cout << "Zero" << endl;
    else {
        if ((b - a + 1) % 2) cout << "Negative" << endl;
        else cout << "Positive" << endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main() {
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	int k;
	cin >> k;
	
	char check = s[k - 1];
	
	for(int i = 0; i < n; i++) {
		if(check == s[i]) {
			cout << s[i];
		}
		else {
			cout << "*";
		}
	}
	cout << endl;
	
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int R, C;
inline bool in(int r, int c) { return 0 <= r and r < R and 0 <= c and c < C; }

int bfs(vector<vector<int>> B) {
  int sr = 0, sc = 0, gr = 0, gc = 0;
  REP(i, R) REP(j, C) {
    if (B[i][j] == 2) sr = i, sc = j;
    if (B[i][j] == 3) gr = i, gc = j;
  }

  vector<vector<bool>> board(R, vector<bool>(C, false));
  REP(i, R) REP(j, C) board[i][j] = B[i][j] == 0;
  board[sr][sc] = board[gr][gc] = true;

  queue<tuple<int, int, vector<vector<bool>>, int>> que;
  que.emplace(sr, sc, board, 0);
  while (not que.empty()) {
    int r, c, cnt; vector<vector<bool>> board; tie(r, c, board, cnt) = que.front(); que.pop();

    if (cnt == 10) break;

    REP(i, 4) {
      int nr = r + dr[i], nc = c + dc[i];
      if (in(nr, nc) and board[nr][nc]) {
        while (in(nr, nc) and board[nr][nc]) {
          if (nr == gr and nc == gc) return cnt + 1;
          nr += dr[i], nc += dc[i];
        }
        if (in(nr, nc) and cnt < 9) {
          vector<vector<bool>> next_board = board;
          next_board[nr][nc] = true;
          que.emplace(nr - dr[i], nc - dc[i], next_board, cnt + 1);
        }
      }
    }
  }
  return -1;
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  while (true) {
    cin >> C >> R;
    if (R == 0 and C == 0) break;
    vector<vector<int>> B(R, vector<int>(C)); REP(i, R) REP(j, C) cin >> B[i][j];
    cout << bfs(B) << endl;
  }


  return 0;
}

Measured memory_bytes: 40800
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (!s.substring(0, 1).equals("A") || s.substring(1, 2).equals("C")) {
            System.out.println("WA");
        } else {
            int c = 0;
            for (int i = 2 ; i < s.length(); i++) {
                if (s.substring(i, i + 1).equals("C")) {
                    c++;
                }


            }
            int d = 0;
            for (int i = 0; i < s.length(); i++) {
                if (Character.isUpperCase(s.charAt(i))) {
                    d ++;
                }
            }
            if (c == 1 && !s.substring(s.length() -1, s.length()).equals("C") && d == 2) {

                System.out.println("AC");
            } else {
                System.out.println("WA");
            }
        }
    }

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  int n, m;
  cin >> n  >> m;
  bool ac[100010] = {};
  int pen[100010] = {};
  int score = 0, tpen = 0;
  rep(i, m){
    int prob; string judge;
    cin >> prob >> judge;
    if(ac[prob]) continue;
    else if(judge == "AC"){
      score++;
      tpen += pen[prob];
      ac[prob] = true;
    }
    else pen[prob]++;
  }
  cout << score << " " << tpen << endl;
}


Measured memory_bytes: 896
#include<stdio.h>
#include<string.h>
int main()
{
	int c=0,i;
	char W[11],T[1001],*p;
	gets(W);
	for(i=0;W[i];i++)W[i]=tolower(W[i]);
	for(;gets(T),strcmp(T,"END_OF_TEXT");)
	{
		for(i=0;T[i];i++)T[i]=tolower(T[i]);
		p=strtok(T," ");
		while(p!=NULL)
		{
			if(!strcmp(W,p))
				c++;
			p=strtok(NULL," ");
		}
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 528
import math
a, b = map(int, input().split(" "))
x_min = a / 0.08
x_max = (a + 1) / 0.08
y_min = b / 0.10
y_max = (b + 1) / 0.10


lower = math.ceil(max([x_min, y_min]))
upper = math.floor(min([x_max, y_max]))
if lower < upper:
    print(lower)
else:
    print("-1")

Measured memory_bytes: 38512
use std::collections::HashSet;

fn input_one<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

fn input_arr<T: std::str::FromStr> () -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().flat_map(str::parse).collect()
}

fn main() {
    let n = input_one::<usize>().unwrap();
    let a = input_arr::<usize>();
    let mut m = HashSet::with_capacity(n);
    for &v in a.iter() {
        m.insert(v);
    }
    println!("{}", if m.len() == n { "YES" } else { "NO" });
}


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

from collections import Counter
q=Counter(d)

if q[0]!=1 or d[0]!=0:
    print(0)
    exit()

ans=1
for i in range(1,max(d)+1):
    ans*=q[i-1]**q[i]
    if ans == 0:
        break
print(ans%998244353)

Measured memory_bytes: 19808
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1001001001; const long long INFLL=1001001001001001001ll;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
    #ifdef int
        cerr<<"\x1b[7m"<<"'int' is defined as 'long long' !!!!"<<"\x1b[m"<<endl;
    #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(12)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int x;
    cin>>x;
    if(x<1200) cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter

class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

mod = 998244353

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

pow2 = [1]*(N+1)
for i in range(N):
    pow2[i+1] = 2*pow2[i]%mod

ans = pow2[N-1]*N%mod

bit = BIT(N)
for i in range(N):
    l1 = bit.sum(xy[i][1])
    l2 = i-l1
    r1 = xy[i][1]-l1
    r2 = N-xy[i][1]-l2-1
    bit.add(xy[i][1],1)
    ans += (pow2[l2]-1)*(pow2[r1]-1)*pow2[r2]*pow2[l1]
    ans += (pow2[r2]-1)*(pow2[l1]-1)*(pow2[l2]+pow2[r1]-1)
    ans %= mod

print(ans)


Measured memory_bytes: 100996
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    int a[55556];
    for(int i=0;i<55556;i++)a[i]=i;
    a[0]=0;
    a[1]=0;
    for(int i=2;i<=55555;i++){
        if(a[i]!=0){
            for(int j=2;j<=55555/i;j++){
                a[i*j]=0;
            }
        }
    }
    int i,j;
    i=0;
    j=2;
    while(i<n){
        if(a[j]%5==2){
            printf("%d\n",a[j]);
            j++;
            i++;
        }else j++;
    }
}

Measured memory_bytes: 384
from collections import Counter

n = int(input())
s=[""]*n
for i in range(n):
  s[i]=input()

def main():
    t = ["".join(sorted(t)) for t in s]
    c = Counter(t)
    cnt = 0
    for v in c.values():
        cnt += v*(v-1)
    print(cnt//2)
main()

Measured memory_bytes: 26912
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
const lli INF = 1e9+5;
int main(){
    
    lli n,k;
    cin >> n>>k;
    vector <lli> v(n);
    for(int i =0;i<n;i++)cin >> v[i];
    vector <lli> dp(n,INF);
    dp[0]=0;
    for(lli i =1;i<n;i++)
        for(lli j=i-1;j>=max((lli)0,i-k);j--)dp[i]= min(dp[i],dp[j]+abs(v[i]-v[j]));
    cout << dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower)
#define upper(a) transform(a.begin(),a.end(),a.begin(),::toupper)
//#define min(a) *min_element(a.begin(),a.end())
//#define max(a) *max_element(a.begin(),a.end())
#define pdd pair<long double,long double>
#define prnt(a) for(auto x:a) cout<<x<<" ";
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'
#define PI 3.1415926535897932385
#define INF 1000000000000000
#define M 1000000007
#define ve  vector<ll>;
ll n;
vector<ll>a(1e5);
vector<ll>dp(1e5+1,-1);



ll fun(ll i)
{
	if(i>n-1)
	{
		return INT_MAX;
	}
	if(i==n-1)
	{
		return 0;
	}
	if(dp[i]!=-1)
	{
		return dp[i];
	}
	if(i+2>n-1)
	{
      return dp[i]=fun(i+1)+abs(a[i]-a[i+1]);
	}
	return dp[i]=min(fun(i+1)+abs(a[i]-a[i+1]),fun(i+2)+abs(a[i]-a[i+2]));


}

 int main()
 {
 	cin>>n;
 	for(ll i=0;i<n;i++)
 	{
 		cin>>a[i];
 	}
 	cout<<fun(0)<<endl;
 	
 	return 0;

 	}

Measured memory_bytes: 7056
(defun main ()
  (declare (optimize (speed 3) (safety 0)))
  (let* ((unit-r (read))
         (unit-g (read))
         (unit-b (read))
         (n (read))
         (res 0))
    (declare ((integer 0 3000) unit-r unit-g unit-b n)
             ((unsigned-byte 32) res))
    (loop for r to n by unit-r
          do (loop for g to (- n r) by unit-g
                   for rest = (- n r g)
                   when (zerop (rem rest unit-b))
                   do (incf res)))
    (format t "~D~%" res)))
 
#-swank(main)


Measured memory_bytes: 13160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int i = 0;
		int ans = 0;
		while(i * 1000 < N) {
			i++;
			ans = i * 1000 - N;
		}

		System.out.println(ans);
	}

}


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

const int N=1e5+10;
int a[N];

int main()
{
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		int t;
		cin>>t;
		a[t]=i;
	}
	
	for(int i=1; i<=n; i++)
		cout<<a[i]<<" ";
	
	return 0;
}

Measured memory_bytes: 1152
#https://agc023.contest.atcoder.jp/submissions/2429958
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    n,x = LI()
    m = [I() for _ in range(n)]
    r = x
    for i in range(n):
        r = r - m[i]
    r = r // (min(m)) + n

    return r

print(main())

Measured memory_bytes: 5716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */

int dp[100001] = {-1};
int	 a[100001];

int main()
{
	int		N,i,j,l,h,c,ans=0;
	scanf("%d", &N);
	for(i=1; i<=N; i++) {
		scanf("%d",&a[i]);
	}

	for(i=1; i<=N; i++) {
		if (dp[ans] < a[i]) dp[++ans] = a[i];
		else {
			l=0;h=ans;
			while(l!=h) {
				c = (l+h)/2;
				if (dp[c]<a[i]) {
					l = c+1;
				} else {
					h = c;
				}
			}
			dp[l] = a[i];
		}
	}

	if (DEBUG) {
		for(i=0; i<=N; i++) {
			printf("%d ",dp[i]);
		}
		ENTER;
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 2476
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n,cnt1=0,cnt2=0;
	cin>>n;
	n--;
	string s;
	cin>>s;
	for(int i=0;i<=n;i++){
		if(s[i]=='W'){
			cnt1++;
		}
	}
	for(int i=n-cnt1+1;i<=n;i++){
		if(s[i]=='R'){
			cnt2++;
		}
	}
	cout<<cnt2;
	return 0;
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define np next_permutation
#define bs binary_search
#define mp make_pair
#define all(x) x.begin(), x.end()
#define bp __builtin_popcountll
#define sqr(x) ((llong)sqrt (x))
#define b_ctz __builtin_ctzll
#define b_clz __builtin_clzll

#define y1 road_to_respa_top_6
#define prev road_to_respa_top_6
#define Abdrakhman abcdefghijklmnopqrstuvwxyzRakhman
#define left kotoriy_levee_chem_right
#define right kotoriy_pravee_chem_left

#define android ios_base::sync_with_stdio(0), cin.tie (0), cout.tie (0)
#define fn ""

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

typedef vector <int> vi;
typedef vector <string> vs;
typedef vector <vector <llong> > matrix;

typedef pair <llong, llong> pll;

typedef map <int, int> mii;

typedef set <llong> sl;

const int MXN = 1e5 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const int INF = 1e9;
const llong LINF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;
const ldouble PI = 3.1415926536;
const string TIME = "rovno_ushten_push_ketti";

inline llong log2 (llong x) {return 64 - b_clz (x) - 1;};
inline llong __lcm (llong a, llong b) {return a / __gcd (a, b) * b;}

int n;
int a[MXN];

pair <int, int> cnt[2][MXN];

int main () {
    android;
    //freopen ("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
        cnt[i % 2][a[i]].f ++;
        cnt[i % 2][a[i]].s = a[i];
    }
    sort (cnt[0] + 1, cnt[0] + MXN, greater <pair <int, int> > ());
    sort (cnt[1] + 1, cnt[1] + MXN, greater <pair <int, int> > ());
    if (cnt[0][1].s != cnt[1][1].s) {
        cout << n - (cnt[1][1].f + cnt[0][1].f);
    }
    else {
        cout << min (n - (cnt[0][1].f + cnt[1][2].f), n - (cnt[0][2].f + cnt[1][1].f));
    }
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  int ans = -1;
  for (int i = 1; i <= 1000000; ++i) {
    int p = (int)((double)(i * 0.08));
    int q = (int)((double)(i * 0.1));
    if (p == A && q == B) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a>>b>>c>>d;
  if((a+b)>(c+d)) {
    cout << "Left" << endl;}
  else if((a+b)==(c+d)) {
    cout << "Balanced" << endl;}
  else {
    cout << "Right" << endl;}
}
 

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 5005
#define M 2000005
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define FJ(i,a,b) for(int i=a;i<b;++i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _q fd[rt]
#define _l fd[rt << 1]
#define _r fd[rt << 1 | 1]
#define MID int mid=((l+r)>>1)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define zero(x) (((x)>0?(x):-(x))<EPS)
#define PB push_back
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define MP make_pair
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
using namespace std;
int n, k;
int a[N];
bool f[2][5005];
bool g[2][5005];
int l[5005][5005];
int r[5005][5005];
int main(){
    //IN;
    SCC(n, k);
    int big = 0;
    int num = 0;
    FF(i, 1, n){
        SC(a[++num]);
        if(a[i] >= k){
            ++big;
            --num;
        }
    }
    f[0][0] = 1;
    int cur = 1;
    FF(i, 1, num){
        FF(j, 0, k - a[i]){
            if(f[cur ^ 1][j])f[cur][j + a[i]] = 1;
        }
        FF(j, 0, k)if(f[cur ^ 1][j])f[cur][j] = 1;
        FF(j, 0, k)l[i][j] = l[i][j - 1] + f[cur][j];
        cur ^= 1;
    }
    g[0][0] = 1;
    cur = 1;
    RR(i, num, 1){
        FF(j, 0, k - a[i]){
            if(g[cur ^ 1][j])g[cur][j + a[i]] = 1;
        }
        FF(j, 0, k)if(g[cur ^ 1][j])g[cur][j] = 1;
        FF(j, 0, k)r[i][j] = r[i][j - 1] + g[cur][j];
        cur ^= 1;
    }
    FF(i, 1, num){
        bool ok = 0;
        //FF(j, k - a[i], k - 1){
        FF(j, 0, k - 1){
            if(j == 0 || l[i - 1][j] > l[i - 1][j - 1]){
                int L = k - a[i] - j, R = k - 1 -j;
                if(L <= 0 || r[i + 1][R] > r[i + 1][L - 1]){
                    ok = 1;
                    break;
                }
            }
        }
        if(ok)++big;
    }
    PR(n - big);
return 0;
}


Measured memory_bytes: 195840
def check(a,b,c):
    if abs(a-b)<c<a+b:
        return True
    else:
        return False

count=0

import collections

N=int(input())
L=list(map(int,input().split()))

c = collections.Counter(L)
l=sorted(list(c.keys()))

le=len(l)

for i in range(le-2):
    for j in range(i+1,le-1):
        for k in range(j+1,le):
            if check(l[i],l[j],l[k]):
                count+=c[l[i]]*c[l[j]]*c[l[k]]
                
print(count)

Measured memory_bytes: 9456
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func debug(a ...interface{}) {
	if os.Getenv("ONLINE_JUDGE") == "false" {
		fmt.Fprintln(os.Stderr, a...)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	k := scanInt()
	fmt.Fprintln(wr, (k+1)/2*(k/2))
}


Measured memory_bytes: 1780
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		char[][] s = new char[h][w];
		for (int i = 0; i < h; i++) {
			s[i] = br.readLine().toCharArray();
		}
		br.close();

		int ans = 0;
		int[] dx = {-1, 1, 0, 0};
		int[] dy = {0, 0, -1, 1};
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '#') {
					continue;
				}
				int max = 0;
				int[][] d = new int[h][w];
				boolean[][] v = new boolean[h][w];
				Queue<Integer> que = new ArrayDeque<>();
				que.add(i * 100 + j);
				v[i][j] = true;
				while (!que.isEmpty()) {
					int cur = que.poll();
					int cx = cur / 100;
					int cy = cur % 100;
					for (int k = 0; k < 4; k++) {
						int nx = cx + dx[k];
						int ny = cy + dy[k];
						if (0 <= nx && nx < h && 0 <= ny && ny < w && !v[nx][ny] && s[nx][ny] == '.') {
							que.add(nx * 100 + ny);
							d[nx][ny] = d[cx][cy] + 1;
							v[nx][ny] = true;
							max = Math.max(max, d[nx][ny]);
						}
					}
				}
				ans = Math.max(ans, max);
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;
typedef long long ll;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
const ll mod = 1e9 + 7;
#define REP(i, o, n) for (ll i = o; i < n; i++)
#define rep(i, n) REP(i, 0, n)

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(b, a % b) * b; }


void actual() {
    // Resolve the problem.
    ll n, m, a, res = 0;
    cin >> n >> m;

    priority_queue<ll> que;
    rep(i, n) {
        cin >> a;
        que.push(a);
    }

    ll q;
    rep(_, m) {
        q = que.top();
        que.pop();
        que.push(q / 2);
    }
    while (!que.empty()) {
        res += que.top();
        que.pop();
    }
    cout << res << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    actual();
    return 0;
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int x,t;
	cin >> x>>t;

	cout << max(0,x-t) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, m;
    cin >> n >> m;
    vector<bool> ac(n);
    vector<int> wa(n);
    int ans = 0;
    rep(i, m) {
        int p; string s;
        cin >> p >> s;
        p--;
        if (s == "AC") {
            if (!ac[p]) ans += wa[p], ac[p] = true;
        } else {
            wa[p]++;
        }
    }
    cout << accumulate(all(ac), 0) << endl;
    cout << ans << endl;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cntR = 0;
    int cntB = 0;
    for(int i = 0; i < (int)s.size(); i++)
    {
        if (s.at(i) == 'R') cntR++;
        else cntB++;
    }
    if (cntR > cntB) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <utility>

using ll = long long;
using namespace std;

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

  // 適当
  for (ll i = 1; i < 100000; i++) {
    if (c == i * a % b) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	long long int s = 0;
	long long int n;
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0)
			s += i;
	}
	printf("%lld", s);
	getchar();
	getchar();
}


Measured memory_bytes: 1732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        string s = cin.next();
        int x =s.Length;
        string ans="";
        for(int i=0;i<x;i++)ans+="x";
        Console.WriteLine(ans);
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
long long mp[10][10];
void f(int x)
{
	int mo=x%10;
	int shou;
	if(x<10)
	{
		shou=x;
	}
	else if(x<100)
	{
		shou=x/10;
	}
	else if(x<1000)
	{
		shou=x/100;
	}
	else if(x<10000)
	{
		shou=x/1000;
	}
	else if(x<100000)
	{
		shou=x/10000;
	}
	else if(x<1000000)
	{
		shou=x/100000;
	}
	if(mo!=0&&shou!=0)
	{
		mp[shou][mo]++;
	}
}
long long ans;
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	{
		f(i);
	}
	for(int i=1;i<=9;i++)
	{
		for(int j=i;j<=9;j++)
		{
			if(i==j&&mp[i][j])
			{
				ans+=mp[i][j]*mp[i][j];
			}
			else if(i!=j&&mp[i][j]&&mp[j][i])
			{
				ans=ans+mp[i][j]*mp[j][i]*2;
			}
		}
	}
	cout<<ans<<endl;
}

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

const long long mod = 1e9 + 7;

long long power(long long a, long long k) {
	long long res = 1;
	while (k) {
		if (k & 1) res = (long long)res * a % mod;
		a = (long long)a * a % mod;
		k >>= 1;
	}
	return res;
}


int C(int a, int b) {
	int res = 1;
	for (int i = 1, j = a; i <= b; i++, j--) {
		res = (long long)res * j % mod;
		res = (long long)res * power(i, mod - 2) % mod;
	}
	return res;
}


int lucas(long long a, long long b) {
	if (a < mod && b < mod) return C(a, b);
	return (long long)C(a % mod, b % mod) * lucas(a / mod, b / mod) % mod;
}

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

	cout << (power(2, n) + mod * 10 - 1 - lucas(n, a) - lucas(n, b)) % mod << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> number(N);
  
  for (int i=0; i < N ; i++){
    cin >> number.at(i);
  }
  sort(number.begin(),number.end());
  reverse(number.begin(),number.end());
  
  int a,b;
  
  for (int i=0 ; i < N ; i += 2){
    a += number.at(i);
      if (i == N-1) { break;}
    b +=number.at(i+1);}
  
  cout << a - b << endl;
}
  
    

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
void solve(){
    int a, b;
    cin >> a >> b;
    if(a > 9 || b > 9) cout << -1;
    else cout << a * b;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--) solve();
}

Measured memory_bytes: 896
#include<cstdio>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
#include<cctype>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stack>
#include<ctime>
#define mst(a,b) memset(a,b,sizeof(a));
const int N = 1e9;
const int mod=(int)1e9+7;
const int INF=0x3f3f3f3f;
typedef long long LL;
//#define LOCAL
const double PI = acos(-1.0);
const int maxn=100+5;
using namespace std;

int a[105];
bool cmp(int a, int b)
{
    return a>b;
}

int gcd(int a, int b)
{
    return (b==0)?a:gcd(b,a%b);
}

#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())

int main()
{
#ifdef LOCAL
    freopen("test.txt", "r", stdin);
#endif // LOCAL
    int n, temp, ans;
    ans = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &temp);
        a[temp]++;
    }
    for(int i = 0; i < 105; i ++)
    {
        if(a[i]) ans++;
    }
    printf("%d", ans);
    return 0;
}

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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    bool x;
    cin >> x;
    print(not x);
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3520
#include <stdio.h>
int main(void) {
	int d, i, s;
	while(scanf("%d", &d) != EOF){
		s = 0;
		for(i = d; i <= 600-d; i+=d) s += i * i * d;
		printf("%d\n", s);
	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int ans = -1;
    for (int i = 0; i <= N; i++) {
        int tax = floor((double)1.08*i);
        if (tax == N) ans = i;
    }
    
    if (ans == -1) cout << ":(" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  string s;
  map<string, ll> m;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> s;
    m[s]++;
  }
  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3628
x=[int(input()) for _ in range(5)]
rem=[]
for i in range(5):
    if x[i]%10 != 0:
        rem.append(10-x[i]%10)
    else:
        rem.append(0)
        
a=x[0] + rem[0]
b=x[1] + rem[1]
c=x[2] + rem[2]
d=x[3] + rem[3]
e=x[4] + rem[4]

print(a+b+c+d+e-max(rem[0],rem[1],rem[2],rem[3],rem[4]))

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
#define INF (int)(1e9)
struct edge { int to, cap, rev; };
vector<edge> G[105];
bool used[105];
void add_edge(int from, int to, int cap) {
	G[from].push_back((edge) { to, cap, (int)G[to].size() });
	G[to].push_back((edge) { from, 0, (int)G[from].size() - 1 });
}

int dfs(int v, int t, int f) {
	if (v == t) return f;
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, INF);
		if (f == 0) return flow;
		flow += f;
	}
}

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

	for (int i = 0; i < b; i++) {
		int u, v, c;
		cin >> u >> v >> c;
		add_edge(u, v, c);
	}

	cout << max_flow(0, a - 1) << endl;

	return 0;
}



Measured memory_bytes: 3180
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<utility>
#include<string>
#include<cmath>
using namespace std;

int main(){
    int a,b;cin >> a >> b;
    int ans = 1;
    int tmp = a;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    while(tmp < b){
        tmp --;
        tmp += a;
        ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long int x[100005]={0};
long long int k=0;
int main(){
	int n=0;
	cin>>n>>k;
	int i=0;
	int a,b;
	for(i=0;i<n;i++){
		cin>>a>>b;
		x[a]+=b;
	}
	i=1;
	while(1){
		k-=x[i];
		if(k<=0){
			cout<<i<<endl;
			break;
		}
		while(1){
			i++;
			if(x[i]!=0){
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <ctime>
#include <set>
#include <algorithm>
#include <cstring>
#include <queue>
#include <stack>
#include <sstream>
#include <cstdio>
#include <bitset>
#include <iomanip>

using namespace std;

long long dp[123456][3];
long long a[123456];
long long b[123456];
long long c[123456];

int main()
{
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    for (int i = 0; i < n; ++i)
        cin >> a[i] >> b[i] >> c[i];

    for (int i = 0; i <= n; ++i)
        for (int j = 0; j < 3; ++j)
            dp[i][j] = -(1LL<<60);

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (j == 0) dp[i][j] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
            if (j == 1) dp[i][j] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
            if (j == 2) dp[i][j] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
        }
    }

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;

    return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N,K,ans=1;
    cin >> N >> K;
    if(K >= 8){
        if(N >= 5) cout << 16 + K*(N-4) << endl;
        else{
            for(int i=0;i<N;i++){
                ans *= 2;
            }
            cout << ans << endl;
        }
    }
    else if(K >= 4){
        if(N >= 4) cout << 8 + K*(N-3) << endl;
        else{
            for(int i=0;i<N;i++){
                ans *= 2;
            }
            cout << ans << endl;
        }
    }
    else if(K >= 2){
        if(N >= 3) cout << 4 + K*(N-2) << endl;
        else{
            for(int i=0;i<N;i++){
                ans *= 2;
            }
            cout << ans << endl;
        }
    }
    else cout << N+1 << endl;


}

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

int main()
{
  string w,b;
  int m,h;
  while(1){
    cin>>w;
    if(w=="-") return 0;
    cin>>m;
    for(int i=0;i<m;i++){
      cin>>h;
      b=w.substr(0,h);
      w.erase(0,h);
      w=w+b;
    }
    cout<<w<<endl;
  }
  return 0;
}                 



Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define mod 1000000007;

int main(){
  ll n,m;
  cin >>n >> m;
  ll ans=0;
  bool zero=true;
  if(n==m||n==m+1||n==m-1)zero=false;
  if(!zero){
    ll counter=1;
    rep(i,n){
      counter*=i+1;
      counter%=mod;
    }
    rep(i,m){
      counter*=i+1;
      counter%=mod;
    }
    if(n!=m)ans=counter;
    else ans=counter*2;
  }
  ans%=mod;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    string A,B;
    cin >> A>>B;

    int a,b;
    cin >>a>>b;

    map<string,int> nums;
    nums[A] = a;
    nums[B] = b;

    string C;
    cin >> C;

    nums[C] -= 1;

    cout << nums[A] <<" " <<nums[B] << endl;



   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

template<class T> class segtree {
	int n;
	vector<T> data;
	T id = INF;
	T operation(T a, T b) { return min(a, b); };
public:
	segtree(int _n) {
		n = 1;
		while (n < _n + 2) n <<= 1;
		data = vector<T>(2 * n, id);
	}
	void change(int i, T x) {
		i += n;
		data[i] = x;
		while (i > 1) {
			i >>= 1;
			data[i] = operation(data[i << 1], data[i << 1 | 1]);
		}
	}
	void add(int i, T x) { change(i, data[i + n] + x); }
	T get(int a, int b) {
		T left = id; T right = id;
		a += n; b += n;
		while (a < b) {
			if (a & 1) left = operation(left, data[a++]);
			if (b & 1) right = operation(data[--b], right);
			a >>= 1; b >>= 1;
		}
		return operation(left, right);
	}
	T get_all() { return data[1]; }
	T operator[](int i) { return data[i + n]; }
};

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

	ll n, e, t;
	cin >> n >> e >> t;
	vector<ll> a(n + 1);
	a[0] = 0;
	for (int i = 1; i <= n; i++) cin >> a[i];
	vector<vector<int>> ch(n + 2, vector<int>());
	rep(i, n) {
		ll sum = 2 * a[i + 1] + t;
		int ng = -1, ok = n + 1;
		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (2 * a[mid] > sum) ok = mid;
			else ng = mid;
		}
		ch[ok].pb(i);
	}
	segtree<ll> dp(n + 1), seg(n + 1);
	dp.change(0, 0);
	for (int i = 1; i <= n; i++) {
		for (int j : ch[i]) {
			seg.change(j, dp[j] - 2 * a[j + 1]);
			dp.change(j, INF);
		}
		ll mi = dp.get(0, i) + t;
		chmin(mi, seg.get(0, i) + 2 * a[i]);
		dp.change(i, mi);
	}
	cout << dp[n] + e << '\n';
}

Measured memory_bytes: 13496
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
int main()
{
    //optimize();
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=(min(k,a)*1);
    k-=a;
    if(k>0)
    {
        ans+=min(k,b)*0;
    }
    k-=b;
    if(k>0)
    {
        ans+=(min(k,c)*-1);
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            Set<String> set = new HashSet<String>();
            int n = Integer.parseInt(reader.readLine());
            int[] eq = new int[n];
            int k = 0;
            for(int i = 0; i < n; i++){
                String line = reader.readLine();
                String[] str = line.split(" ");
                if(str[0].equals("insert")){
                    set.add(str[1]);
                }else if(str[0].equals("find")){
                    if(set.contains(str[1])){
                        eq[k] = 1;
                    }else{
                        eq[k] = 0;
                    }
                    k++;
                }
            }
            for(int i = 0; i < k; i++){
                if(eq[i] == 1){
                    System.out.println("yes");
                }else if(eq[i] == 0){
                    System.out.println("no");
                }
            }
        }catch(IOException e){

        }
    }
}


Measured memory_bytes: 200108
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

int main()
{
    ll N;

    cin >> N;

    struct Restaurant {
        int idx;
        std::string city;
        int score;
    };

    std::vector<Restaurant> rests(N);

    for (size_t i = 0; i < N; i++) {
        rests[i].idx = i;
        cin >> rests[i].city >> rests[i].score;
    }

    std::sort(rests.begin(), rests.end(), [](const Restaurant &lhs, const Restaurant &rhs) {
        if (lhs.city != rhs.city) {
            return lhs.city < rhs.city;
        }
        return lhs.score >= rhs.score;
    });

    for (const auto &rest : rests) {
        cout << rest.idx + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256