akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool is_positive(vector<int> &Ai, vector<int> &B, int C) {
  int sum = 0;
  for (int j = 0; j < Ai.size(); ++j) {
    sum += Ai[j] * B[j];
  }
  sum += C;
  if (sum > 0) return true;
  return false;
}

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i = 0; i < M; ++i) {
    cin >> B[i];
  }

  int ans = 0;
  vector<int> Ai(M);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      cin >> Ai[j];
    }
    if (is_positive(Ai, B, C)) ans += 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			
			if(m == -1 && f == -1 && r == -1) {
				break;
			} else if(m == -1 || f == -1) {
				System.out.println("F");
			} else if(m + f >= 80) {
				System.out.println("A");
			} else if(m + f >= 65) {
				System.out.println("B");
			} else if(m + f >= 50) {
				System.out.println("C");
			} else if(m + f >= 30) {
				if(r >= 50){
					System.out.println("C");
				} else {
					System.out.println("D");
				}
			} else {
				System.out.println("F");
			}
		}
		sc.close();
	}

}

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

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    int n,d;
    cin>>n>>d;
    int ans=0;
    int t=d+d+1;
    ans = n/t;
    if(n%t) ans++;
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const string YES = "Yes";
const string NO = "No";
 
void solve(long long a, long long b, long long c){

    long long i = c-a-b;

    if(i>0 && 4*a*b < (i*i)){
        cout << YES << endl;
        return;
    }
    cout << NO << endl;
 
}
 
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
now_max = 0
count = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1
    else:
        if now_max < count:
            now_max = count
        count = 0
    if now_max < count:
        now_max = count
    
print(now_max)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
void dfs(long long int x, vector<long long int> adj[],long long int dp[], bool vis[]) 
{ 
    
    vis[x] = true; 
  
     
    for (long long int i = 0; i < adj[x].size(); i++) { 
  
        
        if (!vis[adj[x][i]]) 
            dfs(adj[x][i], adj, dp, vis); 
  
        
        dp[x] = max(dp[x], 1 + dp[adj[x][i]]); 
    } 
} 
int main() 
{   
  

 
long long int n,m;
scanf("%lld %lld",&n,&m);

vector<long long int>adj[n+1];
    for(long long int i = 0; i <m; i++){
   long long int x,y;
scanf("%lld %lld",&x,&y);
adj[x].push_back(y);
}
long long int dp[n+1];
memset(dp, 0, sizeof dp); 
bool vis[n + 1]; 
    memset(vis, false, sizeof vis); 
    for(long long int i = 1; i <=n; i++){
   if(!vis[i])
dfs(i,adj,dp,vis);

}
long long int sum=0;
 for(long long int i = 1; i <=n; i++){
  sum=max(sum,dp[i]);
}

printf("%lld\n",sum);



}

  
 

Measured memory_bytes: 9984
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    a,tmp = list(map(int,input().split())),0
    for j in range(m):
        tmp+=a[j]*b[j]
    if tmp+c>0: ans+=1
print(ans)

Measured memory_bytes: 3064
from math import ceil
N,A,B=map(int,input().split())
if N+1<A+B or A*B<N:
  print(-1)
  exit()

t=N//B
s=[]
while N>0:
  if N==A:
    s.append(list(range(1,N+1)))
    break
  if N-B>=A-1:
    s.append(list(range(N,N-B,-1)))
    N-=B
    A-=1
    continue  
  s.append(list(range(N,A-1,-1)))
  s.append(list(range(1,A)))
  break
ans=[]
s.reverse()
for a in s:
  ans.append(' '.join(map(str,a)))
 
print(' '.join(ans))

Measured memory_bytes: 99480
#include <stdio.h>
int main (){

int h = 0;
int w = 0;
int i = 0;
int j = 0;
int a = 0;

while(1){

scanf("%d %d",&h,&w);

if (h == 0 && w == 0) break;

for (i = 0;i<h-1;i++){
if (i == 0){
for (a = 1;a<w;a++){
printf("#");
}
printf("#\n");
}else if (i == h-2){
for (a = 1;a<w;a++){
printf("#");
}
printf("#\n");
continue;
}

for (j = 0;j<w;j++){
if (j == 0){
printf ("#");
}else if (j == w-1){
printf("#\n");
}else{
printf(".");
}
}
}
printf ("\n");
}
return 0;
}


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

using namespace std;

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

int main(){
  int N, A, B;
  cin >> N >> A >> B;

  int tmp=0;

  rep(i, N+1){
    int value=0;
    int con = i;
    rep(j,5){
      value += con%10;
      con /= 10;
    }
    if((A<=value)&&(value<=B)) tmp += i;
  }

  cout << tmp << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;
int n;
vector<int>vec;
void input();

void solve(){
    int cnt = 0;
    for(int i=0;i<n;i++){
        if((i+1)%2==1 && vec[i]%2==1)cnt++;
    }
    cout<<cnt<<"\n";
}

void Clear(){

}

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

    input();
    solve();
    Clear();
}

void input(){
    cin>>n;
    for(int i=0;i<n;i++){
        int  a;
        cin>>a;
        vec.pb(a);
    }
}


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

int main() {
	int x;
	int count = 0;

	while (1) {
		scanf("%d ", &x);
		
		if(x != 0) {
			count += 1;
			printf("Case %d: %d\n", count, x);
			//cout << "Case " << count << ": " << x << endl;
		}
		else {
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 3180
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,m,k=mp()
A=lmp()
B=lmp()
a=[A[0]]
b=[B[0]]
for i in range(1,n):
    a.append(a[i-1]+A[i])
for i in range(1,m):
    b.append(b[i-1]+B[i])
a.insert(0,0)
b.insert(0,0)
a.append(float("inf"))
b.append(float("inf"))
ans=0

ind=bisect.bisect_right(a,k)
j=0
ans=ind-1
for i in range(ind-1,-1,-1):
    while a[i]+b[j]>k or a[i]+b[j+1]<=k:
        j+=1
    ans=max(ans,i+j)
print(ans)

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

int main() {
  int n, m;
  cin>>n>>m;

  std::vector<int> requests;
  for (int i = 0; i < m; ++i) {
    int e;
    cin>>e;
    requests.push_back(e);
  }

  std::set<int> used;
  for (int i = m - 1; i >= 0; --i) {
    if (used.find(requests[i]) == used.end()) {
      cout << requests[i] << endl;
      used.insert(requests[i]);
    }
  }
  for (int i = 0; i < n; ++i) {
    if (used.find(i + 1) == used.end()) {
      cout << i + 1 << endl;
    }
  }
}

Measured memory_bytes: 7872
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
const int mod = 1000000007;
#define Yes(ifeq) cout<<((ifeq)? "Yes":"No")<<endl;

void Main(){
  int x,y,z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout<<x<<" "<<y<<" "<<z<<" "<<endl;
  

} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int a, b, sum = 0;
    cin >> a >> b;
    REP(i, b - a) {
        sum += i;
    }
    cout << sum - a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    vector <bool>  exist(n+1) ;
    vector <int> data(n+1);
    int ans = 0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a<=n) {data[a]++; exist[a]=true;}
        else ans++;
    }
    for(int i=1;i<=n;i++){
        if(exist[i]){
        if(data[i]>=i) ans += data[i]-i;
        else ans+= data[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
int div, rem;
double a, b, divr;
cin >> a >> b;
div = a / b;
rem = fmod(a,b);
divr = a / b;
cout << div << " " << rem << " ";
cout << setprecision(10) << fixed;
cout << divr << endl;
return 0;
}


Measured memory_bytes: 3324
import sys
input=sys.stdin.readline

def main():
    N = int(input())
    B = list(map(int, input().split()))
    A = [0]*N
    A[0] = B[0]
    for i in range(1,N-1):
        A[i] = min(B[i-1],B[i])
    A[N-1] = B[N-2]
    print(sum(A))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sanyes ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long int
#define pb push_back
#define bpc __builtin_popcount
#define f first
#define s second

const llong mxn = 1e5 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

llong n, l, r, a[mxn], dp[mxn][2], cnt[2];

int main(){
    cin >> n >> l >> r;
    if(n == 1 && r == l){
        cout << 1;
    }else if(n > 1 && r >= l){
        cout << (n - 2) * (r - l) + 1;
    }else{
        cout << 0;
    }
    return 0;
}


Measured memory_bytes: 256
a,b=input().split()
if int(a)>0 :
    if a>b:
        print("a > b")
    elif a<b:
        print("a < b")
    else:
        print("a == b")
else:
    if a>b:
        print("a < b")
    elif a<b:
        print("a > b")
    else:
        print("a == b")


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
	ll n, c;
	cin >> n >> c;

	vector<pair<ll, int> > v(n);

	for(int i=0; i<n; i++){
		cin >> v[i].first >> v[i].second;
	}

	ll curv=0;
	vector<ll> maxlo(n), maxlr(n);
	ll maxloi=0, maxlri=0;
	for(int i=0; i<n; i++){
		curv+=v[i].second;
		maxloi=max(maxloi, curv-v[i].first);
		maxlri=max(maxlri, curv-2*v[i].first);
		maxlo[i]=maxloi;
		maxlr[i]=maxlri;
	}
	curv=0;
	ll maxroi=0, maxrri=0, res=0;
	res=maxlo[n-1];
	for(int i=n-1; 0<=i; i--){
		curv+=v[i].second;
		maxroi=max(maxroi, curv-(c-v[i].first));
		maxrri=max(maxrri, curv-2*(c-v[i].first));
		if(i!=0) res=max({res,
			              maxroi,
				          maxroi+maxlr[i-1],
		                  maxrri+maxlo[i-1]});
	}
	res=max({res, maxroi, 0ll});

	cout << res << endl;

	return 0;

}


Measured memory_bytes: 3456
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 2 * 1e5 + 5;
string s;

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


int main() {
	int n = 0, cntm = 0, cnte = 0, cnt = 0;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		if(a[i] % 4 == 0){
			++cntm;
		}
		else if(a[i] % 2 == 0){
			++cnte;
		}
		else{
			++cnt;
		}
	}
	if(cnte == 0){
		if(cnt <= cntm+1){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	else{
		if(cnt <= cntm){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}

    return 0;
}

Measured memory_bytes: 640
// Submitted By Subhash Yadav
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Scanner;

import java.util.*;

public class Main {
	static int ans;
	public static ArrayList<Integer>[] adjArrayLists;
	static boolean visited[];
	public static void dfs(int src) {
		visited[src]=true;
		ans++;
		for(int u:adjArrayLists[src]) {
			if(!visited[u])
				dfs(u);
		}
		
	}

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

		FastScanner sc = new FastScanner();
		int n=sc.nextInt(),m=sc.nextInt();
		adjArrayLists=new ArrayList[n+1];
		for(int i=0;i<=n;i++) adjArrayLists[i]=new ArrayList<>();
				
		for(int i=0;i<m;i++) {
			int x=sc.nextInt(),y=sc.nextInt();
			adjArrayLists[x].add(y);
			adjArrayLists[y].add(x);
		}
		visited=new boolean[n+1];
		int res=Integer.MIN_VALUE;
		for(int i=1;i<=n;i++) {
			if(!visited[i]) {
				ans=0;
				dfs(i);
				res=Math.max(res, ans);
			}
		}
		System.out.println(res);

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}

Measured memory_bytes: 104824
#include<iostream>
#include<cstdio>
#include<cstring>
const int N=101000;
int n,m;
int main()
{
	scanf("%d",&n);
	m=0;
	for(int i=1,x;i<=n;i++)
		scanf("%d",&x),m^=(x&1);
	if(n==1 || m==0)printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll h,w,n;
	cin >> h >> w >> n;
	map<pair<int, int>, int> mp;
	REP(i,n){
		int a,b;
		cin >> a >> b;
		REP(i,9){
			int x = b + dx[i];
			int y = a + dy[i];
			if(x<2 || w<=x || y<2 || h<=y) continue;
			mp[pair<int, int>(x,y)]++;
		}
	}
	
	map<int, int> ans;
	for(auto itr: mp){
		ans[itr.second]++;
	}
	cout << (h-2)*(w-2) - mp.size() << '\n';
	FOR(j,1,10){
		cout << ans[j] << '\n';
	}
	
	return 0;
}



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

int main(){
    int n, x;
    cin >> n >> x;
    int l[n];
    for(int i = 0; i < n; i++){
        cin  >> l[i];
    }
    int ans = 1;
    int d = 0;
    for(int i = 0; i < n; i++){
        d = d + l[i];
        if(d <= x){
            ans++;
        } else {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> Input[i];
  }

  int ans = 1;
  int height = Input[0];
  for (int i = 1; i < N; i++) {
    if (height <= Input[i]) {
      ans++;
      height = Input[i];
    }
  }

  cout << ans << endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    string s;
    cin >> s;
    if(s == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }
    if(s.size() < 26){
        char buf = 'a';
        while(true){
            bool checker = true;
            for(int i = 0; i < s.size(); i++){
                if(buf == s[i]){
                    buf++;
                    checker = false;
                    break;
                }
            }
            if(checker){
                cout << s << buf << endl;
                return 0;
            }
        }
    }
    for(int i = 25; i >= 0; i--){
        for(int j = 25; j > i; j--){
            if(s[i] < s[j]){
                for(int k = 0; k < i; k++){
                    cout << s[k];
                }
                cout << s[j] << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(p[i] != i+1) cnt++;
    }
    if(cnt == 0 || cnt == 2) cout << "YES\n";
    else cout << "NO\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	ll L,R;
	cin >> L >> R;
	if(R-L >= 2019){
		cout << 0 << endl;
	}else{
		ll res = 2019;
		for(ll x = L; x < R; x++) for(ll y = x+1; y <=R; y++){
			chmin(res,x*y%2019);
		}
		cout << res << endl;
	}
}


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

int main(){
  long long N, K, c = 0, ans;
  cin >> N >> K;
  vector<pair<long long,long long>> a(N);
  for(int i = 0; i < N; i++)
    cin >> a[i].first >> a[i].second;
  sort(a.begin(),a.end());
  /*for(int i = 0; i < N; i++)
    cout << a[i].first << "," << a[i].second << endl;*/
  for(int i = 0; c < K; i++){
    ans = a[i].first;
    c += a[i].second;
  }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define LL long long
#define rgi register int
#define rgl register long long
#define il inline

il int read() {
	rgi x = 0, f = 0, ch;
	while(!isdigit(ch = getchar())) f |= ch == '-';
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

int main() {
	int n, tot;
	char S[100010], T[100010], ans[100010];
	n = read();
	scanf("%s %s", S + 1, T + 1);
	for(rgi i = 1; i <= n; ++i) {
		ans[++tot] = S[i];
		ans[++tot] = T[i];
	}
	for(rgi i = 1; i <= tot; ++i) printf("%c", ans[i]);
	return 0;
}


Measured memory_bytes: 256
N, L = map(int, input().split())
S = sum([L + i for i in range(N)])
result_d = 10 ** 9
result = 0
for i in range(N):
    r = S - (L + i)
    if abs(S - r) < result_d:
        result_d = abs(S - r)
        result = r
print(result)


Measured memory_bytes: 2940
import math
import itertools
import collections
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
MOD = 10**9 + 7

N = IN()
lis = [0]*N

for x in range(1,10**2 + 1):
  for y in range(1,10**2 + 1):
    for z in range(1,10**2 + 1):
      n = x**2 + y**2 + z**2 + x*y + y*z + z*x 
      if n > N:
        continue
      else:
        lis[n-1] += 1
      
for i in lis:
  print(i)

Measured memory_bytes: 9628
#include<iostream>
using namespace std;
int main() {
	long max = -1000000001, min, time;
	cin >> time;
	int code[200000];
	for (int i= 0; i < time; ++i){
		cin >> code[i];
	}
	min = code[0];
	for (int i = 1; i < time; ++i) {
		if (max < code[i] - min) {
			max = code[i] - min;
		}
		if (min > code[i]) {
			min = code[i];
		}
	}
	cout << max << endl;
	return 0;
}

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


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	//bit
	string T = "";
	if (n == 0) {
		cout << 0 << endl;
		return 0;
	}
	while (n != 1) {
		if (n < 0) {
			if (n % 2 == 0) {
				n = n / (-2);
				T += "0";
			}
			else {
				n = n / (-2) + 1;
				T += "1";
			}
		}
		else {
			if (n % 2 == 0) {
				n = n / (-2);
				T += "0";
			}
			else {
				n = n / (-2);
				T += "1";
			}
		}
	}
	T += '1';
	reverse(T.begin(), T.end());
	cout << T << endl;
 	return 0;
}

Measured memory_bytes: 256
mod=10**6+3
frac=[1]
for i in range(1,10**6+3):
    frac.append((frac[-1]*i)%mod)

inv=[pow(frac[i],mod-2,mod) for i in range(len(frac))]

for _ in range(int(input())):
    x,d,n=map(int,input().split())
    if d==0:
        print(pow(x,n,mod))
    elif n>=mod:
        print(0)
    else:
        c=(x*pow(d,mod-2,mod))%mod
        if c==0 or c+n-1>=mod:
            print(0)
        else:
            ans=frac[c+n-1]*inv[c-1]*pow(d,n,mod)
            ans%=mod
            print(ans)


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

int main()
{
   long long n,x,k,sum=0;
   cin>>n>>k;
   long long a[n];
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   sort(a,a+n,greater<int>());
   for(int i=k;i<n;i++)
   {
       sum+=a[i];
   }
   cout<<sum;
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	double r;
	cin >> r;
	cout << 2*r*3.1415926535 << endl;
	return 0;
}


Measured memory_bytes: 3788
from string import ascii_lowercase
S = input()
if not S[0] is 'A' or not 'C' in S[2:-1]:
    print('WA'),exit()
for i in range(1,len(S)):
    if i == S.index('C'):
        continue
    if not S[i] in ascii_lowercase:
        print('WA'),exit()
print('AC')
# S[2:-1] in 'C'
# S.remove('A'),S.remove('C')
# S is all lower


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	const int INF = 1e8;
	int H, W;
	cin >> H >> W;
	vector<string> a(H);
	for (int i = 0; i < H; ++i) { cin >> a[i]; }

	vector<vector<int>> grid(H, vector<int>(W, INF));
	deque<P> que;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (a[i][j] == '#') {
				que.push_back(P(i, j));
				grid[i][j] = 0;
			}
		}
	}

	int dx[4] = { 1, 0, -1, 0 };
	int dy[4] = { 0, 1, 0, -1 };
	while (!que.empty()) {
		P p = que.front();
		que.pop_front();

		int x = p.second, y = p.first;
		for (int k = 0; k < 4; ++k) {
			int nx = x + dx[k];
			int ny = y + dy[k];
			if ((nx >= 0) && (nx < W) && (ny >= 0) && (ny < H)) {
				if (grid[ny][nx] == INF) {
					que.push_back(P(ny, nx));
					grid[ny][nx] = grid[y][x] + 1;
				}
			}
		}
	}

	int res = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			res = max(res, grid[i][j]);
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 13456
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int a;
	
	cin >> a;
	syc(a,1,100);
	
	for(int i=1;i<10;i++){
		for(int j=i;j<10;j++){
			//cout << i << j << endl;
			if(a == i*j){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
			
	cout << "No" << endl;
	
	return 0;
}


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

int main(void) {
  int x, joy=0, fh, f; cin >> x;
  
  fh = x / 500;
  joy += fh * 1000; 
  x -= fh * 500;

  f = x / 5;
  joy += f * 5;
  
  cout << joy << endl;
  return 0;
}

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

int main() {

	int R,G,B,N;
	int ans = 0;
	cin >> R >> G >> B >> N;

	int tmp = 0;

	for (int i = 0; i <= 3000; i++) {
		if (R*i > N)break;
		tmp += R*i;
		for (int j = 0; j <= 3000; j++) {
			if (R*i + G*j > N)break;
			if ((N - R * i - G * j) % B == 0) {
				ans++;
			}
		}
	
	}
	cout << ans << endl;

}

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

pattern = ["."] * N
for i in range(M):
  s,c = input().split()
  s = int(s)
  if pattern[s - 1] not in (".",c):
    print(-1)
    exit(0)
  pattern[s - 1] = c

import re

comp = re.compile("^" + "".join(pattern) + "$")

for i in range(10 ** N):
  res = comp.match(str(i))
  if res:
    print(i)
    break
else:
  print(-1)


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

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

	int C=1;
	while(true){
		int W=in();
		if(!W) break;
		int N=in();
		vector<int> v(N),w(N);
		REP(i,N){
			scanf("%d,%d",&v[i],&w[i]);
		}

		vector<vector<int>> dp(N+1,vector<int>(W+1,0));

		REP(i,N){
			REP(j,W+1){
				if(j+w[i]<=W) chmax(dp[i+1][j+w[i]],dp[i][j]+v[i]);
				chmax(dp[i+1][j],dp[i][j]);
			}
		}
		int AW=0,AV=0;
		REP(i,W+1){
			if(dp[N][i]>AV){
				AV = dp[N][i];
				AW = i;
			}
		}
		printf("Case %d:\n",C++);
		out(AV);
		out(AW);
	}
	return 0;
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a > c) swap(a, c), swap(b, d);
    if (b < c) cout << 0 << endl;
    else 
        if (d < b) cout << d - c << endl;
        else cout << b - c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int x;

    scanf("%d", &x);
    
    switch (x % 7){
      case 0:
        printf("thu\n");
        break;

      case 1:
        printf("fri\n");
        break;

      case 2:
        printf("sat\n");
        break;

      case 3:
        printf("sun\n");
        break;

      case 4:
        printf("mon\n");
        break;

      case 5:
        printf("tue\n");
        break;

      case 6:
        printf("wed\n");
        break;
    }

    return (0);
}




Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

int H,W,h,w;
int g[505][505]={};

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> H >> W >> h >> w;
	swap(W,H);
	swap(w,h);
	ll sm = W*H;

	for(int i = 1; i <= W; ++i)
		for(int j = 1; j <= H; ++j)
			g[i][j] = 1;

	for(int i = w; i <= W; i += w) {
		for(int j = h; j <= H; j += h) {
			g[i][j] = -h*w;
			sm = sm-1-h*w;
		}
	}
	if(sm <= 0 && W%w == 0 && H%h == 0) cout << "No\n";
	else {
		while(sm <= 0) {
			for(int i = 1; i <= W; ++i) {
				for(int j = 1; j <= H; ++j) {
					sm -= g[i][j];
					if(g[i][j] > 0) g[i][j] = g[i][j]*2;
					else g[i][j] = g[i][j]*2+1;
					sm += g[i][j];
				}
			}
		}
		cout << "Yes\n";
		for(int i = 1; i <= W; ++i) {
			for(int j = 1; j <= H; ++j) {
				if(j!=1) cout << " ";
				cout << g[i][j];
			}
			cout << "\n";
		}
	}


	return 0;
}

Measured memory_bytes: 2304
#include<stdio.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define lln long long int
#define INF 1LL << 50


int main(){

	lln a[2000],b[2000],c[2000],n,m;
	lln dist[1000],nega[1000],ans;

	scanf("%lld %lld",&n,&m);

	FOR(i,0,m){
		scanf("%lld %lld %lld",&a[i],&b[i],&c[i]);
		c[i] = - c[i];
	}

	FOR(i,0,n){
		dist[i] = INF;
	}

	FOR(i,0,n){
		nega[i] = 0;
	}



	dist[0] = 0;

	FOR(loop,0,n-1){
		FOR(i,0,m){
			if(dist[a[i]-1] == INF) continue;

			if(dist[b[i]-1] > dist[a[i]-1] + c[i]){
				dist[b[i]-1] = dist[a[i]-1] + c[i];
			}
		}
	}

	ans = dist[n-1];

	FOR(loop,0,n){
		FOR(i,0,m){
			if(dist[a[i] - 1] == INF) continue;

			if(dist[b[i] - 1] > dist[a[i]-1] + c[i]){
				dist[b[i] - 1] = dist[a[i]-1] + c[i];
				nega[b[i] - 1] = 1;
			}

			if(nega[a[i] - 1] == 1){
				nega[b[i] - 1] = 1;
			}
		}
	}

	if(nega[n - 1] == 1)	printf("inf\n");
	else 					printf("%lld\n",-ans);

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char s;
  cin >> s;
  if (s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o'){
  cout <<"vowel";
  }else{
  cout << "consonant";
  } 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define int long long
#define hell 1000000007 
#define endl "\n"
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX_SIZE 200002

int n, q;
int scores[MAX_SIZE]={0};
int final_scores[MAX_SIZE] = {0};
vector<int> v[MAX_SIZE];
map<int, int> visited;

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

void dfs(int node, int score)
{
    visited[node] =1;
    final_scores[node] = scores[node] + score;
    score = final_scores[node];

    for(auto x:v[node])
    {
        if(!visited[x])
        {
            dfs(x, score);
        }
    }

}



int32_t main()
{
    cin>>n>>q;
    int a, b;

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

    for(int i=0;i<q;i++)
    {
        cin>>a>>b;
        scores[a] += b;
    }

    dfs(1, 0);

    for(int i=1;i<=n;i++)
        cout<<final_scores[i]<<" ";

return 0;
}   

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

int main(){    
    int N; cin >> N;
    vector<int> A(100010, 0);
    int long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        A[a] += 1;
        sum += a;
    }

    int Q; cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        int b, c; cin >> b >> c;
        sum += c*A[b] - b*A[b];
        A[c] += A[b];
        A[b] = 0;
        cout << sum << endl;
    }
    
}

Measured memory_bytes: 3780
import java.io.BufferedReader
import java.io.InputStreamReader

fun main(args: Array<String>) {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val n = br.readLine()
    var flag = false
    for (i in 0..1) {
        flag = flag or (n[i] == n[i+1] && n[i] == n[i+2])
    }
    println(if (flag) "Yes" else "No")
}

Measured memory_bytes: 31396
def stacker(l):
  stack=[0]
  a=0
  b=0
  for i in l:
    if i=="+":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a+b)
    elif i=="-":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(-a+b)
    elif i=="*":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a*b)
    else:
      stack.append(i)
  print(stack[-1])
l=list(input().split())
stacker(l)


Measured memory_bytes: 5600
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store,no-stack-protector")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "#" << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double;  using ui = uint_fast32_t;
using ll = int_fast64_t; using ul = uint_fast64_t;

// -----------------------------------------------------------------------------

void solve() {
    int r; cin >> r;
    ld MATH_PI = 6.28318530717958623200;
    cout << MATH_PI * r << '\n';
}

// -----------------------------------------------------------------------------

int main() {
    fast_io; cout_precision;
#ifdef LOCAL
    cin_exception;
#endif
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }
}

Measured memory_bytes: 3792
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<climits>
using namespace std;
void File(){
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
}
template<typename T>bool chkmax(T &_,T __){return _<__ ? (_=__,1) : 0;}
template<typename T>bool chkmin(T &_,T __){return _>__ ? (_=__,1) : 0;}
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
#define MREP(i,x) for(register int i=beg[x];i;i=E[i].last)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define inf INT_MAX
const ll mod=998244353;
const int maxn=3e5+10;
ll x,y,n,k,C[maxn],inv[maxn];
ll qpow(ll f,ll b){
	ll base=f,ret=1ll;
	while(b){
		if(b&1)ret=ret*base%mod;	
		base=base*base%mod;
		b>>=1;
	}
	return ret;
}
ll ans;
ll zuhe(ll _,ll __){return C[_]*inv[_-__]%mod*inv[__]%mod;}
int main(){
	//File();
	ll a,b;
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	C[0]=1ll;
	REP(i,1,n)C[i]=C[i-1]*i%mod;
	inv[n]=qpow(C[n],mod-2);
	DREP(i,n-1,0)inv[i]=inv[i+1]*(i+1)%mod;
	REP(i,0,n){
		ll num;
		if(i*a>k)continue;
		if((k-i*a)%b)continue;
		num=(k-i*a)/b;
		if(max((ll)i,num)>n)continue;
		ans=(ans+zuhe(n,i)*zuhe(n,num)%mod)%mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4992
# coding: utf-8
import sys

N,M,X,Y = map(int,input().strip().split())
xs = list(map(int,input().strip().split()))
ys = list(map(int,input().strip().split()))

def main():
    Zs = list(range(X+1,Y+1))
    for _ in Zs:
        if max(xs) < _ <= min(ys):
            print("No War")
            sys.exit()
    print("War")

if __name__ == '__main__':
    main()
    

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

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> a(m);
	for (int i = 0;i < m;i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int sum = 0, sum2 = 0;
	for (int i = 0;i < m;i++) {
		if (a[i] < x) {
			sum++;
		}
		else {
			sum2++;
		}
	}
	cout << min(sum, sum2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

const int mod = 1000000007;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint p(int n, int k)
    {
        return fact[n] * ifact[n - k];
    }
} c(1000005);

vector<pair<long long, int>> factorize(long long N)
{
    vector<pair<long long, int>> res;
    for (long long i = 2; i * i <= N; i++)
    {
        if (N % i != 0)
            continue;
        res.emplace_back(i, 0);
        while (N % i == 0)
        {
            N /= i;
            res.back().second++;
        }
    }
    if (N != 1)
        res.emplace_back(N, 1);
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, int>> factor = factorize(M);
    mint ans = 1;
    for (auto it : factor)
    {
        // cerr << it.second + 1 << endl;
        ans *= c(it.second + N - 1, N - 1);
    }
    cout << ans << endl;
    return 0;
}

// it.second + N-1個の数字と仕切りの場所からN-1個の仕切りの場所を選ぶと考える．その他の解説は公式のeditrial参照．


Measured memory_bytes: 18588
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i].first;
        a[i].second = i+1;
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        cout << a[i].second << " ";
    }
    return 0;
}


Measured memory_bytes: 1536
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        long m = sc.nextLong();
        long ans = 0;

        if(n * 2 <= m){
            ans += n;
            m -= n * 2;
            ans += m / 4;
        }else{
            ans += m / 2;

        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
import numpy as np 
import bisect
N,M,K = map(int,input().split())
a_list = np.array([0]+list(map(int,input().split())))
b_list = np.array(list(map(int,input().split())))


a_list = a_list.cumsum()
b_list = b_list.cumsum()

max_cnt = 0
for i in range(N+1):
    if a_list[i]>K:
        continue
    cnt = i
    bT = K - a_list[i] + 1
    cnt += bisect.bisect_left(b_list,bT)
    if cnt >max_cnt:
        max_cnt = cnt

print(max_cnt)




Measured memory_bytes: 53896
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int n, k, a[N], b[N];

main () {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];

	while (k--) {
		memset(b, 0, sizeof(b));
		for (int i = 1; i <= n; ++i) {
			++b[max(1, i - a[i])];
			--b[min(n, i + a[i]) + 1];
		}

		bool ok = 1;
		for (int i = 1; i <= n; ++i) {
			b[i] += b[i - 1];	
			a[i] = b[i];
			if (a[i] < n)
				ok = 0;
		}

		if (ok)
			break;			
	}
	for (int i = 1; i <= n; ++i)
		cout << a[i] << ' ';
}


Measured memory_bytes: 5180
h, w = map(int, input().split())
a = [['#']*(w+2) for _ in [0]*(h+2)]
print(''.join(a[0]))
for x in range(1, h+1):
    line = input().rstrip()
    a[x][1:w+1] = line
    print(''.join(a[x]))
print(''.join(a[h+1]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, m, p = 1000000007;
  cin >> n >> m;
  vll a(m);
  for (ll i = 0; i < m; i++) cin >> a[i];
  vll dp(n + 1);
  dp[0] = 1;
  ll check_next = 0;
  if (m > 0 && a[0] == 1) {
    dp[1] = 0;
    check_next++;
  }
  else dp[1] = 1;
  for (ll i = 2; i <= n; i++) {
    ll is_broken = 0;
    for (ll j = check_next; j < m; j++) {
      if (i == a[j]) {
        is_broken = 1;
        check_next = j + 1;
        break;
      }
      if (i < a[j]) {
        check_next = j;
        break;
      }
    }
    if (is_broken == 0) dp[i] = (dp[i - 2] + dp[i - 1]) % p;
    else dp[i] = 0;
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)1000000000000

int main() {
  ll N,K;
  cin>>N>>K;
  vector<P>A(N);
  int memoflag=0;
  int cnt=0;
  rep(i,N){
    ll g;
    cin>>g;
    if(g<0){A[i]=P(-1ll*g,-1);cnt++;}
    else{A[i]=P(g,1);if(g>0){memoflag=1;}}
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  stack<ll>sei;
  stack<ll>hu;
  rep(i,K){
    auto t=A[i];
    if(t.second==1){sei.push(t.first);}
    else{hu.push(t.first);}
  }
  queue<ll>SS;
  queue<ll>HH;
  for(int i=K;i<N;i++){
    auto t=A[i];
    if(t.second==1){SS.push(t.first);}
    else{HH.push(t.first);}
  }
  ll ans=1ll;
  //積が負になる例外処理
  if(memoflag==0&&K%2==1){
    reverse(A.begin(),A.end());
    rep(i,K){
      ans*=A[i].first*(-1ll);
      ans+=MOD;
      ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
  }
  if(memoflag==0&&(cnt<K)){
    
    cout<<0<<endl;
    return 0;
  }
  //このままかけて正になるとき
  if(hu.size()%2==0){
    while(!sei.empty()){
    ans*=sei.top();sei.pop();
    ans%=MOD;
  }
  while(!hu.empty()){
    ans*=hu.top();hu.pop();
    ans%=MOD;
  }
    ans+=MOD;ans%=MOD;
    cout<<ans;
    return 0;
  }
  //このままだと負のとき
  if(hu.size()%2==1){
    if(sei.empty()){sei.push(SS.front());hu.pop();}//ok
    else if(SS.empty()&&!HH.empty()){sei.pop();hu.push(HH.front());}//ok
    else if(HH.empty()&&!SS.empty()){hu.pop();sei.push(SS.front());}//ok
    else if(HH.empty()&&SS.empty()){}
   else{ll g=SS.front()*sei.top();
    ll h=HH.front()*hu.top();
    if(g>h){hu.pop();sei.push(SS.front());}
    else{sei.pop();hu.push(HH.front());}
   }      
  }
  while(!sei.empty()){
    ans*=sei.top();sei.pop();
    ans%=MOD;
  }
  while(!hu.empty()){
    ans*=(-1ll)*hu.top();hu.pop();
    ans+=MOD;
    ans%=MOD;
    ans+=MOD;
    ans%=MOD;
  }
  ans+=MOD;
  ans%=MOD;
  cout<<ans;
}

Measured memory_bytes: 8024