akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


vector<int> calc(vector<int> a,vector<int> b){
  int n = a.size();
  vector<int> c(n);
  for(int i=0;i<n;i++) c[i] = b[a[i]];
  return c;
}

vector<int> doubling(vector<int> idx,int K){
  int n = idx.size();
  vector<int> res(n);
  for(int i=0;i<n;i++) res[i] = i;
  while(K){
    if(K%2) res = calc(res, idx);
    idx = calc(idx, idx);
    K/=2;
  }
  return res;
}

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin>>n;
  vector<int> X(n);
  cin>>X;
  
  int m, K;
  cin>>m>>K;
  vector<int> A(m);
  cin>>A;

  vector<int> sa(n-1);
  for(int i=0;i<n-1;i++) sa[i] = X[i+1] - X[i];

  vector<int> idx(n-1);
  for(int i=0;i<n-1;i++) idx[i] = i;
  for(int i=0;i<m;i++){
    int a = A[i] - 1;
    swap(idx[a], idx[a-1]);
  }

  idx = doubling(idx,K);
  vector<int> ans(n);
  ans[0] = X[0];
  ans[n-1] = X[n-1];

  for(int i=1;i<n;i++) ans[i] = ans[i-1] + sa[idx[i-1]];
  for(double a:ans) cout<<a<<endl;
  return 0;
}


Measured memory_bytes: 7360
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>

long long n, m, d;

int main() {
    // E(tot) = (m - 1)E(single)
    double ret = 0;
    scanf("%lld%lld%lld", &n, &m, &d);
    ret = m - 1;
    ret *= d == 0 ? (1.0 / n) : (2.0 * (n - d) / n / n);
    printf("%.12lf\n", ret);
    return 0;
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    i32 N;
    cin >> N;
    f64 sum = 0.0;
    for (i32 i = 1; i <= N; i++) if (i % 2) sum += 1.0;
    cout << sum / N << endl;
}


Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int n;
int a[110000];
int cntk(int k){
  int left=-1,right=n;
  while(right-left>1){
    int mid = (right+left)/2;
    if(a[mid]>=k) right = mid;
    else left = mid;
  }
  int left2=-1,right2=n;
  while(right2-left2>1){
    int mid = (right2+left2)/2;
    if(a[mid]>k) right2 = mid;
    else left2 = mid;
  }
  return right2-right;
}
int main()
{
  cin >> n;
  rep(i,n) cin >> a[i];

  int m;
  cin >> m;
  int res = 0;
  rep(i,m){
    int q;
    cin >> q;
    if(cntk(q)>0) res++;
  }
  cout << res << "\n";
  
  return 0;
}



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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10E9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)


typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}
                                                                                    
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;  

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif
  
  int n; cin >> n;
  string s; cin >> s;
  int k; cin >> k;
  forn(i , 0 , n) if(s[i] != s[k - 1]) s[i] = '*';
  cout << s << endl;
  
                                                   
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

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

int main(int argc, char *argv[]){

  int i, j;
  int N, L;

  scanf("%d %d", &N, &L);

  char s[N][101];
  char l[101];

  for(i=0; i<=N-1; i++){
    scanf("%s", s[i]);
  }


  for(i=0; i<=N-1; i++){
    for(j=i+1; j<=N-1; j++){
      if(strcmp(s[i], s[j]) > 0){
        strcpy(l, s[i]);
        strcpy(s[i], s[j]);
        strcpy(s[j], l);
      }
    }
  }

  for(i=0; i<=N-1; i++){
    printf("%s", s[i]);
  }
  printf("\n");

  return 0;

}


Measured memory_bytes: 128
n = int(input())
P = list(map(int, input().split()))
X = list(map(int, input().split()))

dp = [0] * n
child = [[] for i in range(n)]
for i in range(n-1):
    child[P[i] - 1].append(i + 1)

for i in range(n-1, -1, -1):
    if not child[i]:
        dp[i] = 0
    else:
        child_sum_min = 0
        child_sum_rest = 0
        change_candidate = set([0]) #色を変更した場合に生じる差分を管理する
        for c in child[i]:
            z = min(X[c], dp[c])
            child_sum_min += z
        if child_sum_min > X[i]:
            print('IMPOSSIBLE')
            exit()
        change_space = X[i] - child_sum_min
        for c in child[i]:
            z = min(X[c], dp[c])
            rest = max(X[c], dp[c]) - z
            child_sum_rest += rest
            tmp = set(change_candidate)
            for num in change_candidate:
                if num + rest <= change_space:
                    tmp.add(num + rest)
            change_candidate = tmp
        dp[i] = child_sum_min + child_sum_rest - max(change_candidate)

print('POSSIBLE')

Measured memory_bytes: 74036
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

N, a_list = gets_n_and_i_list

index = []
(N-1).step(0, -2){|i| index.push(i)}
if index.last == 0
  1.step(N-1, 2){|i| index.push(i)}
else
  0.step(N-1, 2){|i| index.push(i)}
end

index.each do |e|
  print a_list[e].to_s + " "
end
print "\n"


Measured memory_bytes: 25864
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  if(A>=13){
    cout << B << endl;
  }else if(A<=5){
    cout << 0 << endl;
  }else{
    cout << B/2 << endl;
  }
}

Measured memory_bytes: 3624
#include<iostream>
#include<queue>
using namespace std;
struct Edge { int next; int cost; };
enum colors { WHITE, GRAY, BLACK ,INVALID };

int dist[100000];
Edge g[100000][2];
colors color[100000];

int main() {
	int k;
	cin >> k;
	for (int i = 0; i < k - 1; i++) {
		dist[i] = 1;
		color[i] = WHITE;
		g[i][0] = { i + 1,1 };
		g[i][1] = { (i * 10) % k,0 };
	}
	dist[k - 1] = 1;
	color[k - 1] = WHITE;
	g[k - 1][0] = { 0,1 };
	g[k - 1][1] = { ((k - 1) * 10) % k,0 };
	queue<int> q;
	q.push(1);
	while (!q.empty()) {
		if (color[0] != WHITE) { break; }
		while (!q.empty()) {
			int v = q.front(); 
			if (color[v] == GRAY) { break; }
			q.pop();
			int n = dist[v];
			color[v] = GRAY;
			q.push(v);
			int u = g[v][1].next;
			while (color[u] == WHITE) {
				color[u] = GRAY;
				dist[u] = n;
				q.push(u);
				u = g[u][1].next;
			}
		}
		while (!q.empty()) {
			int v = q.front();
			int n = dist[v];
			if (color[v] == WHITE) { break; }
			q.pop();
			color[v] = BLACK;
			int u = g[v][0].next;
			if (color[u] == WHITE) {
				q.push(u);
				dist[u] = n + 1;
			}
		}
	}
	cout << dist[0] << endl;
	return 0;
}

Measured memory_bytes: 2944
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define llrep(i,j,k) for(long long int i=j;i<(long long int)k;i++)
#define Sort(x) sort(x.begin(),x.end()); 
#define vi vector<int>
#define vvi vector<vector<int>> 
#define ll long long
int mod=1e9+7;
const int INF = 1e9;

using namespace std;



int main(void) {
	int x, y, z;
	cin >> x >> y >> z;
	//if (x % (y + z) == 0)cout << (x / (y + z)) - 1 << endl;
	//else cout << x / (y + z) << endl;

	int count = 0;
	x -= z;
	while (x >= (y + z)) {
		x -= (y + z);
		count++;
	}

	cout << count << endl;


	return 0;
}

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

int k;
long long m = 0;

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

	return gcd(b, a % b);
}

int main()
{
	cin >> k;

	m = k * (k + 1) / 2;

	for (int i = 1; i < k; i++)
		for (int j = i + 1; j <= k; j++)
			m += 6 * gcd(i, j);

	for (int i = 1; i < k - 1; i++) {
		for (int j = i + 1; j < k; j++) {
			for (int t = j + 1; t <= k; t++) {
				int c = gcd(i, j);

				m += gcd(c, t) * 6;
			}
		}
	}

	cout << m << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
    
        if (A + B <= K) {
            A = 0;
            B = 0;
        } else if (A <= K) {
            B -= K - A;
            A = 0;
        } else {
            A -= K;
        }
        
        System.out.printf("%d %d", A, B);
        
    }
}

Measured memory_bytes: 23252
using System;
using System.Collections.Generic;

namespace ABC159d
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            var s = Console.ReadLine().Split(' ');
            int[] A = new int[s.Length];
            var D = new Dictionary<int,int>();
            for (int i = 0; i < s.Length; i++)
            {
                A[i] = int.Parse(s[i]);
                if (!D.ContainsKey(A[i]))
                {
                    D.Add(A[i], 1);
                }
                else
                {
                    D[A[i]] = D[A[i]] + 1;
                }
            }
            long m = 0;
            foreach (var d in D.Keys)
            {
                long q = D[d];
                m += Combination(q);
            }

            for (int i = 0; i < A.Length; i++)
            {
                long tot = m;

                int t = A[i];
                long b = D[t];

                tot -= Combination(b);
                tot += Combination(b - 1);


                Console.WriteLine(tot);
            }
        }
        static long Combination(long n)
        {
            return (long)(n * (n - 1) / 2);
        }
    }
}


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

int beki(int a,int b){
	int ans=1;
	for(int i=0;i<b;i++){
		ans=ans*a;
	}
	return ans;
}
int main(){
	int k=-1;
	int length=0;
	char s;
	while(cin>>s){
		if(s=='1'){
			if(k==-1){k=2;}
			else{k=k*10+2;}
			length++;
		}
		if(s=='0'){
			if(k==-1){k=1;}
			else{k=k*10+1;}
			length++;		
		}
		if(s=='B'){
			if(length==0){continue;}
			else{k=k/10;length--;}
		}
	}
	for(int i=length-1;i>=0;i--){
		cout<<(k/beki(10,i))-1;
		k=k%beki(10,i);
	}
	cout<<endl;

return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(void){
	int x, st[10], p = 0;
	while(scanf("%d",&x) != EOF){
		if(x == 0){
			printf("%d\n",st[--p]);
		}else{
			st[p++] = x;
		}
	}
	return 0;
}

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


int main()
{
	int a, b, suma = 1, sumb = 1,i,p;
	char ans[100][100];
	cin >> a >> b;
	for (i = 0;i < 100;i++)
	{
		for (p = 0;p < 100;p++)
		{
			if (p < 50)ans[i][p] = '#';
			else ans[i][p] = '.';
		}
	}
	
	for ( i = 0;i < 100;i += 2)
	{
		for (p = 0;p < 48;p += 2)
		{
			if (suma == a)break;
			ans[i][p] = '.';
			suma++;
		}
		if (suma == a)break;
	}
	
	for (i = 0;i < 100;i += 2)
	{
		for (p = 51;p < 98;p += 2)
		{
			if (sumb == b)break;
			ans[i][p] = '#';
			sumb++;
		}
		if (sumb == b)break;
	}
	
	cout << "100 100" << endl;
	for (int i = 0;i < 100;i++)
	{
		for (int p = 0;p < 100;p++)
			cout << ans[i][p];
		cout << endl;
	}
	return 0;
}

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

int main(){
	int h, n;
	cin >> h >> n;

	int a[n];
	int power = 0;
	string ans = "No";
	for(int i = 0; i < n; i++){
		cin >> a[i];
		power+=a[i];
	}

	if(power >= h){
		ans = "Yes";
	}

	cout << ans << endl;


}


Measured memory_bytes: 640
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prl puts("\n------------------\n")
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prl 
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

const int maxn = 1e5 + 5;
ll dp[maxn];
int w[105], v[105];
int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n = read(), W = read();
    rep(i, 1, n) w[i] = read(), v[i] = read();
    rep(i, 1, n) {
        per(j, W, w[i]) {
            dp[j] = max(dp[j], dp[j - w[i]] + 1LL * v[i]);
        }
    }
    cout << dp[W] << endl;
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

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

const int MAX = 1e5+10;
int64_t cnt[MAX];

int main(){
  int N;
  cin >> N;
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    cnt[x]++;
  }
  
  int Q;
  cin >> Q;
  
  int64_t sum = 0;
  for(int i=0; i<MAX; i++){
    sum += cnt[i]*i;
  }
  
  for(int i=0; i<Q; i++){
    int b, c;
    cin >> b >> c;
    sum -= cnt[b]*b;
    sum -= cnt[c]*c;
    cnt[c] += cnt[b];
    cnt[b] = 0;
    sum += cnt[c]*c;
    cout << sum << endl;
  }
  
}

Measured memory_bytes: 4412
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort(key=lambda x: -x)
    ans = a[0]
    for i in range(1, n//2):
        ans += a[i]*2
    if n%2 == 1:
        ans += a[n//2]
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 31616
#include "vector"
#include "set"
#include "map"
#include "unordered_set"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define MAX_SIZE 1000000000

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) { bool first = true; for (const auto& j: v) { if (!first) { os << " "; } first = false; os <<j; } os << "\n"; return os; }
template<typename T>
istream& operator>>(istream& is, vector<T>& v) { for (auto& elem : v) { is >> elem; } return is; }


void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    for (int i=0; i<1000; i++) {
        if (i % 2 == 0) {
            c -= b;
        } else {
            a -= d;
        }

        if (c <= 0 || a <= 0) {
            break;
        }
    }

    cout << (a <= 0 ? "No" : "Yes");
}


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

    if (0) {
        int tests;
        cin >> tests;
        for (int t = 1; t <= tests; t++) {
            //cout << "Case #" << t << ": ";
            solve();
            cout << "\n";
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <iostream>
#include <math.h>

#define PI 3.14159265358979323846264338327950L

using namespace std;

 int main(void) {
 int a, b, h, m;
 scanf("%d%d%d%d", &a, &b, &h, &m);

 long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);

 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

 printf("%20.20Lf\n", sqrtl(rsq));

 cin >> a;

 return 0;
 }

Measured memory_bytes: 4140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define frep(i, m, n) for(int i = m;i < n;i++)
#define frepr(i, m, n) for(int i = m;i >= n;i--)
#define vsort(v) sort(v.begin(),v.end())
#define ll long long
#define inf 999999999
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vst;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef pair<int,P> PP;
typedef pair<ll,LP> LPP;

int change(char color){
    switch(color){
        case 'R':return 0;break;
        case 'G':return 10;break;
        case 'B':return 20;break;
        default:return 30;break;
    }
}

int main(){
    int t;
    cin >> t;
    rep(z,t){
        int n,k;
        cin >> n >> k;
        vi x(n);
        int a=0,b=0;
        cin >> a;
        rep(i,n-1){
            b=a;
            cin >> a;
            x[i]=a-b;
        }
        vsort(x);
        // rep(i,x.size())cout << x[i] << ",";
        // cout << endl;
        if(k>n-1){
            cout << 0 << endl;
        }
        else{
            cout << accumulate(x.begin(),x.end()-k+1,0) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3436
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
typedef pair<ll,ll> P;

int main()
{
	int n;
	cin>>n;
	vector<P> vi;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		vi.push_back(P(a,b));
	}
	for(int i=1;i<n;i++)
	{
		if(vi[i].first<vi[i-1].first||vi[i].second<vi[i-1].second)
		{
			ll ri = max(vi[i-1].first,vi[i-1].second);
			ll le = 1;
			ll mid;
			while(le+1<ri)
			{
				mid = (ri+le)/2;
				ll mi = (vi[i-1].first+vi[i].first-1)/vi[i].first;
				ll ma = (vi[i-1].second+vi[i].second-1)/vi[i].second;
				if( mid>=mi && mid>= ma )
				{
					ri = mid;
				}
				else
				{
					le = mid;
				}
			}
			vi[i].first*=ri;
			vi[i].second*=ri;
		}
	}
	cout<<vi[n-1].first+vi[n-1].second<<endl;
}


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

int main()
{
	ll n,x;
	cin >> n >>x ;
	if(2<=x&&x<=2*n-2)
	{
		cout << "Yes"<<endl;
		vector<int> ans(2*n-1);
		for(int i = 1;i<=ans.size();i++)
			ans[i-1] = i;
		for(int i = 0;i<ans.size();i++)
		{
			int buff = -(n) + x + ans.size();
			buff %= ans.size();
			buff = (i+buff)%ans.size();
			cout << ans[buff]<<endl;
		}
	}
	else cout << "No"<<endl;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
int main()

{
    long long int n;
    cin >> n;
    long long int sum=0;
    for (int i =1;i<=n;i++){
        if(i%15==0 || i%3==0 || i%5==0 ) continue;
        else
        {   //cout<<" "<< i;
            sum+=i;
        }
    }
    cout<< sum<< "\n";
}


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


int main() {
  int N, M;
  cin >> N >> M;
  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
  return 0;
}


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

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll ;
typedef long double ldb ;
 
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl "\n"
 
#define all( x ) x.begin(),x.end()
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );

int main( ) {
	timesaver ;
	long int n;
	cin >> n;
	string s;
	unordered_map <string, int> m;
	// list<string> m;
	while(n--) {
		cin >> s;
		if(m.find(s) == m.end())
			m.insert({s, 0});

	}
	cout << m.size();
	return 0;
}

Measured memory_bytes: 17716
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int a[3][n];
	long long b[3][n];
	for(int i=0;i<n;i++)
	{
		for(int t=0;t<3;t++)
		{
			scanf("%d",&a[t][i]);
		}
	}
	for(int i=0;i<3;i++)
	{
		b[i][0]=a[i][0];
	}
	for(int i=1;i<n;i++)
	{
		for(int t=0;t<3;t++)
		{
			b[t][i]=0;
		}
	}
	for(int i=1;i<n;i++)//从第二行开始遍历 
	{
		for(int t=0;t<3;t++)//遍历该行的每个状态 
		{
			for(int j=0;j<3;j++)//遍历上一行的每个状态 
			{
				if(j==t)continue;
				b[t][i]=max(b[t][i],b[j][i-1]+a[t][i]);
			}
		}
	}
	long long mm=b[0][n-1];
	for(int i=1;i<3;i++)
	{
		if(mm<b[i][n-1])mm=b[i][n-1];
	}
	printf("%lld",mm);
	return 0;
}

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

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

    int h1, m1, h2, m2, k;
    cin>>h1>>m1>>h2>>m2>>k;

    cout<<max(0, 60*h2+m2-60*h1-m1-k)<<endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<stack>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

int main()
{
  stack<int> S;
  char c[10];
  int x,y;
  while((scanf("%s",&c))!=EOF){
    if(c[0]=='+'){
      x=S.top();S.pop();
      y=S.top();S.pop();
      S.push(x+y);
    }
    else if(c[0]=='-'){ 
      x=S.top();S.pop();
      y=S.top();S.pop();
      S.push(y-x);
    }
    else if(c[0]=='*'){
      x=S.top();S.pop();
      y=S.top();S.pop();
      S.push(x*y);
    }
    else{
      S.push(atoi(c));
    }
  }
  cout<<S.top()<<endl;
  return 0;
}




Measured memory_bytes: 3240
#include <stdio.h>
#include <ctype.h>

int main(){
  int count[26]={0};
  char ch;
  int i, num;

  while(scanf("%c", &ch)!=EOF){
    if(islower(ch)){
      num=ch-'a';
    }else if(isupper(ch)){
      num=ch-'A';
    }else{
      continue;
    }
    count[num]++;
  }
  for(i=0; i<26; i++){
    printf("%c : %d\n", 'a'+i, count[i]);
  }
  return 0;
}



Measured memory_bytes: 2756
#include<stdio.h>
int main(void){
	int n,a[5000],i,j,k;

	while(1){
		scanf("%d",&n);
		if(n==0){break;}
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		int ans=-100000,sum;

		for(i=1;i<=n;i++){
			for(j=0;j<=n-i;j++){
				sum=0;
				for(k=0;k<i;k++){
					sum+=a[j+k];
					if(sum<0){break;}
				}
				if(sum>ans){ans=sum;}
			}
		}

		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

//繰り返し二乗法
template <typename T>
T doubling(T a, T p) {
	if (p == 0)return 1;//出口
	if (p % 2 == 0) {//pを半分にしていく
		T half = doubling<T>(a, p / 2);
		return (half%mod * half % mod)%mod;
	}
	else {//pが奇数ならpを偶数にする
		return (a * doubling<T>(a, p - 1))%mod;
	}
}
 
 
int main(){
 ll h,w,a,b;
 cin>>h>>w>>a>>b;
 vector<ll>fav(h+w+5,1),inv(h+w+5);
 rep(i,h+w)fav[i+1]=(fav[i]*(i+1))%mod;
 rep(i,h+w)inv[i]=doubling<ll>(fav[i],mod-2)%mod;
 ll ans=0;
 for(int i=b;i<w;++i){
   ans+=(((fav[h-a-1+i]%mod*inv[i]%mod)%mod)*inv[h-a-1]%mod)%mod*(((fav[a+w-2-i]%mod*inv[a-1]%mod)%mod)*inv[w-1-i]%mod)%mod;
   ans%=mod;
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
 
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    string a, b;
    int cntA, cntB;
    cin >> a >> b >> cntA >> cntB;
    string x;
    cin >> x;
    if(x == a) cntA--;
    else if(x == b) cntB--;
    cout << cntA << " " << cntB;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))

def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1''などで指定、整数に戻すならintをかます
MOD = 998244353
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))

def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 998244353
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

A = LI2(3)
N = I()
for _ in range(N):
    b = I()
    for i in range(3):
        for j in range(3):
            if b==A[i][j]:
                A[i][j]=0
for c in A:
    if sum(c)==0:
        print('Yes')
        break
else:
    for r in range(3):
        if A[0][r]+A[1][r]+A[2][r]==0:
            print('Yes')
            break
    else:
        if A[0][0]+A[1][1]+A[2][2]==0 or A[0][2]+A[1][1]+A[2][0]==0:
            print('Yes')
        else:
            print('No')


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N; cin >> N;
  vector<LL> xs(N), ys(N);
  REP(i,N) cin >> xs[i];
  REP(i,N) cin >> ys[i];

  vector<PLL> rng(N, MP(1e9,1));
  LL mx = 0;
  REP(i,N){
	if(xs[i] > mx){
	  rng[i] = MP(xs[i], xs[i]);
	  mx = xs[i];
	}
	else{
	  rng[i].FF = min(rng[i].FF, mx);
	}
  }

  LL ans = 1;
  mx = 0;
  for(int i=N-1;i>=0;--i){
	if(ys[i] > mx){
	  mx = ys[i];
	  if(rng[i].FF < ys[i] || rng[i].SS > ys[i])
		ans = 0;

	  rng[i] = MP(ys[i], ys[i]);
	}
	else{
	  rng[i].FF = min(rng[i].FF, mx);
	}
	if(rng[i].SS > mx)
	  ans = 0;
  }

  REP(i,N)
	(ans *= rng[i].FF - rng[i].SS + 1) %= MOD;

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


Measured memory_bytes: 3456
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int len = S.Length;
            int kisuu = 0;
            int guusuu = 0;
            for(int i = 0; i < len; i++)
            {
                if(i % 2 == 0)
                {
                    if(S[i] == 'R' || S[i] == 'U'|| S[i] == 'D')
                    {
                        kisuu++;
                    }
                }
                if (i % 2 != 0)
                {
                    if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D')
                    {
                        guusuu++;
                    }
                }
            }
            if(len == kisuu + guusuu)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    } 
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



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

using ll = long long;

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

  map<string, bool> mp;

  for(int i=1; i<=5; i++){
    for(int j=0; j<s.length(); j++){
      mp[s.substr(j, i)] = true;
    }
  }

  int i=1;
  for(auto itr=mp.begin(); itr!=mp.end(); itr++){
    if(i==k){
      cout << itr->first << endl;
      break;
    }
    i++;
  }

  return 0;
}


Measured memory_bytes: 1920
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>
// ↓これいる？
#include <boost/graph/strong_components.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;
using ll = long long;
namespace bst = boost;
template<class T> void fill(T& v) { for (auto&& i : v) cin >> i; }

//#include "atcoder.hpp"

int main() {
    ll N;
    
    cin >> N;
  
  for (ll i = (ll)ceil(sqrt(N)); i > 0; i--)
    if (N % i == 0) {
      ll b = N / i;
    cout << i + b - 2 << endl;
break;
    }
    
    
    return 0;
}







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

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    cout << (s < t ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

const ll ts = 100005;

#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define endl "\n"

signed main() {

    IOS;
    ll h ,a , n  , sum  = 0 ;
    cin >> h >> n ;
    for(ll i = 1 ; i <= n ; i++) {
    	cin >> a; sum+= a; 
	}
	if(h <= sum) cout << "Yes";
	else cout << "No";
 }


Measured memory_bytes: 256
# C - Ubiquity
def main():
    N = int(input())
    MOD = 10 ** 9 + 7
    res = (10 ** N - 2 * (9 ** N) + 8 ** N) % MOD  # inclusion–exclusion principle
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10940
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        abcd: Chars,
    }

    let a: i64 = abcd[0].to_digit(10).unwrap() as i64;
    let b: i64 = abcd[1].to_digit(10).unwrap() as i64;
    let c: i64 = abcd[2].to_digit(10).unwrap() as i64;
    let d: i64 = abcd[3].to_digit(10).unwrap() as i64;

    if a+b+c+d==7 {
        println!("{}+{}+{}+{}=7", a,b,c,d);
    } else if a-b+c+d==7 {
        println!("{}-{}+{}+{}=7", a,b,c,d);
    } else if a+b-c+d==7 {
        println!("{}+{}-{}+{}=7", a,b,c,d);
    } else if a+b+c-d==7 {
        println!("{}+{}+{}-{}=7", a,b,c,d);
    } else if a-b-c+d==7 {
        println!("{}-{}-{}+{}=7", a,b,c,d);
    } else if a+b-c-d==7 {
        println!("{}+{}-{}-{}=7", a,b,c,d);
    } else if a-b+c-d==7 {
        println!("{}-{}+{}-{}=7", a,b,c,d);
    } else if a-b-c-d==7 {
        println!("{}-{}-{}-{}=7", a,b,c,d);
    }

}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
    int n, m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

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

    map<ll,ll>mpa;

    for(int i = 0;i <= 10000;i++)
        mpa[i] = 0;

    ll goukei=0;
    ll wa;

    for(int x = 1;x <= 98;x++)
        for(int y = 1;y <= 98;y++)
            for(int z = 1;z <= 98;z++){
                wa = x*x+y*y+z*z+x*y+y*z+z*x;
                mpa[wa]++;
            }

    for(int i = 1;i <=N;i++)
        cout << mpa[i] << endl;

    
}


Measured memory_bytes: 5984
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<vector>
#include<set>
#include<map>
#include<deque>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=300010;
int n,m;
int k;
map<pii,int> mp;
int col[N],row[N];
int maxr,maxc;
vector<int> a,b;
int main()
{
    cin>>n>>m>>k;
    while(k--)
    {
        int a,b;
        cin>>a>>b;
        mp[{a,b}]=1;
        row[a]++;
        col[b]++;
        maxr=max(maxr,row[a]);
        maxc=max(maxc,col[b]);
    }
    for(int i=1;i<=n;i++) 
        if(row[i]==maxr) a.push_back(i);
    for(int j=1;j<=m;j++)
        if(col[j]==maxc) b.push_back(j);
    for(int i=0;i<a.size();i++) 
        for(int j=0;j<b.size();j++)
            if(mp[{a[i],b[j]}]==0) 
            {
                cout<<maxr+maxc<<endl;
                return 0;
            }
    cout<<maxr+maxc-1<<endl;
    return 0;
}


Measured memory_bytes: 28508
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		int ans = 0;
		for(int i = 0;i < s.length;i++){
			if(s[i].equals("+")){
				ans++;
			} else {
				ans--;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

int w,h;
bool grid[10][10],vis[10][10];
int block[10][10];
int sy,sx,n;
int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};
int b[] = {3,5,6,9,10,12};

int dfs(int y,int x){
  if(vis[y][x])return 0;
  vis[y][x] = true;

  int res = 1;
  for(int i=0;i<4;i++){
    if((block[y][x] >> i) & 1){
      int ty = y+dy[i], tx = x+dx[i];
      if(ty<0 || tx<0 || ty>=h || tx>=w)continue;
      res += dfs(ty,tx);
    }
  }
  return res;
}

bool rec(int y,int x){
  if(y==h){
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)vis[i][j] = false;
    return dfs(sy,sx)==n;
  }
  if(grid[y][x]){
    return (x+1>=w)?rec(y+1,0):rec(y,x+1);
  }

  bool res;
  for(int i=0;i<6;i++){
    if( b[i]&1 ){
      if(y-1<0 || grid[y-1][x] || !((block[y-1][x]>>2)&1))continue;
    }else{
      if(y && !grid[y-1][x] && (block[y-1][x]>>2)&1)continue;
    }
    if( (b[i]>>1)&1){
      if(x+1>=w || grid[y][x+1])continue;
    }
    if( (b[i]>>2)&1){
      if(y+1>=h || grid[y+1][x])continue;
    }
    if( (b[i]>>3)&1 ){
      if(x-1<0 || grid[y][x-1] || !((block[y][x-1]>>1)&1))continue;
    }else{
      if(x && !grid[y][x-1] && (block[y][x-1]>>1)&1)continue;
    }

    block[y][x] = b[i];
    res = (x+1>=w)?rec(y+1,0):rec(y,x+1);
    if(res)return true;
  }
  return false;
}

int main(){
  while(cin >> w >> h,(w||h)){
    sy = sx = -1; n = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> grid[i][j];
	if(!grid[i][j] && sy<0){sy = i; sx = j;} 
	n+=grid[i][j];
	block[i][j] = 0;
      }
    }
    n = h*w-n;

    cout << ((n && rec(0,0))?"Yes":"No") << endl;
  }
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};
using namespace std;
int main() {
	int K;
	cin >> K;
	
	string S;
	cin >> S;
	combination c(S.size() + K);
	mint ans = 0;
	for (int i = 0;i <= K;++i) {
		mint tmpans = mint(26).pow(i);
		tmpans *= mint(25).pow(K - i);
		tmpans *= c(K-i+S.size()-1,S.size()-1);
		ans += tmpans;
	}
	cout << ans<< endl;

	return 0;
}

Measured memory_bytes: 35632
H, W = gets.split.map(&:to_i)
 
k, m, r = Array.new(W, 0), Array.new(W, 0), 0
H.times do
  l = 0
  s = gets.chomp
  (0 ... W).each do |j|
    if s[j] == '.'
      if l == 0
        t = j + 1
        while t < W && s[t] == '.'
          t += 1
        end
        l = t - j
      end
      k[j] += 1
      m[j] = l if l > m[j]
    else
      x = k[j] + m[j]
      r = x if x > r
      l = 0
      k[j] = 0
      m[j] = 0
    end
  end
end
(0 ... W).each{|j| x = k[j] + m[j]; r = x if x > r}
puts r - 1

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

int main()
{
    vector<int> vt;
    for(int i=0; i<3; i++){
        int tmp;
        cin >> tmp;
        vt.push_back(tmp);
    }
    sort(vt.begin(), vt.end());
    if(vt[0]+vt[1]==vt[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
#include<unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int n, t; cin >> n >> t;
	int a[n];
	rep(i, n) cin >> a[i];
	
	int mi = a[0];
	int ma = 0;
	int ans = 0;
	rep(i, n-1){
		int dif = a[i+1] - mi;
		if(ma < dif){
			ma = dif;
			ans = 1;
		}else if(ma == dif){
			ans++;
		}
		
		mi = min(mi, a[i+1]);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640