akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  vi a(5);
  cin >> a;
  rep(i, 0, 5) {
    if (a[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 3644
#include <cstdio>
#include <iterator>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 234567;
set<int> col[MAXN];

int dfs(int x, int y, int tu) {
    //printf("x = %d y = %d tu = %d\n", x, y, tu);
    if (tu == 0) {
       if (col[y].find(x + 1) != col[y].end())
          return x;
       else
          return dfs(x + 1, y, 1);
    }
    int rans = (*col[y].upper_bound(x)) - 1;
    if (col[y].find(x + 1) != col[y].end())
        return x;
    else if (col[y + 1].find(x) == col[y + 1].end())
        return min(rans, dfs(x, y + 1, 0));
    else
        return dfs(x, y, 0);
}

int main() {
    int H, W, N;
    scanf("%d %d %d", &H, &W, &N);
    for (int i = 0; i < N; i++) {
        int X, Y;
        scanf("%d %d", &X, &Y);
        col[Y].insert(X);
    }
    for (int i = 1; i <= W; i++) col[i].insert(H + 1);
    for (int i = 1; i<= H; i++) col[W + 1].insert(i);
    printf("%d\n", dfs(1, 1, 0));
    return 0;
}


Measured memory_bytes: 43392
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

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

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)

int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    sf(n);
    pf(n*n);
    return 0;
}



Measured memory_bytes: 256
from math import factorial
from collections import Counter

N, M = map(int, input().split())
MOD = 10 ** 9 + 7

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A = prime_factorize(M)
c = Counter(A)
cases = 1

for v in c.values():
    if v > 1:
        x = factorial(v+N-1)%MOD*pow(factorial(N-1)*factorial(v) % MOD, MOD-2, MOD)%MOD
        cases *= x
    else:
        cases *= N
    cases %= MOD
print(cases)


Measured memory_bytes: 4608
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    int num,a;
    double sum = 0;
    cin >> num;
    
    vector<int>v;
    
    for(int i = 0;i < num;++i){
        cin >> a;
        v.push_back(a);
        sum += a;
    }
    int max = *max_element(v.begin(), v.end());
    int min = *min_element(v.begin(), v.end());
    
    cout << min << " " << max << " " << fixed << setprecision(0) << sum << endl;
    
    return 0;
}


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

using namespace std;

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

ll mod = 1e9 + 7;

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

	int a[20];
	int b[20];
	int c[20];

	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	for(int i=0;i<n-1;i++){
		cin >> c[i];
	}

	int ans = 0;
	for(int i=0;i<n;i++){
		ans += b[i];
	}
	for(int i=1;i<n;i++){
		if(a[i-1]+1==a[i]) ans += c[a[i-1]-1];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int main(){
  long ii,jj,kk;
  vector<int> a;
  int n,q;
  int x,y;
  cin >> n >> q;
  a.resize(n);

  for(ii=0;ii<n;ii++){
    a[ii] = INF;
  }

  int qq;

  for(ii=0;ii<q;ii++){

    cin >> qq;

    //cout << "q:" << q << " " << qq << endl;

    if(qq == 0){
      cin >> x >> y;
      a[x] = y;
      //cout << y << endl;
    }
    
    else{

      cin >> x >> y;

      int min = INF;

      for(jj=x;jj<=y;jj++){

        if(a[jj] < min){
          min = a[jj];
        }

      }
      
      cout << min << endl;

    }

    //cout << "x:" << x <<"y:" << y << endl;
    
  }

  //cout << "========" << endl;
  //for(ii=0;ii<n;ii++){
  //  cout << a[ii] << endl;
  //}
  return 0;
}



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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> c(h);
  for(int i = 0; i < h; i++)
    cin >> c.at(i);
  for(int i = 0; i < h; i++)
    cout << c.at(i) << '\n' << c.at(i) << '\n';
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class P{
    static long[] leng=new long[51];
    // l+ = 2l+3
    //l0=1
    //l=
    static long count(long sou,long nagasa){
        if(sou==0)return(nagasa==1?1:0);
        if(nagasa<=1)return 0;
        if(nagasa<=leng[sou-1]+1)return(count(sou-1,nagasa-1));
        if(nagasa==leng[sou-1]+2)return(count(sou-1,leng[sou-1])+1);
        if(nagasa==leng[sou])return(2*count(sou-1,leng[sou-1])+1);
        return(count(sou-1,leng[sou-1])+1+count(sou-1,nagasa-2-leng[sou-1]));
    }
    static void Main(){
        leng[0]=1;
        for(int i=1;i<=50;i++){
            leng[i]=3+2*leng[i-1];
        }
        var s=Console.ReadLine().Split().Select(long.Parse).ToArray();
        Console.WriteLine(count(s[0],s[1])); 
    }
}

Measured memory_bytes: 13396
import sys
input = sys.stdin.readline
n=int(input())
A=[]
append=A.append
for i in range(n):
  append((int(input()),i+1))
A.sort(key=lambda x:x[0])
ans=0
for i in range(n):
  a,b=A[i]
  if (i+1)%2!=b%2:
    ans+=1
print(ans//2)


Measured memory_bytes: 18224
n = gets.to_i
list = {}
n.times{ |i|
    str = gets.chomp
    list[str] = 1
}
for i in ["S","H","C","D"] do
    for j in 1..13 do
        str =  i + " " + j.to_s
        if  !list.include?(str)
            puts str
        end
    end
end

Measured memory_bytes: 8560
#include <stdio.h>

int main() {

int A, B, C, D;

scanf("%d %d %d %d", &A, &B, &C, &D);

while (1) {
    C -= B;
    if (C <= 0) {
        printf("Yes\n");
        break;
    }
    A -= D;
    if (A <= 0) {
        printf("No\n");
        break;
    }
}

return 0;

}

Measured memory_bytes: 1664
#include <iostream>

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

bool binarySearch(int *S, int left, int right, int x) {
  if (right - left <= 1)
    return false;

  int mid = (left + right) / 2;
  if (S[mid] == x)
    return true;

  if (S[mid] > x)
    return binarySearch(S, left, mid, x);
  else
    return binarySearch(S, mid, right, x);
}

bool binarySearch2(int *S, int n, int x) {
  int left = -1;
  int right = n;

  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (S[mid] == x)
      return true;

    if (x < S[mid])
      right = mid;
    else
      left = mid;
  }

  return false;
}

int main() {
  int n, q;
  std::cin >> n;
  int S[n];
  rep(i, n) std::cin >> S[i];
  std::cin >> q;
  int T[q];
  rep(i, q) std::cin >> T[i];

  int cnt = 0;
  // rep(i, q) { cnt += binarySearch(S, 0, n, T[i]); }
  rep(i, q) { cnt += binarySearch2(S, n, T[i]); }

  std::cout << cnt << '\n';

  return 0;
}



Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
	int a,b,c,x,i,j,k,r=0;
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for(i=0;i<=x/500;i++)
	{
		for(j=0;j<=(x-500*i)/100;j++)
		{
			k=x-500*i-100*j;
			if(k%50==0&&c>=k/50&&a>=i&&b>=j)
			{
				r++;
			}
		}
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define pb push_back 
#define F first 
#define S second 
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 

using namespace std;

void test(){
	int n;
	cin>>n;
	vector<int> adj[n];
	f(i,n-1){
		int x;
		cin>>x;
		adj[x-1].pb(i+1);
	}
	f(i,n)cout<<adj[i].size()<<"\n";
}

int main(){
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}

Measured memory_bytes: 14504
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<ll, P>;
using PP = pair<P ,P>;
constexpr ll MOD = 998244353;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()
 
ll power(ll x, ll k){
    if(x == 0) return 0;
    ll res = 1;
    x %= MOD;
    while(k > 0){
        if(k & 1){
            res = res*x%MOD;
        }
        x = x*x%MOD;
        k >>= 1;
    }
    return res;
}


int main(){
    ll n, dmax = 0;
    cin >> n;
    vector<ll> d(n), cnt(n+1);
    for(int i=0;i<n;i++){
        cin >> d[i];
        cnt[d[i]]++;
        dmax = max(dmax, d[i]);
    }
    if(d[0] != 0 || cnt[0] != 1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for(int i=0;i<dmax;i++){
        ans *= power(cnt[i], cnt[i+1]);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long n = scanner.nextLong();

        for (long i = (int) Math.sqrt(n); i >= 2; i--) {
            if (n % i == 0) {
                System.out.println(Long.toString(n / i).length());
                return;
            }
        }

        System.out.println(Long.toString(n).length());
    }
}


Measured memory_bytes: 22996
#include <stdio.h>

int main()
{

  int n, m, i, a, sum=0;

  while(1){
    sum=0;
    scanf ("%d", &n);
    if( n == 0 ) break;
    a = n /4;
    for ( i = 1; i <=  a; i++ ){
      scanf("%d", &m);
      sum = sum + m;
    }
    printf("%d\n", sum);
  }
  
  return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int getValueWithTax(float value, float tax)
{
    int result = (int)(value * tax);
    return result;
}

int main()
{
    int A, B;

    cin >> A >> B;

    float ans = 1;

    while (getValueWithTax(ans, 0.08) != A || getValueWithTax(ans, 0.1) != B)
    {
        ans++;
        if (getValueWithTax(ans, 0.08) > A || getValueWithTax(ans, 0.1) > B)
        {
            ans = -1;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

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

struct coordinates{
	double x;
	double y;
};
typedef struct coordinates coordinates_t;

coordinates_t sub_vector( const coordinates_t &a, const coordinates_t &b)
{
	coordinates_t ret;
	ret.x = a.x - b.x;
	ret.y = a.y - b.y;
	return ret;
}


int main()
{
	
	coordinates_t A,B,C,P;
	while(cin >>A.x>>A.y>>B.x>>B.y>>C.x>>C.y>>P.x>>P.y){
		
		coordinates_t AB = sub_vector(B, A);
		coordinates_t BP = sub_vector(P, B);
		
		coordinates_t BC = sub_vector(C, B);
		coordinates_t CP = sub_vector(P, C);
		
		coordinates_t CA = sub_vector(A, C);
		coordinates_t AP = sub_vector(P, A);
		
		// 外積
		double c1 = AB.x*BP.y - AB.y*BP.x;
		double c2 = BC.x*CP.y - BC.y*CP.x;
		double c3 = CA.x*AP.y - CA.y*AP.x;
		
		if(( c1>0&&c2>0&&c3>0) || (c1<0&&c2<0&&c3<0)){
			cout <<"YES" <<endl;
		}else{
			cout <<"NO" <<endl;
		}
		
	}
	return 0;
}
	

Measured memory_bytes: 1216
import sys
N,K = map(int,input().split())
A = list(map(int,input().split()))
place_one = A.index(1)

if (N-1)%(K-1)!=0:
    print((N-1)//(K-1)+1)
    sys.exit()
else:
    print((N-1)//(K-1))
    sys.exit()


Measured memory_bytes: 13812
#include<stdlib.h>
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<cstring>
#include<time.h>
#include<queue>
using namespace std;
#define INF 10000000
int n,k,ct,ba,ch,t[101],h[101],tp/*太郎の枚数*/,hp,p;
void game(){
	int tr=0,hn=0;
	while(1){
		if(tr==n||hn==n||tp==0||hp==0){
			p=(p+1)%2;
			break;
		}
		if(p==0){
			for(;tr<n;tr++){
				if(t[tr]>ba){
					ba=t[tr];
					tp--;
					t[tr]=0;
					p=1;
					break;
				}
			}
		}else{
			for(;hn<n;hn++){
				if(h[hn]>ba){
					ba=h[hn];
					h[hn]=0;
					hp--;
					p=0;
					break;
				}
			}
		}
	}
}
int main(){
	while(1){
		cin>>n;
		tp=n;hp=n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>t[i];
		}
		sort(t,t+n);
		ct=0;ch=0;
		for(int i=1;i<=2*n;i++){
			if(i==t[ct]){
				ct++;
			}else{
				h[ch]=i;
				ch++;
			}
		}
		p=0;
		while(tp!=0&&hp!=0){
			ba=0;
			game();
		}
		cout<<hp<<endl;
		cout<<tp<<endl;
	}
	return 0;
}	

Measured memory_bytes: 1180
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <cstdio>
using namespace std;

#define ll long long
#define vecint vector<int>
#define listint list<int>
#define Pii pair<int, int>

#define REP(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define print(a) cout << a << endl

#define MOD 1000000007
#define NIL -1


int main(){
  int N;
  cin>>N;
  int ans=N*(N+1)/2;
  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec1(std::vector<string> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec2(std::vector<Int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}
void y(){
    cout<<"Yes"<<endl;
    exit(0);
}
void n(){
    cout<<"No"<<endl;
    exit(0);
}
void Y(){
    cout<<"YES"<<endl;
    exit(0);
}
void N(){
    cout<<"NO"<<endl;
    exit(0);
}
Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}
/*   kokomade  */

int cnt=0;
int main() {
    IOS;
    //prec;
    //std::ifstream in("01-04.txt");
    //std::cin.rdbuf(in.rdbuf());
    Int n,k;cin>>n>>k;
    vector<pair<int,int>> z;
    Int sum=0;
    for (int i = 0; i < n; ++i) {
        int a,b;cin>>a>>b;
        z.push_back(make_pair(a,b));
    }
    ssort(z);
    for (int i = 0; i < n; ++i) {
        int a,b;a=z[i].first;b=z[i].second;
        sum+=b;
        if(k<=sum){
            cout<<a;
            break;
        }
    }


    cout << endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


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

const int N = 2e3 + 10;

int n , x , y , ans[N];

int dis(int u , int v){
	return min(v - u , abs(x - u) + abs(y - v) + 1);
}

int main(){
	scanf("%d %d %d" , &n , &x , &y);
	for(int u = 1; u <= n; u++)
		for(int v = u + 1; v <= n; v++)
			ans[dis(u , v)]++;
	for(int i = 1; i < n; i++)
		printf("%d\n" , ans[i]);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int n,now,cnt;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&now);
        while(now%2==0)
        {
            now/=2;
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    int ans = 1;
    bool fl = true;
    for(int i = 1;i<s.size();i++){
        if(s[i-1]==s[i] && fl){
            ans++;
            if(i==s.size()-1) ans--;
            i++;
            fl = false;
        }
        else{
            ans++;
            fl = true;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	
    k := -1
	for i := 0; i < len(s); i++ {
      v,_ := strconv.Atoi(string(s[i]))
		if v == k {
			fmt.Println("Bad")
			return
		}
		k = v
	}
	fmt.Println("Good")
}

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

#define _USE_MATH_DEFINES

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 999999999;
const ll atcoder = 1000000007;
const int dx[4] = { 1 , 0 , -1 ,0 };
const int dy[4] = { 0 , 1 , 0 , -1 };

int main() {

	int a, b;

	cin >> a >> b;

	cout << a*a - b << endl;

	return 0;
}

Measured memory_bytes: 768
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	int data[7];

	while( cin >> n && n != 0 ){
		for( int i = 0;i < 7;i++ ) data[i] = 0;
		for( int i = 0;i < n;i++ ){
			int target;
			cin >> target;

			if( target >= 0 && target < 10 ) data[0]++;
			else if( target >= 10 && target < 20 ) data[1]++;
			else if( target >= 20 && target < 30 ) data[2]++;
			else if( target >= 30 && target < 40 ) data[3]++;
			else if( target >= 40 && target < 50 ) data[4]++;
			else if( target >= 50 && target < 60 ) data[5]++;
			else if( target >= 60 ) data[6]++;
		}
		for( int i = 0;i < 7;i++ ){
			cout << data[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        String[] s = S.split("");
        String[] t = T.split("");
        
        boolean hantei = false;
        StringBuilder ans = new StringBuilder();
        List<String> l = new ArrayList<>();
        for(int i=0; i<s.length-t.length+1; i++) {
            int x = 0;
            for(int j=i; j<i+t.length; j++) {
                if(s[j].equals(t[x]) || s[j].equals("?")) x++;
                else break;
            }
            if(x == t.length) {
                hantei = true;
                x = 0;
                for(int k=0; k<s.length; k++) {
                    if(k >= i && k < i+t.length) {
                        ans.append(t[x]); 
                        x++;
                    }else if(s[k].equals("?")) {
                        ans.append("a");
                    }else {
                        ans.append(s[k]);
                    }
                }
                l.add(String.valueOf(ans));
                ans = new StringBuilder();
            }
        }
        
        if(hantei) {
            Collections.sort(l);
            System.out.println(l.get(0));
        }else {
            System.out.println("UNRESTORABLE");
        }

    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
#include<array>
#define nguyendz the_best


#define ll long long
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define ff first
#define ss second
#define setpre(x) fixed<<setprecision(x)


using namespace std;
const ll maxn=1e6+100;
vector<ll> adj[maxn];
ll a[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (fopen("A.INP","r"))
    {
         freopen("A.INP","r",stdin);
        freopen("A.OUT","w", stdout);
    }
    string s;
    ll k;
    cin>> k>> s;
    ll n=s.length();
    if (n<=k)
    {
        cout <<s;
    }
    else
    {
        for (int i=0;i<k;i++)
        {
            cout <<s[i];
        }
        cout <<"..." ;
    }
}


Measured memory_bytes: 27092
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll x = n/(a+b); // bとrの完全ブロックがいくつ入るか
  ll y = n%(a+b); // bとrの半端なブロックにいくつボールがあるか
  cout << (x*a) + min(a, y) << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        int n = in.nextInt();
        int ma = in.nextInt();
        int mb = in.nextInt();

        int[][] dp = new int[401][401];
        for(int i=0;i<=400;i++){
            Arrays.fill(dp[i],Integer.MAX_VALUE);
        }
        dp[0][0] = 0;

        for(int i=0;i<n;i++){
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();

            for(int j=400-a;j>=0;j--){
                for(int k=400-b;k>=0;k--){
                    if(dp[j][k]!=Integer.MAX_VALUE){
                        dp[j+a][k+b] = Math.min(dp[j+a][k+b],dp[j][k]+c);
                    }
                }
            }
        }
        int mn = Integer.MAX_VALUE;
        for(int i=0;i<=400;i++){
            for(int j=0;j<=400;j++){
                if(dp[i][j]!=Integer.MAX_VALUE){
                    int g = gcd(i,j);
                    if(g == 0) continue;
                    if(i/g == ma && j/g == mb){
                        mn = Math.min(mn,dp[i][j]);
                    }
                }
            }
        }
        if(mn == Integer.MAX_VALUE) out.print(-1);
        else out.print(mn);
    }

    private int gcd(int a ,int b){
        if(b==0) return a;
        return gcd(b,a%b);
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

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


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


int main() {
	
	int N;
	cin >> N;
	int sum = 0;
	int m = N;
	for(int i=0; i<=9; i++){
		sum += N % 10;
		N /=10;
	}
	if(m % sum) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int a[100000] = { 0 };
int main() {
	int N;
	int sum = 0;
	int temp;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >>temp;
		temp <= N ? a[temp]++ : sum++;
	}
	for (int j = 1; j <= N; j++) sum+=a[j]>= j? a[j]-j:a[j];
	cout << sum;
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

const int N=1e5+100;
vi g[N];

int dfs(int v){
    vi kek;
    for(auto p:g[v]){
        kek.push_back(dfs(p));
    }
    sort(RALL(kek));
    int ans=0;
    for(int i=0;i<SZ(kek);i++){
        inmax(ans,kek[i]+i+1);
    }
    return ans;
}

void smain() {

    int n;
    cin>>n;
    for(int i=2;i<=n;i++){
        int a;
        cin>>a;
        g[a].push_back(i);
    }
    cout<<dfs(1);

}

Measured memory_bytes: 15104
n = int(input())
dat = list(map(int, input().split()))
buf = [0] * (10**5 + 100)
res = 0
for i in range(n):
    buf[dat[i]] += 1
    res += dat[i]
q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    res -= b * buf[b]
    res += c * buf[b]
    buf[c] += buf[b]
    buf[b] = 0
    print(res)


Measured memory_bytes: 84160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;
	while(cin >> n,n){
	vector<int> a(n);
	REP(i,n)cin >> a[i];
	sort(a.begin(),a.end());
	int min_ = 1e9;
	REP(i,n - 1)min_ = min(min_,abs(a[i] - a[i + 1]));
	cout << min_ << endl;
	}
  return 0;
}

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  long long a, b, x, h;
  cin >> a >> b >> x;
  if(a == 0){
    cout << b / x + 1 <<endl;
    return 0;
  }
  if(a < x){
    h = x;
  } else{
    if(a % x != 0){
     h = a + (x - a % x);
    } else {
      h = a;
    }
  }
  if(h > b){
    cout << 0 <<endl;
  } else{
    cout << (b - h) / x  + 1<<endl; 
  }
}


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

int main(){
  int n,p[20];
  cin>>n;
  for (int i(0);i<n;i++){
    cin>>p[i];
  }
  int cnt(0);
  for (int i(1);i<n-1;i++){
    vector <int>di(3);
    di[0]=p[i-1];
    di[1]=p[i];
    di[2]=p[i+1];
    sort(di.begin(),di.end());
    if(di[1]==p[i]&&di[2]!=p[i]){
      cnt+=1;
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

string s;
int v[30];

signed main(){
    cin>>s;
    int all = s.size()*(s.size()-1)/2;
    for(int i=0;i<s.size();++i)v[s[i]-'a']++;
    for(int i=0;i<s.size();++i){
        v[s[i]-'a']--;
        all-=v[s[i]-'a'];
    }
    cout<<all+1<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define M 1000000007
#define prdb(pranay) cout << fixed << setprecision(10) << pranay;
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    speed;
    ll k;
    cin >> k;
    ll i;
    for (i = 0; i < k; i++)
        cout << "ACL";
}


Measured memory_bytes: 3576
/* code by AbhiTaker
         ____
        /    \
       /  __  \              _______      __       _   _    _____    _____
      /  /  \  \            |__   __|    /  \     | | / /  |  ___|  |  _  \
     /  /____\  \     ___      | |      / /\ \    | |/ /   | |__    | |_)  )
    /  /______\  \   |___|     | |     / /__\ \   |   /    |  __|   |    _/
   /  /        \  \            | |    / /----\ \  | |\ \   | |___   | |\ \
  /__/          \__\           |_|   /_/      \_\ |_| \_\  |_____|  |_| \_\
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 2000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x,y;
    cin>>x>>y;
    if(x%y==0)
        cout<<"-1\n";
    else
        cout<<x<<"\n";

    return 0;
}


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

using namespace std;

int A[3], M[3];
long long int Count[3];

void calculation() {
	long long int ans;

	for (int index = 0; index < 3; index++) {
		ans = A[index] % M[index];
		while (ans != 1) {
			Count[index]++;
			ans = (A[index] * ans) % M[index];
		}
	}

}

long long int findLeastCommonMultiple(long long int a, long long int b) {
	long long int c, a1, b1;

	a1 = a;
	b1 = b;
	c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return (b1 / b) *a1;
}


int main() {

	while (1) {
		for (int i = 0; i < 3; i++) {
			cin >> A[i] >> M[i];
			Count[i] = 1;
		}
		if (A[0] == 0) {
			break;
		}

		calculation();
		cout << findLeastCommonMultiple(findLeastCommonMultiple(Count[0],Count[1]),Count[2]) << endl;
	}

	return 0;
}


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

using namespace std;
std::vector<int> v[100002];
int indegree[100002],visited[100002],n,dp[100002];
std::vector<int> topo;
void toposort()
{
	queue<int> qu;
	for (int i = 1; i <=n; ++i)
	{
		if(indegree[i]==0)
		{
			qu.push(i);
		}
	}
	while(!qu.empty())
	{
		int vertex=qu.front();
		qu.pop();
		topo.push_back(vertex);
		for (int i = 0; i <v[vertex].size() ; ++i)
		{
			indegree[v[vertex][i]]--;	
			if(indegree[v[vertex][i]]==0)
				qu.push(v[vertex][i]);
		}
	}
}
int main()
{
	int m;
	cin>>n>>m;
	for (int i = 1; i <= n; ++i)
	{
		indegree[i]=0;
		visited[i]=0;
		dp[i]=0;
	}
	for (int i = 0; i < m; ++i)
	{
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		indegree[b]++;
	}
	toposort();
	for (int i = 0; i < topo.size(); ++i)
	{
		for (int j=0; j < v[topo[i]].size(); ++j)
		{
			dp[v[topo[i]][j]]=max(dp[v[topo[i]][j]],dp[topo[i]]+1);
		}
	}
	int max=0;
	for (int i = 1; i <=n; ++i)
	{
		if(dp[i]>max)
		{
			max=dp[i];
		}
	}
	cout<<max<<'\n';
}

Measured memory_bytes: 7548
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int a=scan.nextInt();
    scan.nextLine();
    String s=scan.nextLine();
    if(a>=3200){
      System.out.println(s);
    }else{
      System.out.println("red");
    }
  }
}

Measured memory_bytes: 21716
n,l = gets.chomp.split(' ').map(&:to_i)

apples = []
n.times do |i|
  apples << l + (i+1) - 1
end

abs_apples = apples.map{|apple| apple.abs}
abs_min_index = abs_apples.index(abs_apples.min)

apples.delete_at(abs_min_index)
puts apples.inject(:+)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (int)(n); (i) += (step))
#define ROF(i, a, n, step) for (int (i) = (a); (i) >= (int)(n); (i) -= (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;

template <class T>
const bool is_impar(const T &x) {return (bool) (x & 1);}

string s;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    if (s[0] != 'A')
        return !(cout << "WA");
    int C = 0;
    if (s[0] == 'C' || s[1] == 'C' || s[sz(s) - 1] == 'C')
        return !(cout << "WA");
    FOR(i, 2, sz(s) - 1, 1)
        C += (s[i] == 'C');
    if (C != 1)
        return !(cout << "WA");
    FOR(i, 1, sz(s), 1)
        if ((s[i] < 'a' || s[i] > 'z') && s[i] != 'C')
            return !(cout << "WA");
    cout << "AC";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	int a, b, c, d; cin >>a >> b >> c >> d;
	int x, y;
	x = max(a, c);
	y = min(b, d);

	if (x < y) cout << y - x;
	else cout << 0;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
# ABC075 C - Bridge
def dfs(v):
    visited[v]=True
    for nv in range(n):
        if G[v][nv]==False:
            continue
        if visited[nv]:
            continue
        dfs(nv)

n,m = map(int,input().split())
G = [[False]*n for _ in range(n)]
ans = 0
visited = [False for _ in range(n)]
A,B = [],[]
for i in range(m):
    a,b = map(int,input().split())
    A.append(b-1)
    B.append(a-1)
    G[a-1][b-1]=G[b-1][a-1]=True

for i in range(m):
    G[A[i]][B[i]]=G[B[i]][A[i]]=False
    visited = [False for _ in range(n)]
    dfs(0)
    if all(visited):
        ans += 1
    G[A[i]][B[i]]=G[B[i]][A[i]]=True

print(m-ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

int n;
long long a[100010];
int main(){
  std::cin>>n;
  for(int i=0;i<n;++i)
    std::cin>>a[i];

  long long ans=1;
  int up=0;
  for(int i=0;i<n-1;++i){
    if(up==0){
      if(a[i]<a[i+1])
        up=1;
      else if(a[i]>a[i+1])
        up=-1;
    }
    else if(up>0){
      if(a[i]>a[i+1]){
        ++ans;
        up=0;
      }
    }
    else if(up<0){
      if(a[i]<a[i+1]){
        ++ans;
        up=0;
      }
    }
  }
  
  std::cout<<ans<<std::endl;
  return 0;
}


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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll long long int

int main()
{
    FAST;
    ll a,b,c=0,d=0,e;
    cin>>a>>b>>e;
    if (a%b==0)
    a=a/b;
	else
	a=a/b+1;
	cout<<a*e;
}


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

const ll mm = 1e9+7;


ll kai(ll a,ll b){
    ll ans =1;
    while(a>b){
        ans=(ans*a)%mm;
      
        a--;
    }
    return ans;
}


ll joyou(ll a,ll b){
    ll ans=1;
    while (b) {
        ans*=a;
        ans%=mm;
        b--;
    }
    return ans;
}

int main() {
    ll N;
    cin >> N;
    ll rid = (joyou(9, N)*2)%mm - joyou(8, N);
    if(rid<0)rid+=mm;
    ll ans = joyou(10, N)-rid;
    if(ans<0)ans+=mm;
    cout << ans%mm << endl;
    
    
}



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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)



signed main(){

	int A, B, C;
	cin >> A >> B >> C;

	int ans = 0;
	for (ans = 0; ans < 100; ans++){
		if (A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
			int a1 = (B + C) / 2;
			int b1 = (C + A) / 2;
			int c1 = (A + B) / 2;
			A = a1;
			B = b1;
			C = c1;
		}
		else
			break;
	}

	if (ans == 100) cout << "-1" << endl;
	else
		cout << ans << endl;

	return 0;
}


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

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

    bool flg = false;
    for (auto i = 0; i <= 25; i++) {
        for (auto j = 0; j < 15; j++) {
            int price = 4 * i + 7 * j;
            if(price == n) {
                flg = true;
                break;
            }
        }
    }

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

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

unsigned GetDigit(unsigned num){
    return log10(num)+1;
}
int main() {
  int N;
  cin >> N;
  int n = GetDigit(N);
  int a[n-1];
  for (int i = 0;i<n;i++){
    int x = pow(10,(n-i-1));
    a[i]=N/x;
    N = N % x;
 }
 if((a[0]==a[1] && a[1]==a[2]) 
    || (a[1]==a[2] && a[2]==a[3])){
 	cout << "Yes" << endl;
 }else{
 	cout << "No" << endl;
 }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)

int main(){
 
 
  ll n,a,b;
  cin>>n>>a>>b;
  ll sum=0;
  ll ans=0;
  ans+=n/(a+b)*a;
  if(n%(a+b)<=a){
      ans+=n%(a+b);
  }else{
      ans+=a;
  }
  cout<<ans<<endl;
  
  
  
  

  
  
 
}



Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
double dmax(double a,double b){
    return a>b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}

typedef struct tagNode{
    struct tagNode *next;
    
}Node;

void tansaku(int n){
    
}

int main(void){
    int i,n=in(),T=in(),c[n],t[n],cost=inf;
    rep(i,n){
        c[i]=in();
        t[i]=in();
        if(t[i]<=T&&c[i]<cost)cost=c[i];
    }
    if(cost==inf)printf("TLE\n");
    else print(cost);
    return 0;
}

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


void solve(long long A, long long B, long long K){
    ll i = min(A,B), j = 0;
    while(1){
        if(A%i==0 && B%i==0){
            j++;
            if(j==K)break;
        }
        i--;
    }
    std::cout << i << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


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

const int dy[]={-1,0,1,0},dx[]={0,-1,0,1};
int h,w;
char fld[20][20];
int lim;

void paint(int y,int x,char c,vector<int>&V){
    char tmp=fld[y][x];
    fld[y][x]=c;
    V.push_back(y*w+x);
    for(int d=0;d<4;d++){
        int ny=y+dy[d],nx=x+dx[d];
        if(ny<0||ny>=h||nx<0||nx>=w)continue;
        if(fld[ny][nx]==tmp)paint(ny,nx,c,V);
    }
}
bool dfs(int cnt){
    char c=fld[0][0];
    bool ok=1;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(fld[i][j]!=c)ok=0;
    if(ok)return 1;

    if(cnt>=lim)return 0;

    for(int i=0;i<3;i++)if(c!="RGB"[i]){
        vector<int>V;
        paint(0,0,"RGB"[i],V);
        if(dfs(cnt+1))return 1;
        for(int j=0;j<V.size();j++)fld[V[j]/w][V[j]%w]=c;
    }
    return 0;
}
int main(){
    while(cin>>w>>h,w||h){
        for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>fld[i][j];
        for(lim=0;;lim++)if(dfs(0))break;
        cout<<lim<<endl;
    }
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() {
  for (int i = 0; i < 3; i ++) {
    int h1, m1, s1, h2, m2, s2;
    cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
    int x = h2 * 60 * 60 + m2 * 60 + s2 - h1 * 60 * 60 - m1 * 60 - s1;
    cout << x / 3600;
    x %= 3600;
    cout << " " << x / 60;
    x %= 60;
    cout << " " << x;
    cout << endl;
  }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

void solve() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double t = h * 60 + m;
	int x = t;
	m = t * 6 - 360 * ((x * 6) / 360);
	h = t / 2 - 360 * ((x / 2) / 360);
	double al = min(abs(h - m), abs(m + 360 - h));
	//cout << al << endl;
	cout << fixed << setprecision(14) << sqrt(a * a + b * b - 2 * a * b * cos(al * (3.14159265358979323846 / 180)));
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1; 
    //cin >> T;
    while(T--) solve();
}

Measured memory_bytes: 4208