akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

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 FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int MAX = 200060;
const double pi = acos(-1);
const ll INF = 1e16;


void solve() {
	int N; cin >> N;
	vector<int>A(N);
	REP(i, N)cin >> A[i];
	sort(all(A));
	ll ans = 0;
	REP(i, N - 2) {
		FOR(j, i + 1, N - 1) {
			FOR(k, j + 1, N) {
				if (A[i] + A[j] <= A[k])break;
				if (A[i] < A[j] + A[k] && A[j] < A[i] + A[k] && A[k] < A[i] + A[j])ans++;
			}
		}
	}
	print(ans);
}


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

	solve();
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main(){
	ll N, M, X, Y;
	vector<ll> x, y;
	cin >> N >> M >> X >> Y;
	
	rep(i, 0, N){
		ll temp;
		cin >> temp;
		if (temp < X) continue;
		x.push_back(temp);
	}
	rep(i, 0, M){
		ll temp;
		cin >> temp;
		if (temp > Y) continue;
		y.push_back(temp);
	}
	bool xFlg = false;
	bool yFlg = false;
	rep(i, X+1, Y+1){
		rep(ii, 0, x.size()){
			if ((x[ii] >= i) || (x[ii] > Y)) xFlg = true;
		}
		rep(ii, 0, y.size()){
			if ((y[ii] < i) || (y[ii] <= X)) yFlg = true;
		}
		if (!xFlg && !yFlg){
			cout << "No War" << endl;
			return 0;
		}
		xFlg = false;
		yFlg = false;
	}
	cout << "War" << endl;
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  std::vector<int> A(26);

  for (int i = 0; i < S.size(); i++) {
    A.at(S.at(i)-'a')++;
  }
  for (int i = 0; i < 26; i++) {
    if(A.at(i)==0) {
      char s='a'+i;
      cout << s << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
import collections

N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

c = collections.Counter(A)
values,counts = zip(*c.most_common())
D=[]
for i in range(len(counts)):
    D.append([counts[i],values[i]])
for i in range(M):
    D.append(BC[i])
D=sorted(D,key=lambda x:x[1], reverse=True)

t=0
i=0
ans=0
while t<N:
    if D[i][0]+t<=N:
        ans+=D[i][1]*D[i][0]
        t+=D[i][0]
        i+=1
    else:
        ans+=D[i][1]*(N-t)
        t+=N-t
print(ans)

Measured memory_bytes: 122676
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    if(N==0){cout<<0<<endl;exit(0);}
    vector<int>sub;
    int a=N,b;
    for(int i=0;a!=0;i++){
        if(a%(-2)==0){sub.push_back(0);a/=(-2);}
        else if(a%(-2)==1){sub.push_back(1);a/=(-2);}
        else{sub.push_back(1);a=a/(-2)+1;}
    }
    int SIZE=sub.size();
    for(int i=0;i<SIZE;i++){
        printf("%d",sub[SIZE-i-1]);
    }
    cout<<endl;
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    import collections
    N = int(input())
    A_list = [int(item) for item in input().split()]

    cnt_dict = collections.Counter(A_list)

    cnt = 0
    for i, v in cnt_dict.items():
        if i <= v:
            cnt += v - i
        elif i > v:
            cnt += v
    print(cnt)
if __name__ == "__main__":
    resolve()


Measured memory_bytes: 18676
#include <bits/stdc++.h>
using namespace std;
using P = pair<string, int>;

int main() {
  map<char, int> rbg;
  rbg['r'] = 0;
  rbg['b'] = 1;
  rbg['g'] = 2;

  string s;
  while (cin >> s && s[0] != '0') {
    vector<string> goal;
    for (int i = 0; i < 3; ++i) goal.push_back(string(s.length(), "rbg"[i]));

    auto check = [&](string s) {
      for (int i = 0; i < 3; ++i) {
        if (goal[i] == s) return true;
      }
      return false;
    };

    map<string, bool> mp; mp[s] = true;
    queue<P, deque<P>> que; que.push({s, 1});

    int ans = 0;
    bool ok = check(s);
    while (!que.empty() && !ok) {
      tie(s, ans) = que.front(); que.pop();
      if (!mp[s]) continue;

      for (int i = 0; i < s.length() - 1; ++i) {
        string tmp(s);
        if (s[i] == s[i + 1]) continue;
        int c = 3 - rbg[s[i]] - rbg[s[i + 1]];
        tmp[i] = tmp[i + 1] = "rbg"[c];
        if (check(tmp)) ok = true;
        if (!mp[tmp]) que.push({tmp, ans + 1});
        mp[tmp] = true;
      }
    }
    cout << ( (ok) ? to_string(ans) : "NA" ) << endl;
  }
  return 0;
}



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

int main(void)
{
    vector<ll> cost(5);
    ll N;
    cin >> N;
    for (int i = 0; i < 5; i++)
    {
        cin >> cost[i];
    }
    

    ll result = (ll) ceil((double) N / *min_element(cost.begin(), cost.end())) + 4;
    cout << result << endl;

    return 0;
}


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

using namespace std;
#define ll long long
#define pb push_back

int func(int n)
{
	int temp =n ;
	int s=0;
	while(temp>0){
		s += temp%10;
		temp/=10;
	}
	return s;
}

int main()
{	
	int n, s;
	cin >> n;
	s = func(n);
	if(n%s) cout << "No\n";
	else cout << "Yes\n";
	return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, K;
int A[220000], F[220000];
signed main() {
    cin >> N >> K;
    rep(i, N) { cin >> A[i]; }
    sort(A, A + N);
    rep(i, N) { cin >> F[i]; }
    sort(F, F + N), reverse(F, F + N);
    int ok = 1e13, ng = -1;
    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        int sum = 0;
        rep(i, N) {
            sum += max(0LL, A[i] - mid / F[i]);
        }
        ((sum <= K) ? ok : ng) = mid;
    }
    cout << ok << endl;
}

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


class Main {
  public static void main(String[] args) throws IOException {
  	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	int n = Integer.parseInt(br.readLine());
  	int[] a = new int[n];
  	String[] elements = br.readLine().split(" ");
  	
	for (int i = 0; i < n; ++i){
		a[i] = Integer.parseInt(elements[i]);
	}
	
	int num = 0;
	
	for (int i = 0; i < n-1; ++i){
		for (int j = n - 1; j > i; --j){
			if(a[j] < a[j-1]){
				int tmp = a[j-1];
				a[j-1] = a[j];
				a[j] = tmp;
				num = num + 1;
			}
		}
	}
	
	for(int i = 0; i < n; ++i){
		System.out.print(i == 0 ? a[i] : " " + a[i]);
	}
	System.out.println();
	System.out.println(num);
	
  }
}

Measured memory_bytes: 24360
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;

int main() {
  // Happy hacking!
  string s;
  ll idx_max = 0;
  ll len_max = 0;
  ll idx = 0;
  ll len = 0;
  bool is_counting = false;
  cin >> s;

  for(ll i=0; i<s.length(); i++) {
    if(is_counting) {
      if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
        len++;
      } else {
        if(len > len_max) {
          idx_max = idx;
          len_max = len;
        }
        is_counting = false;
      }
    } else {
      if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
        idx = i;
        len = 1;
        is_counting = true;
        } else {
        
        }
    }
  }
  if(len > len_max) {
          idx_max = idx;
          len_max = len;
        }
  
  cout << len_max << endl;

  return 0;
}


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

const ll INF = 1e17;
const ll MOD = 1e9+7;


int main() {
    // input, ready
    ll A,B,K;
    cin >> A >> B >> K;

    //resolve
    ll tc = max((ll)0,A-K);
    ll ac = max((ll)0,min(B,B-(K-A)));

    // output
    cout << tc << ' ' << ac << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
 
int main(void){
    int n;
    int w[150];
    int res1 = 0, res2 = 0;
 
    cin >> n;
 
    for(int i = 0; i < n; i++){
        cin >> w[i];
        res1 += w[i];
    }
 
    res1 -= w[n-1];
    res2 = w[n-1];
 
    int ans = abs(res1 - res2);
    for(int i = n - 2; i > 0; i--){
        res1 -= w[i];
        res2 += w[i];
 
        int diff = abs(res1 - res2);
        if(diff < ans){
            ans = diff;
        }
    }
    cout << ans << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD pow(10,9)+7

int main()
{
  int N;cin>>N;
  for(int i=1;i<=9;i++)
  {
    for(int j=1;j<=9;j++)
    {
      if (i*j==N)
      {
        cout<<"Yes"<<endl;
        return (0);
      } 
    }
  }
  cout<<"No"<<endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    sort(All(v));
    double res = v[0];
    rep(i, N - 1) { res = (res + v[i + 1]) / 2.0; }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
#define Mod 998244353
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
struct node {int x,y;} a[N];
struct cmp {bool operator ()(const node &a,const node &b)const {return a.x<b.x;}};
int n,x[N],y[N],f[N],ans;
int t[N];
void add(int x) {while(x<=n)t[x]++,x+=x&-x;}
int query(int x) {int res=0; while(x)res+=t[x],x-=x&-x; return res;}
int main() {
	f[0]=1;
	scanf("%d",&n);
	for(int i=1; i<=n; i++)f[i]=(f[i-1]<<1)%Mod;
	for(int i=1; i<=n; i++)scanf("%d%d",&a[i].x,&a[i].y),x[i]=a[i].x,y[i]=a[i].y;
	sort(x+1,x+1+n),sort(y+1,y+1+n);
	int lx=unique(x+1,x+1+n)-x-1;
	int ly=unique(y+1,y+1+n)-y-1;
	for(int i=1; i<=n; i++) {
		a[i].x=lower_bound(x+1,x+1+lx,a[i].x)-x;
		a[i].y=lower_bound(y+1,y+1+ly,a[i].y)-y;
	}
	ans=1ll*n*(f[n]-1)%Mod;
	for(int i=1; i<=n; i++) {
		ans-=f[i-1]-1,ans+=ans<0?Mod:0;
		ans-=f[i-1]-1,ans+=ans<0?Mod:0;
		ans-=f[n-i]-1,ans+=ans<0?Mod:0;
		ans-=f[n-i]-1,ans+=ans<0?Mod:0;
	}
	sort(a+1,a+1+n,cmp());
	for(int i=1; i<=n; i++) {
		ans+=f[query(a[i].y)]-1,ans-=ans>=Mod?Mod:0;
		ans+=f[i-query(a[i].y)-1]-1,ans-=ans>=Mod?Mod:0;
		add(a[i].y);
	}
	Ms(t,0);
	for(int i=n; i>=1; i--) {
		ans+=f[query(a[i].y)]-1,ans-=ans>=Mod?Mod:0;
		ans+=f[n-i-query(a[i].y)]-1,ans-=ans>=Mod?Mod:0;
		add(a[i].y);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(void){
int N,M,s[4],c[4],ans[4]={};
  scanf("%d %d",&N,&M);
  for(int i=0;i<M;i++){
   scanf("%d %d",&s[i],&c[i]);
    if(s[i]==1&&c[i]==0&&N>1){
      printf("-1");
      return 0;
    }
  }
  
  int max=-1;
  for(int i=0;i<M;i++){
    if(s[i]>max)max=s[i];
  }
    
   for(int i=0;i<M-1;i++){
     if(max>N){printf("-1");
               return 0;
              }
   }
  
 for(int i=0;i<M-1;i++){
   if(s[i]==s[i+1]&&c[i]!=c[i+1]){
     printf("-1");
  return 0;
}
 }
 
    
  
  int cc=0;
  for(int i=0;i<M;i++){
    cc+=c[i];
  }
  if(N==1&&cc==0){
    printf("0");
    return 0;
  }
  
  for(int i=0;i<M;i++){
    
ans[s[i]-1]=c[i];
  }
  if(ans[0]==0)ans[0]=1;
// printf("%d\n",strlen(ans));
  
  //int count=0;
  for(int i=0;i<N;i++){
    //if(count==0&&ans[i]==0){continue;}
   // else {count++;
         printf("%d",ans[i]);
         
  }
  
 
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
    int N,K;
    cin >> N >> K;
    vector<int>p(N);
    rep(i,N)cin >> p[i];
    int sum = 0,ans = 0;
    rep(i,N){
        if(i<K){
            sum+=p[i];
            ans=sum;
        }
        else{
            sum+=(p[i]-p[i-K]);
            ans=max(ans,sum);
        }
    }

    cout << setprecision(10) << (double)(K+ans)/2.0 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

ll factorial(ll n) {
    ll ret = 1;
    for (int i = 1; i <= n; ++i) {
        ret = ret * i % MOD;
    }
    return ret;
}

int main() {
    ll N, M;
    cin >> N >> M;
    ll ret = 0;
    if (abs(N - M) > 1)
        ret = 0;
    else {
        if (N == M) {
            ret = (2 * factorial(N) * factorial(N)) % MOD;
        } else {
            ret = factorial(M) * factorial(N) % MOD;
        }
    }
    cout << ret << endl;
    return 0;
}

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

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

    array<long, 256> countchar{};

    for(char i : s){
        countchar[i] = countchar[i] + 1;
    }

    long ans = 1;

    for(long i : countchar){
        ans = ans * (i + 1) % 1000000007;
    }

    cout << ans - 1 << endl;

    return 0;
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqL = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        Array.Sort(seqL);

        var k = 0;
        for (int a = 0; a < seqL.Length; ++a)
        for (int b = a + 1; b < seqL.Length; ++b)
        {
            var ok = b + 1;
            var ng = seqL.Length;
            while (Math.Abs(ok - ng) > 1)
            {
                var m = (ok + ng) / 2;
                if (seqL[m] < seqL[a] + seqL[b])
                {
                    ok = m;
                }
                else
                {
                    ng = m;
                }
            }
            if (ok >= seqL.Length || seqL[ok] >= seqL[a] + seqL[b])
            {
                continue;
            }

            k += ok - b;
        }
        Console.WriteLine(k);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;
const int MAX = 100005;

int main() {
    int a, b; cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;
}

Measured memory_bytes: 256
(function(stdin) {

  // Define Function

  // Declare Variable
  const inputs  = stdin.toString().trim().split('\n');

  // Main Procedure
  const result = (function(X) {

//    return [X];
//x???3?????????
    return Math.pow(X,3);

//parseInt??§??????????????°????????????(10?????°)
  }(parseInt(inputs[0]),10));

  // Display
  console.log(result);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15784
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    int cnt = 0;
    rep(i, 0, n) if(s[i] == 'o') cnt++;
    cnt += 15 - n;
    if(cnt >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){

  string S; cin >> S;
  int N = sz(S);
  string ss = S;
  reverse(all(ss));
  if(S!=ss){
    cout << "No" << endl;
    return 0;
  }
  string sss;
  sss = ss = S.substr(0,(N-1)/2);
  cerr << sss << endl;
  reverse(all(sss));
  if(ss!=sss){
    cout << "No" << endl;
    return 0;
  }
  sss = ss = S.substr((N+3)/2-1,100);
  cerr << sss << endl;
  reverse(all(sss));
  if(sss!=ss){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(void){
    int x, y, a;
    cin >> x >> y;
    if(x < y){
        a = y;
        y = x;
        x = a;
    }
    while(y > 0){
        a = x % y;
        x = y;
        y = a;
    }
    cout << x << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

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

  ll m = 0;          // 一番得点の低い人の順位
  ll M = 1000000000; // 一番得点が高い人の順位
  ll min_score;      // 一番得点が低い人の点数

  ll a, b; // (順位、得点)
  for (int i = 0; i < n; i++)
  {
    cin >> a >> b;
    if (a > m)
    {
      m = a;
      min_score = b;
    }
    if (a < M)
    {
      M = a;
    }
  }

  cout << m + min_score << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x%N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x)%N;
		y = y >> 1;
		x = (x * x)%N;
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll a, b;
	cin >> a >> b;
	ll gc = gcd(a, b);
	ll count = 1;
	if (gc % 2 == 0)
	{
		count += 1;
		while (gc % 2 == 0)
		{
			gc /= 2;
		}
	}
	for (ll i = 3; i <= sqrt(gc); i += 2)
	{
		if (gc % i == 0)
		{
			count += 1;
			while (gc % i == 0)
			{
				gc /= i;
			}
		}
	}
	if (gc > 2)
	{
		count += 1;
	}
	cout << count;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
#define MAX 1000005
#define mod 1000000007



int main()
{
 //O_O ;
   dl t;
   cin>>t;
  cout<<2*t*pi<<nn;


    return 0;
}


Measured memory_bytes: 3796
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
 
		Scanner sc =  new Scanner(System.in);
		
		String a = sc.next();
		String b = sc.next();
		
		int count = 0;
		int ans = 0;
		
	if(a.charAt(0) == b.charAt(2)){
		count++;
	}
	if(a.charAt(1) == b.charAt(1)){
		count++;
	}
	if(a.charAt(2) == b.charAt(0)){
		count++;
	}
	if(count == 3){
		System.out.println("YES");
	}else
		System.out.println("NO");
	
	}
}

Measured memory_bytes: 23636
#include<stdio.h>

int main(void){
    int S ;
    int h ,m ,s ;

    scanf("%d",&S);

    h=S/3600;
    m=(S%3600)/60;
    s=(S%3600)%60;
    printf("%d:%d:%d\n",h ,m ,s);

    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const int MOD = (int)1e9 + 7;

ll pow3(int n) {
    if(n == 0) return 1;
    else if(n == -1) return 0;
    else if(n % 2 == 0) return pow3(n / 2) * pow3(n / 2) % MOD;
    else return (pow3((n - 1) / 2) * pow3((n - 1) / 2) % MOD) * 3 % MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    
    ll dp[n + 1][4];
    REP(i, n + 1)REP(j, 4) dp[i][j] = 0;
    dp[n][3] = 1;

    FORR(i, n - 1, 0) {
        if(s[i] == '?') dp[i][3] = dp[i + 1][3] * 3 % MOD;
        else dp[i][3] = dp[i + 1][3];
        REP(j, 3) {
            if(s[i] == '?' or s[i] == (char)('A' + j)) 
                dp[i][j] = dp[i + 1][j + 1];
            if(s[i] == '?') dp[i][j] = (dp[i][j] + dp[i + 1][j] * 3 % MOD) % MOD;
            else dp[i][j] = (dp[i][j] + dp[i + 1][j]) % MOD;
        }
    }

    cout << dp[0][0] << endl;
    return 0;
}


Measured memory_bytes: 3664
import sys
from collections import deque

dic={'o':lambda s:1-(s[1]^s[0]), 'x':lambda s:s[1]^s[0]}
def mknseq(ox,ld):
    for x in ld:
        x.append(dic[ox]((x[-2],x[-1])))
def main():
    N=int(sys.stdin.readline().strip())
    s=list(sys.stdin.readline().strip())
    ans=[deque([x,y]) for x in range(2) for y in range(2)]
    for x in range(N):
        mknseq(s[x],ans)
    # print(ans)
    for x in ans:
        if x[0]==x[-2] and x[1]==x[-1]:
            return print(''.join([['W','S'][i] for i in x])[1:-1])
    print(-1)

if __name__=='__main__':
    main()


Measured memory_bytes: 14044
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

pii dir4[4] = {
    {0, 1},
    {0, -1},
    {1, 0},
    {-1, 0},
};

int main(void) {
    int row, col;
    cin >> row >> col;
    vector<vector<char>> map(row+2, vector<char>(col+2));

    for(int i = 1; i <= row; i++) {
        string str;
        cin >> str;
        for(int j = 1; j <= col; j++) {
            map[i][j] = (str[j-1] == '#');
        }
    }

    int flag = 1;
    for(int i = 1; i <= row; i++) {
        for(int j = 1; j <= col; j++) {
            if(!map[i][j]) continue;
            int is_ok = 0;
            for(pii d: dir4) {
                pii np = make_pair(
                    i + d.first,
                    j + d.second
                );
                if(map[np.first][np.second]) is_ok = 1;
            }
            if(!is_ok) { flag = 0; goto finish; }
        }
    }
finish:
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtTest
{
    class ARC101_C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            input = Console.ReadLine().Split(' ');
            var minusX = new List<long>();
            var plusOrZeroX = new List<long>();

            for (int i = 0; i < n; i++)
            {
                long x = long.Parse(input[i]);
                if (x < 0)
                {
                    minusX.Add(x);
                }
                else
                {
                    plusOrZeroX.Add(x);
                }
            }
            long[] minuses = minusX.ToArray();
            Array.Reverse(minuses);
            minuses = minuses.Select(x => x *= -1).ToArray();
            for(int i = 0; i < minuses.Length; i++)
            {
                //Console.WriteLine(minuses[i]);
            }
            long[] pluses = plusOrZeroX.ToArray();
            for (int i = 0; i < pluses.Length; i++)
            {
                //Console.WriteLine(pluses[i]);
            }

            long minDistance = -1;
            for(int i = -1; i < pluses.Length; i++)
            {
                if (i == -1)
                {
                    if (k <= minuses.Length)
                    {
                        long dist = minuses[k - 1];
                        minDistance = dist;
                    }
                    continue;
                }

                int minusCnt = k - i - 1;
                if (minusCnt > minuses.Length) continue;

                long plusDist = 2 * pluses[i];
                long minusDist = pluses[i];
                if (minusCnt > 0)
                {
                    plusDist += minuses[minusCnt - 1];
                    minusDist += 2 * minuses[minusCnt - 1];
                }
                long min = plusDist < minusDist ? plusDist : minusDist;
                if (minDistance == -1 || minDistance > min)
                {
                    minDistance = min;
                }
            }

            Console.WriteLine(minDistance);
        }
    }
}


Measured memory_bytes: 24416
import java.util.*

fun main(args : Array<String>) {
//    val scanner = Scanner(System.`in`)
    println(inOutExec(null))
}

fun inOutExec(scanner: Scanner?): String {
    val (numOfPref, numOfCity) = readLine()!!.split(" ").map { it.toInt() }

    val citiesIn = mutableListOf<Pair<Int, Int>>()
    repeat(numOfCity) {
        val (pref, year) = readLine()!!.split(" ").map { it.toInt() }
        citiesIn.add(Pair(pref, year))
    }

    val cityCodeMap = citiesIn
            .groupByTo(mutableMapOf()) { it.first }
            .flatMap { entry ->
                entry.value
                        .sortedBy { info -> info.second }
                        .mapIndexed { index, pair ->
                            pair to "%06d%06d".format(pair.first, index + 1) } } // Pair<Pair<Int, Int>, String>
            .toMap()

    return citiesIn.joinToString(separator = "\n", postfix = "\n") { cityCodeMap[it]!! }
}


Measured memory_bytes: 148252
n,m = map(int,input().split())
x = list(map(int,input().split()))
if n >= m:
    print("0")
else:
    x.sort()
    ans = max(x) - min(x)
    dif = []
    for i in range(m-1):
        dif.append(abs(x[i+1]-x[i]))
    dif.sort()
    dif.reverse()
    for i in range(n-1):
        ans += -dif[i]
    print(ans)

Measured memory_bytes: 13968
// orz yyb
#include <bits/stdc++.h>

using std::cerr;
using std::endl;

const int N = 2e5 + 233, INF = 1e9;

int n, A[N], B[N], pre, Q[N], cnt0, cnt1, max0, max1, ans[N];

struct SegTree {
  int max[N * 4];
  #define ls (p << 1)
  #define rs (ls | 1)
  #define mid ((L + R) >> 1)
  inline void init() {
    memset(max, 0xcf, sizeof(max));
  }
  void modify(int p, int x, int v, int L, int R) {
    if (L == R) return max[p] = v, void();
    if (x <= mid) modify(ls, x, v, L, mid);
    else modify(rs, x, v, mid + 1, R);
    max[p] = std::max(max[ls], max[rs]);
  }
  int query(int p, int l, int r, int L, int R) {
    if (l <= L && r >= R) return max[p];
    int ret = -INF;
    if (l <= mid) ret = std::max(ret, query(ls, l, r, L, mid));
    if (r > mid) ret = std::max(ret, query(rs, l, r, mid + 1, R));
    return ret;
  }
} seg[2];

inline int check(int x, int y) {
  if (y < 0) return 0;
  return seg[y & 1].query(1, x, n, 1, n) >= y;
}

int main() {
  // freopen("data", "r", stdin);
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", A + i);
    if (A[i] > pre) pre = A[i], B[i] = 2;
    else B[i] = 1;
  }
  seg[1].init();
  for (int i = n; i; --i) {
    int max0 = seg[0].query(1, A[i], n, 1, n), max1 = seg[1].query(1, A[i], n, 1, n);
    if (B[i] == 1) seg[0].modify(1, A[i], max1 + 1, 1, n), seg[1].modify(1, A[i], max0 + 1, 1, n);
    else seg[0].modify(1, A[i], max0 + 2, 1, n), seg[1].modify(1, A[i], max1 + 2, 1, n);
    Q[i] = Q[i + 1] + B[i] - 1;
  }
  for (int i = 1; i <= n; ++i) {
    seg[0].modify(1, A[i], 0, 1, n), seg[1].modify(1, A[i], -INF, 1, n);
    if (check(max1, cnt0 - cnt1 + Q[i + 1] + (A[i] > max0)) || check(std::max(max0, A[i]), cnt1 - cnt0 + Q[i + 1] - (A[i] > max0)))
      ans[i] = 0, cnt0 += A[i] > max0, max0 = std::max(max0, A[i]);
    else ans[i] = 1, cnt1 += A[i] > max1, max1 = std::max(max1, A[i]);
  }
  if (cnt0 != cnt1) printf("-1");
  else for (int i = 1; i <= n; ++i) printf("%d", ans[i]);
  putchar('\n');
  return 0;
}



Measured memory_bytes: 9856
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            double a = double.Parse(input[0]);
            double b = double.Parse(input[1]);
            double c = double.Parse(input[2]);

            double c_rad = c * Math.PI / 180;

            double S = a * b * Math.Sin(c_rad)/2;
            double L = a + b + Math.Sqrt(a * a + b * b - (2 * a * b * Math.Cos(c_rad)));
            double h = b * Math.Sin(c_rad);

            Console.WriteLine("{0:f8}", S);
            Console.WriteLine("{0:f8}", L);
            Console.WriteLine("{0:f8}", h);

        }
    }
}

Measured memory_bytes: 9208
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#endif
using namespace std;

template <typename T>
struct StackProcessor {
  StackProcessor() : m(new T[buffer_len]) {}

  template <typename F>
  void process(F f) {
    assert(index >= 2);
    auto rhs = pop();
    auto lhs = pop();
    m[index++] = f(lhs, rhs);
  }

  void put(T t) {
    assert(index < buffer_len);
    m[index++] = t;
  }

  T pop() {
    assert(index > 0);
    return m[--index];
  }

  constexpr static size_t buffer_len = 1024;
  unique_ptr<T[]> m;
  size_t index = 0;
};

int main() {
  string s;
  getline(cin, s);
  stringstream ss(s);

  StackProcessor<int> proc;

  while (ss >> s) {
    if (!s.compare("+")) {
      proc.process([](int lhs, int rhs) { return lhs + rhs; });
    } else if (!s.compare("-")) {
      proc.process([](int lhs, int rhs) { return lhs - rhs; });
    } else if (!s.compare("*")) {
      proc.process([](int lhs, int rhs) { return lhs * rhs; });
    } else {
      proc.put(stoi(s));
    }
  }
  cout << proc.pop() << endl;
}

Measured memory_bytes: 3204
#include <stdio.h>

int main(void)
{
	int k, x, i;

	scanf("%d %d", &k, &x);

	//座標の最小値まで出力
	for (i = k - 1; i > 0; i--) {
		printf("%d ", x - i);
	}
	//座標Xから座標の最大値まで出力
	for (i = 0; i < k; i++) {
		printf("%d ", x + i);
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
const ll mod = 1000000007;
int main()
{
    /*int d, t, s; cin >> d >> t >> s;
    if (d <= t * s) cout << "Yes" << endl;
    else cout << "No" << endl;
    */

    /*string s, t; cin >> s >> t;
    int mx = 0;
    rep(i, s.size()) {
        int tmp = 0;
        if (s.size() < i + t.size()) continue;
        rep(j, t.size()) {
            if (s[i + j] == t[j]) tmp++;
        }
        mx = max(mx, tmp);
    }
    cout << t.size() - mx << endl;
    */

    int n; cin >> n;
    vector<ll> a(n);
    vector<ll> sum(n + 1, 0);
    sum[0] = 0;
    rep(i, n) {
        cin >> a[i];
        sum[i + 1] = a[i] + sum[i];
        sum[i + 1] %= mod;
    }
    ll ans = 0;
    rep(i, n) {
        ll s = sum.back() - sum[i + 1];
        s %= mod;
        if (s < 0) s += mod;
        ans += a[i] * s;
        ans %= mod;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 6424
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class DDisjointSetOfCommonDivisors {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        lint A, B;
        in>>A>>B;
        lint g = __gcd(A, B);
        lint ans = 1;
        for(lint i=2;i*i<=g;++i){
            if(g%i==0){
                ++ans;
                while(g%i==0) g /= i;
            }
        }
        if(g>1) ++ans;
        out<<ans<<'\n';
    }
};


int main() {
	DDisjointSetOfCommonDivisors solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main(void){
	int a[3], b, c, i;

	scanf("%d %d %d", &a[0], &a[1], &a[2]);
	for (c = 0; c < 2; c++){
		for (i = 0; i < 2; i++){
			if (a[i]>a[i + 1]){
				b = a[i];
				a[i] = a[i + 1];
				a[i + 1] = b;
			}
		}
	}
	printf("%d %d %d\n", a[0], a[1], a[2]);
	return 0;
}

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

int main(){
    long long int A,B,M; cin>>A>>B>>M;
    long long int minia=100000,minib=100000;
    vector<long long int> a(A,0),b(B,0);
    for(long long int i=0;i<A;i++){
        cin>>a[i];
        minia=min(minia,a[i]);
    }
    for(long long int i=0;i<B;i++){
        cin>>b[i];
        minib=min(minib,b[i]);
    }
    long long int mini=minia+minib;
    for(long long int i=0;i<M;i++){
        long long int x,y,c;
        cin>>x>>y>>c;
        mini=min(mini,a[x-1]+b[y-1]-c);
    }
    cout<<mini;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = [[int(i) for i in input().split()] for _ in range(N)]

def judge() :
    s = 0
    for i in range(N) :
        for j in range(i + 1, N) :
            for k in range(N) :
                if i == k or j == k :
                    continue
                if A[i][k] + A[k][j] < A[i][j] :
                    return -1
                elif A[i][k] + A[k][j] == A[i][j] :
                    s += A[i][j]
                    break
    tot = 0
    for i in range(N) :
        for j in range(i + 1, N) :
            tot += A[i][j]
    return tot - s
    
print(judge())


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

int main (){
    long long N;

    pair<int,int> p[100007];

    cin >> N;
    
    for(int i=1;i<=N;i++){
        cin >> p[i-1].first;
        p[i-1].second = i;
    }

    sort(p,p+N);
    
    for(int i=1;i<=N;i++){
        cout << p[i-1].second << " ";
    }

    cout << endl;

}

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

int N, l[2002]; ll ans = 0;
int main(){
    scanf("%d", &N);
    for (int i = 0; i < N; i++)scanf("%d", &l[i]);
    sort(l, l+N);
    for (int i = 0; i < N-2; i++) {
        int k = i+2;
        for (int j = i+1; j < N; j++) {
            while (k<N && l[i]+l[j]>l[k]) k++;
            if(k>j) ans += k-j-1;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string str;
	string res("");
	cin >> str;
	bool a = true;
	for (auto c : str) 
	{
		if (a) res += c;
		a = !a;
	}
	cout << res << endl;
	return 0;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    bool check[n+1];
    fill(check,check+n+1,false);
    for(int i=0; i<k; i++){
        int d;
        cin >> d;
        for(int j=0; j<d; j++){
            int a;
            cin >> a;
            check[a] = true;
        }
    }
    int ans = 0;
    for(int i=1; i<n+1; i++){
        if(check[i]==false) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

/*-------------------Define Start-------------------*/
typedef bool BL;    					// 布尔类型
typedef char SB;    					// 有符号1字节,8位
typedef unsigned char UB;    			// 无符号1字节,8位
typedef short SW;    					// 有符号短整型,16位
typedef unsigned short UW;    			// 无符号短整型,16位
typedef long SDW;    					// 有符号整型,32位
typedef unsigned long UDW;   			// 无符号整型,32位
typedef long long SLL;    				// 有符号长整型,64位
typedef unsigned long long ULL;			// 无符号长整型,64位
typedef char CH;    					// 单个字符
typedef float R32;    					// 单精度浮点数
typedef double R64;    					// 双精度浮点数

#define Rep(i, n) for (register SDW i = 0; i < (n); ++i)
#define For(i, s, t) for (register SDW i = (s); i <= (t); ++i)
#define rFor(i, t, s) for (register SDW i = (t); i >= (s); --i)
#define foreach(i, c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,0x7f,sizeof(a))
#define LOWBIT(x) ((x)&(-x))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second

#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl

const ULL mod = 1e9 + 7;				//常用模数(可根据题目需要修改)
const ULL inf = 0x7fffffff;				//用来表示无限大
const ULL infLL = 0x7fffffffffffffffLL;	//用来表示无限大
/*-------------------Define End-------------------*/

const UDW maxN = 1e6 + 7;
UDW N;
set< UDW > s;
string ans;

void input(){
	UDW tmp;
	
	cin >> N;
	Rep(i, N) {
		cin >> tmp;
		s.insert(tmp);
	}
}

void solve(){
	if((UDW)s.size() == N) {
		ans = "YES";
	}
	else {
		ans = "NO";
	}
}

void output(){
	cout << ans << endl;
}

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

Measured memory_bytes: 9600
def main():
    n,k=map(int,input().split(' '))
    b=list(input())
    ans = 0
    cnt = 0
    tmp = b[0]
    for i in range(1,n):
        if tmp == b[i]:
            ans += 1
        else:
            cnt += 1
            tmp = b[i]
    print(ans+min(2*k,cnt))

if __name__ == '__main__':
    main()

Measured memory_bytes: 4084
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<vector<pii>> test(N, vector<pii>());
    rep(i, N) {
        int A;
        cin >> A;
        rep(j, A) {
            int x, y;
            cin >> x >> y;
            x--;
            test[i].pb(MP(x, y));
        }
    }

    int res = 0;
    for(int bit = 0; bit < (1 << N); bit++) {
        vector<int> honest(N);
        rep(i, N) {
            if(bit & (1 << i))
                honest[i] = 1;
        }
        int ok = 1;
        rep(i, N) {
            if(honest[i]) {
                rep(j, test[i].size()) {
                    if(test[i][j].second) {
                        if(!honest[test[i][j].first])
                            ok = 0;
                    } else {
                        if(honest[test[i][j].first])
                            ok = 0;
                    }
                }
            }
        }
        if(ok)
            res = max(res, __builtin_popcount(bit));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 1005;
int arr[15][MAX];
int pre[15][MAX];

int calc(int x1, int y1, int x2, int y2)
{
	return (pre[x2][y2] - pre[x2][y1 - 1] - pre[x1 - 1][y2] + pre[x1 - 1][y1 - 1]);
}
int main()
{
	boost;
	int h, w, k, i, j;
	cin >> h >> w >> k;
	foe(i, 1, h) {
		string s;
		cin >> s;
		foe(j, 1, w)
		arr[i][j] = s[j - 1] - '0';
	}
	foe(i, 1, h) {
		int sum = 0;
		foe(j, 1, w) {
			sum += arr[i][j];
			pre[i][j] = pre[i - 1][j] + sum;
		}
	}
	int n = h - 1;
	vector <vector <int> > v;
	fo(i, 0, (1 << n)) {
		vector <int> w;
		fo(j, 0, n) {
			if((i & (1 << j)))
			w.pb(j + 1);
		}
		reverse(all(w));
		w.pb(0);
		reverse(all(w));
		w.pb(h);
		v.eb(w);
	}
	int ans = inf;
	for(auto q : v) {
		int prev = 1;
		int cnt = 0;
		bool poss = true;
		for(j = 1; j <= w; j++) {
			for(int i = 0; i + 1 < q.size(); i++) {
				int area = calc(q[i] + 1, prev, q[i + 1], j);
				if(area > k) {
					if(prev == j) {
						poss = false;
						break;
					}
					prev = j;
					cnt++;
				}
			}
			if(!poss) break;
		}
		if(poss) ans = min(ans, cnt + (int)q.size() - 2);
	}
	cout << ans;
}


Measured memory_bytes: 384