akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll k, t;
    cin >> k >> t;

    ll a[t];
    ll ma = 0;
    ll sum = 0;
    rep(i, 0, t){
        cin >> a[i];
        ma = max(a[i], ma);
        sum += a[i];
    }

    if(sum - ma < ma - 1){
        cout << ma - 1 - sum + ma << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;




}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    char s[100005];
    ll n,a,b;
    scanf("%lld%lld%lld%s",&n,&a,&b,s);
    // n=strlen(s);
    ll abr=0,pass=0;
    rep(i,0,n){
        if(s[i]=='c'){
            NO;
        }
        if(s[i]=='a'){
            if(pass<a+b){
                YES;
                pass++;
            }else NO;
        }
        if(s[i]=='b'){
            if(pass<a+b && abr<b){
                YES;
                pass++;
                abr++;
            }else{
                NO;
            }
        }
    }

    
    // printf("%lld\n");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <limits.h>
 
#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;



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

    double S = R * 2.0 * 3.141592;
    printf("%.10f\n", S);
}

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

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    vector<vector<char>> data(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> data[i][j];
        }
    }

    // 行を選ぶパターン
    vector<vector<int>> rp(1<<h);
    for (int i = 0; i < 1<<h; i++) {
        for (int j = 0; j < h; j++) {
            // i行目が選ばれている
            if (i & 1<<j) {
                rp[i].push_back(j);
            }
        }
    }

    // 列を選ぶパターン
    vector<vector<int>> cp(1<<w);
    for (int i = 0; i < 1<<w; i++) {
        for (int j = 0; j < w; j++) {
            // i行目が選ばれている
            if (i & 1<<j) {
                cp[i].push_back(j);
            }
        }
    }

    int res = 0;
    for (int i = 0; i < rp.size(); i++) {
        for (int j = 0; j < cp.size(); j++) {
            vector<vector<char>> tmpd = data;

            for (int k = 0; k < rp[i].size(); k++) {
                // rp[i][k]行目を赤く塗る
                for (int kk = 0; kk < w; kk++) {
                    tmpd[rp[i][k]][kk] = '-';
                }
            }
            for (int l = 0; l < cp[j].size(); l++) {
                for (int ll = 0; ll < h; ll++) {
                    tmpd[ll][cp[j][l]] = '-';
                }
            }

            // 調査
            int cnt = 0;
            rep(i, h) {
                rep(j, w) {
                    if (tmpd[i][j] == '#') cnt++;
                }
            }
            if (cnt == k) res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3636
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll X, Y, Z, K;
vector<ll> A(X);
vector<ll> B(Y);
vector<ll> C(Z);

// おいしさP以上でK個以上作れるか
bool can_make(ll P){
    ll count = 0;
    FOR(i, 0, X){
        FOR(j, 0, Y){
            FOR(k, 0, Z){
                if(A[i]+B[j]+C[k]<P) break;
                count++;
                if(count>=K) return true;
            }
        }
    }
    return false;
}

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

    // input
    cin >> X >> Y >> Z >> K;
    A.resize(X);
    B.resize(Y);
    C.resize(Z);
    
    FOR(i, 0, X){
        cin >> A[i];
    }
    FOR(i, 0, Y){
        cin >> B[i];
    }
    FOR(i, 0, Z){
        cin >> C[i];
    }
    sort(ALL(A), greater<ll>());
    sort(ALL(B), greater<ll>());
    sort(ALL(C), greater<ll>());

    ll left = 0; // P個以上絶対に選べる
    ll right = inf;
    while(left+1!=right){
        ll center = (left + right) / 2;
        if(can_make(center)){
            left = center;
        }else{
            right = center;
        }
    }

    vector<ll> answers;
    ll border = left;
    FOR(i, 0, X){
        FOR(j, 0, Y){
            FOR(k, 0, Z){
                ll taste = A[i]+B[j]+C[k];
                if(taste>border){
                    answers.push_back(taste);
                }
                else{
      
                    break;
                }
            }
        }
    }

    // 足りない分
    ll diff = K - answers.size();
    FOR(i, 0, diff){
        answers.push_back(border);
    }
    sort(ALL(answers), greater<ll>());

    for(ll a : answers){
        p(a);
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main(){
    int k, i, a, b;
    cin >> k >> a >> b;
    for(i=a; i<=b; i++){
        if(i % k == 0){
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> ht(n);
  long long ans=0;
  for(int i=0;i<n;i++){
    cin >> ht[i];
    if(i>0 && ht[i]<ht[i-1]){
      ans += ht[i-1]-ht[i];
      ht[i] = ht[i-1];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3952
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		int i = 0;
		while(true) {
			int div = n / (int) Math.pow(10, i);
			int mod = n % (int) Math.pow(10, i);
			if(div >= 10) {
				ans += Math.pow(10, i) * 9;
			} else if(div > 0) {
				ans += (div - 1) * Math.pow(10, i);
				ans += mod + 1;
				break;
			} else {
				break;
			}
			i += 2;
		}
		System.out.println(ans);
	}

}


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

int main() {
 int n,x,t;
 cin >> n >> x>>t;
 
 cout << (n+x-1)/x*t;


}

Measured memory_bytes: 3592
import java.util.*; 

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

        while(true){ 
            int a = sc.nextInt(); 
            int b = sc.nextInt(); 
            int c = sc.nextInt(); 
            int sum = a + b; 
            if(a == -1 && b == -1 && c== -1){ 
                break; 
            }else if(a == -1 || b == -1){ 
                System.out.println("F"); 
            }else{ 
                if(sum<30){ 
                    System.out.println("F"); 
                }else if(sum<50){ 
                    if(c<50){ 
                        System.out.println("D"); 
                    }else{ 
                        System.out.println("C"); 
                    } 
                }else if(sum<65){ 
                    System.out.println("C"); 
                }else if(sum<80){ 
                    System.out.println("B"); 
                }else{ 
                    System.out.println("A"); 
                } 
            } 
        } 
        sc.close(); 
    } 
}


Measured memory_bytes: 26196
# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys
import itertools

def main():
    k,s = map(int,sys.stdin.read().split())

    count = 0
    for x in xrange(k+1):
        for y in xrange(k+1):
            if x + y <= s:
                z = s - (x + y)
                if(z>=0 and z <= k):
                    count += 1
            else:
                break

    sys.stdout.write("%d" % count)

if __name__ == '__main__':
    main()  


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;
ll i,j,k;
ll mod=1000000007;

int main(){
    ll n;cin>>n;
    map<pair<ll,ll>,ll> H;
    vector<pair<ll,ll>> P(n);
    for(i=0;i<n;i++){
        ll x,y,h;
        cin>>x>>y>>h;
        P[i]=make_pair(x,y);
        H[make_pair(x,y)]=h;
    }

    ll h;
    for(i=0;i<=100;i++){
        for(j=0;j<=100;j++){
            for(k=0;k<n;k++){
                if(H[P[k]]!=0){
                    h=H[P[k]]+abs(P[k].first-i)+abs(P[k].second-j);
                    break;
                }
            }
            
            bool ok=true;
            for(k=0;k<n;k++){
                if(max(h-abs(P[k].first-i)-abs(P[k].second-j),(ll)0)!=H[P[k]]){
                    ok=false;
                }
            }
            if(ok){cout<<i<<" "<<j<<" "<<h<<endl;return 0;}
        }
    }

    return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let a = sc.array::<i64>(3);

    let ans = a.iter().max().unwrap() - a.iter().min().unwrap();

    println!("{}", ans);
}


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

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

vector<int> to[202020];
vector<int> ans;

// 第 2 引数を受け取らないとき, 自動的に p = -1 となる
void dfs(int v, int p = -1) {
  for(auto nv : to[v]) {
    // 自分の親へは辿らない
    if(nv == p) continue;
    ans[nv] += ans[v];
    dfs(nv, v);
  }
}

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

  int n, q; cin >> n >> q;
  rep(i, n-1) {
    int a, b; cin >> a >> b;
    a--, b--;
    // 無向グラフ
    to[a].push_back(b);
    to[b].push_back(a);
  }

  ans.resize(n);
  rep(i, q) {
    int p, x; cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);

  rep(i, n) {
    cout << ans[i] << (i == n-1 ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 23552
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//char arr[57][57];
int main(){
	Lancer();
	ll a, b, c, k, mx, res;
	cin >> a >> b >> c >> k;
	res = a + b + c;
	mx = max(a, max(b, c));
	res -= mx;
	while (k--)
	{
		mx *= 2;
	}
	res += mx;
	cout << res;
	cout << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) cin >> h[i];
    vector<ll> dp(N+1, INF);
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            if (i+j < N) dp[i+j] = min(dp[i+j], abs(h[i+j] - h[i]) + dp[i]);
        }
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 4308
#include <iostream>
#include <math.h>
#include <iomanip>

int main()
{
	double res, x1, y1, x2, y2;
	std::cin >> x1 >> y1 >> x2 >> y2;
	res = sqrt(pow(y2 - y1, 2) + pow(x2 - x1,2));
	std::cout << std::setprecision(6) << std::fixed << res << "\n";
    return 0;
}




Measured memory_bytes: 3264
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while ((buf = br.readLine())!=null) {
				int m = 1;
				int e = 1;
				int n = Integer.parseInt(buf);
				while (n>0) {
					int check = n&m;
					if (check == m) {
						System.out.print(e);
						if (n>1) System.out.print(" ");
					}
					n >>= 1;
					e <<= 1; 
				}
				System.out.println("");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

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

ll n,h[100001],dp[100001];

ll solve(ll i)
 {
    if(i>=n)
     {
      return mod;     
     }
    if(i==n-1)
     {
      return 0;     
     }
    if(dp[i]!=-1)
     {
         return dp[i];
     }
    return dp[i]=min(solve(i+1)+abs(h[i+1]-h[i]),solve(i+2)+abs(h[i+2]-h[i])); 
 }

int main() {
	// your code goes here
ll i;
cin>>n;
for(i=0;i<n;i++)
 {
  cin>>h[i];
  dp[i]=-1;
 }
cout<<solve(0); 
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	int max = 0;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		int m;
		cin >> m;
		if (m >= max) {
			sum++;
		}
		max = std::max(max, m);
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int inf = 1<<30;
const ll mod = 1000000007;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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() {
  int n; cin >> n;
  map<string,int> mp;
  rep(i,n) {
    string s; cin >> s;
    SORT(s);
    mp[s]++;
  }

  ll ans = 0;
  for (auto p : mp) {
    int s = p.second;
    ans += (ll)s*(s-1)/2;
  }

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

Measured memory_bytes: 11136
import scala.io.StdIn

object Main extends App {

  def solv(pd: Long) = aind.foldLeft(0L)((acc, ai) => acc + scala.math.abs(ai._1 - (pd + ai._2 + 1)))

  val n = StdIn.readLine().toInt
  val a = StdIn.readLine().split(" ").map(_.toLong)
  val aind = a.zipWithIndex

  //val r = aind.map( ai => scala.math.abs(ai._1 - (ai._2 + 1)))
  val r = aind.map(ai => ai._1 - (ai._2 + 1))
  //println(r.mkString(" "))
  //val ds = r.distinct.sorted
  val ds = r.sorted
  //println(ds.mkString(" "))
  val c = ds.length
  val r1 = if (c % 2 == 0) {
    //println("s1 :" + solv(ds(c / 2 - 1)))
    //println("s2 :" + solv(ds(c / 2)))

    scala.math.min(solv(ds(c / 2 - 1)), solv(ds(c / 2)))
  } else {
    solv(ds(c / 2))
  }


  println(r1)

  //val mina = for(d <- ind) yield solv(pd)

  //println(mina.toList.mkString(" "))

  //println(mina.min)

}


Measured memory_bytes: 84560
#include<iostream>
using namespace std;
int main (){
	int h,m,s,S;
	cin>>S;
	
	h=S/(60*60);
	m=(S-(h*3600))/60;
	s=(S-(h*3600))%60;
	
	cout<<h<<":"<<m<<":"<<s<<endl;
	
	
return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=1e5+7;

int a[N],n,ans;
int num[N];

int main(){
//	fileio("test");
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d",a+i);
		if(a[i]>n){
			++ans;
			continue;
		}
		++num[a[i]];
	}
	rep(i,1,n){
		if(num[i]<i) ans+=num[i];
		else ans+=num[i]-i;
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 640
//created by pyoxiao on 2020/05/03
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
int x;
vector<int> fac;
LL cal(int a, int b) {
    return a * a * a * a  + a * a * a * b + a * a * b * b + a * b * b * b + b * b * b * b;
}
void solve() {
    scanf("%d", &x);
    for(int i = 1; i * i <= x; i ++) {
        if(x % i == 0) {
            fac.pb(i);
            if(i != x / i)  fac.pb(x / i);
        }
    }
    for(auto it : fac) {
        int cur = x / it;
        for(int i = -1000; i <= 1000; i ++) {
            int b = i, a = i + it;
            if(cal(a, b) == cur) {
                printf("%d %d\n", a, b);
                return;
            }
        }
    }
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 3872
import math

def comb(n, r):
  return math.factorial(n) // math.factorial(r) // math.factorial(n - r)

N, M = map(int, input().split())
res = 0
if 2 <= N:
  res += comb(N, 2)
if 2 <= M:
  res += comb(M, 2)
print(res)

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) {
        cout << C << endl;
    } else if (A == C) {
        cout << B << endl;
    } else {
        cout << A << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest
import os
import itertools

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    n, k = map(int, input().split())

    if (n * (n - 1)) // 2 - (n - 1) < k:
        print(-1)
        return

    # 点の一覧(1~n)
    points = [i for i in range(1, n + 1)]

    # 辺の一覧(初期値：中心点から延びる辺の一覧)
    e = [(1, point) for point in points if not point == 1]
    # 辺の数
    cnt = len(e)

    # 増やせる辺の候補
    addables = itertools.combinations(points[1:], 2)

    # いくつ辺を追加するか
    # k= 6 = 増やさない。
    # k= 0 = 6回増やす。
    # つまり「(n * (n - 1)) / 2 - (n - 1) - k」だけ辺を増やす。
    adds = list(addables)[0:(n * (n - 1)) // 2 - (n - 1) - k]
    e += adds
    cnt += len(adds)

    print(cnt)

    for aa in e:
        print(str(aa[0]) + " " + str(aa[1]))


# テストクラス


class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """5 3"""
        output = """5
4 3
1 2
3 1
4 5
2 3"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """5 8"""
        output = """-1"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 77912
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 100000

int table[NUM+2],left_table[NUM+2],right_table[NUM+2];

int main(){

	int W;
	scanf("%d",&W);

	for(int i = 1; i <= W; i++)scanf("%d",&table[i]);

	left_table[0] = 0;

	for(int i = 1; i <= W; i++){
		if(table[i] == 0){
			left_table[i] = BIG_NUM;
		}else if(table[i] > 0){
			left_table[i] = max(0,left_table[i-1]-1);
		}else{
			left_table[i] = max(0,min(left_table[i-1]-1,abs(table[i])));
		}
	}

	right_table[W+1] = 0;
	for(int i = W; i >= 1; i--){
		if(table[i] == 0){
			right_table[i] = BIG_NUM;
		}else if(table[i] > 0){
			right_table[i] = max(0,right_table[i+1]-1);
		}else{
			right_table[i] = max(0,min(right_table[i+1]-1,abs(table[i])));
		}
	}

	ll ans = 0;
	for(int i = 1; i <= W; i++){
		if(table[i] > 0){
			ans += min(table[i],max(left_table[i],right_table[i]));
		}
	}

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

	return 0;
}



Measured memory_bytes: 4384
from collections import deque

H, W = map(int, input().split())

Map = [[] for _ in range(H)]
reached = [[False] * W for _ in range(H)]
q = deque()
cnt = 0
count = 0
tempList = []
for y in range(H):
    for i, x in enumerate(input()):
        Map[y].append(x)
        if x == "#":
            cnt += 1
            reached[y][i] = True
            if i + 1 < W and not reached[y][i + 1]:
                reached[y][i + 1] = True
                tempList.append((i + 1, y))

            if i > 0 and not reached[y][i - 1]:
                reached[y][i - 1] = True
                tempList.append((i - 1, y))

            if y + 1 < H and not reached[y + 1][i]:
                reached[y + 1][i] = True
                tempList.append((i, y + 1))

            if y > 0 and not reached[y - 1][i]:
                reached[y - 1][i] = True
                tempList.append((i, y - 1))
if cnt==H*W:
    print(0)
    exit()

q.append(tempList)


def BFS(blist):
    global count
    tList = []

    count += 1

    for (x, y) in blist:
        if x+1<W and not reached[y][x + 1]:
            reached[y][x + 1] = True
            tList.append((x + 1, y))

        if x-1>=0 and not reached[y][x - 1]:
            reached[y][x - 1] = True
            tList.append((x - 1, y))

        if y+1<H and not reached[y + 1][x]:
            reached[y + 1][x] = True
            tList.append((x, y + 1))

        if y-1>=0 and not reached[y - 1][x]:
            reached[y - 1][x] = True
            tList.append((x, y - 1))

    if tList:
        q.append(tList)


while q:
    BFS(q.popleft())

print(count)













Measured memory_bytes: 135968
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var a = o.m(n);
  a.sort((a,b)=>a[1]-b[1]);
  var t = 0;
  for(var i = 0; i < n; i++){
    t += a[i][0];
    if(t > a[i][1])return "No";
  }
  return "Yes";
}

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

int main() {
	long long N,M;
  	cin >> N >> M;
  
  	long long ans;
  
  	if(N >= 2) N -= 2;
  	if(M >= 2) M -= 2;
    ans = N * M;
  
   cout << ans << endl;
}


	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector <int> s(13,0);
    vector <int> h(13,0);
    vector <int> c(13,0);
    vector <int> d(13,0);
    
    int number;
    cin>>number;
    for(int i=1;i<=number;i++){
        string A;
        int B;
        cin>>A>>B;
        if(A=="S"){
            s[B-1]++;
        }
        else if(A=="H"){
            h[B-1]++;
        }
        else if(A=="C"){
            c[B-1]++;
        }
        else if(A=="D"){
            d[B-1]++;
        }
        
    }
    for(int i=0;i<13;i++){
        if(s.at(i)==0){
            cout<<"S"<<" "<<i+1<<endl;
        }
    }
    for(int i=0;i<13;i++){
        if(h.at(i)==0){
            cout<<"H"<<" "<<i+1<<endl;
        }
    }
    for(int i=0;i<13;i++){
        if(c.at(i)==0){
            cout<<"C"<<" "<<i+1<<endl;
        }
    }
    for(int i=0;i<13;i++){
        if(d.at(i)==0){
            cout<<"D"<<" "<<i+1<<endl;
        }
    }
   
}


Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long m = scanner.nextLong();

        if (m <= n * 2) {
            System.out.println(m / 2);
            return;
        }

        System.out.println(n + (m - 2 * n) / 4);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
string str;
int w[50][26];
int word[26];
int main(){
    cin.sync_with_stdio(false);
    int n;
    while(cin>>n){
        memset(w,0,sizeof(w));
        for(int i=0;i<n;i++){
            cin>>str;
            for(int j=0;j<str.length();j++){
                w[i][str[j]-'a']++;
            }
        }
        memset(word,0x3f,sizeof(word));
        for(int i=0;i<26;i++){
            for(int j=0;j<n;j++){
                word[i]=min(word[i],w[j][i]);
            }
        }
        string ans="";
        for(int i=0;i<26;i++){
            while(word[i]){
                ans+=char('a'+i);
                word[i]--;
            }
        }
        cout<<ans<<endl;
    }
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int i = 1;
    int x;

    while(1){
        scanf("%d", &x);
        if ( x == 0 /*|| 1<=x<=10000*/ ) break;
        printf("Case %d: %d\n",i ,x);
        i++;
    }

	return 0;
}


Measured memory_bytes: 2692
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int bitCount(uint bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);    //  2bitごとに計算
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);    //  4bitごとに計算
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);    //  8bitごとに計算
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);    //  16ビットごとに計算
    return (bits & 0x0000ffff) + (bits >> 16);    //  32ビット分を計算
}

int main(){
	int n,a[55]={};
	char ch[5]={'M','A','R','C','H'};
	cin>>n;
	string s;
	LL ans=0;
	int c=0;
	FOR(i,0,n){
		cin>>s;
		if(a[s[0]-'A']==0)c++;
		a[s[0]-'A']++;
	}
	if(c<3){
		cout<<0<<endl;
		return 0;
	}
	FOR(i,0,32){
		if(bitCount(i)!=3)continue;
		LL plus=1;
		FOR(j,0,5){
			if(((i>>j)&1))plus*=a[ch[j]-'A'];
		}
		ans+=plus;
	}
	cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A;
		int B;
		A = sc.nextInt();
		B = sc.nextInt();
		if(A <= B){
			System.out.println(0);
		}
		else if(A <= 2 * B){
			System.out.println(0);
		}
		else{
			System.out.println(A - 2 * B);
		}
	}
}



Measured memory_bytes: 22996
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        int x = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            x ^= arr[i];
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                sb.append(" ");
            }
            sb.append(x ^ arr[i]);
        }
        System.out.println(sb);
    }
}

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

int main(){
    unsigned long long X, money, year, rishi;
    cin >> X;
    money = 100;
    year = 0;
    while(money < X){
        rishi = money * 0.01;
        money += rishi;
        year++;
    }
    cout << year << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const int inf = 1e9 + 7;
const int mod = 998244353;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) exp(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
ll prime[100002];
ll exp(ll a,ll b);
void sieve(ll n);
ll gcd(ll a ,ll b);
ll countdigit(ll n);
vector<ll>ft;

ll mul(ll a, ll b){
    ll ans= ((a%mod)*(b%mod))%mod;
    return ans%mod;
}
ll sub(ll a, ll b){
    ll ans = (a-b+mod)%mod;
    return ans;
}
ll add(ll a,ll b){
    ll ans = (a+b)%mod;
    return ans;
}
ll fun(ll number) 
{     
      return (ll)log2(number)+1; 
} 
void solve(){
    ll k;
    cin >> k;
    string s="ACL";
    rep(i,0,k){
        cout<<s;
    }
    
    
}
int main()
{   
    flash;
    ll t=1;
    //ft.pb(1);
    //fact(10000001);
    //cin >> t;
    while(t--) { 
        solve();
    }
}

//
//
//
//
//
// IMPORTANT FUNCTIONS
ll exp(ll a, ll b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res%mod;
}
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
void sieve(ll n) {
    for(ll i=0;i<=n;i++) {
        prime[i]=1;
    }
    prime[0]=0;prime[1]=0;
    for(ll i=2;i<=n;i++) {
        if(prime[i]==1) {
            for(ll j=2;i*j<=n;j++) {
                prime[i*j]=0;
            }
        }
    }
}
ll countdigit(ll  n)
{
    return floor(log10(n) + 1);
}

Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static long solve(List<Long> scores, int K){
		long S = 0;
		for(long s : scores){
			S += s;
		}
		long ret = 0;
		if(S >= 0){
			int step = K / scores.size();
			if(step >= 2){
				ret = S * (step - 2);
				K -= (step - 2) * scores.size();
			}
		}else{
			K = Math.min(K, scores.size());
		}
//		System.out.println(ret+" "+K);
		long ret2 = S >= 0 ? 0 : Long.MIN_VALUE;
		for(int i = 0 ; i < scores.size() ; ++i){
			long sum = 0;
			for(int j = 0; j < K ; ++j){
				int ind = (i + j) % scores.size();
				long s = scores.get(ind);
				sum += s;
				ret2 = Math.max(ret2, sum);
			}
		}
		// 31455326818
//		System.out.println(ret+" "+ret2+" "+(ret + ret2 - 29507023469L));
		return ret + ret2;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int P[] = new int[N];
		long C[] = new long[N];
		for(int i = 0 ; i < N ; ++i){
			P[i] = sc.nextInt() - 1;
		}
		for(int i = 0 ; i < N ; ++i){
			C[i] = sc.nextLong();
		}
		boolean vis[] = new boolean[N];
		long ret = Long.MIN_VALUE;
		for(int i = 0 ; i < N ; ++i){
			if(vis[i]){
				continue;
			}
			List<Long> scores = new ArrayList<Long>();
			int cur = i;
			scores.add(C[cur]);
			vis[cur] = true;
			cur = P[cur];
			while(!vis[cur]){
				scores.add(C[cur]);
				vis[cur] = true;
				cur = P[cur];
			}
			ret = Math.max(ret, solve(scores, K));
		}
		System.out.println(ret);
	}
}


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


int main(){
	char ss[101];
	int i,c;
	c=0;
	while(0<=scanf("%s",ss)){
		for(i=0;i<=strlen(ss)-1;i++){
			if(ss[i]!=ss[strlen(ss)-i-1])break;
		}
		
		if(i==strlen(ss))++c;
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 0
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define ll long long

int main(void){
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    ll p[a],q[b],r[c];
    for(ll i = 0;i < a;i++)cin >> p[i];
    for(ll i = 0;i < b;i++)cin >> q[i];
    for(ll i = 0;i < c;i++)cin >> r[i];
    
    sort(p,p+a,greater<ll>());
    sort(q,q+b,greater<ll>());
    sort(r,r+c,greater<ll>());
    
    ll num0[x+y],num[x+y],num2 = 0,sum = 0;
    for(ll i = 0;i < x;i++)num0[i] = p[i],sum += p[i];
    for(ll i = 0;i < y;i++)num0[x+i] = q[i],sum += q[i];
    sort(num0,num0+(x+y),greater<ll>());
    
    num[0] = num0[0];
    for(ll i = 1;i < x+y;i++)num[i] = num[i-1] + num0[i];
    
    for(ll i = 0;i < c;i++){
        num2 += r[i];
        if(i == x+y)break;
        if(i+1 == x+y)sum = max(sum,num2);
        else {
            ll sum2 = num2 + num[(x+y-1)-(i+1)];
            sum = max(sum,sum2);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 5376
#include <stdio.h>
#define M 10000
#define N -1

struct node{
    int p,l,r;
};

struct node tree[M];
int n;

void pre(int u){
    if(u == N) return;
    printf(" %d",u);
    pre(tree[u].l);
    pre(tree[u].r);
}

void in(int u){
    if(u == N)return;
    in(tree[u].l);
    printf(" %d",u);
    in(tree[u].r);
}

void post(int u){
    if(u == N) return;
    post(tree[u].l);
    post(tree[u].r);
    printf(" %d",u);
}

int main(){
    int i,s,t,u,root;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        tree[i].p=N;
    }

    for(i=0;i<n;i++){
        scanf("%d %d %d",&s,&t,&u);
        tree[s].l=t;
        tree[s].r=u;
        if(t != N)tree[t].p=s;
        if(u != N)tree[u].p=s;
        }

        for(i=0;i<n;i++){
            if(tree[i].p==N)root = i;
        }
        printf("Preorder\n");
        pre(root);
        printf("\n");
        printf("Inorder\n");
        in(root);
        printf("\n");
        printf("Postorder\n");
        post(root);
        printf("\n");

        return 0;
	
}


Measured memory_bytes: 2112
// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int H, W;
int V = 10;
int a[200][200];
int d[10][10];

void warshall_floyd()
{
    REP(k, V){
        REP(i, V){
            REP(j, V){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

void init()
{
}

void solve()
{
    warshall_floyd();
    int ans = 0;
    REP(i, H){
        REP(j, W){
            if(a[i][j] != -1) ans += d[a[i][j]][1];
        }
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    REP(i, 10){
        REP(j, 10){
            cin >> d[i][j];
        }
    }
    REP(i, H){
        REP(j, W){
            cin >> a[i][j];
        }
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> L(n);
    for(int i=0;i<n;i++) cin>>L[i];
    sort(L.begin(),L.end());
    long long ans=0;
    for(int i=0;i<=n;i++){
        for(int j=i+1;j<n;++j){
            int r=lower_bound(L.begin(),L.end(),L[j]+L[i])-L.begin();
            ans+=(r-1)-j;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = ["1"]*N
for i in range(N):
    s[i] = sorted(list(input()))
s = sorted(s)
ren = 1
ans = 0
for i in range(N-1):
    if(s[i] == s[i+1]):
        ren += 1
    else:
        ans += ren*(ren-1)/2
        ren = 1
ans += ren*(ren-1)/2
print(int(ans))

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

int main()
{
  unsigned long A, B, K;
  
  cin >> A >> B >> K;
  if (A <= K) {
    K -= A;
    A = 0;
  }
  else {
    A -= K;
    K = 0;
  }
  if (B <= K) {
    B = 0;
  }
  else {
    B -= K;
  }
  cout << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[100010];
    rep(i, N) cin >> a[i];
    int cnt4 = 0, cnt2 = 0, cnt1 = 0;
    rep(i, N) {
        if(a[i] % 4 == 0) cnt4++;
        else if(a[i] % 2 == 0) cnt2++;
        else cnt1++;
    }
    //cerr << cnt4<< " " << cnt2 << " " << cnt1 << endl;
    if(cnt4 > 0 && cnt2 > 0) cnt1++;
    if(cnt4 + (cnt4 > 0) >= cnt1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M,A,sum=0;
    cin >> N >> M;
    for(int i=0; i<M; i++){
        cin >> A;
        sum+=A;
    }
    if(sum>N){
        cout << -1;
    }else{
        cout << N-sum;
    }
    return 0;
}


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

int N, M;
vector<T> RLC;
int dp[100010];

struct segtree {
    int size;
    vector<int> node;
    
    segtree(int n) {
        size = 1;
        while (size<n) size *= 2;
        node.resize(2*size-1);
        fill(node.begin(), node.end(), 1000000000000000);
    }
    
    void update(int k, int a) {
        k += size-1;
        node[k] = a;
        while (k>0) {
            k = (k-1)/2;
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }
    
    int query(int a, int b, int k, int l, int r) {
        if (r<=a || b<=l) return 1000000000000000;
        if (a<=l && r<=b) return node[k];
        else {
            int vl = query(a, b, 2*k+1, l, (l+r)/2);
            int vr = query(a, b, 2*k+2, (l+r)/2, r);
            return min(vl, vr);
        }
    }
    
    int get(int a, int b) {
        return query(a, b, 0, 0, size);
    }
};
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, M) {
        int L, R, C; cin >> L >> R >> C;
        RLC.pb(make_tuple(R, L, C));
    }
    sort(RLC.begin(), RLC.end());
    rep(i, N) dp[i] = 1000000000000000;
    dp[0] = 0;
    segtree st(N);
    rep(i, N) st.update(i, dp[i]);
    
    rep(i, M) {
        int L = get<1>(RLC[i]), R = get<0>(RLC[i]), C = get<2>(RLC[i]);
        dp[R-1] = min(dp[R-1], st.get(L-1, R)+C);
        st.update(R-1, dp[R-1]);
    }
    if (dp[N-1]==1000000000000000) cout << -1 << endl;
    else cout << dp[N-1] << endl;
}

Measured memory_bytes: 8436
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int a,b,k;
    cin>>a>>b>>k;
    if(a>=k){
        cout<<a-k<<" "<<b<<endl;
    }else{
        cout<<0<<" "<<max(b-k+a,0ll)<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    int n;
    cin >> n;
    int t,x,y, t2,x2,y2;
    cin>> t >> x >> y ;

    if (n==1 && (x>1||y>1)){
        cout << "No" << endl;
        return 0;
    }

    rep(i, n-1){
       cin >> t2 >> x2 >> y2;
       if((abs(x2-x)+abs(y2-y) > abs(t2-t)) || (abs(t2-t)%2!=(abs(x2-x)+abs(y2-y))%2)){
           cout << "No" << endl;
           return 0;
       }else{
           t = t2;
           x = x2;
           y = y2;
       }

    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    string S;
    cin >> S;

    long long b_count = 0, w_count = 0;
    for (auto c: S) c == 'B' ? b_count++ : w_count++;

    long long sum_now = 0;
    for (int i = 0; i < S.size(); i++) if (S[i] == 'B')sum_now += i;

    long long sum_to = 0;
    for (int i = 0; i < b_count; i++) sum_to += (S.size() - 1 - i);

    cout << sum_to - sum_now << endl;

}



























Measured memory_bytes: 640