akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,s=0;cin>>n;
  lvector A(n);rep(i,n) {cin>>A[i];s^=A[i];}
  rep(i,n) A[i]^=s;
  rep(i,n-1) cout<<A[i]<<' ';print(A[n-1]);
  return 0;
}


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


int main()
{
    int N;
    cin>>N;
    int **d = new int*[N];

    for(int i = 0; i < N; ++i)
        d[i] = new int[2];

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



    for(int i=0;i<N-2;i++)
    {
        if(d[i][0]==d[i][1] && d[i+1][0]==d[i+1][1] && d[i+2][0]==d[i+2][1])
        {
            cout<<"Yes";
            return 0;
        }
    }

    cout<<"No";

return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define SZ(x) ((int)(x).size())
typedef long long ll;

typedef long double ld;
using namespace std;


int main() {
    ll N;
    cin>>N;
    double A;
    double sum=0.0;
    REP(i,N){
        cin>>A;
        sum+=(1/A);
    }
    double t;
    t=1/sum;

    cout<<t<<endl;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES" : "NO")
#define mod(a, b) (b + (a % b)) % b
#define MOD  (int)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::pair <ll, ll> pll;
typedef std::vector<pii> vpii;
using namespace std;
int n, d;
int a[11][11];
bool ok(int i, int j){
    double dist = 0;
    for(int k = 0; k < d; k++){
        dist += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
    }
    int sq = sqrt(dist);
    return (sq * sq == dist);
}
 
void solve(){
    cin >> n >> d;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++) cin >> a[i][j];
    }
    int cnt = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i != j){
                if(ok(i, j))cnt++;
            }
        }
    }
    cout << cnt / 2;
}
 
int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}
 


Measured memory_bytes: 256
from itertools import combinations

n, a, q, ms = int(input()), list(map(int, input().split())), input(), map(int, input().split())

cache = {}


def sum_a(tmp, t):
    global a, cache
    if t in cache:
        return tmp + cache[t]
    elif len(t) == 1:
        return tmp + a[t[0]]
    else:
        cache[t] = result = sum_a(tmp + a[t[0]], t[1:])
        return result


l = list(sum_a(0, t) for i in range(n) for t in combinations(range(n), i + 1))

for m in ms:
    print('yes' if m in l else 'no')

Measured memory_bytes: 228988
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int m=-1;
    int sl=s.length();
    int tl=t.length();
    for(int i=0;i<sl-tl+1;i++)
    {
        int ct=0;
        for(int j=i;j<i+tl;j++){
            if(t[j-i]==s[j]){
                ct++;
            }
        }
       m=max(m,ct);
    }
    cout<<tl-m;

}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
long long int s[100009] = {0};
long long int f[100009] = {0};
string z;
long long int n, m, i, x;
int main()
{
    //freopen("test.inp","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    long long int dem1 = 0, dem2 = 0;
    for (i = 1; i <= m; i++)
    {
        cin >> x >> z;
        if (z == "WA")
        {
            if (s[x] == 0) f[x]++;
        }
        else s[x]++;
    }
    for (i = 1; i <= n; i++)
    {
        if (s[i] != 0) dem1 ++;
        if (s[i] != 0) dem2 += f[i];
    }
    cout << dem1 << " " << dem2;
}

Measured memory_bytes: 1792
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll a,p;
	cin>>a>>p;
	cout<<(a*3+p)/2;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

const int MOD = 1e9+7;
vector<int> G[201010];

signed main(){

  int n,k; cin >> n >> k;
  for(int i = 0; i < n-1; i++){
    int a,b; cin >> a >> b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int ans = k;
  function< void(int,int) > dfs =
  [&](int u,int pre){
    int color = k-2;
    if(pre == -9) color++;
    for(int v : G[u]){
      if(v == pre) continue;
      dfs(v,u);
      ans = (ans * color) % MOD;
      color--;
      if(color < 0){
        ans = 0;
        return;
      }
    }
  };
  dfs(0,-9);
  cout << ans << endl;

  return 0;
}


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

typedef long long ll;
const ll mod=1e9+7;
const ll N=20003;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	string s;
	cin>>s;
	s+=(s.back()=='s'?"es":"s");
	cout<<s;
}	  


Measured memory_bytes: 3660
/*
 * Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
 *       Example:-   $ g++ -std=c++11 c++Template.cpp
 *
 * Author : Denzil Bernard  
 * Handle: 1_mn_RMY
 *
 */
#include<bits/stdc++.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define read(type) readInt<type>()
#define ll long long
typedef pair< ll, ll> PII;
typedef vector<ll> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<ll,ll> MPII;
typedef set<ll> SETI;
typedef multiset<ll> MSETI;

ll SI(){
    ll x;
    cin>>x;
    return x;
}


/********** Main()  function **********/
int main()
{
    
    
    VI v(4);
    bool a = false, b = false, c = false, d = false;
    REP(i,4){
        v[i] = SI();
        if(v[i]==1){
            a = true;
        }
        if(v[i]==9){
            b = true;
        }
        if(v[i]==7){
            c = true;
        }
        if(v[i]==4){
            d = true;
        }
    }
    if(a&&b&&c&&d){
        cout<<"YES\n";
    }
    else{
        cout<<"NO\n";
    }


    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(int qtd, char* nome[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	int n, m;
	cin >> n >> m;
	if(n < m)
		for(int i = 0; i < m; i++)
			cout << n;
	else
		for(int i = 0; i < n; i++)
			cout << m;
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
int main(){
 int A[100],N,Al,Bo,ans;
 std::cin >> N;
 for(int i=0;i<N;i++)
  std::cin >> A[i];
 std::sort (A,A+N);
 for(int i=N-1;i>=0;i-=2)
  Al+=A[i];
 for(int i=N-2;i>=0;i-=2)
  Bo+=A[i];
std::cout << std::abs(Al-Bo) << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);

    int n;
    cin>>n;
    string s[n];
    int p[n];
    set<string> st;
    for(int i=0;i<n;i++){
        cin>>s[i]>>p[i];
        st.insert(s[i]);
    }
    for(auto i:st){
        vector<pair<int,int>> v;
        for(int j=0;j<n;j++){
            if(i==s[j]){
                v.push_back(make_pair(p[j],j));
            }
        }
        sort(v.begin(),v.end());
        reverse(v.begin(),v.end());
        for(auto j:v){
            cout<<j.second+1<<endl;
        }
    }

}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [[0]+list(map(int, input().split())) for i in range(n)]

# +++ or ---
for i in range(n):
    a[i][0]=a[i][1]+a[i][2]+a[i][3]

a.sort()
ans1=0
ans2=0
for i in range(m):
    ans1-=a[i][0]
    ans2+=a[n-i-1][0]
ansA=max(ans1,ans2)

#++- or --+
for i in range(n):
    a[i][0]=a[i][1]+a[i][2]-a[i][3]
a.sort()
ans3=0
ans4=0
for i in range(m):
    ans3-=a[i][0]
    ans4+=a[n-i-1][0]
ansB=max(ans3,ans4)

#+-+ or -+-
for i in range(n):
    a[i][0]=a[i][1]-a[i][2]+a[i][3]
a.sort()
ans5=0
ans6=0
for i in range(m):
    ans5-=a[i][0]
    ans6+=a[n-i-1][0]
ansC=max(ans5,ans6)

#+-- or -++
for i in range(n):
    a[i][0]=a[i][1]-a[i][2]-a[i][3]
a.sort()
ans7=0
ans8=0
for i in range(m):
    ans7-=a[i][0]
    ans8+=a[n-i-1][0]
ansD=max(ans7,ans8)

print(max(ansA,ansB,ansC,ansD))

Measured memory_bytes: 39664
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
using namespace std;
long long inf=100000000000007;
#define int long long
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int to,cost;};
vector<edge> G[22];
char fi[1005][1005];
P sg[10];
int d[1005][1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int c=0;
int n,m,t;
signed main(){
    string s;cin>>s;
    string r={};
    vector<int>num;
    int x=0;
    for(int i=0; i<s.length();i++){
        if(s[i]!='x'){
            r+=s[i];
            num.push_back(x);
            x=0;
        }
        else x++;
    }
    num.push_back(x);
    string f=r;
    reverse(r.begin(),r.end());
    if(r!=f){
        cout<<-1<<endl;
        return 0;
    }
    int rco=0;
    for(int i=0; i<num.size()/2;i++){
        rco+=max(num[i],num[num.size()-i-1])-min(num[i],num[num.size()-i-1]);
    }
    cout<<rco<<endl;
    return 0;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
int N, A, B, ans;

int sum(int x){
	int ret = 0;
	while(x){
		ret += x % 10;
		x /= 10;
	}
	return ret;
}

int main(){
	scanf("%d %d %d", &N, &A, &B);
	for(int i = 1; i <= N; i++){
		int s = sum(i);
		if(A <= s && s <= B)	ans += i;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
h,w,k= map(int,input().split())
mat=[]
for i in range(h):
  mat.append(input())
    
ans = 0    
for i in range(2**(h+w)):
  num = 0
  t = i
  tmat = [list(jj) for jj in mat]
  
  for j in range(h):
    if j>0:
      t = t>>1
    if t&1:
      tmat[j]=list(["9"]*w)
      
  for j in range(w):
    t = t>>1
    if t&1:
      for p in range(h):
        tmat[p][j]="9"
      
  for hh in range(h):
    for ww in range(w):
      if tmat[hh][ww]=="#":
        num+=1
      if num>k:
        break
        
  if num==k:
    ans +=1
    
print(ans)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
const int MAX = 10000;
 
int main(void) {
 
    int x;
    cin >> x;
 
    vector<ll> power5(MAX + 1);
    for (ll i = 0; i <= MAX; i++) {
        power5[i] = pow(i, 5);
    }
 
    for (int i = 0; i <= MAX; i++) {
        for (int j = i; j <= MAX; j++) {
            if (power5[j] - power5[i] == x) {
                cout << j << " " << i << endl;
                return 0;
            }
            else if (power5[j] + power5[i] == x) {
                cout << j << " " << -i << endl;
                return 0;
            }
        }
    }
 
    return 0;
 
}

Measured memory_bytes: 4256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;


int main(){
    set<ll> se;
    ll n;
    rep(i,3) {
        cin >> n;
        se.insert(n);
    }
    cout << se.size() << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;

void solve()
{
	int animals,legs;
	cin>>animals>>legs;
	int p = animals*2;
	int q = animals*4;
	if(legs==p||legs==q)
		cout<<"Yes"<<endl;
	else
	{
		int i = 1;
		int ans = (animals-i)*4+2*i;
		bool flag = true;
		if(ans==legs)
		{
			cout<<"Yes"<<endl;
			flag = false;
		}
		while(legs!=ans && i<animals && flag)
		{
			i++;
			ans = (animals-i)*4+2*i;
			if(ans==legs)
			{
				cout<<"Yes"<<endl;
				flag = false;
				break;
			}
		}
		if(flag)
			cout<<"No"<<endl;
	}
}

int32_t main()
{
	FastIO; PRECISION;
	int t = 1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
} 

Measured memory_bytes: 3168
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int row = input.nextInt();
        int col = input.nextInt();
        int sum_row = 0, sum_col = 0;
        int[][] new_table = new int[row + 1][col + 1];
        for (int i = 0; i < new_table.length - 1; i ++ )
            for (int j = 0; j < new_table[0].length - 1; j ++ )
                new_table[i][j] = input.nextInt();
                
        for (int i = 0; i < new_table.length; i ++ ) {
            int sum = 0;
            for (int j = 0; j < new_table[0].length; j ++ )
                sum += new_table[i][j];
            new_table[i][new_table[0].length - 1] = sum;
        }
        
        for (int i = 0; i < new_table[0].length; i ++ ) {
            int sum = 0;
            for (int j = 0; j < new_table.length; j ++ )
                sum += new_table[j][i];
            new_table[new_table.length-1][i] = sum;
        }
        
        for (int i = 0; i < new_table.length; i ++ ) {
            System.out.print(new_table[i][0]);
            for (int j = 1; j < new_table[0].length; j ++ )
                System.out.print(" " + new_table[i][j]);
            System.out.println();
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

signed main(void)
{
	int a, b;
	cin >> a >> b;
	if(a+b >= 10) cout << "error" << endl;
	else cout << a+b << endl;

	return 0;
}


Measured memory_bytes: 256
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;


constexpr int D = 365;
int c[26], d[D][26], t[D];
int now_score;

random_device rd;
mt19937 mt(rd());
uniform_int_distribution<> dist0(0, D - 1), dist1(0, 25), dist2(0, 1);
int day_rand() {return dist0(mt);}
int type_rand() {return dist1(mt);}
int b_rand() {return dist2(mt);}

int new_score(const int t0, const int t1, const int new_t[D]) {
    int ans = now_score;
    int last[26];
    rep(i, 26) last[i] = -1;
    rep(i, D) {
        if (new_t[i] == t0 || new_t[i] == t1) ans -= d[i][new_t[i]];
        last[new_t[i]] = i;
        ans += (i - last[t0]) * c[t0];
        ans += (i - last[t1]) * c[t1];
    }
    rep(i, 26) last[i] = -1;
    rep(i, D) {
        if (new_t[i] == t0 || new_t[i] == t1) ans += d[i][new_t[i]];
        last[new_t[i]] = i;
        ans -= (i - last[t0]) * c[t0];
        ans -= (i - last[t1]) * c[t1];
    }
    return ans;
}

int main() {
    using chrono::system_clock;
    using chrono::milliseconds;
    chrono::system_clock::time_point p = system_clock::now() + milliseconds(1950);
    
    
    cin >> c[0];
    rep(i, 26) cin >> c[i];
    rep(i, D) rep(j, 26) cin >> d[i][j];
    
    
    // 貪欲
    int last[26];
    rep(i, 26) last[i] = -1;
    rep(i, D) {
        int max_score = -inf, max_id = -1;
        rep(j, 26) {
            if (chmax(max_score, (i - last[j]) * c[j] + d[i][j])) max_id = j;
        }
        t[i] = max_id;
        last[max_id] = i;
    }
    rep(i, 26) last[i] = -1;
    now_score = 0;
    rep(i, D) {
        now_score += d[i][t[i]];
        last[t[i]] = i;
        rep(j, 26) now_score -= c[j] * (i - last[j]);
    }
    
    
    while (system_clock::now() < p) {
        int new_t[D];
        rep(i, D) new_t[i] = t[i];
        if (b_rand()) {
            int d0 = day_rand(), d1 = day_rand();
            swap(new_t[d0], new_t[d1]);
            if (chmax(now_score, new_score(t[d0], t[d1], new_t))) swap(t[d0], t[d1]);
        } else {
            int d0 = day_rand(), t0 = type_rand();
            new_t[d0] = t0;
            if (chmax(now_score, new_score(t0, t[d0], new_t))) t[d0] = t0;
        }
    }
    
    
    // cout << "Score: " << now_score << "\n";
    rep(i, D) cout << t[i] + 1 << "\n";
}


Measured memory_bytes: 3684
N, M = map(int, input().split())
a = 1
b = N
d = set([1, N - 1])
for _ in range(M):
    print(a, b)
    a += 1
    b -= 1
    while (b - a) in d or (N - b + a) in d or (b - a) == (N - b + a): b -= 1
    d.add(b - a)
    d.add(N - b + a)


Measured memory_bytes: 90248
#include<stdio.h>
#include<stdlib.h>

int comp(const void *p1,const void *p2);

int main(void){
	int *customer,n,c,k,i;
	int bus,count,standard;
	scanf("%d %d %d",&n,&c,&k);
	customer=(int *)calloc(n,sizeof(int));
	for(i=0;i<n;i++){
		scanf("%d",&customer[i]);
		//customer[i]+=k;
	}
	
	qsort(customer,n,sizeof(int),comp);
	bus=0;
	count=0;
	for(i=0;i<n;i++){
		if(count==0){
			standard=customer[i];
			count++;
			bus++;
		}else{
			//printf("now:%d\n",i);
			if(count<c && customer[i]<=standard+k){
				count++;
			}else{
				//printf("count reseted at i=%d\n",i);
				count=1;
				bus++;
				standard=customer[i];
			}
		}
	}
	
	printf("%d\n",bus);
	return 0;
}

int comp(const void *p1,const void *p2){
	int n1,n2;
	n1=*((const int *)p1);
	n2=*((const int *)p2);
	return n1-n2;
}

Measured memory_bytes: 892
#include<stdio.h>



int A[10000];
int main( void ) 
{
  
    int n,count=0;
    scanf( "%d", &n );
     
    int i, j;

    for( i=0; i<n; i++ ) 
	{
        scanf( "%d", &A[i] );
    }
    for( i=n; i>0; i-- ) 
	{    
        for(j=0;j<i-1;j++)
		{
			if(A[j]>A[j+1])
			{
				int temp = A[j];
				A[j] = A[j+1];
				A[j+1]=temp;
				count++;
			}
		}
	}
	printf("%d",A[0]);
    for(i=1;i<n;i++) printf(" %d",A[i]);
    printf("\n");
    printf("%d\n",count);

    return 0;
	
}

/*#include<stdio.h>

#include<conio.h>

int A[10000];
int main( void ) 
{
  
    int n,count=0;
    scanf( "%d", &n );
     
    int i, j;

    for( i=0; i<n; i++ ) 
	{
        scanf( "%d", &A[i] );
    }
    for( i=0; i<n; i++ ) 
	{    
        for(j=n-1;j>i;j--)
		{
			if(A[j-1] > A[j])
			{
				int temp = A[j-1];
				A[j-1] = A[j];
				A[j]=temp;
				count++;
			}
		}
		printf(" %d",A[j]);
    }
	printf("%d",count);
    getch();
    return 0;
	
}*/

Measured memory_bytes: 604
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var ans = 0;
            var n = int.Parse(ReadLine());
            //var s = Console.ReadLine().Split(' ')
            var s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            for (int i = 0; i < n; i++)
            {
                if (i % 2 == 0 && s[i] % 2 == 1)
                {
                    ans++;
                }
            }

            WriteLine(ans);
            Out.Flush();
        }
    }
}

Measured memory_bytes: 28092
while True:
	a=0
	num=list(map(int,input().split()))
	if num[0]==0 and num[1]==0:
		break
	else:
		for i in range(1,num[0]+1):
			for j in range(i+1,num[0]+1):
				for k in range(j+1,num[0]+1):
					if i+j+k==num[1]:
						a+=1
		print(a)
					
			


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
using namespace std;
#define MAP_SIZE 10

class Pos {
  public:
    Pos(int x, int y) : x(x), y(y) {}
    int x, y;
    bool alive(Pos p) { return p.x - 1 <= this->x && this->x <= p.x + 1 && p.y - 1 <= this->y && this->y <= p.y + 1; }
};

int dx[12] = {-2, -2, -2, 2, 2, 2, -1, 0, 1, -1, 0, 1}; 
int dy[12] = {-1, 0, 1, -1, 0, 1, -2, -2, -2, 2, 2, 2}; 
bool move(Pos p, vector<Pos> sp, int n) {
  if (p.x < 0 || MAP_SIZE <= p.x || p.y < 0 || MAP_SIZE <= p.y) return false;
  if (n == -1) return true;
  if (!p.alive(sp[n--])) return false;
  sp.pop_back();
  bool result = false;
  for (int i = 0; i < 12; i++) {
    if (move(Pos(p.x + dx[i], p.y + dy[i]), sp, n)) result = true;
    if (result) break;
  }
  return result;
}

int main() {
  int x, y, n, i;
  while (cin >> x >> y) {
    if (!(x || y)) break;
    Pos p = Pos(x, y); 

    cin >> n;
    vector<Pos> sp = { p };
    for (i = 0; i < n; i++) {
      cin >> x >> y;
      sp.insert(sp.begin(), Pos(x, y));
    } 
    cout << (move(p, sp, n) ? "OK" : "NA") << endl;
  }
  return 0;
}

Measured memory_bytes: 2964
#include <iostream>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string.h>

using namespace std;

int A1, A2, A3;
int main(int argc, char** argv) {
    cin >> A1 >> A2 >> A3;
    int C[3];
    C[0] = abs(A1 - A2);
    C[1] = abs(A2 - A3);
    C[2] = abs(A3 - A1);
    sort(C, C + 3);
    cout << C[0] + C[1] << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]
if A[0] > 0:
    print(-1)
else:
    ans = 0
    for n in range(N-1, -1, -1):
        if A[n] - A[n-1] > 1 or A[n] > n:
            print(-1)
            break
        else:
            if A[n] - A[n-1] == 1:
                ans += 1
            else:
                ans += A[n]
    else:
        print(ans)


Measured memory_bytes: 11048
//antaji dhil martasi. vul hoile amar kono dosh nai
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    int i = m/n;
    while(i > 1)
    {
        if(m%i == 0)
            break;
        i--;
    }
    printf("%d", i);
}


Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn rep<T, F: FnMut() -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|_| f()).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let m: usize = scan(tokens);
    let a: Vec<usize> = rep(n, || scan(tokens));
    let h: Vec<usize> = a.into_iter().map(|ai| ai / 2).collect();
    let mut lcm = 1;
    for i in 0..n {
        lcm *= h[i] / gcd(lcm, h[i]);
        if lcm > m {
            println!("0");
            return;
        }
    }
    let e = exponent_of_two(h[0]);
    for i in 1..n {
        if exponent_of_two(h[i]) != e {
            println!("0");
            return;
        }
    }
    println!("{}", (m / lcm + 1) / 2);
}

fn gcd(mut x: usize, mut y: usize) -> usize {
    while y > 0 {
        let r = x % y;
        x = y;
        y = r;
    }
    x
}

fn exponent_of_two(mut x: usize) -> usize {
    let mut cnt = 0;
    while x & 1 == 0 {
        x >>= 1;
        cnt += 1;
    }
    cnt
}

Measured memory_bytes: 8444
N = int(input())
X = []
for _ in range(N):
    x, y = list(map(int, input().split()))
    X.append([x, y])

import numpy as np
X = np.array(X)

Mx = (X[:, 0].reshape(-1, 1) - X[:, 0].reshape(1, -1)) ** 2
My = (X[:, 1].reshape(-1, 1) - X[:, 1].reshape(1, -1)) ** 2
M = np.sqrt(Mx + My)

print((N - 1) * (np.sum(M) / (N ** 2 - N)))

Measured memory_bytes: 21344
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A;
    string B;
    cin >> A >> B;
    int idx = 0;
    rep(i, 0, B.size()) {
        if (B[i] == '.') {
            idx = i;
            break;
        }
    }
    string C = B.substr(0, idx) + B.substr(idx + 1, B.size() - idx + 1);
    ll D = stoll(C);
    cout << A * D / 100 << endl;
    return 0;
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#define INF numeric_limits<int>::infinity()
#pragma endregion


int main()
{
    vi v(2, 0);
    rep(i, 2) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        v[i] += a + b + c + d;
    }
    P(max(v[0], v[1]));
    return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

const int maxn = 2e5 + 5;
int n;
int a[maxn];
int dp[maxn];

void chemthan() {
    cin >> n;
    int res = 0;
    FOR(i, 0, n) {
        cin >> a[i];
        chkmax(dp[a[i]], dp[a[i] - 1] + 1);
        chkmax(res, dp[a[i]]);
    }
    cout << n - res << "\n";
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,m;
  cin >> n>> m;
  vector<int> s(m),c(m);
  for(int i=0;i<m;i++) cin >> s[i] >> c[i];

  bool f = true;
  int d1=-1,d2=-1,d3=-1;
  for(int i=0;i<m;i++){
    if(s[i] == 1){
      if(d1 == -1) d1 = c[i];
      else if(d1 != c[i]){
        f = false;
      }
    }else if(s[i] == 2){
      if(d2 == -1) d2 = c[i];
      else if(d2 != c[i]){
        f = false;
      }
    }else if(s[i] == 3){
      if(d3 == -1) d3 = c[i];
      else if(d3 != c[i]){
        f = false;
      }
    }
  }

  if(d1 == 0 && n != 1){
    f = false;
  }
  if(d1 == -1){
    d1 = 1;
    if(n == 1){
      d1 = 0;
    }
  }
  if(d2 == -1){
    d2 = 0;
  }
  if(d3 == -1){
    d3 = 0;
  }

  int ans;
  if(n==1) ans = d1;
  else if(n==2) ans = d1*10+d2;
  else if(n==3) ans = d1*100+d2*10+d3;

  if(f) cout << ans << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 256
from math import *
PI = 3.1415926535898
while True:
    try:
        t = input()
        ans = ""
        ans += str(t/(60*60))
        t %= 60*60
        ans += ":"
        ans += str(t/60)
        t %= 60
        ans += ":"
        ans += str(t)
        print ans
    except EOFError:
        break

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

int main() {
  int a, b;
  //string op;
  cin >> a >> b;
  int C = a * b;
  if (C%2 == 0){
    cout << "Even" <<endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
import itertools

n = int(input())
lst_n = [i for i in range(1, n+1)]

lst_p = list(itertools.permutations(lst_n))
    
p = lst_p.index(tuple(map(int, input().split())))
q = lst_p.index(tuple(map(int, input().split())))
print(abs(p-q))

Measured memory_bytes: 8052
#include <iostream>

using namespace std;

int main()
{
  long long int x;
  
  cin >> x;
  
  for (long long int i = -2000; i <= 2000; i++) {
    for (long long int j = -2000; j <= 2000; j++) {
      if (i*i*i*i*i - j*j*j*j*j == x) {
        cout << i << " " << j << endl;
        return (0);
      }
    }
  }
}

Measured memory_bytes: 3640
#include <iostream>

int main()
{
	long long n, d;
	std::cin >> n >> d;
	int count = 0;
	for (int i = 0; i < n; i++)
	{
		long long x, y;
		std::cin >> x >> y;
		if (x * x + y * y <= d * d)
			count++;
	}
	std::cout << count << std::endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K;
    int odd = 0;
    int even = 0;
    cin >> K;
    int i;
    for (i = 1; i <= K; i++){
        if (i % 2 == 0) even++;
        else odd++;
    }
    cout << even * odd << endl;
}

Measured memory_bytes: 256
using System;
class Program
{    static void Main(String[] args){
  
    string[] str = Console.ReadLine().Split(' ');
    int a = int.Parse(str[0]);
    int b = int.Parse(str[1]);
    if (a%2==1){
        if (b%2==1){
          Console.WriteLine("Yes");
        }else {
            Console.WriteLine("No");
        }
    }else {
        Console.WriteLine("No");
        }   
    }   
}

Measured memory_bytes: 13140
n = int(input())
dat = list(map(int, input().split()))
import collections
c = collections.Counter(dat)
data = []
for k in c:
    cnt = c[k]
    if cnt > 1:
        data.append((k, cnt//2))
data.sort(reverse=True)
#print(data)
if len(data) == 0:
    print(0)
else:
    a = data[0]
    x =a[0]
    if a[1] > 1:
        y = a[0]
        print(x*y)
    elif len(data) > 1:
        y = data[1][0]
        print(x*y)
    else:
        print(0)

Measured memory_bytes: 68760
#include<stdio.h>
#include<string.h>
int main()
{
	int n,count=0;
	scanf("%d",&n);
		if(n>=105)count++;
		if(n>=135)count++;
		if(n>=165)count++;
		if(n>=189)count++;
		if(n>=195)count++;
	printf("%d",count);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

namespace data {}

typedef long long ll;
typedef std::pair<int, int> pii;
typedef unsigned long ul;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cout.setf(std::ios::fixed);
    cout.precision(3);
    int T, X;
    cin >> T >> X;
    cout << (double)T / X << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    int s;
    cin >> s;
    int a, b, c;
    a = s/100;
    b = s%100;
    c = (s/10)%100;

    if((a%11)*(b%11)*(c%11) == 0){
        cout << "Bad";
    }else{
        cout << "Good";
    }
    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 r = Integer.parseInt(sc.next());;
    int g = Integer.parseInt(sc.next());;
    int b = Integer.parseInt(sc.next());;
    int a = r*100 + g*10+b;
    if(a % 4 == 0) System.out.println("YES");
    else System.out.println("NO");
    

}
}


Measured memory_bytes: 23636
def calc_gcd(x,y):
    amari = max(x,y)%min(x,y)
    if amari == 0:
        return min(x,y)
    return calc_gcd(min(x,y), amari)
def calc_scm(x,y,gcd):
    return x*y//gcd

A,B,C,D = list(map(int, input().split()))
scm = calc_scm(C,D,calc_gcd(C,D))
low = (A-1)//C + (A-1)//D - (A-1)//scm
high = B//C + B//D - B//scm
print(B - A + 1 - (high - low))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
        
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int start = 1;
		while(k-1>0) {
			start += 2;
			k--;
		}
		if(start <= n) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
    }

}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tofile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); 
#define M 1000000007
#define ll long long
#define db double
#define pb push_back
#define fi first
#define se second
#define vl vector<ll>
#define vvl vector<vl>
#define pii pair<int,int>
#define mkp make_pair

const ll N=100005;
vector<ll> g[N];
bool vis[N];
ll dp[N];

void dfs(ll u)
{
	vis[u]=true;
	if(g[u].size()==0)
	{
		dp[u]=0;
		return;
	}
	ll& temp=dp[u];
	for(auto v:g[u])
	{
		if(!vis[v]) dfs(v);
		temp=max(temp,1+dp[v]);
	}
}

int main()
{
	ll n,m;
	cin >> n >> m;
	for(ll i=0;i<m;i++)
	{
		ll u,v; cin >> u >> v;
		g[u].pb(v);
	}
	
	for(ll i=1;i<=n;i++)
	{
		if(!vis[i]) dfs(i);
	}
	
	ll mx=0;
	for(ll i=1;i<=n;i++) mx=max(mx,dp[i]);
	cout << mx << endl;
	
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N;
  cin >> N;
  int ga, sa, ba;
  int gb, sb, bb;
  cin >> ga >> sa >> ba >> gb >> sb >> bb;
  vector<i64> dp(10001);
  repc(i, N) {
    amax(dp[i], (i64) i);
    amax(dp[i + ga], dp[i] + gb);
    amax(dp[i + sa], dp[i] + sb);
    amax(dp[i + ba], dp[i] + bb);
  }
  i64 ma = 0;
  repc(i, N) amax(ma, dp[i]);
  dp.assign(ma + 1, 0);
  repc(i, ma) {
    amax(dp[i], (i64) i);
    if (i + gb <= ma) amax(dp[i + gb], dp[i] + ga);
    if (i + sb <= ma) amax(dp[i + sb], dp[i] + sa);
    if (i + bb <= ma) amax(dp[i + bb], dp[i] + ba);
  }
  i64 ans = 0;
  repc(i, ma) amax(ans, dp[i]);
  cout << ans << endl;
}


Measured memory_bytes: 195712
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

ll a[200000];
ll sum[200000], n;
int table[200000];

bool solve(ll x) {
	int l, r = 1; // [l,r)
	REP(i, 2 * n) table[i] = i;
	REP(i, 2 * n) {
		l = i;
		if (l >= r) r = l + 1;
		while (r - l < n && r < 2 * n && sum[r - 1] - sum[l] + a[l] < x) r++;
		if (sum[r - 1] - sum[l] + a[l] >= x) table[l] = r;
	}
	
	REP(i, n) {
		int pos = i;
		REP(j, 3) {
			if (pos == table[pos]) break;
			pos = table[pos];
			if (pos > i + n) break;
			if (j == 2 && pos <= i + n) return true;
		}
	}
	return false;
}

int main() {
	cin >> n;
	
	REP(i, n) {
		scanf("%lld", &a[i]);
		a[n + i] = a[i];
	}
	sum[0] = a[0];
	FOR(i, 1, 2*n) sum[i] = sum[i - 1] + a[i];
	
	ll l = -1, r = n * 1000000000;
	while (r - l > 1) {
		ll m = (l + r) / 2;
		if (solve(m)) l = m;
		else r = m;
	}
	
	cout << l << endl;
	
	return 0;
}

Measured memory_bytes: 7096
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
#define INF 0x3f3f3f
#define ll long long
#define pb push_back
#define mp make_pair
#define pair pair<int,int>
#define C(a) cout<<a<<endl;
#define CY cout<<"YES"<<endl;
#define CN cout<<"NO"<<endl;
#define Cy cout<<"Yes"<<endl;
#define Cn cout<<"No"<<endl;
#define ull unsigned long long
#define me(a) memset(a,0,sizeof(a));
#define my(a,b) memcpy(a,b,sizeof(b));
#define cio ios::sync_with_stdio(false)
ll mod=1e9+7;
ll gcd(ll a,ll b){return (a%b==0) ? b : gcd(b,a%b);}
int main(){
	
	ll n,d;
	cin>>n>>d;
	int cnt=0;
	while(n--){
		double a,b;
		cin>>a>>b;
		if(sqrt(a*a+b*b)<=d){
			cnt++;
		}	
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3744
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
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};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
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; }
ll h,w;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h>>w;
    if(h==1||w==1){cout<<1<<"\n";return 0;}
    ll ans=h*(w/2);
    if(w%2==1){
        ans+=(h+1)/2;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, x = 0, y=0 ;
    scanf("%d",&n);
    for(int i = 1; i <= n; ++i){
        if((i % 2 != 0) && (n >= 105)){
            x = 0;
            for(int j = 1; j <= i; ++j){
                if(i % j == 0) ++x;
                if(x == 9) break;
            }
            if(x == 8) ++y;
        }
    }
    printf("%d\n", y);
    return 0;
}



Measured memory_bytes: 128
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int y = sc.nextInt();
    
    int a = 0, b = 0, c = 0;
    boolean flag = false;
        for(int i=n;i>=0;i--){     
          for(int j=n-i;j>=0;j--){
              int k = n-i-j;
              int number = 10000 * i + 5000 * j + 1000 * k;
              if(number == y && i + j + k == n){
              	 a = i;
                 b = j;
                 c = k;
                 flag = true;
                
              
            }
          }
         }
    if(flag){
      System.out.println(a +" "+ b +" "+ c);
    }else{
      System.out.println("-1" + " " + "-1" + " " + "-1");
    }  
  }
}  

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



void extapp(string str1, int k ){

string str3 = str1.substr(0,k);
string str2 = ("..."); 
cout << str3.append(str2);

}

void solve(){
int k;
string str1;
cin >> k >> str1;
if(str1.length() > k ) {extapp(str1,k); }
else {cout << str1;}



}

int main(){

solve();
return 0;


}

Measured memory_bytes: 3596