akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

vector<int> bs[10];
int dp[2001];
int N,K;
int main() {
	cin >> N >> K;
	for(int i=0;i<N;i++){
		int c,g;
		cin >> c >> g;
		g--;
		bs[g].push_back(c);
	}
	for(int i=0;i<10;i++){
		sort(bs[i].begin(),bs[i].end(),greater<int>());
		for(int j=1;j<bs[i].size();j++){
			bs[i][j]+=bs[i][j-1];
		}
	}
	int total=0;
	for(int i=0;i<10;i++){
		total+=bs[i].size();
		for(int j=min(total,K);j>0;j--){
			for(int k=1;k<=min(j,(int)bs[i].size());k++){
				int v=dp[j-k]+bs[i][k-1]+(k-1)*k;
				dp[j]=max(dp[j],v);
			}
		}
	}
	cout << dp[K] << endl;
}

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

int main() {
  int N; cin >> N;
  int min_num = N;
  string S; cin >> S;
  vector<int> E(N), W(N);


  for(int i = 0; i < N; i++){
    if(S[i] == 'W'){
      if(i == 0) W[0]++;
      else W[i] = W[i-1] + 1;
    } 
    else W[i] = W[i-1];

    if(S[N-1-i] == 'E'){
      if(i == 0) E[N-i-1]++;
      else E[N-1-i] = E[N-i] + 1;
    } 
    else E[N-1-i] = E[N-i];

  }


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

    if(i == 0) num = E[1];
    else if(i == N-1) num = W[N-1];
    else num = E[i+1] + W[i-1];

    min_num = min(min_num, num);
  }

  cout << min_num;
  return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end



int main(){
   int n; scanf("%d",&n);
   vector<int> a(n); rep(i,0,n)scanf("%d",&a[i]);
   int p=1; ll res=a[0]-1;
   rep(i,1,n){
      if(a[i]==p+1)p++;
      else if(a[i]>p+1)res+=(a[i]-1)/(p+1);
   }
   printf("%lld\n",res);
   return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll A, B, C, X, Y;
    while (cin >> A >> B >> C >> X >> Y) {
        ll ans = LLONG_MAX;
        for (ll i = 0;; i += 2) {
            ll x = max(0ll, X - i / 2);
            ll y = max(0ll, Y - i / 2);
            smin(ans, x*A + y*B + i*C);
            if (x + y == 0)break;
        }
        cout << ans << endl;
    }
}

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

int main(){
  string s;
  cin >> s;
  int l = s.length();
  if(l % 2) {
    cout << "No" << endl;
    return 0;
  }
  bool f = true;
  rep(i,l) {
    if(f && s[i] == 'h') f = !f;
    else if(!f && s[i] == 'i') f = !f;
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>){
    val inputList = readLine()!!.split(" ").map{ it.toInt() }
    val n = inputList[0]
    val m = inputList[1]
    var isFirst = true
    val answerList: MutableList<Int> = mutableListOf<Int>()

    for (i in 0 until n) {
        val aList = readLine()!!.split(" ").map{ it.toInt() }.drop(1)
        if (isFirst) {
            answerList.addAll(aList)
            isFirst = false
            continue
        }
        answerList.retainAll { aList.contains(it) }
    }

    println(answerList.size)
}


Measured memory_bytes: 37864
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

int main(){
    int n;
    cin>>n;
    vector<tuple<string,int,int>> a;
    for(int i=1;i<=n;++i){
        string s;
        int p;
        cin>>s>>p;
        p=-p;
        a.push_back(tie(s,p,i));
    }
    sort(a.begin(),a.end());
    rep(i,n){
        cout<<get<2>(a[i])<<endl;
    }
}



Measured memory_bytes: 3532
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, l;
	cin >> n >> l;

	vector<string> str(n);

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

	sort(str.begin(), str.end());

	for (int i = 0; i < n; i++) {
		cout << str[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
data = []

for i in range(N):
    x, y, h = map(int, input().split())
    data.append([x, y, h])

data = sorted(data, key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        flag = True
        H = data[0][2] + abs(data[0][0]-cx) + abs(data[0][1]-cy)
        for i in range(1, len(data)):
            if not max(H - abs(data[i][0]-cx) - abs(data[i][1]-cy), 0) == data[i][2]:
                flag = False
                break

        else:  # 全て条件を満たしていたら出力
            print(cx, cy, H)
            exit()


Measured memory_bytes: 3064
main( )
{int a, b, c,i ,num[3];
  for(i = 0 ; i < 3 ; i++)
    {scanf("%d",&num[i]);}     
  if( num[0] > num[1])
    { a = num[0];
  num[0] = num[1];
  num[1] = a ;} 
  if(num[1] > num[2])
    {b = num[1];
  num[1] = num[2];
  num[2] = b;
  if(num[0] > num[1])
    {c = num[0];
  num[0] = num[1];
  num[1] = c;}}
  printf("%d %d %d\n", num[0], num[1], num[2]);
  return 0;}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

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

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }
ll findSum(ll n)
{

    ll sum2, sum5, sum10;

    sum2 = ((n / 3) * (6 + (n / 3 - 1) * 3)) / 2;

    sum5 = ((n / 5) * (10 + (n / 5 - 1) * 5)) / 2;

    sum10 = ((n / 15) * (30 + (n / 15 - 1) * 15)) / 2;

    return sum2 + sum5 - sum10;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);


		ll n;
		cin>>n;
		ll ans=(n*(n+1))/2;
		cout<<ans-findSum(n);

	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
const long long P=1000000007ll;
long long n,k,f[10001];
inline long long qpow(long long a,int x){
    if(x<0)return 1;
    long long s=1ll;
    while(x){if(x&1)(s*=a)%=P;(a*=a)%=P;x>>=1;}
    return s;
}
int main(){
    scanf("%lld%lld",&n,&k);
    f[0]=1ll;
    for(int i=1;i<n;++i){for(int j=i;j;--j)f[j]=(f[j+1]+f[j-1])%P;f[0]=f[1];}
    printf("%lld",f[n-k]*qpow(2ll,n-k-1)%P);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin>>n>>m;
    vector<vector<long long int> > v(n, vector<long long int>(2, 0));
    for(int i=0; i<n; i++)
        cin>>v[i][0]>>v[i][1];
    sort(v.begin(), v.end());
	long long int dp[n+1][m+1];
	memset(dp, 0, sizeof(dp));
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
        	dp[i][j] = dp[i-1][j];
        	if(j-v[i-1][0]>=0)
        	{
        		dp[i][j] = max(dp[i][j], dp[i-1][j-v[i-1][0]]+v[i-1][1]);
			}
		}
    }
//    for(int i=1; i<=n; i++)
//    {
//        for(int j=1; j<=m; j++)
//        {
//        	cout<<dp[i][j]<<" ";
//		}
//		cout<<endl;
//    }
    cout<<dp[n][m]<<endl;
    return 0;
}

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

int main() {
	int n;
	cin>>n;
	int arr[n];

	for(int i=0;i<n;i++)
	cin>>arr[i];
	
	for(int i=0;i<n-1;i++)
	{
		if(arr[i]>=arr[i+1]&&arr[i]>arr[i-1])
		{
			arr[i]=arr[i]-1;
		}
	}
	
	int flag=0;
	
	for(int i=0;i<n-1;i++)
	{
		if(arr[i]>arr[i+1])
		{
			flag=1;
			break;
		}
	}
	
	if(flag==0||n==1)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n/100==7 || ((n/10)%10)==7 || (n%10)==7){
    cout << "Yes" << "\n";
  }
  else{
    cout << "No" << "\n";
  }
  return 0;
}

Measured memory_bytes: 3636
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
	for(int i=0;i<5;i++)
	{
		int x;
		cin>>x;
		if(!x)
		{
			cout<<i+1;
			return ;
		}
	}
}
int main()
{
//code
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
    int v;
    ll c;
    node() {}
    node(int v_, ll c_):
        v(v_), c(c_)
    {}
};
int N, M;
vector<vector<node> > e;
vector<ll> dis;
vector<bool> inq;
vector<ll> inq_cnt;
set<int> st;

void spfa(){
    queue<int> q;
    dis.clear(); dis.resize(N, LLONG_MAX );
    inq.clear(); inq.resize(N, false);
    inq_cnt.clear(); inq_cnt.resize(N, 0);
    q.push(0);
    dis[0]=0;
    inq[0]=true;
    inq_cnt[0]=1;
    while(!q.empty()){
        int u=q.front(); q.pop();
        inq[u]=false;
        for(int i=0; i<e[u].size(); ++i){
            int v=e[u][i].v;
            if(v==u)
                continue;
            ll c=e[u][i].c;
            if(dis[u]+c<dis[v]){
                dis[v]=dis[u]+c;
                if(!inq[v]){
                    ++inq_cnt[v];
                    if(inq_cnt[v]>N){
                        st.insert(v);
                        continue;
                    }
                    inq[v]=true;
                    q.push(v);
                    ++inq_cnt[v];
                }
            }
        }
    }
}

int main(){
    cin>>N>>M;
    e.clear(); e.resize(N, vector<node>());
    for(int i=0; i<M; ++i){
        int u, v;
        ll c;
        cin>>u>>v>>c;
        --u; --v;
        e[u].push_back(node(v, -c));
    }
    spfa();
    vector<bool> vis(N, false);
    for(auto it=st.begin(); it!=st.end(); ++it){
        int u=*it;
        queue<int> q;
        vis[u]=true;
        q.push(u);
        while(!q.empty()){
            u=q.front(); q.pop();
            for(int i=0; i<e[u].size(); ++i){
                int v=e[u][i].v;
                if(!vis[v]){
                    vis[v]=true;
                    q.push(v);
                }
            }
        }
    }
    if(vis[N-1]){
        cout<<"inf"<<endl;
    }else{
        cout<<-dis[N-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 100000000;
const int MAX_N = 50;
using namespace std;
int main() {
	int a,b;
  	cin>>a>>b;
 	int cnt=0;
  	for(int i=a; i<=b; i++){
      int k=i;
      int x=k%10; k=k/10;
      int y=k%10; k=k/10;
      int z=k%10; k=k/10;
      int w=k%10; k=k/10;
      int u=k%10; 
      if(x==u&&y==w){
        cnt++;
      }
    }
      cout<<cnt<<endl;
}









Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Scanner s = new Scanner(System.in);
        String str = s.next();
        int changes = 0;
        
        char[] cs = {str.charAt(0), '0'};
        if (cs[0] == '0')
            cs[1] = '1';
        
        for (int i = 0; i < str.length(); i ++) {
            if (str.charAt(i) != cs[i % 2])
                changes ++;
                
        }
        
        System.out.println(changes);
        
    }
    
}


Measured memory_bytes: 24032
#include<iostream>
using namespace std;
int main(){
    int x,y;
    while(true){
        cin >> x >> y;
        if(x==0 && y==0){break;
        }else if(x<y){
            cout << x << " " << y <<endl;
        }else{
            cout << y << " " << x <<endl;
        }
    }return 0;
}


Measured memory_bytes: 2996
#include<iostream>
#include<cstdio>
#include<ctype.h>
#include<algorithm>
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int x[100007];
int main(){
	int n=read(),l=read(),t=read(),c=0;
	for(int i=1;i<=n;++i){
		int r=read()+(-2*read()+3)*t;
		if(r>0)(c+=r/l)%=n;
		else if(r)(c+=(r+1)/l-1)%=n;
		x[i]=(r%l+l)%l;
	}
	sort(x+1,x+n+1);
	c=(c+n)%n;
	for(int i=c+1;i<=n;++i)printf("%d\n",x[i]);
	for(int i=1;i<=c;++i)printf("%d\n",x[i]);
	return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;


int main(){
   char b;
   cin >> b;
   switch(b){
      case 'A':
         cout << "T" << endl;
         break;
      case 'C':
         cout << "G" << endl;
         break;
      case 'G':
         cout << "C" << endl;
         break;
      case 'T':
         cout <<"A"<< endl;
         break;
   }
   return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
 
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;
 
template <typename _T>
inline void read(_T &f) {
	f = 0; _T fu = 1; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
	while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
	f *= fu;
}
 
template <typename T>
void print(T x) {
	if (x < 0) putchar('-'), x = -x;
	if (x < 10) putchar(x + 48);
	else print(x / 10), putchar(x % 10 + 48);
}
 
template <typename T>
void print(T x, char t) {
	print(x); putchar(t);
}

const ll INF = 0x7f7f7f7f7f7f7f7f, INFF = 1e18 + 5;
const int N = 70;

inline void addmin(ll &x, ll y) { x = min(x, y); }

ll f[N][N][N][2], p[N][N][N];
int T, a, b, c, d; ll n, ans;

int main() {
	p[0][0][0] = 1;
	for (int i = 0; i <= 60; i++) {
		for (int j = 0; j <= 60; j++) {
			for (int k = 0; k <= 60; k++) {
				p[i + 1][j][k] = min(INFF, p[i][j][k] * 2);
				p[i][j + 1][k] = min(INFF, p[i][j][k] * 3);
				p[i][j][k + 1] = min(INFF, p[i][j][k] * 5);
			}
		}
	}
	read(T);
	while (T--) {
		memset(f, 0x7f, sizeof(f));
		read(n); read(a); read(b); read(c); read(d);
		f[0][0][0][0] = 0; ans = INF;
		for (int i = 0; i <= 60; i++) {
			for (int j = 0; j <= 60; j++) {
				for (int k = 0; k <= 60; k++) {
					for (int t = 0; t <= 1; t++) {
						if (f[i][j][k][t] == INF) continue;
						if ((double)(n / p[i][j][k]) * d > INFF) continue;
						addmin(ans, f[i][j][k][t] + (n / p[i][j][k] + t) * d);
					}
					if (p[i][j][k] >= INFF) break;
					for (int t = 0; t <= 1; t++) {
						if (f[i][j][k][t] == INF) continue;
						ll cnt = n / p[i][j][k] + t;
						addmin(f[i + 1][j][k][0], f[i][j][k][t] + a + abs(n / p[i + 1][j][k] * 2 - cnt) * d);
						addmin(f[i][j + 1][k][0], f[i][j][k][t] + b + abs(n / p[i][j + 1][k] * 3 - cnt) * d);
						addmin(f[i][j][k + 1][0], f[i][j][k][t] + c + abs(n / p[i][j][k + 1] * 5 - cnt) * d);
						addmin(f[i + 1][j][k][1], f[i][j][k][t] + a + abs((n / p[i + 1][j][k] + 1) * 2 - cnt) * d);
						addmin(f[i][j + 1][k][1], f[i][j][k][t] + b + abs((n / p[i][j + 1][k] + 1) * 3 - cnt) * d);
						addmin(f[i][j][k + 1][1], f[i][j][k][t] + c + abs((n / p[i][j][k + 1] + 1) * 5 - cnt) * d);
					}
				}
			}
		}
		print(ans, '\n');
	}
	return 0;
}

Measured memory_bytes: 11280
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = Integer.parseInt(sc.next());
		Arrays.sort(a);
		int N = a[n - 1];
		int R = 0;
		double t = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			double diff = Math.abs((double)N / 2 - a[i]);
			if (diff < t) {
				t = diff;
				R = a[i];
			}
		}
		System.out.println(N + " " + R);
	}
}

Measured memory_bytes: 47300
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n;
  cin >> n;
  
  FOR(i,1,10) {
    if (n%i==0 && (1<=n/i && n/i<=9)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

llint n, a, b, k;

const int FACT_MAX = 400005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main(void)
{
	cin >> n >> a >> b >> k;
	make_fact();
	
	llint ans = 0;
	for(int i = 0; i <= n; i++){
		llint rem = k - a*i;
		if(rem < 0 || rem % b || rem/b > n) continue;
		ans += comb(n, i) * comb(n, rem/b) % mod;
		ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 6528
N = int(input())
A = list(input().split(" "))

class Card:
    def __init__(self,suit,num):
        self.suit = suit
        self.value = int(num)
        self.id = suit+num
        
    

B_bubble = [Card(a[0],a[1])for a in A]
B_selection = [b for b in B_bubble]

B_id = [b.id for b in B_bubble]

def BubbleSort(C,N):
    for i in range(N):
        for j in range(N-1,i,-1):
            if C[j].value < C[j-1].value:
                tmp = C[j]
                C[j] = C[j-1]
                C[j-1] = tmp
        #print([b.id for b in C])
    return C
    
def SelectionSort(C, N):
    for i in range(N):
      minj = i
      for j in range(i,N):
        if C[j].value < C[minj].value:
          minj = j
      tmp = C[i]
      C[i] = C[minj]
      C[minj] = tmp
      #print([b.id for b in C])
    return C

def stable_check(B_id,C_id):
    tmp = C_id[0]
    for i in range(1,len(C_id)):
        c = C_id[i]
        if c[1]!=tmp[1]:
            tmp = c
            continue
        if B_id.index(tmp)>B_id.index(c):
            return "Not stable" 
        tmp = c
    return "Stable"
    

C_bubble =  [b.id for b in BubbleSort(B_bubble,N)]
print(" ".join(C_bubble))
#C_bubble_id = [b.id for b in C_bubble]
print(stable_check(B_id,C_bubble))

C_selection =  [b.id for b in SelectionSort(B_selection,N)]
print(" ".join(C_selection))
#C_selection_id = [b.id for b in C_selection]
print(stable_check(B_id,C_selection))




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

int maxtime(int x){
  return (x + 9) / 10 * 10;
}

int remtime(int x){
  return maxtime(x) - x;
}

int main(){
  int A,B,C,D,E;
  cin >> A >> B >> C >> D >> E;
  
  int sum;
  sum = maxtime(A) + maxtime(B) + maxtime(C) + maxtime(D) + maxtime(E);
  sum -= max({remtime(A),remtime(B),remtime(C),remtime(D),remtime(E)});
  
  cout << sum << endl;
  return 0;
}


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

int main(void){

    string S; cin>>S;
    char past=S[0];
    for (int i = 1; i < S.size(); ++i) {
        if(past==S[i]){
            cout<<"Bad"<<endl;
            return 0;
        }
        past=S[i];
    }
    cout<<"Good"<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();

		int ans = 0;
		for(int i = 0; i < m; i++) {
			int a = sc.nextInt();
			if(x < a) {
				ans = Math.min(i, m - i);
				break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23508
#include<bits/stdc++.h>
#define mp make_pair
#define x first
#define y second
#define pll pair<LL,LL>
#define pii pair<int,int>
#define LL long long
#define pb push_back
#define pi acos(-1)
#define pdd pair<double,double>
#define MEM(x) memset(x,0,sizeof(x))
#define EPS 1e-7
using namespace std;
int Size[5005];
int f[5005];
int mod=1e9+7;
int Find(int x){
    if(f[x]==x)return x;
    return f[x]=Find(f[x]);
}
LL f_pow(LL a,LL b){
    LL res=1,temp=a;
    while(b){
        if(b&1)res=res*temp%mod;
        temp=temp*temp%mod;
        b>>=1;
    }
    return res;
}
LL dp[5005];

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i<=n;i++)f[i]=i,Size[i]=1;
    int p[5005];
    int cnt=0;
    int tot=0;
    for(int i = 1;i<=n;i++){
        scanf("%d",&p[i]);
        if(p[i]!=-1){
            if(Find(p[i])!=Find(i)){
                int a=Find(p[i]),b=Find(i);
                f[a]=b;
                Size[b]+=Size[a];
               // cnt++;
            }
            else{
                cnt++;
            }
        }
        else{
            tot++;
        }
    }
    LL ans=cnt*f_pow(n-1,tot)%mod;
 //   printf("%lld %d\n",ans);
    dp[0]=1;
    for(int i = 1;i<=n;i++){
        if(p[i]==-1){
           // printf("%d\n",Size[Find(i)]);
            for(int j = n-1;j>=0;j--){
                dp[j+1]+=dp[j]*max(j,1)%mod*Size[Find(i)]%mod;
                dp[j]=dp[j]*(n-1)%mod;
                //printf("%lld ",dp[j]);
            }
          /*  for(int j = 0;j<=n;j++){
                printf("%lld ",dp[j]);
            }
            printf("\n");*/
            ans+=(Size[Find(i)]-1)*f_pow(n-1,tot-1)%mod;
        }
        
    }
// printf("%lld\n",ans);
    for(int i=2;i<=n;i++){
        ans+=dp[i];
        ans%=mod;
    }
 //   printf("%lld\n",ans);
    printf("%lld\n",((f_pow(n-1,tot)*n-ans)%mod+mod)%mod);
}
/*
2 11 14
9 3
0 1 2 3
0 1 2 3
0 1 2 3
0 1 2 3
0 1 2 3
3**5+3**5-2**5
000111222
001112220
*/

Measured memory_bytes: 3912
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;


int main() {
    uint64_t A;
	string B;

	cin >> A >> B;
	int len = B.length();

	B.erase(remove(B.begin(), B.end(), '.'), B.end());

	uint64_t b = atoll(B.c_str());
	B = to_string(A * b);

	switch (len)
	{
		case 3:
			if (B.length() > 1)
				B = B.substr(0, B.size() - 1);
			else
				B = "0";
			break;
		case 4:
			if (B.length() > 2)
				B = B.substr(0, B.size() - 2);
			else
				B = "0";
			break;
		case 1:
		case 2:
		default:
			break;
	}

	cout << B << endl;
	return 0;
}



Measured memory_bytes: 3108
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  int n = readln.chomp.to!int;
  bool[int] set;
  foreach (i; 0..n) {
    int a = readln.chomp.to!int;
    if (a in set) {
      set.remove(a);
    } else {
      set[a] = true;
    }
  }
  writeln = set.length;
}


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

int main(){
	int m,d;
	cin>>m>>d;
	int s,t;
	int ans=0;
	for (int i = 1; i <=m; i++) {
		for (int j = 1; j <=d; j++) {
			s=j/10;
			t=j%10;
			if (s<2||t<2) {
				continue;
			}
			if (s*t==i) {
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int a,b;
    cin >> a >> b;
    int sa=b-a;
    int ans=b-a;
    while(sa>0){
        sa--;
        ans+=sa;
    }
    cout << ans-b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {

  long int n,i,Ai;
  scanf("%ld",&n);
  int ans[n];
  for (i = 1;i <= n;i ++) {
    ans[i] = 0;
  }
  for (i = 1;i < n;i ++) {
    scanf("%ld",&Ai);
    ans[Ai] ++;
  }
  for(i = 1;i <= n;i ++) {
    printf("%d\n",ans[i]);
  }
}


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

using namespace std;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug // (...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); os << "\n"; return os;}
ostream &operator<<(ostream &os, pii &p){ os << "(" << p.first << " " << p.second << ")"; return os;}

pii process(string &s){
    int o = 0, c = 0, i;
    for(i=0;i<s.size();i++){
        if(s[i] == '(') o++;
        else{ // )
            if(o > 0){
                o--;
            }else{
                c++;
            }
        }
    }
    return {c,o};
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<pii> v;
    int no, nc, i, o, c;
    no = 0;
    nc = 0;
    for(i=0;i<n;i++){
        string s; cin >> s;
        tie(c,o) = process(s);
        if(c == 0)
            no += o;
        else if(o == 0){
            nc += c;
        }
        else{
            v.push_back({c,o});
        }
    }
    sort(all(v), [](pii &p1, pii &p2) -> bool {
        // positive delta first
        int d1 = p1.second - p1.first; //o - c
        int d2 = p2.second - p2.first;
        if(d1 > d2) return true;
        if(d1 < d2) return false;
        // smaller c first
        return p1.first < p2.first;
    });
    for(i=0;i<v.size();i++){
        tie(c,o) = v[i];
        no -= c;
        if(no < 0) break;
        no += o;
    }
    bool ok = (i == v.size()) && (no == nc);
    if(!ok){
        cout << "No\n";
    }else{
        cout << "Yes\n";
    }
    return 0;
}

Measured memory_bytes: 5324
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int mod = 86400;
const int len = 10801;
int d[mod];

int main() {
    #ifdef LOCAL
    assert(freopen("h.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    int t = 0;
    forn (i, n) {
        int a, b;
        cin >> a >> b;
        t += a;
        t %= mod;
        d[t]++;
        t += b;
    }
    int sum = 0;
    forn (i, len)
        sum += d[i];
    int best = 0;
    forn (i, mod) {
        best = max(best, sum);
        sum -= d[i];
        sum += d[(i + len) % mod];
    }
    cout << best << '\n';
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		string S;
		cin >> S;
		int N = S.size();

		if( f( S, 0, N ) && f( S, 0, N/2 ) && f( S, (N+2)/2, N ) ) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	bool f( const string& s, int a, int b ) const {
		int m = (a+b)/2;

		for( int i = a; i < m; ++i ) {
			if( s[i] != s[b-1-i] ) {
				return false;
			}
		}

		return true;
	}
};

int main() {
	Solver().solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
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; }

int main(){
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int maxNum = 0, maxI = 0;
    for(int i = 0; i < n-1; i++){
        if (chmax(maxNum, a[i]+a[i+1])) maxI = i;
    }


    vector<int> ans;
    if (maxI == 0){
        if (a[0] + a[1] < l){
            cout << "Impossible" << endl;
            return 0;
        }
        for(int i = 0; i < n-1; i++){
            ans.push_back(i);
        }
    }
    else if (maxI == n-1){
        if (a[n-1] + a[n-2] < l){
            cout << "Impossible" << endl;
            return 0;
        }
        for(int i = n-2; i >= 0; i--){
            ans.push_back(i);
        }
    }else{
        if (a[maxI-1] > a[maxI+1]){
            if (a[maxI-1] + a[maxI] < l){
                cout << "Impossible" << endl;
                return 0;
            }
            for(int i = maxI-1; i >= 0; i--){
                ans.push_back(i);
            }
            for(int i = maxI+1; i < n; i++){
                ans.push_back(i-1);
            }
            
        }else{
            if (a[maxI] + a[maxI+1] < l){
                cout << "Impossible" << endl;
                return 0;
            }
            for(int i = maxI+1; i < n; i++){
                ans.push_back(i-1);
            }
            for(int i = maxI-1; i >= 0; i--){
                ans.push_back(i);
            }
        }
    }
    reverse(all(ans));
    cout << "Possible" << endl;
    rep(i, ans.size()){
        cout << ans[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4312
// Believe in yourself...
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) (c).size()
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)

#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf=4e18;
const ll maxn=2e5+10;
const ll mod=1e9+7;

#pragma GCC Optimize("Ofast")

ll f(ll x,ll k){
	if(x%k==0)return x/k;
	ll num=(x/k)+1;
	ll kaf=(x/k)*k;
	ll A=((x-kaf)%num)+kaf,B=x-num;
	return f(min(A,B),k);
}

int main(){
	ll n;cin>>n;
	ll ans=0;
	REP(i,n){
		ll x,k;cin>>x>>k;
		ans^=f(x,k);
	}
	cout<<(ans==0?"Aoki":"Takahashi");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, X;
  cin >> N >> X;
  int sum = 0;
  vector <int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int min = vec.at(0);
  cout << N +(X - sum) / min << endl;
}

Measured memory_bytes: 256
N,M,X=map(int,input().split())
alist=list(map(int,input().split()))

a1list=[]
a2list=[]
for a in alist:
  if a<X:
    a1list.append(a)
  else:
    a2list.append(a)
    
print(min(len(a1list),len(a2list)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, K;
  cin >> N >> K;

  i64 ans = 0;
  rep(b, K + 1, N + 1){
    ans += (N / b) * (b - K);
    if(N % b >= K){
      ans += (N % b - K + 1);
    }
  }

  if(K==0) ans -= N;

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

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

typedef long long ll;

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	vector<bool> found(26,false);
	string s;
	cin >> s;
	FOR(i,0,(int)s.size()){
		found[s[i] - 'a'] = true;
	}
	FOR(i,0,26){
		if(!found[i]){
			ANS((char)('a'+i));
			return 0;
		}
	}
	ANS("None");
	return 0;
}


Measured memory_bytes: 512
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>

using namespace std;

int main(int argc, char* argv[]) {
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; ++i) {
		cin >> x[i];
	}
	int ans = 1 << 30;
	sort(x.begin(), x.end());
	for (int i = x[0]; i <= x.back(); ++i) {
		int sum = 0;
		for (int j = 0; j < n; ++j) {
			int d = i - x[j];
			sum += d * d;
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  long long N, D;
  cin >> N >> D;
  //cout << M << endl;

  long long D_2 = D*D;
  int ans = 0;
  for(int i = 0; i < N; i++){
    long long x, y;
    cin >> x >> y;

    if((x*x) + (y*y) <= D_2){
      ans++;
    }
    //cout << x*x << " " << y*y << endl;
  }
  cout << ans << endl;

  /*int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }*/

  /*for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }

  for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

const int MOD = 1000000007;

int main(){
	long long N;
	while(cin >> N){
		long long dp[2][3];
		for(int i=0;i<3;i++) dp[0][i] = dp[1][i] = 0;
		dp[0][0] = 1;
		for(int i=60;i>=0;i--){
			long long* cur = dp[i%2];
			long long* next = dp[1-i%2];
			for(int j=0;j<3;j++) next[j] = 0;
			for(int j=0;j<3;j++){
				int r = 2*j + (N>>i)%2;
				for(int k=0;k<=2;k++){
					if(r-k < 0) break;
					next[min(2, r-k)] += cur[j];
				}
			}
			for(int j=0;j<3;j++) next[j] %= MOD;
		}
		int res = 0;
		for(int j=0;j<3;j++) res = (res + dp[1][j])%MOD;
		cout << res << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 200000
typedef long long ll;

using namespace std;

int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;

    int res=0;
    for (int i=0;i<=a;i++){
	for (int j=0;j<=b;j++){
	    for (int k=0;k<=c;k++){
		if ((500*i+100*j+50*k) == x) res++;
	    }
	}
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    bool flag1=false;
    for (int i=1;i<10;i++){
        for (int j=1;j<10;j++){
            int sum=0;
            sum=i*j;
            if(N==sum){
                flag1=true;
                break;
            }
        }
    }
    if(flag1==true)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	  cin>>a;
	  for(int b =0;b<a;b++){
	  int c[3];
	  cin>>c[0]>>c[1]>>c[2];
	  sort(c,c+3);
	  if(c[0]*c[0]+c[1]*c[1]==c[2]*c[2])
	  cout<<"YES"<<endl;
	  else cout<<"NO"<<endl;}
}

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

int H[105];

int dp[105][105];
int all[105];

int mod = 1000000007;
long long qexp(long long b, long long p){
    long long res = 1;
    while(p){
        if(p&1) res = (res * b) % mod;
        b = (b * b) % mod;
        p >>= 1;
    }
    return res;
}

vector<int> dis = {1};
int get(int x){ return lower_bound(dis.begin(),dis.end(),x) - dis.begin(); }
void c(int &x){
	x %= mod;
	if(x < 0) x += mod;
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	int n; cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> H[i];
		dis.push_back(H[i]);
	}

	sort(dis.begin(),dis.end());
	dis.erase(unique(dis.begin(), dis.end()), dis.end());
	int m = dis.size();
	
	all[0] = 1;
	
	for(int i = 1;i <= n;i++){
		if(H[i] > H[i-1]){			
			for(int j = m-1;j >= 0;j--){
				if(dis[j] >= H[i]) dp[i][j] = 0;
				else if(dis[j] >= H[i-1]){
					dp[i][j] = all[i-1] * (qexp(2, H[i] - dis[j]) - 1) * 2;
					c(dp[i][j]);
				}
				else{
					dp[i][j] = dp[i-1][j] * qexp(2,H[i] - H[i-1]);
					c(dp[i][j]);
					dp[i][j] += all[i-1] * (qexp(2, H[i] - H[i-1]) - 1) * 2;
					c(dp[i][j]);
				}
			}
			all[i] = all[i-1] * 2;
			c(all[i]);
		}
		else{
			for(int j = 0;j < m;j++){
				if(dis[j] >= H[i]) dp[i][j] = 0;
				else{
					dp[i][j] = dp[i-1][j] - dp[i-1][get(H[i])];
					c(dp[i][j]);
				}
			}
			all[i] = (all[i-1] + dp[i-1][get(H[i])]) * 2;
			c(all[i]);
		}
		
	}
	
	int ans = all[n] + dp[n][0];
	c(ans);
	
	cout << ans;
}



Measured memory_bytes: 384
//abc058_b.cpp
//Sat Oct 27 20:50:14 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	string odd,even;
	cin >> odd >> even;

	for (int i=0;i<even.size();i++){
		cout << odd[i];
		cout << even[i];
	}
	if (odd.size() > even.size()){
		cout << odd[odd.size()-1];
	}

	printf("\n");
//	printf("%.4f\n",ans);
}

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

int main()
{
    int ar[10];   int c5=0,c7=0;
    for(int i=0;i<=2;i++)
    {
        cin>>ar[i];
        if(ar[i]==5)
            c5++;
        if(ar[i]==7)
            c7++;
    }
    if(c5==2&&c7==1)
        cout<<"YES";
    else
    {
        cout<<"NO";
    }
    return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  using pii=pair<int,int>;
  vector<pii> A(N),B(M);
  for(pii &i:A)
    cin>>i.first>>i.second;
  for(pii &i:B)
    cin>>i.first>>i.second;
  for(pii i:A){
    int k=0,l=400000001;
    for(int j=0;j<M;j++){
      int p=abs(B[j].first-i.first)+abs(B[j].second-i.second);
      if(l>p){
        l=p;
        k=j;
      }
    }
    cout<<k+1<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main() {
	int N;
	cin >> N;
	
	map<int,int> m;

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

	int ans = 0;
	for (auto p : m) {
		if (p.first == p.second) continue;
		if (p.first > p.second) ans += p.second;
		else ans += p.second - p.first;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
using namespace std;
typedef long long int ll;

struct V{
  double x,y;
  V(double x=0,double y=0):x(x),y(y) {}
  V& operator+=(const V& v){ x+= v.x; y+=v.y; return *this;}
  V operator+(const V& v) const { return V(*this) +=v;}
  V& operator-=(const V& v){ x-= v.x; y-=v.y; return *this;}
  V operator-(const V& v) const { return V(*this) -=v;}
  V& operator*=(double s){ x*=s; y*=s; return *this;}
  V operator*(double s) const {return V(*this) *=s;}
  V& operator/=(double s) { x/=s; y/=s; return *this;}
  V operator/(double s) const { return V(*this) /=s;}
  double dot(const V& v) const { return x*v.x+y*v.y; }
  double cross(const V& v) const {return x*v.y-v.x*y; }
  double norm2() const { return x*x + y*y;}
  double norm() const { return sqrt(norm2());}
  int ort() const {
    if(y>0) return x>0 ? 1:2;
    else return x>0? 4:3;
  }
  bool operator<(const V& v) const{
    int o=ort(),vo=v.ort();
    if(o!=vo) return o<vo;
    return cross(v) >0;
  }
};
istream& operator>>(istream& is, V& v){
  is >> v.x >> v.y; return is;
}
ostream& operator<<(ostream& os,const V& v){
  os <<"("<<v.x<<","<<v.y<<")"; return os;
}

int main(){
  int n; cin >> n;
  vector<V> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  double ans=0;
  for(int i=0;i<n;i++){
    int r=i;
    V now;
    for(int j=0;j<n;j++){
      now+=v[r];
      ans=max(ans,now.norm());
      r=(r+1)%n;
    }
  }
  printf("%.12f\n",ans);
  return 0;
}

Measured memory_bytes: 764
md = list(map(int, input().split()))

def divisors(n):
    divs = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)

    divs.sort()
    return divs

cnt = 0

for m in range(1, md[0]+1):
    divs = divisors(m)

    for d in divs:
        if d >= 2 and d != m and m/d < 10 and d*10 + m/d <= md[1]:
            cnt += 1

print(cnt)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define inf 1e18
using namespace std;
const int N=200050;
inline ll rd(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?x:-x;
}char str[N];int nxt[N],n,m,tot,top;
ll len[1005],nt[1005],cnt[1005][27],ct2[1005][27],o[27],ans[27];
inline void kmp(){
	int j=0;
	for(int i=2;i<=n;i++){
		while(j&&str[j+1]!=str[i]) j=nxt[j];
		if(str[j+1]==str[i]) j++;
		nxt[i]=j;
	}
}
inline void work(ll n,int f){
	for(int i=top;i>=1;i--){
		if(n>=len[i]){
			for(int j=0;j<26;j++) ans[j]+=f*(cnt[i][j]*2+ct2[i][j]);
			n-=len[i];
		}
	}
	if(n>=len[0]){
		for(int j=0;j<26;j++) ans[j]+=f*o[j];
		n-=len[0];
	}for(int i=1;i<=n;i++) ans[str[i]-'a']+=f;
}
inline void solve(ll n,int f){
	for(int i=0;i<26;i++) ans[i]+=1ll*f*(n/tot)*o[i];
	n%=tot;
	for(int i=1;i<=n;i++) ans[str[i]-'a']+=f; 
}
int main(){
	scanf("%s",str+1);n=strlen(str+1);n/=2;
	kmp();ll l=rd(),r=rd();
	if(n%(n-nxt[n])){
		for(int i=1;i<=nxt[n];i++) cnt[0][str[i]-'a']++;
		for(int i=nxt[n]+1;i<=n-nxt[n];i++) ct2[0][str[i]-'a']++; 
		for(int i=1;i<=n;i++) o[str[i]-'a']++;
		len[0]=n;nt[0]=nxt[n];
		if(nxt[n]>=(n+1)/2){
			top++;
			len[top]=len[top-1]*2-nt[top-1];
			nt[top]=len[top-1]-nt[top-1];
			for(int i=1;i<=nt[top];i++){
				cnt[top][str[i]-'a']++;
			}
			for(int i=n-nxt[n]+1;i<=n;i++){
				ct2[top][str[i]-'a']++; 
			} 
		} 
		while(len[top]<inf){
			top++;
			len[top]=len[top-1]*2-nt[top-1];
			nt[top]=len[top-1]-nt[top-1];
			for(int i=0;i<26;i++){
				cnt[top][i]=cnt[top-1][i]+ct2[top-1][i];
				ct2[top][i]=cnt[top-1][i];
			}
		}
		work(r,1);work(l-1,-1);
	}
	else{
		tot=n-nxt[n];
		for(int i=1;i<=tot;i++){
			o[str[i]-'a']++;
		}solve(r,1);solve(l-1,-1);
	}
	for(int i=0;i<26;i++) printf("%lld ",ans[i]);
	return 0;
}

Measured memory_bytes: 896