akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

func main() {
	var N, M, X int
	fmt.Scan(&N, &M, &X)
	A := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&A[i])
	}
	leftA := 0
	rightA := M
	j := 0
	for i := 1; i < N; i++ {
		if i == A[j] {
			rightA--
		}
		if i == X {
			break
		}
		if i == A[j] {
			leftA++
			j++
		}
	}
	fmt.Println(min(rightA, leftA))

}

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

Measured memory_bytes: 512
//#include <algorithm>
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>


using namespace std;



class room {
public:
	vector<int> m_conectedRooms;
	int m_aite;
	int m_step;
	
	room() {
		m_aite = -1;
		m_step = 999999;
	}
};




void BFS(vector<room> *rooms) {
	queue<int> roomQue;

	roomQue.push(1);
	while (!roomQue.empty()) {
		// Queを探って、depthとaiteを入れます
		int curRoomID = roomQue.front();
		roomQue.pop();
		room curRoom = (*rooms).at(curRoomID);
		for (int j = 0; j < curRoom.m_conectedRooms.size(); j++) {
			if ((*rooms).at(curRoom.m_conectedRooms[j]).m_step > curRoom.m_step + 1) {
				roomQue.push(curRoom.m_conectedRooms[j]);
				(*rooms).at(curRoom.m_conectedRooms[j]).m_step = curRoom.m_step + 1;
				(*rooms).at(curRoom.m_conectedRooms[j]).m_aite = curRoomID;
			}
		}

	}


}



int main(void) {
	int N, M;


	
	cin >> N >> M;

	vector<room> rooms(N+1);


	// マップを作る
	for (int i = 0; i < M; i++) {
		int roomA, roomB;
		cin >> roomA >> roomB;
		rooms[roomA].m_conectedRooms.push_back(roomB);
		rooms[roomB].m_conectedRooms.push_back(roomA);
	}


	// 部屋１からたどれるかフラグを付ける
	rooms[1].m_step = 0;
	rooms[1].m_aite = 0;

//	gotoNext(&rooms, 1);
	BFS(&rooms);


#ifdef _DBG_
	for (int i = 1; i <= N; i++) {
		cout << "room:" << i << " "<< (int)(rooms[i].m_conectedRooms.size()) << " " << rooms[i].m_aite << endl;
		for (int j = 0; j < (int)(rooms[i].m_conectedRooms.size()); j++) {
			cout << "  " << rooms[i].m_conectedRooms[j] << endl;
		}
	}
#endif


	// 相手を調べる
	bool flgOK = true;
	for (int i = 2; i <= N; i++) {
		if (rooms[i].m_aite == -1) {
			flgOK = false;
			break;
		}
	}

	// 最終出力
	if (flgOK) {
		cout << "Yes" << endl;
		for (int i = 2; i <= N; i++) {
			cout << rooms[i].m_aite << endl;
		}
	}
	else {
		cout << "No" << endl;
	}



#ifdef _DBG_
	int CC;
	cin >> CC;
#endif

	return 0;
}


Measured memory_bytes: 10784
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int SetInput( vector<int>& vec )
{
    int size;
    cin >> size;
    for(int i = 0; i < size; ++i )
    {
        int value;
        cin >> value;
        vec.at( i ) = value;
    }
    vec.resize( size );
    return size;
}

int Calc( vector<int>& input )
{
    // ふるい
    const int max = 1000000;
    int sieve[max+1] = { 0 };

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

    for( const int& i : input )
    {
        // cout << "i : " <<  i << endl;
        ++sieve[i];
    }

    int count = 0;

    for( const int& i : input )
    {
        const int& s = sieve[i];

        if( s == 1 ) {
            ++count;
        }
        if( s > 0 )
        {
            const int maxMul = max / i;
            for( int mul = 1; i * mul <= max; ++mul )
            {
                sieve[i * mul] = -1;
            }
        }
        
    }

    return count;
}

int main()
{
    const int N = 200000;
    
    vector<int> input(N);

    SetInput( input );

    int ans = Calc( input );

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8012
#include <stdio.h>
int main (int argc, char * argv[])
{
    int  n,m,l,A,B,C;
    long long a[101][101]={0};
    long long b[101][101]={0};
    long long c[101][101]={0};
    scanf("%d %d %d",&n,&m,&l);
    //行列aの入力
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
             scanf("%d", &A);
            a[i][j] = A;
        }
    }
    //行列bの入力
    for(int j=0;j<m;j++){
        for(int k=0;k<l;k++){
             scanf("%d", &B);
            b[j][k] = B;
        }
    }
  
    //行列aと行列bの計算
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            c[i][j] = 0;
            for(int k=0;k<m;k++){
                c[i][j] += a[i][k]*b[k][j];
            }
            
        }
    }
    //結果を出力
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            printf("%lld", c[i][j]);
            c[i][j] = C;

            if(j!=l-1){
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
ii find_ends(int a)
{
    ii ends;
    int cur = a;
    ends.ss = a%10;
    while( a > 0)
    {
        ends.ff = a;
        a /= 10;
    }
    return ends;
}
int main()
{
    she_told_me_dont_worry
    ll n;
    cin>>n;
    ll i;
    map< ii, ll > m;
    FOR(i, 1, n+1)
    {
        m[find_ends(i)]++;
    }
    ll ans = 0;
    // starts 1 to 9
    map< ii, ll>::iterator it = m.begin(), it2;
    while(it != m.end())
    {
        ii tobe = mp(it->ff.ss, it->ff.ff);
        it2 = m.find(tobe);
        if(it2 != m.end())
            ans += it->ss*it2->ss;
        it++;
    }
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
const ll mod = 1e9+7;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int N, W, w[101], v[101];
ll dp[101][200020];

int main() {
  cin >> N >> W;
  rep(i, 0, N) cin >> w[i] >> v[i];
  rep(i, 0, N) rep(tot, 0, W) {
    chmax(dp[i+1][tot], dp[i][tot]);
    chmax(dp[i+1][tot + w[i]], dp[i][tot] + v[i]);
  }

  ll res = 0;
  rep(tot, 0, W+1) chmax(res, dp[N][tot]);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 156416
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();
            int p = (S + S).indexOf(T);
            out.println(p == -1 ? "No" : "Yes");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



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

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (a + b <= 2 * c) { cout << a * x + b * y << '\n'; }
    else {
        int ans = 2 * c * min(x, y);
        if (x <= y) { ans += (y - x) * min(2 * c, b); }
        else { ans += (x - y) * min(2 * c, a); }
        cout << ans << '\n';
    }
}


Measured memory_bytes: 256
import sys
n, m, x = map(int, input().split())
MAX = sys.maxsize

datas = []
for i in range(n):
    datas.append(list(map(int, input().split())))

kingaku = 0
memos = [[0] * (m+2) for _ in range(n)]


def rec(i, rikaido, kingaku):
    
    #print('i, rikaido, kingaku', i, rikaido, kingaku)
    #print('終了条件', [i >= x for i in rikaido])
    # 終了条件：成功：全ての理解度がx以上になっている
    if all([i >= x for i in rikaido]):
        return kingaku

    # 終了条件：失敗；n冊目までチェックし終えた
    if i == n:
       return MAX

    return min(rec(i+1, rikaido, kingaku), rec(i+1, [u+t for u, t in zip(rikaido, datas[i][1:])], kingaku+datas[i][0]))


ans = rec(0, [0] * m , 0)
if ans == MAX:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 70980
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String O = sc.next();
        String S = sc.next();
        for(int i = 0; i < S.length(); i++){
            System.out.print(O.charAt(i));
            System.out.print(S.charAt(i));
        }
        if(O.length() > S.length())
            System.out.println(O.charAt(O.length()-1));
    }
}

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

int gcd(int a, int b);
int lcm(int a, int b);

int main(){
	int a, b;
	while(cin >> a >> b){
		while(!(((a > 0)&&(a <= 2000000000))&&((b > 0)&&(b <= 2000000000)))){
			cout << "wrong value\n";
			cin >> a >> b;
		}
		cout << gcd(a, b) << " " << lcm(a, b) << "\n";
	}
    return 0;
}

//Greatest Common Divisor
int gcd(int a, int b){
	while(a != b){
		if(a > b) a = a - b;
		else b = b - a;
	}
	return a;
}

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

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

int main()
{
	int n, a[100005], sum = 0;

	cin >> n;

	a[0] = 0;

	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += abs(a[i] - a[i - 1]);
	}
	a[n+1] = 0;
	sum += abs(a[n+1] - a[n]);

	for (int i = 1; i <= n; i++) {
		cout << sum - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]) << endl;
	}

	return 0;
}


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

using namespace std;

template<typename T>
class LazySegTree {
public:
    explicit LazySegTree(int n, T init, T def) : N(calcN_(n)), def(def) {
        mVal.assign(2*N+1, init);
        mLazy.assign(2*N+1, 0);
        mDirty.assign(2*N+1, 0);
    }
    void update(int l, int r, T value){
        updateImpl_(l, r, value, 0, 0, N);
    }
    T get(int l, int r){
        return getImpl_(l, r, 0, 0, N);
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void updateImpl_(int l, int r, T value, int idx, int rangeL, int rangeR){
        eval_(idx, rangeL, rangeR);
        if(r <= rangeL || rangeR <= l) return;
        if(l <= rangeL && rangeR <= r){
            setLazy_(idx, value);
            eval_(idx, rangeL, rangeR);
        } else {
            int rangeM = (rangeL+rangeR)/2;
            updateImpl_(l, r, value, 2*idx+1, rangeL, rangeM);
            updateImpl_(l, r, value, 2*idx+2, rangeM, rangeR);
            mVal[idx] = operate_(mVal[2*idx+1], mVal[2*idx+2]);
        }
    }
    void setLazy_(int idx, T value){
        mLazy[idx] = value;
        mDirty[idx] = 1;
    }
    T getImpl_(int l, int r, int idx, int rangeL, int rangeR){
        if(r <= rangeL || rangeR <= l) return def;
        eval_(idx, rangeL, rangeR);
        if(l <= rangeL && rangeR <= r) return mVal[idx];
        int rangeM = (rangeL+rangeR)/2;
        T a = getImpl_(l, r, 2*idx+1, rangeL, rangeM);
        T b = getImpl_(l, r, 2*idx+2, rangeM, rangeR);
        return operate_(a, b);
    }
    void eval_(int idx, int rangeL, int rangeR){
        if(!mDirty[idx]) return;
        mVal[idx] = (rangeR - rangeL) * mLazy[idx];
        if(idx < N-1){
            setLazy_(2*idx+1, mLazy[idx]);
            setLazy_(2*idx+2, mLazy[idx]);
        }
        mLazy[idx] = 0;
        mDirty[idx] = 0;
    }
    T operate_(T a, T b) const { return a + b; }
    const int N;
    const T def;
    vector<T> mVal; 
    vector<T> mLazy;
    vector<int> mDirty;
};

int main(){
    int n, q;
    while(cin >> n >> q){
        LazySegTree<int> seg(n, 0, 0);
        for(int i=0;i<q;i++){
            int c; cin >> c;
            if(c == 0){
                int s, t, x; cin >> s >> t >> x;
                seg.update(s, t+1, x);
            } else {
                int s, t; cin >> s >> t;
                cout << seg.get(s, t+1) << endl;
            }
        }
    }
}



Measured memory_bytes: 5972
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			Dice dice = new Dice(sc.nextLine().split(" "));
			char[] str = sc.next().toCharArray();

			for(char ch: str) {
				dice.rotate(ch);
			}
			System.out.println(dice.showTop());
		}
	}
	static class Dice{
		private int[] face;
		public Dice(int[] face) {
			this.face = face;
		}
		public Dice(String[] face) {
			this.face = new int[6];
			for(int i=0;i<this.face.length;i++) {
				this.face[i] = Integer.parseInt(face[i]);
			}
		}
		public void rotate(char to){
			int buf;
			switch(to) {
			case 'E':
				buf = this.face[0];
				this.face[0] = this.face[3];
				this.face[3] = this.face[5];
				this.face[5] = this.face[2];
				this.face[2] = buf;
				break;
			case 'W':
				buf = this.face[0];
				this.face[0] = this.face[2];
				this.face[2] = this.face[5];
				this.face[5] = this.face[3];
				this.face[3] = buf;
				break;
			case 'S':
				buf = this.face[0];
				this.face[0] = this.face[4];
				this.face[4] = this.face[5];
				this.face[5] = this.face[1];
				this.face[1] = buf;
				break;
			case 'N':
				buf = this.face[0];
				this.face[0] = this.face[1];
				this.face[1] = this.face[5];
				this.face[5] = this.face[4];
				this.face[4] = buf;
				break;
			}
		}
		public int showTop() {
			return this.face[0];
		}
	}
}


Measured memory_bytes: 26376
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll N,M,Y=0;
  cin >> N >> M;
  ll K;
  cin >> K;
  rep(i,N+1){
    rep(j,M+1){
      if((N-i)*j+(M-j)*i==K){
        Y=1;
      }
    }
  }
  if(Y){
    cYes;
  }
  else{
    cNo;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int N;
	int i, j, s, num;
	
	while (scanf("%d", &N), N){
		num = 0;
		
		for (i = 1; i <= N; i++){
			s = 0;
			j = i;
			while (1){
				s += j;
				
				if (s == N && j != N){
					num++;
					break;
				}
				else if (s > N){
					break;
				}
				j++;
			}
		}
		
		printf("%d\n", num);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <iostream>

int main(){
    int k,x;
    std::cin >> k >> x;
    
    int iki=k-1;
    
    for(int i=-1*iki;i<=iki;i++){
        int num=x+i;
        std::cout << num << " ";
    }
    std::cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
typedef int TInt;
typedef std::vector<TInt> TList;

TList Input()
{
    int Count;
    std::cin >> Count;
    TList List(Count);
    for(int i = 0; i < Count; ++i){
        std::cin >> List[i];
    }
    return List;
}
int insertionSort(TList& A, int g)
{
    int cnt = 0;
    for(int i = g; i < A.size(); ++i){
        TInt v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
    return cnt;
}
void Reverse(TList& List)
{
    TList R;
    for(TList::reverse_iterator It = List.rbegin();
        It != List.rend();
        ++It)
    {
        R.push_back(*It);
    }
    std::swap(R, List);
}
TList GetG(int Max)
{
    TList G;
    int h = 1;
    while(h <= Max){
        G.push_back(h);
        h = 3 * h + 1;
    }
    Reverse(G);
    return G;
}
int shellSort(TList& A, const TList& G)
{
    int cnt = 0;
    for(TList::const_iterator It = G.begin();
        It != G.end();
        ++It){
        cnt += insertionSort(A, *It);
    }
    return cnt;
}
void OutputLine(const TList& List)
{
    TList::const_iterator It = List.begin();
    std::cout << *(It++);
    for(; It != List.end(); ++It){
        std::cout << " " << *It;
    }
    std::cout << std::endl;
}
void Output(const TList& List)
{
    TList::const_iterator It = List.begin();
    // std::cout << *(It++);
    for(; It != List.end(); ++It){
        std::cout << *It << std::endl;
    }
}
int main()
{
    TList A = Input();
    TList G = GetG(A.size());
    int cnt = shellSort(A, G);
    std::cout << G.size() << std::endl;
    OutputLine(G);
    std::cout << cnt << std::endl;
    Output(A);
    return 0;   
}

Measured memory_bytes: 4896
#include <iostream>
#include <algorithm>
#include <cmath>
#define INF 1000000000
using namespace std;
int ary[5010],fn[80],ff[80],fl[80],fr[80];

int main(){
	int N;
	while(true){
		cin>>N;
		if(N==0) break;
		for(int i=0;i<N;i++){
			cin>>ary[i];
		}
		int NN=sqrt(N),NNN=(N-1)/NN+1,cnt,hog,hog2;
		for(int i=0;i<NNN;i++){
			hog=hog2=-INF;
			for(int j=NN*i;j<min(NN*(i+1),N);j++){
				for(int k=j;k<min(NN*(i+1),N);k++){
					cnt=0;
					for(int l=j;l<=k;l++){
						cnt+=ary[l];
					}
					hog=max(hog,cnt);
					if(k==min(N,NN*(i+1))-1) hog2=max(hog2,cnt);
					if(j==NN*i&&k==min(N,NN*(i+1))-1) ff[i]=cnt;
				}
				if(j==NN*i) fl[i]=hog;
			}
			fn[i]=hog;
			fr[i]=hog2;
		}
		int res=-INF;
		for(int i=0;i<NNN;i++){
			res=max(res,fn[i]);
			for(int j=i+1;j<NNN;j++){
				hog=0;
				cnt=fr[i]+fl[j];
				for(int k=i+1;k<j;k++){
					cnt+=ff[k];
				}
				res=max(res,cnt);
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 3084
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> A = new ArrayList<Integer>();
        ArrayList<Integer> B;// = new ArrayList<Integer>();
        int N = sc.nextInt();
        int K = sc.nextInt();
        long ans = 0;
        for (int i = 0; i < N; i++) {
            A.add(sc.nextInt());
        }
        B = new ArrayList<Integer>(A);
        Collections.sort(B);
        // int base = 0;
        for (int i = 0; i < N; i++) {
            long base = 0;
            int num = A.get(i);
            for (int j = i + 1; j < N; j++) {
                if (num > A.get(j)) {
                    base++;
                }
            }

            // System.out.println(num + " b" + base);
            base *= K;
            base %= MOD;
            int ki = binary_search(num, B);
            // System.out.println(num + " k" + ki);
            BigInteger big = new BigInteger("1");
            big = big.multiply(new BigInteger(String.valueOf(K)));
            big = big.multiply(new BigInteger(String.valueOf(K-1)));
            big = big.multiply(new BigInteger(String.valueOf(ki)));
            big = big.divide(new BigInteger(String.valueOf(2)));
            big = big.mod(new BigInteger(String.valueOf(MOD)));
            // big.
            long pl = Long.parseLong(big.toString());
            // long pl = ki * K * (K - 1) / 2 % MOD;
            // pl %= MOD;
            // pl *= ki;
            // pl %= MOD;
            // pl /=2;

            // System.out.println(num + " b:" + base + " p:" + pl);

            ans += base;
            ans %= MOD;
            ans += pl;
            ans %= MOD;
        }
        System.out.println(ans);
    }

    static boolean isOK(int index, int key, ArrayList<Integer> list) {
        if (list.get(index) >= key)
            return true;
        else
            return false;
    }

    static int binary_search(int key, ArrayList<Integer> list) {
        int left = -1;
        int right = (int) list.size();
        while (right - left > 1) {
            int mid = left + (right - left) / 2;
            if (isOK(mid, key, list))
                right = mid;
            else
                left = mid;
        }
        return right;
    }
}

Measured memory_bytes: 29160
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<ll,ll> P;

int n, c, k;
int t[100000];

int main(){
    I(n,c,k);
    rep(i,n) I(t[i]);
    sort(t,t+n);
    int num = 0;
    int pos = 0;
    int ans = 1;
    pos = t[0]+k;
    num = 1;
    for(int i = 1; i < n; i++){
        if(num == c){
            num = 1;
            pos = t[i]+k;
            ans++;
            continue;
        }
        if(pos >= t[i]){
            num++;
        } else{
            num = 1;
            pos = t[i]+k;
            ans++;
        }
    }
    cout << ans << endl;
}
































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

  vector<int> d(51, 0);
  for (int i=0; i<N; i++) cin >> d[i];

  int sum = 0;
  for (int i=0; i<N; i++){
    for (int j=0; j<i; j++){
      sum += d[i] * d[j];
    }
  }

  cout << sum << endl;
}

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

class union_find{
    public:
    vector<int> parent;

    union_find(int n) : parent(n, -1){

    }

    int root(int x){
        if(parent[x] < 0) return x;
        else return parent[x] = root(parent[x]);
    }

    bool is_same(int x, int y){
        return root(x) == root(y);
    }

    bool marge(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(parent[x] > parent[y]) swap(x, y);
        parent[x] += parent[y];
        parent[y] = x;
        return true;
    }

    int size(int x){
        return -parent[root(x)];
    }
};

int main(){

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

    union_find uf(N);
    long long comb = N * (N - 1) / 2;
    vector<long long> ans;
    for(int i = M - 1; i >= 0; i--){
        ans.push_back(comb);
        int a = A[i], b = B[i];
        if(uf.is_same(a, b)) continue;

        long long as = uf.size(a), bs = uf.size(b);
        comb -= as * bs;
        uf.marge(a, b);
    }

    for(int i = ans.size() - 1; i >= 0; i--){
        cout << ans[i] << endl;
    }

    return 0;
}

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

int main() {
	long long a, b, k;
	cin >> a >> b >> k;
	if(a >= k) {
		a = a - k;
		k = 0;
	} else {
		k = k - a; 
		a = 0;
	}
	
	cout << a << " " << (b - k >= 0 ? b - k : 0);
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())

num = list(input().split())
ans = 1
if '0' in num :
    ans = 0
else:
    for i in num:
        ans *= int(i)
        if ans  > 10**18:
            break

if ans > 10**18:
    print('-1')
else: 
    print(ans)



Measured memory_bytes: 19492
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e6 + 2;
const ll N = 2e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


ll n, a[N], cnt[MOD], ans=0, ex[MOD], pr[MOD];

void solve()
{
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
        ex[a[i]] = 1;
    }
    sort(a,a+n); ll k = a[n-1];

    for (ll i=a[0]; i<=k; i++) {
        if (ex[i]==0) continue;
        if (pr[i]==0) {
            for (ll j = i+i; j<=k; j+=i) pr[j] = 1;
        }
    }
    for (int i=0; i<n; i++) {
        if (cnt[a[i]]==1&&pr[a[i]]==0) ans++;
    }nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 28696
n,a,b = gets.strip.split.map(&:to_i)
#n,a,b = STDIN.gets.chomp.split(" ").map(&:to_i)
result = 0
 
(1..n).each do |i|
  j = i
  sum = 0
  while j > 0
    sum += j % 10
    j = j / 10
  end
  if sum >= a && sum <= b
    result += i
  end
end
 
puts result

Measured memory_bytes: 1788
def a():
    s, t  = input().split()
    s_n, t_n = input().split()
    u = input()
    if u == s:
        s_n = int(s_n) - 1
    elif t == u:
        t_n = int(t_n) - 1
    return str(s_n) + " " + str(t_n)
print(a())

Measured memory_bytes: 3060
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, Adj[N][N];
int color[N], d[N], f[N], time;

void visit(int);
void depth_first_search();

int main(){
  int u, v, k, i, j;
  
  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);
    u--;
    for(j = 0; j < k; j++){
      scanf("%d", &v);
      Adj[u][--v] = 1;
    }
  }

  depth_first_search();

  return 0;
}

void visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++time;
  for(v = 0; v < n; v++){
    if(Adj[u][v] == 0)   continue;
    if(color[v] == WHITE)    visit(v);
  }
  color[u] = BLACK;
  f[u] = ++time;
}

void depth_first_search(){
  int u;
  for(u = 0; u < n; u++) 
    color[u] = WHITE;
  time = 0;

  for(u = 0; u < n; u++)
    if(color[u] == WHITE)   visit(u);

  for(u = 0; u < n;  u++)
    printf("%d %d %d\n", u + 1, d[u], f[u]);
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
S = readline()
count = 0
for i in range(10):
    a = S.find(str(i))
    if a == -1: 
        continue
    for j in range(10):
        b = S.find(str(j),a+1)
        if b == -1: 
            continue
        for k in range(10):
            c = S.find(str(k),b+1)
            if c != -1: count +=1
print(count)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	cin>>n;

	double ans=0;
	rep(i, n){
		double x;
		string u;
		cin>>x>>u;
		if(u=="JPY"){
			ans+=x;
		} else{
			ans+=x*380000.0;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string s;cin>>s;
    int a=-1,z=0;
    REP(i,s.size()){
        if(s[i]=='A'&&a==-1)a=i;
        if(s[i]=='Z')z=i;
    }
    cout<<z-a+1<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
  cin >> N;
    vector<int> p(N);
    int c =0;
    for (int i =0;i<N;i++){
        cin >>p.at(i);
        if (p.at(i)!=i+1){
            c++; 
        }
    }
    if (c<=2){
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	max := 0
	ans := 1
	for i := 1; i <= n; i++ {
		a := i
		var cnt int
		for a > 0 {
			if a%2 != 0 {
				break
			}
			a /= 2
			cnt++
		}
		if cnt > max {
			max = cnt
			ans = i
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

#define ll long long
#define ld long double

//#define TEST

int n;
vector<vector<int>> g;
vector<int> d_u, d_v;

void dfs_v(int v, int cur = -1) {
	static vector<bool> visited(n, false);
	visited[v] = true;
	d_v[v] = ++cur;
	for (auto nx : g[v])
		if (!visited[nx])
			dfs_v(nx, cur);
}
void dfs_u(int v, int cur = -1) {
	static vector<bool> visited(n, false);
	visited[v] = true;
	d_u[v] = ++cur;
	for (auto nx : g[v])
		if (!visited[nx])
			dfs_u(nx, cur);
}

signed main() {
	cin >> n;
	g.resize(n); d_u.resize(n); d_v.resize(n);
	int u, v; cin >> u >> v;
	--u; --v;
	for (int i = 0; i < n - 1; ++i) {
		int a, b; cin >> a >> b;
		--a; --b;
		g[a].push_back(b); g[b].push_back(a);
	}
	dfs_v(v);
#ifdef TEST
	for (auto dvi : d_v)
		cout << dvi << " ";
	cout << endl;
#endif
	dfs_u(u);
#ifdef TEST
	for (auto dui : d_u)
		cout << dui << " ";
	cout << endl;
#endif

	int ans = 0;
	for (int i = 0; i < n; ++i)
		ans = max(ans, d_v[i] > d_u[i] ? d_v[i] - 1 : 0);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10368
#include<stdio.h>

int main(void){
  int n,i;
  int max;
  int a[7]={1,2,4,8,16,32,64};
  
  scanf("%d",&n);
  for(i=0;i<7;i++){
    if(a[i]<=n){
      max=a[i];
    }
  }
  printf("%d",max);
    
  return 0;
}

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

int main()
{
	int N,K;
	std::vector<int> h;
	cin >> N;
	cin >> K;
	h.resize(N);
	for (int i = 0; i < N; i++) cin >> h[i];
	vector<int> ans(N);
	ans[0] = 0;
	for (int i = 1; i < N; i++) {
		int tmp = 1000000000;
		for (int k = K; k >= 1; k--) {
			if (i - k >= 0) {
				tmp = min(ans[i - k] + abs(h[i] - h[i - k]),tmp);
			}
		}
		ans[i] = tmp;
	}
	
	cout << ans[N - 1] << endl;

	return 0;
}

Measured memory_bytes: 1024
use num::One;

#[derive(Clone)]
struct Func {
    p: Vec<usize>,
}

impl std::ops::Mul for Func {
    type Output = Self;
    fn mul(self, rhs: Self) -> Self {
        let n = self.p.len();
        let mut p = vec![0; n];
        for (c, a) in p.iter_mut().zip(self.p.iter()) {
            *c = rhs.p[*a];
        }
        Func {
            p
        }
    }
}

impl One for Func {
    fn one() -> Self {
        Func {
            p: (0..200_000).collect()
        }
    }
}

fn run() {
    proconio::input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }
    let mut f = Func::one();
    for (p, a) in f.p.iter_mut().zip(a.iter()) {
        *p = *a - 1;
    }
    let ans = num::pow::pow(f, k).p[0] + 1;
    println!("{}", ans);
}

fn main() {
    run();
}


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

#define Pi 3.14159265358973284626

int main(void){
    double a,b,h,m;
    scanf("%lf %lf %lf %lf",&a,&b,&h,&m);

    long double kaku=(m/60-(h/12+m/720))*2*Pi;
    if(kaku<0){
        kaku*=-1;
    }
    long double kyuori2=a*a + b*b - 2*a*b*cos(kaku);
    printf("%.15Lf\n",sqrtl(kyuori2));

    return 0;
}


Measured memory_bytes: 2516
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3
    ^lb   ^ub */
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define TEST_ID 0
#define fopn(STR,MODE) fopen((STR).c_str(),MODE)
#define ASSERT(A,B) \
if(A!=B) {\
cerr<< "At line:"<< __LINE__ << endl;\
cerr<< #A << "is '" << A << "'" <<endl;\
cerr<<#B<<"is '"<<B<<"'"<<endl;\
throw "Assertion failed";\
    }
//#define ASSERT(A,B) {}
using namespace std;
typedef long long ll;
typedef long double ld;
ll N,X;
ll emd(ll x, ll y) {
    if (x==y)
        return x;
    if (x==0)
        return -y;
    if (x>y)
        return emd(y,x);
    return emd(y%x,x) + 2 * x * (y/x);
}
int main() {
    vector<char> buf(1<<24);
    fread(&buf[0],1,buf.size(),stdin);
    istringstream ist(&buf[0]);
    stringstream ost;
    ost<< fixed << setprecision(15);

    ist >> N >> X;
    ost << N + emd(N-X,X)<< endl;
    string o=ost.str();
    fwrite(o.c_str(),1,o.size(),stdout);
    return 0;
}


Measured memory_bytes: 16640
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  vl f(100);
  f[0]=2;f[1]=1;
  ll n;cin>>n;
  for(ll i=2;i<=n;i++)f[i]=f[i-1]+f[i-2];
  cout<<f[n]<<endl;
}


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

long long _calc_comb(long long n) {
    return (n * (n-1)) / 2;
}

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

    int a, as[n+1];
    long long counts[n+1]={0};
    rep(i, n) {
        cin >> a;
        as[i+1] = a;
        counts[a] += 1;
    }
    long long base = 0;
    rep(i, n) {
        base += _calc_comb(counts[i+1]);
    }
    rep(i, n) {
        cout << base - (counts[as[i+1]] - 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

int main(){
    ll n;cin >> n;
    bool a = false;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            if(i * j == n){
                a = true;
                break;
            }
        }

    }
    if(a){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define INF 1e9+7
#define ll long long
#define f(x) for(ull i=0;i<x;i++)
#define F first
#define S second
#define N 1000005
#define M 1000000007
#define mp make_pair
#define ull unsigned long long
#define sc(n) scanf("%d",&n)
#define gcd __gcd
using namespace std;
ll a[1002];
int sp[2000]={0};
void seive(int n=1500){
    sp[1]=1;
    for(int i=2;i<=n;i+=2){
        sp[i]=2;
    }
    for(int i=3;i<=n;i+=2){
        if(!sp[i]){
            sp[i]=i;
            for(int j=i;j<=n;j+=i){
                if(!sp[j])
                    sp[j]=i;

        }
    }
}
}
int main() {
	ios::sync_with_stdio(false);
    int n,k;
    ll c,sum=1;
    seive();
    cin>>n;
    for(int i=1;i<1002;i++)
        a[i]=1;
    for(int i=2;i<=n;i++){
        k=i;
        while(sp[k]!=1){
            a[sp[k]]++;
            k/=sp[k];
        }
    }
    for(int i=1;i<1002;i++){
        a[i]%=M;
        sum=(sum*a[i])%M;
    }
    cout<<sum<<endl;
    return 0;
}


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

int main( )
{
    int x = 0, mx = 0, n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'I') {
            x++;
        }
        else {
            x--;
        }
        mx = max(mx, x);
    }
    cout << mx << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		if(a<b){
			if(c<a){
				System.out.println(b-c);
			}else {
				if(b>c) {
					System.out.println(b-a);
				}else {
					System.out.println(c-a);
				}
			}
		}else {
			if(b>c) {
				System.out.println(a-c);
			}else{
				if(a>c) {
					System.out.println(a-b);
				}else {
					System.out.println(c-b);
				}
			}
		}

	}
}


Measured memory_bytes: 23764
using Yorukatsu051.Questions;
using Yorukatsu051.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu051.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/abc048/tasks/abc048_b
    /// </summary>
    public class QuestionD : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var abx = inputStream.ReadLongArray();
            var a = abx[0];
            var b = abx[1];
            var x = abx[2];

            if (a == 0)
            {
                if (b == 0)
                {
                    yield return 1;
                }
                else
                {
                    yield return b / x + 1;
                }
            }
            else
            {
                yield return b / x - (a - 1) / x;
            }
        }
    }
}


namespace Yorukatsu051
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionD();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu051.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu051.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}


pair<int, int> E[200001];
int H[200001];
int kotae[100001];
int Vis[100001];
void sagasu(int P, int D, int C) {
	if (D == 0 && kotae[P] == 0) kotae[P] = C;
	else if (Vis[P] < D) {
		Vis[P] = D;
		if (kotae[P] == 0) kotae[P] = C;
		for (int p = H[P]; p; p = E[p].second) {
			sagasu(E[p].first, D - 1, C);
		}
	}
}

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


	int N, M, Q;
	N = getint();
	M = getint();
	for (int i = 1; i < 2 * M; i += 2) {
		int a = getint(), b = getint();
		E[i] = mp(a, H[b]);
		H[b] = i;
		E[i + 1] = mp(b, H[a]);
		H[a] = i + 1;
	}
	Q = getint();
	int v[100000], d[100000], c[100000];
	rep(i, Q) {
		v[i] = getint();
		d[i] = getint();
		c[i] = getint();
	}
	for (int i = Q - 1; i >= 0; i--) {
		sagasu(v[i], d[i], c[i]);
	}
	rep1(i, N) {
		putint(kotae[i]);
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 5504