akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int i = a; i <= (n); ++i)
#define repD(i, a, n) for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	ll n, m, v, p; cin >> n >> m >> v >> p;
	vl a(n); rep(i,n) cin >> a[i];
	sort(all(a));
	reverse(all(a));
	ll hi = n, lo = p-1, mid = (hi+lo)/2;
	while(hi - lo > 1){
		ll vm = min(mid, p-1);
		ll va = n-mid-1;
		ll vl = max(0LL, v - vm - va - 1);
		ll ta = a[mid] + m;
		ll tu = vl*m;
		bool possible = true;
		repD(i,mid-1,p-1){
			if(a[i] > ta){
				possible = false;
				break;
			}
			tu -= min(m, ta-a[i]);
		}
		if(tu > 0){
			possible = false;
		}
		if(possible){
			lo = mid;
		}else{
			hi = mid;
		}
		mid = (hi+lo)/2;
	}
	cout << hi << endl;
	return 0;
}



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

using namespace std;

int inversion = 0;

void bubble_sort (vector<int> &a, size_t n) {
	bool flag = true;
	while (flag) {
		flag = false;
		for (size_t j = n; j --> 1;) {
			if (a[j] < a[j - 1]) {
				inversion++;
				swap(a[j], a[j - 1]);
				flag = true;
			}
		}
	}
}

int main() {
	size_t n;
	cin >> n;
	vector<int> a(n);
	for (size_t i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	bubble_sort(a, n);
	
	for (size_t i = 0; i < n; i++) {
		cout << a[i] << " \n"[i + 1 == n];
	}
	
	cout << inversion << '\n';
	
	return 0;
}


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

using ll = long long;
const int INF = 1e9+100;
const int S = 1e3+5;

vector<int> pr;
vector<int> isp(S, 1);
void sieve(){
	for (int p = 2; p < S; p++){
		if (isp[p]){
			pr.push_back(p);
			for (int j = p*2; j < S; j += p){
				isp[j] = 0;
			}
		}
	}
}

int n;
vector<int> a;
bool f1(){
	vector<int> occ(1e6+5, 0);
	for (auto it: a){
		for (auto p: pr){
			if (it % p == 0){
				if (occ[p]){
					return 0;
				}
				occ[p]++;
				while (it % p == 0){
					it /= p;
				}
			}
		}
		if (it != 1){
			if (occ[it]){
				return 0;
			}
			occ[it]++;
		}
	}
	return 1;
}
bool f2(){
	int allGCD = a[0];
	for (int i = 1; i < n; i++){
		allGCD = __gcd(allGCD, a[i]);
	}
	return allGCD == 1;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	sieve();
	// cout<<pr.size()<<'\n';
	// for (int i = 0; i < 5; i++){
	// 	cout<<pr[i]<<'\n';
	// }

	cin>>n;
	a.resize(n);
	for (int i = 0; i < n; i++){
		cin>>a[i];
	}
	if (f1()){
		cout<<"pairwise coprime\n";
	}else if (f2()){
		cout<<"setwise coprime\n";
	}else{
		cout<<"not coprime\n";
	}
	return 0;
}

Measured memory_bytes: 11080
/*input
10 4
*/
#include<bits/stdc++.h>
#define ull         unsigned long long
#define ll             long long
#define M             1000000007
#define pb             push_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()    
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp             make_pair
#define lb             lower_bound
#define ub            upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)    for(ll int i=0;i<n;i++) a[i]=0;
#define F            first
#define S            second
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

bool DEBUG = 0;

void solve()
{
    //initialize();
    ll h,a;cin>>h>>a;
    cout<<(h+a-1)/a<<"\n";
}


int main(void)
{
    ios
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

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
// Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Macro
#define rep(i, N) for(int i=0; i<(int)N; i++)
#define rrep(i, N) for(int i=(int)N-1; i>=0; i--)

// Type
template <typename T> using P = pair<T, T>;
using ll = long long;
using ull = unsigned long long;

// Constants
const ll INF = 1e18;
const ll MOD = 1000000007;

int main() {
  ll N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;

  ll _min = min(A, min(B, min(C, min(D, E))));
  ll t = (N%_min == 0) ? N / _min : N / _min + 1;

  cout << t + 4 << endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int V = scanner.nextInt();
        int E = scanner.nextInt();
        scanner.nextLine();

        CycleDetection cycleDetection = new CycleDetection(V);
        for (int i = 0; i < E; i++) {
            int[] e = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            cycleDetection.addEdge(e[0], e[1]);
        }

        cycleDetection.run();
        System.out.println(cycleDetection.cycles.isEmpty() ? 0 : 1);
    }
}

class CycleDetection {
    public Map<Integer, Set<Edge>> edges;
    private TreeSet<Integer> unvisited;
    public List<List<Integer>> cycles;

    public CycleDetection(int size) {
        edges = new HashMap<>();
        cycles = new ArrayList<>();
        unvisited = new TreeSet<>();
        for (int i = 0; i < size; i++) {
            unvisited.add(i);
        }
    }

    public void addEdge(int from, int to) {
        if (!edges.containsKey(from)) {
            edges.put(from, new HashSet<>());
        }
        edges.get(from).add(new Edge(from, to, 1));
    }

    public void run() {
        while (!unvisited.isEmpty()) {
            dfs(unvisited.pollFirst(), new LinkedHashSet<>(), new HashSet<>());
        }
    }

    private void dfs(int s, LinkedHashSet<Integer> inProcess, Set<Integer> visited) {
        if (visited.contains(s)) {
            return;
        }
        if (inProcess.contains(s)) {
            cycles.add(new ArrayList<>(inProcess));
            return;
        }
        inProcess.add(s);
        for (Edge e : edges.getOrDefault(s, Collections.emptySet())) {
            dfs(e.to, inProcess, visited);
        }
        inProcess.remove(s);
        visited.add(s);
    }
}

class Edge {
    public final int from;
    public final int to;
    public final int cost;

    public Edge(int from, int to, int cost) {
        this.from = from;
        this.to = to;
        this.cost = cost;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Edge edge = (Edge) o;
        return from == edge.from &&
                to == edge.to &&
                cost == edge.cost;
    }

    @Override
    public int hashCode() {
        return Objects.hash(from, to, cost);
    }
}



Measured memory_bytes: 58876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
template<class T> inline bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
ll calc(ll n,ll p,ll q,ll r,ll s,ll t,ll u){
    vl dp(n+1,-1);
    for(int i=0;i<=n;i++)dp[i]=i;
    dp[0]=0;
    for(int i=1;i<=n;i++){
        if(i>=p&&dp[i-p]>=0){
            chmax(dp[i],dp[i-p]+s);
        }
        if(i>=q&&dp[i-q]>=0){
            chmax(dp[i],dp[i-q]+t);
        }
        if(i>=r&&dp[i-r]>=0){
            chmax(dp[i],dp[i-r]+u);
        }
    }
    return *max_element(dp.begin(),dp.begin()+n+1);
}
int main(){
    ll n;cin>>n;
    ll p,q,r,s,t,u;cin>>p>>q>>r>>s>>t>>u;
    ll res1=calc(n,p,q,r,s,t,u);
    ll ans=calc(res1,s,t,u,p,q,r);
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    string s;

    cin >> s;

    int n = s.size();

    int digitSum = 0;

    for (int i = 0; i < n; i++){
        digitSum += s[i] - '0';
        digitSum = digitSum%9;
    }

    if (digitSum % 9 == 0){
        cout << "Yes" << endl;
    }

    else
    {
        cout << "No" << endl;
    }
    

    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> G[N];
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for (int i = 0; i < G[0].size(); i++) {
        int u = G[0][i];
        for (int j = 0; j < G[u].size(); j++) {
            int v = G[u][j];
            if (v == N - 1) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 12016
#include <iostream>
#include <string>
using namespace std;
int main(void){
    char S[3];
    for(int i = 0; i < 3; i++){
        cin >> S[i];
    }
    
    int count = 0;
    if(S[0] == 'R' && S[1] == 'R' && S[2] == 'R') count = 3;
    else if(S[0] == 'R' && S[1] == 'R' && S[2] == 'S') count = 2;
    else if(S[0] == 'R' && S[1] == 'S' && S[2] == 'R') count = 1;
    else if(S[0] == 'R' && S[1] == 'S' && S[2] == 'S') count = 1;
    else if(S[0] == 'S' && S[1] == 'R' && S[2] == 'R') count = 2;
    else if(S[0] == 'S' && S[1] == 'R' && S[2] == 'S') count = 1;
    else if(S[0] == 'S' && S[1] == 'S' && S[2] == 'R') count = 1;
    
    cout << count << endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
const ll mod = 1e9 + 7;

void solve() {
   int n, m;
   cin >> n >> m;
   vector <vector <int>> adj(n + 1);
   for (int i = 0; i < m; i++) {
      int u, v;
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   vector <bool> vis(n + 1);
   int comp = 0, ans = 0;
   function <void (int)> dfs = [&](int v) {
      vis[v] = true;
      comp++;
      for (auto u : adj[v]) {
         if (!vis[u])
            dfs(u);
      }
   };
   for (int i = 1; i <= n; i++) {
      if (!vis[i]) {
         comp = 0;
         dfs(i);
         ans = max(ans, comp);
      }
   }
   cout << ans << '\n';
}

int main() {
#ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);      freopen("outp.txt", "w", stdout);
#endif
   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   solve();

   return 0;
}

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

vector<bool> shops;

int main()
{
    int n, k;
    cin >> n >> k;
    shops.resize(n+1);
    for(int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for(int j = 0; j < d; j++) {
            int shop;
            cin >> shop;
            shops[shop] = true;
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(!shops[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
static const int MAX_N = 16;
static const int INF = 1 << 30;

int N;
int t[MAX_N][MAX_N + 1];
int memo[1 << MAX_N];

int main(){
	for(;;){
		scanf("%d", &N);
		if(N == 0) break;
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N + 1; j++){
				scanf("%d", &t[i][j]);
			}
		}
		fill(memo, memo + (1 << N), INF);
		memo[0] = 0;
		for(int i = 0; i < (1 << N); i++){
			for(int j = 0; j < N; j++){
				if(i & (1 << j)) continue;
				memo[i + (1 << j)] = min(memo[i + (1 << j)], memo[i] + t[j][0]);
				for(int k = 0; k < N; k++){
					if(k == j) continue;
					if(!(i & (1 << k))) continue;
					memo[i + (1 << j)] = min(memo[i + (1 << j)], memo[i] + t[j][k + 1]);
				}
			}
		}
		printf("%d\n", memo[(1 << N) - 1]);
	}
	return 0;
}



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

int main() {
    int a[5];
    for(int i=0; i<5; ++i) cin >> a[i];
    int res = 1000;
    do{
    int temp =0;
        for(int i=0; i<5; ++i){
            temp += a[i];
            while(i != 4 &&temp % 10 != 0) ++temp;
        }
        res = min(res, temp );
    }while(next_permutation(a, a+5));
    cout << res <<"\n";
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt
  val X = in.nextLong

  val lStream: Stream[Long] = 1L #:: lStream.map(_ * 2 + 3)
  val ls = lStream.take(N + 1).toArray
  val pStream: Stream[Long] = 1L #:: pStream.map(_ * 2 + 1)
  val ps = pStream.take(N + 1).toArray

  def count(l: Int, eat: Long): Long = {
    if (l == 0) (if (eat <= 0) 0 else 1)
    else if (eat <= 1 + ls(l - 1)) count(l - 1, eat - 1)
    else ps(l - 1) + 1 + count(l - 1, eat - ls(l - 1) - 2)
  }

  println(count(N, X))
}

Measured memory_bytes: 27320
#include<iostream>
#include<utility>
#include<vector>
using namespace std ;
using pic = pair<int,char> ;

vector<pic> bubble(vector<pic> a){
    bool flag = true ;
    while(flag){
        flag = false ;
        for(int i=a.size()-1;i>0;i--){
            if(a.at(i).first<a.at(i-1).first){
                flag = true ;
                int sub = a.at(i).first ;
                a.at(i).first = a.at(i-1).first ;
                a.at(i-1).first = sub ;
                char c = a.at(i).second ;
                a.at(i).second = a.at(i-1).second ;
                a.at(i-1).second = c ;
            }
        }
    }
    return a ;
}

vector<pic> select(vector<pic> a){
    for(int i=0;i<a.size()-1;i++){
        int mn = i ;
        for(int j=i+1;j<a.size();j++){
            if(a.at(mn).first>a.at(j).first) mn = j ;
        }
        int sub = a.at(i).first ;
        a.at(i).first = a.at(mn).first ;
        a.at(mn).first = sub ;
        char c = a.at(i).second ;
        a.at(i).second = a.at(mn).second ;
        a.at(mn).second = c ;
    }
    return a ;
}

int main(){
    int n ; cin >> n ;
    vector<pic> a(n) ;
    for(int i=0;i<n;i++) cin >> a.at(i).second >> a.at(i).first ;
    vector<pic> b = bubble(a) ;
    for(int i=0;i<n;i++){
        cout << b.at(i).second << b.at(i).first ;
        if(i==n-1) cout << endl ;
        else cout << " " ;
    }
    cout << "Stable" << endl ;
    vector<pic> s = select(a) ;
    for(int i=0;i<n;i++){
        cout << s.at(i).second << s.at(i).first ;
        if(i==n-1) cout << endl ;
        else cout << " " ;
    }
    if(b==s) cout << "Stable" << endl ;
    else cout << "Not stable" << endl ;
}


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

int main(){
  int a, b, cnt;
  cin >> a >> b;
  for(int i=1; i<1000; i++){
    if(b==1){
      cnt = 0;
      break;
    }
    if(a*i-(i-1) >= b){
      cnt = i;
      break;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <string.h>
#include <iostream>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

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

const int N = 500;

using namespace std;

int main() {
	int n, count = 0;
	string s;
	
	cin >> n >> s;
	
	for (int i = 0; i < n - 2; i++) {
		count += (s.substr(i, 3) == "ABC");
	}
	
	cout << count << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
//
#define mx 100000
int main(){
    int ar[6];
    for(int i=1;i<=5;i++)cin>>ar[i];
    int k;
    cin>>k;
    for(int i=1;i<=5;i++){
        for(int j=i+1;j<=5;j++){
            if(abs(ar[i]-ar[j])>k){
                cout<<":("<<endl;
                return 0;
            }
        }
    }
    cout<<"Yay!"<<endl;

    return 0;
}

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

#define int long long

int n, MOD;
int a[200010];
map<int, int> mp;
signed main(){
    cin >> n >> MOD;

    int ans = 0;
    mp[0] = 1;
    queue<int> que;
    que.push(0);

    if(MOD == 1){
        que.pop();
        mp[0]--;
    }

    for(int i = 0;i < n;i++){
        cin >> a[i+1];
        a[i+1] = (a[i+1] + a[i]) % MOD;
        int tmp = (a[i+1] - (i+1)%MOD + MOD) % MOD;
        ans += mp[tmp];
        mp[tmp]++;
        que.push(tmp);
        if(que.size() == MOD){
            mp[que.front()]--;
            que.pop();
        }
    }

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


Measured memory_bytes: 16000
#include <algorithm>　　
#include <cmath>
#include <iostream>
using namespace std;
int main(){
    int k;
    cin>>k;
    string s;
    cin>>s;
    int len = s.length();
    if( len <= k ){
        cout<<s;
    }else{
        for(int i=0;i<k;i++){
            cout<<s[i];
        }
        cout<<"...";
    }
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n) for (int i = (n - 1); i >= 0; i--)
#define repb2(i, a, n) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define print(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
const int INF = 2e9 + 7;

struct arr {
    int x, y, h;
};

int main() {
    int N;
    cin >> N;
    int x[100], y[100], h[100];
    int maxx = 0, maxy = 0, maxh = 0;
    rep(i, N) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] > maxh) {
            maxx = x[i];
            maxy = y[i];
            maxh = h[i];
        }
    }
    rep(cx, 101) {
        rep(cy, 101) {
            int ansh = maxh + abs(maxx - cx) + abs(maxy - cy);
            bool isAnswer = true;
            rep(i, N) {
                int tmp = max(ansh - abs(x[i] - cx) - abs(y[i] - cy), 0);
                if (tmp != h[i]) {
                    isAnswer = false;
                    break;
                }
            }
            if (isAnswer) {
                cout << cx << " " << cy << " " << ansh << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;

int main()
{
    string s;
    cin>>s;
    vector<vector<ll>> dp(100005,vector<ll>(13,0));

    dp[0][0]=1;
    ll len=s.length();

    rep(i,len)
    {
        if(s[i]=='?')
        {
            rep(j,10)
            {
                rep(k,13)
                {
                    dp[i+1][(k*10+j)%13]+=dp[i][k]%=mod;
                }
            }
        }
        else
        {
            rep(k,13)
            {
                dp[i+1][(k*10+(int)(s[i]-'0'))%13]+=dp[i][k];
            }
        }
        rep(j,13)dp[i+1][j]%=mod;
        
    }
    cout<<dp[len][5];
}

Measured memory_bytes: 13568
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
bc = [list(map(int, readline().split())) for _ in range(m)]
bc.sort(key=lambda x: -x[1])
a.sort()
idx = 0
for b, c in bc:
    while b > 0:
        if a[idx] < c:
            a[idx] = c
            idx += 1
            b -= 1
        else:
            break
        if idx >= n:
            print(sum(a))
            exit()
print(sum(a))


Measured memory_bytes: 36108
import bisect

n = int(input())
a = sorted([int(i) for i in input().split()])
b = [int(i) for i in input().split()]
c = sorted([int(i) for i in input().split()])

total = 0

for middle in b:

    total += bisect.bisect_left(a,middle) * (n-bisect.bisect_right(c,middle))

print(total)

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

#define INF 1000000007LL
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)

int n,r,p[55],c[55];

int main(){
	while(cin>>n>>r && n){
		rep(i,r)cin>>p[i]>>c[i];
		int x=1;
		for(int i=r-1;i>=0;i--){
			if(x<=c[i])x+=p[i]-1;
			else if(x<=c[i]+p[i]-1)x-=c[i];
		}
		cout<<n+1-x<<endl;
	}
}

Measured memory_bytes: 0
a = [int(input()) for i in range(5)]

b = []

for i in a:
    n = i % 10
    b.append(n)
sum = 0
if b == [0,0,0,0,0]:
    for j in a:
        sum += j
    print(sum)
else:
    c = [i for i in b if i > 0]
    c.sort()

    for j in a:
        sum += j
 
    n = 0
    for k in c:
        n += 10 - k

    N = sum + n + (c[0] - 10)
    print(N)


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

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int a[n] = {};
    int t;
    for(int i=0;i<m;i++){
        cin >> t;
        a[t] = 1;
    }
    int left=0,right=0;
    for(int i=0;i<n;i++){
        if(i < x){
            left += a[i];
        }
        if(i > x){
            right += a[i];
        }
    }
    cout << min(left,right) << endl;    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,m,a;
    cin>>n>>m;
    f(i,0,m){
        cin>>a;
        n-=a;
    }
    if(n<0){
        cout<<-1<<endl;
    }
    else{
        cout<<n<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

struct Edge {
    ll to;  // 頂点の番号(0-index)
    ll id;  // 辺の番号(0-index)
};

vector<vector<Edge>> G; 
vl ans;  // ans[i] : 辺iの色

void dfs(ll v, ll p, ll color) {  // いま見ている頂点v、vの親p、vとpを結ぶ辺の色color
    ll num = 1;
    rep(i, G[v].size()) {
        ll u = G[v][i].to;  // vと隣接する頂点の番号
        ll ei = G[v][i].id;  // vにつながっている辺の番号
        if(u == p) {
            continue;
        }
        if(num == color) {
            num++;
        }
        ans[ei] = num;
        num++;
        dfs(u, v, ans[ei]);
    }
}

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

    G.resize(n);
    ans.resize(n-1);

    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb((Edge){b, i});
        G[b].pb((Edge){a, i});
    } 
    
    dfs(0, -1, -1);

    ll K = 0;
    rep(i, n) {
        chmax(K, (ll)G[i].size());
    }
    out(K);
    rep(i, n-1) {
        out(ans[i]);
    }

    re0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007

int fn(int A,int B,int C)
{
  return abs(A-B) + abs(B-C) + abs(C-A);
}

void solve(void)
{
  int N,K;
  cin>>N>>K;
  cout<<N*N - K <<endl;
  return;
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
char str[110];
int i,j,k,l,m,n;
int n,e,s,w,un,up;
int a[7],b[7], qu[25],qf[25],ufl[25];
int t;
 
void input() {
  for(i=0;i<6;i++){
    scanf("%d",&a[i+1]);
    b[i+1] = a[i+1];
    // printf("a[%d] = %d\n",i+1,a[i+1]);
  }
 
  scanf("%d",&n);
  //printf("n = %d\n",n);
 
  for(i=0;i<n;i++) {
    scanf("%d %d",&qu[i],&qf[i]);
    //  printf("qu[%d] = %d qf[%d] = %d\n",i,qu[i],i,qf[i]);
  }
}
 
void N() {
  t = a[1];
  a[1] = a[2];
  a[2] = a[6];
  a[6] = a[5];
  a[5] = t;
}
 
void S() {
  t = a[1];
  a[1] = a[5];
  a[5] = a[6];
  a[6] = a[2];
  a[2] = t;
}
 
void E() {
  t = a[1];
  a[1] = a[4];
  a[4] = a[6];
  a[6] = a[3];
  a[3] = t;
}
 
void W() {
  t = a[1];
  a[1] = a[3];
  a[3] = a[6];
  a[6] = a[4];
  a[4] = t;
}
 
void UF() {
 
  if(qu[k] == a[1]) { // if qu == 1;
    // printf("qu == 1\n");
    if(qf[k] == a[3]) strcpy( str, "NWS");
    else if(qf[k] == a[5]) strcpy(str ,"NEES");
    else if(qf[k] == a[4]) strcpy(str,"NES");
  }  else if(qu[k] == a[2]) {  // if qu == 2;
    // printf("qu == 2\n");
    if(qf[k] == a[3])  strcpy( str, "NWS");
    else if(qf[k] == a[1] ) strcpy(str ,"NEES");
    else if(qf[k] == a[4]) strcpy(str,"NES");
    N();
  } else if(qu[k] == a[3]){ // if qu == 3;
    //   printf("qu(%d) == %d\n",qu[k],a[3]);
     
    if(qf[k] == a[6])  strcpy( str, "NWS");
    else if(qf[k] == a[5])  strcpy(str ,"NEES");
    else if(qf[k] == a[1]) strcpy(str,"NES");
    W();
  } else if(qu[k] == a[4]) {
    if(qf[k] == a[1]) strcpy( str, "NWS");
    if(qf[k] == a[5])  strcpy(str ,"NEES");
    if(qf[k] == a[6]) strcpy(str,"NES");
    E();
  } else if(qu[k] == a[5]) {
    if(qf[k] == a[3]) strcpy( str, "NWS");
    else if(qf[k] == a[6])  strcpy(str ,"NEES");
    else if(qf[k] == a[4]) strcpy(str,"NES");
    S();
  } else if(qu[k] == a[6]) {
    if(qf[k] == a[3]) strcpy( str, "NWS");
    else if(qf[k] == a[2])  strcpy(str ,"NEES");
    else if(qf[k] == a[4]) strcpy(str,"NES");
    N();
    N();
  }
 
 
}
 
void reset() {
  // printf("before reset str = '%s'\n",str);
  strcpy(str , "");
  for(i=1;i<=6;i++){
    //  printf("before reset a[%d] = %d\n",i,a[i]);
    a[i] = b[i];
    //     printf("a[%d] = %d\n",i,a[i]);
  }
  // printf("str = '%s'\n",str);
}
 
 
void output() {
  /*  printf("%d\n",a[1]); */
 
  printf("%d\n",a[3]);
}
 
void IF() {
 
  // scanf("%s",str);
 
  for(i=0;i<strlen(str);i++) {
 
    if(str[i] == 'N') N();
    else if(str[i] == 'S') S();
    else if(str[i] == 'W') W();
    else if(str[i] == 'E') E();
  }
}
 
int main() {
 
  k = 0;
 
  input();
 
  for(j=0;j<n;j++) {
    UF();
     
    IF();
 
    output();
 
    reset();
    k = k + 1;
 
  }
 
  //  strlen(?) ???????????????(??°)
 
 
  return 0;
}


Measured memory_bytes: 2060
#include <stdio.h>

    int main() {
      char S[4];
      scanf("%s", S);

      if (S[0] != S[1] && S[1] != S[2] && S[2] != S[0]) {
        printf("Yes");
      }
      else {
        printf("No");
      }

      return 0;
    }


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

int main(){
  long double a,b,x,c; cin >>a >>b >>x;
  if(x<=a*a*b/2) c = atan2(b*b, 2*(x/a));
  else c = atan2(2*(a*b-(x/a)), a*a);
  double ans = c/(2*acos(-1))*360;
  cout << fixed << setprecision(9) << ans << endl;
  return 0;
}

Measured memory_bytes: 3808
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

int main(){

  int N; cin >> N;
  while (N > 0){
    if (N % 10 == 7){
      cout << "Yes" << endl;
      return 0;
    }
    N /= 10;
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3632
<?php
// D
fscanf(STDIN, '%d %d', $n, $x);
$cnt = [1];
$cnt_p = [1];
for ($i = 1; $i <= $n; $i++) {
    $cnt[] = $cnt[$i - 1] * 2 + 3;
    $cnt_p[] = $cnt_p[$i - 1] * 2 + 1;
}
echo f($n, $x);

function f($n, $x)
{
    global $cnt, $cnt_p;

    if ($n === 0) return min(1, $x);

    if ($x <= 1) return 0;
    if ($x <= ($cnt[$n] - 3) / 2 + 1) {
        return f($n - 1, $x - 1);
    }
    if ($x === ($cnt[$n] - 3) / 2 + 2) {
        return f($n - 1, $x - 2) + 1;
    }
    return $cnt_p[$n - 1] + 1 + f($n - 1, $x - (($cnt[$n] - 3) / 2 + 2));
}

Measured memory_bytes: 4604
program main
  
  implicit none
  integer :: a, b, c, ll, ss, tmp ,ab
  integer :: ans, k
  integer,allocatable :: aa(:,:)
  
  read(*,*) k
  allocate(aa(200,200))
  
  aa = 0 
  ans = 0
  do a = 1, k
    do b = 1, k
      if( a > b) then
        ll = a
        ss = b
      else
        ll = b
        ss = a
      end if
      do
        tmp = ss
        ss = mod(ll,ss)
        ll = tmp
        if( ss == 0 ) then
          aa(a,b) = tmp
          exit
        end if
      end do
    end do
  end do

  do a = 1, k
    do b = 1, k
      ll = aa(a,b)
      do c = 1, k
        ans = ans + aa(ll,c)
      end do
    end do
  end do
  print*, ans
  
  
end program main


Measured memory_bytes: 3016
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

const int MAX = 510000;
const int MOD = 1000000007;

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;
}

signed main() {
  // 前処理
  COMinit();

  int N, K; cin >> N >> K;

  for (int i = 1; i <= K; i++) {
    cout << (COM(K - 1, i - 1) * COM(N - K + 1, i)) % MOD << endl;
  }
  // 計算例
  // cout << COM(100000, 50000) << endl;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, x;
int a[2010];
ll ret = LLONG_MAX;
int mn[2010][2010];

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

    rep(i, N) {
	cin >> a[i];
    }

    rep(i, N) {
	int t = a[i];

	for (int j = i; j < N; ++j) {
	    t = min(t, a[j]);
	    mn[i][j] = t;
	}
    }

    for (int i = 0; i < N; ++i) {
	ll tt = 0;

	rep(j, N) {
	    int l = j - i;
	    int u = mn[max(0, l)][j];

	    if (l < 0) {
		l += N;
		u = min(u, mn[l][N-1]);
	    }

	    tt += u;
	}

	ret = min(ret, tt + (ll)x * i);
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 14080
n,m,x,y=map(int,input().split())
x_list=list(map(int,input().split()))
y_list=list(map(int,input().split()))
ans="War"
z=max(x_list)+1
if z>x and z<=y and z<=min(y_list):
    ans="No War"
print(ans)

Measured memory_bytes: 3060
x1,y1,x2,y2=map(int,input().split())
if y2>=y1 and x2>=x1:
    y3=y2+abs(x2-x1)
    x3=x2-abs(y2-y1)
elif y2>=y1 and x1>x2:
    x3=x2-abs(y2-y1)
    y3=y2-abs(x2-x1)
elif y1>y2 and x2>=x1:
    x3=x2+abs(y2-y1)
    y3=y2+abs(x2-x1)
elif y1>y2 and x1>x2:
    x3=x2+abs(y2-y1)
    y3=y2-abs(x2-x1)

x4=x1+x3-x2
y4=y1+y3-y2

print(x3,y3,x4,y4)

Measured memory_bytes: 9172
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 1005

int N;

int main(){

	scanf("%d",&N);

	int tmp;
	int minimum = BIG_NUM,maximum = -BIG_NUM;

	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);

		minimum = min(minimum,tmp);
		maximum = max(maximum,tmp);
	}

	if((maximum-minimum)%2 == 0){

		printf("%d\n",(maximum-minimum)/2);

	}else{

		printf("%d\n",(maximum-minimum)/2+1);
	}

	return 0;
}



Measured memory_bytes: 3224
#include <assert.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define F first
#define S second
#define qq queue
#define dq deque
#define vc vector
#define INF ((int)(2e9))
#define LINF ((int)(1e18))
#define fir for( int i = 1 ; i <= n ; i++ )
#define fjr for( int j = 1 ; j <= n ; j++ )
#define fkr for( int k = 1 ; k <= n ; k++ )
#define firx( _x ) for( int i = 1 ; i <= _x ; i++ )
#define fjrx( _x ) for( int j = 1 ; j <= _x ; j++ )
#define fkrx( _x ) for( int k = 1 ; k <= _x ; k++ )
#define fir0x( _x ) for( int i = 0 ; i < _x ; i++ )
#define fjr0x( _x ) for( int j = 0 ; j < _x ; j++ )
#define fkr0x( _x ) for( int k = 0 ; k < _x ; k++ )
#define out cout <<
#define ln  << endl
#define pb push_back
#define mp make_pair
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define mp make_pair
#define sint short int
#define ull unsigned long long
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define ll long long
#define B out "BreakPoint\n";
#define read(_nowans) scanf("%d",&_nowans)
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define read2(_nowans1,_nowans2) scanf("%d %d",&_nowans1,&_nowans2)
#define msn(_data,_nowans) memset(_data,_nowans,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define read3(_nowans1,_nowans2,_nowans3) scanf("%d %d %d",&_nowans1,&_nowans2,&_nowans3)
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
void print( ll _x ){ cout << _x << endl; }
_tp<_tyn T>void print( T _data[] , int _size ){
	firx( _size )
		cout << _data[i] << " ";
	cout << endl;
}
#define MAXN 100100

int n;
ll a[MAXN];

bool cmp( int a , int b ){
	return a > b;
}

int main(){
	//fin( "C.txt" );

	cin >> n;
	fir{
		cin >> a[i];
	}

	sort( a+1 , a+n+1 , cmp );

	vc<ll> app2;
	for( int i = 1 ; i <= n+1 ; i++ ){
		if( a[i] == a[i+1] ){
			app2.pb( a[i] );
			i++;
		}
		if( app2.size() >= 2 ) break;
	}

	if( app2.size() < 2 ) print(0);
	else print( app2[0] * app2[1] );

	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define CLR(a, b) memset((a), (b), sizeof((a)))
template <typename t> bool ckmin(t& a, const t& b) {return a > b ? a = b, true : false;}
template <typename t> bool ckmax(t& a, const t& b) {return a < b ? a = b, true : false;}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
if (DEBUG) std::cerr
# define PPI 3.14159265358979323846
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    int r;
    cin >> r;

    cout << fixed << setprecision(9) << 2*PPI*r << endl;
}




Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int DFS(int x){
	vector<int> lis;
	int pnt=x,cnt=0;
	while(1){pnt++;
		if(v[pnt]==-2)break;
		if(v[pnt]==-1)lis.push_back(DFS(pnt));
		if(v[pnt]>0)cnt++;
	}v[x]=0,v[pnt]=0;
	if(cnt==1)return v[pnt-1]/2+1;cnt=0;
	sort(lis.begin(),lis.end());
	for(int i=0;i<=lis.size()/2;i++)cnt+=lis[i];
	return cnt;
}
int main(){
	int n;cin>>n;string s;
	while(n--){cin>>s;v.clear();int cnt=0;
		for(int i=0;i<s.size();i++){
			if(s[i]=='[')v.push_back(-1);
			if(s[i]==']'){
				if(cnt>0)v.push_back(cnt);
				v.push_back(-2);cnt=0;
			}if(s[i]>='0'&&s[i]<='9')cnt*=10,cnt+=s[i]-'0';
		}cout<<DFS(0)<<endl;
	}return 0;
}

Measured memory_bytes: 3208
n=int(input())
shoujiki=[[] for i in range(n)]
usotsuki=[[] for i in range(n)]
for i in range(n):
	a = int(input())
	for j in range(a):
		x,y = map(int,input().split())
		if y == 0:
			usotsuki[i].append(x-1)
		else:
			shoujiki[i].append(x-1)
ans = 0
for i in range(2**n):
	sl = []
	t = 0
	for j in range(n):
		if (i>>j) & 1:
			sl.append(1)
			t += 1
		else:
			sl.append(0)
	yes = 1
	for j in range(n):
		if sl[j] == 1:
			for k in shoujiki[j]:
				if sl[k] == 0:
					yes = 0
					break
			if yes == 0:
				break
			for k in usotsuki[j]:
				if sl[k] == 1:
					yes = 0
					break
			if yes == 0:
				break
	if yes == 1:
		ans = max(t, ans)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<algorithm>
#define f first
#define s second
#define pb push_back
using namespace std;
int const INF=0x3f3f3f3f;
int const maxn=105;
typedef long long ll;
typedef pair<int,int>P;
char s[maxn][maxn];
int num[maxn][maxn];
bool vis[maxn][maxn];
int mv[2][2]={{1,0},{0,1}};
queue<P>que;
char p[105];
bool judge(int l,int r){
	while(l<r){
		if(p[l++]!=p[r--]) return 0; 
	}
	return 1;
}
int main(){
	scanf("%s",p+1);
	int n=strlen(p+1);
	if(judge(1,(n-1)/2)&&judge((n+3)/2,n)&&judge(1,n)) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
def main():
    r,g,b,n=map(int,input().split())
    a = 0
    for i in range(n+1):
        ri = r * i
        if ri > n:
            break
        for j in range(n+1):
            x=(n-(ri + j*g))
            if x>=0:
                if x%b == 0:
                    a += 1
            else:
                break
    print(a)

if __name__ == "__main__":
    main()

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

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  S = input()
  if S == 'SUN':
    print(7)
  elif S == 'MON':
    print(6)
  elif S == 'TUE':
    print(5)
  elif S == 'WED':
    print(4)
  elif S == 'THU':
    print(3)
  elif S == 'FRI':
    print(2)
  elif S == 'SAT':
    print(1)
  else:
    raise Exception('something wrong')

if __name__ == "__main__":
  main()


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

int main(){
  int N, K;
  cin >> N >> K;
  vector<bool> needTrick(N, true);
  for(int i = 0; i < K; i++){
    int d;
    cin >> d;
    vector<int> A(d);
    for(int j = 0; j < d; j++){
      cin >> A.at(j);
      needTrick.at(A.at(j) - 1) = false;
    }
  }

  int ans = 0;
  for(int i = 0; i < N; i++){
    if(needTrick.at(i) == true) ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3584
from operator import itemgetter

n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
ans = 0
a.sort(key=itemgetter(0))
i = 0
while(1):
    if m == 0:
        break
    if a[i][1] <= m:
        ans += a[i][0]*a[i][1]
        m -= a[i][1]
        i += 1
    else:
        ans += a[i][0]*m
        m = 0
print(ans)

Measured memory_bytes: 28968
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;
//const ll INF = (ll)1e18 + 1;

int main(){
  int K; cin >> K;
  int A, B; cin >> A >> B;
  bool flag = false;
  for (int i = A; i <= B; ++i){
    if (i % K == 0) flag = true;
  }
  if(flag) cout << "OK" << endl;
  else cout << "NG" << endl;
}


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

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

    vector<long long> a(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    long long min = a[0];
    for (size_t i = 0; i < n; i++)
    {
        if (a[i] < min)
        {
            min = a[i];
        }
    }

    long long max = a[0];
    for (size_t i = 0; i < n; i++)
    {
        if (a[i] > max)
        {
            max = a[i];
        }
    }

    long long sum = 0;
    for (size_t i = 0; i < n; i++)
    {
        sum += a[i];
    }

    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3160
#include<iostream>
using namespace std;
int main()
{
  int A1,A2,A3;
  cin>>A1>>A2>>A3;
  if((A1+A2+A3)>=22)
  {
    cout<<"bust"<<endl;
  }
  else
  { 
    cout<<"win"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int h, m, s, S;

int main(void)
{
	
	scanf("%d",&S);
	
	
	h = S / 3600;
	m = (S - 3600 * h) / 60;
	s = S - 3600 * h - 60 * m;
	
	printf("%d:%d:%d\n",h, m, s);
	return 0;
	
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    string s;
    cin>>s;
    ll n=s.size();
    int k;
    cin>>k;
    if (k==1)
    {
        cout<<9*(n-1)+s[0]-'0';
        return 0;
    }
    if (k==2)
    {
        ll cnt=0;
        int ind=-1;
        for (int i=1;i<n;i++)
        {
            if (s[i]!='0') {
                ind = i + 1;
                break;
            }
        }
        cnt+=9*9*(n-1)*(n-2)/2;
        cnt+=9*(n-1)*(s[0]-'0'-1);
        if (ind!=-1)
        {
            cnt+=(n-ind)*9;
            cnt+=s[ind-1]-'0';
        }

        cout<<cnt;
        return 0;
    }
    if (k==3)
    {
        ll cnt=0;
        int ind=-1,ind1=-1;
        for (int i=1;i<n;i++)
        {
            if (s[i]!='0') {
                ind = i + 1;
                break;
            }
        }
        if (ind!=-1)
        {
            for (int i=ind;i<n;i++)
            {
                if (s[i]!='0')
                {
                    ind1=i+1;
                    break;
                }
            }
        }
        cnt+=(n-1)*(n-2)*(n-3)*9*9*9/6;
        cnt+=(s[0]-'0'-1)*9*9*(n-1)*(n-2)/2;
        if (ind!=-1)
        {
            cnt+=9*9*(n-ind)*(n-ind-1)/2;
            cnt+=(s[ind-1]-'0'-1)*9*(n-ind);
            if (ind1!=-1)
            {
                cnt+=9*(n-ind1);
                cnt+=s[ind1-1]-'0';
            }
        }
        cout<<cnt;
        return 0;
    }







}

Measured memory_bytes: 256