akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

vector<pair<int, int>> factorization(int num) // 数値を受け取り素因数分解の結果を返す
{
    map<int, int> mp;
    int n = 2;
    while (num != 1)
    {
        if (num % n == 0)
        {
            mp[n]++;
            num /= n;
            continue;
        }
        n++;
    }
    vector<pair<int, int>> ret;
    for (auto m : mp)
    {
        ret.push_back(make_pair(m.first, m.second));
    }
    return ret;
}

int main()
{
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 1; i <= n; i++)
    {
        auto facs = factorization(i);
        for (auto fac : facs)
        {
            mp[fac.first] += fac.second;
        }
    }
    ll ans = 1;
    vector<int> tmp;
    for (auto m : mp)
    {
        tmp.push_back(m.second);
    }
    reverse(tmp.begin(), tmp.end());
    for (int t : tmp)
    {
        ans = (ans * (t + 1)) % MOD;
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
N = int(input())
C = [int(input()) for _ in range(N)]
MOD = 10**9+7

# PreStore:先頭から順に見ていったとき、その色と同じ色の石が前回現れた位置。
PreStone = [-1 for _ in range(2*(10**5))]

# 先頭から順に見ていったとき、ある色が現れ、次に同じ色が現れたとき、
# 前者と後者の間の色を変えるパターンが追加されるわけだから、
# 追加されるパターンの数は、前者が現れた時点でのパターン数と同じ。
# ただし、前者と後者の間には1つ以上の石が存在する必要がある。
dp = [1 for _ in range(N)]
for i in range(N):
  if PreStone[C[i]-1] not in [-1, i-1]:
    dp[i] = dp[i-1] + dp[PreStone[C[i]-1]]
  else:
    dp[i] = dp[i-1]
  dp[i] %= MOD
  PreStone[C[i]-1] = i
print(dp[-1])


Measured memory_bytes: 75044
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
int main(){
    int N;
    cin >> N;
    vector<P> x(N);
    for(int i = 0; i < N; i++) {
        long long x1, y1;
        cin >> x1 >> y1;
        x[i] = P(x1, y1);
    }
    sort(x.begin(), x.end());
    map<P, long long> m;
    for(int i = 0; i < N; i++){
        for(int j = i + 1 ; j < N; j++){
            long long s = x[j].first - x[i].first;
            long long t = x[j].second - x[i].second;
            m[P(s, t)]++;
        }
    }
    long long ans = 0;
    long long M = 0;
    for(auto v: m){
        M = max(M, v.second);
    }
    ans = N - M;
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int BSearch(int *,int,int);

int BSearch(int *S,int key,int n)
{
  int left=0,right=n,mid;
  while( left < right )
    {
      mid = (left+right)/2;
      if( S[mid] == key )
	return 1;
      else if( key < S[mid] )
	right = mid;
      else
	left = mid +1;
    }
  return 0;
}
  
int main()
{
  int i,n,q,key,count=0;
  int S[100000];

  scanf("%d",&n);
  for( i=0;i < n;i++)
      scanf("%d",&S[i]);

  scanf("%d",&q);
  for( i=0;i < q;i++)
    {
      scanf("%d",&key);
      count += BSearch(S,key,n);
    }

  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
long long GCD(long long a,long long b){
  return b?GCD(b,a%b):a;
}
long long LCM(long long a,long long b){
  return a/GCD(a,b)*b;
}
int main(){
  long long N,T[100],X=1;
  cin>>N;
  FOR(i,0,N){
    cin>>T[i];
    X=LCM(X,T[i]);
  }
  cout<<X<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long int
int min(int x, int y){return x<y?x:y;}
int compare_long(const void *a, const void *b) {ll *A = (ll *)a;ll *B = (ll *)b;if (*A > *B) return -1;if (*A < *B) return 1;return 0;}
int main(void){
	int x,y,z,k,i,j,l;
	scanf("%d%d%d%d",&x,&y,&z,&k);
	ll a[x],b[y],c[z];
	for(i=0;i<x;i++)scanf("%lld",&a[i]);
	for(i=0;i<y;i++)scanf("%lld",&b[i]);
	for(i=0;i<z;i++)scanf("%lld",&c[i]);
	qsort(a, x, sizeof(ll), compare_long);
	qsort(b, y, sizeof(ll), compare_long);
	qsort(c, z, sizeof(ll), compare_long);
	
	ll ab[x*y];
	l=0;
	for(i=0;i<x;i++)for(j=0;j<y;j++)ab[l++] = a[i]+b[j];
	qsort(ab, x*y, sizeof(ll), compare_long);
	
	int kk = min(k,x*y);
	ll abc[kk*z];
	l=0;
	for(i=0;i<kk;i++)for(j=0;j<z;j++)abc[l++] = ab[i]+c[j];
	qsort(abc, kk*z, sizeof(ll), compare_long);
	for(i=0;i<k;i++)printf("%lld\n",abc[i]);
	
	return 0;
}

Measured memory_bytes: 54912
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

void solve(long long N, std::vector<long long> A, std::vector<long long> B,std::vector<long long> C) {
  int ans = 0;
  REP(i, N){
    ans += B[A[i]-1];
    // debug(B[A[i]-1])
    if(i>0){
      if(A[i]-A[i-1]==1){
        ans+=C[A[i-1]-1];
        // debug(C[A[i-1]-1)
      }
    }
  }
  cout<<ans<<endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  std::vector<long long> B(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &B[i]);
  }
  std::vector<long long> C(N - 1);
  for (int i = 0; i < N - 1; i++) {
    scanf("%lld", &C[i]);
  }
  solve(N, std::move(A), std::move(B), std::move(C));
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
 
ans = 0
for i in range(2**n):
    light = 0
    for ki, j in enumerate(k):
        switch = 0
        for s in j[1:]:
            if i & (1 << s-1):
                switch += 1
        if switch % 2 == p[ki]:
            light += 1
    if light == m:
        ans += 1
print(ans)

Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

double a, b, x, y, z;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> a >> b >> x;
	if(x <= b*a*a/2){
		y = 2*x/(a*b);
		cout << setprecision(10) << atan(b/y)*(180/M_PI) << endl;
	}
	else{
		y = 2*x/(a*a)-b;
		z = a*b/(b-y);
		cout << setprecision(10) << atan(b/z)*(180/M_PI) << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

minim = 10e999999

for jj in range(201):
    j = -100+jj
    total = 0
    for i in range(n):
        total += (a[i]-j)*(a[i]-j)

    minim = min(minim,total)
print(minim)


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

int main(){
  int N, X;
  vector<int> L(110);

  cin >> N >> X;
  for(int i=0; i<N; i++) cin >> L[i];

  int d = 0, cnt = 1;
  for(int i=0; i<N; i++){
    d += L[i];
    if(d > X) break;
    cnt++;
  }

  cout << cnt << endl;
}

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

const int INF = 1000000;

int main(){

    int n;
    while(1){
      cin >> n;
      if(n==0){
        break;
      }
      int table[10][10];

      bool realtowntable[10];

      for(int i=0;i<10;i++){
        realtowntable[i] = false;
      }

      for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
          if(i==j){
            table[i][j] = 0;
          }
          else{
            table[i][j] = INF;
          }
        }
      }
      int a,b,c;
      for(int i=0;i<n;i++){
        cin >> a >> b >> c;
        if(!realtowntable[a]){
          realtowntable[a] = true;
        }
        if(!realtowntable[b]){
          realtowntable[b] = true;
        }
        table[a][b] = table[b][a] = c;
      }

      for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
          for(int j=0;j<10;j++){
            if(table[i][j] > table[i][k] + table[k][j]){
              table[i][j] = table[i][k] + table[k][j];
            }
          }
        }
      }

      /*for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
          for(int j=0;j<10;j++){
            if(table[j][i] > table[j][k] + table[k][i]){
              table[j][i] = table[j][k] + table[k][i];
            }
          }
        }
      }*/

      int anstown = 0;
      long long int ans=0,tmp=0;
      ans = INF * 12;
      for(int i=0;i<10;i++){
        if(realtowntable[i]){
          tmp = 0;
          for(int j=0;j<10;j++){
            if(realtowntable[j]){
              tmp += table[i][j];
            }
          }
          if(ans > tmp){
            ans = tmp;
            anstown = i;
          }
        }
      }
      cout << anstown << ' ' << ans << endl;

    }


    return 0;
}

Measured memory_bytes: 3100
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
from pprint import pprint
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M, S = MAP()
graph = [[] for _ in range(N)]
for _ in range(M):
    U, V, A, B = MAP()
    graph[U-1].append((V-1, A, B))
    graph[V-1].append((U-1, A, B))

C, D = ZIP(N)
M = 2500
if S >= M: S = M-1
dist = [[INF]*M for _ in range(N)]
dist[0][S] = 0
q = [(0, S, 0)]

while q:
    d, coin, n = heappop(q)
    if coin + C[n] < M and d+D[n] < dist[n][coin+C[n]]:
        dist[n][coin+C[n]] = d+D[n]
        heappush(q, (d+D[n], coin + C[n], n))
    for node, cnode, dnode in graph[n]:
        nd = d + dnode
        if coin >= cnode and nd < dist[node][coin-cnode]:
            dist[node][coin-cnode] = nd
            heappush(q, (nd, coin-cnode, node))

for i in range(1, N):
    print(min(dist[i]))


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

using namespace std;

int main(){
  int n,k,d;
  cin>>n>>k;
  int cnt=n;
  set<int> set;
  for(int i=0;i<k;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      int a;
      cin>>a;
      set.insert(a);
    }
  }
  cout<<cnt - set.size()<<endl;
}

Measured memory_bytes: 3644
fun main(args: Array<String>) {

    val s = readLine()!!
    val l = 753

    var min = Integer.MAX_VALUE
    for (i in 0 until s.length - 2) {
        min = Math.min(min, Math.abs(l - s.slice(i..i + 2).toString().toInt()))
    }
    println(min)
}

Measured memory_bytes: 33664
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
 
//aは食事の時間
//bはおいしさ
//t時間以内に注文して最大の満腹度を得たい
//平方分割dp
ll n,t;
 
int main(){
  ll ans=0;
  cin >> n >> t;
  vi a(n),b(n);
  REP(i,n) cin>>a[i]>>b[i];
  ll st=sqrt(n);
  if (st==0)st=1;
  ll nt=n/st+1;
  //cout<<st<<endl;
  //cout<<nt<<endl;
 
  vector<ll> data(t);//ダミー
  vector<ll> dp(t);
 
  for(int i=0;i<nt;i++){//stきざみ。大ループ
    for(int j=1;j<t;j++){
      dp[j]=-1;
    }
    dp[0]=0;
    
    for(int k=0;k<n;k++){//sqrt(n)除く全食品
      if ((k>=i*st)&(k<i*st+st)){
        continue;
      }
      for(int j=t-a[k]-1;j>=0;j--){
        if (dp[j]!=-1){
          dp[j+a[k]]=max(dp[j+a[k]],dp[j]+b[k]);
        }
      }
    }
    //ここで得たdpをsqrt(n)回使いまわす
    
    //残りの食品
    for(int dk=0;dk<st;dk++){
      int idx=dk+i*st;//skipするやつ
      if (idx>=n)break;
      for(int j=0;j<t;j++)data[j]=dp[j];
      for(int k=0;k<st;k++){
        if (dk==k){
          continue;
        }
        int kk=i*st+k;
        if (kk>=n)break;//バグではまった
        for(int j=t-a[kk]-1;j>=0;j--){
          if (data[j]!=-1){
            data[j+a[kk]]=max(data[j+a[kk]],data[j]+b[kk]);
            //cout<<data[j+a[kk]]<<" "<<kk<<endl;
          }
        }
      }
      //この時点での最大を検出
      
      for(int j=0;j<t;j++){
        ans=max(data[j]+b[idx],ans);
      }
    }//残りの食品ループ最後
    
  }//大ループ最後(sqrt(n)回)
 
 
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 10e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl
#define prt3(var1, var2, var3) cout << var1 << " " << var2 << " " << var3 << endl
#define prtseq(var) cout << var << " "


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

int main(void) {
  int n, k;
  cin >> n >> k;

  vecll v(n);
  rep(i,n){
    cin >> v[i];
  }

  ll ans=0;
  vecll have;
  rep(i,k+1){ // pick left
    rep(j,k+1){ // pick right
      ll tmp=0;
      //prt2(i, j);
      if(i+j>k){
        //prt("---CUT1");
        break;
      }
      rep(p,i){
        if(have.size()<n){
          have.push_back(v[p]);
        };
      }
      rep(q,j){
        if(have.size()<n){
          have.push_back(v[n-q-1]);
          //prt3("? ", q, v[n-q-1]);
        }
      }
      //prt("---HAVE---");
      //rep(z,have.size()){
      //  prtseq(have[z]);
      //}
      //cout << endl;

      sort(all(have));

      //prt("---HAVE-sort--");
      //rep(z,have.size()){
      //  prtseq(have[z]);
      //}
      //cout << endl;

      int b = k - (i+j);
      rep(s,b){
        //prt2("-rep", s);
        if(have.size()<1){
          //prt("---CUT2");
          break;
        }
        if(have[0]>=0){
          //prt("---CUT3");
          break;
        }
        have.erase(have.begin());
      }

      rep(r,have.size()){
        tmp += have[r];
      }
      if(tmp>ans){
        ans = tmp;
      }

      //prt2("--->tmp", tmp);

      have.erase(all(have));
    }
  }

  prt(ans);

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );

		String[] list = str.split(" ");

		System.out.print("A");
		System.out.print(list[1].substring(0, 1));
		System.out.println("C");

	}

}


Measured memory_bytes: 21076
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    p = list(map(float, input().split()))
    
    dp = [[0]*(n+1) for i in range(n+1)]
    dp[0][0] = 1
    
    for i in range(n):
        for j in range(i+1):
            dp[i+1][j+1] += dp[i][j]*p[i]
            dp[i+1][j] += dp[i][j]*(1-p[i])
    
    ans = 0
    for i in range((n-1)//2+1, n+1):
        ans += dp[n][i]
            
    print(ans)
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 222544
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
void solve(){
	ll n;
	cin>>n;
	cout<<360/(__gcd(n,(ll)360));
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var K = int.Parse(Console.ReadLine());
            if (K % 2 == 0 || K% 5 == 0)
            {
                Console.WriteLine(-1);
                return;
            }
            //var n = 7L;
            //var answer = 1L;
            //while (n % K != 0)
            //{
            //    n *= 10;
            //    n += 7;
            //    n %= K;
            //    answer++;
            //}

            //好きな数字である７を初期化
            int num = 7;
            //何項目を初期化
            int count = 1;

            while (num % K != 0)
            {
                //ｋの倍数かどうかを判断
                
                count ++;
                //乗余はｋの倍数かどうかを判断
                num = (num % K) * 10 + 7;
            }
            //何項目を出力
            Console.WriteLine(count);

            //Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 27492
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,K;
  cin>>N>>K;
  
  int arr[N];
  for(int i=0;i<N;i++)
  {
    cin>>arr[i];
  }
  sort(arr,arr+N);
  int sum=0;
  for(int i=0;i<K;i++)
  {
    sum+=arr[i];
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int x;
    cin>>x;
    int ans=0,tmp=1;
    for(int i=1;i<=x;i++){
        tmp=1;
        for(int j=1;j<=x;j++){
            tmp*=i;
            if(tmp<=x && j>1)ans=max(ans,tmp);
        }
    }
    if(x==1)ans=1;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define itrep(it, a) for(it = (a).begin(); it != (a).end(); it++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

int dp1[2000050];
int dp2[2000050];

void solve(){
    vector<int> va;
    vector<int> vb;
    for(int i = 1; i * (i + 1) * (i + 2) / 6 <= 1000000; i++){
        int a = i * (i + 1) * (i + 2) / 6;
        va.push_back(a);
        if(a % 2 == 1) vb.push_back(a);
    }
    rep(i,1000005){
        dp1[i] = INF;
        dp2[i] = INF;
    }
    dp1[0] = dp2[0] = 0;

    rep(i,va.size()){
        rep(j, 1000000){
            if(dp1[j] != INF){
                dp1[j + va[i]] = min(dp1[j + va[i]], dp1[j] + 1);
            }
        }
    }
    rep(i,vb.size()){
        rep(j, 1000000){
            if(dp2[j] != INF){
                dp2[j + vb[i]] = min(dp2[j + vb[i]], dp2[j] + 1);
            }
        }
    }
}

int main(){
    int n;
    solve();
    while(cin >> n, n){
        cout << dp1[n] << ' ' << dp2[n] << endl;
    }
}

Measured memory_bytes: 16800
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x <<  " " << y << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define D long double
#define eb emplace_back
#define mkp make_pair
#define MOD 100000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    D a,b,c;	cin>>a>>b>>c;
  	((sqrt(a)+sqrt(b)+1e-14)<sqrt(c))?cout<<"Yes":cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, l = 0;
	long long N, a[100];
	cin >> N;
	for (i; i < N; i++)cin >> a[i];

	for (i = 1; i <= N; i++) {
		if (a[i - 1] == a[i]) {
			ans++;
			i++;
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    ll a = (h + 1) / 2, b = h / 2;
    ll c = (w + 1) / 2, d = w / 2;
    cout << a * c + b * d << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<set>
#include<string>
#include<vector>

#include<stack>
#include<queue>
#include<utility>
#include<tuple>
#include<cstdio>
#include<cstdlib>
#define mod 1000000007;
typedef long long ll;
#define rep(i,n) for(ll i=0; i<n; i++)
using namespace std;

int main(){
  ll n,m,x;
  cin >> n >> m;
  vector<ll> a(n+1,true);
  rep(i,m){
    cin >> x;
    a[x] = false;
  }
  vector<ll> ans(n+1);
  ans[0] = 1;
  rep(i,n){
    for(ll j = i+1; j <= min(n,i+2); j++){
      if (a[j]) {
        ans[j] += ans[i];
        ans[j] %= mod;
      }
    }
  }
  cout << ans[n];
  return 0;
}


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

void solve(long long N, std::vector<long long> A) {
    ll sum = 0;
    for (ll i = 1; i <= N + 1; i++) {
        sum += abs(A[i] - A[i - 1]);
    }
    for (ll i = 1; i <= N; i++) {
        cout << sum - (abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i])) + abs(A[i + 1] - A[i - 1]) << endl;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N + 2);
    A[0] = 0;
    for (int i = 1; i <= N; i++) {
        scanf("%lld", &A[i]);
    }
    A[N + 1] = 0;
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 3976
n = int(input())
d_lst = [list(map(int, input().split())) for _ in range(n)]

flag = False
count = 0
for i in range(n):
    d1 = d_lst[i][0]
    d2 = d_lst[i][1]

    if d1 == d2:
        count += 1

        if count == 3:
            flag = True

    else:
        count = 0

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9188
#include<stdio.h>

int main(){

    int a[10000],data,i,j,N;
    i==0;
    while(1){ 
        scanf("%d", &data);
        if(data==0){    break;
        }
        a[i]=data;
        i++;
    }

    for(j=0;j<i;j++){
        printf("Case %d: %d\n",j+1,a[j]);
        }

    return 0;
}


Measured memory_bytes: 2100
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
   uniform_int_distribution<int> uid(l, r);
   return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
 char c; cin >> c;
 if(c <= 'Z') cout << "A\n";
 else cout << "a\n";   
}

signed main() {   
   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
      solve();
  }
}    


Measured memory_bytes: 3616
#include <stdio.h>

int main(){
  int S[10000],T[500],n,q,cnt=0,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i]==S[j]){
	cnt++;
	break;
      }
    }
  }

  printf("%d\n",cnt);
  
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

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() {
	int A, B, K;
	int count = 0;
	int ans;

	cin >> A >> B >> K;

	for(int i = 100; i >= 1; i--){
		if((A % i == 0) && (B % i == 0)){
			count++;

			if(count  ==  K){
				ans = i;
				break;
			}
		}
	}

	cout << ans << endl;



}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val S = readLine()!!
    
    
    val rud = setOf('R', 'U', 'D')
    val lud = setOf('L', 'U', 'D')

    S.forEachIndexed { index, c ->
        val set = if (index % 2 == 0)  rud else lud
        if (!set.contains(c)) {
            println("No")
            return
        }
    }
    println("Yes")
}

Measured memory_bytes: 35792
// finish date: 2018/06/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <functional>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
const int bigmod = 1000000007;
const int INF = 1050000000;


int main() {
    int N, K;
    cin >> N >> K;
    vi A(N);
    int idx = 0;
    rep(i, N) {
        cin >> A[i];
        if (A[i] == 0) idx = i;
    }
    cout << (N - 1 +( K-2)) / (K - 1) << endl;


    return 0;
}






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


using namespace std;
int cnt[26], Cnt[26];

int main()
{
    int n; cin >> n;
    fill(Cnt, Cnt + 26, 1e6);
    for (int i = 0; i < n; i ++) {
        string s; cin >> s;
        memset(cnt, 0, sizeof cnt);
        for (int j = 0; j < s.size(); j ++) cnt[s[j] - 'a']++;
        for (int j = 0; j < 26; j ++) Cnt[j] = min(Cnt[j], cnt[j]);
    }
    for (int i = 0; i < 26; i ++) for (int j = 0; j < Cnt[i]; j ++) cout << char('a' + i);
    cout << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,i,coin;
	
	for(;;){
		scanf("%d",&n);
		if(n==0){break;}
		else{
			coin=0;
			n=1000-n;
			for(;n!=0;){
				if	   (n>=500){n-=500;coin++;}
				else if(n>=100){n-=100;coin++;}
				else if(n>= 50){n-= 50;coin++;}
				else if(n>= 10){n-= 10;coin++;}
				else if(n>=  5){n-=  5;coin++;}
				else if(n>=  1){n-=  1;coin++;}
			}
			printf("%d\n",coin);
		}
	}
	return 0;
}

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

void maxHeapify(int* A, int i, int heapSize) {
    int l = 2*i, r = 2*i+1;
    int largest;
    if (l <= heapSize && A[l] > A[i]) {
        largest = l;
    } else {
        largest = i;
    }
    if (r <= heapSize && A[r] > A[largest]) {
        largest = r;
    }
    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(A, largest, heapSize); //?????°??????????????????
    }
}

void buildMaxHeap(int* A, int heapSize) {
    for(int i = heapSize/2; i >= 1; --i) {
        maxHeapify(A, i, heapSize);
    }
}

int main() {
    int H, A[500001];
    cin >> H;
    for(int i = 1; i <= H; ++i) {
        cin >> A[i];
    }

    buildMaxHeap(A, H);

    for(int i = 1; i <= H; ++i) {
        cout << " " << A[i] << flush;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(int argc,char const* argv[])
{
  int n;
  long long ans=1;
  long long amari=1000000007;
  cin >> n;
  vector <int> a(n+1,0);
  for(int i=1;i<=n;i++)
    {
      int j=i;
      for(int k=2;k<=j;k++){
	while(j%k==0) j/=k,a[k]++;
      }
    }
  for(int i=1;i<=n;i++)
    {
      ans=ans *(a[i]+1)%amari;
    }
    
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

ll arr[87];
ll n;

int main(){
    ios::sync_with_stdio(0);
    arr[0] = 2;
    arr[1] = 1;
    forr(i,2,87){
        arr[i] = arr[i-1] + arr[i-2];
    }
    cin >> n;
    cout << arr[n] << "\n";
    return 0;
}

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

using namespace std;

int N;
bool RelInfos[201][201];

bool solve() {

	for (int k = 1; k < 201; ++k) {
		for (int i = 1; i < 201; ++i) {
			for (int j = 1; j < 201; ++j) {
				if (RelInfos[i][k] && RelInfos[k][j]) {
					RelInfos[i][j] = true;
				}
			}
		}
	}

	for (int i = 1; i < 101; ++i) {
		if (RelInfos[i][i]) {
			return true;
		}
	}
	return false;
}

int main() {
	int u, d;
	string rel;

	cin >> N;
	memset(RelInfos, false, sizeof(RelInfos));
	for (int i = 0; i < N; ++i) {
		cin >> u >> rel >> d;
		//cout << u << ends << rel << ends << d << endl;
		if (rel == "lock") {
			RelInfos[d+100][u] = true;
		}
		else if (rel == "wait") {
			RelInfos[u][d+100] = true;
		}
	}
	if (solve()) {
		cout << "1" << endl;
	}
	else {
		cout << "0" << endl;
	}

	return 0;
}



Measured memory_bytes: 3220
#include <stdio.h>

int A[1000000], n;

int binarySearch(int key)
{
    int left = 0;
    int right = n - 1;
    int mid;
    while (left <= right) {
        mid = left + (right - left) / 2;
        if (key == A[mid]) return 1;
        if (key > A[mid]) left = mid + 1;
        else if (key < A[mid]) right = mid - 1;
    }
    return 0;
}


int main(int argc, char const *argv[])
{
    int q, k, sum = 0;

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

    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &k);
        if (binarySearch(k)) {
            sum++;
        }
    }

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

    return 0;
}




Measured memory_bytes: 2116
/*
    f[i][j] = \sum f[i - 1][j - x] * comb(n - x, a[i] - x) * ifac[x]
*/
#include <bits/stdc++.h>
#define K 25
#define N 1005

using namespace std;

const int mod = 1e9 + 7;

int n, k;
int a[K], f[K][N];
int fac[N], ifac[N];

inline int fpm(int x, int y) {
    int r = 1;
    while(y) {
        if(y & 1) r = 1LL * r * x % mod;
        x = 1LL * x * x % mod, y >>= 1;
    }
    return r;
}
inline int perm(int x, int y) { return 1LL * fac[x] * ifac[x - y] % mod; }
inline int comb(int x, int y) { return 1LL * perm(x, y) * ifac[y] % mod; }

int main() {
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= k; ++i)
        scanf("%d", &a[i]);

    fac[0] = 1;
    for(int i = 1; i <= n; ++i) fac[i] = 1LL * i * fac[i - 1] % mod;
    ifac[n] = fpm(fac[n], mod - 2);
    for(int i = n; i; --i) ifac[i - 1] = 1LL * i * ifac[i] % mod;

    f[0][0] = 1;
    for(int i = 0; i < k; ++i) {
        for(int j = 0; j <= n; ++j) {
            if(!f[i][j]) continue;
            for(int x = 0; x <= a[i + 1] && j + x <= n; ++x) {
                f[i + 1][j + x] = (f[i + 1][j + x] + 
                1LL * f[i][j] * comb(n - x, a[i + 1] - x) % mod * ifac[x]) % mod;
            }
        }
    }

    int ans = 1LL * fac[n] * f[k][n] % mod;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int dp[3003][6006];
const int INF=1e9;
const int L=6001;

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

  int N,T;
  cin>>N>>T;
  vector<int> A(N),B(N);
  rep(i,N) cin>>A[i]>>B[i];

  vector<pair<int,int>> v;
  rep(i,N) v.push_back(mkp(A[i],i));
  sort(v.begin(),v.end());

  rep(i,N+1) rep(j,L) dp[i][j]=-INF;
  dp[0][0]=0;
  for(int i=0;i<N;i++){
    int now=v[i].second;
    for(int j=0;j<=L;j++) chmax(dp[i+1][j],dp[i][j]);
    for(int j=0;j<=L;j++){
      if(j>=T) break;
      if(dp[i][j]==-INF) continue;
      chmax(dp[i+1][j+A[now]],dp[i][j]+B[now]);
    }
  }

  int ans=0;
  rep(i,L) chmax(ans,dp[N][i]);
  cout<<ans<<endl;

  return 0;
}


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

LL h, w;
char s[50][50];
bool is_enqueued[50][50];

LL bfs() {
  LL dx[] = {0, 0, -1, 1};
  LL dy[] = {-1, 1, 0, 0};

  queue<tuple<LL, LL, LL>> q; // row, col, depth

  is_enqueued[0][0] = true;
  q.push(make_tuple(0, 0, 1));
  
  while (true) {
    if (q.empty()) {
      return -1;
    }
    const LL row = std::get<0>(q.front());
    const LL col = std::get<1>(q.front());
    const LL depth = std::get<2>(q.front());
    q.pop();
    #ifdef DEBUG
    cout << row << ":" << col << ":" << depth << endl;
    #endif
    if (row == h - 1 && col == w - 1) {
      // goal
      return depth;
    }
    rep(k, 4) {
      const LL i = dx[k];
      const LL j = dy[k];
      if (row + i >= 0 && row + i < h &&
          col + j >= 0 && col + j < w) {
        if (s[row + i][col + j] == '.') {
          if (!is_enqueued[row + i][col + j]) {
            q.push(make_tuple(row + i, col + j, depth + 1));
            is_enqueued[row + i][col + j] = true;
          }
        }
      }
    }
  }
}

int main() {
  cin >> h >> w;
  rep(i, h) {
    string ss;
    cin >> ss;
    rep(j, w) {
      s[i][j] = ss[j];
      is_enqueued[i][j] = false;
    }
  }

  const auto distance = bfs();
  if (distance == -1) {
    cout << -1 << endl;
    return 0;
  }
 
  LL n_black = 0;
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#') n_black++;
    }
  }
  cout << w * h - distance - n_black << endl;
  return 0;
  

  #ifdef DEBUG
  cout << distance << endl;
  #endif
}



Measured memory_bytes: 256
n, q = gets.to_s.split.map{|t|t.to_i}
s    = gets.to_s.chomp

cum = Array.new(s.size){ 0 }
s.chars.each_cons(2).each_with_index do |w,i|
  
  if w[0] == 'A' && w[1] == 'C'
    cum[i+1] = cum[i] + 1
  else
    cum[i+1] = cum[i]
  end
end

q.times do
  l, r = gets.to_s.split.map{|t|t.to_i-1}
  puts cum[r] - cum[l]
end

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

ll mp[333][333];
ll ans[333][333];

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

	REP(i, 333)REP(j, 333){
		mp[i][j] = LLINF;
		ans[i][j] = LLINF;
	}

	ll n, m, l;cin >> n >> m >> l;
	REP(i, m){
		ll a, b, c;cin >> a >> b >> c;
		a--;b--;
		if(c > l)continue;

		mp[a][b] = min(mp[a][b], c);
		mp[b][a] = min(mp[b][a], c);
	}

	REP(k, 333)REP(i, 333)REP(j, 333){
		mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
	}

	//SHOW2d(mp, n, n);

	REP(i, n){
		REP(j, n){
			if(mp[i][j] <= l)ans[i][j] = 0;
		}
	}

	REP(k, 333)REP(i, 333)REP(j, 333){
		ans[i][j] = min(ans[i][j], ans[i][k] + ans[k][j] + 1);
	}

	//SHOW2d(ans, n, n);

	ll q;cin >> q;
	REP(i, q){
		ll a, b;cin >> a >> b;
		a--;b--;
		if(ans[a][b] == LLINF)cout << -1 << "\n";
		else cout << ans[a][b] << "\n";
	}


	return 0;
}


Measured memory_bytes: 2304
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int pri[1010];
const ll mod=1e9+7;
ll a[1010];
ll ans=1;
ll n;
ll cnt;
bool is_pri(ll m){
	for(int i=2;i<m;i++){
		if(m%i==0)return 0;
	}
	return 1;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	if(n==1){
		cout<<1;
		return 0;
	}
	for(int i=2;i<=n;i++){
		if(is_pri(i))pri[cnt++]=i,a[i]++;
		else {
			ll x=i;
			for(int j=0;j<cnt;j++){
				while(x%pri[j]==0){
					a[pri[j]]++;
					x/=pri[j];
				}
				if(x==1)break;
			}
		}
	}
	for(int i=0;i<cnt;i++)ans*=(a[pri[i]]+1),ans%=mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def dijkstra(E, start):
    N_d = len(E)
    dist = [INF] * N_d
    dist[start] = 0
    q = [(0, start)]
    while q:
        dist_v, v = heappop(q)
        if dist[v] != dist_v:
            continue
        for u, dist_vu in E[v]:
            dist_u = dist_v + dist_vu
            if dist_u < dist[u]:
                dist[u] = dist_u
                heappush(q, (dist_u, u))
    return dist

def main():
	N, u, v = MAP()

	tree = [[] for _ in range(N)]
	for _ in range(N-1):
		A, B = MAP()
		tree[A-1].append((B-1, 1))
		tree[B-1].append((A-1, 1))

	d_t = dijkstra(tree, u-1)
	d_a = dijkstra(tree, v-1)
	# print(d_t, d_a)
	ans = -1
	for i in range(N):
		if d_t[i] <= d_a[i]:  # 青木くんより距離が近いか同じところで追いつかれる
			ans = max(ans, d_a[i])
	print(ans-1)

if __name__ == '__main__':
	main()


Measured memory_bytes: 43800
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  int N;
  string S1,S2;
  cin>>N;
  cin>>S1>>S2;
  int L=S1.size();
  long long cnt,k;
  if(S1[0]==S2[0]){
    cnt=3;
    k=1;
  }else{
    cnt=6;
    k=2;
  }
  FOR(i,k,L){
    if(S1[i]==S2[i]){
      if(S1[i-1]==S2[i-1]){
        (cnt*=2)%=INF;
      }else{
        continue;
      }
    }else{
      if(S1[i-1]==S2[i-1]){
        (cnt*=2)%=INF;
      }else{
        (cnt*=3)%=INF;
      }
      i++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
ID: Aman Raj
LANG: C++
TASK: money
*/
#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
//Â
using namespace std;
using namespace __gnu_pbds;
//Â
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
  //# define mod 1e9+7
   ll gcd(ll a,ll b)
   {
       if(a==0)return b;
       return gcd(b%a,a);
   }
//Â

int main()
{    ifstream fin("money.in");
     ofstream fout("money.out");
     string s;
      ll ans=0;
        cin>>s;
        char ch=s[0];ans=1;
          ll i=1;
           while(i<s.size())
         { if(s[i]!=ch){ch=s[i];ans++;  }
           else
            {ans++;i++;
                 if(i==s.size())
                 { ans--;


                 }
                 ch=' ';
            }
           i++;

         }
         cout<<ans;


      return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main() {
	double b;
	ll a, ans = 0;
	cin >> a >> b;
	ll bb = (ll)(b * 100 + 0.5);
	ans = a * bb;
	ans /= 100;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3728
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const int_least64_t INF = 10000000;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int n;
    cin >> n;
    map<string, int> m;
    string s;
    rep(i, n){
        cin >> s;
        m[s]++;
    }
    int res = 0;
    for(auto x : m){
        res = max(res, x.second);
    }
    for(auto x : m){
        if(x.second == res)
            cout << x.first << endl;
    }

    //cout << "" << endl;

    return 0;
}



Measured memory_bytes: 23808
n = int(input())
graph = [[0]*n for _ in range(n)]

for _ in range(n):
    u, k, *V = map(int, input().split())
    if k == 0:
        continue
    for j in V:
        graph[u-1][j-1] = 1

for g in graph:
    print(' '.join(map(str, g)))



Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int A, B;
  cin >> A >> B;
  int sum=1;
  int count=0;
  
  while(sum < B){
    sum += (A-1);
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
def split(para):
    return [char for char in para]
inp = split(para=input())
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(len(inp)):
    inp[i] = alpha[(alpha.index(inp[i])+n)%26]
joiner=""
print(joiner.join(inp))

Measured memory_bytes: 9076