akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    map<ll, vector<ll>> mp;
    for (ll i = 0; i < n; i++)
    {
        ll a, b;
        cin >> a >> b;
        mp[a].push_back(b);
    }
    ll ans = 0;
    priority_queue<ll> pq;

    for (ll i = 0; i <= m; i++)
    {
        for (auto p : mp[i])
        {
            pq.push(p);
        }
        if (pq.empty())
        {
            continue;
        }
        ans += pq.top();
        pq.pop();
    }

    cout << ans << endl;
}

Measured memory_bytes: 10880
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 2e5;
int a[N+3];
int n,m;

int main()
{
	scanf("%d%d",&n,&m); int cnt = 0;
	for(int i=1; i<=m; i++) {scanf("%d",&a[i]); cnt += (a[i]&1);}
	if(m==1)
	{
		if(a[1]==1) printf("1\n1\n1\n");
		else printf("%d\n2\n%d %d\n",a[1],1,a[1]-1);
		return 0;
	}
	else if(m==2)
	{
		if(a[1]==1 && a[2]==1) {printf("1 1\n1\n2\n");}
		else if(a[1]==1) {printf("1 %d\n1\n%d\n",a[2],n);}
		else {printf("%d %d\n2\n%d %d\n",a[1],a[2],a[1]-1,a[2]+1);}
		return 0;
	}
	if(cnt>2) {printf("Impossible"); return 0;}
	if(cnt==1)
	{
		for(int i=1; i<=m; i++) if(a[i]&1) {swap(a[i],a[1]); break;}
	}
	else
	{
		int flag = 0;
		for(int i=1; i<=m; i++) if(a[i]&1) {flag++; if(flag==1) swap(a[i],a[1]); else {swap(a[i],a[m]); break;}}
	}
	for(int i=1; i<=m; i++) printf("%d ",a[i]); puts("");
	printf("%d\n",a[1]==1 ? m-1 : m);
	if(a[1]>1) printf("%d ",a[1]-1);
	for(int i=2; i<=m; i++) printf("%d ",a[i]+(i==m?1:0)); puts("");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
#define N 1000010
using namespace std;
LL a,b,c,d;
int main()
{
	cin >> a >> b >> c >> d;
	cout << max(max(max(a*c,b*c),a*d),b*d);
	return 0;
}



Measured memory_bytes: 3548
#include<iostream>
#include<cstring>
#include<iomanip>
using namespace std;

#define MAX_N 1000

double x[MAX_N][MAX_N];
double t[MAX_N][MAX_N];
int n, m, l;
int p[MAX_N][3];
double dp[MAX_N][MAX_N];
double boss[MAX_N];
double kakuritsu;
double res;

int main() {
	cin >> n >> m >> l;
	for (int h = 0; h < n; h++) {
		cin >> p[h][0] >> p[h][1] >> p[h][2];
		//kakuritsu calc.
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1.0;
		for (int i = 1; i <= m; i++) {
			for (int j = 0; j <= m; j++) {
				dp[i][j] += dp[i - 1][j] * (100.0 - p[h][0]) / 100.0;
				dp[i][j + 1] += 1.0 * dp[i - 1][j] * p[h][0] / 100.0;
			}
		}
		for (int i = 0; i <= m; i++) {
			x[h][i] = dp[m][i];
		}
		//time calc.
		for (int i = 0; i <= m; i++) {
			t[h][i] = (1.0*l / p[h][2]) + p[h][1] * i;
		}
	}
	//kakuritsu calc 2.
	for (int h = 0; h < n; h++) {
		res = 0.0;
		for (int i = 0; i <= m; i++) {
		memset(boss, 0, sizeof(boss));
		kakuritsu = 1.0;
			for (int j = 0; j < n; j++) {
				if (h != j) {
					for (int k = 0; k <= m; k++) {
						if (t[h][i] < t[j][k]) {
							boss[j] += x[j][k];
						}
					}
					kakuritsu *= boss[j];
				}
			}
			res += kakuritsu*x[h][i];
		}
		cout << fixed << setprecision(15) << res << endl;
	}
	return 0;
}

Measured memory_bytes: 15572
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>

int n;
bool a[4];

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    char s;
    cin>>s;
    if(s=='G') a[0]=true;
    if(s=='P') a[1]=true;
    if(s=='W') a[2]=true;
    if(s=='Y') a[3]=true;
  }
  int ans=0;
  for(int i=0;i<4;i++)
    if(a[i]) ans++;

  if(ans==3)
    cout<<"Three"<<endl;
  else
    cout<<"Four"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int N, res;
  rd(N);
  for(res=111;;res+=111){
    if(N <= res){
      break;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// {
//   int N, res;
//   rd(N);
//   for(res=111;;res+=111) if(N <= res) break;
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define POK cout << "OK" << endl;
#define PNO cout << "NO" << endl
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  int res = 0;
  rep(i, n) {
    int temp;
    cin >> temp;
    res += (temp - 1) != i;
  }
  if (res == 0 or res == 2)
    PYES;
  else
    PNO;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Deque;
import java.util.ArrayDeque;

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

    String input = sc.nextLine();

    System.out.println(calc(input));
  }

  public static boolean inputIsOperand(String input) {
    try {
      Integer.parseInt(input);
      return true;

    } catch (NumberFormatException e) {
      return false;
    }
  }

  public static int calc(String input) {
    Deque<Integer> operand = new ArrayDeque<Integer>(100000);
    String[] inputs = input.split(" ");

    int operand1, operand2;
    int result = 0;

    for (String str : inputs) {

      if (str.equals("+")) {
        operand1 = operand.removeFirst();
        operand2 = operand.removeFirst();
        operand.offerFirst(operand2 + operand1);

      } else if (str.equals("-")) {
        operand1 = operand.removeFirst();
        operand2 = operand.removeFirst();
        operand.offerFirst(operand2 - operand1);

      } else if (str.equals("*")) {
        operand1 = operand.removeFirst();
        operand2 = operand.removeFirst();
        operand.offerFirst(operand2 * operand1);

      } else {
        operand.offerFirst(Integer.parseInt(str));
      }
    }

    return operand.removeFirst();
  }
}



Measured memory_bytes: 26700
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int d = sc.nextInt();
			int n = sc.nextInt();
			
			if (d == 0) {
				if (n == 100) {
					System.out.println(101);
				} else {
					System.out.println(n);
				}
			} else {
				long num = 100;
				if (d == 2) {
					num *= 100;
				}
				if (n == 100) {
					System.out.println(num * 101);
				} else {
					System.out.println(num * n);
				}
			}
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <vector>
#define MAX 10010
#define rep(i,p) for(int i=0;i<p;i++)
#define pb push_back
using namespace std;
int n,hoge,foo,visit_time=1;
int graph[MAX][MAX] = {0};
int d[MAX]; // ????????????
int f[MAX]; // ??£??\????????????????????????

void dfs (int cur) {
  // visiting cur
  d[cur] = visit_time;
  visit_time++;

  rep(dst,n) {
    if (graph[cur][dst] == 1 && d[dst] == -1) dfs(dst);
  }
  f[cur] = visit_time;
  visit_time++;
}

int main(){
  cin >> n;
  rep(i,n) {
    d[i] = -1;
    f[i] = -1;
  }
  rep(i,n) {
    cin >> hoge >> foo;
    rep(j,foo) {
      cin >> hoge;
      graph[i][hoge-1] = 1;
    }
  }
  rep(i,n) if (d[i] == -1) dfs(i);
  rep(i,n) cout << i+1 << " " << d[i] << " " << f[i] << endl;
  return 0;
}

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

int main() {
  int k, x;
  cin >> k >> x;

  vector<int> a(2*k-1);

  a.at(0) = x - k + 1;
  for (int i = 1; i < 2*k-1; i++) {
    a.at(i) = a.at(i-1) + 1;
  }
  for (int i = 0; i < 2*k-1; i++) {
    if (i < 2*k-2)
      cout << a.at(i) << " ";
    else
      cout << a.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
#define ll long long
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp;}
    y>>=1;
    tmp=tmp*tmp;
  }
  return res;
}
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> minprice(N);
  vector<int> price(M);
  vector<int> key(N);
  unordered_map<int,int> mp;
  int dp[1020][4120];
  for(int i=0;i<M;i++){
    int a,b;//値段、開けれる宝箱の数
    int rock=0;
    cin>>a>>b;
    price.at(i)=a;
    //cout<<i<<" "<<price.at(i)<<endl;
    for(int j=0;j<b;j++){
      int c;
      cin>>c;
      //vec.at(i).push_back(c);
      rock+=pow(2,c-1);
    }
    mp[i+1]=rock;
  }
  for(int i=1;i<=M;i++){
    for(int j=0;j<(1<<N);j++){
      if(j==0){dp[i][j]=0;}
      else{dp[i][j]=MOD;}
    }
  }
  for(int i=1;i<=M;i++){
    for(int j=0;j<(1<<N);j++){
      if(i>1){dp[i][j]=dp[i-1][j];}
    }
    for(int j=0;j<(1<<N);j++){
      int a=j&mp[i];
      if(a==j){
        dp[i][j]=min(dp[i][j],price.at(i-1));
      }
      else if(a==mp[i] && i>1){
        dp[i][j]=min(dp[i][j-mp[i]]+price.at(i-1),dp[i][j]);
        dp[i][j]=min(dp[i][j],dp[i-1][j]);
      }
      int c=j-a;
      if(i>1){
        dp[i][j]=min(dp[i][j],dp[i-1][c]+price.at(i-1));
      }
      //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    }
  }
  int b=(1<<N);
  b--;
  if(dp[M][b]!=MOD){cout<<dp[M][b]<<endl;}
  else{cout<<-1<<endl;}
}

Measured memory_bytes: 19988
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    int a,sum=0;

    cin>>n>>m;
    for(int i=0;i<m;i++){ cin>>a; sum+=a; }

    if(sum>n) cout<<"-1"<<endl;
    else cout<<n-sum<<endl;
    return 0;
}

Measured memory_bytes: 3584
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
ans = 0

for n in sorted(ab, key=lambda x: x[0]):
    cnt += n[1]
    if cnt >= K:
        ans = n[0]
        break

print(ans)


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

int main() {
	int n, a, b, i, j, c[1000], ans = 0, s, d,k;
	cin >> n >> a >> b >> d;
	for (i = 0; i < n; i++) cin >> c[i];
	sort(c,c+n,greater<int>());
	s = d;
	for (i = 0; i < n; i++) {
		j = i + 1;
		s += c[i];
		k = a + b*j;
		if (s / k > ans) ans = s / k;
	}
	if (d / a > ans) ans = d / a;
	cout << ans << endl;
	cin >> ans;
	return 0;
}


Measured memory_bytes: 3172
#import math
h,w = map(int, input().split())

if h == 1 or w == 1:
  print(1)
  exit()

x = h*w
if x % 2 == 0:
  print(x//2)
else:
  print(x//2 + 1)
#print(math.ceil(h*w/2))

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

void sorter(int*, int);

int main() {
  int n,m,n1;
  cin >> n >> m;
  int food[n][m];

  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    if (i == 0) {
      n1 = k;
    }
    for (int j = 0; j < m; j++) {
      if (k != 0) {
        cin >> food[i][j];
        k--;
      }
      else {
        food[i][j] = 0;
      }
    }
  }

  for(int i = 0; i < n; i++) {
    sorter(food[i],m);
  }

  int like = 0;
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n - 1; i++) {
      if((food[i][j] != food[i + 1][j]) || (food[i][j] == 0)) {
        like--; break;
      }
    }
    like++;
  }

  if (n == 1) {
    like = n1;
  }

  cout << like << endl;
  return 0;
}

void sorter(int *array, int size) {
  int dummy[size] = {0};
  int mem = 0;
  for(int i = 0; i < size; i++) {
    mem = array[i];
    if (mem != 0) {
      dummy[mem - 1] = mem;
    }
  }
  for(int i = 0; i < size; i++) {
    array[i] = dummy[i];
  }
}


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

int main() {
	int n; cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) cin >> d[i];

	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());

	cout << d.size() << endl;

	return 0;
}

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

using namespace std;
#define ll long long int

int main()
{
   ll t;
   t = 1;	
   //cin t;
   while(t--){
         ll a , b , x;
         cin >> a >> b >> x;
         cout << floor(a * min( b - 1, x) * 1.0 / b) << endl;    
   }
}


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

int main(){
  cout << setprecision(15);
  int N, K; cin >> N >> K;
  vector<int> A(N); 
  rep(i, N) {
    int p; cin >> p;
    A[i] = p + 1;
  }
  vector<long long> ans;
  long long sum = 0;
  rep(i, N) {
    sum += A[i];
    if (i < K - 1) continue;
    ans.push_back(sum);
    sum -= A[i - K + 1];
  }
  long long maxans = 0;
  for (long long x :ans) maxans = max(maxans, x); 
  cout << (long double)maxans / 2 << endl;
}


Measured memory_bytes: 3188
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	var ans, sum int
	scores := make([]int, N)
	for i := range scores {
		scores[i] = nextInt()
		sum += scores[i]
	}
	sort.Ints(scores)
	if sum%10 != 0 {
		ans = sum
	} else {
		for i := 0; i < N; i++ {
			if scores[i]%10 != 0 {
				ans = sum - scores[i]
				break
			}
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t,h[maxn],tot,ans[maxn];
set<int>comp[maxn];
struct node
{
    int c,id;
    node(int _c,int _id)
    {
        c=_c,id=_id;
    }
    bool operator<(const node&p)const
    {
        return c>p.c;
    }
};
struct node1
{
    int to,nxt,com;
}e[maxn<<2];
void add(int x,int y,int z)
{
    tot++;
    e[tot].to=y;
    e[tot].com=z;
    e[tot].nxt=h[x];
    h[x]=tot;
}
priority_queue<pair<int,int> >p;
int main()
{
    int i,j;
    memset(ans,inf,sizeof ans);
    scanf("%d%d",&n,&m);
    while(m--)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        add(a,b,c);
        add(b,a,c);
    }
    p.push({0,1});ans[1]=0;
    while(!p.empty())
    {
        int now=p.top().se,ca=-p.top().fi;
        p.pop();
        if(ans[now]<ca)continue;
        for(i=h[now];i;i=e[i].nxt)
        {
            int to=e[i].to,to_com=e[i].com;
            int to_ca=ca+(!comp[now].count(to_com));
            if(ans[to]>to_ca)
            {
                ans[to]=to_ca;
                p.push({-to_ca,to});
                comp[to].clear();
                comp[to].insert(to_com);
            }
            else if(ans[to]==to_ca)
            {
                comp[to].insert(to_com);
            }
        }
    }
    printf("%d\n",ans[n]==inf?-1:ans[n]);
    //system("Pause");
    return 0;
}


Measured memory_bytes: 20216
N, M = map(int, input().split())
minimum = []
maximum = []
for i in range(M):
  L, R = map(int, input().split())
  minimum.append(L)
  maximum.append(R)
  
ans = int(min(maximum) - max(minimum) + 1)
if ans < 0:
  print(0)
else:
  print(ans)

Measured memory_bytes: 10996
import heapq

def main():
    N, M = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        G[a - 1].append((b - 1, c))
        G[b - 1].append((a - 1, c))
    used = set()
    for i in range(N):
        H = []
        for b, c in G[i]:
            heapq.heappush(H, (c, i, b))
        D = [10**10] * N
        D[i] = 0
        while H:
            c, a, b = heapq.heappop(H)
            if D[b] < c:
                continue
            D[b] = c
            if a < b:
                used.add((a, b))
            else:
                used.add((b, a))
            for d, cc in G[b]:
                if D[d] > c + cc:
                    D[d] = c + cc
                    heapq.heappush(H, (c + cc, b, d))
    return M - len(used)

print(main())


Measured memory_bytes: 9360
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) {

		while (true) {
			int N = nextInt();
			if (N == 0) {
				break;
			}

			Map<Integer, ArrayList<Integer[]>> map = new HashMap<Integer, ArrayList<Integer[]>>();
			for (int i = 0; i <= N; i++) {
				int point = nextInt();
				ArrayList<Integer[]> list = new ArrayList<Integer[]>();
				for (int j = 0; j < point; j++) {
					int x = nextInt();
					int y = nextInt();
					Integer[] push = { x, y };
					list.add(push);
				}
				map.put(i, list);
			}

			for (int i = 1; i < map.size(); i++) {
				if (map.get(0).size() != map.get(i).size()) {
					continue;
				}
				boolean is_same = isSame(map.get(0), map.get(i));
				if (!is_same) {
					Collections.reverse(map.get(i));
					is_same = isSame(map.get(0), map.get(i));
				}
				if (is_same) {
					System.out.println(i);
				}
			}
			System.out.println("+++++");
		}
	}

	static boolean isSame(ArrayList<Integer[]> list0, ArrayList<Integer[]> list1) {
		boolean is_same = true;
		// 長さを調べる
		for (int j = 1; j < list1.size(); j++) {
			int length = Math.abs(list1.get(j)[0] - list1.get(j - 1)[0]
					+ list1.get(j)[1] - list1.get(j - 1)[1]);
			int length0 = Math.abs(list0.get(j)[0] - list0.get(j - 1)[0]
					+ list0.get(j)[1] - list0.get(j - 1)[1]);
			if (length != length0) {
				is_same = false;
				break;
			}
		}
		if (!is_same) {
			return false;
		}
		boolean[] right0 = isRight(list0);
		boolean[] right1 = isRight(list1);
		for (int i = 0; i < right1.length; i++) {
			if ((!right0[i] && right1[i]) || (right0[i] && !right1[i])) {
				is_same = false;
				break;
			}
		}

		return is_same;
	}

	static boolean[] isRight(ArrayList<Integer[]> list) {
		boolean[] right = new boolean[list.size() - 2];

		for (int i = 2; i < list.size(); i++) {
			Integer[] first = list.get(i - 2);
			Integer[] second = list.get(i - 1);
			Integer[] third = list.get(i);
			if ((second[0] > first[0] && third[1] < second[1])
					|| (first[1] > second[1] && third[0] < second[0])
					|| (first[1] < second[1] && third[0] > second[0])
					|| (second[0] < first[0] && third[1] > second[1])) {
				right[i - 2] = true;
			}
		}

		return right;
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

	static char nextChar() {
		try {
			int b = System.in.read();
			while (b != -1 && (b == ' ' || b == '\r' || b == '\n'))
				;
			if (b == -1)
				return 0;
			return (char) b;
		} catch (IOException e) {
		}
		return 0;
	}

}

Measured memory_bytes: 20508
import sys
input = sys.stdin.readline
import numpy as np

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n = I()
mylist = [list(MI()) for i in range(n-1)]

def main(j):
    time = 0
    for i in range(j,n-1):
        c, s, f = mylist[i]
        if time < s:
            time = s
        if (time - s) % f != 0:
            time += (f - (time - s) % f) #待ち時間を足す
        time += c
    print(time)
    
    
for i in range(n-1):
    main(i)
print(0)

Measured memory_bytes: 12260
def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L, R = A[left: left + n1], A[mid: mid + n2]

    L.append([0,2000000000])
    R.append([0,2000000000])

    i, j = 0, 0
    for k in range(left, right):
        #print("k", k, "l", left, "m", mid, "r", right, "L", L, "R", R)
        if L[i][1] <= R[j][1]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1


def mergeSort(A, left, right):
    #print("l", left, "r", right)
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)


def partition(A, p, r):
    x = A[r][1]
    i = p - 1

    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]

    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1


def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q - 1)
        quick_sort(A, q + 1, r)


n = int(input())
cards = []
merge_cards = []
for _ in range(n):
    tmp = input().split(' ')
    cards.append([tmp[0], int(tmp[1])])
    merge_cards.append([tmp[0], int(tmp[1])])

mergeSort(merge_cards, 0, n)

quick_sort(cards, 0, n - 1)

if merge_cards == cards:
    print("Stable")
else:
    print("Not stable")

for card in cards:
    print(*card)


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

#define ll long long int

char s[105][105];
ll h , w , dp[105][105][3] , flag[105][105][3];

ll findRoute(ll r , ll c , ll isAddable){

	//basecase
	if(r == h && c == w){

		if(s[r][c] == '#') return 1;

		else if(s[r][c] == '.' && isAddable) return 1;

		return 0;
	}

	//memorization
	if(flag[r][c][isAddable] == 1) return dp[r][c][isAddable];


	//recursive relation
	ll cur = 0 , right = 0, down = 0 , res = 1000000000;

	if(s[r][c] == '#'){

		if(c < w) right = findRoute(r , c + 1 , 1);
		if(r < h) down  = findRoute(r + 1 , c , 1);
		//printf("%lld %lld\n", r , c);
	}

	else if(s[r][c] == '.'){

		if(isAddable){

			cur = 1;
		}

		if(c < w) right = findRoute(r , c + 1 , 0) + cur;
		if(r < h) down  = findRoute(r + 1 , c , 0) + cur;
	}

	

	if(r < h && c < w){

		res = min(down , right);
		//res = min(res , down);
	}

	else if(r == h) res = right;

	else if(c == w) res = down;

	dp[r][c][isAddable] = res;
	flag[r][c][isAddable] = 1;

	return dp[r][c][isAddable];
}


int main(){

	ll ans = 0 , i , j;
	
	cin >> h >> w;

	for( i = 1 ; i <= h ; i++) for(j = 1 ; j <= w ; j++) cin >> s[i][j];

	ans = findRoute(1 , 1 , 0);

	cout << ans << endl;
}

Measured memory_bytes: 768
a, b = map(int, input().split())

def gcd(a, b):
    # 大きい方を被除数、小さい方を除数とする
    dividend = max(a, b)
    divider = min(a, b)

    if divider == 0:
        return dividend

    # 最大公約数を見つけるまで繰り返す
    while dividend % divider != 0:
        # 除算を行い、その除数を次回の被除数、剰余を次回の除数として処理を繰り返す
        r = dividend % divider
        dividend = divider
        divider = r

    # 一方がもう一方を割り切れた時点で、その除数を最大公約数とみなせる
    return divider

ans = int((a * b) / gcd(a, b))
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n; int cnt = 0;
	for (int i = 1; i <= n; i++)
	{
		int m;
		cin >> m;
		if (i % 2 == 1 && m % 2 == 1)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3568
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;
int main(){
    string S;
    cin >> S;
    string head_s = S.substr(0, 2);
    string tail_s = S.substr(2,2);
    int head = stoi(head_s);
    int tail = stoi(tail_s);
    bool head_MM = false, tail_MM = false;
    if(head < 13 && 0 < head){
        head_MM = true;
    }
    if(tail < 13 && 0 < tail){
        tail_MM = true;
    }
    if(head_MM && tail_MM)cout << "AMBIGUOUS" << endl;
    else if (head_MM)
    {
        cout << "MMYY" << endl;
    }
    else if(tail_MM){
        cout << "YYMM" << endl;
    }
    else{
        cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
 
struct UnionFind{
	vector<long> par;
 
	UnionFind(long N) : par(N) {
		for(long i=0;i<N;++i) par[i] = i;
	}
 
	long root(long x){
		if(par[x] == x) return x;
		else root(par[x]);
	}
 
	void unite(long x, long y){
		long rx = root(x);
		long ry = root(y);
		if(rx == ry) return;
		else par[rx] = ry;
	}
 
	bool same(long x, long y){
		long rx = root(x);
		long ry = root(y);
		return rx == ry;
	}
};
 
int main() {
	long N, M;
	cin>>N>>M;
	long A[M], B[M];
	for(long i=0;i<M;++i){
		cin>>A[i]>>B[i];
		A[i]--;
		B[i]--;
	}
 
	UnionFind tree(N);
 
	long ans[M];
	ans[M-1] = N*(N-1)/2;
	map<long, long>size;
 
	for(long i=0;i<N;++i){
		size[i] = 1;
	}
 
	for(long i=M-1;i>=0;--i){
		if(!tree.same(A[i], B[i]) & i>0){
			ans[i-1] = ans[i] - size[tree.root(A[i])]*size[tree.root(B[i])];
			long a = size[tree.root(A[i])];
			long b = size[tree.root(B[i])];
			size[tree.root(A[i])] += b;
			size[tree.root(B[i])] += a;
          	if(b>a){
				tree.unite(A[i], B[i]);
            }
          	else{
              	tree.unite(B[i], A[i]);
            }
		}
		else if(i>0){
			ans[i-1] = ans[i];
		}
	}
	for(long i=0;i<M;++i){
		cout<<ans[i]<<endl;
	}
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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 C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100'000
#define MAX_M 100'000

using P = pair<i64, i64>;

int main() {
    i64 N, M; cin >> N >> M;
    vector<P> interval(M);
    REP(i, M) {
        i64 a, b; cin >> a >> b;
        a--; b--;
        interval[i] = {a, b};
    }
    sort(interval.begin(), interval.end(), [](const P &p1, const P &p2) {
        return p1.second < p2.second;
    });

    i64 cnt = 0;
    i64 r;
    REP(i, M) {
        if (i == 0) {
            r = interval[i].second;
            cnt++;
            continue;
        }

        if (interval[i].first >= r) {
            cnt++;
            r = interval[i].second;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1792
# ABC86 C - Traveling
N = int(input())
ans = "Yes"
t, x, y = 0, 0, 0
for i in range(N):
    ti, xi, yi = map(int, input().split())
    dt, dx, dy = ti - t, abs(xi - x), abs(yi - y)
    if dt >= dx + dy and (dt - (dx + dy)) % 2 == 0:
        t, x, y = ti, xi, yi
    else:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 3064
/*
    AUTHOR : TANMAY SINHA
    INORMATION TECHNOLOGY
    BIT MESRA ,RANCHI
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(j,L,R) for(j=L;j<R;j++)
#define per(i,L,R) for(i=L;i>= R;i--)
#define all(con) (con).begin(),(con).end()
#define fi first
#define se second
#define foreach(iter,con) for(auto iter=(con).begin(); iter!=(con).end(); iter++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
const ll INF = 1e18l+10,N = 1e5+10,MAX = 1e6+5;
#define sq(a) ((a)*(a))

unordered_set <ll> s;
ll res,res1;
void printknapSack(ll W, ll wt[], ll val[], ll n)
{
    ll i, w;
    ll K[n + 1][W + 1];
    for (i = 0; i <= n; i++) {
        for (w = 0; w <= W; w++) {
            if (i == 0 || w == 0)
                K[i][w] = 0;
            else if (wt[i - 1] <= w)
                K[i][w] = max(val[i - 1] +
                    K[i - 1][w - wt[i - 1]], K[i - 1][w]);
            else
                K[i][w] = K[i - 1][w];
        }
    }
    res = K[n][W];
    //printf("%d\n", res);
    res1=res;

    w = W;
    for (i = n; i > 0 && res > 0; i--) {
                  if (res == K[i - 1][w])
            continue;
        else {
            //printf("%d ", wt[i - 1]);
             s.insert(i-1);
            res = res - val[i - 1];
            w = w - wt[i - 1];
        }
    }
}

int main()
{
   SPEED
   ll n,t,i,j;
   cin>>n>>t;
   ll a[n],b[n];
   for(i=0;i<n;i++)
   {
       cin>>a[i]>>b[i];
   }
   ll ma = 0;
   printknapSack(t-1,a,b,n);
   for(i=0;i<n;i++)
   {
       if(s.find(i)==s.end())
           ma = max(ma,b[i]);
   }
   res1+= ma;
   cout<<res1<<"\n";
}



Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T& t)
{T f=1;char ch=getchar();t=0;
while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
while(ch>='0'&&ch<='9')t=t*10+ch-'0',ch=getchar();t*=f;}
template <typename T,typename... Args>
inline void read(T& t, Args&... args)
{read(t);read(args...);}
int n;
const long long p=1e9+7;
inline long long power(long long x,long long k)
{
	long long re=1;
	for(;k;k>>=1,x=x*x%p)if(k&1)re=re*x%p;
	return re;
}
long long fic[200005];
long long size[200005],f[200005];
int head[200005],ne[400005],to[400005],total=1;
inline void add(int a,int b)
{
	total++;
	to[total]=b;
	ne[total]=head[a];
	head[a]=total;
}
void dfs1(int now,int fa)
{
	size[now]=1;
	for(int i=head[now];i;i=ne[i])
		if(to[i]!=fa)
		{
			dfs1(to[i],now);
			size[now]+=size[to[i]];
		}
	f[1]=f[1]*size[now]%p;
}
void dfs2(int now,int fa)
{
	if(now!=1)
		f[now]=f[fa]*power(size[now],p-2)%p*(n-size[now])%p;
	for(int i=head[now];i;i=ne[i])
		if(to[i]!=fa)
			dfs2(to[i],now);
}
int main()
{
	read(n);
	for(int i=1,x,y;i<n;i++)read(x,y),add(x,y),add(y,x);
	f[1]=1;
	dfs1(1,0);
	dfs2(1,0);
	long long tp=1;
	for(int i=1;i<=n;i++)tp=tp*i%p;
	for(int i=1;i<=n;i++)
		printf("%lld\n",tp*power(f[i],p-2)%p);
	return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    int flag=0;
    for (int i=1;i<=1000;i++) {
        if (floor(i*0.08)==a&&floor(i*0.1)==b) {
            cout<<i<<endl;
            flag=1;
            break;
        }
    }
    if (flag==0) {
        cout<<-1<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 998244353;
LL qpow(LL a, LL b) {LL s = 1; while (b > 0) {if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1;} return s;}
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
typedef pair<int, int> P;
typedef pair<ULL, int> PLL;
const int maxn = 5e3 + 10;
char ar[maxn];
ULL Hash[maxn], gen = 13131;
int Hash2[maxn], gen2 = 233;
ULL powgen[maxn];
int powgen2[maxn];
int N;
PLL Get(int mid,int i){
	ULL t = Hash[i] - Hash[i - mid] * powgen[mid];
	int t2 = (Hash2[i] - 1ll * Hash2[i - mid] * powgen2[mid] % mod + mod) % mod;
	return PLL(t,t2);
}
bool check(int mid) {
	set<PLL> se;
	for (int i = mid; i <= N; ++i) {
		PLL p = Get(mid,i);
		// ULL t = Hash[i] - Hash[i - mid] * powgen[mid];
		// int t2 = (Hash2[i] - 1ll * Hash2[i - mid] * powgen2[mid] % mod + mod) % mod;
		if (se.find(p) != se.end()) return true;
		if(i-mid-mid+1>=0){
			se.insert(Get(mid,i-mid+1));
		}
	}
	return false;
}
int main(void)
{
	powgen[0] = 1, powgen2[0] = 1;
	for (int i = 1; i < maxn; ++i)
		powgen[i] = powgen[i - 1] * gen, powgen2[i] = 1ll * powgen2[i - 1] * gen2 % mod;
	cin >> N;
	cin >> (ar + 1);
	for (int i = 1; i <= N; ++i) {
		Hash[i] = Hash[i - 1] * gen + ar[i];
		Hash2[i] = (1ll * Hash2[i - 1] * gen2 + ar[i]) % mod;
	}
	int l = 1, r = N;
	while (r >= l) {
		int mid = (l + r) >> 1;
		if (check(mid))
			l = mid + 1;
		else
			r = mid - 1;
	}
	cout << r << endl;


	return 0;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		String[] fiz = new String[10001];
		for (int i = 1; i <= 10000; i++) {
			if (i % 15 == 0)
				fiz[i] = "FizzBuzz";
			else if (i % 5 == 0)
				fiz[i] = "Buzz";
			else if (i % 3 == 0)
				fiz[i] = "Fizz";
			else
				fiz[i] = String.valueOf(i);
		}
		while (true) {
			int m = scanner.nextInt();
			int n = scanner.nextInt();
			if ((m | n) == 0)
				break;
			List<Integer> list = new LinkedList<Integer>();
			for (int i = 1; i <= m; i++) {
				list.add(i);
			}
			int pos = 0;
			for (int i = 1; i <= n; i++) {
				String str = scanner.next();
				if (list.size() == 1)
					continue;
				if (!str.equals(fiz[i])) {
					list.remove(pos);
					pos--;
				}
				pos = pos == list.size() - 1 ? 0 : pos + 1;

			}
			for (int i = 0; i < list.size(); i++) {
				System.out.print(list.get(i));
				System.out.print(i == list.size() - 1 ? '\n' : ' ');
			}

		}
	}
}

Measured memory_bytes: 69728
#include <iostream>
#include <ostream>
#include <istream>
#include <cmath>
#include <string>
#include <vector>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <vector>
#include <set>
#define pb push_back
#define ppb pop_back
using namespace std;
int asd[1005];
int n;
int const mod=1e9+7;
int main()
{
    cin>>n;
    long long sum=1;
    for(int i=1;i<=n;i++)
    {
    	int t=i;
    	for(int j=2;j<=t;j++)
        {
        	while(t%j==0)
        	{
        		asd[j]++;
        		t/=j;
			}
		}
	}
	for(int i=2;i<1000;i++)
	{
		if(asd[i]!=0)
		{
			sum=sum*(asd[i]+1);
			sum%=mod;
		}
	}
	cout<<sum;
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python

#get dimensions
n, m = input().split()
n = int(n)
m = int(m)

nmmatrix = []
mvector = []
result = []

#make matrix
for x in range(n):
    row = input()
    rowSplit = row.split()
    for y in range(len(rowSplit)):
        rowSplit[y] = int(rowSplit[y])
    nmmatrix.append(rowSplit)

#makevector
for x in range(m):
    mvector.append(int(input()))

#multiplication
for x in range(n):
    value = 0
    for y in range(m):
        value += nmmatrix[x][y]*mvector[y]
    result.append(value)
    
#print result
for x in result:
    print(x)

Measured memory_bytes: 7916
import heapq
import collections as c
N, K = map(int, input().split())
A = c.Counter(list(map(int, input().split())))
S = len(list(A.keys()))

V = list(A.values())
heapq.heapify(V)

ans = 0
for _ in range(max(0,S-K)):
	ans += heapq.heappop(V)

print(ans)

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


int main(){
    string s; cin >> s;
    int K; cin >> K;
    set<string> se;
    
    for(int i=0; i<s.length(); i++){
        for(int j=1; j<=5; j++){
            if(i+j<=s.length())
                se.insert(s.substr(i,j));
        }
    }
    int cnt=0;
    for(set<string>::iterator it=se.begin(); it != se.end(); it++,cnt++){
        if(cnt==K-1) cout << *it << endl;
    }
}


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

   char lt;
   int count[26]={};
   int i,num;
   
   while(scanf("%c",&lt)!=EOF) {
       if('A'<=lt&&lt<='Z') {
           num=lt-'A';
           count[num]+=1;
       }
       else if('a'<=lt&&lt<='z') {
           num=lt-'a';
           count[num]+=1;
       }
   }
   
    for(i=0;i<26;i++) printf("%c : %d\n",97+i,count[i]);
   
    return 0;
}



Measured memory_bytes: 2112
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
#define REP(i, a, b) for(int i = int(a); i <= int(b); i++)
#define LOOP(i, v) for(int i = 0; i < v.size(); i++)
#define EPS 1e-9
#define INF 1e12
#define debug(x) cerr << "DEBUG : " << (#x) << " => " << (x) << endl

long long int MOD = 998244353;
long long int fact[300002];

long long int powpow(long long int x, long long int n)
{
  if(n == 0) return 1;
  if(n == 1) return x;
  long long int y = powpow(x, n/2);
  if(n % 2 == 0) return (y*y)%MOD;
  else return (((y*y)%MOD)*x)%MOD;
}

long long int inverse(long long int x)
{
  return powpow(x, MOD-2);
}

long long int combi(long long int x, long long int X)
{
  long long int a = fact[X];
  long long int b = inverse(fact[X-x]);
  long long int c = inverse(fact[x]);
  return (((a*b)%MOD)*c)%MOD;
}

int main()
{
  long long int N, A, B, K;
  
  cin >> N >> A >> B >> K;
  
  fact[0] = 1;
  REP(i, 1, 300000)
  {
    fact[i] = (fact[i-1]*i)%MOD;
  }
  
  long long int res = 0;
  
  for(long long int a = 0; a <= N; a++)
  {
    // Paint a with A
    long long int already = a*A;
    long long int remains = K-already;
    if(remains >= 0 && remains % B == 0)
    {
      long long int b = remains/B;
      if(b <= N)
      {
        // Paint b in B
        long long int poss = (combi(a, N) * combi(b, N))%MOD;
        //printf("%lld %lld - %lld %lld : %lld %lld\n", a, N, b, N, combi(a,N), combi(b,N));
        res = (res+poss)%MOD;
      }
    }
  }
  
  cout << res << endl;
    
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(),a.end());

	ll sum = 0;
	for (int i = 1; i < n; i++)
	{
		sum += a[n-i/2-1];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define ll long long
//#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define re(v) {for(auto &_re : v) cin >> _re;}
#define rre(v){for(auto &_re : v) for(auto &_rre : _re) cin >> _rre;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define prr(v) {for(auto _prr : v) cout << _prr.ff << " " << _prr.ss << endl;}
#define eb emplace_back
using namespace std;
const int M = 1e9 + 7;
const ll mod = 998244353;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define int long long
int n;
ll a[16][16];
ll subset[1<<16];
ll dp[1<<16];
ll f(int b){ // O(3^n);
	ll &x = dp[b];
	if(x!=-1) return x;
	// iterate over all subsets of mask
	int mask = b ^ ((1<<n) - 1);
	x = -1e18;
	for(int i = mask; i > 0; i = (i-1) & mask){
  	x = max(x, subset[i] + f(b | i));
  }
  return x;
}
void solve(){
	cin >> n;
	rep(i,0,n) rep(j,0,n) cin >> a[i][j];
	for(int i=0;i<1<<n;i++){
		for(int j=0;j<n;j++){
			if(!(i>>j&1)) continue;
			for(int k=j+1;k<n;k++){
				if(!(i>>k&1)) continue;
				subset[i] += a[j][k];
			}
		}
	}
	ms(dp, -1);
	dp[(1<<n) - 1] = 0;
	cout << f(0) << endl;
}
int32_t main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }  
}

Measured memory_bytes: 4672
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

char grid[15][1005];

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

    int H, W, k;
    cin>>H>>W>>k;
    FOR(h,H)
    FOR(w,W)
    cin>>grid[h][w];

    int ans=999999;

    FOR(bm,(1<<(H-1))) {
        vi cnt(15, 0);
        int cut=__builtin_popcount(bm);

        FOR(w,W) {
            vi col(15, 0);
            int idx = 0;
            FOR(h,H) {
                if(grid[h][w]=='1')
                    col[idx]++;
                if(bm & (1<<h))
                    idx++;
            }
            bool reset=0;
            FOR(h,H)
                reset |= (col[h] + cnt[h] > k);
            if(reset) {
                cut++;
                FOR(h,H) cnt[h]=0;
            }
            FOR(h,H) cnt[h]+=col[h];
            FOR(h,H) if(cnt[h] >k) cut = 999999;
        }
        cerr<<bitset<10>(bm)<<" = "<<cut<<endl;
        ans |= MIN(cut);
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = [A[i] - i for i in range(n)]
B.sort()
if n % 2 == 0:
    m = [B[n //2 -1], B[n // 2 + 1]]
    ans1 = [abs(B[i] - m[0]) for i in range(n)]
    ans2 = [abs(B[i] - m[1]) for i in range(n)]
    print(min(sum(ans1), sum(ans2)))
else:
    m = B[n // 2]
    ans = [abs(B[i] - m) for i in range(n)]
    print(sum(ans))


Measured memory_bytes: 34756
/*  ex5_2 ACGT
    pandacodeb  */

#include <stdio.h>
#define SIZE 11

int main(void){
    char name[SIZE];
    char *ptr;
    int max = 0, length;

    //input name
    scanf("%s", name);

    ptr = name;
    while (*ptr != '\0'){
        length = 0;
        //find length for each ACGT subsequence
        while (*ptr == 'A' || *ptr == 'C' || *ptr == 'G' || *ptr == 'T'){
            ptr++;
            length++;
        }
        //move to next index
        ptr++;
        
        //update new max value (if have to)
        if (length > max)
            max = length;
    }

    //print out length of the longest ACGT subsequence
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 1728
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

A,B,C,D=get_i
if A+B==C+D
    puts "Balanced"
elsif A+B>C+D
    puts "Left"
else
    puts "Right"
end

Measured memory_bytes: 1788