akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
#define CAT(a,b)a b
#define VASIZE(a,b,N,...)N
template<class T>auto size(T&&a)->decltype(a.size(), int()) { return a.size(); }
template<class T, class = enable_if_t<is_integral<T>::value, T>>int size(T a) { return a; }
#define REP(t,a,N)for(int t=size(a),_l##t=size(N);t<_l##t;t++)
#define RREP(t,a,N)for(int t=size(N)-1,_l##t=size(a);t>=_l##t;t--)
#define rep(t,...)CAT(REP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define rrep(t,...)CAT(RREP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define all(a)(a).begin(),(a).end()
typedef long long ll;
typedef unsigned long long ull;
void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

template<class T, class B, class...V>struct Vec {
  typedef Vec<T, V...>A; typedef vector<typename A::t>t; t nvec(B a, V...b) { return t(a, A().nvec(b...)); }
};
template<class T, class B>struct Vec<T, B> { typedef vector<T>t; t nvec(B a) { return t(a); } };
template<class T>tuple<T>Init(T t) { return tuple<T>(t); }
template<class T, class C>struct Vec<T, tuple<C>> { using t = T; T nvec(tuple<C> a) { return get<0>(a); } };
template<class T = int, class...B> typename Vec<T, B...>::t nvec(B...b) { return Vec<T, B...>().nvec(b...); }



void Calc() {
  int n, m;
  in, n, m;
  vector<int> ok(n);
  ok[0] = 1;
  vector<int> num(n, 1);
  rep(i, m) {
    int x, y;
    in, x, y;
    x--, y--;
    num[y]++;
    if (ok[x]) {
      ok[y] = 1;
      if (--num[x] == 0) ok[x] = 0;
    } else {
      --num[x];
    }
  }
  cout << (accumulate(all(ok), 0)) << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    
    public static void main (String[] args){
        
        Scanner sc = new Scanner (System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if (A>=13){
            System.out.println(B);
        } else if (A>=6){
            System.out.println(B/2);
        } else {
            System.out.println("0");
        }
    }
}


Measured memory_bytes: 23124
#include<set>    
#include<map>    
#include<stack>    
#include<ctime>    
#include<cstdio>    
#include<queue>    
#include<cmath>    
#include<vector>    
#include<cstring>   
#include<climits>    
#include<iostream>   
#include<algorithm>
using namespace std;
#define LL long long
LL read(){
    LL f=1,x=0;char c=getchar();
    while(c<'0'||'9'<c){if(c==EOF)exit(0);if(c=='-')f=-1;c=getchar();}
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}
    return f*x;
}
#define MAXN 1000000
#define INF 0x3f3f3f3f
#define  Mod 998244353
#define inv2 499122177
//LL Mul(LL x,LL y){return (x*y-(LL)((long double)x*y/Mod)*Mod+Mod)%Mod;}
LL Pow(LL x,LL y){
	LL ret=1;
	while(y){
		if(y&1) ret=ret*x%Mod;
		x=x*x%Mod,y>>=1;
	}
	return ret;
}
int Len(int n){int len=1;while(len<=n)len<<=1;return len;}
void FWT_or(LL *A,int n,int opt){
	for(int i=1;i<n;i<<=1)
		for(int j=0,s=i<<1;j<n;j+=s)
			for(int k=0;k<i;k++)
				A[i+j+k]=(A[i+j+k]+(Mod+1ll*opt*A[j+k])%Mod)%Mod;
	return ;
}
void FWT_and(LL *A,int n,int opt){
	for(int i=1;i<n;i<<=1)
		for(int j=0,s=i<<1;j<n;j+=s)
			for(int k=0;k<i;k++)
				A[j+k]=(A[j+k]+(Mod+1ll*opt*A[i+j+k])%Mod)%Mod;
	return ;
}
void FWT_xor(LL *A,int n,int opt){
	for(int i=1;i<n;i<<=1)
		for(int j=0,s=i<<1;j<n;j+=s)
			for(int k=0;k<i;k++){
				LL x=A[j+k],y=A[i+j+k];
				A[j+k]=(x+y)%Mod,A[i+j+k]=(x-y+Mod)%Mod;
				if(opt==-1) A[j+k]=1ll*A[j+k]*inv2%Mod,A[i+j+k]=1ll*A[i+j+k]*inv2%Mod;
			}
	return ;
}
LL p[MAXN+5],h[MAXN+5],f[MAXN+5];
int main(){
	LL sum=0;
	int n=read();
	for(int i=0;i<(1<<n);i++)
		p[i]=read(),sum=(sum+p[i])%Mod;
	sum=Pow(sum,Mod-2);
	for(int i=0;i<(1<<n);i++)
		p[i]=p[i]*sum%Mod;
	p[0]=(p[0]+Mod-1)%Mod;
	h[0]=(1<<n)-1;
	for(int i=1;i<(1<<n);i++)
		h[i]=Mod-1;
	FWT_xor(h,(1<<n),1),FWT_xor(p,(1<<n),1);
	for(int i=0;i<(1<<n);i++)
		f[i]=h[i]*Pow(p[i],Mod-2)%Mod;
	FWT_xor(f,(1<<n),-1);
	for(int i=0;i<(1<<n);i++)
		printf("%lld\n",((f[i]-f[0])%Mod+Mod)%Mod);
	return 0;
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll k;
    cin >> k;
    if(k<=10){ cout << k << endl; return 0; }
    priority_queue<
    ll,vector<ll>,greater<ll>> memo;
    vector<ll> aa;
    int cnt=9;
    rep(i,1,10){ memo.push(i); aa.push_back(i); }
    
    while(cnt<k){
        ll tmp = memo.top(); memo.pop();
        if(tmp%10!=0){ memo.push(tmp*10+tmp%10-1);aa.push_back(tmp*10+tmp%10-1); cnt++;}
        if(tmp%10!=9){ memo.push(tmp*10+tmp%10+1);aa.push_back(tmp*10+tmp%10+1); cnt++;}
        memo.push(tmp*10+tmp%10);aa.push_back(tmp*10+tmp%10); cnt++;
    }
    sort(all(aa));
    cout << aa[k-1] << endl;
}

Measured memory_bytes: 2288
fun main(arg: Array<String>) {
    val (N, K) =  listOfInt()
    val D = listOfInt()
    val OK = listOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9).toMutableList()
    D.forEach { OK.remove(it) }
    val yen = "0$N".toCharArray().map { it - '0'}
    val pay = yen.toMutableList()
    fun getNum(n: Int): Pair<Boolean, Int> {
        if (OK.contains(n)) return true to n
        for (d in n + 1 .. 10)
            if (OK.contains(d)) return false to d
        for (d in 0 .. n - 1)
            if (OK.contains(d)) return false to 10 + d
        return false to -1
    }
    var n = 1
    while (n < yen.size) {
        val (f, y) = getNum(pay[n])
        if (f) pay[n] = y
        else {
            if (y < 10) {
                pay[n] = y
                for (m in n + 1 until yen.size) pay[m] = OK.first()
            } else {
                pay[n] = y % 10
                pay[n - 1] += y / 10
                for (m in n + 1 until yen.size) pay[m] = OK.first()
                n -= 2
            }
        }
        n += 1
    }
    if (pay.first() == 0) pay.removeAt(0)
    val ans = pay.joinToString("").toInt()
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }

//10000


Measured memory_bytes: 36000
#include<stdio.h>

int main() {
	int i, sum = 0, N, D, X;
	scanf("%d%d%d", &N, &D, &X);
	for(i = 0; i < N; ++i) {
		int j = -1, num, tmp = 0;
		scanf("%d", &num);
		while((++j)*num+1 <= D) tmp++;
		sum += tmp;
	}
	int ans = sum + X;
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
// const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    for (int i=1; i<=n; ++i){
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int ans;
    ans=a*100+b*10+c;
    if(ans%4==0) 
        cout<<"YES";
    else 
        cout<<"NO";
    return 0;
} 

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, t;
  cin >> a >> b >> t;
  int x = t / a;
  cout << x * b << endl;
}


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

int main()
{
  int n, m, sum = 0;
  cin >> n >> m;
  for (int i=0; i<m; i++) {
    int a = 0;
    cin >> a;
    sum += a;
  }
  if (n < sum) cout << -1 << endl;
  else cout << n - sum << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>
#include<tuple>

using namespace std;

#define reep(i, s, n) for(int i=s;i<(int)n;i++)
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define all(v) v.begin(), v.end()
#define tyd typedef
#define vc vector
#define pb push_Back
#define eb emplace_back
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
const int IINF = 1<<28;

#define fs first
#define sc second

int w, h, ans;
int field[128][128];
bool used[128][128];

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

bool in(int x, int y) {
	return 0 <= x && x <= w+1 && 0 <= y && y <= h+1 && !used[x][y];
}

void dfs(int x, int y) {
	used[x][y] = true;
	rep(i, 6) {
		int nx = x + dx[y & 1][i];
		int ny = y + dy[i];
		if(in(nx, ny)) {
			if(field[nx][ny]) {
				ans++;
			} else {
				dfs(nx, ny);
			}
		}
	}
}

int main(){
	cin >> w >> h;
	reep(i, 1, h+1) {
		reep(j, 1, w+1) {
			cin >> field[j][i];
		}
	}
	dfs(0, 0);
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int N;
    int A[100005];
    int ans = 0;

    cin >> N;

    for(int i = 0; i < N; i++) {
        cin >> A[i]; --A[i];
        if(A[i] < i && A[A[i]] == i) {
            ans++;
        }
    }

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
class Main{
  public static void main(String args[])throws Exception{
    int area = 0;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    Deque<Integer> D = new ArrayDeque<Integer>();
    Deque<int[]> U = new ArrayDeque<int[]>();

    String str =  br.readLine();
    //一段ごと考える
    for (int i = 0; i < str.length(); i++) {
      if (str.charAt(i) == '\\')
      D.add(i);
      else if (false==D.isEmpty() && str.charAt(i) == '/') {
        int a = i - D.getLast();
        area += a;
        while (false==U.isEmpty() && D.getLast() < U.getLast()[0]) {
          a += U.getLast()[1];
          //エリアが小さいものを大きいものに含む為にキューを削除
          U.removeLast();
        }
        int[] data = { D.pollLast(), a };
        U.add(data);
      }
    }
    System.out.println(area);
    System.out.print(U.size());
    for(int [] t : U){
      System.out.print(" "+t[1]);
     }
    System.out.println();
  }
}


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

#define mp(x, y) make_pair((x), (y))

typedef long long ll;

int n;
int l, r;
int sl, sr;

int ask(int p) {
	printf("%d\n", p);
	fflush(stdout);
	char s[42];
	scanf("%s", s);
	if(s[0]=='V') exit(EXIT_SUCCESS);
	else return s[0]=='M';
}

int main()
{
	scanf("%d", &n);
	l=0, r=n-1;
	sl=ask(l);
	sr=ask(r);
	while(l<r) {
		int mi=(l+r)/2;
		int smi=ask(mi);
		if((mi-l)%2==(sl==smi)) {
			r=mi;
			sr=smi;
		} else {
			l=mi;
			sl=smi;
		}
	}

	return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int count=0;
  string s;
  bool flag=true;
  cin>>s;
  rep(i,s.size()){
    rep(j,s.size()){
      if(s[i]==s[j]) count++;
    }
    if(count%2!=0){
      flag=false;
      break;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
///////////////////////////

Measured memory_bytes: 256
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int MOD=1e9 + 7;
const int N=1000100;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){  
                                                        for (auto &v : vec) is >> v; return is; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve(){
    ll n,k;
    cin>>n>>k;
    k=min(n,k);
    long a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(n==k){
        cout<<"0\n";
        return ;
    }
    sort(a,a+n);
    ll ans=0;
    for(int i=0;i<n-k;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 5220
#include<bits/stdc++.h>
using namespace std;
int K,N;
int main(){
  cin>>K>>N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<N-1;i++)B[i]=A[i+1]-A[i];
  B[N-1]=A[0]+K-A[N-1];
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  int c=B[0];
  cout<<K-c<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<stdio.h>
using namespace std;

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

typedef long long ll;
typedef unsigned long long int ulli;

const ll INF = ll(1e18) + 1;

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

ulli gcd(ulli a, ulli b) {
	return (b <= 0) ? a : gcd(b, a % b);
}

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

//---------------------------------------------------
typedef pair<int, int> P;

void Main()
{
	int n, ans = 0; cin >> n;
	char s[51];
	cin >> s;
	rep(i, n - 2) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			ans++;
			i += 2;
		}
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
}

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

int f(int x, int y, int z) {
  return x*x + y*y + z*z + x*y + y*z + z*x;
}

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

  map<int, int> mp;
  for (int x = 1; x < 100; ++x) {
    for (int y = x; y < 100; ++y) {
      for (int z = y; f(x, y, z) <= N; ++z) {
        int n = f(x, y, z);
        if (x == y && y == z && z == x) {
          mp[n] += 1;
        } else if (x == y || y == z) {
          mp[n] += 3;
        } else {
          mp[n] += 6;
        }
      }
    }
  }

  rep(i,1,N) {
    cout << mp[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3960
s=str(input())
can=True
while len(s)>4:
    if s[-5::]=='dream':
        s=s[:-5:]
    elif s[-7::]=='dreamer':
        s=s[:-7:]
    elif s[-5::]=='erase':
        s=s[:-5:]
    elif s[-6::]=='eraser':
        s=s[:-6:]
    else:
        can=False
        break
if len(s)==0:
    can=True
elif len(s)<=4:
    can=false
if(can):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)

using namespace std;
const int N=405,M=100005;
bool fk[N],g[N][N];
int n,m,ans;
struct data{int u,v;} dat[M];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

void solve(int x)
{
	g[x][x]=1;
	repd(i,m,1)
	{
		int u=dat[i].u,v=dat[i].v;
		if(g[x][u] && g[x][v]) {fk[x]=1; return;}
		if(!g[x][u] && !g[x][v]) continue;
		g[x][u]=g[x][v]=1;
	}
}

int main()
{
	n=getint(),m=getint();
	rep(i,1,m) dat[i].u=getint(),dat[i].v=getint();
	rep(i,1,n) solve(i);
	rep(i,1,n-1) if(!fk[i]) rep(j,i+1,n) if(!fk[j])
	{
		bool jdg=1;
		rep(k,1,n) if(g[i][k] && g[j][k]) jdg=0;
		ans+=jdg;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	string A, B, C;
	cin >> A >> B >> C;

	string ret;
	if(A.back() == B.front() && B.back() == C.front())
		ret = "YES";
	else
		ret = "NO";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
<?php

ini_set('display_errors', 1);
$ud = array();
$side = array();
$direction = array('R', 'L', 'D', 'U');
$cood = array(array(0, 1), array(0, -1), array(1, 0), array(-1, 0));
$ud[] = str_split(rtrim(fgets(STDIN)));
for ($i = 0; $i < 4; $i++) {
    $side[] = str_split(rtrim(fgets(STDIN)));
    $ud[] = str_split(rtrim(fgets(STDIN)));
}

$field = array_fill(0, 5, array_fill(0, 5, array_fill(0, 4, 0)));
for ($i = 0; $i < 5; $i++) {
    for ($j = 0; $j < 5; $j++) {
        if (isset($side[$i - 1][$j]) && $side[$i - 1][$j] === '1') {
            $field[$i][$j][0] = 3;
        } elseif (isset($ud[$i][$j]) && $ud[$i][$j] === '1') {
            $field[$i][$j][0] = 0;
        } elseif (isset($side[$i][$j]) && $side[$i][$j] === '1') {
                $field[$i][$j][0] = 2;
        } else {
            $field[$i][$j][0] = 1;
        }
        if (isset($side[$i][$j]) && $side[$i][$j] === '1') {
            $field[$i][$j][1] = 2;
        } elseif (isset($ud[$i][$j - 1]) && $ud[$i][$j - 1] === '1') {
            $field[$i][$j][1] = 1;
        } elseif (isset($side[$i - 1][$j]) && $side[$i - 1][$j] === '1') {
                $field[$i][$j][1] = 3;
        } else {
            $field[$i][$j][1] = 0;
        }
        if (isset($ud[$i][$j]) && $ud[$i][$j] === '1') {
            $field[$i][$j][2] = 0;
        } elseif (isset($side[$i][$j]) && $side[$i][$j] === '1') {
            $field[$i][$j][2] = 2;
        } elseif (isset($ud[$i][$j - 1]) && $ud[$i][$j - 1] === '1') {
            $field[$i][$j][2] = 1;
        } else {
            $field[$i][$j][2] = 3;
        }
        if (isset($ud[$i][$j - 1]) && $ud[$i][$j - 1] === '1') {
            $field[$i][$j][3] = 1;
        } elseif (isset($side[$i - 1][$j]) && $side[$i - 1][$j] === '1') {
            $field[$i][$j][3] = 3;
        } elseif (isset($ud[$i][$j]) && $ud[$i][$j] === '1') {
            $field[$i][$j][3] = 0;
        } else {
            $field[$i][$j][3] = 2;
        }
    }
}

$p = array(0, 0);
$d = 0;
$trace = array();
while (true) {
    $trace[] = $direction[$d];
    $p[0] += $cood[$d][0];
    $p[1] += $cood[$d][1];
    $d = $field[$p[0]][$p[1]][$d];
    if ($p[0] === 0 && $p[1] === 0) {
        break;
    }
}

echo implode('', $trace);
echo PHP_EOL;

Measured memory_bytes: 6716
#include<iostream>

using namespace std;

int main()
{
	int a=0,b=0,c=0,d=0,e=0,n,count;
	for(int i=1;i<=50;i++){
		cin>>n;
		do{
		if((a+b+c+d)==n){
			count++;
		}
		if(a==9 && b==9 && c==9 && d==9){
			e=1;
		}
	
		else if(b==9 && c==9 && d==9){
			a++;
			b=0,c=0,d=0;
		}
		else if(c==9 && d==9){
			b++;
			c=0,d=0;
		}
		else if(d==9){
			c++;
			d=0;
		}
		else{
			d++;
		}
	
		}while(e==0);
		cout<<count<<endl;
		count=0,a=0,b=0,c=0,d=0,e=0;
	}
	return 0;
}

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

typedef pair<int,int> P;

int main(){
	int n;	cin>>n;
	vector<P> balls(n);	for(int i=0;i<n;i++)cin>>balls[i].first>>balls[i].second;

	int ans=n;
	for(int I=0;I<n;I++){
		for(int J=0;J<n;J++){
			if(I==J)continue;

			int p=balls[I].first-balls[J].first;
			int q=balls[I].second-balls[J].second;

			int cnt=0;
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(i==j)continue;

					if(balls[i].first-balls[j].first==p && balls[i].second-balls[j].second==q){
						cnt++;
						break;
					}
				}
			}

			ans=min(n-cnt,ans);
		}
	}
	cout<<ans<<endl;

	return 0;
}


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

string solve(int t, string& num) {
    int n = num.size();

    string ans = "error";
    int max_v = 0;
    for (int j = 0; j < (1 << n); j += 2) {
        stringstream ss, tt;
        int sum = 0, a = num[0] - '0';
        for (int k = 1; k < n; ++k) {
            if ((j >> k) & 1 != 0) {
                a = 10 * a + (num[k] - '0');
            } else {
                sum += a;
                ss << a << ' ';
                a = num[k] - '0';
            }
        }
        ss << a;
        sum += a;
        if (max_v <= sum && sum <= t) {
            if (sum == max_v) {
                ans = "rejected"; 
            } else {
                max_v = sum;
                tt << sum << " " << ss.str();
                ans = tt.str();
            }
        }
    }
    return ans;
}

int main() {
    int t, n;
    string num;
    while (true) {
        cin >> t >> num;
        if (t == 0 && num == "0") {
            break;
        }
        cout << solve(t, num) << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
from itertools import permutations
from math import sqrt, fsum
N = int(input())
towns = [tuple(map(int, input().split())) for _ in range(N)]

ds = []
n = 0
for rt in permutations(towns, N):
    for i in range(1, N):
        x1, y1 = rt[i-1]
        x2, y2 = rt[i]
        d = sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
        ds.append(d)
    n += 1
ans = fsum(ds) / n
print(ans)

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

using namespace std;

int n, k;

int init()	
{
	scanf("%d %d", &n, &k);
	int cnt = k * pow(k - 1, n - 1);
	printf("%d\n", cnt);
}
int main()
{
	init();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int a,b,c; cin >> a >> b >> c;
  int now = a;
  while(now <= a*b){
    now += a;
    if(now % b == c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def std_in():
    return sys.stdin.readline().strip()


def get_ints():
    return map(int, sys.stdin.readline().strip().split())


def main():
    s = std_in()

    if s[-1] == "s":
        print(s + "es")
    else:
        print(s + "s")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9036
n = gets.to_i
hs = Hash.new(0)
bf = nil
n.times do |_|
  w = gets.chomp
  if bf.nil? || bf[-1] == w[0]
    bf = w
    hs[w] += 1
  else
    puts "No"
    exit
  end
end

puts (hs.values.any? {|v| v > 1 })? "No" : "Yes"

Measured memory_bytes: 1788
import bisect
inf = 1e10
n,m = map(int,raw_input().split())
xy = [map(int,raw_input().split()) for i in range(n)]
X = sorted([i[0] for i in xy] + [-inf-1] + [inf+1])
Y = sorted([i[1] for i in xy] + [-inf-1] + [inf+1])

s = [[0]*(n+10) for i in range(n+10)]
for i in range(n):
	a = bisect.bisect_left(X,xy[i][0])
	b = bisect.bisect_left(Y,xy[i][1])
	s[a][b] += 1

for i in range(n+2):
	for j in range(n+2):
		s[i+1][j+1] += s[i+1][j] + s[i][j+1] - s[i][j]

for i in range(m):
	x1,y1,x2,y2 = map(int,raw_input().split())
	x1 = bisect.bisect_left(X,x1) - 1
	y1 = bisect.bisect_left(Y,y1) - 1
	x2 = bisect.bisect_left(X,x2+1) - 1
	y2 = bisect.bisect_left(Y,y2+1) - 1
	print s[x2][y2] - s[x1][y2] - s[x2][y1] + s[x1][y1]

Measured memory_bytes: 817904
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <list>
#include <set>
#include <map>
#define F first
#define S second
#define pb push_back
#define sz(c) (LL) c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vLL vector<LL>
#define vpint vector<pair<int, int>>
#define vpLL vector<pair<LL, LL>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(n) \
    for (int i = 0; i < n; i++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long LU;
const LL mod = 1e9 + 7;
vLL num(200005);
vLL a(200005, 1), b(200005, 1), c(200005, 1);
LL dp(int node, vint &par, vector<vint> &adj)
{
    LL ans = 1;
    for (auto u : adj[node])
    {
        if (u != par[node])
        {
            par[u] = node;
            ans = ans + dp(u, par, adj);
            a[node] = (a[node] * b[u]) % mod;
        }
    }
    b[node] = (a[node] * ans) % mod;
    return num[node] = ans;
}
LL power(LL a, LL b)
{
    LL ans = 1;
    while (b)
    {
        if (b % 2)
        {
            ans = (ans * a) % mod;
        }
        a = (a * a) % mod;
        b /= 2;
    }
    return ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vint par(n + 1, 0);
    vector<vint> adj(n + 1);
    fr(n - 1)
    {
        int u, v;
        cin >> u >> v;
        adj[v].pb(u);
        adj[u].pb(v);
    }
    dp(1, par, adj);
    LL ans = 1;
    fr(n)
    {
        if (i)
        {
            ans = (ans * i) % mod;
        }
    }
    queue<int> q;
    c[1] = a[1];
    for (auto u : adj[1])
    {
        q.push(u);
    }
    while (!q.empty())
    {
        int ans = 0, u = q.front();
        q.pop();
        c[u] = (c[par[u]] * (power(b[u], mod-2)))%mod;
        for (auto nd : adj[u])
        {
            if (nd != par[u])
            {
                ans += num[nd];
                c[u] = (c[u] * b[nd]) % mod;
                q.push(nd);
            }
        }
        num[par[u]] = n - ans - 1;
        c[u] = (c[u] * (num[par[u]])) % mod;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << (ans * power(c[i], mod - 2)) % mod << "\n";
    }
    return 0;
}

Measured memory_bytes: 21748
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define sq(a) (a)*(a)
#define nitro std::ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
typedef long long ll;
typedef std::vector< int > vi;
typedef std::pair<int, int> pi;
#define cin std::cin
#define cout std::cout
#define vector std::vector
#define pb push_back
#define pv(x) for(auto y:x)    cerr<<y<<" ";    cerr<<'\n';
#define fr first
#define sc second
#define ppb pop_back
#define max(a,b) a=max(a,b)
#define min(a,b) a=min(a,b)
#define int ll
#define tr(c,it) for(typeof(c.begin()) it= c.begin();it != c.end();it++)
signed main()
{		
	nitro;
	int VASU=1;
	//cin>>VASU;
	while(VASU--)
	{
		int a,b,c,k;
		cin>>a>>b>>c>>k;
		int ans=0;
		if(k>a)
		{
			ans+=a;
			k-=a;
			if(k>b)
			{
				k-=b;
				if(k>c)
				{
					return 0;
					
				}
				else
				{
					cout<<ans-k;
				}
			}
			else
			cout<<ans<<endl;
			
		}
		else
		cout<<k<<endl;
		
	}
	

	
	
	
	return 0;
}



Measured memory_bytes: 3652
// B - Magic 2
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  // 初期値
  unsigned long long int A, B, C, K, i, j, k, sa, sb, sc; 
  cin >> A >> B >> C >> K;
  sa = A;
  sb = B;
  sc = C;
  
  bool hantei = false;
  
  //Main loop
  for(i = 0; i <= K; i++){
    if (i == 0){
      A = sa;
    } else {
      A *= 2;
    }
    for(j = 0; j <= K; j++){
      if (j == 0){
        B = sb;
      } else {
        B *= 2;
      }
      for(k = 0; k <= K; k++){
        if (k == 0){
         C = sc;
        } else {
          C *= 2;
        }
       
        if (B > A && C > B ){
          if (i + j + k <= K){
            hantei = true;
            // cout << A << " " << B << " " <<  C << ":" << ",magic=" << (B > A && C > B) << ", loop=" << (i + j + k == K) << endl; 
          }
        }
      }
    }
  }
  
  if (hantei){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
 	ll k,x,i;cin>>k>>x;
 	for(i=x-k+1;i<=x+k-1;i++)
 	cout<<i<<" ";
	
	
	
	
	
 return 0;
}

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

#define ll long long int
#define ld long double
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k-1] = tolower(s[k-1]);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
signed main(){
    ll n; cin  >> n;
    ll hoge = 50;
    int res = 1;
    while(true){
        int tmp = (res << hoge--) -1;
        if(tmp<=n)return cout<<hoge+1<<endl, 0;
    }
}



Measured memory_bytes: 3096
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  string s, t;
  cin >> s >> t;
  bool f = true;
  for (int i = 0, j = 0; i < s.size() || j < t.size();) {
    if (f) {
      cout << s[i];
      i++;
    } else {
      cout << t[j++];
    }
    f = !f;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i = j; i < k; i += step)
#define loop(i, j, k) for (int i = j; i < k; i++)
#define rloop1(i, j, k, step) for (int i = j; i >= k; i -= step)
#define rloop(i, j, k) for (int i = j; i >= k; i--)
#define rep(i, k) for (int i = (0); i < (k); i++)
#define rrep(i, k) for (int i = k - 1; i >= 0; i--)
#define forall(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define lin "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)
#define PI 2 * acos(0.0)
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
// vector<pair<int, int>> v;
// bool sortinrev(const pair<int, int> &a,
//                const pair<int, int> &b)
// {
//     return (a.second < b.second);
// }
void solve()
{
    long double n;
    cin >> n;
    // cout.precision(12);
    // cout << pow((n / 3), 3) << lin;
    n = n / 3;
    long double v = n * n * n;
    printf("%.12Lf\n", v);
}

int main()
{
    auto start = clock();
    fast_io;
    // freopen("test.txt", "r", stdin);
    int t;
    t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    auto stop = clock();
    cerr << "time taken:" << double(stop - start) / double(CLOCKS_PER_SEC) << " s" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(raw_input())
dp = [j for j in range(n+1)] 
for i in range(1, n+1):
	for u in [6,9]:
		p = 1
		q = u ** p
		while((i  - q) >= 0):
			dp[i] = min(dp[i], 1 + dp[i - q])
			p += 1
			q = u ** p
print dp[n]


Measured memory_bytes: 98732
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int N,K;
	cin >> N >> K;
	LL ret=0;
	for(int i=1;i<=N;i++){
		int a=i%K;
		int b=(K-a)%K;
		if(2*b%K)continue;
		LL v=N/K;
		if(b<=N%K&&b>0)
		{
			v++;
		}
		ret+=v*v;
	}
	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 256
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o A.exe A.cpp 
Execute: ./A
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int n, x, t; 
	cin >> n >> x >> t; 
	
	if(n % x == 0) {
		cout << n / x * t << endl; 
	} else {
		cout << n / x * t + t << endl; 
	}
	
	return 0; 
} 


Measured memory_bytes: 3620
from math import factorial
from functools import reduce
from operator import mul

N = factorial(int(input()))
if N == 1:
  print(1)
  exit()

M = 10**9 + 7
ans = 1

div = 2
while N != 1:
  cnt = 0
  while N%div == 0:
    N //= div
    cnt += 1
  if cnt != 0:
    ans *= (cnt+1)
    ans = ans%M
  div += 1
print(ans)

Measured memory_bytes: 38512
#include<stdio.h>

int main(void)
{
  int n, k;
  scanf("%d %d", &n, &k);

  int p[n];
  for(int i=0;i<n;i++){
    scanf("%d", &p[i]);
  }

  int tmp;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(p[i] > p[j]){
	tmp = p[i];
	p[i] = p[j];
	p[j] = tmp;
      }
    }
  }

  int ans=0;
  for(int i=0;i<k;i++){
    ans += p[i];
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<string>
#include<tuple>
#include<algorithm>

using namespace std;

int main(){

    int ans = 0;

    int N,K;
    cin >> N >> K;
    vector<int> array;

    for(int i=0; i<N; i++)
    {
        int x;
        cin >> x;
        array.push_back(x);
    }

    for(int l=0; l<=K; l++)
    {
        for(int r=0; r<=K-l; r++)
        {
            if(l+r > N)
            {  
                break;
            }
            int d = K-l-r;
            int now = 0;
            vector<int> s;  //取り出したものの集合
            for(int i=0; i<l; i++)
            {
                now += array[i];
                s.push_back(array[i]);
            }
            for(int j=N-r ;j<N; j++)
            {
                now += array[j];
                s.push_back(array[j]);
            }
            sort(s.begin(),s.end());
            for(int i=0; i<d; i++)
            {
                if(i >= s.size())
                    break;
                if(s[i] > 0)
                    break;
                now -= s[i];
            }
            ans = max(ans, now);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

V<string> s(int i, int c, int m, int n)
{
    vector<string> v;
    if (c == n)
    {
        v.push_back("");
        return v;
    }
    for (int j = 0; j <= m+1; ++j)
    {
        for (auto&& t : s(i+1, c+1, max(m, j), n))
            v.push_back((char)('a' + j) + t);
    }
    return v;
}

void solve()
{
    IN(n);
    for (auto&& t : s(0, 0, -1, n))
    {
        cout << t << endl;
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

const int N=2e5+10;
typedef long long ll;
int a[N],n;
ll ans;

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",a+i);
    int sum=0,l=1,t=0;
    for (int i=1;i<=n;i++)
    {
        sum+=a[i];
        t^=a[i];
        while(sum!=t)
        {
            sum-=a[l];
            t^=a[l];
            l++;
        }
        ans+=i-l+1;
    }
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
const ll INF=1000000000000000;

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

int main(){
    ll N; cin>>N;
    vector<ll>A(N);
    ll sum=0,ans=INF;
    rep(i,N){
        cin>>A[i];
        sum+=A[i];
    }
    ll tmp=0;
    rep(i,N-1){
        tmp+=A[i];
        chmin(ans,abs(sum-tmp*2));
    }
    cout<<ans;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
    int r, c; cin>>r>>c;
    int ans[r+1][c+1];
    int i, j, h, k;
    for(i=0; i<=r; i++){
        for(j=0; j<=c; j++){
            if(i<r && j<c){
                cin>>ans[i][j];
            }
            else if(j==c){
                int s=0;
                for(h=0; h<c;h++){
                    s+=ans[i][h];
                }
                ans[i][j]=s;
            }
            else if(i==r){
                int s=0;
                for(k=0;k<r;k++){
                    s+=ans[k][j];
                }
                ans[i][j]=s;
            }
        }
    }
    for(i=0;i<=r;i++){
        for(j=0;j<=c;j++){
            if(j) cout<<" ";
            cout<<ans[i][j];
        }
        cout<<endl;
    }
}


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

const int mxN=1e5+5;
int n, k, a[mxN], dp[mxN];

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> k;
    for (int i=0; i<n; ++i)
        cin >> a[i];
    memset(dp, 0x3f, sizeof(dp));
    dp[0]=0;
    for (int i=0; i<n; ++i)
        for (int j=1; j<=k; ++j)
            dp[i+j]=min(dp[i+j], dp[i]+abs(a[i]-a[i+j]));
    cout << dp[n-1] << '\n';
}



Measured memory_bytes: 4444
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  char c; cin >> c;
  char ans;

  if (c == 'A' || c == 'T') {
    ans = c == 'A' ? 'T' : 'A';
  } else {
    ans = c == 'C' ? 'G' : 'C';
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, C;
	in >> N >> C;
	std::vector<LL>p(C);
	rep(i, C) in >> p[i];

	LL sum = 0;
	rep(i, C) sum += p[i];
	++N;

	out << (sum / N) + std::min(sum % N, 1LL) << std::endl;
}



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


int main(){
    ll x;
    int ans = 0;
    ll now = 100;
    cin >> x;
    while(now < x){
        now += now/100;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    k,q=MI()
    dd=LI()
    for _ in range(q):
        n,x,m=MI()
        sall=spart=0
        zall=zpart=0
        for i,d in enumerate(dd):
            d%=m
            if i<(n-1)%k:
                spart+=d
                if d==0:zpart+=1
            sall+=d
            if d==0:zall+=1
        last=x%m+sall*((n-1)//k)+spart
        no=last//m
        print(n-1-no-zall*((n-1)//k)-zpart)

main()

Measured memory_bytes: 48476
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long k;
    cin>>k;
    queue<long> q;
    for(long i=1;i<=9;i++)   q.push(i);
    long x;
    while(k--)
    {
	x = q.front();
	q.pop();
	if(x%10!=0)
	    q.push(10*x+x%10-1);
	q.push(10*x+x%10);
	if(x%10!=9)
	    q.push(10*x+x%10+1);
    
    }
    cout<<x;
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
#N,K,M= map(int,input().split())
P =list(map(int,input().split()))
#L = [list(map(str,input().split())) for i in range(N)]
min = P[0]+1
answer = 0
for n in P:
    if n < min:
        answer += 1
        min = n
print(answer)


Measured memory_bytes: 24744