akhauriyash/Code-Regression huggingface dataset:
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

#def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
require 'openssl'
def C(a,b)
  if b==0||a==b
    1
  else
    b=a-b if a/2<b
    x=(a-b+1..a).inject(1){|res,i|res*i%MOD}
    y=(1..b).inject(1){|res,i|res*i%MOD}
    yn=OpenSSL::BN.new(y).mod_inverse(MOD)
    x*yn
  end
end

r1,c1,r2,c2=gsmi

sum=0
sum+=C(r2+1+c2+1,c2+1)%MOD
sum-=(C(r1+c2+1,r1)%MOD+C(r2+1+c1,r2+1)%MOD)
sum+=C(r1+c1,c1)%MOD

puts sum%MOD

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

void solve(long long A, long long B, long long T){
	cout << B*(T/A) << endl;
}

int main(){	
	long long A;
	long long B;
	long long T;
	scanf("%lld",&A);
	scanf("%lld",&B);
	scanf("%lld",&T);
	solve(A, B, T);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int,ll> mp;
    rep(i,n) mp[a[i]]++;
    ll total = 0;
    for (auto m: mp) total += m.second * (m.second - 1) / 2;
    rep(i,n) {
        ll pl = max(0LL, ((mp[a[i]] - 1) * (mp[a[i]] - 2) / 2));
        ll mi = (mp[a[i]] - 1) * mp[a[i]] / 2;
        cout << (total - mi + pl) << endl;
    }
    return 0;
}

Measured memory_bytes: 10368
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val (h, w) = sc.intList()
        val a = Array(h) { sc.next() }
        val yy = Array(h) { true }
        val xx = Array(w) { true }
        for (i in 0 until h) {
            for (j in 0 until w) {
                if (a[i][j] == '#') {
                    yy[i] = false
                    xx[j] = false
                }
            }
        }

        val ans = mutableListOf<String>()
        for (i in 0 until h) {
            if (yy[i]) continue
            val line = mutableListOf<Char>()
            for (j in 0 until w) {
                if (xx[j]) continue
                line.add(a[i][j])
            }
            ans.add(String(line.toCharArray()))
        }
        println(ans.joinToString("\n"))
    }
}


class MyScanner() {
    private var index = 0
    private var line = listOf<String>()

    fun next(): String {
        while (line.size <= index) {
            line = readLine()!!.split(' ')
            index = 0
        }
        return line[index++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun strList(): List<String> {
        index = line.size
        return readLine()!!.split(' ')
    }

    fun intList() = strList().map { it.toInt() }
    fun longList() = strList().map { it.toLong() }
    fun doubleList() = strList().map { it.toDouble() }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL A, B; cin >> A >> B;
	LL ans = 0;
	auto f = [](int x) {
		string s = to_string(x);
		bool ok = 1;
		FOR(i, 0, SZ(s) / 2) {
			ok &= s[i] == s[SZ(s) - i - 1];
		}
		return ok;
	};
	FOR(i, A, B + 1) {
		if (f(i))ans++;
	}
	
	
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

long long int fact[100001];
long long int revfact[100001];

int n;

void getfact()
{
	fact[0] = 1;
	fact[1] = 1;
	for(int i = 2; i <= n + 1; i++){
		fact[i] = (i * fact[i - 1]) % mod;
	}
	return;
}

void getrevfact()
{
	for(int i = 0; i <= n + 1; i++){
		long long int tmp[31];
		tmp[0] = fact[i];
		for(int j = 1; j < 31; j++){
			tmp[j] = (tmp[j - 1] * tmp[j - 1]) % mod;
		}
		int now = mod - 2;
		revfact[i] = 1;
		for(int j = 30; j >= 0; j--){
			int t = (int)pow(2, j);
			if(now >= t){
				now -= t;
				revfact[i] = (revfact[i] * tmp[j]) % mod;
			}
		}
	}
	return;
}

long long int getcomb(int n, int r)
{
	if(r > n) return 0;
	// cout << n << " " << r << " " << (fact[n] * ((revfact[r] * revfact[n - r]) % mod)) % mod << endl;
	return (fact[n] * ((revfact[r] * revfact[n - r]) % mod)) % mod;
}

int main()
{
	cin >> n;
	map<int, int> m;
	int n1, n2;
	for(int i = 1; i <= n + 1; i++){
		int a;
		cin >> a;
		if(m.find(a) == m.end()){
			m[a] = i;
		} else {
			n1 = m[a] - 1;
			n2 = n - i + 1;
		}
	}
	// cout << n1 << " " << n2 << endl;
	getfact();
	getrevfact();
	for(int i = 1; i <= n + 1; i++){
		cout << (getcomb(n + 1, i) - getcomb(n1 + n2, i - 1) + mod) % mod << endl;
	}
	return 0;
}

Measured memory_bytes: 7680
// Problem : D - Replacing
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int arr[n];
		int sum = 0;
		map<int,int> mp;
		for(int i=0;i<n;++i)
		{
			cin>>arr[i];
			mp[arr[i]]++;
			sum+=arr[i];
		}
		int q;
		cin>>q;
		while(q--)
		{
			int b,c;
			cin>>b>>c;
			sum-= b*mp[b];
			sum+= c*mp[b];
			mp[c]+= mp[b];
			mp[b] = 0;
			cout<<sum<<"\n";
		}		
    }
    return 0;
}


Measured memory_bytes: 10372
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            int a = Integer.parseInt(s.substring(0, 1));
            int b = Integer.parseInt(s.substring(1, 2));
            int c = Integer.parseInt(s.substring(2, 3));
            int d = Integer.parseInt(s.substring(3, 4));
            // kuso code ;;
            if (a + b + c + d == 7) out.println(a + "+" + b + "+" + c + "+" + d + "=" + 7);
            else if (a + b + c - d == 7) out.println(a + "+" + b + "+" + c + "-" + d + "=" + 7);
            else if (a + b - c + d == 7) out.println(a + "+" + b + "-" + c + "+" + d + "=" + 7);
            else if (a + b - c - d == 7) out.println(a + "+" + b + "-" + c + "-" + d + "=" + 7);
            else if (a - b + c + d == 7) out.println(a + "-" + b + "+" + c + "+" + d + "=" + 7);
            else if (a - b + c - d == 7) out.println(a + "-" + b + "+" + c + "-" + d + "=" + 7);
            else if (a - b - c + d == 7) out.println(a + "-" + b + "-" + c + "+" + d + "=" + 7);
            else if (a - b - c - d == 7) out.println(a + "-" + b + "-" + c + "-" + d + "=" + 7);
        }

    }
}



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

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
typedef vector<int> vi; 
typedef pair<int,int> pii; 
#define pb push_back
#define mp make_pair
#define prarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define prmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<"\t";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }
const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
const int mod=1000*1000*1000+7;  

// ----------------------------------------------------------------------------	-------------- 

void solve(){
  int n; cin>>n; 
  vi a(n); 
  int cur=1; 
  int save=0; 
  for(int i=0;i<n;i++){
    cin>>a[i]; 
    if(a[i]==cur){
      save++; 
      cur++; 
    }
  }
  if(save==0){
    cout<<-1<<endl; 
  }
  else {
    cout<<n-save<<endl; 
  }
}

int main(){
	// clock_t beg=clock(); 
  fast_io; 
  int testcases=1; 
  // cin>>testcases; 
  cout << fixed << setprecision(13); 
  while(testcases--){
    solve(); 	
  }
	// clock_t end=clock(); 
	// fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>


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

    std::map<int, int> m;
    for (int i = 1; i <= n; i++) {
        int t = i, c = 2;
        while (t != 1) {
            while (t % c == 0) {
                m[c]++;
                t /= c;
            }
            c++;
        }
    }

    long long ans = 1;
    for (auto it = m.begin(); it != m.end();it++) {
        ans *= it->second + 1;
        ans %= 1000000007;
    }

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

Measured memory_bytes: 384
import math
import fractions
import collections
import itertools
N=int(input())
l=[0]*4
for i in range(N):
    s=input()
    if s=="AC":
        l[0]=l[0]+1
    if s=="WA":
        l[1]=l[1]+1
    if s=="TLE":
        l[2]=l[2]+1
    if s=="RE":
        l[3]=l[3]+1
print("AC","x",str(l[0]))
print("WA","x",str(l[1]))
print("TLE","x",str(l[2]))
print("RE","x",str(l[3]))


Measured memory_bytes: 74728
from itertools import product
import bisect
import sys


def input():
    return sys.stdin.readline()[:-1]


n, m = map(int, input().split())
n_min = 1
n_max = 10000000
for i in range(m):
    l, r = map(int, input().split())
    n_min = max(n_min, l)
    n_max = min(n_max, r)
ans = n_max-n_min+1
if ans < 0:
    ans = 0
print(ans)


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

using ll = long long;
#define REP(i, n) for (ll(i) = 0, i < ll(n); i++)
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())

int main()
{
  int L, R, d;
  cin >> L >> R >> d;

  int ans = 0;
  for (int i = L; i <= R; i++)
  {
    if (i % d == 0)
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
	    String line = Io.read();

	    int answer = 0;
	    for (int i = 0; i < line.length(); i++) {
	        if (line.charAt(i) == '+') answer++;
	        else answer--;
        }

        Io.write(answer);
    }
}

class Io {

    public static String read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        br.close();
        return line;
    }

    public static void write(int answer)
    {
        System.out.println(answer);
    }
}

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

using namespace std;
#define int long long
const int N = 1e4 + 10, K = 110, MOD = 1e9 + 7;
int dp[N][K];

int32_t main()
{
    string k; cin >> k;
    int D, n = k.size(); cin >> D;
    for (char c = '0'; c < k[0]; c++) dp[0][(c - '0') % D]++;
    int sum = (k[0] - '0') % D;
    for (int i = 1; i < n; i++) {
        for (char c = '0'; c < k[i]; c++) dp[i][(c - '0' + sum) % D]++, dp[i][(c - '0' + sum) % D]%=MOD;
        for (int j = 0; j < D; j++)
            for (char c = '0'; c <= '9'; c++) dp[i][(c - '0' + j) % D] += dp[i - 1][j], dp[i][(c - '0' + j) % D]%=MOD;
        sum = (k[i] - '0' + sum) % D;
    }
    cout << (dp[n - 1][0] + (sum % D == 0) - 1 + MOD) % MOD << "\n";

    return 0;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define ul unsigned long long int
using namespace std;
typedef vector<ul> vi;
void solve()
{
 vi vo(3);
 for(ul &i:vo)
  cin>>i;
 for(ul i = 0;i<3;i++)
  if(i!=1)
   swap(vo[i],vo[(i+1)%3]);
 for(ul i:vo)
  cout<<i<<" ";
 cout<<"\n";
}
int main()
{
 solve();
 return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B,T;
    cin >> A >> B >> T;
    ll ans = 0;
    rep(i,1,25){
        if(i*A <= T) ans += B;
    }
    print(ans);
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second

/* STL */
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a)   reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n) i=1;i<=(n);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";

int main()
{

   Ezio
   ll t,m(0),n,x,a,b;
   string s;

   cin>>n;

   vector<ll>v(n);

   fr(i,n)cin>>v[i];

   fr(i,n){
     for (ll j=i+1;j<n;j++){
         m+= v[i]*v[j];
     }
   }

   cout<<m<<endl;
   return 0;
}


Measured memory_bytes: 3620
package main

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

func main() {
	sc := newInputScanner(true, 1024)
	N, M := sc.nextInt(), sc.nextInt()
	var answer int
	if N > 1 {
		answer += N * (N - 1) / 2
	}
	if M > 1 {
		answer += M * (M - 1) / 2
	}
	fmt.Println(answer)
}

type inputScanner struct {
	*bufio.Scanner
}

func newInputScanner(enabledScanWords bool, sizeInKB int) *inputScanner {
	scanner := bufio.NewScanner(os.Stdin)
	if enabledScanWords {
		scanner.Split(bufio.ScanWords)
	}
	capacity := sizeInKB * 1024
	buf := make([]byte, capacity)
	scanner.Buffer(buf, capacity)
	return &inputScanner{
		Scanner: scanner,
	}
}

func (inputSc *inputScanner) nextInt() int {
	i, e := strconv.Atoi(inputSc.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (inputSc *inputScanner) nextUInt64() uint64 {
	i, e := strconv.ParseUint(inputSc.nextStr(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func (inputSc *inputScanner) nextStr() string {
	inputSc.Scan()
	return inputSc.Text()
}

type debuggable struct {
}

const (
	DEBUG_ON = false
)

func (d *debuggable) debug(f func()) {
	if DEBUG_ON {
		f()
	}
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	
	public static double sequence(int a[], double start) {
		double count = 0.0, presum = start, sum = start;
		
		for(int i = 1; i < a.length; ++i) {
			sum += (double)a[i];
			if(sum * presum > 0) {
				double min = Math.abs(sum) + 1;
				if(presum > 0)sum -= min;
				else sum += min;
				count += min;
			}
			
			if(sum == 0) {
				if(presum > 0)sum--;
				else sum++;
				++count;
			}
			
			presum = sum;
		}
		
		return count;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, a[];
		double count = 0.0, tmp2 = 0.0, tmp3 = 0.0;
		
		n = sc.nextInt();
		a = new int[n];
		
		for(int i = 0; i < n; ++i) a[i] = sc.nextInt();
		
		sc.close();
		
		
		if(a[0] == 0) {
			a[0]++;
			++tmp3;
		}
		
		int tmp = Math.abs(a[0]) + 1;
		
		if(a[0] > 0) {
			tmp2 = tmp - tmp3;
			tmp = a[0] - tmp;
		}
		else { 
			tmp2 = tmp + tmp3;
			tmp = a[0] + tmp;
		}
		
		count = Math.min((tmp3 + sequence(a, (double)a[0])),(tmp2 + sequence(a, (double)tmp)));
		
		System.out.printf("%.0f\n", count);
	}

}


Measured memory_bytes: 51820
def main():
    S = list(input())
    T = list(input())
    d1 = {}
    d2 = {}
    for k in set(T):
        d1[k] = set()
    for k in set(S):
        d2[k] = set()
    for s, t in zip(S, T):
        d1[t].add(s)
        d2[s].add(t)
    if all([len(v) == 1 for v in d1.values()]) and all([len(v) == 1 for v in d2.values()]):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


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

int main(void) {
    int n, ans;
    vector<int> s;
    cin >> n;
    s.resize(n);
    for (int i = 0; i < n; i++)
        cin >> s[i];
    sort(s.begin(), s.end());
    ans = accumulate(s.begin(), s.end(), 0);
    if (!(ans % 10)) {
        for (int i = 0; i < n; i++) {
            if (s[i] % 10) {
                ans -= s[i];
                break;
            }
        }
    }
    cout << (ans % 10 ? ans : 0) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	int n, z, w; scanf("%d %d %d", &n, &z, &w);
	int a[2000];
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	int res;
	if(n == 1) res = abs(a[0] - w);
	else res = max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1]));
	printf("%d\n", res);
	return 0;
}

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

using namespace std;
using ll = long long;



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

    vector<pair<int,int>> s,p,c,tv(n);
    for(int i = 0;i < n;++i) {
        int ts,tp,tc;
        cin>>ts>>tp>>tc;
        s.emplace_back(ts,i);
        p.emplace_back(tp,i);
        c.emplace_back(tc,i);
    }
    sort(s.rbegin(),s.rend());
    sort(p.rbegin(),p.rend());
    sort(c.rbegin(),c.rend());



    int tans=0;
    int ans=1000;
    vector<int> ssc(n,0),psc(n,0),csc(n,0);
    vector<pair<int,int>> sc(n);


    for(int hoge=0;hoge<3;++hoge) {

        tv=s;

        for(int i = 0;i < n;++i) {
            int tr=r[i];
            do{
                psc[p[i].second]=tr;

                ++i;
            }while(i<n&&p[i-1].first==p[i].first);
            --i;
        }

        for(int i = 0;i < n;++i) {
            int tr=r[i];
            do{
                csc[c[i].second]=tr;
                ++i;
            }while(i<n&&c[i-1].first==c[i].first);
            --i;
        }

        tans=0;

        while(tans<=100) {
            ++tans;
            for(int i = 0;i < n;++i) {
                if(s[i].second==0){
                    ++s[i].first;
                    break;
                }
            }
            sort(s.rbegin(),s.rend());


            for(int i = 0;i < n;++i) {
                int tr=r[i];
                do{
                    ssc[s[i].second]=tr;
                    ++i;
                }while(i<n&&s[i-1].first==s[i].first);
                --i;
            }

            for(int i = 0;i < n;++i) {
                sc[i]=make_pair(ssc[i]+psc[i]+csc[i],i);
            }
            sort(sc.rbegin(),sc.rend());

            int juni=0;
            int i=0;

            while(1) {
                juni=i+1;
                do {

                    if(sc[i].second==0) {

                        if(juni<=8)goto eosl;
                        else break;
                    }
                    ++i;
                }while(sc[i-1].first==sc[i].first);




                if(juni>=9)break;
            }

        }

        eosl:;
        ans=min(ans,tans);

        s=p;
        p=c;
        c=tv;
    }

    if(ans>=101)cout<<"Saiko"<<endl;
    else cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 3124
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		List<Long> list = new ArrayList<>();
		long tmp = 0l;
		long count = 0l;
		while (tmp < (long) 1e16 * 20l) {
			tmp = (long) Math.pow(count++, 5);
			list.add(tmp);
		}
		long a = Long.MIN_VALUE;
		long b = 0l;
		boolean end = false;
		for (int i = 0; i < list.size() && !end; ++i) {
			for (int j = 0; j < list.size(); ++j) {
				long a1 = list.get(i);
				long b1 = list.get(j);
				long calc = a1 - b1;
				if (calc == x) {
					a = i;
					b = j;
					if (b1 < 0l) {
						b *= -1l;
					}
					if (a1 < 0l) {
						a *= -1l;
					}
					end = true;
					break;
				}
			}
		}
		if (a < (long) 1e16) {
			for (int i = 0; i < list.size() && !end; ++i) {
				for (int j = 0; j < list.size(); ++j) {
					long a1 = list.get(i);
					long b1 = list.get(j);
					b1 *= -1l;
					long calc = a1 - b1;
					if (calc == x) {
						a = i;
						b = j;
						if (b1 < 0l) {
							b *= -1l;
						}
						if (a1 < 0l) {
							a *= -1l;
						}
						end = true;
						break;
					}
				}
			}
		}
		if (a < (long) 1e16) {
			for (int i = 0; i < list.size() && !end; ++i) {
				for (int j = 0; j < list.size(); ++j) {
					long a1 = list.get(i);
					long b1 = list.get(j);
					a1 *= -1l;
					long calc = a1 - b1;
					if (calc == x) {
						a = i;
						b = j;
						if (b1 < 0l) {
							b *= -1l;
						}
						if (a1 < 0l) {
							a *= -1l;
						}
						end = true;
						break;
					}
				}
			}
		}
		if (a < (long) 1e16) {
			for (int i = 0; i < list.size() && !end; ++i) {
				for (int j = 0; j < list.size(); ++j) {
					long a1 = list.get(i);
					long b1 = list.get(j);
					b1 *= -1l;
					a1 *= -1l;
					long calc = a1 - b1;
					if (calc == x) {
						a = i;
						b = j;
						if (b1 < 0l) {
							b *= -1l;
						}
						if (a1 < 0l) {
							a *= -1l;
						}
						end = true;
						break;
					}
				}
			}
		}
		System.out.println(a + " " + b);
	}
}


Measured memory_bytes: 40020
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>  
using namespace std;
//int M[3001][3001];
int main() {
  stack<char>aux;
  //string a="0", b="0";
  string c,d;
  cin>>c>>d;
  //a+=c;
  //b+=d;
  int linha=c.size(), coluna=d.size();
  int M[linha+1][coluna+1];
  for(int i=0; i <= linha;i++){
    M[i][0]=0;
  }
  for(int i=0; i <= coluna;i++){
    M[0][i]=0;
  }
  for(int i=1;i<=linha;i++){
    for(int j=1;j<=coluna;j++){
      if(c[i-1]==d[j-1]){
        M[i][j]=M[i-1][j-1]+1;
      }
      else if(M[i-1][j]>=M[i][j-1]){
        M[i][j]=M[i-1][j];
      }
      else{
        M[i][j]=M[i][j-1];
      }
    }
  }
    /*for(int i=1;i<linha;i++){
      for(int j=1;j<coluna;j++){
        cout<<M[i][j]<<" ";
      }
      cout<<endl;
    }*/
    for(int i=linha;i>=1;i--){
      for(int j=coluna;j>=1;j--){
        if(c[i-1] == d[j-1]){
          aux.push(c[i-1]);
          coluna--;
          break;
          }
        else if(M[i-1][j]>M[i][j-1]){
          break;
          } 
          coluna--;
     }
  }
  //aux.pop();
  while(aux.size()){
    //if(aux.top()!='0')
    cout<<aux.top();
    aux.pop();
  }
  cout<<endl;
}

Measured memory_bytes: 35456
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, m;
    cin >> n >> m;
    int h[m + 1];
    memset(h, 0, sizeof(h));
    for(int i = 1; i <= n; i++){
        int k;
        cin >> k;
        while(k--){
            int f;
            cin >> f;
            h[f]++;
        }
    }
    int ans = 0;
    for(int i = 1; i <= m; i++){
        if(h[i] == n){
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int calc(int n){
    int res = 0;
    for(int i = 1; i*i <= n; i++){
        if(n % i == 0){
            res += i; 
            if(i*i != n) res += n / i;
        }
    }
    return res - n;
}


signed main(){
    int n;
    while(cin >> n, n){
        int sum = calc(n);
        //o(sum);
        if(sum == n) cout << "perfect number" << endl;
        if(sum < n) cout << "deficient number" << endl;
        if(sum > n) cout << "abundant number" << endl;
    }
}

Measured memory_bytes: 1152
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 6;
const int MAXCLEN = 50;
const int MAXP = MAXN*MAXCLEN;

int n, clen;
int alen[MAXN];
int p[MAXN]; // relative order of fractions
int r[MAXN];

//dp[i][mask][j] is number of ways that we cover exactly the first j segments with arcs when the only the arcs in mask start on the first i points (conditional on relative order of fractions)
double dp[MAXP + 1][1 << (MAXN - 1)][MAXP + 1];

double solve() {
	REP(i, n) r[p[i]] = i;
	memset(dp, 0, sizeof(dp));
	dp[1][0][n*alen[n - 1]] = 1;
	FOR(i, 1, n*clen) REP(mask, 1 << (n - 1)) FORE(j, 1, n*clen) if (dp[i][mask][j] != 0) {
		//no arcs starts at point i+1
		dp[i + 1][mask][j] += dp[i][mask][j];
		//arc r[i%n] starts at point i+1
		int idx = r[i%n];
		if (idx != n - 1 && (mask&(1 << idx)) == 0) {
			int nj = j < i ? j : max(j, min(n*clen, i + n*alen[idx] - 1));
			dp[i + 1][mask | (1 << idx)][nj] += dp[i][mask][j];
		}
	}
	//FORE(i, 1, n*clen) REP(mask, 1 << (n - 1)) FORE(j, 1, n*clen) if (dp[i][mask][j] != 0) printf("%d,%x,%d = %lf\n", i, mask, j, dp[i][mask][j]);
	double num = dp[n*clen][(1 << (n - 1)) - 1][n*clen], den = 1; REP(i, n - 1) den *= clen; double ret = num / den;
	//printf("p:"); REP(i, n) printf(" %d", p[i]); printf(" -> %lf (%lf/%lf)\n", ret,num,den);
	return ret;
}

void run() {
	scanf("%d%d", &n, &clen); REP(i, n) scanf("%d", &alen[i]);
	sort(alen, alen + n);
	REP(i, n - 1) p[i] = i + 1; p[n - 1] = 0;
	double ret = 0; int nperm = 0;
	do {
		ret += solve(); ++nperm;
	} while (next_permutation(p, p + n - 1));
	printf("%.15lf\n", ret / nperm);
}

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


Measured memory_bytes: 23040
def main():
  N=int(input())
  A=list(map(int,input().split()))

  if 0 in A:
    print(0)
    return
  prod=1
  for a in A:
    prod*=a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)
main()


Measured memory_bytes: 21676
using System;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            bool result = true;
            string inputNum = Console.ReadLine();

            for(int i = 0; i < inputNum.Length - 1; i++)
            {
                if(inputNum[i] == inputNum[i + 1])
                {
                    result = false;
                }
            }

            if (result)
            {
                Console.WriteLine("Good");
            }
            else
            {
                Console.WriteLine("Bad");
            }
        }
    }
}


Measured memory_bytes: 13140
import sys
input = sys.stdin.readline
N=int(input())
lst=[0]*N
lst=[list(map(int,input().split())) for i in range(N)]
lst.sort(key=lambda x: x[1])
ans=0
t=0
for i in range(N):
 t+=lst[i][0]
 if t>lst[i][1]:
  ans+=1
if ans==0:
 print("Yes")
else:
 print("No")

Measured memory_bytes: 53412
#include<stdio.h>
#define N 100000
#define Q 50000
int binarySearch(int*,int ,int );
int main(){

  int n,i,j,q,key;
  int S[N];
  int T[Q];
  int count=0;
  
  /*1つめの配列*/
scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);

  /*2つめの配列*/
scanf("%d",&q);
for(i=0;i<q;i++)
    scanf("%d",&T[i]);
/*T配列を二分探索*/
for(i=0;i<q;++i){
    key=S[i];
    j=i-1;
while(j>=0&&S[j]>key){
S[j+1]=S[j];
j--;
S[j+1]=key;
   
 }}
for(i=0;i<q;i++){
  
  if(S[binarySearch(S,n,T[i])]==T[i])
    count++;
  }
/*表示*/
 printf("%d\n",count);

 return 0;
}
/*二分探索*/
int binarySearch(int* A,int n,int key){
  int left = 0;
  int right = n;
  int mid;
  while (left < right){
    mid = (left + right) / 2;
	if (A[mid] == key)
	      return mid;
        else if (key < A[mid])
	  right = mid;
        else
	  left = mid + 1;
	  }
  return 0;
}



Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
typedef long long ll;
const int INF = 1<<29;
const int N = 1e6 + 9;
ll a[N];
bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    if(a.second == b.second){
        return a.first < b.first;
    }
    return a.second < b.second;
}
int main()
{
    fio;
    ll a, b, c;
    cin >> a >> b >> c;
    ll k = a / (b + c);
    ll kk = a % (b + c);
    if(kk == 0){
        cout << b * k;
    }
    else{
        if(kk > b){
            cout << (b * k) + b;
        }
        else cout << (b * k) + kk ;
    }
    return 0;
}


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

int main(){
	long long N;
	vector<long long> L;
	cin >> N;
	for(long long i = 0; i < N; i++){
		long long l;
		cin >> l;
		L.push_back(l);
	}
	sort(L.begin(), L.end());

	long long ans = 0;

	for(long long i = 0; i < N; i++){
		for(long long j = i + 1; j < N; j++){
			long long a = L[i];
			long long b = L[j];
			long long mini = max(a-b, b-a);
			auto minit = upper_bound(L.begin(), L.end(), mini);
			auto maxit = lower_bound(L.begin(), L.end(), a+b);
			if(maxit != L.begin()){
				maxit--;
				long long tmp = maxit - minit + 1;
				if(mini < a){
				 	tmp--;
				}
				if(mini < b){
					tmp--;
				}
				ans += max(0LL, tmp);
			}
		}
	}
	cout << ans / 3 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define FFOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>
 
 
signed main(){
	
	int n;cin >>n;
	
	FOR(ih,1,3500)FOR(i,1,3500)
	{
		if((4*ih*i-n*i-n*ih)<=0) continue;
		if((n*ih*i)%(4*ih*i-n*i-n*ih)==0)
		{
			cout << ih << " " << i << " " << (n*ih*i)/(4*ih*i-n*i-n*ih)<<endl;
			return 0;
		}
	}
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(),a.end());
  ll ub = 2e18;
  ll lb = -2e18;

  while(ub-lb>1){
    ll mid = (ub+lb)/2;
    ll cnt = 0;
    //    cout << "mid " << mid << endl;
    rep(i,n-1){
      if(a[i]>0){
	if(a[n-1]*a[i]<=mid) cnt += (n-1)-(i+1)+1;
	else if(a[i+1]*a[i]>mid) continue;
	else{
	  ll ub2 = n-1;
	  ll lb2 = i+1;
	  while(ub2-lb2>1){
	    ll mid2 = (ub2+lb2)/2;
	    if(a[i]*a[mid2]<=mid) lb2=mid2;
	    else ub2=mid2;
	  }
	  cnt += ub2 - (i+1);	  
	}
      }
      else{
	if(a[i+1]*a[i]<=mid) cnt += (n-1)-(i+1)+1;
        else if(a[n-1]*a[i]>mid) continue;
        else{
	  ll ub2 = n-1;
          ll lb2 = i+1;
          while(ub2-lb2>1){
            ll mid2 = (ub2+lb2)/2;
            if(a[i]*a[mid2]>mid) lb2=mid2;
            else ub2=mid2;
          }
          cnt += (n-1) - lb2;
	}
      }
    }
    //    cout << "mid cnt " << mid << " " << cnt << endl;
    if(cnt<k) lb=mid;
    else ub = mid;
    
  }
  cout << ub << endl;

  
  return 0;
    

}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
using namespace std;
priority_queue<int> A,B,C;
vector<int> AA, BB, CC;
 
int main()
{
    int x, y, a, b, c;
    long long ans = 0;
    cin >> x >> y >> a >> b >> c;
    for (int i = 0; i < a; ++i) {
        int t; cin >> t;
        AA.push_back(t);
    }
    for (int i = 0; i < b; ++i) {
        int t; cin >> t;
        BB.push_back(t);
    }
    for (int i = 0; i < c; ++i) {
        int t; cin >> t;
        CC.push_back(t);
    }
    sort(AA.begin(), AA.end(), greater <int>());
    sort(BB.begin(), BB.end(), greater <int>());

    for (int i = 0; i < x; ++i) {
        CC.push_back(AA[i]);
    }
    for (int i = 0; i < y; ++i) {
        CC.push_back(BB[i]);
    }
    sort(CC.begin(), CC.end(), greater <int>());
    for (int i = 0; i < x + y; ++i) ans += CC[i];
    cout << ans;
    
    return 0;
}

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

using namespace std;

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

    vector<int> cnt_E(N, 0);
    vector<int> cnt_W(N, 0);
    int cnt;
    cnt = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == 'E'){
            cnt++;
            cnt_E[i] = cnt;
        }else{
            cnt_E[i] = cnt;
        }
    }

    cnt = 0;
    for(int i = N-1; i >= 0; i--){
        if(S[i] == 'W'){
            cnt++;
            cnt_W[i] = cnt;
        }else{
            cnt_W[i] = cnt;
        }
    }
    

    int ans = 1;
    for(int i = 0; i < N; i++){
        ans = max(ans, cnt_E[i]+cnt_W[i]);
    }
    ans = N - ans;

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3076
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int q = Integer.parseInt(sc.next());
    List<Rule> rules = new ArrayList<>();
    for (int i = 0; i < q; i++) {
      rules.add(
        new Rule(
          Integer.parseInt(sc.next()),
          Integer.parseInt(sc.next()),
          Integer.parseInt(sc.next()),
          Integer.parseInt(sc.next())
        )
      );
    }
    RuleList ruleList = new RuleList(rules);
    int array[] = new int[n];
    pw.println(dfs(0, 0, m, array, ruleList));
  }

  static long dfs(int index, long max, int m, int[] array, RuleList ruleList) {
    if (index == array.length) {
      if (!meetCondition(array)) {
        return 0;
      }
      return Math.max(max, ruleList.calc(array));
    }
    if (cut(array, index)) {
      return 0;
    }
    for (int i = 1; i <= m; i++) {
      array[index] = i;
      max = Math.max(max, dfs(index + 1, max, m, array, ruleList));
    }
    return max;
  }

  static boolean cut(int[] array, int index) {
    for (int i = 0; i < index - 1; i++) {
      if (array[i] == 0) {
        return false;
      }
      if (array[i] > array[i + 1]) {
        return true;
      }
    }
    return false;
  }

  static boolean meetCondition(int[] array) {
    for (int i = 0; i < array.length - 1; i++) {
      if (array[i] > array[i + 1]) {
        return false;
      }
    }
    return true;
  }

  static class RuleList {

    private List<Rule> rules;

    RuleList(List<Rule> rules) {
      this.rules = rules;
    }

    long calc(int[] array) {
      return rules.stream().mapToInt(rule -> rule.calc(array)).sum();
    }
  }

  static class Rule {

    int a;
    int b;
    int c;
    int d;

    public Rule(int a, int b, int c, int d) {
      this.a = a;
      this.b = b;
      this.c = c;
      this.d = d;
    }

    int calc(int[] array) {
      if (array[b - 1] - array[a - 1] == c) {
        return d;
      }
      return 0;
    }
  }
}


Measured memory_bytes: 60700
import java.util.*;

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

        String S = sc.next();
        int l = S.length();
        int[] x = new int[l];

        loop:for(int i=0; i<l; i++){
            x[i] = S.charAt(i);
            if(i>=1){
                for(int j=0; j<i; j++){
                    if(x[i]==x[j]){
                        System.out.println("no");
                        break loop;
                    }
                }
            }
            if(i==l-1){
                System.out.println("yes");
            }
        }
    }
}

Measured memory_bytes: 23764
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int N,B[10][10],i,j;

int Ix[3][14]={{0,-1,0,1,-2,-1,0,1,2,-1,0,1,0,-9},{0,1,2,0,1,2,0,1,2,-9},{0,-1,0,1,0,-9}};
int Iy[3][14]={{0, 1,1,1, 2, 2,2,2,2, 3,3,3,4,-9},{0,0,0,1,1,1,2,2,2,-9},{0, 1,1,1,2,-9}};

int ch(int x,int y){return (x>=0&&x<10&&y>=0&&y<10&&B[y][x]>0);}
void dbg(){
	int i,j;
	for(i=0;i<10;i++,puts(""))for(j=0;j<10;j++)printf("%d ",B[i][j]);
	puts("----------------------------------------");
}
int dfs(int i,int j,int n)
{
	int k,p;
	if(n>N)return 0;
	if(i==10)return n==N;
	if(B[i][j]==0)return dfs(i+((j+1)/10),(j+1)%10,n);
	//dbg();
	for(k=0;k<3;k++)
	{
		for(p=0;Ix[k][p]!=-9;p++)
			if(!ch(j+Ix[k][p],i+Iy[k][p]))break;
		if(Ix[k][p]!=-9)continue;
		for(p=0;Ix[k][p]!=-9;p++)
			B[i+Iy[k][p]][j+Ix[k][p]]--;
		if(dfs(i,j,n+1))
		{
			printf("%d %d %d\n",j+(k==1?1:0),i+(k==0?2:1),3-k);
			return 1;
		}
		for(p=0;Ix[k][p]!=-9;p++)
			B[i+Iy[k][p]][j+Ix[k][p]]++;
	}
	return 0;
}

int main()
{
	scanf("%d",&N);
	for(i=0;i<10;i++)
		for(j=0;j<10;j++)
			scanf("%d",&B[i][j]);
	return !dfs(0,0,0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 10;
ll fact[maxn];
ll inv[maxn];


ll quickpow(ll a, ll b)
{
    ll ans = 1 % mod;
    while(b)
        {
            if(b & 1)
                ans = ans * a % mod;
            a = a * a % mod;
            b >>= 1;
        }
    return ans;
}

void init(){
    fact[0] = 1;
     for(int i = 1;i <= maxn ;i ++)
       fact[i] = fact[i - 1] * i % mod;
    inv[maxn] = quickpow(fact[maxn], mod - 2);
    for(int i = maxn - 1; i >= 0; i --)
        inv[i] = inv[i + 1] * (i + 1) % mod;
}

ll C(ll x, ll y){
    if(x < y)
        return 0;
    return fact[x] % mod * inv[y] % mod * inv[x - y] % mod;
}


int main()
{
  init();
  ll x, y;
  cin >> x >> y;
  ll m = (2 * y - x) / 3;
  ll n = (2 * x - y) / 3;
  if((x + y) % 3 || m < 0 || n < 0 ) puts("0");
  else{
    printf("%lld\n", C(m + n, m));
  }
  return 0;
}


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

int main(){
  int i;
  char a;
  cin >> a;
  if(a == 'A'){
    cout << "T";
  }else if(a == 'T'){
    cout << "A";
  }else if(a == 'C'){
    cout << "G";
  }else{
    cout << "C";
  }
  //cout << ans;
  return 0;
  
}

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

int main(){
  int r=0, b=0;
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == '0'){
      r++;
    }
    else{
      b++;
    }
  }
  cout <<2 * min(r, b);
}

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

int main(){
  
	int A, B, C, D;
  	cin >> A >> B >> C >> D;
  	
  	while(A > 0){
    	C -= B;
      	if(C <= 0){
        	cout << "Yes" << endl;
          	break;
        }
      	A -= D;
      	if(A <= 0){
        	cout << "No" << endl;
          	break;
        }
    } 

  	return 0;
}

Measured memory_bytes: 3632
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    s = list(input())
    k = ni()

    for i in range(len(s)):
        if s[i] == "a":
            continue
        si = ord(s[i]) - 97
        if k >= 26 - si:
            s[i] = "a"
            k -= 26 - si
            if k == 0:
                break

    s[-1] = chr(97 + (ord(s[-1]) - 97 + k) % 26)

    print(*s, sep="")


if __name__ == '__main__':
    main()


Measured memory_bytes: 17108
n, k = map(int, input().split())
k -= 1
a = sorted([int(input()) for i in range(n)])
ans_min = 10 ** 10
for i in range(n-k):
    result = a[i + k] - a[i]
    ans_min = result if ans_min > result else ans_min
print(ans_min)

Measured memory_bytes: 8280
#include <iostream>

using namespace std;

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

  int x = a;
  int y = c;
  a = b;
  b = x;
  c = a;
  a = y;
  cout << a << " " << b << " " << c << endl;
}

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

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) cin >> H.at(i);

    bool ans = true;
    if(H.front() != 0) H.front()--;
    for(int i = 0; i < N - 1; i++){
        if(H.at(i) < H.at(i + 1)) H.at(i + 1)--;
        if(H.at(i) > H.at(i + 1)) ans = false;
    }

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

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
  ll n;cin >> n;
  map<ll, ll> mp;
  for(int i = 0; i < n; ++i){
    ll a;cin >> a;
    ++mp[a];
  }
  ll ans = 0;
  for(auto it : mp){
    ll tmp = 0;
    if(it.second>=it.first)tmp=it.second-it.first;
    else tmp = it.second;
    ans += tmp;
  }
  cout << ans << endl;
}



Measured memory_bytes: 6272
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const ll mod = 1000000007;
ll dp[maxn];
bool d[maxn];
int n, m, a;
int main()
{
    cin >> n >> m;
    memset(dp,0,sizeof(dp));
    for(int i = 0; i < m; ++i)
        {
            cin >> a;
            d[a] = true;
        }
    bool flag = false;
    if(d[1])
        dp[1] = 0;
    else dp[1] = 1;
    if(d[2])
        dp[2] = 0;
    else if(d[1])
        dp[2] = 1;
    else dp[2] = 2;
    for(int i = 3; i <= n; ++i)
    {
        if(d[i-1] && d[i-2])
        {
            flag = true;
            break;
        }
        if(!d[i-1] && !d[i-2])
        dp[i] = dp[i-1] + dp[i -2];
        else if(!d[i-1])
            dp[i] = dp[i-1];
        else dp[i] = dp[i-2];
        dp[i] %= mod;
    }
    if(!flag)
    cout << dp[n] << endl;
    else cout << "0\n";
    return 0;
}


Measured memory_bytes: 1152
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let v:Vec<i32> = procon_read();
	let b = v[0];
	let v:Vec<i32> = procon_read();
	let c = v[0];
	let v:Vec<i32> = procon_read();
	let x = v[0];
	let mut cnt = 0;
	for i in 0..(a+1) {
		for j in 0..(b+1) {
			if x - (500*i + 100*j) < 0 {
				break;
			}
			if x - (500*i + 100*j) > 50*c {
				continue;
			}
			cnt +=1 ;
		}
	}
	println!("{}", cnt);
}

Measured memory_bytes: 4352