akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <sstream>
using namespace std;

#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C 9/++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()
 
//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(2e4+20)

#define fori(i,n) for(int i=0; i<n; i++)
#define forl(i,n) for(ll i=0; i<n; i++)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
const  llu int_max = pow(2,32) - 1 ;

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.ff < j.ff;
}
const int mod = 1e9 + 7 ;
int n,k ;
ll ans = 1;
std::vector<int> adj[100100];

void dfs(int v, int parent){
	int way = k-1; if(parent != -1) way-- ;
	for(int i=0; i < adj[v].size(); i++){
		int u = adj[v][i];
		if(u == parent)
			continue;
		
		ans *= way ;
		way--;
		ans = ans % mod;
		
		dfs(u,v);
	}

}

int main(){

	fastio
	cin>>n>>k;

	fori(i,n-1){
		int a,b ;
		cin>>a>>b;
		a--; b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	ans = k;
	dfs(0,-1);
	cout<<ans ;
	return 0;
	
}



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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif


#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1)
#define ld long double
#define prime (1000000000 + 7)

using namespace std;

#define INF 1000000000

struct UnionFind{
	vl pai;
	vl peso;
	vl rank;
	UnionFind(ll n): pai(n), peso(n), rank(n){
		iota(pai.begin(), pai.end(), 0);
		fill(peso.begin(), peso.end(), 1);
		fill(rank.begin(), rank.end(), 1);		
	}

	ll Find(ll n){
		if(pai[n] == n){
			return n;
		}
		return pai[n] = Find(pai[n]);
	}

	void Union(ll a, ll b){
		a = Find(a);
		b = Find(b);

		if(a != b){
			if(rank[a] < rank[b]){
				pai[a] = b;
				rank[b] += rank[a];
			} else{
				pai[b] = a;
				rank[a] += rank[b];	
			}
		}
		

	}
};


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

	ll n, m;
	cin >> n >> m;

	vll vet(m);
	vector<vl> listAdj(n);
	set<pll> pontC;
	for(auto &p: vet){
		cin >> p.ff >> p.ss;
		p.ff--;
		p.ss--;
	}
	ll res = (n*(n-1))/2;
	vl vetR(m);
	UnionFind uf(n);
	for(int i = m-1; i >= 0; --i){
		vetR[i] = res;
		if(uf.Find(vet[i].ff) != uf.Find(vet[i].ss)){
			W(uf.rank[uf.Find(vet[i].ff)], " ")
			W(uf.rank[uf.Find(vet[i].ss)], endl)
			res -= uf.rank[uf.Find(vet[i].ff)] * uf.rank[uf.Find(vet[i].ss)];
			uf.Union(vet[i].ff, vet[i].ss);
		}
	}

	for(int i = 0; i < m; ++i){
		cout << vetR[i] << " ";
	}
	cout << endl;


	return 0;
}

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


int main() {
  string s; cin >> s;
  bool ans = true;
  for(int i = 0;i < s.size();i += 2){
  if(s.at(i) == 'L')ans = false;
  }
  for(int i = 1;i < s.size();i += 2){
  if(s.at(i) == 'R')ans = false;
  }
  if(ans)cout << "Yes" <<endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define VALS(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pf push_front
#define LLINF ((long long)1e18)
#define INF 1234567890ll
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define ll long long int 
#define ld long double
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define f first
#define s second
typedef pair <int, int> pi;
typedef pair <ll, ll> pl;
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
const int MOD = 1e9 + 7;


int main()
{
	bool f = true;
	IAMSPEED
	string str; cin >> str;
	int n = str.size();
	FOR(i, 0, n-1) {
		if (!(i % 2)) { // odd
			if (str[i] != 'R' && str[i] != 'U' && str[i] != 'D') f = false;
		} else {
			if (str[i] != 'L' && str[i] != 'U' && str[i] != 'D') f = false;
		}
	}
	if(f) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
// Problem : B - Trick or Treat
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

int n,k,d,vis[101],x;

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>d;
        for(int j=0;j<d;j++) cin>>x, vis[x] = 1;
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(!vis[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int n, k, a[100119][3], dp[100119][3];
int main() {
	cin >> n;
	memset(dp, -100000000, sizeof(dp));
	for (int i = 1; i <= n; i++) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	dp[1][0] = a[1][0];
	dp[1][1] = a[1][1];
	dp[1][2] = a[1][2];
	for (int i = 2; i <= n; i++) {
		dp[i][0] = max({dp[i][0], dp[i - 1][1] + a[i][0], dp[i - 1][2] + a[i][0]});
		dp[i][1] = max({dp[i][1], dp[i - 1][0] + a[i][1], dp[i - 1][2] + a[i][1]});
		dp[i][2] = max({dp[i][2], dp[i - 1][1] + a[i][2], dp[i - 1][0] + a[i][2]});
	}
	cout << max({dp[n][0], dp[n][1], dp[n][2]});
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int n,L;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> L;
    vi a(n+1);
    FOR(i,1,n+1) cin >> a[i];
    FOR(i,1,n) if (a[i]+a[i+1] >= L) {
        cout << "Possible\n";
        FOR(j,1,i) cout << j << "\n";
        FORd(j,i+1,n) cout << j << "\n";
        cout << i << "\n";
        exit(0);
    }
    cout << "Impossible";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#define Find order_of_key
#define at find_by_order
#define x first
#define y second
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'

int n,arr[200010],va[200010];
ll k;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	memset(va,-1,sizeof va);
	int last=1;
	va[1]=0;
	int i;
	bool ff=1;
	for(i=1;i<=k;i++){
		int id=arr[last];
		if(~va[id]){
			ff=0;
			break;
		}
		va[id]=i;
		last=id;
	}
	if(ff){
		cout<<last<<endl;
	}
	else{
		// last=arr[last];
		ll p=i-va[arr[last]];
		ll valll=((k-va[arr[last]])%p)+va[arr[last]];
		for(int i=1;i<=n;i++){
			if(va[i]==valll)cout<<i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5196
N = int(input())
H = list(map(int, input().split()))

DP = [0] * N
DP[1] = abs(H[1]-H[0])
for i in range(2, N):
  DP[i] = min(DP[i-1]+abs(H[i]-H[i-1]), DP[i-2]+abs(H[i]-H[i-2]))
print(DP[N-1])

Measured memory_bytes: 13980
# -*- coding:utf-8 -*-

def solve():
    N, K = list(map(int, input().split()))
    Hs = list(map(int, input().split()))

    Hs.sort(reverse=True)

    ans = 0
    for h in Hs:
        if K > 0:
            K -= 1
            continue
        ans += h
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 26764
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll long long
#define P pair<int,int>
#define cat(p) cout<<p<<endl
#define catA(p,n) for(int i=0;i<n;i++)cout<<p[i]<<((i==n-1)?"\n":" ")

string s;
int cnt[30];

int main(){
  cin>>s;
  sort(s.begin(),s.end());
  if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
def main():
	N = int(input())
	S = [""]*N
	cards = defaultdict(int)
	for i in range(N):
		S[i] = input()
		cards[S[i]] += 1
	M = int(input())
	T = [""]*M
	for i in range(M):
		T[i] = input()
		cards[T[i]] -= 1

	ans = 0
	for v in cards.values():
		ans = max(ans, v)

	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 3316
N, M = map(int,input().split())

routes = list()
for i in range(M):
    routes.append(list(map(int,input().split())))

score = [0,0] + [10**13] * (N-1)
negative = [False] * (N+1)

for i in range(N-1):
    for a,b,c in routes:
        if(score[b] > score[a] - c):
            score[b] = score[a] - c

ans = -score[N]
            
for i in range(N):
    for a,b,c in routes:
        if(score[b] > score[a] - c):
            score[b] = score[a] - c
            negative[b] = True
        if(negative[a] == True):
            negative[b] = True

if(negative[N] == True):
    print("inf")
else:
    print(ans)

Measured memory_bytes: 3572
import java.io.*;
import java.util.*;

public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;

  private static PrintWriter _err = new PrintWriter(System.err);

  private void solve(Scanner sc, PrintWriter out) {
    int N = sc.nextInt();
    int K = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();

    if (N >= K) {
      out.println((X * K + Y * (N - K)));
    } else {
      out.println((X * N));
    }
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  private long ceil2pow(long n) {
    if (n == 0) {
      return 1;
    }
    n--;
    n |= (n >>> 1);
    n |= (n >>> 2);
    n |= (n >>> 4);
    n |= (n >>> 8);
    n |= (n >>> 16);
    n++;
    return n;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();

    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 9808
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long 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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=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 {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

/* -- template -- */
vector<ll>ans;
ll N;

bool is753num(ll x) {
    bool flg3 = false, flg5 = false, flg7 = false;
    while(x > 0) {
        if(x % 10 == 3)flg3 = true;
        else if(x % 10 == 7)flg7 = true;
        else if(x % 10 == 5)flg5 = true;
        x /= 10;
    }
    return flg3 && flg7 && flg5;
}

void dfs(ll x) {
    if(x > N)return;
    if(is753num(x))ans.pb(x);
    rep(i, 3) {
        dfs(x * 10 + 3 + 2*i);
    }
}

int main() {
    cin >> N;
    dfs(0);
    cout << ans.size() << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto& i:k)
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

signed main() {
	int n;
	cin >> n;
	n--;
	int ans=0;
	REP(i,n){
		ans+=i+1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
N = len(s)
a = 0
for x in range(0,N,2):
    if s[x] == "L":
        a = 1
for x in range(1,N,2):
    if s[x] == "R":
        a = 1
if a == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
 
int main()
{
	int n;
	cin>>n;
	int ac=0,wa=0,tle=0,re=0;
	string s;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		if(s=="AC")
			ac++;
		if(s=="WA")
			wa++;
		if(s=="TLE")
			tle++;
		if(s=="RE")
			re++;
	}
	cout<<"AC x "<<ac<<endl; 
	cout<<"WA x "<<wa<<endl; 
	cout<<"TLE x "<<tle<<endl; 
	cout<<"RE x "<<re<<endl; 
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>
#include<queue>
#define mod 998244353
#define pb push_back
#define ll long long
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> a,aso;
	map<int,int> b;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	aso = a;
	sort( aso.begin(), aso.end() ) ;
	for(int i=0;i<n;i++){
		b[aso[i]]=i;
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if( i%2 == b[a[i-1]] % 2 ) cnt++;
	}
	cout<<cnt/2<<endl;
	return 0;
}

Measured memory_bytes: 5752
import java.util.Scanner;

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

		for (int i = 0; i < S.toCharArray().length; i++) {
			System.out.print((char)((S.toCharArray()[i] + N - 65) % 26 + 65));
		}

		System.out.println();
	}
}


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

using namespace std;

int main()
{
    string s;
    int len, num = 0;
    int max = 0;

    cin >> len >> s;

    for (int i=0; i<len; ++i)
    {
        num = (s[i] == 'I') ? num + 1 : num - 1;
        if (max < num ) max = num;
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	//n := r.nextInt()
	r.Scan(true)
	l := r.nextStringArray().toInts()

	sort.Sort(sort.Reverse(sort.IntSlice(l)))

	bFind := func(a []int, n int) int {
		return sort.Search(len(a), func(i int) bool {
			return n > a[i]
		})
	}

	ans := 0
	for i := range l {
		for j, endJ := i+1, len(l); j < endJ; j++ {
			w := l[i] - l[j] + 1
			x := bFind(l[j+1:], w)
			ans += x
		}
	}
	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 640
#!/usr/bin/env python3

def main():
    S = input()

    len_S = len(S)
    i = j = j0 = int(len_S / 2)
    if len_S % 2 == 0:
        i -= 1

    c = S[i]
    while 0 <= i and j < len_S and c == S[i] and c == S[j]:
        i -= 1
        j += 1

    print(j)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

ll K, S, ans;
void solve() {
	for (ll x = 0; x <= K; x++) {
		for (ll y = 0; y <= K; y++) {
			ll z = S - x - y;
			if (K >= z && z >= 0) ans++;
		}
	}
	cout << ans << endl;
}

int main() {
	cin >> K >> S;
	solve();
	return 0;
}




Measured memory_bytes: 256
using System;
namespace kozaiyApp
{
    public class A
    {
        static void Main()
        {
            // 2 * 半径 * 円周率: Math.PI
            int R = int.Parse(Console.ReadLine());
            double ans = 2 * R * Math.PI;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 27604
import sys                                               
for i in sys.stdin:
    lst = i.split(' ')
    lst = map(int, lst)
    lst.sort()

    n = 1
    maxn = 1
    while n*n <= lst[0]:
        if lst[0]%n == 0 and lst[1]%(lst[0]/n) == 0:
            print lst[0]/n
            break
        elif lst[0]%n == 0 and lst[1]%n == 0:
            maxn = n
        n = n+1
    else:
        print maxn
    sys.exit(0)

Measured memory_bytes: 6448
#include <bits/stdc++.h>
using namespace std;
#define int long long
int x[5],ans;

signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		if(s[0]=='M')x[0]++;
		else if(s[0]=='A')x[1]++;
		else if(s[0]=='R')x[2]++;
		else if(s[0]=='C')x[3]++;
		else if(s[0]=='H')x[4]++;
	}
	for(int i=0;i<5;i++){
		for(int j=i+1;j<5;j++){
			for(int k=j+1;k<5;k++){
				ans+=x[i]*x[j]*x[k];
			}
		}
	}
	cout<<ans<<endl;
}

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

using ll = int64_t;
const int MAX = 2e5;

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n; cin >>n;
    if (n >= 30) cout << "Yes";
    else cout << "No";


    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

bool ok=true;
ll n,a[100010];

void init(){
	cin>>n;
	rep(i,n)cin>>a[i];
}

int main(void){
	init();
	rep(i,n){
		if(a[i]%2==0){
			if(a[i]%3!=0 && a[i]%5!=0)ok=false;
		}
	}
	cout<<(ok?"APPROVED":"DENIED")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 100100
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define INF 1000000
using namespace std;

	int A[MAXN],B[MAXN],C[MAXN];
	int dp[MAXN][4];
int32_t main(){
	fastio;
	int n;
	cin>>n;
	memset(dp,-INF,sizeof(dp));
	for(int i=1;i<=n;i++){
		cin>>A[i]>>B[i]>>C[i];
	}
	dp[0][1]=dp[0][2]=dp[0][3]=dp[0][0]=0;
	dp[1][1]=A[1];
	dp[1][2]=B[1];
	dp[1][3]=C[1];
	
	for(int i=2;i<=n;i++){
	dp[i][1]=max(dp[i-1][2],dp[i-1][3])+A[i];
	dp[i][2]=max(dp[i-1][3],dp[i-1][1])+B[i];
	dp[i][3]=max(dp[i-1][1],dp[i-1][2])+C[i];
	}	
	int res=max(dp[n][1],max(dp[n][2],dp[n][3]));
	cout<<res<<endl;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main(){
  int n,i,j,c = 0,minj,tmp;
  scanf("%d",&n);
  int r[n];
  for(i = 0; i < n; i++){
    scanf("%d",&r[i]);
  }
  for(i = 0; i < n; i++){
    minj = i;
    for(j = i; j < n; j++){
      if(r[j] < r[minj]){
        minj = j;
      }
    }
    if(r[i] != r[minj]){
      tmp = r[i];
      r[i] = r[minj];
      r[minj] = tmp;
      c++;
    }
  }
  for(i = 0; i < n; i++){
    printf("%d",r[i]);
    if(i == n - 1){
      printf("\n");
      break;
    }
    printf(" ");
  }
  printf("%d\n",c);
  return 0;
}



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

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a(n+1);
    for (int i = 0; i < n; i++) {
        if (s[i] == '<') {
            a[i+1] = max(a[i]+1, a[i+1]);
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '>') {
            a[i] = max(a[i], a[i+1]+1);
        }
    }
    long ans = 0; 
    for (int i = 0; i <= n; i++) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
 int main(){
   int X,Y,sum=0;
   cin >> X >> Y;
   if(X == 1)
   sum += 300000;
   if(X == 2)
   sum += 200000;
   if(X == 3)
   sum += 100000;
   if(Y == 1)
   sum += 300000;
   if(Y == 2)
   sum += 200000;
   if(Y == 3)
   sum += 100000;
   if(X == 1 && Y == 1)
   sum += 400000;
   cout << sum << endl;
}

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

struct UF {
	vector<int> p;
	UF(int n) : p(n, -1) {}
	int find(int a) {
		return p[a] < 0 ? a : (p[a] = find(p[a]));
	}
	bool join(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return false;
		if (-p[a] < -p[b]) swap(a, b);
		p[a] += p[b];
		p[b] = a;
		return true;
	}
};

string s;
int n;
int m;

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> s;
	n = int(s.size());
	s = "a" + s + "a";
	vector<int> diffs(n+1);
	for (int i = 0; i <= n; i++) {
		diffs[i] = int(s[i+1] - s[i]);
	}

	UF uf(n+1);
	for (int i = 0; i <= n; i++) uf.join(i, n-i);
	cin >> m;
	for (int j = 0; j < m; j++) {
		int l, r;
		cin >> l >> r;
		l--;
		uf.join(l, r);
	}
	vector<int> tot(n+1, 0);
	for (int i = 0; i <= n; i++) {
		tot[uf.find(i)] += diffs[i];
	}
	for (int i = 0; i <= n; i++) {
		if (uf.find(i) != i) continue;
		if (tot[i] % 26 != 0) {
			cout << "NO" << '\n';
			exit(0);
		}
	}
	cout << "YES" << '\n';
}


Measured memory_bytes: 4952
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b;
  int ans = -1;
  cin >> a >> b;
  for (int i = 0; i < 1009; i++) {
    int c = i * 0.08;
    int d = i * 0.1;
    if (a == c && b == d) {
      ans = i;
      break;
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


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

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=1e5+5;



int main()
{ 

IOS;


ll n;cin>>n;

ll s=0;

for(ll j=1;j*j<=n;j++){
  if(n%j==0){
    ll d1=j;
    ll d2=n/j;
    if(d1>1&&(n/(d1-1))*(d1)==n)s+=(d1-1);
    if(d2>1&&(n/(d2-1))*(d2)==n)s+=(d2-1);
  }
}
cout<<s;

//end_routine();

return 0;
 
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;

int main() {
    int n;
    cin >> n;
    int sum = 0, mini = INT_MAX;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        sum += x;
        if (x % 10) {
            mini = min(mini, x);
        }
    }
    if (sum % 10) {
        cout << sum;
    } else if (mini != INT_MAX) {
        cout << sum - mini;
    } else {
        cout << 0;
    }

    return 0;
}

Measured memory_bytes: 256
#define inf 10000000
#include <stdio.h>
int main(void){
    long long int n,m,ans=0;
    scanf("%lld %lld",&n,&m);
    if(n*2<=m){
        ans+=n;
        m=m-2*n;
        ans=ans+m/4;
    }else{
        ans=m/2;
    }
    printf("%lld\n",ans);
    return 0;
}

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

int main(){
    ll n, p;
    string s;
    cin >> n >> p >> s;
    
    if(p == 2 || p == 5){
        ll ans = 0;
        rep(i,n){
            if((int)(s[i] - '0') % p == 0) ans += i + 1;
        }
        cout << ans << endl;
        return 0;
    }

    vector<ll> sum(n+1, 0), ten(n+1, 1);
    for(int i = n-1; i >= 0; i--){
        ten[i] = ten[i+1] * 10 % p;
    }
    for(int i = n-1; i >= 0; i--){
        sum[i] = ((ll)(s[i] - '0') * ten[i+1] % p + sum[i+1]) % p;
    }
    map<ll,ll> m;
    for(auto i : sum){
        m[i]++;
    }
    ll ans = 0;
    for(auto i : m){
        ans += i.second * (i.second - 1) / 2;
    }
    cout << ans << endl;
}

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

typedef long long ll;

char buf[222];
int n;
int cnt;
vector<char> op;
bool counter(char c){
  if( cnt >= n ) return false;
  if( buf[cnt] == c ) { cnt++; return true; }
  return false;
}

ll number(){
  ll num = 0;
  while( '0' <= buf[cnt] && buf[cnt] <= '9' ){
    num *=10;
    num += buf[cnt++]-'0';
  }
  return num;
}

ll calc( ll a, ll b, char o ){
  if( o == '+' ) return a + b;
  if( o == '-' ) return a - b;
  return a * b;
}

ll op1();
ll op4();
ll op6();
ll op7();

ll kakko(){
  if( counter('(') ){
    ll a = op1();
    counter(')');
    return a;
  }
  return number();
}
ll kakko4(){
  if( counter('(') ){
    ll a = op4();
    counter(')');
    return a;
  }
  return number();
}
ll kakko6(){
  if( counter('(') ){
    ll a = op6();
    counter(')');
    return a;
  }
  return number();
}
ll kakko7(){
  if( counter('(') ){
    ll a = op7();
    counter(')');
    return a;
  }
  return number();
}


ll op3(){
  ll a = kakko();
  while( counter( op[2] ) ) {
    ll b = kakko();
    a = calc( a, b, op[2] );
  }
  return a;
}

ll op2(){
  ll a = op3();
  while( counter( op[1] ) ) {
    ll b = op3();
    a = calc( a, b, op[1] );
  }
  return a;
}

ll op1(){
  ll a = op2();
  while( counter( op[0] ) ) {
    ll b = op2();
    a = calc( a, b, op[0] );   
  }
  return a;
}

ll op5(){
  ll a = kakko4();
  while( true ){
    if( counter( op[2] ) ) {
      ll b = kakko4();
      a = calc( a, b, op[2] );
    } else if( counter( op[1] ) ){
      ll b = kakko4();
      a = calc( a, b, op[1] );
    } else
      break;
  }
  return a;
}

ll op4(){
  ll a = op5();
  while( counter( op[0] ) ) {
    ll b = op5();
    a = calc( a, b, op[0] );
  }
  return a;
}

ll op8(){
  ll a = kakko6();
  while( counter( op[2] ) ) {
    ll b = kakko6();
    a = calc( a, b, op[2] );
  }
  return a;  
}

ll op6(){
  ll a = op8();
  while( true ){
    if( counter( op[1] ) ) {
      ll b = op8();
      a = calc( a, b, op[1] );
    } else if( counter( op[0] ) ){
      ll b = op8();
      a = calc( a, b, op[0] );
    } else
      break;
  }
  return a;
}

ll op7(){
  ll a = kakko7();
  while( true ){
    if( counter( op[0] ) ){
      ll b = kakko7();
      a = calc( a, b, op[0] );
    } else if( counter( op[1] ) ) {
      ll b = kakko7();
      a = calc( a, b, op[1] );
    } else if( counter( op[2] ) ){
      ll b = kakko7();
      a = calc( a, b, op[2] );
    } else 
      break;
  }
  return a;
}


int main(){
  cin >> buf;
  n = strlen(buf);
  op.push_back( '+' );
  op.push_back( '-' );
  op.push_back( '*' );
  sort(op.begin(),op.end());
  ll res = -LLONG_MAX;
  do {
    cnt = 0;
    res = max( res, op1() );
    cnt = 0;
    res = max( res, op4() );
    cnt = 0;
    res = max( res, op6() );
    cnt = 0;
    res = max( res, op7() );
  } while( next_permutation( op.begin(), op.end() ) );
  cout << res << endl;
}

Measured memory_bytes: 1200
#include <algorithm>
#include <iostream>
#include <string>
#include <queue>
#include <vector>

typedef struct {
  int parent = -1;
  int depth = 0;
  std::string type;
  std::vector<int> children;
} Node;

int main() {
  int n;
  std::cin >> n;
  std::vector<Node> tree(n);
  for (int i = 0; i < n; ++i) {
    int id, childs;
    std::cin >> id >> childs;
    for (int j = 0; j < childs; ++j) {
      int child;
      std::cin >> child;
      tree[id].children.push_back(child);
      tree[child].parent = id;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (tree[i].parent == -1) {
      tree[i].type = "root";
      std::queue<int> q;
      q.push(i);
      while(!q.empty()) {
        int id = q.front();  q.pop();
        tree[id].depth = (tree[id].parent == -1)
          ? 0 : (tree[tree[id].parent].depth + 1);
        for (int c : tree[id].children)
          q.push(c);
      }
    }
    else if (tree[i].children.size() > 0)
      tree[i].type = "internal node";
    else
      tree[i].type = "leaf";
  }
  for (int i = 0; i < n; ++i) {
    std::cout << "node " << i << ": parent = " << tree[i].parent <<
      ", depth = " << tree[i].depth << ", " << tree[i].type << ", [";
    for (int j = 0; j < (int)tree[i].children.size(); ++j)
      std::cout << tree[i].children[j] <<
        (j == (int)tree[i].children.size() - 1 ? "" : ", ");
    std::cout << "]" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 12116
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int N;
	cin >> N;
	
	long long int x0, x, s;
	cin >> x0 >> s;
	
	long long int mi = 0;
	long long int sum = s;
	long long int ans = s;
	
	for(int i = 1; i < N; i++){
		cin >> x >> s;
		mi = min(sum - (x - x0), mi);
		sum += s;
		ans = max(ans, sum - (x - x0) - mi);
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  if(S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3) ){
    cout << "Bad" << endl;
  }
  else{
    cout << "Good" << endl;
  }
}


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

int main(){
  ll n,m,k;cin>>n>>m>>k;
  vector<ll> a(n+1,0);
  vector<ll> b(m+1,0);
  ll asum=0,bsum=0;
  for(int i=1;i<=n;i++){
    ll ai;cin>>ai;
    asum+=ai;
    a[i]=asum;
  }
  for(int i=1;i<=m;i++){
    ll bi;cin>>bi;
    bsum+=bi;
    b[i]=bsum;
  }
  
  ll ans=0;ll cnt=m;
  for(ll i=0;i<=n;i++){
    ll ka=k-a[i];
    if(ka==0){ans=max(ans,i);cout<<ans<<endl;return 0;}
    else if(ka<0){cout<<ans<<endl;return 0;}
    for(ll j=cnt;j>=0;j--){
      ll kab=ka-b[j];
      if(kab>=0){ans=max(ans,i+j);cnt=j;break;}
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6424
# include <cstdio>
# include <climits>

int main() {
  int lo = INT_MAX, hi = INT_MIN;
  int n;
  for (int i = 0; i < 5; ++i) {
    scanf("%3d", &n);
    if (n > hi) { hi = n; }
    if (n < lo) { lo = n; }
  }
  int k;
  scanf("%3d", &n);
  if (hi - lo <= n) { printf("Yay!"); fflush(stdout); }
  else { printf(":("); fflush(stdout); }
  return 0;
}



Measured memory_bytes: 128
<?php
fscanf(STDIN, "%d %d %d", $number1, $number2, $number3);
fscanf(STDIN, "%d", $doubleTimes);
$maxNumber = max($number1, $number2, $number3);

$maxNumberCalc = $maxNumber * pow(2, $doubleTimes);

echo $number1 + $number2 + $number3 - $maxNumber + $maxNumberCalc."\n";

Measured memory_bytes: 4604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define LOCAL
#ifdef LOCAL
    #define DEBUG(...) printf(" "__VA_ARGS__)
#else
    #define DEBUG(...)
#endif /* LOCAL */
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
char str[100001];
int cnt[3];
int main(void)
{
	int len,p,i;
	scanf("%s",str);
	len=strlen(str);
	FOR(i,0,len) cnt[str[i]-'a']++;
	FOR(i,0,3){
		p=len-cnt[i];
		if(p<2*(cnt[i]-1)){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}
    
    


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <map>

using namespace std;

int main()
{
    bool S[13] = {}, H[13] = {}, C[13] = {}, D[13] = {};
    map<char, bool*> bits_of = { { 'S', S }, { 'H', H }, { 'C', C }, { 'D', D } };
    int n;

    scanf("%d\n", &n);

    for (int i = 0; i < n; i++) {
        char suit;
        int rank;

        scanf("%c %d\n", &suit, &rank);
        bits_of[suit][rank-1] = true;
    }

    for (char suit : { 'S', 'H', 'C', 'D' })
        for (auto i = 0; i < 13; i++)
            if (!bits_of[suit][i])
                cout << suit << ' ' << i+1 << endl;
}

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

using namespace std;
typedef long long ll;

int main(){
    string S; cin >> S;
    int sz = S.size();
    ll all_ptn = pow(2,sz-1);
    ll ans =0;
    reverse(S.begin(),S.end());

    for(int ptn=0; ptn<all_ptn; ptn++){
        ll d=1;
        for(int i=0; i<sz-1; i++){
            ans += (S.at(i) - '0')*d;
            if((ptn >> i)& 1) d=1;
            else d *= 10;
        }
        ans += (S.at(sz-1) -'0') *d;
    }
        
    cout << ans << endl;
}

Measured memory_bytes: 4056
N = int(input())
Blue = []
Red = []
for i in range(N) :
    a,b = map(int,input().split())
    Red.append([a,b])
for i in range(N) :
    c,d = map(int,input().split())
    Blue.append([c,d])

Blue = sorted(Blue)
Red = list(reversed(sorted(Red,key=lambda x: x[1])))

ans = 0
for i in range(N) :
    for j in range(N) :
        if j >= len(Red) :
            break
        if (Blue[i][0] > Red[j][0]) and (Blue[i][1] > Red[j][1]) :
            ans += 1
            Red.pop(j)
            break
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int n; cin >> n;
	vector<uint32_t> as(n);
	for (auto& a : as) {
		cin >> a;
	}

	FOR_DW(i, n - 2, 0) {
		if (as[i] > as[i + 1]) as[i]--;
		if (as[i] > as[i + 1]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;


	return 0;
}

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

int main() 
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a,b,c,d;
    while(cin >> a >> b >> c >> d)
        cout << (abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
int n,m=0;
char str[1050],print[105][1050];

void scf(char scfcommand[20],int scfa,int scfb)
{
	int i,len,j;
	char s,p[1050];
	if(strcmp(scfcommand,"print")==0)
	//if(scfcommand=="print")
	{
		for(i=0;i<=scfb-scfa;i++)
		{
			
			print[m][i]=str[i+scfa];
			//printf("%c",scfcommand[i]);
		}
		m++;
	}
	if(strcmp(scfcommand,"reverse")==0)
	//if(scfcommand=="reverse")
	{
		
		j=scfb;
		len=scfb-scfa+1;
		len/=2;
		
		for(i=scfa;i<=scfa+len-1;i++)
		{
			
			s=str[i];
			str[i]=str[j];
			str[j]=s;
			j--;
		}
	}
	if(strcmp(scfcommand,"replace")==0)
	//if(scfcommand=="replace")
	{
		scanf("%s",p);
		j=0;
		for(i=scfa;i<=scfb;i++)
		{
			str[i]=p[j];
			j++;
		}
	}
	return;
}
int main()
{
	int a,b,i,j;
	char command[20];
	scanf("%s",str);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%s",command);
		scanf("%d %d",&a,&b);
		scf(command,a,b);
	}
	for(i=0;i<=m-1;i++)
		puts(print[i]);
		
	
	return 0;
}


Measured memory_bytes: 2120
#include<iostream>                                        
using namespace  std;                                     
                                                          
int main(){                                               
  int n,m;                                                
  cin >> n >> m;                                          
  int gyoretu1[n][m];                                     
  int gyoretu2[m];                                        
  int gyoretu3[n] = {};                                   
                                                          
  for(int i=0;i<n;i++){                                   
    for(int j=0;j<m;j++){                                 
      cin >> gyoretu1[i][j];                              
    }                                                     
  }                                                       
                                                          
  for(int k=0;k<m;k++){                                   
    cin >> gyoretu2[k];                                   
  }                                                       
                                                          
  for(int l=0;l<n;l++){                                   
    for(int j=0;j<m;j++){                                 
      gyoretu3[l] += gyoretu1[l][j] * gyoretu2[j];        
    }                                                     
  }                                                       
                                                          
  for(int o=0;o<n;o++){                                   
    cout << gyoretu3[o] << endl;                          
  }                                                       
                                                          
  return 0;                                               
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
int main(){
   ll a,b,n;
   cin>>a>>b;
   bool f=0;
   rep(i,10001)if((i*8)/100==a&&(i*10)/100==b&&((i*8)/100)!=0){cout<<i<<endl;return 0;}cout<<-1<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,i,k,min,max;
    long long int sum = 0;
    scanf("%d",&n);
    for(i = 0;i<n;i++){
        scanf("%d",&k);
        sum += k;
        if(i == 0){
            min = k;
            max = k;
        } else {
            if(min > k){
                min = k;
            }
            if(max < k){
                max = k;
            }
        }
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}

Measured memory_bytes: 600
#include <iostream> 
#include <algorithm> 
#include <cstring> 
#include <cstdio>
#include <vector> 
#include <queue> 
#include <cstdlib> 
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime> 
#include <map> 
#include <set> 
using namespace std; 
#define lowbit(x) (x&(-x)) 
#define max(x,y) (x>y?x:y) 
#define min(x,y) (x<y?x:y) 
#define MAX 100000000000000000 
#define MOD 1000000007
#define pi acos(-1.0) 
#define ei exp(1) 
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
string s,rs;
int main()
{
  cin>>s;
  rs=s;
  reverse(rs.begin(),rs.end());
  puts(rs==s?"Yes":"No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>
#include <map>

#pragma warning(disable:4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;

using namespace std;

int dx[4] = { 0, -1, 0, 1 };
int dy[4] = { 1, 0, -1, 0 };

const Int M_H(10);
const Int M_W(10000);

short tile[M_H][M_W];
bool all[M_H];
int H, W;

int main()
{
	cin.tie(0); ios::sync_with_stdio(false);
	//fstream fs("input.txt");
	//fstream fg("0525-input.txt");
	////////////ここから開始///////////
	//fs >> W >> H;
	while (cin >> H >> W, H && W){
		REP(i, M_H)REP(j, M_W)tile[i][j] = 2;
		REP(i, H)REP(j, W){ cin >> tile[i][j]; }
		
		Int ans(0),max_(0);

		for (int i = 0; i < 1 << H; ++i){
			short temptile[M_H][M_W];
			REP(m, H){ REP(n, W){ temptile[m][n] = tile[m][n]; } }
			ans = 0;
			for (int j = 0; j < H; ++j){
				all[H - j - 1] = i >> j & 1;
			}
			REP(m, H){
				if (all[m]){
					REP(n, W){
						if (temptile[m][n])
							temptile[m][n] = 0;
						else
							temptile[m][n] = 1;
					}
				}
			}
			int t(0);
			REP(n, W){
				t = 0;
				REP(m, H){
					t += temptile[m][n];
				}
				t = max(t, H - t);
				ans += t;
			}
			max_ = max(max_, ans);
		}
		cout << max_ << endl;
	}

	return 0;
}

Measured memory_bytes: 1580