akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

bool ham[1000001];
int m,n;

void solve(){
	ham[1] = true;
	for(int i=2; i<1000001; i++)
		ham[i] = false;
	for(int i=1; i<1000001; i++){
		if(ham[i]){
			for(int j=i*2; j<1000001; j*=2)
				ham[j] = true;
			for(int j=i*3; j<1000001; j*=3)
				ham[j] = true;
			for(int j=i*5; j<1000001; j*=5)
				ham[j] = true;
		}
	}
}

int main(){
	solve();
	while(true){
		cin >> m;
		if(!m)
			return 0;
		cin >> n;
		int ans = 0;
		for(int i=m; i<=n; i++)
			if(ham[i])
				ans++;
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1005;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s,t;cin>>s>>t;
    ll n=s.size(),m=t.size();
    if(m!=n+1)return cout<<"No" , 0;
    string cur = t.substr(0,n);
    cout<<(cur==s?"Yes":"No");
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
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;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1e9 + 7;
struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};
ostream& operator<<(ostream& os, const mint& a) {os << a.x; return os;}

const int MAX_N = 1123456;

mint fact[MAX_N];
mint dp[MAX_N];

int main2() {
  int N = nextLong();
  int H = nextLong();
  int D = nextLong();

  mint X = 0;
  for (int i = 1; i <= N; i++) X += fact[i];

  dp[0] = 1;
  mint r = dp[0];
  for (int i = 1; i <= H; i++) {
    dp[i] = r * X;
    r += dp[i];
    if (i - D >= 0) r -= dp[i - D];
  }

  mint ans = dp[H] / X * fact[N];
  cout << ans << endl;

  REP(i, N+1) dp[i] = 0;

  return 0;
}

int main() {

  fact[0] = 1;
  for (int i = 1; i < MAX_N; i++) fact[i] = mint(i) * fact[i-1];

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 21304
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        int pivot = A[0];
        if (pivot == 2) {
            System.out.println(1);
            return;
        }
        for (int i = 1; i < N; i++) {
            pivot = A[pivot - 1];
            if (pivot == 2) {
                System.out.println(i + 1);
                return;
            }
        }
        System.out.println(-1);
    }
}

Measured memory_bytes: 51012
fun main(args:Array<String>) {
    val (k,a,b) = readLine()!!.split(" ").map { it.toLong() }
    val adj = (k-a+1) % 2
    var ans = ((k-a+1)/2)*(b-a)+adj + a
    ans = Math.max(ans, k+1)
    println(ans)
}


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

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int [] count = new int [105];
		int [] countc = new int [105];
		int max;
		int j = 0;
		int x;
 		
		Scanner cin = new Scanner(System.in);
		while (cin.hasNext()) {
    	 	x = cin.nextInt();
    	 	count[x]++;
		}
    	 	
    	 	for (j = 0; j < 100; j++) {
    	 		countc[j] = count[j];
    	 	}
 			
 			Arrays.sort(countc);
 			
 			max = countc[104];
 			
	 		for (j = 0; j < 105; j++) {
    	 		if (count[j] == max) {
    	 			System.out.println(j);
    	 		}
    	 	}
	}
}

Measured memory_bytes: 26172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		
		if(t.substring(0, t.length() - 1).equals(s)) System.out.println("Yes");
		else System.out.println("No");
		
	}

}


Measured memory_bytes: 35656
#include <stdio.h>

int main(){

  int N,i,j,k,minj,t,c=0;
  
  scanf("%d",&N);

  int A[N];

  for(k=0;k<N;k++){
    scanf("%d",&A[k]);
  }

   
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
       
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    t=A[i];
    A[i]=A[minj];
    A[minj]=t;
    if(A[i]!=A[minj]) c++;
}
   
  for(k=0;k<N;k++){
    if(k!=N-1)printf("%d ",A[k]);
    else printf("%d",A[k]);
  }
  printf("\n%d\n",c);
  
  return 0;
}



Measured memory_bytes: 2088
#include <iostream>
#include <string>
#include <queue>
#include <string.h>

using namespace std;

char dx[] = {0, 1, 0, -1};
char dy[] = {1, 0, -1, 0};

int w, h;
string s[60];
bool check[60][10];

bool isStable(int _y, int _x, int *rootM, int *rootCnt){
    bool res = true;
    int M = 2, cnt = 4, XL = 100, XR = -100;
    queue< pair<int, int> > qu; qu.push(make_pair(_y,_x));
    while(!qu.empty()){
        pair<int, int> p = qu.front(); qu.pop();
        int y = p.first, x = p.second;
        if(check[y][x]) continue;
        check[y][x] = true;
        M += x;
        if(y==h-1||(s[y+1][x]!='.'&&s[y+1][x]!=s[y][x])){
            XL = min(XL, x  );
            XR = max(XR, x+1);
        }
        if(y!=0&&!check[y-1][x]&&s[y-1][x]!='.'&&s[y-1][x]!=s[y][x])
            if(!isStable(y-1, x, &M, &cnt)) return false;
        for(int k=0;k<4;k++){
            int ny = y+dy[k], nx = x+dx[k];
            if(ny<0||h<=ny||nx<0||w<=nx) continue;
            if(s[ny][nx]=='.'||s[ny][nx]!=s[y][x]) continue;
            qu.push(make_pair(ny, nx));
        }
    }
    *rootM   += M;
    *rootCnt += cnt;
    return cnt*XL < M && M < cnt*XR;
}

int main(){
    int dM, dC;
    while(cin >> w >> h, w){
        for(int i=0;i<h;i++) cin >> s[i];
        memset(check, false, sizeof(check));
        for(int i=0;i<w;i++)
            if(s[h-1][i]!='.'){
                printf("%sSTABLE\n", isStable(h-1, i, &dM, &dC) ? "" : "UN");
                break;
            }
    }
}

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

struct train {
  int next;
  ll yen;
  ll snuuk;
};

int main() {
  int n, m, s, t;
  cin >> n >> m >> s >> t;

  vector<vector<train>> G(n+1);
  for (int i = 0; i < m; i++) {
    int u, v;
    ll a, b;
    cin >> u >> v >> a >> b;
    G[u].push_back({v, a, b});
    G[v].push_back({u, a, b});
  }

  const ll init_money = 1e15;

  vector<ll> min_yen(n+1, init_money), min_snuuk(n+1, init_money);

  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> Q;  // money, i

  Q.push({0, s});
  min_yen[s] = 0;
  while (!Q.empty()) {
    ll yen = Q.top().first;
    int x = Q.top().second;
    Q.pop();

    if (min_yen[x] < yen) continue;

    for (auto p: G[x]) {
      if (p.yen + yen < min_yen[p.next]) {
        min_yen[p.next] = p.yen + yen;
        Q.push({min_yen[p.next], p.next});
      }
    }
  }

  Q.push({0, t});
  min_snuuk[t] = 0;
  while (!Q.empty()) {
    ll snuuk = Q.top().first;
    int x = Q.top().second;
    Q.pop();

    if (min_snuuk[x] < snuuk) continue;

    for (auto p: G[x]) {
      if (p.snuuk + snuuk < min_snuuk[p.next]) {
        min_snuuk[p.next] = p.snuuk + snuuk;
        Q.push({min_snuuk[p.next], p.next});
      }
    }
  }

  vector<ll> ans(n);
  ll max_snuuk = 0;
  for (int i = n; i > 0; i--) {
    ans[i - 1] = max(max_snuuk, init_money - min_yen[i] - min_snuuk[i]);
    max_snuuk = ans[i - 1];
  }

  for (int i = 0; i < n; i++) cout << ans[i] << endl;

  return 0;
}

Measured memory_bytes: 13688
/* ex4_2
    nnasy */

#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979

int main(void) {
    // 宣言と入力
    double lengthHour, lengthMin, hour, min;
    scanf("%lf%lf%lf%lf", &lengthHour, &lengthMin, &hour, &min);

    // 0時からの時計回りのそれぞれの角度
    double thetaMin = (PI/180)*(min/60)*360;
    double thetaHour = (PI/180)*(hour+min/60)/12*360;

    // 時針と短針のなす角
    double theta = thetaMin - thetaHour;

    // 余弦定理を用いた距離の計算
    printf("%.10f\n", sqrt(pow(lengthHour,2)+pow(lengthMin,2)-2*lengthHour*lengthMin*cos(theta)));

    return 0;
}

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

double dp[3001][3001];

int main()
{
    int n;
    cin >> n;
    vector<double> p(n + 1);
    for(int i = 1; i <= n; i++)
        scanf(" %lf", &p[i]);
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++)
        for(int x = 0; x <= i; x++)
            if(!x) dp[x][i] = (1 - p[i]) * dp[x][i - 1];
            else dp[x][i] = (1 - p[i]) * dp[x][i - 1] + p[i] * dp[x - 1][i - 1];
    double ans = 0;
    for(int x = 1; x <= n; x++) 
        if(x + x > n)
            ans += dp[x][n];

    printf("%.9lf\n", ans);


    return 0;
}

Measured memory_bytes: 70016
#include<stdio.h>
#include<string.h>

int main(void)
{
    char s[16];
  	//char t[16][1];
    int i;
    int ans=0;
    int w=0,l=0,sum=0;
  	
  	scanf("%s",s);

    for(i=0;i<=15;i++){
        if(s[i]=='o'){
            ans+=1;
            w+=1;
          //printf("w=%d\n",w);
        }else if(s[i]=='x'){
            l+=1;
          //printf("l=%d\n",l);
        }
    }
  	//printf("b1:ans=%d\n",ans);

    ans+=16-(l+w);
  	
  	//printf("b2:ans=%d\n",ans);

    if(ans>8){
        puts("YES\n");
    }else{
        puts("NO\n");
    }
    return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int kou,sou=114514,H,W;
int main(){
    cin>>H>>W;
    char HW[H][W];
    for(int i=0;i<H;i++){ for(int o=0;o<W;o++){ scanf(" %c",&HW[i][o]); }}
    for(int i=1;i<H-1;i++){
        for(int j=1;j<H-i;j++){
	    kou=0;
            for(int o=0;o<i;  o++){ for(int f=0;f<W;f++){ if(HW[o][f]!='W'){kou++;} } }
            for(int o=i;o<i+j;o++){ for(int f=0;f<W;f++){ if(HW[o][f]!='B'){kou++;} } }
            for(int o=i+j;o<H;o++){ for(int f=0;f<W;f++){ if(HW[o][f]!='R'){kou++;} } }
            sou=min(sou,kou);
        }
    }
    cout<<sou<<endl;
}

Measured memory_bytes: 3140
//*Here I go out to sea again
//*The sunshine fills my hair
//*And dreams hang in the air

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,a,b;
    cin>>n>>k>>a>>b;
    if(n<=k){
      cout<<n*a<<"\n";
    }
    else{
      cout<<k*a+(n-k)*b<<"\n";
    }

    return 0;
}


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

int main() {
    string binary[10];
    binary[0] = "0111111";
    binary[1] = "0000110";
    binary[2] = "1011011";
    binary[3] = "1001111";
    binary[4] = "1100110";
    binary[5] = "1101101";
    binary[6] = "1111101";
    binary[7] = "0100111";
    binary[8] = "1111111";
    binary[9] = "1101111";
    
    while (true) {
        int n;
        cin >> n;
        
        if (n==-1) {
            break;
        }
        
        string now = "0000000";
        
        for (int i=0; i<n; i++) {
            int d;
            cin >> d;
            string res = "";
            
            for (int i=0; i<7; i++) {
                if (now[i]==binary[d][i]) {
                    res += "0";
                }
                else {
                    res += "1";
                }
            }
            
            now = binary[d];
            
            cout << res << endl;
        }
    }
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

const int INF = 100'100'100;

class digraph
{
private:
    class edge;
    class vertex;
public:
    vec<vec<edge>> adjL;
    vec<vertex> verS;
public:
    void push_edge(int u,int v,int w);
    void push_edge(int u,int v);
    //void pop_edge(int &u, int &v);
public:
    void bfs(int index_of_start_vertex);
    //void dfs();
public:
    digraph(size_t V)
    {
        adjL.resize(V);
        verS.resize(V);
    }
    ~digraph()
    {}
};

class digraph::edge
{
public:
    int from;
    int to;
    int weight;
public:
    edge(int from,int to, int weight):from(from),to(to),weight(weight)
    {}
    ~edge()
    {}
};

class digraph::vertex
{
public:
    //0->white;1->black
    bool color;
    int distance;
    int predecessor;
public:
    vertex()
    {}
    ~vertex()
    {}
};

void digraph::push_edge(int u, int v, int w)
{
    edge new_edge = {u,v,w};
    adjL.at(u).push_back(new_edge);
};
void digraph::push_edge(int u, int v)
{
    push_edge(u,v,1);
};

void digraph::bfs(int index_of_start_vertex)
{
    for (auto &&vertex : verS)
    {
        vertex.color = false; // "white"
        vertex.distance = INF;
        vertex.predecessor = -1;
    }

    auto &s = index_of_start_vertex;
    //s->color = "gray";
    verS.at(s).distance = 0;
    verS.at(s).predecessor = -1;
    queue<int> Q;
    Q.push(s);
    while (!Q.empty())
    {
        int u = Q.front();
        Q.pop();

        for (auto &&Edge : adjL.at(u))
        {
            int v = Edge.to;
            if (verS.at(v).color == 0)
            {
                verS.at(v).color = 1;
                verS.at(v).distance = verS.at(u).distance + 1;
                verS.at(v).predecessor = u;
                Q.push(v);
            }
        }
        verS.at(u).color = 1;
    }
}

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

    digraph G(n);
    for (int i = 0; i < m; i++)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G.push_edge(a,b);
        G.push_edge(b,a);
    }
    
    G.bfs(0);
    bool flag = 1;
    for (auto &&v : G.verS)
    {
        if(v.color == 0)
        flag = 0;
    }
    
    if (flag)
    {
        cout << "Yes" << endl;
        for (size_t i = 1; i < n; i++)
        {
            cout << G.verS.at(i).predecessor + 1 << endl;
        }
        
    }
    else
    {
        cout << "No" << endl;
    }
    

    for (int i=0;i<G.verS.size();i++)
    {
        cerr << "vertex " << i+1 << " : color = " << G.verS.at(i).color << ", distance = " << G.verS.at(i).distance << ", predecessor = " << G.verS.at(i).predecessor+1 << endl;
    }
}

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

ans = 0

for i in range(1, n + 1):
    x = 0
    if i % 2 == 1:
        for j in range(1, i + 1):
            if i % j == 0:
                x += 1
    if x == 8:
        ans += 1

print(ans)


Measured memory_bytes: 9092
#include <stdio.h>

int main(int argc, char *argv[])
{
	int i, N, kisu = 0, time2 = 0, time4 = 0;
	scanf("%d", &N);
	for ( i = 0; i < N; i++ ){
		int a;
		scanf("%d", &a);
		if ( a%2 == 1 ){
			kisu++;
		} else if ( a%4 == 0 ){
			time4++;
		} else {
			time2++;
		}
	}
	if ( kisu > time4 + 1 ){
		printf("No\n");
	} else if ( kisu == time4 + 1 ){
		if ( time2 > 0 ){
			printf("No\n");
		} else {
			printf("Yes\n");
		}
	} else {
		printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 128
def make_divisors(n):
    # from qiita.com/LorseKudos
    l, u = [], []
    i = 1
    while i*i<=n:
        if n%i==0:
            l.append(i)
            if i!=n//i:
                u.append(n//i)
        i+=1
    return l+u[::-1]

n = int(input())
Ns = make_divisors(n)
Ns = [_ns-1 for _ns in Ns if _ns!=1]
ans = 0
for _ns in Ns:
    if n//_ns==n%_ns:
        ans += _ns
print(ans)

Measured memory_bytes: 9300
#include <stdio.h>

int main(void)
{
    int a,b,r,x,tmp;
    a=2;

    scanf("%d",&b);
    x=a*b;

    if(a<b){
        tmp=a;
        a=b;
        b=tmp;
        }

    r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    printf("%d",x/b);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
#define MOD 1000000007
#define INF 1000000

int main()
{
  string S,T;cin>>S>>T;
  T+=S;
  cout<<T<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define debug(x) cerr << #x << ':' << x << '\n'
#define Pi 3.1415926535
#define MOD 1000000007
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << '\n';}
void no(){cout << "No" << '\n';}

int solve(){
    int n, k; cin >> n >> k;
    vint a(n); rep(i,n) cin >> a[i];
    vint b(n); rep(i,n) b[i] = 1;
/*     for(int i = k-1; i < n; ++i){
        for(int j = 0; j < k; ++j){
            b[i] *= a[i-j];
        }
    }

    for(int i = k; i < n; ++i){
        if(b[i] > b[i-1]) yes();
        else no();
    } */

    for(int i = k; i < n; ++i){
        if(a[i] > a[i-k]) yes();
        else no();
    }

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i = 0;i < n;i++){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  double ans = (v.at(0)+v.at(1))/2;
  for(int i = 2;i < n;i++){
    ans = (ans+v.at(i))/2;
  }
  printf("%.30f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;


int main()
{
    lint N;
    cin >> N;
    vector<lint> A(N);
    cin >> A;
    lint ki = 1;
    lint ans = 1;
    for (auto v : A)
    {
        ans *= 3;
        if ((v & 1) == 0) ki *= 2;
    }
    cout << ans - ki << endl;
    return 0;
}


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

struct Vec{
 double x,y;
 Vec(double xx, double yy) : x(xx),y(yy) {}
 Vec operator+() const {return Vec(x,y);}
 Vec operator-() const {return Vec(-x,-y);}
 Vec operator+(const Vec& r) const {return Vec(x+r.x,y+r.y);}
 Vec operator-(const Vec& r) const {return Vec(x-r.x,y-r.y);}
 Vec operator*(double r) const {return Vec(x*r,y*r);}
 Vec operator/(double r) const {return Vec(x/r,y/r);}
 Vec& operator+=(const Vec& r) {*this=*this+r; return *this;}
 Vec& operator-=(const Vec& r) {*this=*this-r; return *this;}
 Vec& operator*=(double r) {*this=*this*r; return *this;}
 Vec& operator/=(double r) {*this=*this/r; return *this;}
 double operator*(const Vec& r) const {return x*r.x+y*r.y;}
 double abs() const {return sqrt(x*x+y*y);}
 double abs_squared() const {return x*x+y*y;}
};

Vec InputVec(){
 double x,y; scanf("%lf%lf",&x,&y);
 return Vec(x,y);
}

void PrintVec(Vec tg){
 printf("%.10f %.10f",tg.x,tg.y);
}

int main() {
 Vec O = InputVec();
 Vec A = InputVec() - O;
 A /= A.abs();
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  Vec X = InputVec() - O;
  Vec Proj = A * (A*X);
  PrintVec(O + Proj + Proj - X);
  printf("\n");
 }
 return 0;
}



Measured memory_bytes: 3240
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        String text = sc.next();
        // スペース区切りの整数の入力
      
      	String a="a";
      	String b="b";
      	String c="c";
  
      if(text.matches(".*" + a + ".*")){
       	if(text.matches(".*" + b + ".*")){
      			 if(text.matches(".*" + c + ".*")){
      				System.out.println("Yes");
      			}else{
    			  System.out.println("No");
    			  }
     	 }else{
     	 System.out.println("No");
     	 }
      }else{
      System.out.println("No");
      }
 
    }
}

Measured memory_bytes: 22612
#include <cstdio> 
#define SZ 3009 
#define llg long long 
using namespace std; 

int n; 
llg p, S[SZ][SZ], ans = 0, C[SZ][SZ]; 

int read(); 
llg fsq(llg x, llg kn, llg mod = p) {
	llg ret = 1; 
	while (kn) {
		if (kn & 1) (ret *= x) %= mod; 
		(x *= x) %= mod; kn >>= 1; 
	} 
	return ret; 
} 
void get_S() {
	for (int i = 0; i <= n + 1; ++i) C[i][0] = 1; S[0][0] = 1; 
	for (int i = 1; i <= n + 1; ++i) for (int j = 1; j <= i; ++j) 
		S[i][j] = (S[i - 1][j - 1] + S[i - 1][j] * j % p) % p; 
	for (int i = 1; i <= n + 1; ++i) for (int j = 1; j <= i; ++j) 
		C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % p; 
} 

int main() {
	n = read(), p = read(); S[0][0] = 1; get_S(); 
	for (int i = 0; i <= n; ++i) {
		llg now = 0, mult = 1, eac = fsq(2, n - i); 
		for (int j = 0; j <= i; ++j) {
			(now += mult * S[i + 1][j + 1] % p) %= p; 
			(mult *= eac) %= p; 
		} 
		(now *= fsq(2, fsq(2, n - i, p - 1))) %= p; 
		if (i & 1) (now *= (p - 1)) %= p; 
		(now *= C[n][i]) %= p; 
		(ans += now) %= p; 
	} 
	printf("%lld\n", ans); 
	return 0; 
} 

int read() {
	int x = 0, f = 1; char c = getchar(); 
	while (c > '9' || c < '0') f = (c == '-') ? -1 : f, c = getchar(); 
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); 
	return x * f; 
} 

Measured memory_bytes: 93936
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let ans = 1;
   for(let i=0; i<xs.length; i++){
      if(xs[i]!=0){
        ans++
      }else{
        break;
      }
   }
   console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 29580
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;


public class Main {

    private static class Point {
        public int x, y;

        Point() {
        }

        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public void getInfo() {
            System.out.println(x + "," + y);
        }

    }

    private static char[][] map;
    private static int[][] d;
    private static int row;
    private static int col;
    private static final Scanner SC = new Scanner(System.in);
    private static final int[] DX = {0, 0, -1, 1};
    private static final int[] DY = {-1, 1, 0, 0};

    public static void main(String[] args) {
        row = SC.nextInt();
        col = SC.nextInt();
        int fNum = SC.nextInt();
        Point[] factories = new Point[fNum + 1];
        SC.nextLine();
        map = new char[row][];
        d = new int[row][col];
        for (int i = 0; i < row; i++) {
            map[i] = SC.nextLine().toCharArray();
        }

        for (int i = 0; i < row; i++) {
            for (int j = 0; j < col; j++) {
                for (int f = 1; f <= fNum; f++) {
                    if (map[i][j] == '0' + f) {
                        factories[f] = new Point(i, j);
                    }
                }
                if (map[i][j] == 'S') {

                    factories[0] = new Point(i, j);
                }

            }
        }
//        for (int i = 0; i <= fNum; i++) {
//            factories[i].getInfo();
//        }
        int ans = 0;
        for (int i = 1; i <= fNum; i++) {
            ans += bfs(factories[i - 1].x, factories[i - 1].y, factories[i].x, factories[i].y);
        }
        System.out.println(ans);
    }

    public static int bfs(int sx, int sy, int ex, int ey) {
        Queue<Point> q = new LinkedList<Point>();
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < col; j++) {
                d[i][j] = -1;
            }
        }
        q.add(new Point(sx, sy));
        d[sx][sy] = 0;
        while (!q.isEmpty()) {
            Point cur = q.poll();
            if (cur.x == ex && cur.y == ey) {
                break;
            }
            for (int i = 0; i < 4; i++) {
                int tr = cur.x + DX[i];
                int tc = cur.y + DY[i];
                if (0 <= tr && tr < row && 0 <= tc && tc < col && d[tr][tc] == -1 && map[tr][tc] != 'X') {
                    d[tr][tc] = d[cur.x][cur.y] + 1;
                    q.add(new Point(tr, tc));
                }

            }
        }
//        System.out.println("[" + sx + "," + sy + "] to [" + ex + "," + ey + "] is " + d[ex][ey]);
        return d[ex][ey];
    }
}



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

int main()
{
  int N,L;
  cin>>N>>L;
  int amin = 300;
  int min = 0;
  int ans = 0;
  for(int i=0;i<N;i++){
    ans += L+i;
    if(abs(L+i)<amin){
      amin = abs(L+i);
      min = L+i;
    }
  }

  cout<<ans-min<<endl;
}


Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())
H_deg = H*(math.pi)/6+M*math.pi/360
M_deg = M*(math.pi)/(3*10)
if H_deg >= M_deg:
    deg = H_deg - M_deg
else:
    deg = M_deg - H_deg
if deg >math.pi:
    deg = 2*(math.pi)-deg
c2=0
c2 = A*A+B*B-2*A*B*(math.cos(deg))
print(math.sqrt(c2))

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

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

    int x = n;
    int f = 0;
    while (x>=1) {
        int mod;
        mod = x%10;
        f += mod;
        x = (x - mod)/10;
    }
    if (n%f == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc164/tasks/abc164_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int cnt = 0;
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (A > 0 && C > 0) {
        if (cnt % 2 == 0) {
            C -= B;
        } else {
            A -= D;
        }
        cnt++;
    }
    if (cnt % 2 == 0) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }

    return 0;
}


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

int main()
{
  int N, r, l;
  int people = 0;
  cin >> N;
  
  for(int i=0; i<N ; i++)
  {
    cin >> l >> r;
    people += r - l + 1;
  }
  
  cout << people << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.stream.Stream;

public class Main {

  static int n;
  static int[] a;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);
    in = br.readLine().split(" ");
    a = Stream.of(in).mapToInt(Integer::parseInt).toArray();

    br.close();

    long kabu = 1000 / a[0];
    long pur = 1000 % a[0];

    for (int i = 1; i < n; i++) {
      if (a[i - 1] > a[i]) {
        pur += kabu * a[i - 1];
      } else {
        pur += kabu * a[i];
      }
      kabu = pur / a[i];
      pur %= a[i];
    }

    pur += kabu * a[n - 1];

    out.println(pur);

    out.flush();
  }
}


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

typedef long long int ll;
using namespace std;

char maze[1002][1002];
ll dp[1002][1002];
ll divide = 1e9 + 7;

int main(){
    int H, W;
    cin >> H >> W;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> maze[i][j];
            dp[i][j] = 0;
        }
    }


    dp[0][0] = 1;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if (i==0){
                if (maze[0][j-1]=='.'){
                    dp[0][j] += dp[0][j-1];
                    dp[0][j] %= divide;
                }
            }else if (j==0){
                if (maze[i-1][0]=='.'){
                    dp[i][0] += dp[i-1][0];
                    dp[i][0] %= divide;
                }
            }else{
                if (maze[i-1][j]=='.'){
                    dp[i][j] += dp[i-1][j];
                    dp[i][j] %= divide;
                }
                if (maze[i][j-1]=='.'){
                    dp[i][j] += dp[i][j-1];
                    dp[i][j] %= divide;
                }
            }
        }
    }

    cout << dp[H-1][W-1] % divide << endl;
    return 0;
}

Measured memory_bytes: 9088
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    constexpr ll mod = inf;
    int n; cin >> n;
    vector<ll> a(n);
    vector<vector<ll>> cnt(n, vector<ll>(63));
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        for (int j = 0; j < 63; ++j) {
            cnt[i][j] += a[i] >> j & 1;
        }
    }

    for (int j = 0; j < 63; ++j) {
        for (int i = n - 2; i >= 0; --i) {
            cnt[i][j] += cnt[i + 1][j];
        }
    }

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 63; ++j) {
            if (cnt[i][j] == 0) continue;

            if (a[i] >> j & 1) {
                ans += (1LL << j) % mod * (n - i - cnt[i][j]);
            }
            else {
                ans += (1LL << j) % mod * (cnt[i][j]);
            }
            ans %= mod;
        }
    }

    // ll ans2 = 0;
    // for (int i = 0; i < n; ++i) {
    //     for (int j = i + 1; j < n; ++j) {
    //         ans2 += a[i] ^ a[j];
    //         ans2 %= mod;
    //     }
    // }

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

Measured memory_bytes: 159616
#include<bits/stdc++.h>
using namespace std;
int a;
int main()
{
 //freopen(".in","r",stdin);
 //freopen(".out","w",stdout);
 cin>>a;
 for(; a>0; a/=10)
  	if(a%10==9)
  	{
   	 cout<<"Yes";
   	 return 0;	
  	}	
 cout<<"No";
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
int main(void){
    int N;
    long long K;
    long long int count =0;
    int a[114514],b[114514];
    long long int E[114514]={};
    cin >> N >> K;
    REP(i,N){cin >> a[i] >> b[i];}
    REP(i,N){
        E[a[i]]+=b[i];
    }
    for(long long int i=1;;i++){count+=E[i];if(count>=K){cout << i << endl;break;}}
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 int i,m,n,q,x,y,ans;
 cin >> n >> m >> q;
 int a[n],b[m],c[q];
 for(i=0;i<n;i++)
 cin >> a[i];
 for(i=0;i<m;i++)
 cin >> b[i];
 ans=*min_element(a,a+n)+*min_element(b,b+m);
 for(i=0;i<q;i++)
 {
  cin >> x >> y >> c[i];
  ans=min(ans,a[x-1]+b[y-1]-c[i]);
 }
 cout << ans;
 return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<cstdio>
int main(){
  std::string s;
  int x = 0, max = 0, n;
  std::cin >> n;
  char S[n];
  for(int i = 0; i < n; i++){
    scanf(" %c",&S[i]);
    if(S[i] == 'I'){
      x++;
      if(x > max)
        max = x;
    }
    if(S[i] == 'D')
      x--;
  }
  std::cout << max << std::endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    string s;
    cin >> s;
    n =stol(s);
    ll sum = 0;
    rp(i,s.length()){
      sum += stol(string(1,s[i]));
    }
    if(n%sum == 0) std::cout << "Yes" << '\n';
    else std::cout << "No" << '\n';

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b; cin >> a >> b;
    int ans = 1;
   	if(b<100) OUT(pow(100, a) * b);
    else{
      	cout << 101;
      	rep(i,a*2) cout << 0;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int X,t;
	cin >> X >> t;
	if(X-t>=0){
		cout << X-t << endl;
	}
	else{
		cout << "0" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> p(m);
    vector<int> y(m);
    vector<int> py[100001];
    for(int i=0;i<m;i++){
        cin>>p[i]>>y[i];
        py[p[i]].push_back(y[i]);
    }
    for(int i=0;i<n;i++){
        sort(py[i+1].begin(),py[i+1].end());
    }
    for(int i=0;i<m;i++){
        printf("%06d%06d\n",p[i],((int)(lower_bound(py[p[i]].begin(),py[p[i]].end(),y[i])-py[p[i]].begin())+1));
    }
    return 0;
}


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

int n,ans;
int a[105],mx;

int main()
{
	
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		if(mx<=a[i]) ans++;
		mx=max(mx,a[i]);
	}
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define min(a,b) (a)<(b)?(a):(b)
int n,k,s=1;
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i)
        s+=min(s,k);
    printf("%d\n",s);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(){
	int d[105][105];
	int i,j,k,f,n,s,x,y,gx,gy;
	scanf("%d",&n);
	for(k=0;k<n;k++){
		memset(d,0,sizeof(d));
		scanf("%d",&s);
		x=0;y=s-1;f=0;
		if(s%2==1){
			if(((s+1)/2)%2==0)gx=gy=(s+1)/2;
			else gx=gy=(s-1)/2;
		}else{
			if((s/2)%2==0)gx=gy=s/2,gy++;
			else gx=gy=s/2,gy--;
		}
		while(1){
			if(x==gx && y==gy)break;
			d[y][x]=1;
			switch(f){
				case 0:
					if(y==0 ||(y>=2 && d[y-2][x]==1))f=1;
					else y--;
				break;
				case 1:
					if(x==s-1 || d[y][x+2]==1)f=2;
					else x++;
				break;
				case 2:
					if(y==s-1 || d[y+2][x]==1)f=3;
					else y++;
				break;
				case 3:
					if(x==0 || (x>=2 &&d[y][x-2]==1))f=0;
					else x--;
				break;
			}
			/*printf("%d %d %d\n",x,y,f);
			for(i=0;i<s;i++){
				for(j=0;j<s;j++){
					if(i!=y || j!=x)printf("%s",d[i][j]?"#":" ");
					else printf("A");
				}
				printf("\n");
			}*/
		}
		d[y][x]=1;
		printf("%s",(k==0)?"":"\n");
		for(i=0;i<s;i++){
			//printf("%d",i);
			for(j=0;j<s;j++)printf("%s",d[i][j]?"#":" ");
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <memory.h>
#include <algorithm>

using namespace std;

const int maxn = 2e+5 + 10;
int pos[maxn], N;

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

	cin >> N;
	for (int i = 1; i <= N; i++) {
		int t;
		cin >> t;
		pos[t] = i;
	}

	int prev = N + 1, cur = 0;
	int res = 0;
	for (int i = N; i >= 1; i--) {
		if (pos[i] < prev) {
			cur++;
			res = max(cur, res);
		}
		else {
			cur = 1;
		}
		prev = pos[i];
	}
	cout << N - res << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  vvi F(N, vi(10));
  rep(i, 0, N) {
    rep(j, 0, 10) {
      in(F[i][j]);
    }
  }
  vvl P(N, vl(11));
  rep(i, 0, N) {
    rep(j, 0, 11) {
      in(P[i][j]);
    }
  }

  ll ans = -LINF;
  rep(b, 1, 1 << 10) {
    ll c = 0;
    rep(i, 0, N) {
      int cnt = 0;
      rep(j, 0, 10) {
        if (1 << j & b) {
          if (F[i][j]) cnt++;
        }
      }
      c += P[i][cnt];
    }
    ans = max(ans, c);
  }
  print(ans);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String[] S = new String[N];
    for (int i = 0; i < N; i++) S[i] = sc.next();
    sc.close();

    Set<String> set = new HashSet<>();
    for (int i = 0; i < N; i++) set.add(S[i]);

    int ans = set.size();
    System.out.println(ans);
  }
}


Measured memory_bytes: 74616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    int x = n/a, y = n/c;
    if(n%a!=0) x++;
    if(n%c!=0) y++;
    x *= b;
    y *= d;
    if(x>y) pr(y);
    else pr(x);
    return 0;}


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

int num[3] = {3, 5, 7};
bool used[10];
int N;
int ans;

void dfs(ll x) {
  if (x > N) return;

  int y = x;
  used[3] = used[5] = used[7] = false;
  while (y > 0) {
    used[y % 10] = true;
    y /= 10;
  }
  if (used[3] && used[5] && used[7]) ++ans;
  rep(i, 3) dfs(10*x+num[i]);
}

int main() {
  cin >> N;
  dfs(0);
  cout << ans << endl;
  return 0;
}

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

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

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

int main() {
    char C;
    cin>>C;

    int ans=(C-'a')+1;
    char ANS=ans+'a';

    cout<<ANS<<endl;

}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

int read()
{
  int x=0,f=1;
  char ch=getchar();
  while((ch<'0')||(ch>'9'))
    {
      if(ch=='-')
        {
          f=-f;
        }
      ch=getchar();
    }
  while((ch>='0')&&(ch<='9'))
    {
      x=x*10+ch-'0';
      ch=getchar();
    }
  return x*f;
}

const int maxn=200000;
const int maxv=99999999;
const double D=11.4159265358979323846264338328;
const double K=-4.2920367320510338076867830836;

int n,m,maxy,sx,sy,tx,ty,tot,c[maxn+10],pos[maxn+10],cnt;
double ans;

struct point
{
  int x,y;
  
  bool operator <(const point &other) const
  {
    return x<other.x;
  }
};

point p[maxn+10],t[maxn+10];

int main(){
  sx=read();
  sy=read();
  tx=read();
  ty=read();
  if(sx>tx)
    {
      std::swap(sx,tx);
      std::swap(sy,ty);
    }
  n=read();
  for(int i=1;i<=n;i++)
    {
      p[i].x=read();
      p[i].y=read();
    }
  if(sy>ty)
    {
      for(int i=1;i<=n;i++)
        {
          p[i].y=maxv-p[i].y;
        }
      sy=maxv-sy,ty=maxv-ty;
    }
  std::sort(p+1,p+n+1);
  ans=(ty+tx-sy-sx)*100.0;
  for(int i=1;i<=n;i++)
    {
      if((p[i].x>=sx)&&(p[i].y>=sy)&&(p[i].x<=tx)&&(p[i].y<=ty))
        {
          t[++tot]=p[i];
        }
    }
  memset(c,63,sizeof c);
  c[0]=cnt=0;
  for(int i=1;i<=tot;i++)
    {
      int res=std::lower_bound(c+1,c+cnt+1,t[i].y)-c;
      if(res>cnt)
        {
          cnt++;
        }
      c[res]=std::min(c[res],t[i].y);
    }
  if(cnt<=tx-sx&&cnt<=ty-sy)
    {
      ans+=cnt*K;
    }
  else
    {
      ans+=(cnt-1)*K+D;
    }
  printf("%.13lf\n",ans);
  return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 1000005;
const int mod = 998244353;

int n, m, ans, sum, fac[MAXN], inv[MAXN];

inline int C(int n, int m)
{
	return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = Read();
	if (n < m)
		swap(n, m);
	ans = n;
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i <= n + m; i ++)
		fac[i] = 1LL * fac[i - 1] * i % mod, inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
	for (int i = 2; i <= n + m; i ++)
		inv[i] = 1LL * inv[i] * inv[i - 1] % mod;
	for (int i = 1; i <= m; i ++)
		sum = (1LL * C(i << 1, i) * C(n + m - (i << 1), n - i) + sum) % mod;
	return printf("%d\n", (1LL * sum * inv[2] % mod * inv[n + m] % mod * fac[n] % mod * fac[m] + ans) % mod), 0;
}


Measured memory_bytes: 8064
N, K = map(int, input().split())
N_list = [0 for n in range(N)]

for k in range(K):
    d_i = int(input())
    # for i in range(d_i):
    l = list(map(int, input().split()))
    for i in l:
        N_list[i-1] += 1

print(N_list.count(0))


Measured memory_bytes: 9172
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


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

  int N, W;
  int v[100], w[100];
  cin >> N >> W;

  rep(i, N){
    cin >> v[i] >> w[i];
  }

  int ans[101][10001];
  rep(i, N+1){
    rep(j, W+1){
      if (i == 0 || j == 0){
        ans[i][j] = 0;
      } else if (j - w[i-1]<0){
        ans[i][j] = ans[i-1][j];
      } else {
        ans[i][j] = max(ans[i-1][j], ans[i][j-w[i-1]] + v[i-1]);
      }
      // cout << ans[i][j]  << " " << i << " " << j << endl;
    }
  }

  cout << ans[N][W] << "\n";

}


Measured memory_bytes: 7156