akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n, q;
    cin >> n >> q;
    ll a[n];
    rep (i, n) cin >> a[i];
    rep (k, q) {
        ll x;
        cin >> x;
        ll ans = 0;
        int right = 0;
        ll sum = 0;
        rep (left, n) {
            while (right < n && sum + a[right] <= x) {
                sum += a[right];
                right++;
            }
            ans += right - left;
            if (left == right) right++;
            else
                sum -= a[left];
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3880
//#include "pch.h"
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b/a, c) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

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

  cout<<max(0,c-(a-b))<<endl;
}

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

int main(void){
  
  int a, b;
  cin >> a >> b;
  
  int total = a + b;
  int ans = total / 2;
  int hantei = total % 2;
  
  if(hantei == 1){
    
    cout << ans + 1 << endl;
    
  }else{
    
    cout << ans << endl;
    
    }
  
  return 0;
  
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M;
  cin>>N>>M;
  vector<int>tokuhyou(N);
  int soutokuhyou=0;
  for(int i=0;i<N;i++){
    cin>>tokuhyou.at(i);
    soutokuhyou+=tokuhyou.at(i);
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(tokuhyou.at(i)*4*M<soutokuhyou){
      count+=0;
    }
    else{
      count+=1;
    }
  }
  if(count>=M){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

 

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000;

signed main() {
  int H, N;
  cin >> H >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i) >> B.at(i);
  
  vector<int> dp(H+10, INF);
  dp.at(0) = 0;
  for( int i = 1; i <= H; i++ ){
    for( int j = 0; j < N; j++ ){
      dp[i] = min( dp[i], B.at(j)+dp[max(i-A.at(j), 0LL)] );
    }
  }
  cout << dp[H] << endl;
}


Measured memory_bytes: 384
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

// ------ Class ------ //
class Graph1 {
public:
	// ------Basics ------ //
	static const int INF = 2147483647;
	int V, E; vector<vector<int> > G;
	Graph1() : V(0), E(0), G(vector<vector<int> >()) {}
	Graph1(int v) : V(v), E(0), G(vector<vector<int> >(v)) {}
	Graph1(vector<vector<int> > g) : V(g.size()), G(g) { for (int i = 0; i < g.size(); i++) E += g[i].size(); }
	int size() { return V; }
	void add1(int v1, int v2) { G[v1].push_back(v2); E++; }
	void add2(int v1, int v2) { add1(v1, v2); add1(v2, v1); }
	friend bool operator==(const Graph1& g1, const Graph1& g2) { return g1.G == g2.G; }
	friend bool operator!=(const Graph1& g1, const Graph1& g2) { return g1.G != g2.G; }
	vector<int> operator[](int x) { return G[x]; }

	// ------ Algorithms ------ //
	vector<int> tsort() {
		int n = G.size();
		vector<int> ret, vis(n);
		function<bool(int)> dfs = [&](int v) {
			vis[v] = true;
			for (auto &e : G[v]) if (!vis[e] && !dfs(e)) return false;
			ret.push_back(v);
			return true;
		};
		for (int i = 0; i < n; i++) if (!vis[i] && !dfs(i)) return{};
		reverse(ret.begin(), ret.end());
		return ret;
	}
};

// ------ Main ------ //
int n, m, a, b;
int main() {
	cin >> n >> m;
	Graph1 G(n);
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		G.add1(a - 1, b - 1);
	}
	vector<int> v = G.tsort();
	for (int i = 0; i < n; i++) cout << v[i] + 1 << endl;
	return 0;
}

Measured memory_bytes: 3164
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int k;
    cin >> k;
    vl a(k);
    for (int i = 0; i < k; ++i) {
        cin >> a[i];
    }
    ll mini = 2;
    ll maxi = 2;
    for (int i = k - 1; i >= 0; --i) {
        ll nmin = (mini + (a[i] - 1)) / a[i] * a[i];
        ll nmax = maxi / a[i] * a[i];
        if (nmin > nmax) {
            cout << -1 << "\n";
            return 0;
        }
        mini = nmin;
        maxi = nmax + a[i] - 1;
    }
    cout << mini << " " << maxi << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

int main(void) {
  int a, b;
  cin >> a >> b;

  cout << (a-1)*(b-1) << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
S = list(s)
f = False
k = 1
flag = False
while len(S) > 2:
    if k == len(S) - 1:
        if flag:
            k = 1
            flag = False
            continue
        break
    if S[k - 1] != S[k + 1]:
        S.pop(k)
        f = not f
        flag = True
    else:
        k += 1
if f:
    print('First')
else:
    print('Second')


Measured memory_bytes: 4084
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;

#define MAX_N 10000
#define M (1000000000 + 7)

int a[MAX_N];

int main() {

  // -----------------------------
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  // input
  int N, K;
  cin >> N >> K;

  int H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  
  // -----------------------------

  sort(H, H + N, greater<>());

  ll cnt = 0;
  for (int i = 0; i < N; i++) {
    if (K > 0) K--;
    else cnt += H[i];
  }

  cout << cnt << endl;
  
  return 0;
  
}


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

const int N = 1e5 + 100;


#define mp make_pair
#define f first
#define s second

#define pb push_back

void boost()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int n,m;

vector<int>g[N];

bool was[N];

int d[N];

vector<int>ord;
int ans;

void dfs(int v)
{
 	was[v] = 1;
 	for (int to :g[v])
 	{
 		if (!was[to])
 		{
 			dfs(to);
 		}
 	}
 	ord.pb(v);
}
                                                                                                          
void dfs1(int v)
{
 	was[v] = 1;
 	for (int to :g[v])
 	{
 		if (!was[to])
 		{
 			dfs1(to);
 		}                               
 		d[v] = max(d[v],d[to] + 1);
 		ans = max(ans,d[v]);
 	}                          
}


int main(){
	boost();
	cin >> n >> m;
	for (int i = 1;i <= m;++i)
	{
		int u,v;
		cin >> u >> v;
		g[u].pb(v);
	}
	for (int i = 1;i <= n;++i)
	{
		if (!was[i])
		{             
			dfs(i);
		}
	}
	for (int i = 1;i <= n;++i)
	{
		was[i] = 0;
	}
	for (int i = 0;i < n;++i)
	{                        
		dfs1(ord[i]);            
	}
	cout << ans;       
}

Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 200000
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int a,b,c;
    cin>>a>>b>>c;
    OUT(max(0,b+c-a));
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int> Pi;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()

void solve(){
	int N; scanf("%d", &N);
	for(int i=1;;i++){
		if((i+1) * i / 2 >= N){
			vector <int> ans;
			for(int j=i;j;j--){
				if(j*(j-1)/2 < N)ans.pb(j), N -= j;
			}
			reverse(all(ans));
			for(auto e : ans)printf("%d\n", e);
			return;
		}
	}
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){

    int A,B;
    int x=0;
scanf("%d%d",&A,&B);
    if(A>=0&&B<=24){
        x=A+B;
       if(x>=24){
           x=x%24;
       }
       printf("%d",x);
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<Int> A(N); for (auto &a : A) cin >> a;
    Int ans = 1;
    for (auto a : A) if (a == 0) {
        cout << 0 << '\n';
        return 0;
    }
    for (auto a : A) {
        if (__builtin_mul_overflow(ans, a, &ans)) {
            ans = -1;
            break;
        }
    }
    if (ans > 1000000000000000000) ans = -1;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3992
t[99],h[99],f;
main(i,s,N,T,L){
for(scanf("%d%d%d%d",&N,&T,&L,&L),i=0;i<N;i++)scanf("%d%d",t+i,h+i);
for(i=s=0;!f;i=(i+1)%N)if(t[i]){
    t[i]--;
    if(++T>L)break;
    if(++s==9)s=0;
}else if(h[i]){
    h[i]--;s++;
    if(T<s)break;
    t[i]=s;T-=s;s=0;
}else break;
printf("%d\n",i+1);exit(0);}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int N, A, B;
vector<int> H;
bool f(long long n) {
	long long s = 0;
	for (auto x : H) {
		auto h = x - B*n;
		if (h > 0) {
			s += (h-1) / (A-B) + 1;
			if (s > n) return false;
		}
	}
	return true;
}
int main() {
	cin >> N >> A >> B;
	H = vector<int> (N);
	for (auto& x : H) cin >> x;

	int l = 0, r = 1<<30;
	while (r - l > 1) {
		int m = (r+l) / 2;
		if (f(m)) {
			r = m;
		} else {
			l = m;
		}
	}
	cout << r << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main() {
  char s[4];
  scanf("%s", s);
  int a = 0, b = 0;
  for (int i = 0; i < 2; i++) {
    a = a*10;
    a += (s[i] - '0');
  }
  for (int i = 0; i < 2; i++) {
    b = b*10;
    b += (s[2+i] - '0');
  }
  if (0 < a && a < 13) {
    if (0 < b && b < 13) {
      printf("%s\n", "AMBIGUOUS");
    }else{
      printf("%s\n", "MMYY");
    }
  }else{
    if (0 < b && b < 13) {
      printf("%s\n", "YYMM");
    }else{
      printf("%s\n", "NA");
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int64_t A,B,K;
  cin>>A>>B>>K;
  if(A>K){cout<<A-K<<" "<<B<<endl;}
  else{if(A+B>K){cout<<0<<" "<<A+B-K<<endl;}else{cout<<0<<" "<<0<<endl;}}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F(i,a,b,c) for(register int i=(a);(b);i=(c))
#define Fu(i,a,b) F(i,(a),i<=(b),i+1)
#define Fd(i,a,b) F(i,(a),i>=(b),i-1)
#define inf 1073741823
#define LL long long
int Fl,ch;template<typename t>int in(t&a){a=0;ch=getchar();Fl=1;while(((ch<'0')||(ch>'9'))&&ch!=EOF)Fl=(ch=='-')?-Fl:Fl,ch=getchar();if(ch==EOF)return 0;while((ch>='0')&&(ch<='9'))a=a*10+ch-'0',ch=getchar();a*=Fl;return 1;}template<typename t,typename ...ARGS>int in(t&a,ARGS&...args){return in(a)+in(args...);}
using namespace std;
LL ans;char c;int n,l,a[200010],b[256];
int main()
{
	c=getchar(); 
	while(!isalpha(c))c=getchar();
	while(isalpha(c))
	{
		++l;
		if(!b[c])a[++n]=c;
		++b[c];
        c=getchar();
	}
	ans=(LL)l*(l-1)/2;
	Fu(i,'a','z')
	ans-=(LL)b[i]*(b[i]-1)/2;
	cout<<ans+1;
	return 0;
}
//BY 线段树蒟蒻



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forab(i, a, b) for(int i=(int)a; i<=(int)b; ++i)
#define fornd(i, n) for(int i=n; i>=0; --i)

const int inf = (int)1e6+5;
const int nax = (int)3e5+5;

void compute(){
    int a, b, t; cin >> a>>b >> t;
    cout << floor((t+0.5)*1.0/(a*1.0))*b << "\n";
}
void compute2(){
    int n;
    cin >> n;
    vi v(n), c(n);
    forn(i, n){
        cin >> v[i];
    }
    forn(i, n){
        cin >> c[i];
        c[i] = v[i]-c[i];
    }
    int res = 0;
    forn(i, n){
        if(c[i] + res > res)
            res += c[i];
    }
    cout << res << "\n";
}
void compute3(){
    int n; cin >> n;
    vi v(n);
    forn(i, n){
        cin >> v[i];
    }
    int k = 0;
}

void compute4(){
    int n; cin >> n;
    vi v(n);
    vii absd(n);
    int pos = 0;
    forn(i, n){
        cin >> v[i];
        absd[i].first = (v[i] < 0) ? v[i]*(-1) : v[i];
        absd[i].second = i;
        if(v[i] > 0) ++pos;
    }
    sort(all(absd));
    ll res = 0;
    map<int, int> mp;
    forn(i, pos){
        res += absd[i].first;
        mp.insert(mkp(absd[i].second, i));
    }
    forn(i, n){
        auto it = mp.find(i);
        if(it == mp.end())
            res += v[i];
    }
    cout << res << "\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //    int t;
    //    cin>>t;
    //    while(t--)
    compute();
    return 0;
}


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

int main(void){
    ll n;
    cin >> n;
    ll r = sqrt(n);
    ll res = n;
    rep1(i,r){
        if (n%i==0) {
            res = min(res, n/i + i - 2);
        }
    }
    cout << res << endl;
    return 0;
}


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

int main(){
 int x, y;
cin >> x >> y;
int ans = 0;
for(int i= 0;i<=x;i++) {
    if(2*i + 4*(x-i)==y) ans++;
 }
 if(ans>0)cout << "Yes" << endl;
 else cout  << "No" << endl;
 return 0;
}

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

vector<vector<bool>> memo;
vector<vector<bool>> isVisit;

bool isOK(int curr_sum, int index, const vector<int>& source, int target_sum) {
    if (index == source.size()) {
        return curr_sum == target_sum;
    }

    if (isVisit[curr_sum + 8000][index]) {
        return memo[curr_sum + 8000][index];
    }
    isVisit[curr_sum + 8000][index] = true;

    return memo[curr_sum + 8000][index] = (isOK(curr_sum + source[index], index + 1, source, target_sum) || isOK(curr_sum - source[index], index + 1, source, target_sum));
}

int main() {
    string s;
    int x, y;
    cin >> s >> x >> y;
    vector<int> command;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'F') {
            //Fが何個続くか確認
            int j;
            for (j = i + 1; j < s.size(); j++) {
                if (s[j] != 'F') {
                    break;
                }
            }
            //Fの数を格納
            command.push_back(j - i);
            i = j - 1;
        } else if (s[i] == 'T') {
            //Tが何個続くか確認
            int j;
            for (j = i + 1; j < s.size(); j++) {
                if (s[j] != 'T') {
                    break;
                }
            }
            //Tが偶数回続いたか奇数回続いたかを格納
            if ((j - i) % 2 == 0) {
                //偶数回続く
                command.push_back(-2);
            } else {
                command.push_back(-1);
            }
            i = j - 1;
        }
    }

    //for (int i = 0; i < command.size(); i++) {
    //    printf("%d\n", command[i]);
    //}

    vector<int> to_pmx, to_pmy;
    int flag = 0;
    int start_x = 0, start_index = 0;
    if (command[0] > 0) {
        start_x = command[0];
        start_index = 1;
    }
    for (int i = start_index; i < command.size(); i++) {
        if (command[i] == -1) {
            flag = (flag == 0 ? 1 : 0);
        } else if (command[i] == -2) {
            //なにもしなくていい
        } else {
            if (flag == 0) {
                to_pmx.push_back(command[i]);
            } else {
                to_pmy.push_back(command[i]);
            }
        }
    }
    //printf("to_pmx\n");
    //for (int i = 0; i < to_pmx.size(); i++) {
    //    printf("%d\n", to_pmx[i]);
    //}
    //printf("to_pmy\n");
    //for (int i = 0; i < to_pmy.size(); i++) {
    //    printf("%d\n", to_pmy[i]);
    //}
    constexpr int size = 8000 * 3;
    isVisit = vector<vector<bool>>(size, vector<bool>(to_pmx.size(), false));
    memo = vector<vector<bool>>(size, vector<bool>(to_pmx.size(), false));

    if (isOK(start_x, 0, to_pmx, x)){
        isVisit = vector<vector<bool>>(size, vector<bool>(to_pmy.size(), false));
        memo = vector<vector<bool>>(size, vector<bool>(to_pmy.size(), false));
        if (isOK(0, 0, to_pmy, y)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 22400
#include <iostream>
using namespace std;
int main(void){
    int n,m,i,j,g,t = 0;
    int a[8];

    for(i = 0; i < 6;i++) {
        cin >> a[i];
        t += a[i];
    }
    m = a[0];
    for(i = 1; i < 4; i++) {
        m = min(m , a[i]);
    }
    t -= m + min(a[4], a[5]);
    cout << t << endl;
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};
int N,W;
const int MAX_N = 110, MAX_W = 1e5+10;
LL w[MAX_N] = {};
LL v[MAX_N] = {};

LL dp[MAX_N][MAX_W] = {};

LL rec(int x, LL tw){
    if(x == 0) return 0;
    if(dp[x][tw] != -LINF) return dp[x][tw];

    LL res = -LINF;
    if(tw >= w[x-1]){
        chmax(res, rec(x-1,tw-w[x-1])+v[x-1]);
    }
    chmax(res, rec(x-1,tw));

    return dp[x][tw] = res;

}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    cin >> N >> W;
    REP(i,N){
        cin >> w[i] >> v[i];
    }
    REP(i,MAX_N) REP(j,MAX_W) dp[i][j] = -LINF;

    LL ans = rec(N,W);
    cout << ans << endl;

    

}

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

int main(void){
	int x,y;
	vector<int> grp={0,1,2,1,3,1,3,1,1,3,1,3,1};
	cin >> x >> y;
	if(grp[x]==grp[y]) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

cnt = 1
ans = 0
b = []

for i, j in enumerate(a):
    if cnt==j:
        cnt += 1
        b.append(j)
        continue
    else:
        ans += 1
        b.append(0)

if sum(b) == 0:print(-1)
else:print(ans)

Measured memory_bytes: 26268
package main

import (
	"fmt"
)

func sum(n int) int {
	sum := 0
	for n != 0 {
		sum += n % 10
		n /= 10
	}
	return sum
}
func main() {
	var n int
	fmt.Scan(&n)
	sn := sum(n)

	if n%sn == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
N, M = map(int, input().split())

a_mat = [input() for _ in range(N)]
b_mat = ''.join([input() for _ in range(M)])


def to_vectors(mat, size=M):
    vectors = []
    for h in range(N-M+1):
        for w in range(N-M+1):
            tmp = [mat[h+i][w:w+M] for i in range(M)]
            vectors.append(''.join(tmp))
    return vectors


if b_mat in to_vectors(a_mat, M):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3444
#include <stdio.h>

int main(void)
{

        int i,a,b,c=0;
        scanf("%d%d",&a,&b);

        for (i=a;i<=b;i++)
                if (((i/10000)==(i%10))&&(((i/1000)%10)==((i/10)%10)))
                        c++;
        printf("%d\n",c);

        return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h> 
using namespace std; 
  
// Function to find that number divisible by 9 or not 
int check(string str) 
{ 
    // Compute sum of digits 
    int n = str.length(); 
    int digitSum = 0; 
    for (int i=0; i<n; i++) 
        digitSum += (str[i]-'0'); 
  
    // Check if sum of digits is divisible by 9. 
    return (digitSum % 9 == 0); 
} 
  
// Driver code 
int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
    string str;
    cin>>str; 
    check(str)?  cout << "Yes" : cout << "No "; 
    return 0; 
} 

Measured memory_bytes: 3860
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	const long Inf = (long) 1e18;
	public void Solve(){
		
		sum = new long[N + 1];
		for(int i=0;i<N;i++){
			sum[i + 1] = sum[i] + A[i];
		}
		memo = new long[N][];
		for(int i=0;i<N;i++){
			memo[i] = new long[N + 1];
			for(int j=0;j<=N;j++) memo[i][j] = Inf;
		}
		Console.WriteLine(dfs(0,N));
		
		
	}
	
	long[][] memo;
	long[] sum;
	long dfs(int now, int cnt){
		if(memo[now][cnt] != Inf) return memo[now][cnt];
		if(cnt == 1){
			return memo[now][cnt] = 0;
		}
		long min = Inf;
		for(int i=1;i<cnt;i++){
			long a = dfs(now,i);
			long b = dfs(now + i, cnt - i);
			min = Math.Min(min, a + b + (sum[now + cnt] - sum[now]));
		}
		return memo[now][cnt] = min;
	}
	
	
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;

using ll = long long;

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = a - b;
    if (k % 2) {
        ans *= -1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define oo 2000000000
#define inf 1000000000000000000
#define P1 31
#define P2 37
#define M  1000000007
#define M2 1000000009
#define pii pair<ll,ll>
typedef long long ll;
using namespace std;
const int N = 255001;
const int SQRTN = 320;
const int LOGN = 20;
const long double PI = acos(-1);
const long double TAU = 2*PI;

int n,ans;
string s,t;

void check(){
    for(int i = 0 ; i < s.size() ; i++){
        if(t[i]=='!')continue;
        if(s[i]!=t[i])return;
    }
    ans=t.size();
    t=t+t+s;
}

signed main(){
    cin >> n >> s >> t;
    ans=n<<1;
    while(t.size()<(s.size())*2){
        check();
        t="!"+t;
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

//The Legendary Sword
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if((w|h)==0)break;
			int[][] map = new int[h][w];
			List<int[]> l = new ArrayList<int[]>();
			int[][] dist = new int[h][w];
			int gi = -1, gj = -1;
			for(int[]a:map)Arrays.fill(a, 1<<29);
			int g = 1;
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				String s = sc.next();
				char c = s.charAt(0);
				if(c=='S'){
					l.add(new int[]{i, j});
					dist[i][j] = 0;
					map[i][j] = 0;
				}
				else if(c=='G'){
					map[i][j] = c;
					gi = i; gj = j;
				}
				else if(c=='.'){
					map[i][j] = 0;
				}
				else{
					map[i][j] = Integer.parseInt(s);
					g = Math.max(g, map[i][j]+1);
				}
			}
			map[gi][gj] = g;
			for(int x=1;x<=g;x++){
				List<int[]> next = new ArrayList<int[]>();
				for(int i=0;i<h;i++)for(int j=0;j<w;j++){
					if(map[i][j]!=x)continue;
					next.add(new int[]{i, j});
					int min = 1<<29;
					for(int[] a:l){
						min = Math.min(min, dist[a[0]][a[1]]+Math.abs(a[0]-i)+Math.abs(a[1]-j));
					}
					dist[i][j] = min;
				}
				l = next;
			}
			System.out.println(dist[gi][gj]);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long ll;

ll MOD = 1000000007;
ll fact[100001];


int main() {
    ll N, M;
    scanf("%lld %lld", &N, &M);
    ll prod = 1;
    for (ll i = 1; i <= 100000; i ++) {
        prod = (prod * i) % MOD;
        fact[i] = prod;
    }
    ll sum = 0;
    if (M == N - 1 || M == N) {
        sum = (sum + fact[N] * fact[M]) % MOD;
    }
    if (N == M - 1 || M == N) {
        sum = (sum + fact[N] * fact[M]) % MOD;
    }
    printf("%lld\n", sum);
}

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

#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template<typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

ll ceil(ll x, ll y) {
    return (x + y - 1) / y;
}

void solve() {
    ll n;
    cin >> n;
    v a = ga(n);


//    priority_queue<ll, v, less<>> pq;

//    for (auto x : a)pq.push(x);

    ll c = 0;

    ll target = n - 1;
//    while (!pq.empty()) {
//        auto num = pq.top();
//        pq.pop();
//        if (num <= target)continue;
//
//        ll steps = ceil(num - target, n);
//        c += steps;
//        num -= steps * n;
//    }

    while (true) {
        sort(rall(a));
        if (a.front() <= target)break;

        ll num = a.front();
        ll steps = ceil(num - target, n);
        c += steps;
        a[0] -= steps * n;
        for (ll i = 1; i < n; i++)a[i] += steps;
    }
    cout << c << endl;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
-- | Main entry point to the application.
module Main where
 
import Control.Applicative
import Control.Monad
import Data.List
import Debug.Trace
import Text.Printf
import Data.Array

-- | The main entry point.
main :: IO ()
main = do
    forM_ [1..9] $ \i -> do
      forM_ [1..9] $ \j -> do
        printf "%dx%d=%d\n" (i::Int) (j::Int) (i*j)

Measured memory_bytes: 4104
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    priority_queue<int> que;
    int X,top;
    long long sum = 0;
    for(int i=0;i<N;i++){
        cin >> X;
        que.push(X);
    }
    for(int i=0;i<M;i++){
        top=que.top();
        que.pop();
        que.push(top/2);
    }
    for(int i=0;i<N;i++){
        top=que.top();
        sum=sum+top;
        que.pop();
    }
    cout << sum << endl;
        
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    int d[10] = {};
    rep(i,0,k){
        int tmp;
        cin >> tmp;
        d[tmp] = true;
    }
    bool ok;
    int t;
    rep(i,n,100001){
        t = i;
        ok = true;
        while(t != 0){
            if(d[t%10]){
                ok = false;
                break;
            }
            t /= 10;
        }
        if(ok){
            t = i;
            break;
        }
    }
    cout << t << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int N, T, A;
	cin >> N >> T >> A; 
	int S[1010] = {};
	int saishou = 11451419; 
	for(int i = 1; i <= N; i++){
		int H; 
		cin >> H; 
		S[i] = abs(500 * T - 3 * H - 500 * A); 
		saishou = min(saishou, S[i]); 
	}
	for(int i = 1; i <= N; i++){
		if(S[i] == saishou){cout << i << endl; }
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}


vector<vi> dp(100001,vi(100,-1));

int f(int weig,int indx,const vector<vi> &v){
    if(indx>=v.size())return 0;
    if(dp[weig][indx]!=-1)return dp[weig][indx];
    int ans=INT_MIN,a,b;a=b=ans;
    if(weig-v[indx][0]>=0)a=f(weig-v[indx][0],indx+1,v)+v[indx][1];
    b=f(weig,indx+1,v);
    ans=max(a,b);
    dp[weig][indx]=ans;
    return ans;
}

signed main(){
    FASTER;//ifstream cinn("input.txt");ofstream coutt("output.txt");
    int n,w;cin>>n>>w;
    vector<vi> v(n,vi(2));cin>>v;
    cout<<f(w,0,v);
}


Measured memory_bytes: 84352
#include <stdio.h>
int main()
{
    int x1,x2,x3,x4;
    int y1,y2,y3,y4;
    int xsa,ysa;

    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
    if(x1>=x2){
        if(y1>=y2){
            xsa = x1 - x2;
            ysa = y1 - y2;

            x3 = x2 + ysa;
            y3 = y2 - xsa;

            x4 = x1 + ysa;
            y4 = y1 - xsa;

        }else{
            xsa = x1 -x2;
            ysa = y2 -y1;

            x3 = x2 - ysa;
            y3 = y2 - xsa;

            x4 = x1 - ysa;
            y4 = y1 - xsa;
        }
    }else{
        if(y1 >= y2){
            xsa = x2 - x1;
            ysa = y1 - y2;

            x3 = x2 + ysa;
            y3 = y2 + xsa;

            x4 = x1 + ysa;
            y4 = y1 + xsa;
        }else{
            xsa = x2 - x1;
            ysa = y2 - y1;

            x3 = x2 - ysa;
            y3 = y2 + xsa;

            x4 = x1 - ysa;
            y4 = y1 + xsa;
        }   
    }

    printf("%d %d %d %d",x3,y3,x4,y4);

    return 0;
}

Measured memory_bytes: 128
use std::collections::BTreeSet;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s = read::<String>().as_bytes().to_vec();
    let k: usize = read();
    let mut substrings = BTreeSet::new();

    for i in 1..k + 1 {
        let mut v: Vec<_> = s.windows(i).collect();
        for x in v {
            substrings.insert(x);
        }
    }
    println!(
        "{}",
        String::from_utf8_lossy(substrings.iter().skip(k - 1).next().unwrap())
    );
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void) {
  int A,B,ans,X;
  scanf("%d %d",&A,&B);
  ans=A+B;
  X=(A+B)/2;
  if(ans%2==0)
  printf("%d\n",X);
  else 
  printf("IMPOSSIBLE");

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define vec vector
typedef int64_t intl;
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
vec<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};



int main(){
char A,B,C;
  cin >> A >>B>>C;
  if( A == '7' || B =='7' || C == '7' ){cout <<"Yes";}
  else {cout <<"No";}
  
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int countStr(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int main() {
  int n;
  string s;
  cin >> s;
  if (s[0] != 'A' || countStr(s, 'C') != 1) {
    cout << "WA" << endl;
    return 0;
  }
  for (int i = 1; i < s.length(); ++i) {
    if (s[i] < 'a' || 'z' < s[i]) {
      if (s[i] != 'C' || i < 2 || s.length() - 2 < i) {
        cout << "WA" << endl;
        return 0;
      }
    }
  }
  cout << "AC" << endl;
  return 0;
}

Measured memory_bytes: 256
/*  ex3_2
    yy8332  */

#include <stdio.h>

int main(void){
  int number;

  //入力受け取り
  scanf("%d", &number);

  //下一桁が2,4,5,7,9の場合
  switch(number % 10){
    case 2: case 4: case 5: case 7: case 9:
      printf("hon");
      break;
    //下一桁が0,1,6,8の場合
    case 0: case 1: case 6: case 8:
      printf("pon");
      break;
    //下一桁が3の場合
    case 3:
      printf("bon");
      break;
  }



return 0;
}


Measured memory_bytes: 1716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;

void merge (int *first1, int *last1, int *first2, int *last2){
    int size1 = last1 - first1;
    int size2 = last2 - first2;
    int *result = new int[size1+size2];
    int i = 0;
    int j = 0;
    int index = 0;
    while (true){
        if (i < size1 && (first1[i] <= first2[j] || j >= size2)){
            result[index] = first1[i];
            ++i; ++index;
        }
        if (j < size2 && (first1[i] > first2[j] || i >= size1)){
            result[index] = first2[j];
            ++j; ++index;
        }
        if (i==size1 && j==size2){
            for (i=0; i<size1; ++i) first1[i] = result[i];
            for (j=0; j<size2; ++j) first2[j] = result[j+size1];
            delete[] result;
            return;
        }
    }
}
void MergeSort (int *first, int *last){
    int size = last - first;
    if(size <= 1) return;
    MergeSort(first, first+size/2);
    MergeSort(first+size/2, last);
    merge(first, first+size/2, first+size/2, last);
}


int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

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



    int N;

    while(1){

      vi v;
      cin >> N;
      if(N == 0) break;

      int av;
      REP(i, N){
        int temp;
        cin >> temp;
        v.push_back(temp);
      }

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

      int sum = 0;
      
      sum = accumulate(v.begin(), v.end(), 0)-v[0]-v[N-1];

      av = sum/(v.size()-2);

      cout << av << endl;
    }

    return 0;
  }

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

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


const ll SIZE = (1e5+10)*2;
ll a,b;
char c;
ll ans;

int main(){
    cin >> a >> c >> b;
    if(c == '+')    ans = a+b;
    else
    {
        ans = a-b;
    }
    cout << ans << endl;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
// clang-format on
/* }}} */


signed main() 
{
    int n;
    cin >> n;
    cout << n/3 << endl;
}

Measured memory_bytes: 256
class Dice:
    def __init__(self, d):
        self.d = d

    def setNum(self, n0, n1, n2, n3, n4, n5):
        self.d[0], self.d[1], self.d[2], self.d[3], self.d[4], self.d[5] = (
            n0,
            n1,
            n2,
            n3,
            n4,
            n5,
        )

    def roll(self, direction):
        if direction == "E":
            self.setNum(
                self.d[3], self.d[1], self.d[0], self.d[5], self.d[4], self.d[2]
            )
        elif direction == "N":
            self.setNum(
                self.d[1], self.d[5], self.d[2], self.d[3], self.d[0], self.d[4]
            )
        elif direction == "S":
            self.setNum(
                self.d[4], self.d[0], self.d[2], self.d[3], self.d[5], self.d[1]
            )
        elif direction == "W":
            self.setNum(
                self.d[2], self.d[1], self.d[5], self.d[0], self.d[4], self.d[3]
            )

a = list(map(int, input().split()))
b = list(map(int, input().split()))
d1 = Dice(a)
d2 = Dice(b)

flag = False
for i in list("NNNNWNNNWNNNENNNENNNWNNN"):
    d2.roll(i)
    if d1.d[0] == d2.d[0]:
        if d1.d == d2.d:
            flag = True

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



Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    ll x;
    cin >> N >> x;
    ll a[N];
    rep(i, N) cin >> a[i];
    ll ans = INF, b[N];
    fill(b, b+N, INF);
    //魔法をi回書ける場合を考える
    rep(i, N){
        rep(j, N){
            b[j] = min(b[j], a[(j+N-i)%N]);
        }
        ll tmp = x*i;
        rep(j, N){
            tmp += b[j];
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		String str=s.next();
		int ad[]=new int[10];
		for(int i=2;i<str.length();i+=4){
			ad[(int)(str.charAt(i)-'0')]++;
		}
		BigInteger bi=new BigInteger("0");
		for(int i=0;i<10;i++){
			BigInteger p=new BigInteger("1");
			for(int j=0;j<i;j++){
				p=p.multiply(new BigInteger(""+a));
			}
			bi=bi.add(p.multiply(new BigInteger(""+ad[i])));
		}
		bi=bi.multiply(new BigInteger(""+b));
		if(bi.compareTo(new BigInteger("1000000000"))<=0){
			System.out.println(bi.toString());
		}else System.out.println("TLE");
	}
}

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

int main(){
    int n;
    cin >> n;
    if(n == 25){
        cout << "Christmas" << endl;
    }else if(n == 24){
        cout << "Christmas Eve" << endl;
    }else if(n == 23){
        cout << "Christmas Eve Eve" << endl;
    }else if(n == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll n,t;cin >> n >> t;
	
	vector<ll> v;
	REP(i,n)
	{
		int tmp;cin >> tmp;
		v.PB(tmp);
	}
	v.PB(1000000000000000);
	
	ll ans = 0;
	REP(i,n)
	{
		ans += min(t,v[i+1]-v[i]);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2420