akhauriyash/Code-Regression huggingface dataset:
n,m = map(int,input().split())
a = sorted(list(map(int,input().split())))
bc = [list(map(int,input().split())) for i in range(m)]
bc.sort(key = lambda x:x[1],reverse=True)
ind = 0
c = 0
for i in range(n):
    if a[i]<bc[ind][1]:
        a[i] = bc[ind][1]
        c += 1
        if bc[ind][0]==c:
            ind += 1
            c = 0
            if ind>m-1:break

print(sum(a))


Measured memory_bytes: 32872
#include<iostream>
using namespace std;
int main()
{
	int H, W, i,j;
	while (1)
	{
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (i = 1; i <= H; i++)
		{
			for (j = 1; j <= W; j++)
			{
				if ((i%2==0&&j%2==0)||(i%2==1&&j%2==1))cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include<iostream>

using namespace std; 

int main()
{
	int N,K;
	char a[100000];
	cin>>N;
	cin>>K;
	for(int i=0;i<N;i++)
	{
		cin>>a[i];
	}	
	int m=1;
	char n=a[0];
	for(int i=0;i<N;i++)
	{
		
		if(n==a[i]);
		else {
			m++;
			n=a[i];		
		}
	}
	int M=N-m;
	for(int j=K;K>0;K--)
	{
		m-=2;
		if(m>0) M+=2;
		else if(m<0) break;
		 else
			{
			M+=1;
			break;
			} 			
	}
	cout<<M;
	return 0;
 } 

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

int main(){
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	int cost = 0;
	if(K < N){
		cost += K * X;
		cost += (N - K) * Y;
	}
	else{
		cost = N * X;
	}
	cout << cost << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();
        String s = fs.next();

        int ans = 0;
        for (int i = 0; i < 1000; ++i) {
            String tmp = Integer.toString(i);
            if (tmp.length() == 1) {
                tmp = "0" + "0" + tmp;
            }
            if (tmp.length() == 2) {
                tmp = "0" + tmp;
            }
            int idx = 0;
            for (int j = 0; j < s.length(); ++j) {
                if (tmp.charAt(idx) == s.charAt(j)) {
                    ++idx;
                    if (idx == 3) {
                        ++ans;
                        break;
                    }
                }
            }
        }

        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

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

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

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




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

const int N = 100006;

int main ()
{
    int n,x;
    scanf("%d %d",&n,&x);
    int gcd = 0;
    for (int i=1;i<=n;++i)
    {
        int y;
        scanf("%d",&y);
        y -= x;
        y = abs(y);
        gcd = __gcd(gcd,y);
    }
    printf("%d\n",gcd);
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int N, D;
        cin >> N;

        vector<pair<string, int>> vec(N), A(N);

        for (int i = 0; i < N; i++)
        {
                string S;
                int num;
                cin >> S >> num;
                num *= -1;

                vec[i] = make_pair(S, num);
                A[i] = make_pair(S, num);
        }

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

        for (int i = 0; i < N; i++)
        {
                for (int j = 0; j < N; j++)
                {
                        if (vec[i] == A[j])
                        {
                                cout << j + 1 << endl;
                        }
                }
        }

        return 0;
}


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

int main() {
        const int N = 10;
        const int T =  3;
        vector<int> W(N);
        vector<int> K(N);
        int wt = 0, kt = 0;

        rep(n, N) {
                cin >> W.at(n);
        }
        rep(n, N) {
                cin >> K.at(n);
        }
        sort(W.begin(), W.end(), greater<int>());
        sort(K.begin(), K.end(), greater<int>());
        rep(i, 3) {
                wt += W.at(i);
                kt += K.at(i);
        }
        cout << wt << " " << kt << endl;

        return 0;
}



Measured memory_bytes: 3156
def corp(i):
    return i*(i-1)//2

N=int(input())
A=list(map(int,input().split()))
box=[0]*N
for i in A:
    box[i-1]+=1
sum=0
for i in box:
    if i != 1:
        sum+=corp(i)
for i in A:
    ans=sum
    if box[i-1] != 1:
        ans=ans-corp(box[i-1])+corp(box[i-1]-1)
    print(ans)


Measured memory_bytes: 26140
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T,class Size=typename vector<T>::size_type>inline auto vector_2d(Size h,Size w,T v){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator,class Pair=typename iterator_traits<RandomAccessIterator>::value_type>inline void sort_pairs_by_second(RandomAccessIterator first,RandomAccessIterator last){sort(first,last,[](const Pair&p1,const Pair&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll n=in();
    vector<ll>a(n);for(ll i=0;i<n;++i)a[i]=in();
    ll max=a[0];
    ll sum=0;
    for(ll i=1;i<n;++i){
        if(a[i]<max){
            sum+=max-a[i];
        }else{
            max=a[i];
        }
    }
    cout<<sum<<endl;
}


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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a <= b && c <= d) {
        cout << a + c << "\n";
    } else if (a <= b && c >= d) {
        cout << a + d << "\n";
    } else if (a >= b && c >= d) {
        cout << b + d << "\n";
    } else if (a >= b && c <= d) {
        cout << b + c << "\n";
    }


}















Measured memory_bytes: 3608
#include <iostream>

using namespace std;
typedef long long llong;

int gcd(int a, int b) {
  if (b > a)
    return gcd(a, b % a);
  if (a == b || b == 0)
    return a;
  if ((a % b) == 0)
    return b;
  return gcd(a % b, b);
}

void CSnack(std::istream& in, std::ostream& out) {
  int a, b;
  in >> a >> b;
  int g = gcd(a, b);
  out << (llong)a * b / g;
}

int main(int argc, char** argv) { CSnack(cin, cout); return 0; }


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

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> s(n), t(m);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> t[i];
  }

  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  int a = s[n-1], b = t[0];
  if (a < b && x < a && b <= y) {
    cout << "No War" << endl;
  }
  else {
    cout << "War" << endl;
  }

  return 0;
}

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

#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 INF 1e9


int main(){
  double A, B;
  cin >> A >> B;
  double la = A / 0.08, ra = (A+1) / 0.08, lb = B / 0.1, rb = (B+1)/ 0.1;
  int s = (int)floor(min(la, lb)), e = (int)ceil(min(ra, rb));
  FOR(i, s, e){
    double a = floor(i * 0.08), b= floor(i*0.1);
    if(a == A && b == B){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int A[100100];
int B[100100];
int C[100100];
int DP[100100][3];

int main(){
    int N;
    cin >> N;
    REP(i,N){
        int a,b,c;
        cin >> a >> b >> c;
        A[i] = a;
        B[i] = b;
        C[i] = c;
    }

    DP[0][0] = A[0];
    DP[0][1] = B[0];
    DP[0][2] = C[0];

    for(int i = 1; i < N; i++){
        DP[i][0] = A[i] + max(DP[i-1][1], DP[i-1][2]);
        DP[i][1] = B[i] + max(DP[i-1][0], DP[i-1][2]);
        DP[i][2] = C[i] + max(DP[i-1][0], DP[i-1][1]);
    }

    cout << max(DP[N-1][0], max(DP[N-1][1], DP[N-1][2])) << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(void){
	int a,b;
	
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
n,m=map(int,input().split())
l=list(map(int,input().split()))
l=list(set(l))
n=len(l)
ll=[]
for i in l:
    ll.append(int(i/2))

newl=[]
for i in ll:
    j=i
    count=0
    while j%2==0:
        j//=2
        count+=1
    newl.append(count)
import collections
newl=collections.Counter(newl)
if len(newl)!=1:
    print(0)
     
else:
    from fractions import gcd
    num=ll[0]
    flag=True
    for i in ll:
        if num<=m:
            num=int(i*num/gcd(i,num))
        else:
            flag=False
            break
    if flag==False:
        print(0)
    else:
        k=m%(num*2)
        if k>=num:
            print(int(m//(num*2)+1))
        else:
            print(int(m//(num*2)))

Measured memory_bytes: 14244
n=int(input())
a = list(map(int,input().split()))
minus_cnt = len([x for x in a if x<0])
abs_a = list(map(abs,a))
# print(a)
# print(abs_a)
# print(minus_cnt)
if 0 in abs_a:
    print(sum(abs_a))
elif minus_cnt %2 == 0:
    print(sum(abs_a))
else:
    print(sum(abs_a)-2*min(abs_a))

Measured memory_bytes: 14412
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
long long ans;
void dfs(int x,long long sum,long long last){
	if(x==n){
		ans+=sum+last;
		return;
	}
	dfs(x+1,sum+last,s[x]-'0');
	dfs(x+1,sum,last*10+s[x]-'0');
}
int main(){
	cin>>s;
	n=s.length();
	dfs(1,0,s[0]-'0');
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	ll n,w;
	cin>>n>>w;
	ll we[n+1]={};
	ll va[n+1]={};
	for(int i=1;i<=n;i++){
	    cin>>we[i]>>va[i];
	}
	ll d[2][w+1]={0};
	for(int i=0;i<2;i++){
	    for(int j=0;j<=w;j++){
	        d[i][j]=0;
	    }
	}
	//cout<<d[1][15]<<endl;
	for(int i=1;i<=n;i++){
	    for(int j=1;j<=w;j++){
	        if(j-we[i]>=0){
	            d[1][j]  = max(d[0][j],va[i]+d[0][j-we[i]]);
	        }
	    }
	    for(int j=1;j<=w;j++){
	        d[0][j]=d[1][j];
	    }
	}
	cout<<d[1][w];
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		char x[]=sc.next().toCharArray();
		int s = 0,g = 0;
		for (int i = 0; i < x.length; i++) {
		    if(x[i]=='A'){
		    	s = i;
		    	break;
		    }
		}
		for (int i = 0; i < x.length; i++) {
			if(x[x.length-i-1]=='Z'){
				g = x.length-i-1;
				break;
			}
		}
		System.out.println(g-s+1);
		}
	}

Measured memory_bytes: 26508
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

int n;
vector<string> ans;

void dfs(int len = 0, string s = "", char ch = 'a'){
    if(len >= n){
        ans.push_back(s);
        return;
    }
    
    for(char c = 'a'; c <= ch; ++c){
        string t = s;
        t += c;
        if(c == ch) dfs(len + 1, t, (char)(ch + 1));
        else    dfs(len + 1, t, ch);
    }
    return;
}

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

    cin >> n;
    dfs();
    sort(ans.begin(), ans.end());
    int sz = ans.size();
    for(int i = 0; i < sz; ++i) cout << ans[i] << "\n";
}

Measured memory_bytes: 7796
#include <stdio.h>


int gcd(int a,int b,int c){
    int d,e;
    d = gc(a,b);
    e = gc(c,d);
    return e;
}

int gc(int a,int b){
    int r, tmp;
    if(a<b){
       tmp = a;
       a = b;
       b = tmp;
     }
     r = a % b;
     while(r!=0){
       a = b;
       b = r;
       r = a % b;
     }
    return b;
}
int main(){
    int n,i,j,k,sum;
    scanf("%d",&n);
    sum =0;
    for(i=1;i<n+1;i++){
        for(j=1;j<n+1;j++){
            for(k=1;k<n+1;k++){
                sum = sum + gcd(i,j,k);
            }
        }
    }
    printf("%d",sum);
    return 0;
}



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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    string s;
    cin >> s;
    V<pii> vec;
    for (auto c : s) {
        if (!vec.size() || c != vec.back().fi) {
            vec.eb(c, 1);
        } else {
            vec.back().se++;
        }
    }
    cout << (int)vec.size() - 1 << endl;
    return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<int,int> P;

int N,M;
int v[100100];
int tmp_cnt[100100];
int cnt[100100];
int ans=0;
int main(){
  cin >> N >> M;
  for(int i=0;i<N;i++){
    int t;
    cin >> t;
    v[t%M]++;
    tmp_cnt[t]++;
    if(tmp_cnt[t] == 2){
      cnt[t%M]++;
      tmp_cnt[t] = 0;
    }
  }
  /*
  for(int i=0;i<M;i++){
    cout << v[i] << " " << cnt[i] << endl;
  }
  */
  for(int i=1;i<(M+1)/2;i++){
    int tmp = min(v[i],v[M-i]);
    ans += tmp;
    if(v[i] - tmp < cnt[i]*2){
      cnt[i] = (v[i] - tmp) / 2;
    }
    if(cnt[i] > 0) ans += cnt[i];

    if(v[M-i] - tmp < cnt[M-i]*2){
      cnt[M-i] = (v[M-i] - tmp) / 2;
    }
    if(cnt[M-i] > 0) ans += cnt[M-i];
    //cout << " "<< i << " " << ans << endl;
  }
  ans += v[0] / 2;
  if(M%2 == 0) ans += v[M/2]/2;
  cout << ans << endl;
}


Measured memory_bytes: 1408
# cook your dish here
n=int(input())
m=int(input())
if (n==1 and m==2) or (n==2 and m==1):
  print('3')
elif (n==1 and m==3) or (n==3 and m==1):
  print('2')
elif (n==3 and m==2) or (n==2 and m==3):
  print('1')


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

typedef pair<int,int> PII;

int c[5];
int main(){
	int a;
	for (int i = 0; i < 6; ++i){
		cin>>a;
		c[a]++;
	}

	int ans=0;
	for (int i = 1; i < 5; ++i){
		if(c[i]==2)ans++;
	}

	if(ans==2)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;

}

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

const int dx[4]={0,-1,0,1};
const int dy[4]={-1,0,1,0};
int h,w;
tuple<int,int,int> bfs(const vector<string> &s,int x,int y){
    vector<vector<int>> d(h,vector<int>(w,-INF));
    queue<P> q;
    q.push(make_pair(x,y));
    d[x][y] = 0;
    int ma=0;
    while(!q.empty()){
        int xi = q.front().first;
        int yi = q.front().second;
        q.pop();
        rep(i,4){
            int nx = xi + dx[i];
            int ny = yi + dy[i];
            if(nx>=0 && nx<h && ny>=0 && ny<w && d[nx][ny]==-INF &&s[nx][ny]=='.'){
                q.push(make_pair(nx,ny));
                d[nx][ny] = d[xi][yi] + 1;
                ma = max(ma,d[nx][ny]);
                //cout << d[nx][ny] << endl;
            }
        }
    }
    P res;
    rep(i,h){
        rep(j,w){
            if(d[i][j]==ma) res = make_pair(i,j);
            //cout << d[i][j] << " ";
        }
        //cout << endl;
    }
    return make_tuple(ma,res.first,res.second);
}

int main(){
    cin >> h >> w;
    vector<string> m(h);
    rep(i,h) cin >> m[i];
    int x,y;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(m[i][j]=='.'){
                x = i;
                y = j;
                break;
            }
        }
    }
    tuple<int,int,int> s = bfs(m,x,y);
    int a,b,c;
    tie(a,b,c) = s;
    s = bfs(m,b,c);
    tie(a,b,c) = s;
    cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int a;
  cin>>a;
  if(a<105){
    cout<<0<<endl;
  }else if(a<135){
    cout<<1<<endl;
  }else if(a<165){
    cout<<2<<endl;
  }else if(a<189){
    cout<<3<<endl;
  }else if(a<195){
    cout<<4<<endl;
  }else{
    cout<<5<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int K, A, B;
	cin >> K >> A >> B;
	int mn = 1 + K;

	int res = A; K -= A - 1;

	res += (K / 2)*(B - A);
	res += K % 2;


	cout << max(res, mn) << endl;
}

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

int main() {

	int n, m, k;	cin >> n >> m >> k;
	vector<string> v(n);
	for (auto &i : v)	cin >> i;

	auto solve = [&](int bit) {
		int res = __builtin_popcount(bit);
		int siz = res + 1;	
		vector <int> cnt(siz);

		for (int j = 0; j < m; j++) {
			int temp = 0, sec = 0;

			for (int i = 0; i < n; i++) {
				temp += (v[i][j] == '1');
				cnt[sec] += (v[i][j] == '1');

				if (temp > k)	return n + m;
				if (bit & (1 << i))		temp = 0,sec++;
			}

			if (*max_element(cnt.begin(), cnt.end()) > k) {
				cnt.assign(siz, 0);
				j--;	res++;
			}
		}
		return res;
	};

	int ans = n + m;
	rep(i, 1 << (n - 1))
		ans = min(ans, solve(i));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define inf 0x3f3f3f3f
#include<queue>
using namespace std;
const int N=10005;
const int M=20005;

int n,m;
int head[N],top=0;
int dis[N];bool vis[N];
struct Edge
{
    int v,next,d,c;
}edge[M*2];

void init()
{
    memset(head,-1,sizeof(head));
    top=0;
}

void addedge(int u,int v,int d,int c)
{
    edge[top].v=v;edge[top].next=head[u];
    edge[top].c=c;edge[top].d=d;
    head[u]=top++;
}

void spfa()
{
    for(int i=1;i<=n;i++){
        dis[i]=inf;
        vis[i]=0;
    }
    dis[1]=0;
    queue<int>que;
    que.push(1);
    while(!que.empty())
    {
        int u=que.front();que.pop();
        vis[u]=0;
        for(int i=head[u];i!=-1;i=edge[i].next)
        {
            int v=edge[i].v,w=edge[i].d;
            if(dis[v]>dis[u]+w){
                dis[v]=dis[u]+w;
                if(!vis[v]){
                    que.push(v);
                    vis[v]=1;
                }
            }
        }
    }
}

int d[N];

int cost[N];

void bfs()
{
    memset(d,0,sizeof(d));
    queue<int>que;
    que.push(1);
    memset(vis,0,sizeof(vis));
    memset(cost,0,sizeof(cost));
    vis[1]=1;
    while(!que.empty())
    {
        int u=que.front();que.pop();
        for(int i=head[u];i!=-1;i=edge[i].next)
        {

            int v=edge[i].v,w=edge[i].d;
            if(vis[v]&&d[v]!=dis[u]+w)continue;
            if(d[u]+w==dis[v]){
                d[v]=d[u]+w;
                if(cost[v]) cost[v]=min(cost[v],edge[i].c);
                else cost[v]=edge[i].c;
                vis[v]=1;
                que.push(v);
            }
        }
    }

    int ans=0;
    for(int i=2;i<=n;i++){
        ans+=cost[i];
    }
    printf("%d\n",ans);

}


int main()
{
    while(~scanf("%d%d",&n,&m))
    {
    	if(n==0&&m==0) break; 
        init();
        int u,v,d,c;
        for(int i=0;i<m;i++)
        {
            scanf("%d%d%d%d",&u,&v,&d,&c);
            addedge(u,v,d,c);
            addedge(v,u,d,c);
        }
        spfa();
        bfs();
    }
    return 0;
}

Measured memory_bytes: 1868
#include <iostream>
#include <vector>

using namespace std;

const int maxN = 2e5 + 5, maxM = 1e5 + 5;

vector<vector<int> > ed(maxN);
vector<int> dist(maxN, 0), in_degree(maxN, 0);
bool visited[maxN];

void max_self(int &a, int b) {
    a = max(a, b);
}

void dfs(int b) {
    visited[b] = true;
    //cout << "In dfs with b " << b << endl;
    for(auto a : ed[b]) {
        //cout << a << endl;
        max_self(dist[a], dist[b] + 1);
        in_degree[a]--;
        if(!in_degree[a]) dfs(a);
    }
}

int main ()
{
  int n, me, x, y;
  cin >> n >> me;
  for(int i = 0; i < me; i++) {
      cin >> x >> y;
      ed[x].push_back(y);
      in_degree[y]++;
  }
  for(int i = 1; i <= n; i++) {
      if(!visited[i] && !in_degree[i])
        dfs(i);
  }
  int ans = 0;
  for(int i = 1; i <= n; i++) max_self(ans, dist[i]);
  cout << ans;
  return 0;
}

Measured memory_bytes: 17252
#include <iostream>
#include <sstream>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <set>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
using namespace std;
int main()
{
    long int i,a,b,c,d,cc,ccc,cccc,dd,ddd,dddd,cd,cdcd,cdcdcd,cdcdcdcd,answer;
    cin >> a >> b >> c >> d;
    answer = 0;
    if(a % c == 0){
        cc = a;
    }
    else{
        cc = (a - (a % c)) + c;
    }
    if (b % c == 0){
        ccc = b;
    }
    else{
        ccc = (b - (b % c));
    }
    cccc = ((ccc - cc) / c) + 1;
    if (a % d == 0){
        dd = a;
    }
    else{
        dd = (a - (a % d)) + d;
    }
    if (b % d == 0){
        ddd = b;
    }
    else{
        ddd = (b - (b % d));
    }
    dddd = ((ddd - dd) / d) + 1;
    cd = (c * d) / __gcd(c,d);
    if (a % cd == 0){
        cdcd = a;
    }
    else{
        cdcd = (a - (a % cd)) + cd;
    }
    if (b % d == 0){
        cdcdcd = b;
    }
    else{
        cdcdcd = (b - (b % cd));
    }
    cdcdcdcd = ((cdcdcd - cdcd) / cd) + 1;
    cout << b - a + 1 -(cccc + dddd - cdcdcdcd) << endl;
}

Measured memory_bytes: 3608
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  int n;
  cin >> n;
  vector<int> t(n);
  int sm = 0;
  forn(i, n) cin >> t[i], sm+=t[i];
  int m;
  cin >> m;

  forn(i,m){
    int p, x;
    cin >> p >> x;
    p--;
    int y = sm - t[p] + x;
    cout << y << endl;
  }
}

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
1000000000000000000


*/

Measured memory_bytes: 3648
def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)


import sys
import numpy as np


def solve(N, Q, LRD):
    mod = 998244353
    p = 1
    n = 0
    p10 = np.empty(202020, dtype=np.int64)
    n11 = np.empty(202020, dtype=np.int64)
    for i in range(202020):
        p10[i] = p
        n11[i] = n
        p = p*10%mod
        n = (n*10+1)%mod

    identity = 0
    sqrtN = 256
    n_buckets = N//sqrtN+1
    Data_val = np.ones(n_buckets*sqrtN, dtype=np.int64)
    Data_val[N:] = 0
    Bucket_val = np.full(n_buckets, n11[sqrtN], dtype=np.int64)
    Lazy = np.full(n_buckets, identity, dtype=np.int64)
    M = N % sqrtN
    Bucket_val[n_buckets-1] = n11[M]

    def eval_data(k):
        if Lazy[k] != identity:
            l, r = k*sqrtN, (k+1)*sqrtN
            for i in range(l, r):
                Data_val[i] = Lazy[k]
            Lazy[k] = identity

    def apply(s, t, f):
        for k in range(s//sqrtN, (t-1)//sqrtN+1):
            l, r = k*sqrtN, (k+1)*sqrtN
            if s <= l and r <= t:
                Bucket_val[k] = f * n11[sqrtN] % mod
                Lazy[k] = f
            else:
                eval_data(k)
                for i in range(max(l, s), min(r, t)):
                    Data_val[i] = f
                Bucket_val[k] = 0
                for i in range(l, min(r, N)):
                    Bucket_val[k] = (Bucket_val[k] * 10 + Data_val[i]) % mod

    def get(i):
        k = i//sqrtN
        eval_data(k)
        return Data_val[i]

    def all_prod():
        res = 0
        for k in range(n_buckets-1):
            res = (res * p10[sqrtN] + Bucket_val[k]) % mod
        res = (res * p10[M] + Bucket_val[n_buckets-1]) % mod
        return res

    Ans = np.zeros(Q, dtype=np.int64)
    for i in range(Q):
        l, r, d = LRD[i]
        apply(l-1, r, d)
        ans = all_prod()
        Ans[i] = ans

    return Ans


numba_compile([
    [solve, "i8[:](i8,i8,i8[:,:])"]
])


def main():
    N, Q = map(int, sys.stdin.buffer.readline().split())
    LRD = np.array(sys.stdin.buffer.read().split(), dtype=np.int64).reshape(Q, 3)
    Ans = solve(N, Q, LRD)
    print("\n".join(map(str, Ans.tolist())))


main()


Measured memory_bytes: 58632
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i, j;
		LinkedList<Integer> list = new LinkedList<Integer>();
		ListIterator<Integer> cursor = list.listIterator();
		try (Scanner sc = new Scanner(System.in)) {
			int q = sc.nextInt();
			for(i = 0; i < q; i++) {
				int order_number = sc.nextInt();
				switch(order_number) {
				case 0 :
					cursor.add(sc.nextInt());
					cursor.previous();
					break;
				case 1 :
					int d = sc.nextInt();
					if(d >= 0) {
						for(j = 0; j < d; j++) {
							cursor.next();
						}
					}else {
						for(j = 0; j < -d; j++) {
							cursor.previous();
						}
					}
					break;
				case 2 :
					cursor.next();
					cursor.remove();
					break;
				}
			}
			for (int output : list) {
				System.out.println(output);
			}
		}
	}
}



Measured memory_bytes: 308260
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n = get();
    let m = get();
    let mut edges = vec![Vec::new(); n];
    for _ in 0 .. m {
        let a = get::<usize>() - 1;
        let b = get::<usize>() - 1;
        edges[a].push(b);
        edges[b].push(a);
    }
    let q = get();
    let mut vdc = Vec::new();
    for _ in 0 .. q {
        let v = get::<usize>() - 1;
        let d: usize = get();
        let c: usize = get();
        vdc.push((v, d, c));
    }
    vdc.reverse();
    let mut ans = vec![0; n];
    let mut done = vec![0; n]; // offset 1
    for (v, d, c) in vdc {
        let mut que = VecDeque::new();
        que.push_back((v, d));
        while let Some((w, rem)) = que.pop_front() {
            if done[w] >= rem + 1 {
                continue;
            }
            if ans[w] == 0 {
                ans[w] = c;
            }
            done[w] = rem + 1;
            if rem > 0 {
                for &x in edges[w].iter() {
                    que.push_back((x, rem - 1));
                }
            }
        }
    }
    for v in ans {
        println!("{}", v);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 26836
MOD = 10**9 + 7


n, m = map(int, input().split())
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]

Sx, Sy = 0, 0

for i in range(n-1):
    Sx += (X[i+1]-X[i])*(i+1)*(n-1-i)

for k in range(m-1):
    Sy += (Y[k+1]-Y[k])*(k+1)*(m-1-k)

print((Sx*Sy) % MOD)


Measured memory_bytes: 97064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] x = new int[N];
		for(int i = 0;i < N;++i)
			x[i] = sc.nextInt();
		sc.close();
		
		int ans = Integer.MAX_VALUE;
		for(int i = 0;i <= N-K;++i) {
			int cost = x[i+K-1] - x[i];
			cost += Math.abs(x[i+K-1]) < Math.abs(x[i]) ? Math.abs(x[i+K-1]) : Math.abs(x[i]);
			if(ans > cost)
				ans = cost;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 50364
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var W = double.Parse(ss[0]);
            var H = double.Parse(ss[1]);
            var x = double.Parse(ss[2]);
            var y = double.Parse(ss[3]);

            var num = (W / 2 == x && H / 2 == y) ? "1" : "0";
            Console.WriteLine(W * H / 2 + " " + num);
        }
    }
}

Measured memory_bytes: 11220
//https://triple-four.hatenablog.com/entry/2019/04/02/143939
//https://qiita.com/okaryo/items/8e6cd73f8a676b7a5d75
//https://www.slideshare.net/hcpc_hokudai/shortest-path-50585527
//https://www.npca.jp/works/magazine/2014_1/
//AOJ本
//マクロを使えるように

#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

#define INF pow(10,10)


int main(){
  int v,e;
  int s,t,d;
  cin >> v >> e;
  vector<vector<long long>> dp(v,vector<long long>(v,INF));
  for(int i=0;i<e;i++){
    cin >> s >> t >> d;
    dp[s][t]=d;
    //有向ならdp[t][s]=dも
    //多重辺がある場合はmin(dp[s][t],d)とする
  }
  for(int i=0;i<v;i++){
    dp[i][i]=0;
  }
  for(int k=0;k<v;k++){
    for(int i=0;i<v;i++){
      for(int j=0;j<v;j++){
        //INFへ足し引き算してもINF
        //ここもっとうまくできそう？？
        if(dp[i][k]!=INF && dp[k][j]!=INF){
          dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
        }
      }
    }
  }
  //負の閉じた経路がある場合は、割り続けるたびにマイナスになってしまう
  //WF法が終わった時点で自分自身に戻ってくるのがマイナスになればそれは負の閉じた経路にその頂点が含まれていることになる
  int x=0;
  for(int i=0;i<v;i++){
    if(dp[i][i]<0){
      x=1;
      break;
    }
  }
  if(x==1){
    cout << "NEGATIVE CYCLE" << endl;
  }else{
    for(int i=0;i<v;i++){
      for(int j=0;j<v;j++){
        if(dp[i][j]==INF){
          //INFで変わらない場合があるのを考慮し忘れていた
          cout << "INF";
        }else{
          cout << dp[i][j];
        }
        if(j==v-1){
          cout << endl;
        }else{
          cout << " ";
        }
      }
    }
  }
}



Measured memory_bytes: 3248
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, M;
    string s;
    map<string, int> S, T;
    cin >> N;
    REP(i, N) { cin >> s; S[s]++; }
    cin >> M;
    REP(i, M) { cin >> s; T[s]++; }

    int ans = 0;
    for (auto s : S) {
        ans = max(ans, s.second - T[s.first]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int kk=2*n-1;
  int ll[kk];
  if(n==1){ 
        int o=(m-n)+1;
        cout<<o<<endl;
        return 0;
  }
    int o=(m-n)+1;
    cout<<o<<" ";
    int i=0;
  while(i<kk-1){
      o+=1;
      cout<<o<<" ";
      i+=1;
  }
  return 0;
}

Measured memory_bytes: 256
require("fs").readFileSync("/dev/stdin","utf8").split(/\s/).map(function(j){j?console.log(j<=48?'light fly':j<=51?'fly':j<=54?'bantam':j<=57?'feather':j<=60?'light':j<=64?'light welter':j<=69?'welter':j<=75?'light middle':j<=81?'middle':j<=91?'light heavy':'heavy'):0})

Measured memory_bytes: 7648
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    char x, y; cin >> x >> y;

    if (x == y) {
        cout << "=" << endl;
    } else if (x < y) {
        cout << "<" << endl;
    } else {
        cout << ">" << endl;
    }
}


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

#define ll long long
#define N 1100
const ll MOD = (ll)1e9 + 7;
int n, m, a[N], b[N];

bool check()
{
	for (int i = 1; i <= n; ++i) for (int j = i + 1; j <= n; ++j)
		if (a[i] == a[j]) return false;
	for (int i = 1; i <= m; ++i) for (int j = i + 1; j <= m; ++j)
		if (b[i] == b[j]) return false; 
	return true; 
}

int main()
{
	while (scanf("%d%d", &n, &m) != EOF)
	{
		for (int i = 1; i <= n; ++i) scanf("%d", a + i);
		for (int i = 1; i <= m; ++i) scanf("%d", b + i);
		sort(a + 1, a + 1 + n);
		sort(b + 1, b + 1 + m);
		if (!check()) puts("0");  
		else
		{
			a[n + 1] = n + 1;
			b[m + 1] = m + 1;
			int l[2] = {0, 0};
			ll res = 1; 
			for (int i = 1; i <= n * m; ++i)
			{
				while (l[0] <= n && a[l[0]] < i) ++l[0]; 
				while (l[1] <= m && b[l[1]] < i) ++l[1];
				ll d = 0;
				if (a[l[0]] == i && b[l[1]] == i)
					d = 1;
				else if (a[l[0]] == i && b[l[1]] != i)
					d = m - l[1] + 1;
				else if (b[l[1]] == i && a[l[0]] != i)
					d = n - l[0] + 1;
				else
					d = (m - l[1] + 1) * (n - l[0] + 1) - (n * m - i);
				/*if (a[l[0]] > i) 
					d *= n - l[0] + 1; 
				if (b[l[1]] > i) 
					d *= m - l[1] + 1; 
				if (a[l[0]] > i && b[l[1]] > i) 
					d -= n * m - i;  */   
				res = (res * d) % MOD; 
			} 
			printf("%lld\n", res);
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
    	Scanner sc = new Scanner(System.in);
    	long a = sc.nextLong();
    	long b = sc.nextLong();
    	long c = a - b;

    	System.out.println(c >= 0 ? c : 0);
    }

}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
    
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
    
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int gcd(int a, int b){
    while(b){
        int t = a;
        a = b;
        b = t%b;
    }
    return a;
}

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


int main() {
    int d; cin >> d;
    string s = "Christmas";
    while(25-d){
        d++;
        s += " Eve";
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 380
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

func main() {
	n := scanInt()
	h := scanInts(n)
	answer := isNoneDescreasing(h)
	fmt.Println(answer)
}

func debug(a ...interface{}) {
	fmt.Println(a...)
}

func isNoneDescreasing(h []int) string {
	prev := -1
	for i := 0; i < len(h); i++ {
		if h[i] > prev {
			prev = h[i] - 1
		} else if h[i] == prev {
			prev = h[i]
		} else { // h[i] < prev
			return "No"
		}
	}
	return "Yes"
}


Measured memory_bytes: 3072
N=int(input())
D={}
from decimal import Decimal
B=[Decimal(input()) for _ in range(N)]
B=[int(i*10**9) for i in B]
A=[[0]*19 for i in range(19)]
for i in range(N):
  x=B[i]
  y=x
  tcnt,fcnt=0,0
  while x%2==0 and tcnt<18:
    tcnt+=1
    x=x//2
  while y%5==0 and fcnt<18:
    fcnt+=1
    y=y//5
  A[fcnt][tcnt]+=1

cnt=0
for i in range(19):
  for j in range(19):
    for k in range(19):
      for l in range(19):
        if i+k>=18 and j+l>=18:
          if i!=k and j!=l:
            d=A[i][j]
            e=A[k][l]
            p=d*e
          elif i==k and j==l:
            d=A[i][j]
            p=d*(d-1)
          else:
            d=A[i][j]
            e=A[k][l]
            p=d*e
          cnt+=p
print(cnt//2)


Measured memory_bytes: 256392
#include <iostream>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
const int MAX_N = 1e5;
int occ[MAX_N + 1];


int main()
{
    cin.sync_with_stdio(0);

    int N;
    cin >> N;

    LL tot_sum = 0;
    for (int i = 0; i < N; ++i)
    {
        int nr;
        cin >> nr;

        tot_sum += nr;
        ++occ[nr];
    }

    int Q;
    cin >> Q;

    while (Q--)
    {
        int B, C;
        cin >> B >> C;

        tot_sum -= (LL)B * occ[B];
        tot_sum += (LL)C * occ[B];
        occ[C] += occ[B];
        occ[B] = 0;
        cout << tot_sum << "\n";
    }
}

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

using namespace std;

typedef long long ll;

const int N = 200200;
const int Mod = 1e9 + 7;

int P2[N];

int P[N];
int W[N];
vector <int> Adj[N];

void add_self(int& x, int y)
{
    if((x += y) >= Mod) x -= Mod;
}

void sub_self(int& x, int y)
{
    if((x -= y) < 0)    x += Mod;
}

int add(int x, int y)
{
    return add_self(x, y), x;
}

int sub(int x, int y)
{
    return sub_self(x, y), x;
}

int mul(int x, int y)
{
    return (ll) x * y % Mod;
}

int fp(int x, int y)
{
    int Res = 1;
    for(; y > 0; y >>= 1, x = mul(x, x))
        if(y & 1)
            Res = mul(Res, x);
    return Res;
}

int inv(int x)
{
    return fp(x, Mod - 2);
}

void DFS(int x = 1, int p = 0)
{
    P[x] = p;
    W[x] = 1;

    for(int y : Adj[x])
        if(y != p)
            DFS(y, x), W[x] += W[y];
}

int main()
{
    P2[0] = 1;
    for(int i = 1; i < N; i++)  P2[i] = mul(2, P2[i - 1]);

    int n;  cin >> n;

    for(int i = 1; i < n; i++)
    {
        int x, y;   scanf("%d%d", &x, &y);

        Adj[x].push_back(y);
        Adj[y].push_back(x);
    }

    DFS();

    int Ans = 0;

    for(int x = 1; x <= n; x++)
    {
        add_self(Ans, sub(P2[n - 1], 1));

        for(int y : Adj[x])
        {
            int Wy = (y == P[x] ? n - W[x] : W[y]);

            sub_self(Ans, sub(P2[Wy], 1));
        }
    }

    Ans = mul(Ans, inv(P2[n]));

    cout << Ans << endl;
}


Measured memory_bytes: 22400
#include <iostream>
#include <cstdio>
using namespace std;
int x;
int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
int main()
{
	scanf("%d",&x);
	int k=gcd(360,x);
	printf("%d",360/k);
	return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> count;
    vector<int> unique_num;
    vector<int> bu(100001, 0);
    for(int n=0; n<N; n++) {
        cin >> A[n];
        
        if(bu[A[n]]==0) {
            unique_num.push_back(A[n]);
            count.push_back(0);
            bu[A[n]]++;
        } else {
            bu[A[n]]++;
            for(int ui=0; ui<unique_num.size(); ui++) {
                if(unique_num[ui]==A[n]) {
                    count[ui]++;
                }
            }
        }
    }
    
    int sum=0;
    for(int ui=0; ui<unique_num.size(); ui++) {
        sum += count[ui];
    }
    
    if(sum%2==0) {
        cout << unique_num.size() << endl;
    } else {
        cout << unique_num.size()-1 << endl;
    }

    return 0;
}

Measured memory_bytes: 2044