akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x; 
}

Node treeSearch(Node u, int k){
  if(u==NIL){
    return NIL;
  }
  if(u->key == k){
    return u;
  }
  else if(u->key > k){
    return treeSearch(u->left,k);
  }
  else{
    return treeSearch(u->right,k);
  }
}

Node treeSuccessor(Node x){
  Node y;
  
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  else{
    return NIL;
  }
  
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

/*void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL && z->right == NIL){
    y = z;
  }
  else{
    y = treeSuccessor(z);
  }


  if(y->left != NIL){
    x = y->left;
  }
  else{
    x = y->right;
  }


  if(x != NIL){
    x->parent = y->parent;
  }


  if(y->parent == NIL){
    root = x;
  }
  else if(y == y->parent->left){
    y->parent->left = x;
  }
  else{
    y->parent->right = x;
  }
  
  
  if (y != z){
    z->key = y->key;
  }
}
*/
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
    else 
      x = x->right;
  }
  
  z->parent = y;
  if(y==NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else
    y->right = z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}


void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) {
	printf("yes\n");
      }
      else printf("no\n");
    } 
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
    /* else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/
  }
  
  return 0;
}

Measured memory_bytes: 19360
package main

import (
	"fmt"
)

func main() {
	var n,y int
	fmt.Scan(&n,&y)
	
	for a := 0; a <= n; a++ {
		for b := 0; b <= n - a; b++ {
			sum := 10000 * a + 5000 * b + 1000 * (n - (a+b))
			if sum == y {
				fmt.Printf("%d %d %d",a,b,n-(a+b))
				return
			}
		}
	}
	fmt.Println("-1 -1 -1")
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] trees = new int[N];

		for(int i=0;i<N;i++) {
			trees[i]=sc.nextInt();
		}

		Arrays.sort(trees);
//		System.out.println(Arrays.toString(trees));

		int min=Integer.MAX_VALUE;
		for(int i=0;i<N-K+1;i++) {
			min=Math.min(min,Math.abs(trees[i]-trees[i+K-1]));
		}
		System.out.println(min);
	}


}


Measured memory_bytes: 51664
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      r: usize,
      c: usize,
      k: usize,
      rcv: [(Usize1, Usize1, usize); k]
   }

   let mut map = vec![vec![0; c]; r];
   for (i, j, v) in rcv {
      map[i][j] = v;
   }

   let mut dp = vec![vec![vec![0usize; 4]; c + 1]; r + 1];
   for i in 0..r {
      for j in 0..c {
         for k in 0..=3 {
            dp[i + 1][j + 1][0] = max(dp[i + 1][j + 1][0], dp[i][j + 1][k]);
         }
         for k in 0..=3 {
            dp[i + 1][j + 1][k] = max(dp[i + 1][j + 1][k], dp[i + 1][j][k]);
         }
         if map[i][j] != 0 {
            for k in 0..=3 {
               dp[i + 1][j + 1][1] = max(dp[i + 1][j + 1][1], dp[i][j + 1][k] + map[i][j]);
               if k > 0 {
                  dp[i + 1][j + 1][k] = max(dp[i + 1][j + 1][k], dp[i + 1][j][k - 1] + map[i][j]);
               }
            }
         }
      }
   }
   let mut ans = 0;
   for i in 0..=3 {
      ans = max(ans, dp[r][c][i]);
   }
   println!("{}", ans);
}


Measured memory_bytes: 708652
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    int idx = 0;
    for (int i = 1; i <= n; ++i) {
        if (s.substr(n-1-(i-1), i) == t.substr(0, i)) {
            idx = i;
        }
    }
    cout << n * 2 - idx << endl;
}


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

int main(){
  int N;
  cin >> N;
  
  int s1, s2, s3;
  s1 = N / 100;
  s2 = (N % 100) / 10;
  s3 = N % 10;
  
  if(s1 == 7 || s2 == 7 || s3 == 7){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n,m;
	cin >> n >> m;
	char a[n][n], b[m][m];
	FOR(i,0,n)FOR(j,0,n)cin >> a[i][j];
	FOR(i,0,m)FOR(j,0,m)cin >> b[i][j];bool ans = false;
	FOR(i,0,n-m+1)FOR(j,0,n-m+1){
		bool itti = true;
		FOR(k,0,m)FOR(l,0,m){
			if(a[i+k][j+l] != b[k][l])itti = false;
		}
		if(itti){
			ans = true;
			break;
		}
	}
	Yes(ans);
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
 
int main(void){
    int N,X,T;
    cin >> N >> X >> T;
    cout << ((N+X-1)/X)*T << endl;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>

int main()
{
    std::string s;
    std::cin >> s;

    auto first = true;
    char prev;
    for (char c : s) {
        if (!first) {
            if (c == prev) {
                std::cout << "Bad" << std::endl;
                return EXIT_SUCCESS;
            }
        }
        first = false;
        prev = c;
    }

    std::cout << "Good" << std::endl;
    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int ll;
#define MAX (ll)1e18

int main(void){
  int N;
  cin >> N;
  ll ans = 1;
  vector<ll> v;
  for(int i=0;i<N;i++){
    ll tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(),v.end());
  for(int i=0;i<N;i++){
    ll tmp = v[i];
    if(tmp == 0){
      cout << 0 << endl;
      return 0;
    }
    double logans = log10((double)ans);
    double logtmp = log10((double)tmp);
    //cout << logans << " " << logtmp << endl;
    if(logans + logtmp > 18.0){
      cout << -1 << endl;
      return 0;
    }
    ans = ans*tmp;
    if(ans > MAX){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4380
import java.util.Scanner;
class Main{
	int t;
	int n;
	int cnt=0;
	
	public void solve(){
    Scanner sc=new Scanner(System.in);
		
		while(cnt<4){
			t=sc.nextInt();
			n=sc.nextInt();
        if(t==1){
			System.out.println(6000*n);
			cnt++;
        }else if(t==2){
			System.out.println(4000*n);
			cnt++;
        }else if(t==3){
			System.out.println(3000*n);
			cnt++;
		}else{
			System.out.println(2000*n);
			cnt++;
        }
		}
	}
	public static void main(String[] args){
        Main obj =new Main();
        obj.solve();
    }
}

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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

void solve()
{
	int k ,n, x, pp, ans = 0;
	cin >> k >> n;
  	cin >> x;
  	pp = x;
  	for(int i = 1; i < n; i++)
	  {
	  	int x1;
    cin >> x1;
    ans = max(ans, x1 - pp);
    pp = x1;
  }
  ans = max(ans, x + (k - pp));
  cout << k - ans << "\n";
}

int main()
{
	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}



Measured memory_bytes: 256
d,g = map(int,input().split())
P,C = [],[]
for i in range(1, d+1):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)
ans = 10**9
for bin in range(1, 1<<d):
    cnt = tot = 0
    for j in range(d):
        if bin & 1<<j:
            cnt += P[j]
            tot += P[j]*(j+1)*100 + C[j]
    if tot >= g: ans = min(ans, cnt)
    for j in range(d):
        if bin & 1<<j:
            now_cnt = cnt
            now_tot = tot - C[j]
            for k in range(P[j]-1):
                now_cnt -= 1
                now_tot -= (j+1)*100
                if now_tot >= g: ans = min(ans, now_cnt)
print(ans)


Measured memory_bytes: 3188
s = input()

mae = s[:2]
usiro = s[2:]

flag = 'NA'

if 1 <= int(mae) <= 12 and int(usiro) > 12 :
    flag = 'MMYY'
if 1 <= int(mae) <= 12 and int(usiro) == 0 :
    flag = 'MMYY'
if 1 <= int(usiro) <= 12 and int(mae) > 12:
    flag = 'YYMM'
if 1 <= int(usiro) <= 12 and int(mae) == 0:
    flag = 'YYMM'
if 1 <= int(mae) <= 12 and 1 <= int(usiro) <= 12:
    flag = 'AMBIGUOUS'

print(flag)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int countNum(int sy, int sx, int ey, int ex, const vector<vector<int>> &num)
{
	if (ey < sy) {
		return 0;
	}
	if (ex < sx) {
		return 0;
	}

	int ans = num[ey][ex];

	if (sy != 0) {
		ans -= num[sy - 1][ex];
	}
	if (sx != 0) {
		ans -= num[ey][sx - 1];
	}
	if (sx != 0 && sy != 0) {
		ans += num[sy - 1][sx - 1];
	}

	return ans;
}

int countNum(int i, int j, int K, const vector<vector<int>> &num)
{
	const int S = 2 * K;
	i %= S;
	j %= S;

	if (i + K <= S && j + K <= S) {
		return countNum(i, j, i + K - 1, j + K - 1, num);
	}

	if (i + K <= S) {
		int ans = 0;
		ans += countNum(i, j, i + K - 1, S - 1, num);
		ans += countNum(i, 0, i + K - 1, K - (S - j) - 1, num);
		return ans;
	}

	if (j + K <= S) {
		int ans = 0;
		ans += countNum(i, j, S - 1, j + K - 1, num);
		ans += countNum(0, j, K - (S - i) - 1, j + K - 1, num);
		return ans;
	}

	int ans = 0;
	ans += countNum(i, j, S - 1, S - 1, num);
	
	ans += countNum(i, 0, S - 1, K - (S - j) - 1, num);
	ans += countNum(0, j, K - (S - i) - 1, S - 1, num);
	ans += countNum(0, 0, K - (S - i) - 1, K - (S - j) - 1, num);

	return ans;
}

int main()
{
	int N, K;
	cin >> N >> K;

	const int S = 2 * K;
	
	vector<vector<int>> numW(S, vector<int>(S, 0));
	vector<vector<int>> numB(S, vector<int>(S, 0));

	for (int i = 0; i < N; ++i) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		if (c == 'W') {
			++numW[y % S][x % S];
		}
		else if (c == 'B') {
			++numB[y % S][x % S];
		}
	}

	for (int i = 1; i < S; ++i) {
		numW[i][0] += numW[i - 1][0];
		numB[i][0] += numB[i - 1][0];
	}
	for (int j = 1; j < S; ++j) {
		numW[0][j] += numW[0][j - 1];
		numB[0][j] += numB[0][j - 1];
	}
	for (int i = 1; i < S; ++i) {
		for (int j = 1; j < S; ++j) {
			numW[i][j] += numW[i - 1][j] + numW[i][j - 1] - numW[i - 1][j - 1];
			numB[i][j] += numB[i - 1][j] + numB[i][j - 1] - numB[i - 1][j - 1];
		}
	}

#if 0
	cout << "numW=" << endl;
	for (int i = 0; i < S; ++i) {
		for (int j = 0; j < S; ++j) {
			cout << numW[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
#endif

	int ans = 0;

	for (int i = 0; i < S; ++i) {
		for (int j = 0; j < S; ++j) {
			int nw1 = countNum(i, j, K, numW);
			int nw2 = countNum(i + K, j + K, K, numW);
			int nw = nw1 + nw2;
			int nb = countNum(i, j + K, K, numB) + countNum(i + K, j, K, numB);
			ans = max(ans, nw + nb);
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 33664
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }



int main(int argc, char const *argv[]) {
  string s, t;
  cin >> s >> t;
  if (s == t.substr(0, sz(s))) puts("Yes");
  else
    puts("No");
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	int n;
	cin >> n;
	string s;
	int ac, wa, tle, re;
	ac = wa = tle = re = 0;
	rep(i, n) {
		cin >> s;
		if (s == "AC") ac++;
		else if (s == "WA") wa++;
		else if (s == "TLE") tle++;
		else if (s == "RE") re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <set>

void solve() {
    std::set<int> s;
    for (int i = 1; i <= 30; ++i) s.insert(i);
    for (int i = 1; i <= 28; ++i) {
        int x;
        std::cin >> x;
        s.erase(x);
    }

    for (auto x : s) std::cout << x << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3184
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if (n % 2 == 0) {
      System.out.println(n / 2);
    } else {
      System.out.println(n / 2 + 1);
    }
  }
}

Measured memory_bytes: 35604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1000000007;


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

    ll r = (D - C) * (N-1);
    bool ok = false;
    for(int i=0;i<N;i++){
        ll s = (N - 1 - i) * D - i * C;
        if(s - r <= B - A && B - A <= s){
            ok = true;
            break;
        }
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def func(n, k):
    """
    n個のものをk個ずつ重なり1でとる回数
    """
    if n <= 1: return 0
    if n <= k: return 1
    if (n - k) % (k - 1) == 0: return 1 + (n - k) // (k - 1)
    return 1 + (n - k) // (k - 1) + 1

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    place = 0
    for i in range(N):
        if A[i] == 1:
            place = i
            break
    """
    1を常に端点にとると失敗する！
    反例：A=[2,3,4,1,5,6,7], K=3
    """
    ans = 10**10
    for i in range(K):
        ans1 = func(place - i + 1, K)
        ans2 = func((N - place) - (K - i) + 1, K)
        #print("i={}, ans1={}, ans2={}".format(i, ans1, ans2))
        ans = min(ans, ans1 + ans2 + 1)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 83916
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, d;
    cin >> h >> w >> d;
    vector<pair<int, int>> hash(h * w + 1);
    REP(i, h)REP(j, w) {
        int a;
        cin >> a;
        hash[a] = make_pair(i + 1, j + 1);
    }

    VL cost_sum(h * w + 1, 0);
    FOR(a, d + 1, h * w) {
        cost_sum[a] = cost_sum[a - d];
        cost_sum[a] += abs(hash[a].first - hash[a - d].first);
        cost_sum[a] += abs(hash[a].second - hash[a - d].second);
    }

    int q;
    cin >> q;
    REP(i, q) {
        int l, r;
        cin >> l >> r;
        cout << cost_sum[r] - cost_sum[l] << endl;
    }
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) {
  	cout << "Yes" << '\n';
  } else {
  	cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
def div(x):
    cnt = 0
    for i in range(1, x + 1):
        if x % i == 0:
            cnt += 1
    return cnt


n = int(input())
ans = 0
for i in range(1, n + 1, 2):
    if div(i) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 9160
//Moh_K_Imar .......
//24/08/2020  ... 5,50.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a,b;
    cin>>a>>b;
    if((a==1&&b==2)||(a==2&&b==1))cout<<3<<endl;
    else if((a==2&&b==3)||(a==3&&b==2))cout<<1<<endl; 
    else if((a==1&&b==3)||(a==3&&b==1))cout<<2<<endl; 
       
    return 0;
}



Measured memory_bytes: 3612
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 100000000000000000

int main() {
    string s;
    cin >> s;
    vector<bool> use(26, false);
    rep(i, s.size()) {
        int n = s[i] - 'a';
        use[n] = true;
    }

    if (s.size() != 26) {
        rep(i, 26) {
            if (!use[i]) {
                s += (char)(i + 'a');
                break;
            }
        }
        cout << s << endl;
    } else {
        int cnt = 0;
        string ss = s;
        string ns;
        do {
            cnt++;
            ns = s;
            if (cnt == 2)
                break;
        } while (next_permutation(all(s)));

        if (ns == ss) {
            cout << -1 << endl;
            return 0;
        }

        rep(i, s.size()) {
            if (ss[i] == ns[i])
                cout << ns[i];
            else {
                cout << ns[i];
                break;
            }
        }
    }
}

Measured memory_bytes: 3608
N = int(input())
mod = 10**9+7
memo = {}

for i in range(2, N+1):
    for j in range(2, i+1):
        while i % j == 0:
            i  = i // j
            try:
                memo[j] += 1
            except:
                memo[j] = 1

ans = 1
for key in memo.keys():
    ans *= memo[key] + 1
    ans %= mod

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ll n,k;
   cin>>n>>k;
   
   map<ll,ll> ma;
   rep(k)
   {
       ll siz;
       cin>>siz;
       while(siz--)
       {
           ll temp;
           cin>>temp;
           ma[temp] = 1;
       }
   }
   
   cout<<(n - (ll)ma.size());
   
   
   return 0;        
}  
  
   

Measured memory_bytes: 3664
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut seq = vec![0; n];
    for i in 0..n {
        seq[i] = read::<i64>();
    }
    let mut usables = vec![];
    for i in 0..n {
        let index = match usables.binary_search(&(-seq[i], (n as i64))) {
            Ok(index) => index,
            Err(index) => index,
        };
        if index != usables.len() {
            usables[index as usize] = (-seq[i], -(i as i64));
        } else {
            usables.push((-seq[i], i as i64));
        }
    }
    // println!("{:?}", usables);
    println!("{}", usables.len());
}


Measured memory_bytes: 8444
n = int(input())
t = 1
a = 1
for i in range(n):
    next_t, next_a = map(int, input().split())
    kake_t = (t + next_t - 1) // next_t
    kake_a = (a + next_a - 1) // next_a
    kake = max(kake_t, kake_a)
    t = next_t * kake
    a = next_a * kake
print(int(a + t))

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N, X;
int sr, sc, tr, tc;
int ar[101], ac[101];
int br[101], bc[101];
vint R; // compress
map<int, int> mp; // uncompress
set< pair<pint, pint> > st; // non-exist edge

double base;

double distance(int ar, int br) {
  return (ar == br ? (R[ar]+1)*base : abs(R[ar] - R[br]));
}

double mincost[808][101];

using State = tuple<double, int, int>;

const int dr[] = {0, 1, 0, -1};
const int dc[] = {1, 0, -1, 0};

double dijkstra() {
  priority_queue<State, vector<State>, greater<State> > que;
  fill(mincost[0], mincost[808], DBL_MAX/2);
  que.emplace(0, sr, sc);
  mincost[sr][sc] = 0;
  while(!que.empty()) {
    double cost; int r, c;
    tie(cost, r, c) = que.top(); que.pop();
    if(mincost[r][c] < cost) continue;
    if(r == tr && c == tc) return cost;
    rep(i, 4) {
      int nr = r + dr[i], nc = (c+dc[i]+N)%N;
      if(nr < 0 || R.size() <= nr) continue;
      auto u = make_pair(r, c);
      auto v = make_pair(nr, nc);
      if(st.count(make_pair(u, v))) continue;
      double dist = cost + distance(r, nr);
      if(dist < mincost[nr][nc]) {
	mincost[nr][nc] = dist;
	que.emplace(dist, nr, nc);
      }
    }
  }
  return -1;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> N >> X, N) {
    cin >> sr >> sc >> tr >> tc;
    --sr, --sc, --tr, --tc;
    R.clear();
    R.push_back(0);
    R.push_back(sr);
    R.push_back(tr);
    rep(i, X) {
      cin >> ar[i] >> ac[i] >> br[i] >> bc[i];
      --ar[i], --ac[i], --br[i], --bc[i];
      if(ar[i]) R.push_back(ar[i]-1);
      R.push_back(ar[i]);
      R.push_back(ar[i]+1);
      if(br[i]) R.push_back(br[i]-1);
      R.push_back(br[i]);
      R.push_back(br[i]+1);
    }
    sort(all(R));
    R.erase(unique(all(R)), R.end());
    mp.clear();
    st.clear();
    rep(i, R.size()) mp[R[i]] = i;
    sr = mp[sr], tr = mp[tr];
    rep(i, X) {
      ar[i] = mp[ar[i]], br[i] = mp[br[i]];
      auto u = make_pair(ar[i], ac[i]);
      auto v = make_pair(br[i], bc[i]);
      st.emplace(u, v);
      st.emplace(v, u);
    }
    base = sqrt(2.0-2.0*cos(2.0*acos(-1)/(double)N));
    cout << dijkstra() << endl;
  }

  return 0;
}

Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}

int main(){
    int n;
    cin>>n;
    vi v(n);
    rep(i,n){
        cin>>v[i];
    }
    vs s;
    string t="123456789";
    rep(i,n-1)range(j,i+1,n){
        string x=to_string(v[i]*v[j]);
        if(t.find(x)!=string::npos) s.push_back(x);
    }
    sort(all(s),[](string a,string b){
        return a.length()>b.length() || (a.length()==b.length() && a[0]>b[0]);
    });
    if(s.size()){
        cout<<s[0]<<endl;
    }else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 3288
#include<iostream>
#include<stack>
using namespace std;
string s;
main()
{
	while(getline(cin,s),s!=".")
	{
		stack<int>a,b;
		int ca=0,cb=0,f=0;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]=='(')
			{
				ca++;
				a.push(cb);
			}
			else if(s[i]=='[')
			{
				cb++;
				b.push(ca);
			}
			else if(s[i]==')')
			{
				ca--;
				if(a.empty()||cb!=a.top())
				{
					cout<<"no"<<endl;
					f=1;
					break;
				}
				a.pop();
			}
			else if(s[i]==']')
			{
				cb--;
				if(b.empty()||ca!=b.top())
				{
					cout<<"no"<<endl;
					f=1;
					break;
				}
				b.pop();
			}
			if(ca<0||cb<0)
			{
				cout<<"no"<<endl;
				f=1;
				break;
			}
		}
		if(!f)
		{
			cout<<(ca||cb?"no":"yes")<<endl;
		}
	}
}



Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,X,T;
  cin>>N>>X>>T;
  cout<<(N+X-1)/X*T<<endl;
}



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


void solve(long long N, long long K, long long C, std::string S){
    vector<int> dp1(N + 1), dp2(N + 1);
    int ma = -1e9;
    for(int i = 0;i < N;i++){
        dp1[i + 1] = max(dp1[i], dp1[i+1]);
        if(S[i] == 'o' && i - ma > C){
            dp1[i+1]++;
            ma = i;
        }
    }
    ma = -1e9;
    reverse(S.begin(), S.end());
    for(int i = 0;i < N;i++){
        dp2[i + 1] = max(dp2[i], dp2[i+1]);
        if(S[i] == 'o' && i - ma > C){
            dp2[i+1]++;
            ma = i;
        }
    }
   
    reverse(S.begin(), S.end());
    reverse(dp2.begin(), dp2.end());
    /*
    for(int i : dp1){
        cout<<i<<" ";
    }
    cout<<endl;
    for(int i : dp2)
    {
        cout<<i<<" ";
    }
    cout<<endl;
    */
    vector<int> v;
    for(int i = 0;i < N;i++){
        if(dp1[i] + dp2[i+1] < K)v.push_back(i);
    }
    for(auto i : v)cout<<i+1<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long C;
    scanf("%lld",&C);
    std::string S;
    std::cin >> S;
    solve(N, K, C, S);
    return 0;
}


Measured memory_bytes: 4344
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,i;
  string s;
  int cnt=0;
  int flag=0;

  cin >>n;
  for(i=0;i<n;++i){
    cin>>s;
    if(s=="A"){
      cnt++;
    }else{
      cnt--;
    }
    if(cnt<0) flag=1;
  }
  if(flag) cout << "NO\n";
  else if(cnt==0) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}

Measured memory_bytes: 3160
N, K = map(int, input().split())

MAX = 10 ** 5 + 1
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    
# Inverse factorial
finv = [0] * (MAX + 1)
finv[MAX] = pow(fac[MAX], MOD - 2, MOD)
for i in reversed(range(1, MAX + 1)):
    finv[i - 1] = finv[i] * i % MOD

def comb(n, k):
    if n < k or k < 0:
        return 0
    return (fac[n] * finv[k] * finv[n - k]) % MOD

for i in range(1, K + 1):
    print((comb(N - K + 1, i) * comb(K - 1, i - 1)) % MOD)



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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  map<char, set<ll> > a, b;
  string s, t;
  cin >> s >> t;
  ll n = s.size();
  rep(i, n){
    a[s[i]].insert(i);
    b[t[i]].insert(i);
  }

  bool ans = true;
  for(auto ia: a){
    ll tmp = false;
    for(auto ib: b){
      tmp = tmp or ia.second == ib.second;
    }
    ans = ans and tmp;
  }
  

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


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


int main() {
  int n , m ;
  cin >> n >> m ;
  
  vector<int> a(m);
  vector<int> b(m);
  for(int i=0;i<m ;i++){
    cin >> a.at(i);
    cin >> b.at(i);
    if(m==1){
      cout << b.at(i)-a.at(i)+1 << endl;
    }
    if(i>0){
      if(b.at(i-1)<a.at(i)){
        cout << 0 << endl;
        break;
      }
      a.at(i)=max(a.at(i),a.at(i-1));
      b.at(i)=min(b.at(i),b.at(i-1));
      if(i==m-1){
        cout << b.at(i)-a.at(i)+1 <<endl;
      }
    }
  }
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using tll = tuple<ll,ll,ll>;
using vtll = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


ll dp[10005][2][105];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll d; cin>>d;
  ll n=s.size();
  
  dp[0][0][0]=1;
  rep(i,n) rep(j,2) rep(k,d){
    ll now=s[i]-'0';
    rep(nxt,10){
      if(nxt>now&&j==0) continue;
      ll nj=j,nk;
      if(nxt<now) nj=1;
      nk=(k+nxt)%d; // 各桁の和より、k*10とする必要はない
      (dp[i+1][nj][nk]+=dp[i][j][k])%=MOD;
    }
  }
  ll ans=(dp[n][0][0]+dp[n][1][0]+MOD-1)%MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>


struct reg {
	int num;
	int ind;
};
bool operator<(const reg& left, const reg& right) {
	return left.num < right.num;
}

int main(void) {
	int N;
	std::cin >> N;
	std::vector<reg> A;
	
	for (int i = 0; i < N; i++) {
		reg tmp;
		std::cin >> tmp.num;
		tmp.ind = i;
		A.push_back(tmp);
	}
	std::sort(A.begin(), A.end());
	for (int i = 0; i < N; i++) {
		std::cout << A[i].ind + 1 << " ";
	}

	return 0;
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;


int main() {
	/*
	int n, m, q;
	cin >> n >> m >> q;
	int a[q], b[q], c[q], d[q];
	rep (i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

	*/

	ll a, b, n;
	cin >> a >> b >> n;


	ll ans = 0;
	ll x = min(n, b - 1);
	ans = a * x / b - a * (x / b);

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
 
int n,ans=1;
int t[MAX];
int L[MAX],R[MAX];
 
int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++)scanf("%d",&t[i]);
  for(int i=1;i<=n;i++)L[i]=(t[i]==t[i-1]?1:L[i-1]+1);
  for(int i=n;i>=1;i--)R[i]=(t[i]==t[i+1]?1:R[i+1]+1);
  for(int i=1;i<=n;i++)ans=max(ans,L[i-1]+R[i]+R[i+R[i]]);
  printf("%d\n",ans);
  return 0;
}

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

#define int long long

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

struct P {
  double x, y, z;
  P() {}
  P(double x, double y, double z) : x(x), y(y), z(z) {}
  P operator+(P p) { return P(x+p.x, y+p.y, z+p.z); }
  P operator-(P p) { return P(x-p.x, y-p.y, z-p.z); }
  P operator*(double k) { return P(x*k, y*k, z*k); }
  P operator/(double k) { return P(x/k, y/k, z/k); }
  P operator*(P p) {
    return P(y*p.z-z*p.y, z*p.x-x*p.z, x*p.y-y*p.x);    
  }
};

typedef P V;

struct Seg {
  P p1, p2;
  Seg(){}
  Seg(P p1, P p2) : p1(p1), p2(p2) {}
};

typedef Seg Line;

struct Sphere {
  P c;
  double r;
  Sphere() {}  
  Sphere(P c, double r) : c(c), r(r){}
};

double norm(V a) {
  return a.x*a.x+a.y*a.y+a.z*a.z;
}

double abs(V a) {
  return sqrt(norm(a));
}

double dot(V a, V b) {
  return a.x*b.x+a.y*b.y+a.z*b.z;
}

V cross(V a, V b) {
  return V(a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x);  
}

double gdLP(Line l, P p) {
  return abs(cross(l.p2-l.p1, p-l.p1)/abs(l.p2-l.p1));  
}

double gdSP(Seg s, P p) {
  if ( dot(s.p2-s.p1, p-s.p1) < 0.0 ) return abs(p-s.p1);
  if ( dot(s.p1-s.p2, p-s.p2) < 0.0 ) return abs(p-s.p2);
  return gdLP(s, p);  
}

bool iSC(Seg s, Sphere c) {
  double d = gdSP(s, c.c);
  if ( d > c.r ) return 0;
  return !((abs(s.p1-c.c)<=c.r) && (abs(s.p2-c.c)<=c.r));  
}

signed main(){
  int N, Q;
  cin >> N >> Q;
 
  vector<Sphere> s(N);
  vector<int> l(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> s[i].c.x >> s[i].c.y >> s[i].c.z >> s[i].r >> l[i];    
  }

  for ( int i = 0; i < Q; i++ ) {
    int sum = 0;
    Seg seg;
    P p1, p2;
    cin >> p1.x >> p1.y >> p1.z >> p2.x >> p2.y >> p2.z;
    seg = Seg(p1, p2);
    for ( int j = 0; j < N; j++ ) {
      if ( iSC(seg, s[j]) ) {
	sum += l[j];	
      }
    }

    cout << sum << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3188
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
#include <numeric>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	long long H,W,M,cmaxR{0},cmaxC{0},cr{0}, cc{0},pr;
	cin>>H>>W>>M;
	vector<pair<long long int, long long int>> targets;
	vector<long long> rows(H+1,0), columns(W+1,0);
	while(M--){
		long long int x,y;
		cin>>x>>y;
		cmaxR=max(cmaxR,++rows[x]);
		cmaxC=max(cmaxC,++columns[y]);
		targets.push_back({x,y});
	}
	for(auto i:rows){
		if(i==cmaxR){
			++cr;
		}
	}
	for(auto i:columns){
		if(i==cmaxC){
			++cc;
		}
	}
	pr=cr*cc;
	for(auto &i:targets){
		if(rows[i.first]==cmaxR&&columns[i.second]==cmaxC){
			--pr;
		}
	}
	if(pr){
		cout<<cmaxR+cmaxC<<endl;
	}
	else{
		cout<<cmaxR+cmaxC-1<<endl;
	}
}


Measured memory_bytes: 16284
N,M=gets.split.map &:to_i
L=N.lcm M
S,T=*$<
h=N.times.map{|i|[L/N*i,S[i]]}.to_h
p M.times.any?{|i|c=h[L/M*i]and c!=T[i]}?-1:L

Measured memory_bytes: 18428
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const int maxm=100050;
const int mod=1e9+7;
struct nod{
	int a[4][4];
	inline void clear(){
		memset(a,0,sizeof(a));
	}
	inline void st1(){
		clear();
		a[0][0]=a[0][2]=a[1][1]=a[2][2]=1;
		a[1][2]=1;
		a[0][1]=2;
	}
	inline void st(){
		clear();
		a[0][0]=a[0][2]=a[1][1]=a[1][2]=1;
		a[2][0]=1;
		a[2][1]=a[2][2]=a[0][1]=2;
	}
};
int n,m;
int x[maxm];
nod ans,tmp;
inline nod operator * (nod x,nod y){
	nod c;
	c.clear();
	for(register int i=0;i<3;i++){
		for(register int j=0;j<3;j++){
			for(register int k=0;k<3;k++){
				c.a[i][j]=(c.a[i][j]+((ll)x.a[i][k]*(ll)y.a[k][j])%mod)%mod;
			}
		}
	}
	return c;
}
inline nod ksm(nod a,int x){
	nod cheng;
	cheng.st();
	while(x){
		if(x&1)a=a*cheng;
		cheng=cheng*cheng;
		x>>=1;
	}
	return a;
}
int main(){
	tmp.st1();
	ans.clear();
	ans.a[0][0]=ans.a[0][2]=1;
	ans.a[0][1]=2;
	scanf("%d%d",&n,&m);
	for(register int i=1;i<=m;i++)scanf("%d",&x[i]);
	x[++m]=n;
	for(register int i=1;i<=m;i++){
		int dis=x[i]-(x[i-1]+1);
		ans=ksm(ans,dis);
		if(i!=m)ans=ans*tmp;
	}
	printf("%d\n",ans.a[0][2]);
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, ll>a,pair<ll,ll>b)
{
    return a.fi>=b.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll n; cin>>n;
vi arr(n);
ll ans = 0;
rep(i,0,n)
{
    cin>>arr[i];
    ans = ans^arr[i];
}
rep(i,0,n)arr[i] = ans^arr[i];
for(auto x:arr)cout<<x<<" ";
return 0;
}
/*
50 25
39 99 70 24 49 13 86 43 88 74 45 92 72 71 90 32 19 76 84 46 63 15 87 1 39 58 17 65 99 43 83 29 64 67 100 14 17 100 81 26 45 40 95 94 86 2 89 57 52 91 45
1221 360 459 651 958 584 345 181 536 116 1310 403 669 1044 1281 711 222 280 1255 257 811 409 698 74 838
*/


Measured memory_bytes: 4764
#include <iostream>
#include <vector>
//#include <algorightm>
#include <map>
#include <tuple>
//#include <cstudio>

int main() {
    int H,W;
    std::cin >> H >> W ;
    std::vector<std::string> str(H);
    for (int i = 0; i < H ; i++) {
        std::cin >> str.at(i) ;
    }
    for (int i = 0; i < W + 2; i++) {
        std::cout << "#";
    }
    std::cout << '\n' ;
    for (int i = 0; i < H; i++) {
        std::cout <<"#"<< str.at(i) <<"#"<< std::endl;
    }
    for (int i = 0; i < W + 2; i++) {
        std::cout << "#";
    }


}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

map<int,int> memo;

int go(int n){
	if(memo[n] != 0)
		return memo[n];
	return memo[n] = (go(n/2) + go((n-1)/2) + go((n-2)/2))%mod;;
}

int32_t main(){
    boost;
   //code
    int n;
    cin >> n;
    memo[0] = 1;  // {0,0}
    memo[1] = 2;  // {1,0} , {0,1};
    cout << go(n);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

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

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
//  int  a, b, c, d, e, X, Y ,r;
  unsigned long long a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
  int  A[200003]={};
  int  B[100003]={};
//  int  C[100003][100001]={};
  int  C[100003]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
  int sosuu[46] ={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199};
  int min =100000001;
  int len=0;
  int l=0;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%lld", &a);
  for(i=0;i<a-1;i++){
    scanf("%lld", &c);
    A[c]++;
  }
  for(i=1;i<a+1;i++){
    printf("%lld\n", A[i]);
  }
  
return 0;
}


Measured memory_bytes: 2508
n=int(input())
x=[]
y=[]
ans=0
for i in range(n):
  a,b=map(int,input().split())
  x.append(a)
  y.append(b)
for p in range(n-1):
  for q in range(p+1,n):
    ans += (((x[p]-x[q])**2+(y[p]-y[q])**2)**0.5)*2/n
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include <vector>
#include <map>
using namespace std;
long long Read() {
	long long x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
	return x*f;
}
int main() {
	long long n,b;
	 n=Read(),b=Read();
	 cout<<n*n-b; 
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    val K = input.nextInt()
    var count = 0;
    
    for (i in 1..N) {
      if (input.nextInt() >= K) {
        ++count
      }
    }
    
    println(count)
  }
}

Measured memory_bytes: 59900
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args)throws Exception {
		Scanner scan = new Scanner(System.in);
		int cnt = scan.nextInt();
		int moch[] = new int[cnt];
		int num = 0;
		for(int i = 0;i < cnt;i++) {
			moch[i] = scan.nextInt();
		}
		Arrays.sort(moch);
		for(int i = 0;i < cnt-1;i++) {
			if(moch[i] != moch[i+1]) {
				num++;
			}
		}
		System.out.println(num+1);

		scan.close();
	}
}

Measured memory_bytes: 27272
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return (a / gcd(a,b)) * b; }
ll extended_gcd(ll a, ll b, ll &x, ll &y) {
    if (b == 0) { x = 1; y = 0; return a; }
    ll xx, yy;
    ll res = extended_gcd(b, a%b, xx, yy); x = yy; y = xx - yy * (a / b);
    return res;
}

// const ll sz = 1e5 + 5;
// vector<ll> fac(sz, 1);

// ll nCr(ll n, ll r) {
//     return ( ( ( (fac[n] * powmod(fac[n-r], mod-2)) % mod ) * powmod(fac[r], mod-2) ) % mod );
// }

// * ALways PASS arrays, strings etc to functions BY REFERENCE

// const ll sz = 1e6 + 6;
// vector<bool> p(sz, true);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // for (int i = 1; i < sz; i++)
    //     fac[i] = (fac[i-1] * i) % mod;
    
    // p[0] = p[1] = false;
    // for (ll i = 2; i*i <= sz; i++) if (p[i]) {
    //     for (ll j = i*i; j <= sz; j += i)
    //         p[j] = false;
    // }
    
    int t = 1;
    // cin >> t;

    while(t--) {
        int n;
        cin >> n;
        cout << (!n) << endl;
    }
    
	return 0;
}


Measured memory_bytes: 3604
def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
    return d


n, w = map(int, input().split())
INF = 10 ** 5
d = [[INF for i in range(n)] for i in range(n)]
e_list = []
for i in range(w):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    d[x][y] = z
    d[y][x] = z
    e_list.append([x, y, z])
for i in range(n):
    d[i][i] = 0

warshall_floyd(d)
ans = w
for x, y, z in e_list:
    # dにx,y,z の情報が残っていたら利用されている
    if d[x][y] == z:
        ans -= 1
print(ans)


Measured memory_bytes: 3440