akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> pairs;
#define mod 1000000007
typedef pair<ll,ll>pairs;
ll ans(ll n)
{
    ll p=1;;
    for(int i=1;i<=n;i++)
    {
        p*=i;
        p%=mod;
    }
    p*=p;
    p%=mod;
    return p;
}
int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,c,f;
	cin>>i>>j;
	if(llabs(i-j)==1)
	cout<<(ans(min(i,j))*max(i,j))%mod;
	else if(i==j)
	cout<<(ans(i)*2)%mod;
	else
	cout<<0;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,M; cin >> N >> M;
    vector<pll> edge(M);
    for(auto & in:edge){
        cin >> in.first >> in.second;
    }
    sort(edge.begin(),edge.end(),[](const pll& l,const pll& r){
        return l.second < r.second;
    });
    
    ll secl = 0;
    for(int i = 0; i < M;i++){
        if(edge[i].first >= secl){
            res++;
            secl = edge[i].second;
        }
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1792
import sys
import collections
n = int(input())
# s = []
dic = {}
s = []
for i in range(n):
    s.append(input())
c = collections.Counter(s)
values, counts = zip(*c.most_common())
if counts[0] == 1:
    for i in sorted(values):
        print(i)
else:
    for i in range(len(counts)-1):
        if counts[i] != counts[i+1]:
            stop = i
            break
    a = values[:i+1]
    for v in sorted(a):
        print(v)






Measured memory_bytes: 59504
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ l, r ] :: [Integer] <- map fromIntegral <$> readInts
	print $ minimum $ do
		a <- take 5000 [ l .. r ]
		b <- take 5000 [ l .. r ]
		guard $ a < b
		return $ a * b `mod` 2019

Measured memory_bytes: 2428
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
//#include"functions.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define INF 0x7fffffff
#define LLINF 0x7fffffffffffffff
#define EPS 1e-5
#define LDEPS 1e-9
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORN(a,m,n) for(int a=m;a<n;a++)
#define REP(a,m,n) for(int a=0;a<m;a+=n)
#define REPN(a,m,n,p) for(int a=m;a<n;a+=p)
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdfopen(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define ifopen(a) freopen(a,"r",stdin);
#define ofopen(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int a[100005];
int b[100005];
int main(){
	int n;
	ll ans=0,sum=0;
	cin>>n;
	for(int i=0;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	for(int i=0;i<n;i++){
		if(a[i]<=b[i]){
			//cout<<a[i+1]<<" "<<i<<endl;
			ans+=min(b[i]-a[i],a[i+1]);
			a[i+1]-=(b[i]-a[i]);
			if(a[i+1]<0)a[i+1]=0;
			ans+=a[i];
			//cout<<a[i]<<endl;
			a[i]=0;
		}
		else{
			//cout<<b[i]<<endl;
			ans+=b[i];
			a[i]=a[i]-b[i];
		}
	}
	ans+=b[n];
	cout<<min(ans,sum)<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int64_t> v1(n);
  vector<int64_t> v2(n);
  rep(i,n) cin >> v1[i] >> v2[i];
  sort(v1.begin(),v1.end());
  sort(v2.begin(),v2.end());
  if(n%2==0){
    int x=(v1[n/2-1]+v1[n/2]);
    int y=(v2[n/2-1]+v2[n/2]);
    cout << y-x+1 << endl;
  }
  else{
    int x=v1[n/2];
    int y=v2[n/2];
    cout << y-x+1 << endl;
  }
}

Measured memory_bytes: 6360
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
//typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) <<double値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n,m;
    cin >> n >> m;
    priority_queue<ll> a;
    rep(i,n){
        ll no;
        cin >> no;
        a.push(no);
    }

    rep(i,m){
        ll to;
        to = a.top();
        a.pop();
        a.push(to/2);
    }
    ll ans = 0;
    rep(i,n){
        ans += a.top();
        a.pop();
    }

    cout << ans;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
	  #define endl "\n"
	  #define ll long long int
	  #define mod 1000000007
	  #define inf 1000000000000000001;
	  using namespace std;
	  int main()
	  {
	    //  #ifndef ONLINE_JUDGE
	    //  // for getting input from input.txt
	    //  freopen("input.txt", "r", stdin);
	    //  // for writing output to output.txt
	    //  freopen("output.txt", "w", stdout);
	    // #endif
	    std::ios::sync_with_stdio(false);
	    cin.tie(NULL);
	    int a;
	    cin>>a;
	   

	   int L=a/100;
		int R=a%100;
		if(1<=L&&L<=12){
		if(1<=R&&R<=12)printf("AMBIGUOUS\n");
		else printf("MMYY\n");
		}else{
		if(1<=R&&R<=12)printf("YYMM\n");
		else printf("NA\n");
		}
		

	  
	
	    
	    return 0;
	  }


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

void appletopeach(string &s) {
    auto pos = s.find("apple");
    s.replace(pos, 5, "peach");
}

void peachtoapple(string &s) {
    auto pos = s.find("peach");
    s.replace(pos, 5, "apple");
}

int main() {
    string s;
    vector<string> v;
    while(cin >> s) {
        if (s.find("apple") != string::npos) {
            appletopeach(s);
            v.push_back(s);
        }else if (s.find("peach") != string::npos) {
            peachtoapple(s);
            v.push_back(s);
        }else {
            v.push_back(s);
        }
    }
    REP(i,v.size()-1) {
        cout << v[i] << " ";
    }
    cout << v[v.size()-1] << endl;
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <set>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const string YES = "yes";
const string NO = "no";

void solve(std::string S){
    set<char> str;
    REP(i, S.size())
        str.insert(S[i]);
    if (S.size() == str.size()) cout << YES << '\n';
    else cout << NO << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d; cin >> a >> b >> c >> d;
    int table[101] = {0};
    rrep(i, a, b + 1) table[i] = 1;
    rrep(i, c, d + 1) table[i]++;
    int cc = 0;
    rep(i, 101) if (table[i] == 2) cc++;
    
    cout << (cc == 0 ? 0 : cc - 1) << endl;
}


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


void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d){
  for(long long i = 0; i < N; i++) {
    long long mymin = LLONG_MAX;
    long long minidx;

    for(long long j = 0; j < M; j++) {
      long long current = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if(current < mymin){
        mymin = current;
        minidx = j;
      }
    }
    cout << minidx+1 << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> a(N);
  std::vector<long long> b(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&a[i]);
    scanf("%lld",&b[i]);
  }
  std::vector<long long> c(M);
  std::vector<long long> d(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&c[i]);
    scanf("%lld",&d[i]);
  }
    solve(N, M, std::move(a), std::move(b), std::move(c), std::move(d));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    int a_ = A % 10 > 0 ? 10 - (A % 10) : 0;
    int b_ = B % 10 > 0 ? 10 - (B % 10) : 0;
    int c_ = C % 10 > 0 ? 10 - (C % 10) : 0;
    int d_ = D % 10 > 0 ? 10 - (D % 10) : 0;
    int e_ = E % 10 > 0 ? 10 - (E % 10) : 0;
    cout << A + B + C + D + E + a_ + b_ + c_ + d_ + e_ - max({a_, b_, c_, d_, e_}) << endl;
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
const int MAX = 2000010;
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  ll N, M; cin >> N >> M;
  COMinit();

  ll ans = 1;
  for(ll i=2; i*i<=M; i++){
    
    if(M%i == 0){
      int cnt = 0;
      while(M%i == 0){
        cnt++;
        M /= i;
      }

      ans *= COM(cnt+N-1, N-1);
      ans %= MOD;
    }
    
  }

  if(M!=1){
    ans *= COM(N-1+1, N-1);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 50520
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	LL ans = 0;
	LL a, b, x;
	cin >> a >> b >> x;
	if (b == 0) puts("1"), exit(0);
	if (a == 0) ans++, a++;
	cout << ans + b / x - (a - 1) / x << endl;
	return 0;
}

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

using namespace std;

int main()
{
    string s, f = "First", sc = "Second";
    cin >> s;
    int len = s.size();
    if( (len - 2) % 2 ) {
        if(s[0] != s[len-1])
            cout << f;
        else
            cout << sc;
    }
    else {
        if(s[0] != s[len-1])
            cout << sc;
        else
            cout << f;
    }
}
/*
From the conclusion, the exclusive OR of "the length of s is even" and "the first and last characters of s are the same"
If true, the second player wins, and if false, the first player wins. This is shown below.
Consider the final s when either player becomes inoperable. The final s is
Two different characters should alternate, such as “abababab ...”. Because the same character from the rule
If there is no place where is adjacent, and if there is a place where three different characters are consecutive, such as “abc”, the middle character is still taken.
Because it can be removed.
The final length of s is not uniquely determined, but its evenness is uniquely determined. Specifically, with the first character of s
If the last character is the same, it will be an odd length like “ababa”, and if the first and last characters of s are different, it will be “ababab”.
It has an even length as shown in. From the above, since the evenness of the length of s is known at the beginning and the end, the evenness of the number of turns is also known.
I understand. Therefore, it is possible to find out which player will not be able to operate first.
*/

Measured memory_bytes: 3736
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>
#include<cmath>
#include<unordered_map>

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

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

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


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N,K,G,A;
  bool mx=false;
  cin>>N>>K;
  rep(i,N){
    if(i==0){
      cin>>G;
      if(G>=K)mx=true;
    }
    else{
      cin>>A;
      G=gcd(A,G);
      if(A>=K)mx=true;
    }
  }
  if(K%G==0&&mx)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << (x) << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;

#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> P) { for(auto const &vv: P)os<<"("<<vv.first<<","<<vv.second<<")"; return os; }
template<class T> ostream& operator<<(ostream &os, set<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 1000001

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int k,x;
    sc(k,x);
    vi lol;
    for(int i = max(-1000000,x-k+1); i <= min(1000000,x+k-1); ++i){
        cout << i << ' ';
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring> 
#include<cstdio>
#include<vector>
#define MN 200000
#define N 262144
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
vector<int> v[28];
char s[MN+5];long long ans;
int n,b[MN+5],T[N*2+5],num[28],oddnum,Num[28];
inline void Renew(int x,int v){for(T[x+=N]+=v;x>>=1;)T[x]=T[x<<1]+T[x<<1|1];}
inline int Query(int l,int r)
{
	int res=0;
	for(l+=N-1,r+=N+1;l^r^1;l>>=1,r>>=1)
	{
		if(~l&1) res+=T[l+1];
		if( r&1) res+=T[r-1];	
	}
	return res;
}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=1;i<=n;++i) ++num[s[i]-'a'];
	for(int i=0;i<26;++i) oddnum+=num[i]&1;
	if(oddnum>1) return 0*puts("-1");
	for(int i=n,rnum=0;i;--i) 
	{
		int x=s[i]-'a',p=num[x]-(Num[x]++);
		if(p*2-1==num[x]) ans+=(n/2-rnum);
		else if(p*2>num[x]) b[i]=1;
		if(!b[i]) v[x].push_back(i); else ++rnum;
	}
	for(int i=n,p=0;i;--i) if(b[i])
	{
	//	cout<<i<<" "<<b[i]<<endl;
		int match=v[s[i]-'a'].back(),pos=++p;
		v[s[i]-'a'].pop_back();
		int mm=match+Query(match,n);
		ans+=mm-pos;Renew(match,1);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2300
N=gets.to_i
M=10**9+7
*F=I=[r=1,t=1]
R=*I,*(2..N).map{|i|I<<z=M/i*-I[M%i]%M;F<<r=r*i%M;t=t*z%M}
(-~N/2...N).each{|i|r-=F[i-1]*R[2*i-N]*F[i]%M}
p r%M
###############################################
###############################################
###############################################
###############################################
###############################################

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








int main(){
  double a,b,x,y;
  cin>>a>>b>>x>>y;
  cout<<(a*b)/2<<" ";
  if(2*x == a && 2*y ==b)cout<<1<<endl;
                      else cout<<0<<endl;
}




  

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
    int k,s;
    int z;
    int ans=0;
    cin>>k>>s;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            z = s-x-y;
            if(z>=0&&z<=k){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int N, K, ans = 1234567890;
int A[101010];

int main(){
    scanf("%d %d", &N, &K);
    for (int i=1; i<=N; i++) scanf("%d", &A[i]);
    for (int i=1; i+K-1<=N; i++){
        if (A[i+K-1] < 0) ans = min(ans, -A[i]);
        else if (A[i] > 0) ans = min(ans, A[i+K-1]);
        else ans = min(ans, (-A[i]) + A[i+K-1] + min((-A[i]), A[i+K-1]));
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

vector<string> table;
int lsum[2001][2001];
int usum[2001][2001];
int rsum[2001][2001];
int dsum[2001][2001];

int main() {
  int R, C;
  while (cin >> R >> C) {
    memset(lsum, 0, sizeof(lsum));
    memset(usum, 0, sizeof(usum));
    memset(rsum, 0, sizeof(rsum));
    memset(dsum, 0, sizeof(dsum));
    table.clear();
    for (int i = 0; i < R; i++) {
      string s;
      cin >> s;
      table.push_back(s);
    }
    for (int r = 0; r < R; r++) {
      for (int c = 0; c < C; c++) {
        if (table[r][c] == '#') {
          continue;
        }

        if (c == 0) {
          lsum[r][c] = 1;
        } else {
          lsum[r][c] = lsum[r][c-1] + 1;
        }
        if (r == 0) {
          usum[r][c] = 1;
        } else {
          usum[r][c] = usum[r-1][c] + 1;
        }
      }
    }
    for (int r = R-1; r >= 0; r--) {
      for (int c = C-1; c >= 0; c--) {
        if (table[r][c] == '#') {
          continue;
        }
        dsum[r][c] = dsum[r+1][c] + 1;
        rsum[r][c] = rsum[r][c+1] + 1;
      }
    }
    int ans = 0;
    for (int r = R-1; r >= 0; r--) {
      for (int c = C-1; c >= 0; c--) {
        ans = max(ans, rsum[r][c] + lsum[r][c] + usum[r][c] + dsum[r][c] - 3);
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 66816
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <map>
#include <algorithm>  
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
double dp[3005][3005];
ll n;
double prob[3002];
double calc(ll idx,ll hcount,ll tcount)
{
    if(idx==n)
    {
        if(hcount>tcount)
        {
            return 1;
        }
        return 0;
    }
    if(dp[hcount][tcount]!=1.8)
    {
        return dp[hcount][tcount];
    }
    double ans1=prob[idx]*calc(idx+1,hcount+1,tcount);
    double ans2=(1.0-prob[idx])*calc(idx+1,hcount,tcount+1);
    dp[hcount][tcount]=ans1+ans2;
    return dp[hcount][tcount];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    for(ll i=0;i<3004;++i)
    {
        for(ll j=0;j<3004;++j)
        {
            dp[i][j]=1.8;
        }
    }
    cin>>n;
    for(ll i=0;i<n;++i)
    {
        cin>>prob[i];
    }
    cout<<fixed<<setprecision(10)<<calc(0,0,0)<<endl;
}






































Measured memory_bytes: 74500
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 105;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}

char x[maxn];

void solve()
{
	scanf("%s",x+1);
	int len = strlen(x+1);

	int fl=0;
	repp(i,1,len)
	{
		if(fl==0&&x[i]=='C')
		{
			fl=1;
		}
		if(fl==1&&x[i]=='F')
		{
			fl=2;
		}
	}
	if(fl==2)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
}

int main()
{

    solve();
    return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(s) (int)s.size()
#define endl '\n'

void PLAY() {

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int main() {
	PLAY();
	
	int a, b;
	cin >> a >> b;
	cout << 6 - (a + b) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

int N, Q, K;
vector<vector<pint>> adj;
vector<pint> xy;
vector<ll> dp;
vector<bool> visited;

void dfs(int v, int parent, ll distance) {
	for (auto &&to : adj[v]) {
		if (visited[to.first]) {
			continue;
		}
		visited[to.first] = true;

		if (to.first == parent) {
			continue;
		}

		dp[to.first] = distance + to.second;
		dfs(to.first, v, dp[to.first]);
	}

	return;
}

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	cin >> N;
	adj.resize(N);

	for (int i = 0; i < N - 1; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		adj[a - 1].push_back({b - 1, c});
		adj[b - 1].push_back({a - 1, c});
	}

	cin >> Q >> K;
	xy.resize(Q);
	for (int i = 0; i < Q; i++) {
		int x, y;
		cin >> x >> y;
		xy[i] = {x - 1, y - 1};
	}

	dp.resize(N);
	visited.resize(N);
	fill(visited.begin(), visited.end(), false);

	dfs(K - 1, -1, 0);
	for (int i = 0; i < Q; i++) {
		cout << dp[xy[i].first] + dp[xy[i].second] << endl;
	}

	return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()


int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> cnt(n,0);
    for(int i=0;i<q;i++){
        int a;
        cin >> a;
        a--;
        cnt[a]++;
    }
    for(int i=0;i<n;i++){
        cout << (cnt[i]+k-q > 0 ? "Yes" : "No") << endl;
    }
    return 0;
}


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

int main()
{
  	int a, b, k, i; 
  	cin>>a>>b>>k;
	for (i=min(a,b);i>=1;i--) 
    {
		if (a%i==0 && b%i == 0)
			k--;
		if (k==0) 
        {
			cout<<i<<endl ;
          	return 0;
        }
    }
  	assert(false);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
int x,a,b;
cin>>x>>a>>b;
if(a>=b)cout<<"delicious"<<endl;
else if(b-a<=x)cout<<"safe"<<endl;
else cout<<"dangerous"<<endl;
	return 0;
}



Measured memory_bytes: 256
//Copyright(c)2017 Mstdream
#include<bits/stdc++.h>
using namespace std;

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
const int N=305;
int a[N][N],n,use[N][N];
long long ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			splay(a[i][j]);
			if(i>j)ans+=a[i][j];
		}
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				if(k==i||k==j||i==j)continue;
				if(a[i][k]+a[k][j]<a[i][j]){
					puts("-1"),exit(0);
				}
				if(a[i][k]+a[k][j]==a[i][j]&&(!use[i][j])){
					ans-=a[i][j];
					use[i][j]=1;
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
Q=int(input())
queries=[tuple(map(int,input().split())) for _ in range(Q)]

#エラトステネスの篩
p=[True]*(10**5+1)
p[0]=False
p[1]=False
for i in range(2,10**5+1):
    if p[i]:
        for j in range(2*i, 10**5+1, i):
            p[j]=False

#like2017[n]=n以下の「2017に似た数」の数
like2017=[0]*(10**5+1)
for i in range(1,10**5+1):
    like2017[i]=like2017[i-1]+(1 if i&1 and p[i] and p[(i+1)//2] else 0)

for l,r in queries:
    print(like2017[r]-like2017[l-1])


Measured memory_bytes: 67544
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N;

signed main(){
    scanf("%lld",&N);
    int ans=0;
    int dp[105][64+5];
    rep(i,N){
        rep(j,64){
            int one=j%4;
            int two=(j/4)%4;
            int thr=(j/16)%4;
            dp[i][j]=0;
            if(i==0){
                if(two==3&&thr==3)dp[i][j]=1;
            }else{
                rep(k,64){
                    int one_=k%4;
                    int two_=(k/4)%4;
                    int thr_=(k/16)%4;
                    if(one_==two&&two_==thr){
                        if(thr==0&&two==1&&one==2)continue;//AGC
                        if(thr==0&&two==2&&one==1)continue;//ACG
                        if(thr==1&&two==0&&one==2)continue;//GAC
                        if(thr_==0&&two==1&&one==2)continue;//AxGC
                        if(thr_==0&&thr==1&&one==2)continue;//AGxC
                        dp[i][j]+=dp[i-1][k]%mod;
                        dp[i][j]%=mod;
                    }   
                }
            }
        }
    }
    rep(i,64){
        ans+=dp[N-1][i];
        ans%=mod;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 1752
#include<iostream>

int a,b,c,n;

int main(){
	std::cin >> n;
	for(int i=0; i<n; i++){
		std::cin >> a >> b >> c;
		if((a*a + b*b == c*c)||(a*a + c*c == b*b)||(b*b + c*c == a*a))
			std::cout << "YES\n";
		else
			std::cout << "NO\n";
	}
	return 0;
}

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 59;

template< typename T >
struct Dinic
{
  struct edge
  {
    int to;
    T cap;
    int rev;
  };

  vector< vector< edge > > graph;
  vector< T > min_cost;
  vector< int > iter;

  Dinic(int n)
  {
    graph.resize(n);
  }

  void add_edge(int from, int to, T cap)
  {
    graph[from].push_back((edge) {to, cap, (int) graph[to].size()});
    graph[to].push_back((edge) {from, 0, (int) graph[from].size() - 1});
  }

  bool bfs(int s, int t)
  {
    min_cost.assign(graph.size(), -1);
    queue< int > que;
    min_cost[s] = 0;
    que.push(s);
    while(!que.empty()) {
      int p = que.front();
      que.pop();
      for(auto &e : graph[p]) {
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[p] + 1;
          que.push(e.to);
        }
      }
    }
    return (min_cost[t] != -1);
  }

  T dfs(int idx, const int t, T flow)
  {
    if(idx == t) return (flow);
    for(int &i = iter[idx]; i < graph[idx].size(); i++) {
      edge &e = graph[idx][i];
      if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
        T d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return (d);
        }
      }
    }
    return (0);
  }

  T max_flow(int s, int t)
  {
    T flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      T f = 0;
      while((f = dfs(s, t, INF)) > 0) {
        flow += f;
      }
    }
    return (flow);
  }
};

int main()
{
  int N, A[100];

  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }

  Dinic< int64 > flow(N + 2);
  int S = N, T = N + 1;

  for(int i = 1; i <= N; i++) {
    for(int j = i + i; j <= N; j += i) {
      flow.add_edge(i - 1, j - 1, INF);
    }
  }

  int64 sum = 0;
  for(int i = 0; i < N; i++) {
    if(A[i] > 0) {
      sum += A[i];
      flow.add_edge(i, T, A[i]);
    } else {
      flow.add_edge(S, i, -A[i]);
    }
  }

  cout << sum - flow.max_flow(S, T) << endl;
}


Measured memory_bytes: 256
import sys
import io
import math

datalist = input().split()

i = 0
for i in range(int(datalist[0])):
    if i == 0:
        l_new = input().split()
        l_new.pop(0)
    if i != 0:
        l_input = input().split()
        l_input.pop(0)
        l_new = set(l_input) & set(l_new)

print(len(l_new))

Measured memory_bytes: 3060
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
long long UF[210000];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
int X[110000];
int Y[110000];
int C[110000];
pair<int,pair<int,int> > p[110000];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<b+c+1;i++)UF[i]=-1;
	for(int i=0;i<a;i++){
		scanf("%d%d%d",X+i,Y+i,C+i);X[i]--;Y[i]--;
		p[i]=make_pair(-C[i],make_pair(X[i],Y[i]));
	}

	std::sort(p,p+a);
	long long ret=0;
	for(int i=0;i<a;i++){
		if(FIND(p[i].second.first)!=FIND(p[i].second.second+b)){
			ret-=p[i].first;
			UNION(p[i].second.first,p[i].second.second+b);
		}else if(FIND(p[i].second.first)!=FIND(b+c)){
			UNION(p[i].second.first,b+c);
			ret-=p[i].first;
		}
	}
	printf("%lld\n",ret);
}

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

int main() {
  int masu, a, b, c;
  cin >> masu;
  a = masu / 100;
  b = (masu-a*100)/10;
  c = masu - a * 100 - b * 10; 

  cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a, cc = b; i <= cc; ++i)
#define PER(i, a, b) for (int i = a, cc = b; i >= cc; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
 
typedef unsigned long long LL;
typedef vector<int> VI;
typedef pair<int, int> pii;
 
inline int read(){
    int x = 0, ch = getchar(), f = 1;
    while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();}
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    return x * f;
}

int cnt[100005], even;
int main(){
	int n = read();
	REP(i, 1, n) cnt[read()]++;
	int ans = 0;
	REP(i, 1, 100000){
		if (cnt[i]) ++ans;
		if (cnt[i] > 0 && cnt[i] % 2 == 0) ++even;
	}
	if (even & 1) --ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {



    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
            int x =sc.nextInt();
            long ans1 =0;
            long ans2=0;
            for(long i=-1000;i<1000;i++)
            {
                long a =i*i*i*i*i;
                for(long j=i;j<1000;j++)
                {
                    long b = j*j*j*j*j;


                    if(b-a<1000000001&&(int)(b-a)==x)
                    {
                        ans1=i;
                        ans2=j;
                    }
                }

            }
            System.out.println(ans2 +" "+ans1);

    }


}

Measured memory_bytes: 38860
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
char res[40];
int ress;
int main(){
  rd(N);
  while(N){
    if(N%2){
      res[ress++] = '1';
      N -= 1;
    }
    else{
      res[ress++] = '0';
    }
    N /= -2;
  }
  if(!ress){
    res[ress++] = '0';
  }
  reverse(res, res+ress);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N;
// char res[40]; int ress;
// 
// {
//   rd(N);
//   while(N){
//     if(N%2){
//       res[ress++] = '1';
//       N -= 1;
//     } else {
//       res[ress++] = '0';
//     }
//     N /= -2;
//   }
//   if(!ress) res[ress++] = '0';
// 
//   reverse(res, res+ress);
//   wt(res);
// }


Measured memory_bytes: 256
input = readlines()
n = input.shift.chomp.to_i
s = input.shift.chomp.to_s

dic = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

r = ''
s.split('').each do |c|
  i = dic.find_index(c)
  ni = i + n
  ni = ni % 26 if ni > 25
  r += dic[ni]
end

puts r

Measured memory_bytes: 50412
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(x)				(x).begin(),(x).end()
#define REP(i, n)			for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)		for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF					(ll)1e9
#define EPS					(double)1e-9
#define MOD					(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)			(((((x))+((n)-1))/(n)))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)			(((((x))+((n)-1))/(n))*(n))	/* Nの倍数に切り上げ */
#define FloorN(x, n)		((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)			(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)			(!IsOdd((x)))						
#define M_PI				3.14159265358979323846
typedef long long			ll;
typedef pair<ll, ll>		P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	int a, b;
	cin >> a >> b;

	string ans;
	if (a < b) {
		REP(i, b) {
			ans += a + '0';
		}
	} else {
		REP(i, a) {
			ans += b + '0';
		}
	}

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



Measured memory_bytes: 256
/*
[abc165] F - LIS on Tree
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 2e5;
const int INF = 1e9 + 7;

int N;
int a[MAX_N];
vector<int> g[MAX_N];
int ans[MAX_N];

void dfs(vector<int> &path, int v, int par = -1) {
    int idx = lower_bound(ALL(path), a[v]) - path.begin();
    int org = path[idx];
    path[idx] = a[v];
    int len = lower_bound(ALL(path), INF) - path.begin();
    ans[v] = len;
    for (int to : g[v]) {
        if (to == par) continue;
        dfs(path, to, v);
    }
    path[idx] = org;
}

void solve() {
    vector<int> path(N, INF);
    dfs(path, 0);
    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N - 1; i++) {
        int u, v;
        cin >> u >> v;
        g[u - 1].push_back(v - 1);
        g[v - 1].push_back(u - 1);
    }

    solve();

    return 0;
}


Measured memory_bytes: 30748
n = input()
 
max = 10**9 + 7
 
a_list = [int(a) % max for a in input().split(" ")]
a_sum = sum(a_list)

total = 0
for i in range(0, len(a_list)-1):
    a_sum -= a_list[i]
    total += a_list[i] * a_sum
total = total % max
print(total)


Measured memory_bytes: 31404
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll N;
  cin >> N;
  vector<ll> L(N);
  REP(i,N) { cin >> L[i]; }
  
  sort(L.begin(), L.end(), greater<ll>());
  
  vector<ll> sumcnt(L[0]+L[1]+1);
  REP(i,N){
    REP3(j,i+1,N){
      sumcnt[L[i]+L[j]]++;
    }
  }
  ll sc = 0;
  for(ll i=sumcnt.size()-1;i>=0;i--){
    sc += sumcnt[i];
    sumcnt[i] = sc;
  }


  ll ans = 0;
  REP(i,N){
    ans += max(0ll, sumcnt[L[i]+1] - (i+1)*N + (i+1)*(i+2)/2);
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, k := nextInt(), nextInt()
	a, f := nextInts(n), nextInts(n)
	sort.Sort(sort.IntSlice(a))
	sort.Sort(sort.Reverse(sort.IntSlice(f)))

	cost := func(t int) int {
		res := 0
		for i := 0; i < n; i++ {
			res += max(0, a[i]-t/f[i])
		}
		return res
	}

	low, high := -1, 1000000000000
	for low+1 < high {
		mid := (low + high) / 2
		if cost(mid) <= k {
			high = mid
		} else {
			low = mid
		}
	}

	puts(high)
}


Measured memory_bytes: 7300
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();
		String S = sc.next();
		int N = S.length();
		if( N<=K ){
			System.out.println(S);
		}else{
			System.out.println(S.substring(0,K)+"...");
		}
	}
}

Measured memory_bytes: 38592