akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b&&b<c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2552
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

int main(void) {
    string S;
    cin >> S;

    for (int i = 0; i < (int) S.size(); i++) {
        printf("x");
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 256
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};

int p, q;
string P[11], Q[11];

int indent[11];
int ans[11];

void solve() {
	minit(indent, 0);
	
	for_(i,0,p) {
		int p_size = size_of(P[i]);
		
		for_(j,0,p_size) {
			if (P[i][j] == '.') ++indent[i];
			else break;
		}
	}
	
	fill(ans, ans + 11, -2);
	
	for_(R,1,21) for_(C,1,21) for_(S,1,21) {
		int r = 0, c = 0, s = 0;
		bool flag = true;
		
		for_(i,0,p) {
			if (R * r + C * c + S * s != indent[i]) {
				flag = false;
				break;
			}
			
			int p_size = size_of(P[i]);
			for_(j,0,p_size) {
				switch (P[i][j]) {
				case '(': ++r; break;
				case ')': --r; break;
				case '{': ++c; break;
				case '}': --c; break;
				case '[': ++s; break;
				case ']': --s; break;
				}
			}
		}
		
		if (!flag) continue;
		
		r = c = s = 0;
		for_(i,0,q) {
			int val = R * r + C * c + S * s;
			
			if (ans[i] == -2) ans[i] = val;
			else if (ans[i] != val) ans[i] = -1;
			
			int q_size = size_of(Q[i]);
			for_(j,0,q_size) {
				switch (Q[i][j]) {
				case '(': ++r; break;
				case ')': --r; break;
				case '{': ++c; break;
				case '}': --c; break;
				case '[': ++s; break;
				case ']': --s; break;
				}
			}
		}
	}
	
	for_(i,0,q) {
		if (i < q - 1) cout << ans[i] << " ";
		else cout << ans[i] << endl;
	}
}

int main() {
	while (cin >> p >> q, p) {
		for_(i,0,p) cin >> P[i];
		for_(i,0,q) cin >> Q[i];
		solve();
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	
	if( a + b + c >= 22 ) cout << "bust" << endl;
	else cout << "win" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

Measured memory_bytes: 3068
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

    if(n%10==9 || n/10==9){
        cout << "Yes" << endl;
    } 
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        k: usize,
        mut s: String,
    }

    let result = if s.len() <= k {
        s
    } else {
        let mut s: String = s.chars().into_iter().take(k).collect();
        s.push_str("...");
        s
    };
    println!("{}", result);
}


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

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;

  int a, b, c, d;
  a = s[0]-'0';
  b = s[1]-'0';
  c = s[2]-'0';
  d = s[3]-'0';  

  if ( a+b+c+d == 7 ) {
    printf("%d+%d+%d+%d=7\n", a, b, c, d);
    return 0;
  }
  if ( a+b+c-d == 7 ) {
    printf("%d+%d+%d-%d=7\n", a, b, c, d);
    return 0;
  }
  if ( a+b-c+d == 7 ) {
    printf("%d+%d-%d+%d=7\n", a, b, c, d);
    return 0;
  }
  if ( a+b-c-d == 7 ) {
    printf("%d+%d-%d-%d=7\n", a, b, c, d);
    return 0;
  }
  if ( a-b+c+d == 7 ) {
    printf("%d-%d+%d+%d=7\n", a, b, c, d);
    return 0;
  }
  if ( a-b+c-d == 7 ) {
    printf("%d-%d+%d-%d=7\n", a, b, c, d);
    return 0;
  }
  if ( a-b-c+d == 7 ) {
    printf("%d-%d-%d+%d=7\n", a, b, c, d);
    return 0;
  }
  if ( a-b-c-d == 7 ) {
    printf("%d-%d-%d-%d=7\n", a, b, c, d);
    return 0;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
using namespace std;
using ll = long long;
const int mod = 10000007;

ll n, hap[100000][3], memo[100000][3];

ll dp(int day,int pt);
int main() {
	fill(memo[0], memo[100000], -1);
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> hap[i][j];
		}
	}
	for (int i = 0; i < 3; i++) {
		memo[0][i] = hap[0][i];
	}
	cout << max(max(dp(n-1,0),dp(n-1,1)),dp(n-1,2)) << endl;
}
ll dp(int day,int pt) {
	if (memo[day][pt] == -1) {
		switch (pt){
		case 0:
			memo[day][pt] = max(dp(day - 1, 1), dp(day - 1, 2));
			break;
		case 1:
			memo[day][pt] = max(dp(day - 1, 0), dp(day - 1, 2));
			break;
		case 2:
			memo[day][pt] = max(dp(day - 1, 0), dp(day - 1, 1));
			break;
		}
		memo[day][pt] += hap[day][pt];
	}
	return memo[day][pt];
}


Measured memory_bytes: 9600
def main():
    N,K=map(int,input().split())
    ans=[i for i in range(1,N+1)]
    for _ in range(K):
        d = int(input())
        A=[int(_) for _ in input().split()]
        for a in A:
            if a in ans:
                ans.remove(a)
    print(len(ans))

main()

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

using namespace std;
void findPath(vector<int> &visited, vector<int> &dp, vector<vector<int>> &edges, int v){
    visited[v] = 1;
    for(int i = 0; i < edges[v].size();++i){
        if(visited[edges[v][i]] == 0) findPath(visited, dp, edges, edges[v][i]);
        dp[v] = max(dp[v], 1 + dp[edges[v][i]]);
    }
}
int main() {
   int n, m;
   cin >> n >> m;
   vector<vector<int>> edges(n + 1);
   int src, dest;
   for(int i = 0;i < m;++i){
       cin >> src >> dest;
       edges[src].push_back(dest);
   }
   vector<int> dp(n + 1, 0), visited(n + 1, 0);
   for(int i = 1; i <= n; ++i){
       if(visited[i] == 0) findPath(visited, dp, edges, i);
   }
   int ans = 0;
   for(int i = 1; i <= n;++i) ans = max(ans, dp[i]);
   cout << ans << endl;
   return 0;
}

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

string s;

int main() {
  cin >> s;
  int size_ = s.size();
  for(int i = size_ - 1; i >= 0; i--) {
    if (i % 2) continue;
    if (s.substr(0, i/2) == s.substr(i/2, i/2)) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, a[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	
	int j, type = 1, count[3] = {1, 0, 0}, appear[3] = {a[1], -1, -1};
	for (i = 2; i <= N; i++) {
		for (j = 0; j < type; j++) if (a[i] == appear[j]) break;
		if (j < type) count[j]++;
		else if (type < 3) {
			count[type]++;
			appear[type++] = a[i];
		} else break;
	}
	if (i <= N) printf("No\n");
	else if (type == 1) {
		if (appear[0] == 0) printf("Yes\n");
		else printf("No\n");
	} else if (type == 2) {
		if ((appear[0] == 0 && count[0] * 2 == count[1]) || (appear[1] == 0 && count[1] * 2 == count[0])) printf("Yes\n");
		else printf("No\n");
	} else {
		if ((appear[0] ^ appear[1] ^ appear[2]) == 0 && count[0] == count[1] && count[1] == count[2]) printf("Yes\n");
		else printf("No\n");
	}
		
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 512
n,m = gets.split(" ").map(&:to_i)
l,r = gets.split(" ").map(&:to_i)

low = l
upp = r

(m-1).times do 
  l,r = gets.split(" ").map(&:to_i)
  low = l if low < l
  upp = r if upp > r
end

num = upp - low + 1
num = 0 if num < 0
puts num

Measured memory_bytes: 1788
n = int(input())
l = list(map(int, input().split()))
 
import fractions
from functools import reduce
def lcm_base(x, y):
  return (x * y) // fractions.gcd(x, y)
  
def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)
 
x = lcm_list(l)
ans = 0
for i in range(n):
  ans += x//l[i]
ans %= 10**9+7
  
print(ans)

Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define int               long long
#define M                 1000000007
#define MM                998244353
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount

template<typename T1,typename T2>
std::istream& operator>>(std::istream& in,pair<T1,T2> &a)
{
	in>>a.fr>>a.sc;
	return in;
}
template<typename T1,typename T2>
std::ostream& operator<<(std::ostream& out,pair<T1,T2> &a)
{
	out<<a.fr<<" "<<a.sc;
	return out;
}

int n,m;
vector<int> v[100005];
vector<int> pf[100005];
vector<int> sf[100005];
vector<int> vals[100005];
int dp[100005];
void dfs(int z,int p){
	dp[z]=1;
	for(auto it=v[z].begin();it!=v[z].end();it++){
		if(*it==p){
			v[z].erase(it);
			break;
		}
	}
	pf[z].pb(1);
	for(int x:v[z]){
		dfs(x,z);
		vals[z].pb((1+dp[x])%m);
		pf[z].pb((1+dp[x])%m);
		sf[z].pb((1+dp[x])%m);
	}
	sf[z].pb(1);
	for(int i=1;i<sz(pf[z]);i++){
		pf[z][i]=pf[z][i-1]*pf[z][i]%m;
	}
	for(int i=sz(sf[z])-2;i>=0;i--){
		sf[z][i]=sf[z][i+1]*sf[z][i]%m;
	}
	dp[z]=sf[z][0];
}
void dfs2(int z,int k){
	dp[z]=dp[z]*(1+k)%m;
	rep(i,0,sz(v[z])){
		int r=pf[z][i]*sf[z][i+1]%m*(1+k)%m;
		dfs2(v[z][i],r);
	}
}
void solve(){
	// mem1(dp);
	cin>>n>>m;
	rep(i,1,n){
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs(1,0);
	dfs2(1,0);
	rep(i,1,n+1){
		cout<<dp[i]<<"\n";
	}
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	#ifdef DSU
		cleardsu(MAXDSUSIZE);
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 30592
import sys

def gcd(inta, intb):
    large = max(inta, intb)
    small = min(inta,intb)
    mod = large % small
    if mod ==0:
        return small
    else:
        return gcd(small, mod) 
    
def lcm(inta, intb, intgcd):
    return (inta * intb // intgcd)

sets = sys.stdin.readlines()
for line in sets:
    a, b = map(int, line.split())
    c = gcd(a, b)
    print(c, lcm(a, b, c))

Measured memory_bytes: 7692
import numpy as np
S = input()
l = len(S)
n = list(map(int, str(S)))
a = np.arange(l) # 12345...
b = np.where(a%2==0, 0, 1) # 010101010...
c = np.where(a%2==1, 0, 1) # 101010101...
bool1 = np.logical_xor(n, b)
bool2 = np.logical_xor(n, c)

count1 = np.sum(bool1)
count2 = np.sum(bool2)

if count1 < count2:
    print(count1)
else:
    print(count2)
    



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {

    set<li> st;
    li n;
    cin >> n;
    rin{
        li a;
        cin >> a;
        st.insert(a);
    }

    cout << (sz(st) == n ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<string> v(N);
    rep(i, N) cin >> v[i];
    map<string, int> mp;
    int m = 0;
    for(int i = 0; i < N; i++) {
        string x = v[i];
        if(mp.count(x)){
            mp[x]++;
        } else {
            mp[x] = 1;
        }
        m = max(m, mp[x]);
    }

    set<string> st;
    for(int i = 0; i < N; i++) {
        string x = v[i];
        if(mp[x] == m){
            st.insert(x);
        }
    }

    for(auto itr = st.begin(); itr != st.end(); ++itr) {
        std::cout << *itr << "\n";
    }
}


Measured memory_bytes: 36096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,m;
  cin >> n >> m;
  vector<long> l(m),r(m),c(m),saitan(n,1000000000000000);
  vector<vector<long>> lr(n,vector<long>(0)),lc(n,vector<long>(0)),rc(n,vector<long>(0));
  multiset<long> ms;
  saitan[0]=0;
  for(long i=0;i<m;i++) {
    cin >> l[i] >> r[i] >> c[i];
    lr[l[i]-1].push_back(r[i]-1);
    lc[l[i]-1].push_back(c[i]);
  }
  for(long i=0;i<lr[0].size();i++) {
    ms.insert(lc[0][i]);
    rc[lr[0][i]].push_back(lc[0][i]);
  }
  for(long i=1;i<n;i++) {
    if(ms.size()!=0) saitan[i]=min(1000000000000000L,*(ms.begin()));
    for(long j=0;j<rc[i].size();j++) {
      ms.erase(ms.find(rc[i][j]));
    }
    for(long j=0;j<lr[i].size();j++) {
      ms.insert(lc[i][j]+saitan[i]);
      rc[lr[i][j]].push_back(lc[i][j]+saitan[i]);
    }
  }
  if(saitan[n-1]!=1000000000000000)cout << saitan[n-1] << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 22056
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = n; j >= 1; j-- ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}








Measured memory_bytes: 9572
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int S, x = 1;
	
	cin>>S;
	
	while(S > x*x){
		x++;
	}
	if(S == x*x){
		cout<<"0 0 0 "<<x<<" "<<x<<" 0"<<endl;
	}  else if(S > (x-1)*x){
		cout<<"0 0 1 "<<x<<" "<<x<<" "<<(x*x - S)<<endl;
	} else if(S == (x-1)*x){
		cout<<"0 0 0 "<<(x-1)<<" "<<x<<" 0"<<endl;
	} else {
		cout<<"0 0 1 "<<(x-1)<<" "<<x<<" "<<(x*(x-1) - S)<<endl;
	}
	
	return 0;
}

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

#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++)

using namespace std;
const long long MOD = 998244353;
const long long INF = 1LL << 61;

int main() {
	int N; cin >> N;
	vector<int> B(N - 1);
	rep(i, N - 1)cin >> B[i];

	long long ans = 0;

	int preNum = 100000+1;
	rep(i, N-1) {
		ans += min(preNum, B[i]);
		preNum = B[i];
	}
	ans += B[N - 2];
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;

int a[100005], last[100005];
ll s[100005];

int main() {
  ll n;
  int M;
  cin >> n >> a[1] >> M;
  last[a[1]] = 1;
  s[1] = a[1];
  int R, p;
  ll S;
  for (int i = 2; ; ++i) {
    a[i] = 1LL * a[i - 1] * a[i - 1] % M;
    if (last[a[i]]) {
      R = i - last[a[i]];
      s[i] = s[i - 1] + a[i];
      S = s[i] - s[last[a[i]]];
      p = last[a[i]];
      break;
    }
    last[a[i]] = i;
    s[i] = s[i - 1] + a[i];
  }
  cout << s[p + (n - p) % R] + ((n - p) / R) * S;
  return 0;
}

Measured memory_bytes: 4136
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;

int warota[100];
int main(void){
  int n;
  cin>>n;
  char c;
  int s=0;
  for(int i=0;i<n;i++){
    cin>>c;
    if(warota[c]==0) s++;
    warota[c]=1;
  }
  if(s==3) cout<<"Three"<<endl;
  else cout<<"Four"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int MAX = 150007;
const int MOD = 1000000007;

void solve() {
    int n;
    long double d;
    cin >> n >> d;
    long double a, b;
    int res = 0;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        if (sqrt(a*a + b*b) <= d) {res++;}
    }
    cout << res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("rental.in", "r", stdin); freopen("rental.out", "w", stdout);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve(); cout << endl;}
    solve();
}


Measured memory_bytes: 3828
#include<iostream>

using namespace std;

int main(){
    int n, a[21], b[21], c[21];
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];
    for(int i = 1; i <= n - 1; i++) cin >> c[i];
    int satisfied = 0;
    for(int i = 1; i <= n; i++){
        satisfied += b[a[i]];
        if(a[i + 1] - a[i] == 1) satisfied += c[a[i]];
    }
    cout << satisfied << endl;
    return 0;
}

Measured memory_bytes: 256
nmc = gets.split(" ").map(&:to_i)
n = nmc[0]
m = nmc[1]
c = nmc[2]

b = gets.split(" ").map(&:to_i)

a = Array.new(n).map{gets.split(" ").map(&:to_i)}
result = 0
a.each do |row|
  sum = c
  row.zip(b).each do |a, b|
    sum += a*b
  end
  result += 1 if(sum > 0)
end

puts result


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

int p[20];
int c[20];

int D,G;
int main () {
    cin >> D >> G;
    for(int i=0; i<D; i++) cin >> p[i] >> c[i];

    int ans = 99999999;
    for(int i=0; i<(1<<D); i++) {
        int score = 0;
        int cnt = 0;
        for(int j=0; j<D; j++) {
            if( i & ( 1<<j )) {
                score += p[j] * (j+1) * 100 + c[j];
                cnt += p[j];
            }
        }
        for(int j=D-1; j>=0; j-- ) {
            if( !(i & ( 1<<j)) ) {
                for(int k=0; k < p[j]; k++) {
                    if(score >= G) continue;
                    score += (j+1) * 100;
                    cnt++;
                }
            }
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# 12:55
import itertools
n = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

a = []
for i in range(1, n+1):
    a.append(i)
a = list(itertools.permutations(a))
b = 0
c = 0
for i, v in enumerate(a):
    if list(v) == P:
        b = i
    if list(v) == Q:
        c = i

print(abs(b-c))


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

const int N = 100009;
int a[N], b[N], c[N];
int main()
{
    int n;
    cin>>n;
    for(int i = 0; i < n; i++) cin>>a[i];
    for(int i = 0; i < n; i++) cin>>b[i];
    for(int i = 0; i < n; i++) cin>>c[i];
    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);
    LL ans = 0;
    int d=(upper_bound(b,b+n,a[0])-b);
    long long  bnum[n];
    memset(bnum,0,sizeof bnum);
    long long  anum[n];
    memset(anum,0,sizeof anum);

    for(int i=d;i<n;i++) bnum[i]= n-(upper_bound(c,c+n,b[i])-c);


    for(int i=n-1;i>0;i--)
        bnum[i-1]+=bnum[i];

    for(int i=0;i<n;i++){
        if((anum[i]=(upper_bound(b,b+n,a[i])-b))<n)
          ans+=bnum[anum[i]];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <ios>
#include <iomanip>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    double ans = 0;
    for (int i = 0; i < N; ++i) ans += 1.0 / A[i];
    ans = 1.0 / ans;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define     ll      long long
#define     pb      push_back
#define     F       first
#define     S       second
#define     n1      "\n"
#define     sz      size()
#define     cinfast ios_base::sync_with_stdio(false); cin.tie(NULL);


int main ()
{
ll x ;
cin >> x;
for (int i = 1000; i >= -1000 ; --i){
    for (int j = 1000 ; j >= -1000 ; --j){
        ll a = i , b = j ;
        a*=i;
        a*=i;
        a*=i;
        a*=i;
        b*=j;
        b*=j;
        b*=j;
        b*=j;
        if (a-b==x){
            cout << i << " " << j ; return 0;
        }
    }
}

}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> mp;

  REP(i, n) {
    uint num;
    scanf("%u", &num);
    mp[num]++;
  }

  int ans = 0;
  for(auto &m : mp) {
    if(m.second % 2 == 1) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 4864
// VU TRUONG AN
#include <bits/stdc++.h>
#define F first
#define S second
#define maxn 200005
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define pi acos(-1)
#define bit(p,x) ((x>>p) & 1)
#define Task "CF"
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int > piii;

const int base = 200003;
const long long MM = 1ll * MOD * MOD;

int n,k;
void Solve(){
    cin >> n >> k;
    ll ans = 0;
    int a = k;
    for(int b = k + 1;b <= n;++b){
        while(a <= n){
            if(a == 0) -- ans;
            if(a + b <= n) ans += b - k;
            else ans += min(b - k,n - a + 1);
            a += b;
        }
        a = k;
    }
    cout << ans;
}

void NumTime(){cerr << "Toi" << "\n";cerr << "Di" << "\n";cerr << "Chep" << "\n";cerr << "Code" << "\n";}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen(Task".inp", "r", stdin);
    freopen(Task".out", "w", stdout);
#endif
    int test = 1;
//    cin >> test;
    while(test--){
        NumTime();
        Solve();
    }
}


Measured memory_bytes: 3628
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	int n, k, r, s, p;
	cin >> n >> k >> r >> s >> p;
	string t;
	cin >> t;
	for (int i = 0; i < n; i++)
	{
		if ((i + k) < n && t[i] == t[i + k] && t[i] != 'x')
			t[i + k] = 'x';
	}
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (t[i] == 'r')
			ans += p;
		else if (t[i] == 's')
			ans += r;
		else if (t[i] == 'p')
			ans += s;
	}
	cout << ans << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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

int main() {
    int sum = 0, tr = 0;
    for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < 3; ++j) {
            int c;
            cin >> c;
            tr += (i == j) * c;
            sum += c;
        }
    }
    cout << (sum == 3 * tr ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define int long long
using namespace std;
static const int MAX_N = 100000;
static const int inf  = 1ll<<60;
typedef pair<int,int> pii;

int N,M;
int res;
int ans;
vector<int> V[MAX_N+5];
bool Mark[MAX_N+5];

void dfs(int n){
    if(res!=inf)return ;
    if(Mark[n]==true)res=n;
    else{
        for(int i=0;i<V[n].size();++i){
            dfs(V[n][i]);
        }
    }
}


signed main(){
    while(1){
        cin>>N>>M;
        if(N==0&&M==0)break;
        for(int i=0;i<=N;++i)V[i].clear();
        memset(Mark,0,sizeof(Mark));
        Mark[1]=true;
        for(int i=2;i<=N;++i){
            int v;
            cin>>v;
            V[i].PB(v);
        }
        ans=0;
        for(int i=0;i<M;++i){
            char que;
            int k;
            cin>>que;
            cin>>k;
            if(que =='M')Mark[k]=true;
            else{
                res=inf;
                dfs(k);
                if(res!=inf)ans+=res;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 8252
#include <stdio.h>

int main(){
    
    int i, n, debt;
    
    debt = 100000;
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        debt *= 1.05;
        if (debt % 1000) {
            debt = (debt / 1000 + 1) * 1000;
        }
    }
    printf("%d\n", debt);

    return 0;
}

Measured memory_bytes: 588
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<ll>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 998244353
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000

int main(void) {
	int n; cin >> n;
	vint a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll ans=0;
	int max=0;
	rep(i, n) {
		if (max < a[i]) {
			max = a[i];
		}
		else {
			ans += max - a[i];
		}
	}
	cout << ans << endl;
	return 0;

	return 0;
}


Measured memory_bytes: 4840
use proconio::input;

fn main() {
    input!(n: usize, k: u64, a: [u64; n]);

    let mut ng = 0;
    let mut ok = 1_000_000_000;
    while ng + 1 < ok {
        let mid = (ng + ok) / 2;
        *if eval(mid, k, &a) { &mut ok } else { &mut ng } = mid;
    }

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

fn eval(t: u64, k: u64, a: &[u64]) -> bool {
    let dc = |a, b| (a + b - 1) / b;
    a.iter().map(|a| dc(a, t) - 1).sum::<u64>() <= k
}


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

int main() {
	int verNum;
	int vertexs[100][100];

	for (int i = 0; i < 100; i++)
		for (int j = 0; j < 100; j++)
			vertexs[i][j] = 0;
	cin >> verNum;
	for (int i = 0; i < verNum; i++) {
		int num; cin >> num; num--;
		int outNum;	cin >> outNum;
		for (int j = 0; j < outNum; j++) {
			int outVertex; cin >> outVertex;
			vertexs[i][--outVertex] = 1;
		}
	}

	for (int i = 0; i < verNum; i++) {
		for (int j = 0; j < verNum; j++) {
			if (j) cout << " ";
			cout << vertexs[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char c;
  cin>>c;
  if(c=='A')
    	cout<<'T';
  if(c=='T')
    	cout<<'A';
  if(c=='G')
    	cout<<'C';
  if(c=='C')
    	cout<<'G';
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//cin.tie(0);
//ios::sync_with_stdio(false);
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
llint LBI(vector<llint>&ar,llint in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint UBI(vector<llint>&ar,llint in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint i,n,ans=0,gen=0;cin>>n;
	vector<llint>Ls(n);
	vector<llint>Rs(n);
	for(i=0;i<n;i++){cin>>Ls[i]>>Rs[i];}
	SO(Ls);REV(Ls);SO(Rs);
	for(i=0;i<n;i++){
		maxeq(ans,gen+max(Ls[i],-Rs[i]));//片方だけ
		gen+=Ls[i]-Rs[i];
		maxeq(ans,gen);
	}
	cout<<ans*2<<endl;
	return 0;
}


Measured memory_bytes: 1792
N = int(input().strip())
res = [int(b) for b in input().strip().split()]
flag = True
commands = []
for n in range(N):
    index = -1
    for i, c in enumerate(res):
        if(i + 1 == c):
            index = i
    if(index == -1):
        flag = False
        break
    commands.append(index)
    res.pop(index)

if(flag):
    for c in commands[::-1]:
        print(c+1)
else:
    print(-1)

Measured memory_bytes: 3064
H, W, K = map(int, input().split())

s = [list(input()) for _ in range(H)]

ans = [[None] * W for _ in range(H)]
id_cake = 1

H_s = []
H_ns = []
for i in range(H):
    if s[i].count('#') > 0:
        H_s.append(i)
    else:
        H_ns.append(i)

# print("#", H_s, H_ns)
        
for i in H_s:
    for j in range(W):
        ans[i][j] = id_cake
        if s[i][j] == '#': id_cake += 1
    #
    for j in range(1, W):
        if s[i][j] == '.':
            ans[i][j] = ans[i][j - 1]
    #
    id_cake = ans[i][-1] + 1

for i in H_ns:
    if i == 0: continue
    for j in range(W):
        ans[i][j] = ans[i - 1][j]

for i in H_ns[::-1]:
    if i == H - 1: continue
    for j in range(W):
        ans[i][j] = ans[i + 1][j]

for ans_line in ans:
    print(' '.join(map(str, ans_line)))

Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int gcd(int x, int y)
{
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

int main()
{
  int x, y;
  cin >> x >> y;
  if (x < y)
    swap(x, y);
  cout << gcd(x, y) << endl;

  return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<float> vfloat;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint d(n);
    rep(i, n) cin >> d[i];
    sort(all(d));
    int ans = 0;
    ans = d[n/2] - d[n/2-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> v(N + 1);
  v.at(0) = 0;
  int sum = 0;
  for(int i = 1; i < N + 1; i++){
    if(S.at(i - 1) == 'I'){
      sum++;
    }
    else{
      sum--;
    }
    
    v.at(i) = sum;
  }
  sort(v.begin(), v.end());

  cout << v.at(N) << endl;
  
}

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

#define foru(i, l, r) for(int i = (l); i <= (r); ++i)
#define ford(i, l, r) for(int i = (l); i >= (r); --i)

#define maxn 200010
#define pii pair<int, int>
#define fi first
#define se second

int n, m, k;
ll T;
pii a[maxn], b[maxn];
ll c[maxn];

bool cmp(pii i, pii j) {
  return 1ll * j.fi * (i.se + 1) < 1ll * i.fi * (j.se + 1);
}

ll dp[51][maxn];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
    cin >> n >> T;
    foru(i, 1, n) {
      cin >> a[i].fi >> a[i].se;
    }
    ll cur = 0;
    sort(a + 1, a + n + 1, cmp);

    foru(i, 1, n) {
      if (a[i].fi) {
        b[++m] = a[i];
      } else {
        c[++k] = a[i].se;
      }
    }

    for (int i = 0; i < 51; i++) for (int j = 0; j < maxn; ++j)
      dp[i][j] = 1 << 30;
    for (int i = 0; i <= m; ++i)
      dp[0][i] = 0;

    sort(c + 1, c + k + 1);

    foru(i, 1, k) {
      c[i] = c[i-1] + c[i] + 1;
    }

    foru(j, 1, min(50, m) ) {
      foru(i, j, m) {
        dp[j][i] = dp[j][i-1];
        ll P = dp[j-1][i-1] + 1;
        dp[j][i] = min(dp[j][i], P * (b[i].fi + 1) + b[i].se);
      }
    }

    int ret = 0;
    for (int ans = min(m, 50); ans >= 0; --ans) {
      if (dp[ans][m] > T) continue;
      ll rem = T - dp[ans][m];
      int pl = upper_bound(c, c + k + 1, rem) - c;
      --pl;
      ret = max(ret, ans + pl);
    }
    cout << ret;
    return 0;
}
/// :D


Measured memory_bytes: 86352
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, M;
ll DP[1 << 12];

ll dfs(int t, int p, int q, vector<int>&v) {
	if (t == v.size()) {
		return DP[p] + DP[q];
	}
	return min({ dfs(t + 1,p + (1 << v[t]),q,v),dfs(t + 1,p,q + (1 << v[t]),v),dfs(t + 1,p + (1 << v[t]),q + (1 << v[t]),v) });
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < (1 << N); ++i) {
		DP[i] = 0xE869120E869120;
	}
	while (M--) {
		int a, b;
		cin >> a >> b;
		int t = 0;
		for (int i = 0; i < b; ++i) {
			int c;
			cin >> c;
			t += (1 << c - 1);
		}
		DP[t] = min(DP[t], (ll)a);
	}
	for (int i = 1; i < (1 << N); ++i) {
		vector<int>v;
		for (int j = 0; j < N; ++j) {
			if (i&(1 << j)) {
				v.push_back(j);
			}
		}
		DP[i] = min(DP[i], dfs(0, 0, 0, v));
	}
	if (DP[(1 << N) - 1] == 0xE869120E869120) {
		cout << -1 << endl;
		return 0;
	}
	cout << DP[(1 << N) - 1] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <algorithm>

int main() {
    int n; std::cin >> n;
    std::set<int> set;
    for (int i = 0; i < n; ++i) {
        int d; std::cin >> d;
        set.insert(d);
    }
    std::cout << set.size() << '\n';
    return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        a = []
        if n % i == 0:
            a.append(i)
            # divisors.append(i)
            if i != n // i:
                a.append(n//i)
                # divisors.append(n//i)
            else:
                a.append(i)
        divisors.append(a)

    # divisors.sort()
    return divisors

n = int(input())
divisors = make_divisors(n)
flag = 0
for i in divisors:
    if i:
        if 0 < i[0] < 10 and 0 < i[1] < 10:
            flag = 1

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll t1 = a * c;
    ll t2 = b * d;
    ll t3 = a * d;
    ll t4 = b * c;
    cout << max(max(t1, t2), max(t3, t4)) << endl;
}






Measured memory_bytes: 3624
n = gets.to_i
b = gets.split.map(&:to_i)
for i in 0..n-1
    if b[i] > i+1
        puts -1
        exit
    end
end
a = []
(n-1).downto(0) do |i|
    i.downto(0) do |j|
        if b[j] == j+1
            a.push(j+1)
            b.delete_at(j)
            break
        end
    end
end
puts a.reverse

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

const int NN = 1e5 + 5;
vector <int> gg[NN];
int dp[NN], dd[NN];
int nn, mm, resu;

void DFS(int uu) {
    dd[uu] = 1;
    for (int ii = 0; ii < gg[uu].size(); ++ii) {
        int vv = gg[uu][ii];
        if (dd[vv] == 0) DFS(vv);
        if (dp[vv] + 1 > dp[uu])
            dp[uu] = dp[vv] + 1;
    }
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
        cin >> nn >> mm;
        for (int ii = 1, uu, vv; ii <= mm; ++ii) {
            cin >> uu >> vv;
            gg[uu].push_back(vv);
        }
        for (int ii = 1; ii <= nn; ++ii)
            if (dd[ii] == 0) { DFS(ii); resu = max(resu, dp[ii]); }
        cout << resu;
    return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int v[n];
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    set<int> s;
    int ans=0;
    int num=0;
    for(int i=-1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            if(i+1+(n-j)>k){
                continue;
            }
            s.clear();
            num=0;
            for(int x=0;x<=i;x++){
                s.insert(v[x]);
                num+=v[x];
            }
            for(int x=j;x<n;x++){
                s.insert(v[x]);
                num+=v[x];
            }
            int maki=k-(i+1+(n-j));
            auto itr=s.begin();
            for(int x=0;itr!=s.end()&&x<maki;itr++){
                if(*itr<0)num-=*itr;
                x++;

            }

            ans=max(ans,num);
        }
    }
    cout <<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
n=int(input())
b=input().split()
s=b[:]
for i in range(n):
    for j in range(n-1,i,-1):
        if b[j][1]<b[j-1][1]:b[j],b[j-1]=b[j-1],b[j]
    m=i
    for j in range(i,n):
        if s[m][1]>s[j][1]:m=j
    s[m],s[i]=s[i],s[m]
print(*b)
print('Stable')
print(*s)
print(['Not s','S'][b==s]+'table')


Measured memory_bytes: 5604
#include<stdio.h>
int main()
{
    long long int n,i,s=0;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {

      if(((i%3)==0)||((i%5)==0))
      {
          s=s+0;
      }
        else
        {
            s=s+i;
        }
    }
    printf("%lld",s);
}


Measured memory_bytes: 1732
def main():
  
  n, m = map(int,input().split())
  ss = [input() for i in range(n)]
  a1, a2 = input()
  a3, a4 = input()
  dic = {"J":0, "O":1, "I":2}
  
  n1, n2, n3, n4 = dic[a1], dic[a2], dic[a3], dic[a4]
  fix = [[[0] * m for i in range(n)] for j in range(3)]
  
  ans = 0
  
  for x in range(n - 1):
    for y in range(m - 1):
      b1, b2, b3, b4 = ss[x][y], ss[x][y + 1], ss[x + 1][y], ss[x + 1][y + 1]
      if a1 == b1 and a2 == b2 and a3 == b3 and a4 == b4:
        ans += 1
        for i in range(3):
          if i != n1:
            fix[i][x][y] -= 1
          if i != n2:
            fix[i][x][y + 1] -= 1
          if i != n3:
            fix[i][x + 1][y] -= 1
          if i != n4:
            fix[i][x + 1][y + 1] -= 1
   
      elif not (a1 == b1) and a2 == b2 and a3 == b3 and a4 == b4:
        fix[n1][x][y] += 1
      elif a1 == b1 and not (a2 == b2) and a3 == b3 and a4 == b4:
        fix[n2][x][y + 1] += 1
      elif a1 == b1 and a2 == b2 and not (a3 == b3) and a4 == b4:
        fix[n3][x + 1][y] += 1
      elif a1 == b1 and a2 == b2 and a3 == b3 and not (a4 == b4):
        fix[n4][x + 1][y + 1] += 1
  
  rec = 0
  for i in range(3):
    fixi = fix[i]
    for x in range(n):
      fixix = fixi[x]
      for y in range(m):
        if fixix[y] > rec:
          rec = fixix[y]
          if rec == 4:
            break
      if rec == 4:
        break
    if rec == 4:
      break
  
  print(ans + rec)

main()


Measured memory_bytes: 30368
n=int(input())

a=list()
d=input().split()

for i in d:
    a.append(int(i))
d=0
for i in range(1,n):
    if a[i]<a[i-1]:
        d+=a[i-1]-a[i]
        a[i]+=a[i-1]-a[i]
print(d)

Measured memory_bytes: 32332
#include <cstdio>
#include <cstring>

int main()
{
	int n;
	int p[20];
	
	scanf("%d", &n);
	
	int max = 0;
	int sum = 0;
	
	for (int i = 0 ; i < n ; i++)
	{
		scanf("%d", &(p[i]));
		sum = sum + p[i];
		
		if (max < p[i])
			max = p[i];
	}
	
	sum = sum - max / 2;
	printf("%d\n", sum);
	
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }



int n,m,q,a[N],b[N],c[N],d[N],par[N],ans;

void dfs(int id1,int id2) {
	   if(id1==n+1) {
		     int temp=0;
		     rep1(i,1,q) {				  
				   if(par[b[i]]-par[a[i]]==c[i]) {
					      temp+=d[i];
					   }
					   ans=max(ans,temp);
				 }
		   }
		   
		else {
			  for(int i=id2;i<=m;i++) {
				    par[id1]=i;
				    dfs(id1+1,i);
				  }
			}
	}

void solve() {
	    cin>>n>>m>>q;
	    rep1(i,1,q) {
			  cin>>a[i]>>b[i]>>c[i]>>d[i];
			} 
	    
	    dfs(1,1);
	    
	    cout<<ans<<endl; 
	 
	}

    
int32_t main() {
	cool;
	int t=1;	

	//cin>>t;
	while(t--)
	  solve();

return 0;	   
}


Measured memory_bytes: 3680