akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int maxn=2001;
const int maxk=10001;
int n,K,len[maxn];
char s[maxn][maxk];
bitset<maxk> bit[maxn];
pii v[2][8001];
int main()
{
    scanf("%d%d",&n,&K);
    for (int i=1;i<=n;++i) {
        scanf("%s",s[i]);
        len[i]=strlen(s[i]);
    }
    bit[n+1][0]=1;
    for (int i=n;i>=1;--i)
        bit[i]=bit[i+1]|(bit[i+1]<<len[i]);
    int c1=0;
    for (int i=1;i<=n;++i)
        if (bit[i+1][K-len[i]])
            v[1][++c1]=pii(i,0);
    for (int o=1;o<=K;++o) {
        char mmin='z';int c2=0;
        for (int i=1;i<=c1;++i)
            mmin=min(mmin,s[v[o&1][i].first][v[o&1][i].second]);
        putchar(mmin);
        int ID=n+1;
        for (int i=1;i<=c1;++i) {
            int id=v[o&1][i].first,pos=v[o&1][i].second;
            char ch=s[id][pos];
            if (ch!=mmin) continue;
            if (pos+1==len[id]) ID=min(ID,id);
            else if (c2<8000) v[(o+1)&1][++c2]=pii(id,pos+1);
        }
        for (int i=ID+1;i<=n;++i)
            if (c2<8000&&K-o-len[i]>=0&&bit[i+1][K-o-len[i]])
                v[(o+1)&1][++c2]=pii(i,0);
        c1=c2;
    }
    return 0;
}


Measured memory_bytes: 15216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100000 + 5;
ll N, A, B;
ll a[maxn];

bool sol(ll n) {
	ll task = 0;
	for(int i=0; i<N; i++) {
		ll left = a[i] - B*n;
		if(left > 0) {
			task += (left-1)/(A-B) + 1;
			if(task > n) return false;
		}
	}
	return true;
}

int main() {
	scanf("%lld%lld%lld", &N, &A, &B);
	
	ll l = 0, r = -1;
	for(int i=0; i<N; i++) 
		scanf("%d", &a[i]), r = max(r, a[i]);
	
	while(l<r) {
		ll mid = l+r>>1;
		if(sol(mid)) r = mid;
		else l = mid+1;
	}
	
	printf("%lld\n", r);
}

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

void replace(string &str, int a, int b, string opt)
{
    for (int i = a; i < b + 1; ++i)
        str[i] = opt[i-a];
}

void reverse(string &str, int a, int b)
{
    reverse(&str[a], &str[b+1]);
}

void print(string str, int a, int b)
{
    cout << str.substr(a, b + 1 - a) << endl;
}

int main(void)
{
    string str;
    int n;
    cin >> str >> n;
    for (int i = 0; i < n; ++i) {
        string cmd, opt;
        int a, b;
        cin >> cmd >> a >> b;
        if (cmd == "replace") {
            cin >> opt;
            replace(str, a, b, opt);
        }
        else if (cmd == "reverse") {
            reverse(str, a, b);
        }
        else {
            print(str, a, b);
        }
    }
        
    return 0;
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

int main(){
  int N;
  cin >> N;
  set<string> S;
  rep(i,N){
    string buffer;
    cin >> buffer;
    S.insert(buffer);
  }
  cout << S.size();


  return 0;
}


Measured memory_bytes: 19224
q, h, s, d = gets.split.map(&:to_i)
n = gets.to_i

h = [2 * q, h].min
s = [2 * h, s].min

if n == 1
  puts s
else
  d = [2 * s, d].min
  puts d * (n / 2) + s * (n % 2)
end


Measured memory_bytes: 1788
#include<iostream>
#define MAX_N 1000010
#include<vector>
using namespace std;
int prime[MAX_N];
bool is_prime[MAX_N+1];
void prime_make(int n){
	int p=0;
	for(int i=0;i<=n;i++)
	is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(int j=i*2;j<=n;j+=i)
			is_prime[j]=false;
		}
	}
}
int main(){
	prime_make(MAX_N);
	int A,B;
	while(cin>>A>>B,A||B){
		vector<int> a,b;
		for(int i=0;prime[i]<=A;i++)
		if(A%prime[i]==0)
		a.push_back(prime[i]);
		for(int i=0;prime[i]<=B;i++)
		if(B%prime[i]==0)
		b.push_back(prime[i]);
		int aans=a[a.size()-1],bans=b[b.size()-1];
		for(int i=0;i<a.size()-1;i++)
		aans-=a[i];
		
		for(int i=0;i<b.size()-1;i++)
		bans-=b[i];
		
		//cout<<aans<<' '<<bans<<endl;
		cout<<(aans>bans?'a':'b')<<endl;
		
		
		
	}
	return 0;
}

Measured memory_bytes: 2180
n = int(input())
l = [int(x) for x in input().split()]

ans = 0
import heapq
heapq.heapify(l)
while(len(l)>1):
    a = heapq.heappop(l)
    b = heapq.heappop(l)
    c = (a+b)/2
    heapq.heappush(l,c)

print(l[0])

Measured memory_bytes: 3064
S =list(input())
A,B,C,D = map(int,S)
a = str(A)
b = str(B)
c = str(C)
d = str(D)

for i in range(2):
    for j in range(2):
        for k in range(2):
            if i == 0 and j ==0 and k ==0:
                if A + B + C + D ==7:
                    print(a+"+"+b+"+"+c+"+"+d+"=7")
                    exit()
            elif i == 0 and j ==0 and k ==1:
                if A + B + C - D ==7:
                    print(a + "+" + b + "+" + c + "-" + d + "=7")
                    exit()
            elif i == 0 and j ==1 and k ==0:
                if A + B - C + D ==7:
                    print(a + "+" + b + "-" + c + "+" + d + "=7")
                    exit()
            elif i == 0 and j  ==1 and k ==1:
                if A+B-C-D ==7:
                    print(a + "+" + b + "-" + c + "-" + d + "=7")
                    exit()
            elif i == 1 and j == 0 and k == 0:
                if A-B+C+D ==7:
                    print(a + "-" + b + "+" + c + "+" + d + "=7")
                    exit()
            elif i == 1 and j == 0 and k == 1:
                if A-B+C-D ==7:
                    print(a + "-" + b + "+" + c + "-" + d + "=7")
                    exit()
            elif i == 1 and j == 1 and k ==0:
                if A-B-C+D ==7:
                    print(a + "-" + b + "-" + c + "+" + d + "=7")
                    exit()
            elif i == 1 and j == 1 and k ==1:
                if A-B-C-D==7:
                    print(a + "-" + b + "-" + c + "-" + d + "=7")
                    exit()
                    
    

Measured memory_bytes: 3064
<?php
  	fscanf(STDIN,"%d %d",$n,$k);
	$d_li = array();
	$okashi = array();
	for($i=0;$i<$k;$i++){
      $d_li[] = trim(fgets(STDIN));
      $okashi = array_merge(explode(" ",trim(fgets(STDIN))),$okashi);
    }


$okashi = array_unique($okashi);

$cou=0;
for($i=1;$i<=$n;$i++){
  if(!in_array($i,$okashi)){
    $cou++;
  }
     }
     
     echo $cou."\n";

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  string s;
  cin >> s;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == s[i - 1]) {
      cout << i << ' ' << i + 1 << '\n';
      return;
    }
    if (i > 1 && s[i] == s[i - 2]) {
      cout << i - 1 << ' ' << i + 1 << '\n';
      return;
    }
  }
  cout << -1 << ' ' << -1 << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3752
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN int(1e5)
typedef long long ll;
int n;
ll rod;
struct Sushi{ll pos,val;}poi[MAXN+5];
ll a[MAXN+5],b[MAXN+5];
int main()
{
	scanf("%d%lld",&n,&rod);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&poi[i].pos,&poi[i].val);
	poi[n+1].pos=rod;poi[n+1].val=0;
	for(int i=1;i<=n;i++)
		a[i]=a[i-1]-(poi[i].pos-poi[i-1].pos)+poi[i].val;
	for(int i=n;i>=1;i--)
		b[i]=b[i+1]-(poi[i+1].pos-poi[i].pos)+poi[i].val;
	for(int i=2;i<=n;i++)
		a[i]=max(a[i],a[i-1]);
	for(int i=n-1;i>=1;i--)
		b[i]=max(b[i],b[i+1]);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,max(a[i],b[i]));
		ans=max(ans,max(a[i]-poi[i].pos+b[i+1],b[i]-(rod-poi[i].pos)+a[i-1]));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int a;
    cin>>a;
    while(a!=0)
    {
        if(a%10==9)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        a/=10;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
   int i,n,even=0,odd=0;
   scanf("%d",&n);
   for(i=1; i<=n; i++){
       if(i%2==0){
           even++;
       }
       else odd++;
   }
   printf("%d",even*odd);

    return 0;
}

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

#define MAX 200003
#define MOD 1000000007

typedef int FLOW;
vector<int> level;
#define INF 1000
#define V_MAX 300

struct Edge{
  int rev,from,to;
  FLOW cap,icap;
  Edge(int f,int t,FLOW c){
    from=f;
    to=t;
    cap=c;
    icap=c;
  }
};

struct Graph{
  int V;
  vector<vector<Edge>> list;
  Graph(int n){
    V=n;
    list.resize(V,vector<Edge>(V,Edge(0,0,-1)));
  }
  int size(){
    return V;
  }
  void push_back(int f,int t,FLOW c){
    list.at(f).at(t)=Edge(f,t,c);
    list.at(t).at(f)=Edge(t,f,0);
  }
  Edge& redge(Edge e){
    return list.at(e.to).at(e.from);
  }
};


void dibfs(Graph &G,int s){
  int N=G.size();
  for(int i=0;i<N;i++){
    level.at(i)=-1;
  }
  level.at(s)=0;
  queue<int> q;
  q.push(s);
  while(!q.empty()){
    int v=q.front();
    for(auto e:G.list.at(v)){
      if(level.at(e.to)<0&&e.cap>0){
        level.at(e.to)=level.at(v)+1;
        q.push(e.to);
      }
    }
    q.pop();
  }
}

FLOW didfs(Graph &G,int v,int t,FLOW f){
  if(v==t){
    return f;
  }
  for(auto &e:G.list.at(v)){
    Edge &re=G.redge(e);
    if(level[v]<level[e.to]&&e.cap>0){
      FLOW d=didfs(G,e.to,t,min(f,e.cap));
      if(d>0){
        e.cap-=d;
        re.cap+=d;
        return d;
      }
    }
  }
  return 0;
}

FLOW Dinic(Graph &G,int s,int t){
  level.resize(G.size());
  FLOW res=0;
  while(true){
    dibfs(G,s);
    if(level.at(t)==-1){
      return res;
    }
    FLOW flow;
    while((flow=didfs(G,s,t,INF))>0){
      res+=flow;
    }
  }
}

int main(){
  int N;
  cin>>N;
  vector<int> a(N),b(N),c(N),d(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i)>>b.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>c.at(i)>>d.at(i);
  }

  Graph G(2*N+2);
  int S=2*N;
  int T=2*N+1;
  for(int i=0;i<N;i++){
    G.push_back(S,i,1);
    G.push_back(i+N,T,1);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(a.at(i)<c.at(j)&&b.at(i)<d.at(j)){
        G.push_back(i,N+j,1);
      }
    }
  }

  cout<<Dinic(G,S,T)<<endl;
}


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

using namespace std;

bool isKaibun(string str)
{
  const int len = str.size();
  for (int i = 0; i < str.size()/2; i++) {
  	if (str[i] != str[len-1-i]) {
      return false;
    }
  }
  return true;
}


int main ()
{
  string str;
  cin >> str;
  auto it = str.begin();
  for (int i = 0; i < str.size()/2; i++) {
  	it++;
  }
  string strhalf(str.begin(), it);

	if (isKaibun(str) && isKaibun(strhalf)) {
      	cout << "Yes" << endl;
    }
  	else {
      	cout << "No" << endl;
    }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

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

    cout << (N-2) * 180 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool isLow(char c) { return 'a' <= c && c <= 'z'; }

int main() {
  string s;
  cin >> s;
  bool available = s[0] == 'A' && isLow(s[1]) && isLow(s[s.size() - 1]);
  int cnt = 0;
  for (int i = 2; i < s.size() - 1; ++i) if (s[i] == 'C') cnt++; else if (!isLow(s[i])) available = 0;
  if (cnt != 1) available = 0;
  puts(available ? "AC" : "WA");
}


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

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var V = ReadLine().Split().Select(int.Parse).ToArray();
        var C = ReadLine().Split().Select(int.Parse).ToArray();

        WriteLine(V.Select((x, i) => x - C[i]).Sum(x => x < 0 ? 0 : x));
    }
}


Measured memory_bytes: 13396
#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 bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
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) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
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 power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

vector<int> edges[10010];

void solve() {
  int n; cin >> n;
  rep(i, n - 1) {
    int a, b; cin >> a >> b;
    a--, b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  vi32 c(n); cin >> c;
  sort(all(c));
  vi32 ans(n);
  int i = 0;
  function<void(int, int)> dfs = [&](int x, int p) {
    for (auto v : edges[x]) {
      if (v == p) continue;
      dfs(v, x);
    }
    ans[x] = i++;
  };
  dfs(0, -1);
  i64 sum = 0;
  function<void(int, int)> dfs2 = [&](int x, int p) {
    for (auto v : edges[x]) {
      if (v == p) continue;
      sum += min(c[ans[x]], c[ans[v]]);
      dfs2(v, x);
    }
  };
  dfs2(0, -1);
  cout << sum << '\n';
  vi32 lst(n);
  rep(i, n) lst[i] = c[ans[i]];
  cout << lst << '\n';
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=2147483647;
const ll inf=1e16;
const ll ms=(100000) +5;

int ar[10];

int main()
{
    int n,m;
    cin>>n>>m;
    int i;
    for(i=0;i<=n;i++)ar[i]=-1;
    while (m--)
    {
        int a,b;
        cin>>a>>b;
        if(ar[a]==-1)
        {
            ar[a]=b;
        }
        else {
            if(ar[a]==b)continue;
            else {
                cout<<-1;
                return 0;
            }
        }
    }
    if(n==1)
    {
        if(ar[1]==-1)cout<<0;
        else cout<<ar[1];
    }
    else{
        if(ar[1]==0){cout<<-1;
            return 0;}
        if(ar[1]==-1)cout<<1;
        else cout<<ar[1];
        for(i=2;i<=n;i++)
        {
            if(ar[i]==-1)cout<<0;
            else cout<<ar[i];
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int cnt[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[100010];
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n) {
        if(a[i] > 100000) ans++;
        else cnt[a[i]]++;
    }
    REP(i, 1, 100000) {
        if(cnt[i] >= i) ans += cnt[i] - i;
        else ans += cnt[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss 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,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
ll expo(ll b,ll n,ll m)
{
 ll r,p;
	p=1;
	 b=b%m;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p)*(b))%m;
		b=((b)*(b))%m; 
		n=n/2;		
	}
 return (p%m);
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
ll a[1000002];
int main(int argc, char const *argv[])
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	ll n,maxx=0,ans=0;
	cin>>n;
	for (int i = 0; i < n; i++)
	{
		cin>>a[i];
		ans += max(0ll, maxx-a[i]);
		maxx = max(maxx, a[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5212
#include<iostream>
#include<string>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  string s;
  cin >> s;

  int ans = 1000;
  rep(i,0,s.size()-3) {
    int p = stoi(s.substr(i,3));
    ans = min(ans, abs(p - 753));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
#import itertools
#import heapq
#from collections import deque
#d = deque()

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    ans=0
    for a in range(1,n):
        #bn=(n-1)//a
        ans+=(n-1)//a
    print(ans)
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16156
//package atcoder.beginner_172;

import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main (String[] args) throws Exception {

        String s = "2";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int a=nin();


        bw.write(Integer.toString(a+a*a+a*a*a));
        bw.newLine();
        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
}

Measured memory_bytes: 32680
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long a, long long b, long long n){
    lint x;
    lint res;
    if(n >= b) x = b-1;
    else x = n;
    lint d1 = a * x / b;
    lint d2 = x / b;
    res = d1 - (a * d2);
    cout << res << "\n";
}

int main(){

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(A, B, N);
    return 0;
}



Measured memory_bytes: 3752
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include <cmath>
#include <random>
#include <functional>
#include <climits>
using namespace std;
using lint=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  cout<<v[n-1]-v[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*; 
 
class Main { 
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
      	//int x = sc.nextInt();
      	//int t = sc.nextInt();
      	PrintWriter out = new PrintWriter(System.out);
        out.println(Math.max(sc.nextInt() - sc.nextInt(), 0));
      	out.flush();
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}

    public int nextInt() {
        if (!hasNext()) throw new NoSuchElementException();
        int n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}


Measured memory_bytes: 21332
//have copied gfg code just 2 check coz my soln similar to this

#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 
  
/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( string X, string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   // Following code is used to print LCS 
   int index = L[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
    cout<<lcs<<endl;
   // Print the lcs 
   // cout << "LCS of " << X << " and " << Y << " is " << lcs; 
} 
  
/* Driver program to test above function */
int main() 
{ 
  // char X[] = "AGGTAB"; 
  // char Y[] = "GXTXAYB"; 
  string X, Y;
  cin>>X>>Y;
  int m = X.length();
  int n = Y.length();
  lcs(X, Y, m, n); 
  return 0; 
} 


Measured memory_bytes: 35456
#include <iostream>
#include <string>

int main() {
  int h, w;
  while (std::cin >> h >> w, h | w) {
    std::string a(w, '#');
    std::string b(w, '.');
    b[0] = b[w - 1] = '#';
    std::cout << a << "\n";
    for (int i = 0; i < h - 2; i++) {
      std::cout << b << "\n";
    }
    std::cout << a << "\n" << std::endl;
  }
}


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

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

using namespace std;

int main() {
    char c;
    cin >> c;
    if(c=='A') {
        cout << 'T';
    } else if(c=='T') {
        cout << 'A';
    } else if(c=='C') {
        cout << 'G';
    } else if(c=='G') {
        cout << 'C';
    }
}


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

#define ll long long

struct UnionFind {
	vector<int> r;

	UnionFind(int N) {
		r = vector<int>(N, -1);
	}
	int root(int x) {
		if (r[x] < 0)return x;
		return r[x] = root(r[x]);
	}

	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y)return false;
		if (r[x] > r[y])swap(x, y);
		r[x] += r[y];
		r[y] = x;
		return true;
	}

	int size(int x) {
		return -r[root(x)];
	}
};


int main() {
	int n, m;
	int a, b;
	int i, j;
	int index = 0;
	int ans = 0;
	cin >> n >> m;
	
	UnionFind UF(n);
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		a--;	b--;
		UF.unite(a, b);
	}


	for (i = 0; i < n; i++) {
		ans = max(ans, UF.size(i));
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main(){
	int waseda[10];
	int keo[10];
	for(int i = 0; i < 10; i++){
		cin >> waseda[i];
	}
	for(int i = 0; i < 10; i++){
		cin >> keo[i];
	}
	sort(waseda,waseda+10,greater<int>());
	sort(keo,keo+10,greater<int>());

	int sumW=0;
	int sumK=0;
	for(int i = 0; i < 3; i++){
		sumW += waseda[i];
		sumK += keo[i];
	}
	cout << sumW << " " << sumK << endl;

	return 0;
}

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

using namespace std;

int main() {
  int n; cin >> n;
  vector<long long> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  long long maxscore = 0;
  for (int c = 1; c <= n-1; ++c) {
    // k=0 =>  0 -> n-1
    // k=1 =>  0 -> n-1-c  -> c -> n-1
    // k=2 =>  0 -> n-1-2c -> c -> n-1-c -> 2c -> n-1
    long long score = 0;
    for (int k = 1; c*k < n-1; ++k) {
      //    n-1-c*k == c*s
      // or n-1-c*s == c*k
      int l = n-1-c*k, r = c*k;
      if (l % c == 0 && l/c <= k) break;
      if ((n-1-r) % c == 0 && (n-1-r)/c <= k) break;
      if (l <= c) break;
      score += s[l] + s[r];
      maxscore = max(maxscore, score);
    }
  }
  cout << maxscore << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

void fibonacchi(int n)
{
    int Fib[50];
    int i;
    Fib[0] = 1;
    Fib[1] = 1;
    for (i = 2; i <= n; ++i) {
        Fib[i] = Fib[i-1] + Fib[i-2];
    }
    printf("%d\n",Fib[n]);
}
int main() {

    int n;

    scanf("%d", &n);

    fibonacchi(n);

    return 0;
}


Measured memory_bytes: 1968
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);

    ll n,u;
    cin >> n >> u;
    vector<int> t(n);
    rep(i,n) cin >> t[i];
    ll ol=0;
    rep(i,n-1) {
        ol+=(t[i+1]-t[i]<u)?(u-(t[i+1]-t[i])):0;
    }
    ll ans=n*u-ol;
    cout << ans << endl;

    return 0;   
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
d = {}
x = 0
for i in range(N):
  x += A[i]
  d[x] = d.get(x, 0) + 1
ans = d.get(0, 0)
for x in d.values():
  ans += x * (x-1) // 2
print(ans)

Measured memory_bytes: 117664
#include <cstdio>

typedef long long ll;

inline ll abs(ll x){ return x>0?x:-x; }

const int N=1e3+5;

char s[45]; int n,m; ll x[N],y[N],c[45];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%lld%lld",&x[i],&y[i]);
	int op=abs(x[1]+y[1])&1;
	for(int i=2;i<=n;++i){
		if((abs(x[i]+y[i])&1)!=op){ puts("-1"); return 0; }
	}
	if(op){
		printf("%d\n",31);
		for(int i=0;i<=30;++i) printf("%lld ",c[++m]=1<<i);
		printf("\n");
	}
	else{
		printf("%d\n",32);
		printf("%lld ",c[++m]=1);
		for(int i=0;i<=30;++i) printf("%lld ",c[++m]=1<<i);
		printf("\n");
	}
	for(int i=1;i<=n;++i){
		ll nx=0,ny=0;
		for(int j=m;j;--j){
			ll dx=x[i]-nx,dy=y[i]-ny;
			if(abs(dx)>abs(dy)){
				if(dx>0) s[j]='R',nx+=c[j];
				else s[j]='L',nx-=c[j];
			}
			else{
				if(dy>0) s[j]='U',ny+=c[j];
				else s[j]='D',ny-=c[j];
			}
		}
		printf("%s\n",s+1);
	}
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC095
{
    class Program
    {
        static void Main(string[] args)
        {
            string indata = Console.ReadLine();
            int price = 700;
            if (indata.Substring(0,1) == "o") price += 100;
            if (indata.Substring(1, 1) == "o") price += 100;
            if (indata.Substring(2, 1) == "o") price += 100;
            Console.WriteLine(price);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<list>
using namespace std;
using ll = long long;
int main() {
	int N; cin >> N;
	string S; cin >> S;
	int A[300005];//iまでにあるWの個数
	int B[300005];//iまでにあるEの個数
	for (int i = 0; i < N; ++i) {
		A[i] = 0;
	}
	if (S[0] == 'W')
		A[0]++;
	for (int i = 1; i < N; ++i) {
		if (S[i] == 'W')
			A[i] = A[i - 1] + 1;
		else
			A[i] = A[i - 1];
	}
	for (int i = 0; i < N; ++i) {
		B[i] = i + 1 - A[i];
	}
	int ans = 1e9;
	
	for (int i = 0; i < N; ++i) {
		int sum = 0;
		if (i == 0)
			sum = B[N - 1] - B[0];
		else {
			sum += A[i - 1] + B[N - 1] - B[i];
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <regex>
#include <locale>
using namespace std;

#include <iomanip>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(x) (x).begin(),(x).end()

using ll = long long;

int main () {
  int a, b;
  cin >> a;
  
  cout << setw(3) << setfill('0') << "ABC" << a << endl;
}

Measured memory_bytes: 3144
N = int(input())
l = {}
for i in range(N):
    s = input()
    Si , p = s.split(' ')
    if not Si in l:
         l[Si] = []
    l[Si].append((int(p),i))
l = sorted(l.items())
for i in l:
    #print(i)
    x = dict(i[1])
    #print(x)
    x = sorted(x.items(),key=lambda y: -y[0])
    for k in x:
        print(k[1]+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll h;cin >> h;
    ll num = 0;
    while(h>0){
        h = h/2;
        num++;
    }
    ll ans = 2*(pow(2,num-1)-1) + 1;
    cout << ans << endl;
}

Measured memory_bytes: 4060
from math import cos,sqrt,radians
a,b,h,m = [int(i) for i in input().split()]
br = 6*m
ar = 30*h + m/2
th = abs(ar-br)
th = radians(min(th,360-th))
ansj = a**2 + b**2 - 2*a*b*cos(th)
print(sqrt(ansj))

Measured memory_bytes: 9512
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#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,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------


int main()
{
	boost
	ll h,w,n;
	cin>>h>>w>>n;
	ll x,y;
	cin>>x>>y;
	string s,t;
	cin>>s>>t;
	ll curR=y,curL=y,curU=x,curD=x,maxR=y,maxL=y,maxU=x,maxD=x;
	for(ll i=0;i<n;i++)
	{
		if(s[i]=='L')
		{
			curL=curL-1;
			maxL=min(maxL,curL);
		}
		else if(s[i]=='R')
		{
			curR=curR+1;
			maxR=max(maxR,curR);
		}
		else if(s[i]=='U')
		{
			curU=curU-1;
			maxU=min(maxU,curU);
		}
		else if(s[i]=='D')
		{
			curD=curD+1;
			maxD=max(maxD,curD);
		}
		if(t[i]=='L')
		{
			curR=max(1LL,curR-1);
		}
		else if(t[i]=='R')
		{
			curL=min(w,curL+1);
		}
		else if(t[i]=='U')
		{
			curD=max(1LL,curD-1);
		}
		else if(t[i]=='D')
		{
			curU=min(h,curU+1);
		}
	}
	if(maxU<=0||maxD>h||maxL<=0||maxR>w)
	{
		cout<<"NO"<<endl;
	}
	else
		cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 920
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>

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

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    vector<int> a(n);
    rep(i, n)
    {
        if (s[i] == 'R')
            a[i] = 0;
        if (s[i] == 'G')
            a[i] = 1;
        if (s[i] == 'B')
            a[i] = 2;
    }
    long long ans = 1;
    vector<int> cnt(3);
    rep(i, n) cnt[a[i]]++;
    rep(i, 3) ans *= cnt[i];
    rep(j, n) rep(i, j)
    {
        int k = j + (j - i);
        if (k < n)
        {
            if (a[i] == a[j])
                continue;
            if (a[j] == a[k])
                continue;
            if (a[k] == a[i])
                continue;
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
/*#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
*/

#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr<<#x<<": "<<(x)<<'\n'
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
const ll inf = 0x3f3f3f3f;
const ll nax = 0;
map<ll, ll>cnt;
ll n, m;

int main(){
	IOS
	cin >> n;
	for(int i=0;i<n;++i){
		ll x; cin >> x;
		++cnt[x];
	}
	cin >> m;
	for(int i=0;i<m;++i){
		ll x; cin >> x;
		if(cnt[x]>0){
			cnt[x]--;
		}
		else{
			cout << "NO" << '\n';
			return 0;
  		}
	}
	cout << "YES" << '\n';
}


Measured memory_bytes: 16160
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+4;
const int M=1e5+4;
int n,m;
bool vis[N];
int t[N];
int ans,pen;
int main() {
	scanf("%d%d",&n,&m);
	for (register int i=0;i<m;++i) {
		int id;
		char ss[2];
		scanf("%d%s",&id,ss);
		if (ss[0]^'W') {
			if (!vis[id]) {
				vis[id]=true;
				++ans;
			}
		} else {
			if (!vis[id])
				++t[id];
		}
	}
	for (register int i=1;i<=n;++i)
		if (vis[i])
			pen+=t[i];
	printf("%d %d\n",ans,pen);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	ll tab=2+(n%2);
	vl v(n);
	rep(i,n)cin>>v[i];
	vvl dp(n+2,vl(tab,-LINF));
	dp[0][0]=0;
	rep(i,n){
		rep(j,tab){
			rep(k,j+1){
				if((i-(j-k))<0)continue;
				chmax(dp[i+2][j],dp[i-(j-k)][k]+v[i]);
			}
		}
	}

	ll ans=-LINF;
	rep(i,tab){
		chmax(ans,dp[n+i-(n%2)][i]);
	}
	puta(ans);
}


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

#define testcases int t; cin>>t; while(t--)
#define int long long
const int MOD =  1e9 + 7;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

int n;
const int N = 22;
int mat[N][N];

int dp[N][(1 << 22)];

int solve(int row, int avail)
{
	if (row == n)
	{
		return avail == 0;
	}

	int & ans = dp[row][avail];
	if (ans != -1) return ans;

	ans = 0;

	for (int c = 0; c < n; c++)
	{
		if (mat[row][c] && (avail & (1 << c)))
		{
			int mask = ~(1 << c);
			ans += solve(row + 1, avail & mask);
			ans %= MOD;
		}
	}

	return ans;

}


int32_t main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	FASTIO;

	cin >> n;

	for (int i  = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++) {

			cin >> mat[i][j];
		}
	}

	memset(dp, -1, sizeof dp);

	int ans = solve(0, (1 << n) - 1);
	cout << ans;

}

Measured memory_bytes: 724388
#include <bits/stdc++.h>
#define PB push_back
#define ST first
#define ND second
#define _ ios_base::sync_with_stdio(0); cin.tie(0);
//mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

using namespace std;

using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;

int x[5];

int main() {
	int id = -1;
	for(int i = 0; i < 5; ++i) {
		cin >> x[i];
		if(x[i] == 0) id = i+1;
	}
	cout << id;
	
}


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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define ll long long int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
#define pa pair<ll,ll>
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1e9+7 ;
const ll N = 1e7+5;
int main()
{
    FAST

    ll tc,i,j,k;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
       ll n,k;
       cin>>k;
       if(k%2==0 || k%5==0)
        {
            cout<<-1;
            return 0;
        }
       if(k%7==0)
        k/=7;
       ll   val=1;
       ll cnt=1;
       while(val<k)
       {
           val=10*val+1;
           cnt++;
       }
       while(val%k!=0)
       {
           val=val%k;
           while(val<k)
           {
               val=10*val+1;
           cnt++;
           }
       }
       cout<<cnt<<"\n";


    }
    return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>

using namespace std;

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		(1000000)
#define Rep(i,n) for(int i = 0; i < (n); i++ )

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define	show(x)	 copy( (x).begin(), (x).end(), ostream_iterator<int>(cout, ",") );	// container<int>を全て表示

using namespace std;

typedef long long ll;

//constant
//--------------------------------------------
const double EPS = 1e-10;
//const double PI  = acos(-1.0);

ll kaijo( ll N )
{
	// 階乗
	if( N == 0 ) return 1;
	return N * kaijo(N - 1);
}

map<ll, ll> prime_factor(ll N)
{
	// 素因数分解
	map<ll, ll> ret;
	for( ll i = 2; i * i <= N; i++ ){
		while( N % i == 0 ){
			ret[i]++;
			N /= i;
		}
	}
	if(N != 1) ret[N] = 1;
	return ret;
}

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

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

ll max( ll a, ll b )
{
	if( a > b ) return a;
	return b;
}
ll min( ll a, ll b )
{
	if( a > b ) return b;
	return a;
}

class UnionFind
{
public:
	vector<int> parent;
	vector<int> rank;

	UnionFind(int n)
	{
		Rep(i, n){
			parent.push_back(i);
			rank.push_back(1);
		}
	}
	int root(int x)
	{
		if( parent[x] != x ) parent[x] = root(parent[x]);
		return parent[x];
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if( rx == ry ) return;
		if( rank[rx] > rank[ry] ){
			parent[ry] = rx;
			rank[rx] += rank[ry];
		}
		if( rank[rx] <= rank[ry] ){
			parent[rx] = ry;
			rank[ry] += rank[rx];
		}
	}
};

int main()
{
	ll A = 0;
	ll B = 0;

	cin >> A >> B;
	cout << (A - 1) * (B - 1) << endl;

	cin >> A;

	return 0;
}


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


def main():
    n = int(input())
    grid = [[True for _ in range(n)] for _ in range(n)]

    if n % 2 == 0:
        for i in range(n):
            grid[i][n - i - 1] = False
    else:
        for i in range(n):
            grid[i][n - i - 2] = False

    ans = list()

    for i in range(n):
        for j in range(i, n):
            if i != j and grid[i][j]:
                ans.append((i, j))

    print(len(ans))

    for ai, bi in ans:
        print(ai + 1, bi + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3996
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    ll a[n][n];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    vector<ll> gr(1<<n, 0);
    for(int i = 0; i < 1<<n; i++){
        for(int j = 0; j < n; j++){
            if(((i>>j)&1) == 0)   continue;
            for(int k = j+1; k < n; k++){
                if(((i>>k)&1)==0)    continue;
                gr[i] += a[j][k];
            }
        }
    }
    vector<ll> dp(1<<n, 0);
    for(int i = 1; i < 1<<n; i++){
        int sub = i;
        do{
            dp[i] = max(dp[i], dp[i-sub]+gr[sub]);
            sub = (sub-1)&i;
        }while(sub != i);   // sub=-1のときsub&i==i
    }
    cout << dp.back() << endl;
    return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
  int n, i, j;
  cin >> n;
  vi a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll ans = a[0] - 1;
  ll now = 1;
  for (i = 1; i < n; i++) {
    if (a[i] == now + 1) {
      now++;
      continue;
    }
    else if (a[i] <= now) {
      continue;
    }
    else {
      ans += (a[i] - 1) / (now + 1);
    }
  }
  cout << ans << endl;
  return 0;
}
  
/*
3
3
2
5

15
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9

*/


Measured memory_bytes: 640