akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << p.first << " " << p.second;
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string S;
  std::cin >> S;

  std::vector<ll> vc(3, 0LL);
  for (auto c : S) {
    vc[c - 'a']++;
  }

  std::sort(vc.begin(), vc.end(), std::greater<>());

  if (vc[0] - vc[2] > 1) {
    print("NO");
  } else {
    print("YES");
  }

  return 0;
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,v,ans=0;
    cin>>n>>v;
    ll a[n],b[n],c[n],d[n];
    map<ll,ll> mp1,mp2;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++)cin>>c[i];
    for(int i=0;i<n;i++)cin>>d[i]; 
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++){
    		mp1[a[i]+b[j]]++;
    	}
    }
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++){
    		mp2[c[i]+d[j]]++;
    	}
    }
    for(auto& i:mp1){
    	ans+=i.second*mp2[v-i.first];
    }
    cout << ans<<endl;
    return 0;
}



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

const ll logx=30;
const ll N=4e5+5;
const ll M=3e5+5;
const ll mod=1e9+7;
const ll INF=1e18+5;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

ll dp[N][27];

int main()
{
  ll n;
  //cin>>n;
  string s;
  cin>>s;
  n=s.length();
  vector<char> v;
  for(ll i=0;i<n;i++)
  {
    if(s[i]=='1')
    {
      //m++;
      //ans+='1';
      v.pb('1');
    }
    else if(s[i]=='0')
    {
      //m++;
      //ans+='0';
      v.pb('0');
    }
    else
    {
      //ans.resize(m-1);
      if(v.size()==0){continue;}
      v.pop_back();
    }
  //  trace2(i,v.size());
  }
  for(auto i:v){cout<<i;}
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define clr(x) memset((x), 0, sizeof(x))
#define pb push_back
#define mp make_pair
#define sz size()
#define x first
#define y second
#define forn(i, n) for(int i=0; i<(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)

typedef long double ld;

// Constants
const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-11;

// Types
typedef signed   long long i64;
typedef unsigned long long u64;
typedef pair < int, int > PII;

int n;
i64 a[200200];
int pos[200200];
set <int> st;
set <int>::iterator it;
i64 ans;

int main()
{
	cin >>n;
	forn(i,n)
	{
		cin >>a[i];
		pos[a[i]]=i+1;
	}

	st.insert(0);
	st.insert(n+1);

	for(i64 i=1; i<=n; i++)
	{
		//cout <<i<<' '<<pos[i]<<" : ";

		it=st.lower_bound(pos[i]);
		it--;
		int L=(*it);
		it=st.lower_bound(pos[i]);
		int R=(*it);
		
		ans+=i*(pos[i]-L)*(R-pos[i]);

		//cout <<L<<' '<<R<<" d "<<pos[i]-L<<' '<<R-pos[i]<<endl;
		st.insert(pos[i]);
	}
	cout <<ans;


	return 0;
}

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

using namespace std;

int main()
{
    int s;
    cin >> s;
    vector<int> a(1000000, 0);
  
    a.at(s)++;
    for(int i=2; i<1000000; i++){
        if(s%2 == 0){
            s /= 2;
            a.at(s)++;
        }
		else{
            s *= 3;
            s++;
            a.at(s)++;
        }
        if(a.at(s) == 2){
            cout << i << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
 	long int a,b;
 	cin>>a>>b;

 	long int prev = -1, prev2 = -1;

 	for(long int i = 1; i <= 16; i++){
 		if((a > 0) && ((i - prev) > 1)){
 			a--;
 			prev = i;
 		}
 		else if((b > 0) && ((i - prev2) > 1)){
 			b--;
 			prev2 = i;
 		}
 	}  

 	if(!a && !b)
 		cout<<"Yay!";
 	else
 		cout<<":(";
   return 0;
}

Measured memory_bytes: 256
N,Q,*X=`dd`.split.map &:to_i;A=[0]*(N%2)+X.shift(N);M=-~N/2;L=[];S=[A[M..-1].reduce(:+)];M.times{|i|S<<S[-1]+(l=A[2*i+1])-r=A[i+M];L<<(l+r)/2};X.map{|e|p S[(0...M).bsearch{|i|L[i]>=e}||M]}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;

	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;

int main(){
  long long S;
  long long sum = 0;
  cin >> S;
  long long num = S;
  int digit = 0;
  while(num != 0){
    num /= 10;
    digit++;
  }
  num = S;
  vector<int> vec(digit);
  for(int i = 0; i < digit; i++){
    vec[i] = num/pow(10, digit - i - 1);
    num -= vec[i] * pow(10, digit - i - 1);
  }
  int left = 0;
  int right = digit - 1;
  int leftadd = 0;
  int rightadd = 0;
  int divi = 0;
  int head = 0;
  for(int j = 0; j < digit; j++){
    left = 0;
    right = digit - 1 - j;
    for(int i = 0; i < digit - j; i++){
      head = i;
      divi = 0;
      leftadd = 0;
      rightadd = 0;
      if(left > 1){
        leftadd = pow(2,(left - 1));
      }
      else{
        leftadd = 1;
      }
      if(right > 1){
        rightadd = pow(2,(right - 1));
      }
      else{
        rightadd = 1;
      }
      if(leftadd == 0 && rightadd == 0){
        divi = 1;
      }
      else{
        divi += leftadd * rightadd;
      }
      
      for(int k = 0; k < j + 1; k++){
        sum += vec[head] * pow(10,j - k) * divi;
        head ++;
      }
      left ++;
      right --;
    }
  }
  cout << sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  string s;
  cin>>s;
  int sum=0;
  for(int i=0;i<sz(s);i++)if(s[i]=='o')sum++;
  if(15-sz(s)+sum>=8)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


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

int main(int argc, char const *argv[]) {
	int n; cin >> n;
	vector<int> p(n); rep(i, n) cin >> p[i];

	int cnt = 0;
	rep(i, n - 2) {
		int mi = min({p[i], p[i + 1], p[i + 2]});
		int ma = max({p[i], p[i + 1], p[i + 2]});
		int sum = p[i] + p[i + 1] + p[i + 2];
		if (sum - (mi + ma) == p[i + 1]) {
			cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define fi first
#define se second
#define sz(a) ((int)(a).size())
#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define dec(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define fit(itr,c) for(__typeof((c).begin()) itr = (c).begin();itr!=(c).end();itr++)
#define clr(a,v) memset(a, v, sizeof(a))
#define EPS 1e-8
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;
const int mod = 1e9 + 7;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}

int n, k;
int a[55];
ll dp[55][2555][55];

ll solve(int i, int soma, int esc) {
	if(i == n && esc > 0 && soma % esc == 0) return ((soma/esc) == k);
	else if(i == n) return 0;

	ll ret = dp[i][soma][esc];
	if(ret != -1)return ret;
	ret = 0;
	ret += solve(i+1,soma, esc);
	ret += solve(i+1,soma+a[i],esc+1);
	return dp[i][soma][esc] = ret;
}

int main() {
	clr(dp,-1);
	gn(n);gn(k);
	rep(i,0,n)gn(a[i]);
	cout << solve(0,0,0) << endl;
}

Measured memory_bytes: 60672
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc =new Scanner(System.in);
    int a = sc.nextInt();
    String s = sc.next();
    
    judge(a,s);
  }
    
  public static void judge(int number,String cha){
    if(number>=3200){
      System.out.println(cha);
    }else{
      System.out.println("red");
    }
  }
}

Measured memory_bytes: 21844
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a>c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int i=0 ; i<b ; i++)scanf("%d",&a[i])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	int n;
	scd(n);
	int a[20000];
	scarrd(a,n);
	forde(i,n-1,0)
	printf("%d ",a[i]);
	printf("%d\n",a[0]);
	return 0;
}

Measured memory_bytes: 3200
// Aizu 2070: First Experience
// 2017.9.22 bal4u@uu

#include <stdio.h>
#include <ctype.h>

#define INF 0x7fffffff

char buf[100], *p;

int factor()
{
	int x = 0;
	while (isdigit(*p)) { x = x * 10 + *p++ - '0'; if (x > 9999) return INF; }
	return x;
}

int calc()
{
	int x, y, op;
	
	if ((x = factor()) == INF) return INF;
	while (1) {
		op = *p++;
		if (op == '=') break;
		if ((y = factor()) == INF) return INF;
		if      (op == '+') x += y;
		else if (op == '-') x -= y;
		else                x *= y;
		if (x < 0 || x > 9999) return INF;
	}
	return x;
}

int main()
{
	int ans;

	while (scanf("%s", p = buf) == 1) {
		if ((ans = calc()) != INF) printf("%d\n", ans);
		else puts("E");
	}
	return 0;
}

Measured memory_bytes: 1700
#include<stdio.h>
int main(void)
{
	int S;
	int h,m,s;
	
	scanf("%d",&S);
	h=S/3600;
	m=S%3600/60;
	s=S-3600*h-m*60;
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int l, r, d;
    cin >> l >> r >> d;
    int count = 0;
    for(int i =l; i <= r; i++)
      if(i % d == 0)
        count++;
    cout << count;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int N , K , R , S , P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    map <char , int> A;
    A['r'] = P;
    A['s'] = R;
    A['p'] = S;
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(i < K || T[i] != T[i - K]){
            ans += A[T[i]];
        }
        else{
            T[i] = 'a';
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3776
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

struct UnionFind {
  vector<int> r;
  UnionFind(int N) { r = vector<int>(N, -1); }

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

  int size(int x) { return -r[root(x)]; }
  bool same(int x, int y) {
    if (root(x) == root(y))
      return true;
    else
      return false;
  }
};

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind UF(N);
  vector<int> friend_num = vector<int>(N, 0);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A -= 1;
    B -= 1;
    friend_num[A]++;
    friend_num[B]++;
    UF.unite(A, B);
  }
  vector<int> ans = vector<int>(N, 0);

  for (int i = 0; i < K; i++) {
    int C, D;
    cin >> C >> D;
    C -= 1;
    D -= 1;
    if (UF.same(C, D)) {
      ans[C] -= 1;
      ans[D] -= 1;
    }
  }
  for (int i = 0; i < N; i++) {
    ans[i] += UF.size(i) - friend_num[i] - 1;
    cout << ans[i] << " ";
  }
}

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

int main() {
  int N=0;
  bool flag=false;
  
  cin >> N;
  
  for (int i=0; i < N ; i++) {
    string s;
    cin >> s;
    if (s == "Y") {
      flag = true;
      break;
    }
  }
  
  if (flag) cout << "Four" << endl;
  else cout << "Three" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#include <atcoder/all>

#define FOR_LT(i, beg, end) for (decltype(end) i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (decltype(end) i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (decltype(beg) i = beg; end <= i; i--)
#define REP(n)              for (decltype(n) repeat_index = 0; repeat_index < n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m; cin >> n >> m;
	vector<int> as(n); for (auto& a : as) { cin >> a; }
	vector<int> bs(m); for (auto& b : bs) { cin >> b; }

	auto ret = atcoder::convolution(as, bs);
	for (auto& r : ret) {
		cout << r << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 19056
// https://atcoder.jp/contests/agc037/tasks/agc037_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn solve(mut a: Vec<i64>, mut b: Vec<i64>) -> i64 {
    let n = a.len();
    for i in 0..n {
        if b[i] < a[i] {
            return -1;
        }
    }
    let mut pq = BinaryHeap::new();
    for i in 0..n {
        if a[i] < b[i] {
            pq.push((b[i], i));
        }
    }

    let mut step = 0;
    while let Some((mut v, i)) = pq.pop() {
        let lr = b[(i+1)%n] + b[(i+n-1)%n];
        if lr > v {
            return -1;
        }
        assert!(a[i] < b[i]);
        assert!(b[i] == v);
        let sage = v - a[i];
        let k = sage / lr;
        if k == 0 {
            return -1;
        }
        v -= lr * k;
        b[i] = v;
        if a[i] > b[i] {
            return -1;
        } else if a[i] < b[i] {
            pq.push((b[i], i));
        }
        step += k;
    }

    for i in 0..n {
        if a[i] != b[i] {
            return -1;
        }
    }
    step
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
        b: [i64; n]
    };

    println!("{}", solve(a, b));
}


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

int main()
{
  int w;
  while (cin >> w) {
    if (w == -1)
      break;

    int price = 1150;
    w -= 10;
    if (w > 0) {
     price += 125 *  min(w, 10);
     w -= min(w, 10);
    }

    if (w > 0) {
     price += 140 *  min(w, 10);
     w -= min(w, 10);
    }

    if (w > 0)
      price += 160 * w;

    cout << 4280 - price << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){
	int a[4],b[4];
	for(int i=0;i<4;i++) cin >> a[i] ;
	for(int i=0;i<4;i++) cin >> b[i] ;
	int sa=0; int sb=0;
	for(int i=0;i<4;i++) sa+=a[i] ,sb+=b[i] ;
	if(sa>sb) cout << sa ;
	else cout << sb ;
	cout << '\n' ;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define ld          long double
#define x           first
#define y           second
#define mp          make_pair

using namespace std;

const int N = int(2e5) + 7;
const int inf = int(1e9) + 7;
typedef pair<int, int> pii;

int n, rmax, rmin, bmax, bmin;
ll res1, res2;
pii p[N];

void Maximize(int& x, int y) {if(x < y) x = y;}
void Minimize(int& x, int y) {if(x > y) x = y;}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n; rmax = bmax = -inf, rmin = bmin = inf;
    for(int i = 1; i <= n; ++i) {
        cin >> p[i].x >> p[i].y;
        if(p[i].x > p[i].y) swap(p[i].x, p[i].y);
        Maximize(rmax, p[i].x), Minimize(rmin, p[i].x);
        Maximize(bmax, p[i].y), Minimize(bmin, p[i].y);
    }
    res1 = 1ll * (rmax - rmin) * (bmax - bmin);
    sort(p + 1, p + n + 1);
    res2 = INT_MAX, rmax = bmin = p[1].y;
    for(int i = 2; i < n; ++i) {
        Maximize(rmax, p[i].y), Minimize(bmin, p[i].y);
        res2 = min(res2, (ll)(max(rmax, p[n].x) - min(bmin, p[i + 1].x)));
    }
    res2 *= (bmax - rmin);
    cout << min(res1, res2);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;
int h[100], n;
int grow(int l, int r){ // [l, r)
  // printf("l: %d, r: %d\n", l, r);
  if(l==r-1)return h[l];
  else if(l==r)return 0;
  int min_h = INF, ret;
  for(int i=l;i<r;i++){
  	min_h=min(min_h, h[i]);
  }
  ret=min_h;
  vector<int> zero_h={l-1};
  for(int i=l;i<r;i++){
    h[i]-=min_h;
    if(h[i]==0)zero_h.push_back(i);
  }
  zero_h.push_back(r);
  for(int i=0;i<(int)zero_h.size()-1;i++){
    ret+=grow(zero_h[i]+1, zero_h[i+1]);
  }
  return ret;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>h[i];
  cout<<grow(0, n)<<endl;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
    }
    let mut dp = vec![0; n];
    for i in 1..n {
        for j in 1..n {
            if i * j >= n {
                break;
            } else {
                dp[i * j] += 1;
            }
        }
    }
    let mut r = 0;
    for c in 1..n {
        r += dp[n - c];
    }

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


Measured memory_bytes: 5880
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = (ll)1e18+1;

vector<ll> a, b, c;
ll x, y, z, k;
vector<ll> ans0;
bool check(ll x0){
    ll ans = 0;
    rep(i, x)rep(j, y){
        ll ok = -1, ng = z;
        while(ng-ok>1){
            ll mid = (ok + ng)/2;
            if(a[i]+b[j]+c[mid]>x0)ok = mid;
            else ng = mid;
        }
        ans += ok+1;
        if(ans>=k) return false;
    }
    return ans<k;
}

void syukei(ll x0){
    rep(i, x)rep(j, y){
        ll ok = -1, ng = z;
        while(ng-ok>1){
            ll mid = (ok + ng)/2;
            if(a[i]+b[j]+c[mid]>=x0)ok = mid;
            else ng = mid;
        }
        rep(w, ok+1) ans0.push_back(a[i]+b[j]+c[w]);
    }
    sort(ans0.rbegin(), ans0.rend());
    return;
}

int main(){
    cin >> x >> y >> z >> k;
    a.resize(x); b.resize(y);c.resize(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());

    ll ok = -1, ng = a[0]+b[0]+c[0]+1;

    while(ng-ok>1){
        ll mid = (ok+ng)/2;
        if(check(mid)) ng = mid;
        else ok=mid;
    }

    ans0={};
    syukei(ok);
    rep(i, k){
        cout << ans0[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 264540
n,a,b = list(map(int, input().split()))
mod = int(1e9+7)

def inverse(n, mod):
    return pow(n, mod - 2, mod)

def cmb(n, r, mod):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * inverse(q, mod) % mod

ans = pow(2, n, mod) - 1
ans -= cmb(n, a, mod)
ans -= cmb(n, b, mod)
print(ans % mod)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

const int N = 105;
int cnt[N];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,k;
	cin >> n >> k;
	rep(i,0,k){
		int d;
		cin >> d;
		while(d--){
			int x;
			cin >> x;
			++cnt[x];
		}
	}
	int ans = 0;
	rep(i,1,n+1)ans += cnt[i] == 0;
	cout << ans << '\n';
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,A,B;
    cin>>n>>A>>B;
    int topping[100],base;
    cin>>base;
    for(int i=0;i<n;i++)cin>>topping[i];
    int ans=base/A;
    sort(topping,topping+n);
    for(int i=n-1;i>=0;i--)ans=max(ans,(base+=topping[i])/(A+B*(n-i)));
    cout<<ans<<endl;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const ll N = 1e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}


int main()
{	

	ll n,k; cin >> n >> k;
	ll a[n+1];
	FOR(i,1,n)cin >> a[i];
	ll dp[n+1][k+1];
	ll sum[n+1][k+1];
	fill(dp,0);
	fill(sum,0);
	FOR(i,0,k)if(i<=a[1])dp[1][i] = 1; else dp[1][i] = 0;
	sum[1][0] = 1;
	FOR(i,1,k)sum[1][i] = add(sum[1][i-1],dp[1][i]);
	FOR(i,1,n)dp[i][0] = 1;
	FOR(i,2,n){
		sum[i][0] = 1;
		FOR(j,1,k){
			if(a[i]<j){
				dp[i][j] = ((sum[i-1][j] - sum[i-1][j-a[i]-1])%mod + mod)%mod;
			}
			else dp[i][j] = sum[i-1][j];
			sum[i][j] = add(sum[i][j-1],dp[i][j]);
		}
	}
	cout << dp[n][k];	

	return 0;
}

Measured memory_bytes: 158080
import sys


if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
T = [MAP() for _ in range(N-1)]

S = [0] * N

for i in range(N-1):
	m = 0
	for j in range(i, N-1):
		c, s, f = T[j]
		# 最初の駅
		if m == 0:
			m += c+s
		else:
			# 2駅目以降に到着してすぐに出発できるケース
			if m % f == 0:
				m = max(s, m)
				m += c
			# 次の電車を待つケース(f分刻みで出発する電車の次のやつに乗りたい)	
			else:
				m = max(s, m+f-(m%f))
				m += c
	S[i] = m

#print(S)

for s in S:
	print(s)

Measured memory_bytes: 40176
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());
//int randt(int l, int r){ return (rando() % (r - l + 1) + l); }

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5;
int mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
ll infll = 1e18 + 7;

int n, k;
int a[10];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n; cout << n * (n + 1) / 2;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 998244353
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n;
    string s;
    cin >> n;
    cin >> s;

    bool ans = false;

    if(n % 2 == 0){
        ans = true;
        rep(i, n / 2){
            if(s[i] != s[i + n / 2]){
                ans = false;
                break;
            }
        }
    }

    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

int main()
{
    long double sum = 0;
    int n;
    cin >> n;
    vector<long double> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++)
    {
        sum += 1/a[i];
    }
    cout << setprecision(18);
    cout << fixed;
    cout << 1/sum;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var list = new List<Tuple<int, int>>();
        for (int i = 0; i < n; i++)
        {
            var tp = new Tuple<int, int>(i+1,a[i]);
            list.Add(tp);
        }
        list = list.OrderBy(f => f.Item2).ToList();
        foreach(var x in list)
        {
            Console.Write("{0} ",x.Item1);
        }
    }
}

Measured memory_bytes: 30424
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &p)
{
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec)
{
  int n = 0;
  for (auto e : vec)
    os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream &operator<<(std::ostream &os, const std::set<T> &st)
{
  int n = 0;
  for (auto e : st)
    os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::map<T, U> &mp)
{
  int n = 0;
  for (auto e : mp)
    os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec)
{
  for (T &e : vec)
    is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out()
{
  std::cerr << '\n';
}

template <class Head, class... Tail>
void debug_out(Head &&head, Tail &&... tail)
{
  std::cerr << head;
  if (sizeof...(Tail) != 0)
    std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

using namespace std;
using int64 = long long;

int main()
{
  int N;
  cin >> N;
  vector<int> D(N);
  cin >> D;
  if (D[0] != 0)
  {
    cout << 0 << endl;
    return 0;
  }
  map<int, int> mp;
  int mx = 0;
  for (int i = 0; i < N; i++)
  {
    mx = max(mx, D[i]);
    if (mp.count(D[i]))
    {
      mp[D[i]]++;
    }
    else
    {
      mp[D[i]] = 1;
    }
  }
  debug(mp);
  if (mp[0] != 1)
  {
    cout << 0 << endl;
    return 0;
  }
  int64 ans = 1;
  for (int i = 1; i <= mx; i++)
  {
    if (!mp.count(D[i]))
    {
      cout << 0 << endl;
      return 0;
    }
    for (int j = 0; j < mp[i]; j++)
    {
      ans *= mp[i - 1];
      ans %= 998244353;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8288
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N,M;
 int ans=0;
 vector <int> cnt(31,0);
 cin >> N >> M;
 for(int i=0;i<N;i++){
   int K;
   cin >> K;
   for(int j=0;j<K;j++){
     int A;
     cin >> A;
     cnt.at(A-1)++;
   }
 }
 for(int i=0;i<M;i++){
   if(cnt.at(i)==N){
     ans++;
   }
 }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

int n, k, m = 500;

int main() {
	scanf("%d", &k);
	if(k <= m) {
		n = k;
		pp("%d\n", n);
		fo(i, 1, n) {
			fo(j, 1, n) pp("%d ", (i + j) % n + 1);
			hh;
		}
	} else {
		n = m;
		pp("%d\n", n);
		fo(i, 1, n) {
			fo(j, 1, n) {
				int x = (i + j) % n + 1;
				if(x <= k - n) pp("%d ", i & 1 ? x : x + n); else
					pp("%d ", x);
			}
			hh;
		}
	}
}


Measured memory_bytes: 1152
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

signed main(){
	int n,m;
	cin>>n>>m;
	int w=sqrt(n)+10;
	vi dp(n+1);
	vvi co(w+1,vi(w+2));
	rep(i,m){
		int a,b;
		cin>>a>>b;
		if(b>=w){
			if(a!=b-1){
				dp[0]+=a+1;
				dp[1]-=a;
				for(int j=b-a-1;j<n;j+=b){
					dp[j]-=b;
					dp[j+1]+=b;
				}
			}else{
				dp[1]+=1;
				for(int j=b;j<n;j+=b){
					dp[j]-=b;
					dp[j+1]+=b;
				}
			}
		}else{
			if(a!=b-1){
				co[b][0]+=a+1;
				co[b][1]-=a;
				for(int j=b-a-1;j<b;j+=b){
					co[b][j]-=b;
					co[b][j+1]+=b;
				}
			}else{
				co[b][1]+=1;
			}
			
		}
	}
//	show2d(co);
	rep(i,n)dp[i+1]+=dp[i];
	rep(i,n)dp[i+1]+=dp[i];
	rep(q,w){
		rep(i,w)co[q][i+1]+=co[q][i];
		rep(i,w)co[q][i+1]+=co[q][i];
	}
	rep(i,n){
		int sum=dp[i];
		rep(j,w)sum+=co[j+1][i%(j+1)];
		cout<<sum<<endl;
	}
}









Measured memory_bytes: 4416
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

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

using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    int ans = n * n * n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
#include<vector>
using namespace std;
int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int cnt=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            int z=n-(i*r+j*g);
            if(0<=z && z%b==0)cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define eb emplace_back
#define vec vector

typedef uint8_t   i8;
typedef uint16_t  i16;
typedef int       i32;
typedef long long i64;

template<class T> bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template<class T> bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T> T gcd(T m, T n) {
  if (n == 0) return m;
  return gcd(n, m % n);
}

template<class T> T lcm(T m, T n) {
  return m * n / gcd(m, n);
}

const i64 inf = 1LL << 60;
const i32 mod = 1e9 + 7;

using namespace std;

/* Input variables. */
i32 n;
string s;

/* Solve! */
void solve() {
  i32 res = 0;
  rep(i, n - 2) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
      res++;
  }
  cout << res << endl;
}

int main() {
  /* Input handling. */
  cin >> n;
  cin >> s;

  solve();
  return 0;
}

Measured memory_bytes: 888
N = int(input())

ls = []
for i in range(N):
    S, P = input().split()
    ls.append((i, S, int(P)))

ls.sort(key=lambda x: x[2], reverse=True)
ls.sort(key=lambda x: x[1])

for l in ls:
    print(l[0] + 1)


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#define LEN 100005

int min(int,int);

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head,tail,n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a,int b){return a<b?a:b;}

int main(){
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d", &n, &q);

  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head=1;
  tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  
  return 0;
}

Measured memory_bytes: 10756
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;

int main(){
	int n,a,b;
	
	cin>>n>>a>>b;
    if (abs(a-b)%2==1) cout<<"Borys";
	else cout<<"Alice";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,k;
	cin>>a>>b>>k;
	if (k<=a)  a-=k;
	else if (k>a&&k<=a+b)
	{
		k=k-a;
		a=0;
		b-=k;
	}
    else a=0,b=0;
    cout<<a<<' '<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

struct test{
    signed short mid;
    signed short fin;
    signed short re;
    unsigned char eval;
};

unsigned char evaluate(signed short mid, signed short fin, signed short re);

int main(){
    struct test test[50];
    unsigned short i;
    unsigned short count = 0;
    for(i = 0;i < 50;i++){
        scanf("%d %d %d", &test[i].mid, &test[i].fin, &test[i].re);
        if(test[i].mid == -1 && test[i].fin == -1 && test[i].re == -1){
            break;
        }
        test[i].eval = evaluate(test[i].mid, test[i].fin, test[i].re);
        count++;
    }
    for(i = 0;i < count;i++){
        printf("%c\n", test[i].eval);
    }
    return 0;
}

unsigned char evaluate(signed short mid, signed short fin, signed short re){
    signed short sum;
    unsigned char result;
    sum = mid + fin;
    if(mid == -1 || fin == -1){
        result = 'F';
    }
    else if(sum >= 80){
        result = 'A';
    }
    else if(sum >= 65){
        result = 'B';
    }
    else if(sum >= 50){
        result = 'C';
    }
    else if(sum >= 30){
        if(re >= 50){
            result = 'C';
        }
        else{
            result = 'D';
        }
    }
    else{
        result = 'F';
    }
    return result;
}


Measured memory_bytes: 2100
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long double ldouble;
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 a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<(((abs(a-c)<=d)||(abs(a-b)<=d&&abs(b-c)<=d))?"Yes":"No");
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int flag = 0;
  rep(i,(int)S.size()){
  if (S[i] != T[i]) {flag=1;break;};
  };
  if ((flag==0) && ((int)S.size() + 1 == (int)T.size()))cout << "Yes"<< endl;
  else cout << "No"<< endl;
}

Measured memory_bytes: 3600
N,K = map(int,input().split())
M = (N-1)*(N-2)//2

if K > M:
    print(-1)
else:
    ans = N-1 + M - K
    print(ans)

    for i in range(1,N):
        print(i,N)
        ans -= 1

    for i in range(1,N):
        for j in range(i+1,N):
            if ans == 0:
                exit()
            else:
                print(i,j)
                ans -= 1

Measured memory_bytes: 74716
N,K=map(int,input().split())
A=list(map(int,input().split()))
memo=[-1]*(N+1)
x=1
begin=-1
loop=[]
for i in range(1,K+1):
    if memo[x] == -1:
        loop.append(x)
        memo[x]=i
        x=A[x-1]
        
    else:
        begin=memo[x]
        stop=i-1
        break
# print('begin', begin)
# print('stop', stop)
loop=loop[begin-1:]



if begin == -1:
    print(x)
else:
    print(loop[(K-begin+1)%(stop-begin+1)])

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

int main(void){
	/*input*/
	int n;
	cin >> n;

	int p[n];
	for(int i = 0; i < n;i++){
		cin >> p[i];
	}

	/*calc*/
	int different_num = 0;
	for(int i = 0; i < n; i++){
		if(p[i] != i+1){
			different_num++;
		}
		if(different_num > 2){
			break;
		}
	}

	/*output*/
	if(different_num <= 2){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256