akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			for (char c : s) {
				if (c == '9') {
					out.println("Yes");
					return;
				}
			}
			out.println("No");

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)


int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//CODE TONOY
	string s;
	cin >> s;
	if (s[(int)s.length()-1] == '3') cout << "bon\n";
	else if (s[(int)s.length()-1] == '0' || s[(int)s.length()-1] == '1' || s[(int)s.length()-1] == '6' || s[(int)s.length()-1] == '8') cout << "pon\n";
	else cout << "hon\n";
	return 0;
}


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

#define el '\n'

const long long INF = 1e18L + 5;

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int n, nw;
  cin >> n >> nw;

  long long w[n-1], v[n-1], sum = 0;
  for(int i = 0; i < n; i++){
    cin >> w[i] >> v[i];
    sum += v[i];
  }
  vector<long long> dp(sum+1, INF); // 0..w
  //dp[i] min weight on value i

  dp[0] = 0;
  for(int i = 0; i < n; i++){
    for(long long val = sum-v[i]; val >= 0; val--){
      dp[val+v[i]] = min(dp[val+v[i]], dp[val]+w[i]);
    }
  }

  long long ans = 0;
  for(long long i = 0; i <= sum; i++){
    if(dp[i] <= nw){
      ans = i;
    }
  }
  cout << ans << el;
  
  return 0;
}

Measured memory_bytes: 1024
// You either die a hero, or you live long enough to see yourself become the villain.

/**
 *   author:  Blind_is_love
 *   created: 12.10.2019, 15:16
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

#define endl "\n"
#define vll vector<int>
#define max_heap priority_queue<int>
#define min_heap priority_queue<int , vector<int>, greater<int> >
#define pb push_back
#define all(container) container.begin(), container.end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define printArr(name,from,to) for(int x = from; x < to; x++) cout << name[x] << " ";
#define fi first
#define se second
#define mp make_pair
#define prime1 304933
#define prime2 15486277 
#define mod2 179424691
#define int ll

typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

const ll MOD = 1000000007;
const ll MAX = 1e5+10;
const double PI = 3.1415926;
const ll INF = 1e18;
const double EPS = 1e-5;

int n, k;
int hgt[MAX];
int dp[MAX];
bool seen[MAX];

int solve(int i){

	if (i > n) return 1e12;
	if (i == n) return 0;
	if (seen[i]) return dp[i];
	int ans = 1e12;
	for(int j = i+1; j < min(i+k+1,n+1); ++j){
		int f = solve(j);
		ans = min(ans, f + abs(hgt[i] - hgt[j]));
	}
	seen[i] = true;
	return dp[i] = ans;
}

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	clock_t t1, t2;
	t1 = clock();
	cin >> n >> k;
	for(int i = 1 ; i < n+1; ++i){
		cin >> hgt[i];
	}
	cout << solve(1) << endl;
	t2 = clock(); cerr << "time taken: " << (t2-t1)/(long double)CLOCKS_PER_SEC << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cmath>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main ()
{
   /*int a,b,c,d;
   while(scanf("%d%d",&a,&b)==2)
   {
       c=10-a;
       d=abs(b-10);
        printf("%d %d\n",c,d);
   }*/
   int a[10];
   for(int i=0;i<10;i++)
   {
       scanf("%d",&a[i]);
   }
   sort(a,a+10);
   for(int i=9;i>=7;i--)
   {
       printf("%d\n",a[i]);
   }
   return 0;

}

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

using namespace std;
using ll = long long;
unordered_map<ll, ll> mp;

void factorize(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            mp[i]++;
            while(n % i == 0) {
                n /= i;
            }
        }
    }
    if (n > 1) {
        mp[n]++;
    }
}


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n, m;
    cin >> n >> m;
    factorize(n);
    factorize(m);
    int ans = 1;
    for (auto elem : mp) {
        if (elem.second == 2) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//---------------------------------------------------------------------------------------------------
ll MOD = 998244353;
ll f[101010], rf[101010];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < 101010; i++) f[i] = (f[i - 1] * i) % MOD;
    for(int i = 0; i < 101010; i++) rf[i] = inv(f[i]);
}
ll C(int n, int k) {
    if(n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % MOD;

    return (a * bc) % MOD;
}
ll H(int k, int n)
{
    return C(n+k-1, k-1);
}
//---------------------------------------------------------------------------------------------------

int main()
{
    init();
    int k, n;
    cin >> k >> n;
    for(int i = 2; i <= 2 * k; i++)
    {
        ll ans = 0;
        int num;
        if(i <= k+1)
        {
            num = i/2;
        }
        else
        {
            num = (2*k-i+2)/2;
        }

        for(int j = 0; j <= num; j++)
        {
            ll tmp = 0;
            if(i % 2 != 0)
            {
                tmp = H(k, n-2*j) * C(num, j);
            }
            else
            {
                tmp = (H(k-1, n-2*j) * C(num-1, j) + H(k-1, n-2*j-1) * C(num-1, j)) % MOD;
            }
            if(j % 2 != 0)
            {
                ans = (ans - tmp + MOD) % MOD;
            }
            else
            {
                ans = (ans + tmp + MOD) % MOD;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 1920
#include <stdio.h>
#include <math.h>

void swap(int *x, int *y){
	int tmp =*x;
	*x = *y;
	*y = tmp;
}

int main(void){
	int a, b, c;
	int x=0, y=0, z=0;
	
	while(scanf("%d %d %d", &a, &b, &c) != EOF){
		if(a>b) swap(&a, &b);
		if(b>c) swap(&b, &c);
		
		if(c>=a+b) break;
		int check = c*c - (a*a+b*b);
		if(check<0) y++;
		else if(check==0) x++;
		else z++;  

	}
	
	printf("%d %d %d %d\n", x+y+z, x, y, z);
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
//typedef  long long ll;
typedef unsigned long long ll;
const ll LIM =1e9+7;

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}
template<typename S>
void print(S a){
    cout<<a<<endl;
}



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


    int n;cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        if((i%3!=0)&&(i%5!=0)){
            ans+=i;
        }
    }

    fin(ans);



}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a) //追加//
#define pp() pop_back() //削除//
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())

signed main(){
  string n;
  cin>>n;
 

  if(n[0]==n[1]&&n[1]==n[2]||n[1]==n[2]&&n[2]==n[3])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <map>
#define INF 10000000
using namespace std;
typedef pair<int,int> P;

int senbei[10][10000];
int r,c;
int rowFlag[10];
int Max;

int countSum(){
  int sum=0;
  for(int i=0;i<c;i++){
    int colSum = 0;
    for(int j=0;j<r;j++){
      if(senbei[j][i]==!rowFlag[j]){
        colSum++;
      }
    }
    sum += max(colSum,r-colSum);
  }
  return sum;
}

int main(){
  while(1){
    cin >> r >> c;
    if(r==0&&c==0) return 0;
    for(int i=0;i<r;i++){
      for(int j=0;j<c;j++){
        cin >> senbei[i][j];
      }
    }
    Max = 0;
    for(int i=0;i<1<<r;i++){
      for(int j=0;j<r;j++){
        rowFlag[j] = i >> j & 1;
      }
      int sum = countSum();
      if(Max<sum){
        Max = sum;
      }
    }
    cout << Max << endl;
  }
}

Measured memory_bytes: 1548
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-7

#define INF 1e9

/*

 */

int const MaxSize = 26;
int ans[MaxSize];

int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);
//	freopen("/Users/george/Downloads/C-small-2-attempt0.in", "r", stdin);
//	freopen("/Users/george/Downloads/C_small_2.out", "w", stdout);
	int n;
	cin >> n;
	LP(i, 0, MaxSize)
		ans[i] = INF;

	LP(cn, 0, n)
	{
		string s;
		cin >> s;

		vector<int> cnt(26);

		LP(i,0, s.length())
		{
			cnt[s[i] - 'a']++;
		}

		LP(i,0, MaxSize)
		{
			ans[i] = min(ans[i], cnt[i]);
		}
	}

	LP(i, 0, MaxSize)
	{
		LP(j, 0, ans[i])
		{
			cout << (char)('a' + i);
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll n;
string s, ans;
bool f;

int main(){
	cin >> n;
	while (n--){
		cin >> s;
		ans += s[0];
		for (int i = 1; i < s.size(); i += 3){
			f = 0;
			REP(j, ans.size()){
				if (ans[j] == s[i + 2]){
					f = 1;
				}
			}
			if (f)continue;
			if (s[i] == '-'){
				ans += s[i + 2];
			}
			else{
				ans = s[i + 2] + ans;
			}
		}
		cout << ans << endl;
		ans.clear();
	}
}

Measured memory_bytes: 1212
//Dijkstra法(蟻本p96)
//負の辺がない時のグラフの最短路
//値の代入と最小値の取り出し→priority_queueを利用
#include<bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repr(i,a,b) for(int i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x),end()
typedef long long ll;

struct edge{int to,cost;};//辺の状態(toはどのノードに伸びているか、costは重み)
typedef pair<int,int> P;//firstは最短距離、secondは頂点の番号

const int INF=1<<29;
int N;//ノードの数
vector<edge> G[10010];//グラフの隣接リスト表示
int d[10010];//各頂点の最短距離

void dijkstra(int s){
    //greater<P>を指定しておくことでfirstが小さい順に取り出せるようにする
    priority_queue<P,vector<P>,greater<P> > que;
    fill(d,d+N,INF);//始めに全てのノードへの最短距離をINFとする
    d[s]=0;//探索を開始する地点の最短距離を0に設定
    que.push(P(0,s));//最短距離0で頂点sへのびる辺をqueに入れてスタート
    
    while(!que.empty()){//queueが空==全ての辺の探索が終わったので終了
        P p=que.top();//queueの先頭を取得←最も重みの小さい辺を取得
        que.pop();
        int v=p.second;//もっとも重みの小さい辺が向かうノード
        if(d[v]<p.first)continue;//ノードvへの最短距離が既に求まっている場合はスルー
        //ノードvから伸びている辺を全てqueに入れる(ダイクストラの最短路の候補)
        for(int i=0; i<G[v].size(); i++){
            edge e=G[v][i];
            //辺eの向かうノードが既に探索し終わっていて、かつそれが更新されないとき
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                //queに辺の情報を入れる
                //d[e.to](暫定で)始点からの距離d[e.to]
                //ノードe.toへ向かう辺
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(){
    
    //入力
    cin>>N;
    rep(i,0,N){
        int a,b;
        cin>>a>>b;
        rep(j,0,b){
            int c,d;
            cin>>c>>d;
            G[a].push_back({c,d});
        }
    }
    
    dijkstra(0);
    
    rep(i,0,N){
        cout<<i<<" "<<d[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 8040
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      int N = Integer.parseInt(br.readLine());
      List<Long> list = new LinkedList<>();
      for(int i = 1; i <= 9; i++){
        list.add((long)i);
      }
      
      int count = 0;
      long ans = 0;
      while(count != N){
        ans = list.remove(0);
        long mod = ans%10;
        if(mod != 0) list.add(10*ans+mod-1);
        list.add(10*ans+mod);
        if(mod != 9) list.add(10*ans+mod+1);
        count++;
      }
      
      System.out.println(ans); 
    }catch(Exception e){
    }
  }
}


Measured memory_bytes: 33876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
 
int main(){
    int n,m;cin>>n>>m;
    vector<vector<int>> s(m);
    for(int i=0; i<m; i++){
        int k;cin>>k;
        for(int j=0; j<k; j++){
            int a;cin>>a; a--; // 0始まりで管理する
            s[i].push_back(a);
        }
    }
    vector<int> p(m);
    for(int i=0; i<m; i++) cin>>p[i];
    ll ans = 0;
    for(int bit=0; bit<(1<<n); bit++){
        bool ok = true;
        for(int i=0; i<m; i++){
            int con = 0;
            for(auto v : s[i]){
                if(bit & (1<<v)) con++;
            }
            if (con % 2 != p[i]) ok = false;
        }
        if(ok) ++ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main(){
    ll n; cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    cout << (((((modpow(10, n, MOD) + modpow(8, n, MOD)) % MOD) - modpow(9, n, MOD) + MOD) % MOD) - modpow(9, n, MOD) + MOD) % MOD << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(){
  int i,count=0;
  int a,b,c,ware;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    if(c%i == 0)count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int a[100001];
int ans[100001];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++){		
			ans[a[i]-1]++;
			ans[a[i]]++;
			ans[a[i]+1]++;
	}

	sort(ans,ans+100001,greater<int>());
	cout<<ans[0]<<endl;
	return 0;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define x first
#define y second
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //assert(freopen("input.txt","r",stdin));
    //assert(freopen("output.txt","w",stdout));
    int x;
    cin>>x;
    int val=__gcd(x,360);
    int lol=(x*360)/(val);
    cout<<lol/x;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <string>
#include <sstream>
#include <cstring>
#include <cmath>

using namespace std;

#ifdef DEBUG
#define LOG(args) cout << args << "\n"
#define debug(x) x
#else
#define LOG(args)
#define debug(x)
#endif

#define vi vector<int>
#define ii pair<int, int>
#define vii vector< ii >
#define vvi vector< vi >
#define mp make_pair
#define pb push_back
#define ms(x, v) memset(x, v, sizeof(x))
#define all(x) x.begin(), x.end()
#define REP(x, n) for(int x = 0; x < n; x++)
#define REPV(x, v, n) for(int x = v; x < n; x++)
#define REVE(x, n) for(int x = n; x >= 0; x--)

typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, K;
	cin >> N >> K;
	vi vals(N);
	for(auto &x : vals)
		cin >> x;
	auto ok = [&vals, K, N](int ans)
	{
		int tot = K;
		for(int i = 0; i < N && K >= 0; i++)
		{
			tot -= (vals[i] + ans - 1) / ans - 1;
		}
		return tot >= 0;
	};
	int l = 1, r = (int)1e9 + 10;
	while(l <= r)
	{
		int mid = (l & r) + ((l ^ r) >> 1);
		if(ok(mid))
			r = mid - 1;
		else
			l = mid + 1;
	}
	cout << l << "\n";
	return 0;
}


Measured memory_bytes: 3928
// Problem : D - Not Divisible
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007

// string s=bitset<64>(n).to_string();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n;
	cin>>n;
	ll a[n];
	int bol=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==1)
		bol++;
	}
	if(bol==1)
	cout<<1<<endl;
	else if(bol>1)
	cout<<0<<endl;
	else
	{
	int b[1000001];
	memset(b,0,sizeof(b));	
// 	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
// 		cout<<a[i]<<endl;
		for(int j=a[i];j<1000001;j+=a[i])
		{
			b[j]++;
		}
		
	}
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(b[a[i]]<=1)
		cnt++;
	}
	cout<<cnt<<endl;
	}
	return 0;
}


Measured memory_bytes: 9016
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;

int main() {
	ll n; cin >> n;
	pair<ll, ll> ans = { 1,1 };
	rep(i, n) {
		ll ansum = ans.first + ans.second;
		ll f, s; cin >> f >> s;

		ll f1;
		if(ans.first%f==0) f1 = ans.first;
		else f1 = ans.first - (ans.first % f) + f;
		ll s1 = f1 / f * s;

		ll s2;
		if (ans.second % s == 0) s2 = ans.second;
		else s2 = ans.second - (ans.second % s)+s;

		ll f2 = s2 / s * f;

		if (f1 < ans.first || s1 < ans.second) ans = { f2,s2 };
		else if (f2<ans.first||s2<ans.second) ans = { f1,s1 };
		else if (f1 + s1 <= f2 + s2) ans = { f1,s1 };
		else ans = { f2,s2 };
	}
	cout << ans.first + ans.second << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        n: usize,
        s: [String; n],
    }
    let mut counts = vec![0; 5];
    let patterns = ["M", "A", "R", "C", "H"];
    for si in s {
        for j in 0..5 {
            if si.starts_with(patterns[j]) {
                counts[j] += 1;
            }
        }
    }

    let mut ret = 0;
    for i in 0..5 {
        for j in 0..5 {
            for k in 0..5 {
                if i < j && j < k {
                    ret += counts[i] as i64 * counts[j] as i64 * counts[k] as i64;
                }
            }
        }
    }

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


Measured memory_bytes: 7500
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define MAXN 300010

int ct[MAXN], ans[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int k, x, i, j;
	cin >> k >> x;
	for (i = x - k + 1; i <= x + k - 1; i++) cout << i << " ";
	cout << "\n";


	return 0;
}


Measured memory_bytes: 256
import sys
n = int(input())
lm, rm = 0, 10**10
seg = []
for _ in range(n):
	l, r = map(int, input().split())
	seg.append([l, r])
	lm = max(lm, l)
	rm = min(rm, r)

seg.sort(key=lambda x: (x[0], x[1]))
mins = [seg[-1][1]]
for i in range(n-2, -1, -1):
	mins.append(min(mins[-1], seg[i][1]))
mins.reverse()

ans = 0
for i in range(n):
	l, r = seg[i]
	if rm < l and r < lm:
		print(max([x[1]-x[0]+1 for x in seg]))
		sys.exit()
	elif lm == l and rm == r:
		print(max(rm-lm+1, 0) + max([x[1]-x[0]+1 for x in seg]))
		sys.exit()
	elif i < n-1:
		ans = max(ans, max(0, rm-l+1) + max(0, mins[i+1]-lm+1))

print(max(ans, max(rm-lm+1, 0) + max([x[1]-x[0]+1 for x in seg])))

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef map<int,int> mapii;
typedef map<int,bool> mapib;
typedef map<char,int> mapci;

#define small 1e-9
#define big5 1000000005
#define big7 1000000007
#define big 100000
#define large 200001
#define pi 3.1415926

#define inp(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define cum(arr,n,cumm) cumm[0]=0;for(int i=0;i<n;i++)cumm[i+1]=cumm[i]+arr[i];
#define bsdk ios_base::sync_with_stdio(false);cin.tie(NULL);
#define disp(arr) for(auto i:arr)cout<<i<<" ";cout<<"\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define m1 cout<<"-1\n"
#define nl <<endl
#define hs cout<<"#"

#define fori(a, b, c) for (a = (b); (a) <= (c); ++(a))
#define ford(a, b, c) for (a = (b); (a) >= (c); --(a))
#define rep(i,n) fori(i,0,n-1)
#define rep1(i,n) fori(i,1,n-1)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define ub upper_bound
#define lb lower_bound
#define allv(v) v.begin(), v.end()
#define sorti(v) sort(allv(v))
/*bool isprime[big+1];
vector<int> primes;
void makesieve()
{
    ll i,j;
    rep(i,1000001)
        isprime[i]=false;
    isprime[2]=true;
    for(i=3;i<=big;i+=2)
        isprime[i]=true;
    for(i=3;i<=big;i+=2)
    {
        if(isprime[i])
            for(j=i*i;j<=big;j+=i)
            isprime[j]=false;
    }
    rep(i,big+1)
    {
        if(isprime[i])
            primes.pb(i);
    }
}
ll poww(ll n,ll m){
    if(m==0)return 1;
    if(m==1)return n;
    ll ans = poww(n,m/2);
    if(m%2==1) return (ans*ans)*n;
    else return (ans*ans);
}*/
void solve()
{
   ll n,i;
   ll as=1000000000000000000;
   cin>>n;
   ll arr[n];
   inp(arr,n);
   ll prev=1;
   ll ans=arr[0];
   int c=0;
   rep(i,n)
       if(arr[i]==0)
       {
           c++;
           break;
       }
   for(i=1;i<n;i++)
   {
       prev=ans;
       ans*=arr[i];
       if(ans<prev)
        break;
       //cout<<ans nl;
   }
   if(c>0)
    cout<<"0";
   else if(i<n || ans>as)
    m1;
   else
    cout<<ans;
}
int main()
{
    bsdk
    int t;
    //cin>>t;
    t=1;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 4392
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int dp[1002][1002];
const int MOD = (int)1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x) * t << endl;
}

Measured memory_bytes: 3648
/*---> 12 April 2020 <--- > 23:46:45 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
    string s;
    cin>>s;
    if(s.find('7')!=string::npos)
        cout<<"Yes\n";
    else
        cout<<"No\n";
return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, from, to) for (int i = from; i < to; i++)
typedef long long ll;
const ll mod = (ll)1e9 + 7;

ll mod_pow(ll x, ll n)
{
  ll res = 1;
  while (n != 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n = n >> 1;
  }
  return res;
}

ll mod_fact(ll x)
{
  ll res = 1;
  for (ll i = x; i > 0; i--)
    res *= i, res %= mod;
  return res;
}

ll mod_comb(ll n, ll r)
{
  r = min(r, n - r);
  ll nume = mod_fact(n);
  ll deno = mod_fact(r) * mod_fact(n - r) % mod;
  return nume * mod_pow(deno, mod - 2) % mod;
}

int main()
{
  ll N, M;
  cin >> N >> M;
  ll ans = 1;
  for (int i = 2; i * i <= M; i++)
  {
    int a = 0;
    while (M % i == 0)
    {
      M /= i;
      a++;
    }
    if (a > 0)
      ans = ans * mod_comb(N + a - 1, a) % mod;
  }
  if (M > 1)
    ans = ans * N % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    As = set([int(input()) for _ in range(m)])
    mod = 1000000007

    Steps = [0] * (n+1)
    Steps[0] = 1
    if 1 not in As:
        Steps[1] = 1

    for i in range(2, n+1):
        if i in As:
            continue
        Steps[i] = Steps[i-1] + Steps[i-2]
    ans = Steps[-1] % mod
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

const int INF = numeric_limits<int>::max() / 2;

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

	int n;
	cin >> n;
	vector<int> p(2 * n), dp(2 * n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
		cin >> p[i];
	queue<int> q;
	q.push(0);
	while (!q.empty())
	{
		int now = q.front();
		q.pop();
		for (int i = 1; i <= 6; i++)
		{
			int next = now + i;
			if (next > n - 1)
				break;
			while (dp[next] == INF)
			{
				if (p[next] == 0)
					q.push(next);
				dp[next] = dp[now] + 1;
				next += p[next];
			}
		}
		if (dp[n - 1] != INF)
			break;
	}
	cout << dp[n - 1] << endl;
}


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

int main() {
	int h, w; cin >> h >> w;
	int dis[10][10] = {0};
	for (int i = 0; i < 10; i ++)
		for (int j = 0; j < 10; j ++) cin >> dis[i][j];
	for (int k = 0; k < 10; k ++)
		for (int i = 0; i < 10; i ++)
			for (int j = 0; j < 10; j ++)
				if (dis[i][k] + dis[k][j] < dis[i][j])
					dis[i][j] = dis[i][k] + dis[k][j];
	int ans = 0;
	for (int i = 0; i < h; i ++)
		for (int j = 0; j < w; j ++) {
			int t; cin >> t;
			if (t != -1) ans += dis[t][1];
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin>>n;
long long a[n]={};
long long b[n+1]={};
long long r;
long long ca=0;
long long cb=0;
for(long long i=0; i<n;i++){
cin>>a[i];
b[i]=a[i];}
sort(a,a+n);
ca=a[n/2-1];
cb=a[n/2];
if(ca==cb){
for(long long i=0; i<n;i++){
cout<<ca<<endl;}}
else {
for(long long i=0; i<n;i++){
if(b[i]<=ca){
cout<<cb<<endl;}
else
cout<<ca<<endl;}}}



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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 2000005;

/* ...o(^-^)o... */

long long fac[MAX], facinv[MAX], inv[MAX];
void facinit(){
    fac[0] = fac[1] = 1;
    facinv[0] = facinv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        facinv[i] = facinv[i - 1] * inv[i] % MOD;
    }   
}

long long combi(long long a, long long b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;
    return fac[a] * (facinv[b] * facinv[a - b] % MOD) % MOD;
}

int main(){
    lint r1, c1, r2, c2; cin>>r1>>c1>>r2>>c2;
    facinit();
    lint ans = combi(r2+c2+2, r2+1);
    ans += MOD - combi(r1+c2+1, c2+1); ans %= MOD;
    ans += MOD - combi(r2+c1+1, r2+1); ans %= MOD;
    ans += combi(r1+c1, r1); ans %= MOD;
    out(ans);
}


Measured memory_bytes: 47104
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* It does not matter how slowly you go as long as you do not stop.*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1005;



int32_t main(){
    FAST;

    int n;  cin >> n;
    cout << ((int )(pow(n , 3))) << endl;

    return 0;
}




Measured memory_bytes: 384
N = int(input())
B = list(map(int, input().split()))
A = list(map(int, input().split()))
count = 0

for i in range(N):
    if i == 0:
        tmp = min(A[i], B[i])
        A[i] -= tmp
        B[i] -= tmp
        count += tmp
    else:
        tmp = min(A[i - 1], B[i])
        count += tmp
        A[i - 1] -= tmp
        B[i] -= tmp
        tmp = min(A[i], B[i])
        count += tmp
        A[i] -= tmp
        B[i] -= tmp

tmp = min(A[N - 1], B[N])
count += tmp
B[N] -= tmp
A[N - 1] -= tmp

print(count)

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

int main()
{
    string S, T;
    int A, B;
    string U;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if (U == S)
    {
        A--;
    }
    else
    {
        B--;
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    ll t;
    cin >> t;
    a[i]=t;
    if(t==0){
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans=1;
  ll nmax=1e18;
  for(int i=0;i<n;i++){
    if(a[i]<=nmax/ans){
      ans*=a[i];
    }else{
      ans=-1;
      break;
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 4052
#include <string>
#include <iostream>
using namespace std;
string s; int c[26];
int main() {
	cin >> s;
	for (char i : s) c[i - 97]++;
	long long ret = 1LL * s.size() * (s.size() - 1) / 2 + 1;
	for (int i = 0; i < 26; i++) ret -= 1LL * c[i] * (c[i] - 1) / 2;
	cout << ret << endl;
	return 0;
}

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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  int ans = 1e9;
  for (int i = 0; i < n - m + 1; ++i) {
    string tmp = s.substr(i, m);
    int cnt = 0;
    for (int j = 0; j < m; ++j) {
      if (tmp[j] != t[j]) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << '\n';
  return 0;
}



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

int main(){
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    int i,j,tmp;
    for(i=0;i<2;i++){
        for(j=1;i+j<3;j++){
            if(a.at(i)<a.at(i+j)){
                tmp = a.at(i);
                a.at(i) = a.at(i+j);
                a.at(i+j) = tmp;
            }
        }
    }
    cout << a.at(0)*10+a.at(1)+a.at(2) << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

ostream& operator <<(ostream& out, const pair<int, int>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const set<T>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end(), greater<int>());
  int64 ret = 0;
  for (int i = m; i < n; ++i) ret += a[i];
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 1024
import numpy as np
S = np.array(list(input()))

L1 = np.zeros(len(S)+1)
for i in range(len(S)):
  L1[i+1] = L1[i] + 1 if S[i] == '<' else 0

L2 = np.zeros(len(S)+1)
for i in range(len(S), 0, -1):
  L2[i-1] = L2[i] + 1 if S[i-1] == '>' else 0

print(int(sum(np.max([L1, L2], axis=0))))

Measured memory_bytes: 33924
import fractions
from functools import reduce
n=int(input())
num=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
z=lcm(*num)
ans=0
for i in range(n):
  ans+=z//num[i]
print(ans%1000000007)

Measured memory_bytes: 6112
import sys

inf = 1<<60

def solve():
    N, M = map(int, input().split())
    edges = [None] * M

    for i in range(M):
        ai, bi, ci = map(int, sys.stdin.readline().split())
        ai, bi = ai - 1, bi - 1
        edges[i] = (ai, bi, -ci)

    ans = BellmanFord(N, M, edges)

    if ans is None:
        print('inf')
    else:
        print(-ans)

def BellmanFord(N, M, edges):
    d = [inf] * N
    d[0] = 0

    for i in range(N - 1):
        for (u, v, c) in edges:
            if d[u] + c < d[v]:
                d[v] = d[u] + c

    for i in range(N):
        for (u, v, c) in edges:
            if d[u] + c < d[v]:
                if v == N - 1:
                    return None

                d[v] = d[u] + c

    return d[N - 1]

if __name__ == '__main__':
    solve()

Measured memory_bytes: 42352
import sys
N,Y=map(int,input().split())
for i in range(N+1):
    for j in range(N-i+1):
        k= N-i-j
        t=10000*i+5000*j+1000*k
        if Y==t:
            print(i,j,k)
            sys.exit()
print(-1,-1,-1)

Measured memory_bytes: 42588
#include<stdio.h>
#include <iostream>
using namespace std;

int main() {
int n, k, p;
cin >> n;
for (int i=0; i<n; ++i) {
scanf("%d %d", &k, &p);
int j = 1;
while (--k) { 
++j;
if (j == p+1) j = 1;
}
cout << j <<endl;
}
return 0;
}

Measured memory_bytes: 1240
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
const int N=200005;
int n,x,y;
struct node{
    int u,v,nxt;
}B[N*2],R[N*2];
int hB[N];
int hR[N];
int Bcnt,Rcnt;
int eu[N],ev[N];
void add_B(int u,int v){
    Bcnt++;
    B[Bcnt].u=u;
    B[Bcnt].v=v;
    B[Bcnt].nxt=hB[u];
    hB[u]=Bcnt;
}
void add_R(int u,int v){
    Rcnt++;
    R[Rcnt].u=u;
    R[Rcnt].v=v;
    R[Rcnt].nxt=hR[u];
    hR[u]=Rcnt;
}
int deep[N],fa[N];
int dfn[N],efn[N],tot;
void dfs(int u,int dep){
    deep[u]=dep;
    dfn[u]=++tot;
    for(int i=hB[u];i;i=B[i].nxt){
        int v=B[i].v;
        if(v==fa[u])
            continue;
        fa[v]=u;
        dfs(v,dep+1);
    }
    efn[u]=++tot;
}
bool check(int x,int y){//Islongedge?
    if(dfn[x]>dfn[y])
        swap(x,y);
    if(dfn[x]<=dfn[y]&&efn[y]<=efn[x])
        return deep[y]-deep[x]>2;
    return fa[x]!=fa[y];
}
bool Longedge[N];
queue<int>q;
bool vis[N];
int dist[N];
void bfs(){
    while(!q.empty())
        q.pop();
    vis[x]=1;
    q.push(x);
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=hR[u];i;i=R[i].nxt){
            int v=R[i].v;
            if(!vis[v]){
                dist[v]=dist[u]+1;
                if(dist[v]<deep[v]){
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
}
int main()
{
    //freopen("coalesce.in","r",stdin);
    //freopen("coalesce.out","w",stdout);
    while(~scanf("%d%d%d",&n,&x,&y)){
        memset(hB,0,sizeof hB);
        memset(hR,0,sizeof hR);
        Bcnt=Rcnt=0;
        memset(fa,0,sizeof fa);
        tot=0;
        memset(Longedge,0,sizeof Longedge);
        memset(vis,0,sizeof vis);
        memset(dist,0,sizeof dist);
        for(int i=1;i<n;i++){
            scanf("%d%d",&eu[i],&ev[i]);
        }
        for(int i=1;i<n;i++){
            int u,v;
            scanf("%d%d",&u,&v);
            add_B(u,v);
            add_B(v,u);
        }
        dfs(y,0);
        for(int i=1;i<n;i++){
            int u=eu[i],v=ev[i];
            if(check(u,v))
                Longedge[u]=Longedge[v]=1;
            else
                add_R(u,v),add_R(v,u);
        }
        bfs();
        int ans=0;
        bool f=true;
        for(int i=1;i<=n&&f;i++)
            if(vis[i]&&Longedge[i]){
                puts("-1");
                f=false;
            }
            else
                if(vis[i])
                    ans=max(ans,deep[i]*2);
        if(f)
            printf("%d\n",ans);
    }
}


Measured memory_bytes: 25472