akhauriyash/Code-Regression huggingface dataset:
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int q;cin>>q;
	int a=q/1000,b=q%1000/100,c=q%100/10,d=q%10;
		 if(a+b+c+d==7)cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
	else if(a+b+c-d==7)cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
	else if(a+b-c+d==7)cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
	else if(a+b-c-d==7)cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
	else if(a-b+c+d==7)cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
	else if(a-b+c-d==7)cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
	else if(a-b-c+d==7)cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
	else if(a-b-c-d==7)cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;	
}




Measured memory_bytes: 256
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 11/20/2018, 11:10:45 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  string A, B;
  cin >> A >> B;
  if (A == B)
  {
    cout << "EQUAL" << endl;
    return 0;
  }
  if (A.size() > B.size())
  {
    cout << "GREATER" << endl;
    return 0;
  }
  else if (A.size() < B.size())
  {
    cout << "LESS" << endl;
    return 0;
  }
  else
  {
    for (auto i = 0; i < (int)A.size(); i++)
    {
      if (A[i] > B[i])
      {
        cout << "GREATER" << endl;
        return 0;
      }
      else if (A[i] < B[i])
      {
        cout << "LESS" << endl;
        return 0;
      }
    }
  }
  return 1;
}

Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


H,W,A,B = MI()
for _ in range(B):
    print(''.join(['0']*A+['1']*(W-A)))
for _ in range(H-B):
    print(''.join(['1']*A+['0']*(W-A)))


Measured memory_bytes: 73444
#include <bits/stdc++.h>
using namespace std;
#define lowbit(x) (x & (-x))
typedef long long ll;
const ll mod = 1e9 + 7;
int n;
const int maxn = 2000 + 10;
int a[maxn], b[maxn], c[maxn];
ll ans, k;
void add(int x) { for(int i = x; i < maxn; i += lowbit(i)) ++c[i];}
int getsum(int x) { int ret = 0; for(int i = x; i; i -= lowbit(i)) ret += c[i]; return ret;}
int main()
{
	scanf("%d%lld", &n, &k);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]), b[i] = a[i];
	sort(b + 1, b + n + 1);
	for(int i = n; i; --i)
	{
		ll A = getsum(a[i] - 1);
		ll B = lower_bound(b + 1, b + n + 1, a[i]) - b - 1;
		ll tmp = k * A % mod + k * (k - 1) / 2 % mod * B % mod;
		ans = (ans + tmp % mod) % mod;
		add(a[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N,i=1,T,ma,sum=0,D;
	scanf("%d",&N);
	for(i=1;i<=N;i++)
		{
			scanf("%d",&T);
			sum+=T;
			if(ma<T)
				{
					ma=T;
				}
			else 
				{
					ma=ma;
				}
		}
		D=sum-(ma/2);
	printf("%d\n",D);
	return 0;
}

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

#define rep(i,N) repv(i,0,N)
#define reps(i,N) repvs(i,0,N)
#define repv(i,a,b) for(int i=a;i<b;i++)
#define repvs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<","
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d
#define da(arr,N){if(isDebugMode){rep(i,N+1){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N+1){rep(j,M+1){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back
#define s(a) cout<<a<<endl;

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 100000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
int h,w;
bool s[50][50];
int r[50][50];
int cnt;
int bfs(){
	queue<P> q;
	q.push(P(0,0));
	r[0][0]=0;
	while(!q.empty()){
		P p=q.front();q.pop();
		int y=p.first,x=p.second;
		rep(i,4){
			int ny=p.first+dy[i],nx=p.second+dx[i];
			if(ny>=0&&ny<h&&nx>=0&&nx<w&&s[ny][nx]&&r[ny][nx]>r[y][x]+1)
			{
				q.push(P(ny,nx));
				r[ny][nx]=r[y][x]+1;
			}
		}
	}
	return r[h-1][w-1];
}
void solve(){
	cnt-=bfs();
	cnt--;
	if(cnt<0) cnt=-1;
	cout<<cnt<<endl;
}

int main(){
	cin>>h>>w;
	rep(i,h)rep(j,w){
		char a;
		cin>>a;
		if(a=='.') {s[i][j]=true;cnt++;}
		r[i][j]=INF;
	}
	solve();
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <fstream>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll factorial(ll n) {//階乗
	ll ret = 1;
	rep(i, 1, n + 1)
		ret = (ret *i) % MODU;

	return ret;
}

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b, ll m) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b, m - 2, m)) % m;
}
ll ncr(ll n, ll r) {
	return divmod(factorial(n), (factorial(r) * (factorial(n - r))) % MODU, MODU);
}

int n;
string base;
bool quest(int from) { //True:base
	printf("?");
	REP(i, n) {
		printf(" %d", (from+ i) % (2*n) + 1);
	}
	cout << endl;
	string str;
	cin >> str;
	return str == base;
}

bool quest(int from, int ad) { //True:base
	printf("?");
	REP(i, n - 1) {
		printf(" %d", (from + i) % (2 * n) + 1);
	}
	printf(" %d", ad + 1);
	
	cout << endl;
	string str;
	cin >> str;
	return str == base;
}


signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a != c) {
		cout << 1 << endl;
	}
	else
		cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

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

		String str = br.readLine();

		int N = Integer.parseInt(str);

		List<Pair> restlist = new ArrayList<>();
		for(int i=0;i<N;i++) {
			String[] str1 = br.readLine().split(" ");
			String city = str1[0];
			int val = Integer.parseInt(str1[1]);

			Pair rest = new Pair(city,val,i+1);

			restlist.add(rest);
		}

		Collections.sort(restlist);
		Collections.reverse(restlist);

		Collections.sort(restlist, new PairComparator());


		for(int i=0;i<restlist.size();i++) {
			System.out.println(restlist.get(i).id);
		}

	}



	static class Pair implements Comparable<Pair> {
		String city;
		int val;
		int id;

		public Pair(String city, int val,int id) {
			this.city = city;
			this.val = val;
			this.id = id;
		}

		@Override
		public int compareTo(Pair o) {
			return Integer.compare(val, o.val);
		}
	}

	public static class PairComparator implements Comparator<Pair> {

	    public int compare(Pair a, Pair b) {
	        String no1 = a.city;
	        String no2 = b.city;

	        return no1.compareTo(no2);

	    }

	}
}


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

int binpow(int n, int k) {
    if (k == 0) return 1;
    if (k == 1) return n;
    if (k % 2 == 0) {
        int nn = binpow(n, k / 2);
        return nn*nn;
    }
    if (k % 2 == 1) {
        return n * binpow(n, k - 1);
    }
}

void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> v(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++) {
            v[i][j] = s[j] - '0';
        }
    }
    int resres = n + m;
    for (int mask = 0; mask < binpow(2, n - 1); mask++) {
        int res = __builtin_popcount(mask);
        int sz = res;
        vector<vector<int>> vv(res + 1, vector<int>(m));
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                vv[cnt][j] += v[i][j];
            }
            if ((mask & binpow(2, i)) == binpow(2, i)) cnt++;
        }
        vector<int> cur(res + 1);
        bool invalid = false;
        for (int i = 0; i <= res; i++) {
            cur[i] = vv[i][0];
            if (cur[i] > k) {
                invalid = true;
            }
        }
        if (invalid) continue;
        for (int i = 1; i < m; i++) {
            bool need = false;
            for (int j = 0; j <= sz && ! need; j++) {
                if (cur[j] + vv[j][i] > k) {
                    need = true;
                }
            }
            for (int j = 0; j <= sz; j++) {
                if (need) {
                    cur[j] = vv[j][i];
                } else {
                    cur[j] += vv[j][i];
                }
            }
            if (need) { res ++; }
        }
        resres = min(res, resres);
    } 
    cout << resres << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=105;
int n,a[MAXN],ret;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=2;i<=n;)
		if(a[i]==a[i-1])
			ret++,i+=2;
		else i++;
	printf("%d\n",ret);
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    long N =sc.nextLong();
    long M;
    int m;
    int x=0;
    String ans1 ="0";
    String T[] ={"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"};
    while(N>0){
      M=N%26; if(M==0){M=26;}
      m =(int) M;
      ans1 =T[m-1] + ans1;
      N =(N-m)/26;
      x=x+1;}
    String ans =ans1.substring(0,x);
    System.out.println(ans);
  }
}

Measured memory_bytes: 27044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int c[3][3];
  rep(i,3){
    rep(j,3){
      cin>>c[i][j];
    }
  }
  bool ans=true;
  vector<int>a(3),b(3);
  rep(i,100){
    a[0]=i;
    b[0]=c[0][0]-a[0];
    a[1]=c[1][0]-b[0];
    b[1]=c[0][1]-a[0];
    a[2]=c[2][0]-b[0];
    b[2]=c[0][2]-a[0];
    rep(j,3){
      rep(k,3){
        if(c[j][k]!=a[j]+b[k])
          ans=false;
      }
    }
  }
  if(ans==true){
    cout<<"Yes"<<endl;
  }
  else
    cout<<"No"<<endl;
}

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


int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i = 1;i <= 101;i++){
		if((a * i) % b == c % b){
			printf("YES");
			return 0;
		}
	}
	printf("NO");
}

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

int main(){
    int a;
    cin >> a;
    bool flag = true;
    vector<int> paper(a);
    for(int i = 0; i < a; i++){
        cin >> paper.at(i);
    }
    int j = 0;
    while(j < a){
        if(paper.at(j) % 2 == 0){
            if(paper.at(j) % 3 != 0 && paper.at(j) % 5 != 0){
                flag = false;
            }
        }
        j++;
    }
    if(flag){
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }

}

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

def main():
     n, m = map(int, input().split())
     a_list = list(map(int, input().split()))

     a_sum = sum(a_list)
     if n >= a_sum:
          print(n - a_sum)
     else:
          print(-1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9888
#include <bits/stdc++.h>
using namespace std;
const int N = 3003;
int n;
long long dp[N][N] , a[N];


int32_t main(){
	scanf("%d" , &n);
	for(int i = 1 ; i <= n; i++)
		for(int j = 1 ; j <= n ;j ++){
			dp[i][j] = 0;
		}
	for(int i = 1 ; i <= n; i ++) scanf("%lld" , &a[i]) , dp[i][i] = a[i];
	for(int i = 2 ; i <= n; i ++){
		for(int j = 1 ; j <= n && (j + i - 1) <= n; j ++){
			dp[j][j+i-1] = max(a[j] - dp[j+1][j+i-1] , a[j+i-1] - dp[j][j+i-2]);
		}
	}
	printf("%lld\n" , dp[1][n]);
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define vec(x) vector<x>
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) for(auto i : x) cout << i << " "; cout << endl;
#define outln(x) for(auto i : x) cout << i << " " << endl;
#define vec_cpy(to,from) copy(all(to),back_inserter(from))
#define ary_cpy(to,from) memcpy(to, from, sizeof from)
#define MOD = 1000000007; 
#ifdef DEBUG
#define debug_echo(e) cout << "L" << __LINE__ << ": " << e << endl
#define debug_var(e) cout << "L" << __LINE__ << ": " << #e << " = " << e << endl
#else
#define debug_echo(e)
#define debug_var(e)
#endif

#define MAX_N 50000
#define MAX_M 20

int N;
int M;
int c[MAX_M];

int dp[MAX_N+1];

int solve() {
  for (int i=0; i<M; i++) {
    for (int j=c[i]; j<=N; j++) {
      if (dp[j] == 0) {
        dp[j] = dp[j-c[i]] + 1;
      } else {
        dp[j] = min(dp[j], dp[j-c[i]] + 1);
      } 
    }
  }
}

int main() {
  cin >> N >> M;
  rep(i, M) {
    cin >> c[i];
  }
  memset(dp, 0, sizeof(dp));
  solve();
  rep(i, N+1) {
    debug_echo(i << " " << dp[i]);
  }
  cout << dp[N] << endl;
}

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

int main(){
	int n;
	while(cin >> n && n){
		int o = -1 , p = -1 , u = 0 , c = 0 , t = 0;
		for(int i = 0 ; i < n ; i++){
			cin >> u >> c >> t;
			int d = c + t;
			if(d > o){
				p = u;
				o = d;
			}
		}
		cout << p << " " << o << endl;
	}
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
  vector<ll> Parent; 
 public:
  UnionFind(ll N){
    Parent = vector<ll>(N, -1);
  }
  
  ll root(ll A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  ll size(ll A){
    return -Parent[root(A)]; 
  }
  
  bool connect(ll A, ll B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(ll A, ll B){
    return root(A) == root(B);
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vpll v(m);
  rep(i,m){
    ll a,b; cin>>a>>b;
    a--,b--;
    v[i]={a,b};
  }
  ll ans=0;
  rep(i,m){
    UnionFind uf(n);
    rep(j,m){
      if(i==j) continue;
      uf.connect(v[j].first,v[j].second);
    }
    bool flg=false;
    rep(j,n){
      if(!uf.isSame(0,j)){
        flg=true;
      }
    }
    if(flg) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
 
using namespace std;

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if((a[a.size()-1] == b[0])&&(b[b.size()-1] == c[0])) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	int n,k;cin>>n>>k;

	vector<int> a,b;
	a.push_back(0);
	b.push_back(0);

	rep(i,n){
		int tmp;cin>>tmp;

		if(tmp<0){
			b.push_back(tmp);
		}else {
			a.push_back(tmp);
		}
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end(),greater<int>());

	ll ans = 10000000000000;
	for(int i=0; i<b.size(); i++){
		int sum =0;
		sum  = abs(b[i]);

		if(a.size()-1 >= k-i){
			sum += abs(a[k-i]);

			sum += min(abs(b[i]),abs(a[k-i]));

			ans = min(ans, (ll)sum);
			/*cout<<i<<" "<<k-i<<" "<<sum<<endl;*/
		}
	}

	writeln(ans);



}



Measured memory_bytes: 1020
import math
N = int(input())


li = [list(map(int,input().split())) for i in range(N)]

from itertools import permutations
def func(a):
    if a==1:
        return 1
    return a*func(a-1)

counter = 0
for i in permutations(range(N)):
    x_now,y_now = li[i[0]]
    path = i[1:]
    for next in path:
        x_next,y_next = li[next]
        #print(x_next,y_next,x_now,y_now) 
        ok = (x_next-x_now)**2+(y_next-y_now)**2
        distans = math.sqrt(ok)
    
        counter += distans
 
        x_now,y_now  = x_next,y_next
        #print(counter)
    #print(i)
oppai = func(N)
print(counter/oppai)

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

int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if(W>=2*r && H>=2*r){
        if((0<=x-r && x+r<=W) &&(0<=y-r && y+r<=H)){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }
    }
    else{
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 3088
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e6+4;
int m,vis[N],x;
int tim;
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}

int main() {
	m=read();
	while (1) {
		++tim;
		x=(x*10+7)%m;
		if (!x) {
			printf("%d\n",tim);
			break;
		}
		if (vis[x]) {
			puts("-1");
			break;
		}
		vis[x]=true;
	}
	return 0;
}

Measured memory_bytes: 7524
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))
    M = 1000
    S = 0
    A.append(0)

    for i in range(N):
        if A[i] < A[i+1]:
            s_new = M // A[i]
            S += s_new
            M -= s_new * A[i]
        elif A[i] > A[i+1]:
            M += S * A[i]
            S = 0
    print(M)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62316
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};
struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}



int main(){
    IOS;
    make(char,c);
    if(c>='a' && c<='z') cout<<"a \n";
    else cout<<"A \n";

    return 0;
}


Measured memory_bytes: 3580
using System;

class Atcoder79
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);

        if (a + b >= c)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stdio.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main() {
	int K, N;
	cin >> K >> N;
	vector <int> A(N);
	rep(i, N) {
		cin >> A.at(i);
	}

	int dmax = 0;
	int d = 0;
	rep(i, N - 1) {
		d += A.at(i + 1) - A.at(i);
		dmax = max(dmax, A.at(i + 1) - A.at(i));
	}

	d += A.at(0) + K - A.at(N - 1);
	dmax = max(dmax, A.at(0) + K - A.at(N - 1));

	cout << d - dmax << endl;

	return 0;

}

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

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
using llint = long long int ;
using namespace std;

int Factional(int x){
    int Bi=1;
    for (int i = 1; i <= x; i++) {Bi*=i;}
    return Bi;
}

int main(){
    int N;
    int P[10];
    int Q[10];
    cin>>N;
    vector<int> num{1,2,3,4,5,6,7,8,9};
    rep(i,N){
        cin>>P[i];
    }
    rep(i,N){
        cin>>Q[i];
    }
    int pc=1;
    int qc=1;
    rep(i,N){
        int kazu=0;
        for (int &e:num) {
            ++kazu;
            if (e==P[i])
            {
                num.erase(num.begin()+kazu-1);
                break;
            }
        }
        pc+=(kazu-1)*Factional(N-i-1);
    }

    vector<int> numb{1,2,3,4,5,6,7,8,9};
    rep(i,N){
        int kazu=0;
        for (int &e:numb) {
            ++kazu;
            if (e==Q[i])
            {
                numb.erase(numb.begin()+kazu-1);
                break;
            }
        }
        qc+=(kazu-1)*Factional(N-i-1);
    }
    cout<<abs(pc-qc)<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python


def count_divisor(num):
    c = 0
    for i in range(1, num + 1):
        if num % i == 0:
            c += 1
    return c


n = int(input().strip())

count = 0
for i in range(1, n + 1, 2):
    if count_divisor(i) == 8:
        count += 1

print(count)


Measured memory_bytes: 2940
#include <cstdio>
#include <utility>
#include <map>

using namespace std;

typedef pair <int, int> ii;

#define MOD 1000000007

int x, y;
//n + 2m = x
//2n+ m = y
int n, m;

long long fact[1000005];

long long fastExp(int base, int power)
{
    if (power == 1) return base % MOD;
    long long ans = fastExp(base, power / 2);
    ans *= ans;
    ans %= MOD;
    if (power % 2 == 1)
    {
        ans *= base % MOD;
    }
    return ans % MOD;
}

long long choose(int n, int r)
{
    if (n == r || r == 0) return 1;
    return (fact[n] % MOD * (fastExp(fact[r] % MOD, MOD - 2) % MOD * fastExp(fact[n - r] % MOD, MOD - 2) % MOD) % MOD ) % MOD;
}

int main()
{
	scanf("%d%d", &x, &y);
	if ((x + y) % 3 != 0)
	{
		printf("0\n");
	}
	else
	{
		m = (2 * x - y) / 3;
		n = x - 2 * m;
		if (n < 0 || m < 0) printf("0\n");
		else
		{
		    fact[1] = 1;
		    for (int i = 2; i <= n + m; i++) fact[i] = (fact[i - 1] * i) % MOD;
			printf("%lld\n", choose(n + m, n));
		}
	}
	return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
typedef long long ll;

int n,m,k;
string s,t;
char c;

int main() {
  cin >> n >> m;
  pair<int,string> p[m];
  int a,ac=0,wa=0; string s; bool ok[n]; vector<int> w(n,0);
  rep(i,m){
    cin >> a >> s;
    if(s=="AC" && !ok[a]) ac++ , wa+=w[a], ok[a]=true;
    if(s=="WA" && !ok[a]) w[a]++;
  }
  cout << ac << " " << wa << endl;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

string keyence="keyence";

int main() {
  string S;
  cin >> S;
  bool judge[7];
  rep(i, 7)
    judge[i]=false;
  int N=S.size();
  rep(i, 7){
  if(S[i]==keyence[i]){
  judge[i]=true;
  }
  if(S[N-1-i]==keyence[7-1-i]){
  judge[7-1-i]=true;
  }
    
  
  }
  rep(i, 7){
  if(judge[i]==false){
  cout << "NO" << endl;
  return 0;
  }
  }
  
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#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>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-13;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int x[110];
int y[110];
int p[110];
double g[20][20];
double t[1<<15];
double dp[1<<15];
int UF[20];
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;
}
pair<double,pair<int,int> > edge[400];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d%d%d",x+i,y+i,p+i);
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			g[i][j]=sqrt((long long)(x[i]-x[j])*(x[i]-x[j])+(long long)(y[i]-y[j])*(y[i]-y[j]));
		}
	}
	for(int i=1;i<(1<<a);i++){
		double tmp=0;
		int cnt=0;
		for(int j=0;j<a;j++){
			if(i&(1<<j)){
				cnt++;
				tmp+=p[j];
			}
		}
		for(int j=0;j<a;j++){UF[j]=-1;}
		int sz=0;
		for(int j=0;j<a;j++){
			for(int k=j+1;k<a;k++){
				if(i&(1<<j)){
					if(i&(1<<k)){
						edge[sz++]=make_pair(g[j][k],make_pair(j,k));
					}
				}
			}
		}
		std::sort(edge,edge+sz);
		for(int j=0;j<sz;j++){
			if(FIND(edge[j].second.first)!=FIND(edge[j].second.second)){
				tmp-=edge[j].first;
				UNION(edge[j].second.first,edge[j].second.second);
			}
		}
		t[i]=tmp/cnt;
	}
	dp[0]=mod;
	for(int i=1;i<(1<<a);i++){
		int j=i;
		while(j){
			dp[i]=max(dp[i],min(dp[i-j],t[j]));
			j=((j-1)&i);
		}
	}
	printf("%.12f\n",dp[(1<<a)-1]);
}

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

using namespace std;
#define _rep(n, a, b) for (int n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (int n = (a); n >= (b); --n)
#define _for(n, a, b) for (int n = (a); n < (b); ++n)
#define _rof(n, a, b) for (int n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-3
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pdd pair<db, db>
#define endl "\n"
const int mod = 1e9 + 7;
const int maxn = 2000+10;
vector<int> a, sub;
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin >> x;
    x %= 1000;
    cout << (1000 - x)%1000 << endl;
}

Measured memory_bytes: 3636
n = int(input())
arr = input().split()
count = 0

for i in range(1, n-1):
  if int(arr[i-1]) < int(arr[i]) < int(arr[i+1]) or int(arr[i-1]) > int(arr[i]) > int(arr[i+1]): count +=1
    
print(count)

Measured memory_bytes: 8908
def combination(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = 1
    for i in range(n, n - r, -1):
        over = over * i % p
    under = 1
    for i in range(1, r + 1):
        under = under * i % p
    inv = pow(under, p - 2, p)
    return over * inv % p

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a ** 2 % mod
        n >>= 1
    return res

n, a, b = map(int, input().split())
mod = 10**9 + 7
ans = modpow(2, n, mod) - combination(n, a, mod) - combination(n, b, mod) - 1
while ans < 0:
    ans += mod
print(ans)

Measured memory_bytes: 3064
MOD = int(1e9+7)


def div(a, b):
    return a * pow(b, MOD-2, MOD) % MOD


def main():
    N = int(input())
    A = list(map(int, input().split()))
    M = 60
    bitcnt = [0] * M
    for a in A:
        for i in range(M):
            if a & (1 << i):
                bitcnt[i] += 1
    ans = 0
    for a in A:
        for i in range(M):
            x = 1 << i
            if a & x:
                ans = (ans + x * (N - bitcnt[i])) % MOD
            else:
                ans = (ans + x * bitcnt[i]) % MOD
    ans = div(ans, 2)
    print(ans)


if __name__ == "__main__":
    main()


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

int readnum(void){
	int n=0,i=0;			// data number
	char buf[1024];	// data buffer
	cin.getline(buf,1024);
	while(buf[i] != '\0'){
		n = n*10 + buf[i] - '0';
		i++;
	}
	return n;		// return data number
}

int readdata(int n,int *x){
	int i=0,j=0;
	char dataBuf[1024];		// buffer
	cin.getline(dataBuf, 1024);
	while(dataBuf[i] !='\0'){
		x[j]=0;
		while(!(dataBuf[i] == ' ' || dataBuf[i] == '\0')){
			x[j] = x[j]*10 + dataBuf[i]-'0';
			i++;
		}
		i++;
		j++;
	}
	if(n == j)
		return n;	// read data number
	else
		return -1;	// error read data number not equal the given number
}


int main() {
	int x[1000],n;

	n = readnum();
	if (readdata(n,x)) {
		for(int i=n-1;i>0;i--)
			cout << x[i] << ' ';
		cout << x[0] << endl;
	}


	return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> A){
  vector<ll> cap(N+1);
  if(N==0){
    if(A[0]==1){
      cout<<1<<endl;
    }else{
      cout<<-1<<endl;
    }
    return;
  }
  if(A[0]>0){
    cout<<-1<<endl;
    return ;
  }
  ll cur=1,ans=0;
  REP(N+1){
    if(cur<A[i]){
      cout<<-1<<endl;
      return;
    }
    cur-=A[i];
    cap[i]=cur;
    if(cur<INF){
      cur*=2;
    }
  }
  cur=0;
  Rev(i,N+1){
    cur=min(cur,cap[i]);
    cur+=A[i];
    ans+=cur;
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N-0+1);
    for(int i = 0 ; i < N-0+1 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4868
#include <iostream>
#include <algorithm>
using namespace std;
int N, C, s, t, c, a[33][100009], x[100009];
int main() {
	cin >> N >> C;
	for (int i = 0; i < N; i++) {
		cin >> s >> t >> c; c--;
		for (int j = s; j < t; j++) a[c][j] = 1;
	}
	for (int i = 0; i < C; i++) {
		for (int j = 0; j <= 100000; j++) {
			if (a[i][j + 1]) a[i][j] = 1;
			x[j] += a[i][j];
		}
	}
	cout << *max_element(x, x + 100001) << endl;
	return 0;
}

Measured memory_bytes: 12544
#include<iostream>
bool is_prime(int n){
    if(n%2==0&&n!=2){
        return false;
    }else{
        for(int i=2;i*i<=n;i++){
            if(n%i==0){
                return false;
            }
        }
    }
    return true;
}
int main(){
    int n,count;
    std::cin>>n;
    for(int i=0;i<n;i++){
        int a;
        std::cin>>a;
        if(is_prime(a))count++;
    }
    std::cout<<count<<std::endl;
    return 0;
}


Measured memory_bytes: 3100
def RL(r,l):
    # rが偶数であるなら、[0,r+l]に含まれる奇数の数がRに集まる
    # rが奇数であるなら、[0,r+l]に含まれる偶数の数がRに集まる

    # rが偶数であるなら、[1,r+l+1]に含まれる偶数の数がRに集まる
    # rが奇数であるなら、[1,r+l+1]に含まれる奇数の数がRに集まる

    hoge = (r+l+1)//2
    if r % 2:
        return [hoge,r+l-hoge]
    else:
        return [r+l-hoge,hoge]

o = []
S = input()+"#"
rr = 0
ll = 0
for s in S:
    if s == "#":
        rrr,lll = RL(rr,ll)
        o += [0] * (rr-1)
        o += [rrr]
        o += [lll]
        o += [0] * (ll-1)
        for i in range(len(o)):
            print(o[i],end='')
            print(' ',end='')
        print()
        exit()
    elif s == "R":
        if ll != 0:
            rrr,lll = RL(rr,ll)
            o += [0] * (rr-1)
            o += [rrr]
            o += [lll]
            o += [0] * (ll-1)
            rr = 1
            ll = 0
        else:
            rr += 1
    else:
        ll += 1

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    string s;
    char c;
    while(cin >> c){
        if(c !='B') s += c;
        else if(s !="") s.pop_back();
   } 
   cout << s;
}


Measured memory_bytes: 256
/*
 Eleven Lover(https://onlinejudge.u-aizu.ac.jp/#/problems/2182)
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

const int MAX = 80080;

int dp[MAX][11];

void solve(void){
    while (1) {
        string N;
        cin >> N;
        if (N == "0") return;
        memset(dp, 0, sizeof(dp));
        int L = N.size();
        rep(L, l) {
            int d = N[l]-'0';
            if (d != 0) dp[l+1][d]++;
            rep(11, m) {
                dp[l+1][(m*10+d)%11] += dp[l][m];
            }
        }
        int ans = 0;
        rep(L, i) ans += dp[i+1][0];
        /*
        rep(L+1, i) {
            rep(11, m) printf("%d ", dp[i][m]);
            printf("\n");
        }*/
        cout << ans << endl;
    }
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}



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

int common( map<char,int> small , map<char,int> large  )
{
    int ans =0;
    map<char,int> :: iterator  it = small.begin();
    while( it != small.end()  )
    {
        char t = it->first;
        if( large[t] > 0 )
        {
            ans++;
        }
        it++;
    }
    return ans;
}

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    map<char , int> large , small;
    for(int i=0;i<n;i++)
    {
        large[s[i] ]++;
    }
    int ans =0;
    for(int i=0;i<n;i++)
    {
        small[ s[i]] ++;
        large [ s[i]]--;
        ans = max(ans , common(small , large));
    }
    cout<<ans;
}

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

using namespace std;

using ll = long long;

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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string op = string(ty - sy, 'U') + string(tx - sx, 'R');
    op += string(ty - sy, 'D') + string(tx - sx, 'L');
    op += "L" + string(ty - sy + 1, 'U') + string(tx - sx + 1, 'R');
    op += "DR" + string(ty - sy + 1, 'D') + string(tx - sx + 1, 'L') + "U";

    cout << op << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;
ll C[55][55];

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
	
	int n,aa,b;

	for(int i=0;i<=50;i++){
		for(int j=0;j<=i;j++){
			if(j==0 || j==i)C[i][j]=1;
			else	C[i][j]=C[i-1][j-1]+C[i-1][j];
		}
	}
	scanf("%d %d %d",&n,&aa,&b);

	std::vector<ll> a(n);
	map<double,ll>ways;
	double ans = 0;
	map<ll,int>occ;
	for(int i=0;i<n;i++)scanf("%lld",&a[i]),occ[a[i]]++;
	double curr = 0 ;
	map<ll,int>wa;
	sort(all(a));
	for(int i=n-1;i>=n-aa;i--){
		if((n-i)>b)break;
		curr+=a[i];
		wa[a[i]]++;
		if((n-i)>=aa){
			if(ans == 0 || (ans-curr/(n-i)) <= 0){
				ans = curr/(n-i);
				ll x = 1;
				for(auto p : wa){
					x*=C[occ[p.first]][p.second];
				}
				ways[ans]+=x;
			}
		}
	}
	if(a[n-1]==a[n-aa]){
		for(int i=aa;i<min(b,occ[a[n-aa]]);i++)ways[ans]+=C[occ[a[n-aa]]][i+1];
	}
	printf("%.9lf\n%lld",ans,ways[ans] );
}		


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	int h, w;
	cin >> h >> w;
	REP(i, h+2) {
		if (i == 0||i == h+1) {
			REP(j, w+2) {
				cout << "#";
			}
		}
		else {
			cout << "#";
			string s;
			cin >> s;
			cout << s << "#";
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second

priority_queue<pair<int,int> > LL,RR,L,R;
bool vis[100005];
long long ans1,ans2;
int n;

void PlanA(int now,long long &ans)
{
	while (!L.empty() && vis[L.top().se]) L.pop();
	while (!R.empty() && vis[R.top().se]) R.pop();
	if (!L.empty() && L.top().fi>now)
	{
		ans+=L.top().fi-now;
		now=L.top().fi;
		vis[L.top().se]=1;
		L.pop();
		PlanA(now,ans);
	}
	else if (!R.empty() && -R.top().fi<now)
	{
		ans+=now+R.top().fi;
		now=-R.top().fi;
		vis[R.top().se]=1;
		R.pop();
		PlanA(now,ans);
	}
	else ans+=abs(now);
}

void PlanB(int now,long long &ans)
{
	while (!L.empty() && vis[L.top().se]) L.pop();
	while (!R.empty() && vis[R.top().se]) R.pop();
	if (!R.empty() && -R.top().fi<now)
	{
		ans+=now+R.top().fi;
		now=-R.top().fi;
		vis[R.top().se]=1;
		R.pop();
		PlanB(now,ans);
	}
	else if (!L.empty() && L.top().fi>now)
	{
		ans+=L.top().fi-now;
		now=L.top().fi;
		vis[L.top().se]=1;
		L.pop();
		PlanB(now,ans);
	}
	else ans+=abs(now);
}

int main()
{
	scanf("%d",&n);
	for (int i=1,l,r;i<=n;i++)
	{
		scanf("%d%d",&l,&r);
		LL.push(mp(l,i));
		RR.push(mp(-r,i));
	}
	L=LL,R=RR;
	PlanA(0,ans1);
	memset(vis,0,sizeof(vis));
	L=LL,R=RR;
	PlanB(0,ans2);
	printf("%lld\n",max(ans1,ans2));
}

Measured memory_bytes: 3692