akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;


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

    string S;
    cin >> S;

    ll tmpCount=0;
    ll AnsCount = 0;
    for(ll i = S.length()-1;i >= 0;--i){
        if(S[i] == 'B'){
            AnsCount += ((S.length()-1)-i)-tmpCount;
            tmpCount++;
        }
    }

    cout << AnsCount << endl;
    

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int a = N;
  while (a > 0) {
    sum += a % 10;
    a /= 10;
  }
  if (N % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3600
/*

*/
#include<bits/stdc++.h>

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

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
  ans%=mod;
  cout<<(ans+mod)%mod<<endl;
}

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

bool d[10];
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> D(K);
  for(int i = 0; i < K; i++){
    cin >> D[i];
    d[ D[i] ] = true;
  }
  for(int i = N; ; i++){
    vector<int> digits;
    int t = i;
    bool f = true;
    while( t != 0 ){
      if( d[ t % 10 ] ){
	f = false;
	break;
      }
      t /= 10;
    }
    if( f ){
      cout << i << endl;;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 7 * 100 * 1000 + 47;
const double EPS = 1e-8;
const int MOD = 1000 * 1000 * 1000 + 7;


VI G[MAX];
int Q[MAX];
int U[MAX];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    FOR(i, 0, m)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        --a, --b;
        G[a].PB(b);
        G[b].PB(a);
    }
    int ql = MAX / 2, qr = MAX / 2;
    Q[qr++] = 0;
    U[0] = 1;
    while(true)
    {
        int l = Q[ql];
        int r = Q[qr-1];
        bool fnd = 0;
        FOR(j, 0, SZ(G[l]))
        {
            int to  = G[l][j];
            if (U[to])continue;

            Q[--ql] = to;
            U[to] = 1;
            fnd = 1;
            break;
        }
        if (fnd)continue;
        FOR(j, 0, SZ(G[r]))
        {
            int to = G[r][j];
            if (U[to])continue;
            Q[qr++] = to;
            U[to] = 1;
            fnd = 1;
            break;
        }
        if (!fnd)break;

    }
    printf("%d\n", qr - ql);
    FOR(i, ql, qr)
        printf("%d ", Q[i]+1);
}

Measured memory_bytes: 24192
mod = 10**9+7

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

chk = []
if N % 2 == 1:
    chk.append(0)
    for i in range(N // 2):
        chk.append((i+1)*2)
        chk.append((i+1)*2)
else:
    for i in range(N // 2):
        chk.append(i*2+1)
        chk.append(i*2+1)
#print(chk)

A.sort()

if A != chk:
    print(0)
else:
    print(pow(2, N // 2,mod))

Measured memory_bytes: 56300
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
template<typename T>
class Union_Find {
  private:
	vector<T> t, s;

  public:
	explicit Union_Find(T max_length) {
		for (int i = 0; i < max_length + 1; ++i) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(T x, T y) {
		if (same(x, y)) return;
		T tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}
	T Find(T n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(T x, T y) {
		return Find(x) == Find(y);
	}

	T get_Size(size_t a) {
		return s[a];
	}
};
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int n,m,k;
    cin>>n>>m>>k;
    vector<P> f(m),b(k);
    Union_Find<int> tree(n);
    vector<int> ans(n+1,0);
    rep(i,m){
        cin>>f[i];
        tree.Union(f[i].first,f[i].second);
        ans[f[i].first]--;
        ans[f[i].second]--;
    }
    rep(i,k){
        cin>>b[i];
        if(tree.same(b[i].first,b[i].second)){
            ans[b[i].first]--;
            ans[b[i].second]--;
        }
    }
    rep(i,1,n+1){
        cout<<ans[i]+tree.get_Size(tree.Find(i))-1;
        if(n==i)cout<<endl;
        else cout<<' ';
    }
}


Measured memory_bytes: 6508
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if(A>=10||B>=10){
      System.out.println("-1");
    }else{
      System.out.println(A*B);
    }
  }
}


Measured memory_bytes: 23380
from collections import defaultdict


# 素因数分解
d = defaultdict(int)


def prime_factorize(n):
    while n % 2 == 0:
        d[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            d[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] += 1
    return


N = int(input())
MOD = int(1e9) + 7
ans = 1
for i in range(1, N+1):
    prime_factorize(i)
for v in d.values():
    ans = ans * (v + 1) % MOD
print(ans)

Measured memory_bytes: 9332
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int main() {
  int N,M;
  double sum = 0;
  cin >> N >> M;
  double a[N];
  rep(i,N){
    cin >> a[i];
    sum+=a[i];
  }
  bool f = true;
  sort(a,a+N,greater<int>());
  if(a[M-1] < sum/(4*M)) f = false;
  cans(f);
  
  
  return 0;
}



Measured memory_bytes: 256
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { [ss] <- getInts
  ; let (mm,s) = divMod ss 60
  ; let (h,m) = divMod mm 60
  ; putStrLn (intercalate ":" (map show [h, m, s]))
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

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

int main() {
  string S;
  cin >> S;
  int64_t b = 0, cnt = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'W') {
      cnt += b;
    }
    if (S.at(i) == 'B') {
      b++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>

using namespace std;

long long a[100001],b[100010],c,d=0,e=0;

int main() {
	int n;
	cin >> n;
	for (int i = 0;i < n+1;i++) {
		cin >> a[i];
	}
	for (int i = 0;i < n;i++) {
		cin >> b[i];
	}
	for (int i = 0;i <= n;i++) {
		if (a[i] < b[i]) {
			d += a[i];
			b[i] -= a[i];
		}
		else {
			e += b[i];
			b[i] = 0;
		}
		if (a[i + 1] < b[i]) {
			d += a[i+1];
			a[i+1] = 0;
		}
		else {
			e += b[i];
			a[i + 1] -= b[i];
		}
	}
	cout << d+e << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] arr = br.readLine().split(" ");
        int N = Integer.parseInt(arr[0]);
        int M = Integer.parseInt(arr[1]);

        List<List<String>> list = new ArrayList<>();
        List<String> pList = new ArrayList<>();

        for (int i = 0; i < M; i++) {
            String[] arr2 = br.readLine().split(" ");
            int length = Integer.parseInt(arr2[0]);
            list.add(Arrays.asList(Arrays.copyOfRange(arr2, 1, length + 1)));
        }

        pList = Arrays.asList(br.readLine().split(" "));
        int pow = (int)Math.pow(2, N);
        List<List<Integer>> list2 = new ArrayList<>();
        for (int i = 0; i < pow; i++) {
            String val = Integer.toBinaryString(i);
            String bin = String.format("%0"+ N + "d", Integer.valueOf(val));
            List<Integer> l = Arrays.stream(bin.split(""))
                .map(Integer::parseInt)
                .collect(Collectors.toList());
            list2.add(l);
        }

        int ans = 0;

        for (int i = 0; i < list2.size(); i++) {
            List<Integer> l = list2.get(i);
            Set<String> onSet = new HashSet<>();
            Set<String> offSet = new HashSet<>();
            for (int j = 0; j < l.size(); j++) {
                if (l.get(j) == 0) {
                    offSet.add(String.valueOf(j + 1));
                } else {
                    onSet.add(String.valueOf(j + 1));
                }
            }

            for (int j = 0; j < list.size(); j++) {
                List<String> sl = list.get(j);
                int onCount = 0;
                for (String s: sl) {
                    if (onSet.contains(s)) {
                        onCount++;
                    }
                }
                if (onCount % 2 != Integer.parseInt(pList.get(j))) {
                    break;
                }
                if (j == list.size() - 1) {
                    ans++;
                }
            }
        }

        out.println(ans);
        out.close();
    }
}


Measured memory_bytes: 32160
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

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

int main(){
    int K;
    cin >> K;
    long long ans=0;
    for(int i=1;i<=K;++i){
        for(int j=1;j<=K;++j){
            for(int k=1;k<=K;++k){
                long long tmp=gcd(i,j);
                tmp=gcd(tmp,k);
                ans+=tmp;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
    using Vl = vector<ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;

//最大公約数
ll gcd(ll a, ll b){
    if(a % b == 0)return b;
    else return gcd(b, a % b);
}

int main(){
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i, n){
        ll b;
        cin >> b;
        a[i] = abs(b - x);
    }
    ll res = a[0];
    rep(i, n)res = gcd(res, a[i]);
    cout << res << endl;
}



Measured memory_bytes: 4056
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
 *
 * @author acesine
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int c = in.nextInt() + in.nextInt();
            if (c >= 10) out.println("error");
            else out.println(c);
        }

    }
}



Measured memory_bytes: 21844
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int h,w; cin>>h>>w;
	char **array = new char*[h];
	for (int i = 0; i < h; i++) {
		array[i] = new char[w];
		for (int j = 0; j < w; j++) {
			cin >> array[i][j];
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << array[i][j];
		}
		cout << endl;
		for (int j = 0; j < w; j++) {
			cout << array[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string str;
	cin >> str;
	if (str == "mew"){cout << "Cat" << endl; return 0;
}
	while (true) {
		bool f;
		string temp = str.substr(1, str.length() - 2);
		auto it = temp.find("mew");
		if (it == string::npos) {
			cout << "Rabbit" << endl;
			return 0;
		}
		temp.erase(it, 3);
		str = str[0] + temp + str[str.length() - 1];
		if (str.length() <= 3) {
			if (str == "mew") {
				cout << "Cat" << endl;
			}
			else cout << "Rabbit" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define endl '\n'

using namespace std;
struct custom_hash 
{
    static unsigned long long splitmix64(unsigned long long x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(unsigned long long x) const 
    {
        static const unsigned long long FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
mt19937 random_generator(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 998244353; 
const int maxn = 2e5 + 3; 

int fast_pow(int x, int deg)
{
	int ans = 1, y = x;
	while (deg)
	{
		if (deg & 1)
		ans = 1ll * ans * y % mod;
		
		deg >>= 1;
		y = 1ll * y * y % mod; 
	}
	
	return ans; 
}

int fact[maxn], inv_fact[maxn];
void precompute()
{
	fact[0] = 1;
	for (int i = 1; i < maxn; i++)
	fact[i] = 1ll * fact[i-1] * i % mod;
	
	inv_fact[maxn-1] = fast_pow(fact[maxn-1], mod-2);
	for (int i = maxn-2; i >= 0; i--)
	inv_fact[i] = 1ll * inv_fact[i+1] * (i+1) % mod; 
}

int comb(int a, int b)
{
	return 1ll * fact[a] * inv_fact[b] % mod * inv_fact[a-b] % mod; 
}

int add(int a, int b)
{
	a += b;
	if (a >= mod)
	a -= mod;
	
	return a; 
}

int n, m, k; 
void read()
{
	cin >> n >> m >> k; 
}

void solve()
{
	precompute();
	int ans = 0;
	
	for (int i = n-k; i <= n; i++)
	{
		int curr = comb(n-1, i-1);
		int poss = 1ll * m * fast_pow(m-1, i-1) % mod;
		
		ans = add(ans, 1ll * curr * poss % mod);
	}
	
	cout << ans << endl; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	read();
	solve();
}


Measured memory_bytes: 5240
#include <iostream>

using namespace std;

int main(){

  int n, maxVal = 2e5, val, ans = 0;
  cin >> n;
  for(int i = 1;i <= n;i++){
    cin >> val;
    maxVal = min(val, maxVal);
    if(maxVal == val){
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

using namespace std;

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	string s;
	cin >> s;
	int r = 0, w = 0;
	for(char c: s)
		if(c == 'R')
			r++;
		else
			w++;
	int ans = min(r, w), cnt = 0, l = 0;
	r = n-1;
	while(l < r)
	{
		while(l < n && s[l] == 'R')
			l++;
		while(r > 0 && s[r] == 'W')
			r--;
		if(l >= r)
			break;
		s[r] = 'W';
		s[l] = 'R';
		l++;
		r--;
		cnt++;
	}
	ans = min(ans, cnt);
	cout<<ans<<endl;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    int max_num = -10000;
    max_num = max(max_num, A + B);
    max_num = max(max_num, A - B);
    max_num = max(max_num, A * B);
    cout << max_num << endl;
}

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

const int mxN=1e5+1;
vector<string>op(mxN);
vector<int>a(51),b(51),c(51),d(51);
int n,m,q;
int ans;

void get(vector<int>v){
    if(v.size()==n)
    {
//        for(int i=0;i<v.size();i++)
//            cout<<v[i]<<" ";
//        cout<<endl;
//        cout<<n<<endl;
        int res=0;
        for(int i=0;i<q;i++)
        {
            if((v[b[i]]-v[a[i]])==c[i])
                res+=d[i];
        }
        ans=max(ans,res);
        return;
    }
    int start=1;
    if(v.size()>0)
        start=v.back();
    for(int i=start;i<=m;i++){
        v.push_back(i);
        get(v);
        v.pop_back();
    }
}

signed main(){
    cin>>n>>m>>q;
    for(int i=0;i<q;i++)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]-=1,b[i]-=1;
    }
    vector<int>v;
    get(v);
    cout<<ans<<endl;
}

Measured memory_bytes: 6204
import copy
import sys
import numpy as np

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    if int(N/10) == 9 or int(N % 10) == 9:
        print "Yes"
    else:
        print "No"

if __name__ == '__main__':
    main()

Measured memory_bytes: 13832
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int a[5];
    int ind[5];
    for(int i=0; i<5; i++){
        cin>>a[i]; ind[i]=i;
    }
    int ans=10000;
    while(1){
        int x=0;
        for(int i=0; i<5; i++){
            int p=ind[i];
            x=(x+9)/10*10;
            x+=a[p];
        }
        ans=min(ans, x);
        if(!next_permutation(ind, ind+5)) break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;
typedef unsigned long long ULong;

int l;
int n = 20;
int cnt_nodes = 0;

struct Edge {
  int from, to, w;
  Edge(int from, int to, int l) :
    from(from), to(to), w(l) {
  }
};

vector<Edge> edges;

void addEdge(int u, int v, int w) {
  edges.emplace_back(u, v, w);
}

int getNewNode() {
  return ++cnt_nodes;
}

int get(int l) {
  if (l == 1) {
    cnt_nodes = 1;
    return 1;
  }
  int prev_tail = get(l / 2);
  int curr_tail = getNewNode();
  addEdge(prev_tail, curr_tail, 0);
  addEdge(prev_tail, curr_tail, l / 2);

  if (l & 1) {
    addEdge(1, curr_tail, l - 1);
  }
  return curr_tail;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  cin >> l;

  cout << get(l) << " ";

  cout << edges.size() << endl;
  for (auto& edge : edges) {
    cout << edge.from << " " << edge.to << " " << edge.w << endl;
  }

}


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

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{for(int i=0;i<v.size();i++){if(i>0)o<<" ";o<<v[i];}return o;}

int main(void)
{
    int n;

    cin >> n;
    vector<int> a(n);

    while (n--)
        cin >> a[n];

    cout << a << endl;

    return 0;
}



Measured memory_bytes: 3100
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	long long a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	if(c-a-b>0&&4*a*b<powl((c-a-b),2))
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

string str;

int main() {
#ifdef HOME
	freopen("atc.in", "r", stdin);
	freopen("atc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> str;
	for (int i = 0; i < string("FESTIVAL").size(); ++i)
		str.pop_back();

	cout << str << endl;

	return 0; }


Measured memory_bytes: 256
#!/usr/bin/env python3
import numpy as np


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a = np.array(a) 
    a.sort()

    zero = np.count_nonzero(a == 0)
    positive = a[a > 0] 
    negative = a[a < 0]

    def count(x): # 積が x 以下のペアは何個あるか？
        ans = 0
        if x >= 0:
            ans += n * zero
        ans += np.searchsorted(a, x // positive, side="right").sum() 
        ans += n * len(negative) - np.searchsorted(a, -(-x // negative), side="left").sum() 
        ans -= np.count_nonzero(a * a <= x) # 同じもの2つは選べない
        return ans // 2

    ok = 10**18
    ng = -ok - 1
    while ok - ng > 1: # 二分探索
        cen = (ok + ng) // 2
        if count(cen) >= k:
            ok = cen
        else:
            ng = cen
    print(ok)

if __name__ == '__main__':
    main()


Measured memory_bytes: 32304
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

f [xa,ya,xb,yb,xc,yc,xd,yd] = if abs (dx1 * dx2 + dy1 * dy2) < 1e-10 then "YES" else "NO"
  where
    dx1 = xb - xa
    dy1 = yb - ya
    dx2 = xd - xc
    dy2 = yd - yc

main = map (f . map readDouble . words) . lines <$> getContents >>= mapM_ putStrLn

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

using namespace std;

int main() {
    string s;
    long k;
    cin >> s >> k;

    int n = s.size();

    for (int i=0; i<n; i++) {
        if (i+1 == k) {
            cout << s[i] << endl;
            return 0;
        }
        if (s[i] != '1') {
            cout << s[i] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3612
N,M = map(int,input().split())
a = set([int(input()) for _ in range(M)])
k = 10**9+7
dp = [0]*(N+1)
dp[0] = 1
if N == 1:
  print(1)
else:
  for i in range(1,N+1):
    if i in a:
      continue
    elif i==1:
      dp[1] = 1
    elif i==2:
      dp[i] = 1+dp[1]
    else:
      dp[i] = dp[i-1]+dp[i-2]
  print(dp[N]%k)

Measured memory_bytes: 470520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  cin >> K;
  if(K%2==0) {
    cout << (K/2)*(K/2) << endl;
  }
  else {
    cout << (K/2)*(K/2+1) << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#define N 100005
using namespace std;
typedef long long ll;
ll n,m,v,p,a[N],ans,sum[N];
int main() 
{
    scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
    for(ll i=1;i<=n;i++){
    	scanf("%lld",&a[i]);
	}ans=p;sort(a+1,a+1+n);
	for(ll i=1;i<=n;i++){
		sum[i]=sum[i-1]+a[i];
	}
	for(ll i=1;i<=n-p;i++){
		ll tmp=m*v-m*p;
		if(a[i]+m<a[n-p+1])continue;
		if(tmp<=(i-1)*m+(n-p-i+1)*(a[i]+m)-(sum[n-p+1]-sum[i]))ans++;
	}printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 4796
n = int(input())
ab = []
now = 0
for i in range(n):
    _a, _b = map(int, input().split())
    ab.append([_a, _b])

ab.sort(key=lambda x: x[1])
for a, b in ab:
    now += a
    if now>b:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 40544
// A : minimum spanning tree
#include <stdio.h>
#include <stdlib.h>
#define N 10000
#define INF 1000000
#define WHITE 0
#define BLACK 1

int n;  // the number of vertices in G
int m[N][N] = {0};
int set[N];
int color[N];

int genericMST();

int main() {
  int i, j, k = 1, l;
  int u;
  int min;
  int sum = 0;
  int cnt = 1;

  // input
  scanf("%d", &n);  // the number of vertices in G
  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
      scanf("%d", &m[i][j]); // adjacency matrix M
    }
  }

  // initialization
  for(i = 0; i < n; i++) {
    set[i] = 0;
    color[i] = WHITE;
  }

  // MST
  color[0] = BLACK;
  while(cnt != n) {
    min = INF;
    for(i = 0; i < k; i++) {
      for(j = 0; j < n; j++) {
      	if((m[set[i]][j] < min) && (m[set[i]][j] != -1) && (color[j] != BLACK)) {
      	  min = m[set[i]][j];
          u = j;
      	}
      }
    }
    color[u] = BLACK;
    set[k] = u;
    k++;
    if(min != INF) sum += min;
    cnt++;
  }

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

  return 0;
}



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


int main()
{
	std::vector<int> v;
	
	int q; std::cin >> q;
	for (int i=0; i<q; i++) {
		int op;
		std::cin >> op;
		switch (op) {
		case 0:
			int key;
			std::cin >> key;
			v.push_back(key);
			break;
		case 1:
			int index;
			std::cin >> index;
			std::cout << v[index] << std::endl;
			break;
		case 2:
			v.pop_back();
			break;
		}
	}
	
	return 0;
}
		



Measured memory_bytes: 3788
import itertools
s = input()
plm = ['+','-']

for i in itertools.product(plm, repeat=3):
    moziretsu =s[0]+i[0]+s[1]+i[1]+s[2]+i[2]+s[3]
    if eval(moziretsu) == 7:
        print(moziretsu+'=7')
        break

Measured memory_bytes: 62140
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int n, d;
	cin >> n >> d;
	int x[n][d];
	int cnt = 0;
	double dist;
	rep(i, n) rep(j, d) cin >> x[i][j];
	for(int i=0; i<n-1; i++) {
		for(int j=i+1; j<n; j++) {
			dist = 0;
			rep(k, d) dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			if (sqrt(dist) == (int)sqrt(dist)) cnt++;
		}
	}
	cout << cnt << endl;


	return 0;
}



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

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

using ll = long long;
using namespace std;

int
main ()
{
    int h, n;
    cin >> h >> n;
    // GOAL: a の合計を h 以上にする b の合計の最小

    // SUBGOAL: i 番目までを使って a の合計を j 以上にする b の合計の最小
    //
    // i-1 番目までの結果を用いて、i 番目を k 回使ったときのコストを計算
    // dp[i][j] = min { dp[i-1][j - k*a[i]] + k*b[i] | k = 0.. }
    //
    // ↑ の計算量が悪いのでいいかんじに最適化して
    vector<int> dp(h+1, 100'000'001);
    dp[0] = 0;
    rep(n, i) {
      int a, b;
      cin >> a >> b;
      rep(h, j) {
        int next_j = min(j + a, h);  // 配列外アクセスよけ
        dp[next_j] = min(dp[next_j], dp[j] + b);
      }
    }
    cout << dp[h] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()

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

const long long INF = 1LL << 60;

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

  long long y = 100;
  int i = 0;
  while(y < x){
    y = (long long)(y * 1.01);
    i++;
  }

  cout << i << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a>b) printf("-1");
	else{
		for(int i=1;i<1010;++i){
			if(i*0.08>=a&&i*0.08<a+1&&i*0.1>=b&&i*0.1<b+1){
				printf("%d",i);
				return 0;
			}
		}
		printf("-1");
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
    int n;
    ll H[100000];
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> H[i];
    }
    
    H[0]--;
    for(int i=1; i<n; i++){
        if(H[i]>H[i-1]){
            H[i]--;
        }else if(H[i]==H[i-1]){
            
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int cnt = 0;
  rep(r,N/R+1)rep(g,N/G+1)
  {
    int n = N - r * R - g* G;
    if(n % B == 0 && n >= 0 )
    {
      cnt ++;
    }
  }
  cout << cnt << endl;
  
  
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
const LL mx=1E18;
int main()
{
    LL n;
    cin>>n;
    vector<LL>v(n);
    int f=0;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        if(v[i]==0)f=1;
    }
    if(f)
    {
        cout<<0;
        return 0;
    }
    LL x=1;
    for(int i=0;i<n;i++)
    {
        if(v[i]<=mx/x)
        {
            x=x*v[i];
        }
        else
        {
            f=1;
            break;
        }
    }
    if(f)
        cout<<-1;
    else
        cout<<x;

}


Measured memory_bytes: 4048
#include <stdio.h>

#define MAX 100
int odd(const char *a)
{
  int i=0;

  while(a[i]!='\0'){
    if(a[i]=='L')return 0;
    i+=2;
  }
  return 1;
}

int even(const char *a)
{
  int i=1;

  while(a[i]!='\0'){
    if(a[i]=='R')return 0;
    i+=2;
  }
  return 1;
}

int main(void)
{
  char S[MAX+1];

  scanf("%s",S);

  if(odd(S)&&even(S))printf("Yes\n");
  else printf("No\n");
  return 0;
}



Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func gcd(a, b int) int {
	for b != 0 {
		c := a % b
		a, b = b, c
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := ri(), ri()
	a := make([]int, n)
	max := 0
	for i := 0; i < n; i++ {
		a[i] = ri()
		if a[i] > max {
			max = a[i]
		}
	}
	if k > max {
		fmt.Println("IMPOSSIBLE")
		return
	}
	g := a[0]
	for i := 1; i < n; i++ {
		g = gcd(g, a[i])
	}
	if k%g == 0 {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<bool> AC(N);
  vector<int> WA(N);
  for(int i = 0; i < M; i++){
    int p;
    string S;
    cin >> p >> S;
    if(AC[p-1]) continue;
    if(S == "AC"){
      AC[p-1] = true;
      continue;
    }else{
      WA[p-1] += 1;
    }
  }
  int ac = 0;
  int pn = 0;
  for(int i = 0; i < N; i++){
    if(!AC[i]) continue;
    ac += 1;
    pn += WA[i];
  }
  cout << ac << " " << pn << endl;

}


Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  long double r;
  cin >> r;
  r *= 2;
  long double ans = r*M_PI;
  printf("%.10Lf\n",ans);
}


Measured memory_bytes: 3784
count=0
def merge(A, left, mid, right):
    global count
    h=[]
    L=A[left:mid]+[2**32]
    R=A[mid:right]+[2**32]
    i=0
    j=0
    for k in range(left,right):
        if L[i] <= R[j]:
            A[k] = L[i]
            h.append(L[i])
            i += 1
        else:
            A[k] = R[j]
            h.append(R[j])
            j += 1
            if i < len(L)-1:
                count += len(L) - 1 - i
        
def merge_sort(A, left, right):
    if left+1 < right:
        mid=(left+right)//2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)

if __name__ == "__main__":
    n=int(input())
    A=list(map(int,input().split()))
    merge_sort(A,0,n)
    print(count)


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int N;
  cin >> N;
  if((N%1000)){
    cout << 1000-(N%1000) << endl;
  }
  else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 3676
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int d;
	scanf("%d", &d);
	int c[30];
	int i;
	for (i = 0; i < 26; i++)
		scanf("%d", &c[i]);
	int j;
	int s[400][30];
	for (i = 0; i < d; i++)
		for (j = 0; j < 26; j++)
			scanf("%d", &s[i][j]);
	int l[400][30];
	for (i = 0; i < 26; i++)
		l[0][i] = 0;
	int t[400];
	for (i = 0; i < d; i++)
		t[i] = (26 * 400 - i) % 26;
	int dd, q;
	int a;
	for (i = 1; i <= d; i++)
	{
		for (j = 0; j < 26; j++)
			l[i][j] = l[i - 1][j];
		l[i][t[i - 1]] = i;
	}
	int ans = 0;
	for (i = 0; i < d; i++)
	{
		ans += s[i][t[i]];
		for (j = 0; j < 26; j++)
			ans -= c[j] * (i + 1 - l[i + 1][j]);
	}
	int ans2;
	int k;
	for (k = 0; k < 5; k++)
	{
		dd = rand() % d;
		q = rand() % 26;
		ans2 = ans;
		a = t[dd];
		ans -= s[dd][a];
		ans += s[dd][q];
		t[dd] = q;
		for (i = 0; i < d; i++)
		{
			ans += c[a] * (i + 1 - l[i + 1][a]);
			ans += c[q] * (i + 1 - l[i + 1][q]);
			l[i + 1][a] = l[i][a];
			l[i + 1][q] = l[i][q];
			l[i + 1][t[i]] = i + 1;
			ans -= c[a] * (i + 1 - l[i + 1][a]);
			ans -= c[q] * (i + 1 - l[i + 1][q]);
		}
		if (ans2 > ans)
		{
			t[dd] = a;
			ans = ans2;
			for (i = 1; i <= d; i++)
			{
				for (j = 0; j < 26; j++)
					l[i][j] = l[i - 1][j];
				l[i][t[i - 1]] = i;
			}
		}
	}
	for (i = 0; i < d; i++)
		printf("%d\n", t[i] + 1);
	return 0;
}

Measured memory_bytes: 1796
#include<stdio.h>

int search(int A[], int n, int key) {
	int i = 0;
	A[n] = key;
	while ( A[i] != key ) i++;
	return i != n;
}

int main() {
	int i, n, A[10000+1], q, key, sum = 0;
	
	scanf("%d", &n);
	for ( i = 0; i < n; i++) scanf("%d", &A[i]);
	
	scanf("%d", &q);
	for ( i = 0; i < q; i++ ) {
		scanf("%d",&key);
		if ( search(A, n, key) ) sum++;
	}
	printf("%d\n", sum);
	
	return 0;
}


Measured memory_bytes: 2056
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main() {
  int i;
  char s[100010];
  scanf("%s", s);
  int ans = 0;
  int N = strlen(s);
  if (N % 2 == 1) {
    ans -= 1;
    for (i = 0; i < strlen(s); i++) {
      if (s[i] == 'g') {
	ans += 1;
      } else {
	ans -= 1;
      }
    }
  } else {
    for (i = 0; i < strlen(s); i++) {
      if (s[i] == 'g') {
	ans += 1;
      } else {
	ans -= 1;
      }
    }
  }
  ans = ans/2;
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int p[509][509];
int main() {
    int n,m,q;
    cin>>n>>m>>q;
    
    for(int i=1;i<=m;i++){
        int l,r;
        cin>>l>>r;
        p[l][r]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            p[i][j]+=p[i][j-1];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            p[i][j]+=p[i-1][j];
        }
    }

    rep(i,q){
        int l,r;
        cin>>l>>r;
        cout<<p[r][r]+p[l-1][l-1]-p[l-1][r]-p[r][l-1]<<endl;
    }
}



Measured memory_bytes: 1920
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define B back()
#define FR front()
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)
#define iceil(a) ((int)ceil(a))
#define ifloor(a) ((int)floor(a))

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << "\n";

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int num1[30];
int num2[30];
constexpr int INF=1e9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	string s, t;
	cin>>s>>t;
	int n=s.size(), m=t.size();
	vi a[30];
	REP(i, n){
		++num1[s[i]-'a'];
		a[s[i]-'a'].push_back(i+1);
	}
	REP(i, m){
		++num2[t[i]-'a'];
	}
	REP(i, 30){
		if(num1[i]==0 && num2[i]>0){
			cout<<-1<<'\n';
			return 0;
		}
	}
	REP(i, 30){
		a[i].push_back(INF);
	}
	ll ans=0;
	int crt=0;
	REP(i, m){
		int tmp1=*upper_bound(ALL(a[t[i]-'a']), crt);
		int tmp2=*upper_bound(ALL(a[t[i]-'a']), 0);
		// DEBUG(tmp1);
		// DEBUG(tmp2);
		if(tmp1==INF){
			ans+=n-crt+tmp2;
			crt=tmp2;
		}
		else{
			ans+=tmp1-crt;
			crt=tmp1;
		}
		// DEBUG(ans);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <vector>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <ctime>

using namespace std;


int main()
{
    //freopen("../input.txt", "r", stdin);
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for (auto& el : a) {
        cin >> el;
    }

    sort(a.begin(), a.end());
    int maxDist = 0;
    for (int i = 0; i < n - 1; ++i) {
        maxDist = max(maxDist, a[i + 1] - a[i]);
    }

    maxDist = max(maxDist, k - a.back() + a[0]);

    cout << k - maxDist;


    return 0;
}



Measured memory_bytes: 1024