akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define th third
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()
#define elif else if


int inf=1000000007;

signed main(){
  string s;
  cin>>s;
  int k;
  cin>>k;
  char a='1';
  for(int i=0; i<min<int>(k,s.size()); i++){
    if(s[i]!='1'){
      a=s[i];
      break;
    }
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cmath>
#include <vector>
using namespace std;
typedef complex<double> c;
int main(){

  int m;
  double deg,ta1,ta2,tp;
  cin>>m;
  while(m){
    ta1=0;tp=360;
    for(int i=0;i<m-1;i++){
      cin>>deg;
      ta1+=sin(deg/180*3.14);
      tp-=deg;
    }
    ta1+=sin(tp/180*3.14);
    
   
    ta2=0;tp=360;
    cin>>m;
    for(int i=0;i<m-1;i++){
      cin>>deg;
      ta2+=sin(deg/180*3.14);
      tp-=deg;
    }
    ta2+=sin(tp/180*3.14);
    
    
    if(ta1>ta2) cout<<1<<endl;
    if(ta1<ta2) cout<<2<<endl;
    if(ta1==ta2) cout<<0<<endl;
    cin>>m;
  }
  return 0;
}

Measured memory_bytes: 1264
N,K=(int(x) for x in input().split())
# N,K=3,2
ans=0
for i in range(K,N+2):# i個選ぶ
    
    m=i*(i-1)/2
    M=N*(N+1)/2-(N-i)*(N-i+1)/2
    ans+=M-m+1
    # print("i,m,M",i,int(m),int(M))
print(int(ans%(1e9+7)))

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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  int a,b,c;
  cin >> a >> b >> c;
  if(a<=c&&c<=b) print("Yes");
  else print("No");
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        System.out.println( solve(H, W, N, A) );
    }

    private static String solve(int H, int W, int N, int[] A) {
        List<Integer> numbers = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int n = i + 1;
            int a = A[i];
            for (int j = 0; j < a; j++) {
                numbers.add(n);
            }
        }

        StringJoiner j = new StringJoiner("\n");
        for (int h = 0; h < H; h++) {
            int start = h * W;
            int end = h * W + W;
            List<Integer> line = new ArrayList<>(numbers.subList(start, end));
            if( h % 2 == 1 ) {
                Collections.reverse(line);
            }
            StringJoiner j2 = new StringJoiner(" ");
            line.forEach( i -> j2.add(i.toString()) );
            j.add( j2.toString() );
        }
        return j.toString();
    }
}


Measured memory_bytes: 34784
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

ll modfact(ll x){
  if(x==1) return 1;
  else return (x*modfact(x-1))%mod;
}

int main(){
  int N;
  cin>>N;
  vector<ll> a(N);
  ll sum=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    sum+=a[i];
  }

  ll x=a[0];
  ll ans=1e17;

  for(int i=1;i<N;i++){
    ans=min(ans,abs(sum-2*x));
    x+=a[i];
  }
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 1792
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
p.reverse()
q.sort()
q.reverse()
r.sort()

l = X+Y
lst = []
for i in range(X):
  lst.append(p[i])

for i in range(Y):
  lst.append(q[i])

for i in r:
  lst.append(i)

lst.sort()
lst.reverse()

ans = 0
for i in range(l):
  ans += lst[i]

print(ans)
  

Measured memory_bytes: 22560
/********************/
                    /*user -> tushar284*/
                    /******************/
#include<bits/stdc++.h>
                                                    /*********/            
using namespace std;                             /*   __   __   */
#define  f              first                    /*   @ ) ( @   */
#define  s              second                   /*     / \     */            
#define  mp             make_pair                /*  __  -  __  */
#define  loop(i,s,e)    for(int i=s;i<e;i++)     /*    ..^..    */
#define  rev(i,s,e)     for(int i=s;i>=e;i--)     /*     |     */
#define  mod            1000000007                  /*   |   */
#define  pb             push_back                      /***/
#define  start	        int main()                     
#define  fast           ios_base::sync_with_stdio(false);cin.tie(0);
#define  test           fast int t; cin>>t;while(t--)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;


start
{   
    ll x,bal = 100,year=0;
    cin>>x;
    
    while(bal<x){
        year++;
        ll in = bal/100;
        bal += in;  
    }
    cout<<year;
	return 0;
}


Measured memory_bytes: 3624
import sys

input = sys.stdin.readline


def main():
    A = list(map(int, input().split()))

    cost_1 = abs(A[1] - A[0]) + abs(A[2] - A[1])
    cost_2 = abs(A[2] - A[0]) + abs(A[1] - A[2])
    cost_3 = abs(A[0] - A[1]) + abs(A[2] - A[0])
    cost_4 = abs(A[2] - A[1]) + abs(A[0] - A[2])
    cost_5 = abs(A[0] - A[2]) + abs(A[1] - A[0])
    cost_6 = abs(A[1] - A[2]) + abs(A[0] - A[1])

    ans = min(cost_1, cost_2, cost_3, cost_4, cost_5, cost_6)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;
ll f(ll a,ll b){
    if(a>b)swap(a,b);
    int cnt=0;
    while(b>0){
        cnt++;
        b/=10;
    }
    return cnt;
    }
int main(void){
    ll n;
    cin>>n;
    int ans=INF;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
            int tmp=f(i,n/i);
            if(tmp<ans)ans=tmp;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int a,b,c;
int cnta=0,cntb=0,cntc=0;
signed main(){
    cin>>a>>b>>c;
    if(a==b&&b==c){
        if(a%2)cout<<0<<endl;
        else cout<<-1<<endl;
        return 0;
    }
    int sum=a+b+c;
    int x=a,y=b,z=c;
    while(x%2==0){
        int t=sum-x;
        if(x*2==t){
            cnta=INF;
            break;
        }
        x=t/2;
        cnta++;
    }
    while(y%2==0){
        int t=sum-y;
        if(y*2==t){
            cntb=INF;
            break;
        }
        y=t/2;
        cntb++;
    }
    while(z%2==0){
        int t=sum-z;
        if(z*2==t){
            cntc=INF;
            break;
        }
        z=t/2;
        cntc++;
    }
    int ans=min(cnta,cntb);
    ans=min(ans,cntc);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// abc125_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> V(N), C(N);
    REP(i, N) cin >> V[i];
    REP(i, N) cin >> C[i];

    int ans = 0;
    REP(i, N){
        ans += max(0, V[i] - C[i]);
    }
    print(ans);

    return 0;
}


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

char s[110];

int main() {
	int k;
	scanf("%d%s", &k, s+1);
	int len = strlen(s+1);
	if(len<=k)
		printf("%s\n", s+1);
	else {
		for(int i=1; i<=k; i++)
			printf("%c", s[i]);
		printf("...\n");
	}
	return 0;
}

Measured memory_bytes: 3688
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
bool b[30];

int main(){
	int i,j,k;
	int n;
	int a,c;
	char ca[50];
	cin>>ca;
	for(i=0;i<strlen(ca);i++){
		a=(int)ca[i]-(int)'a';
		b[a]=true;
	}
	n=strlen(ca);
	if(n!=26){
		for(i=0;i<26;i++){
			if(!b[i]){
				ca[n]='a'+i;
				ca[n+1]='\0';
				cout<<ca<<endl;
				return 0;
			}
		}
	}
	for(i=n-1;i>=0;i--){
		a=(int)ca[i]-(int)'a';
		for(j=a;j<26;j++){
			if(!b[j]){
				ca[i]='a'+j;
				ca[i+1]='\0';
				cout<<ca<<endl;
				return 0;
			}
		}
		b[a]=false;
	}
	cout<<-1<<endl;
	return 0;
}


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

const int N_MAX = 110;
const int W_MAX = 100010;

long long dp[N_MAX][W_MAX];

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

    int n, w;
    cin >> n >> w;
    vector<int> W(n);
    vector<long long> V(n);
    for(int i = 0; i < n; i++){
        cin >> W[i] >> V[i];
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            if(j - W[i] >= 0){
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - W[i]] + V[i]);
            }
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }

    cout << dp[n][w] << endl;

    return 0;
}

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

using namespace std;



int main () {

	int N, K;
	scanf("%d %d", &N, &K);

	vector<int> H(N);
	for (int &x : H) scanf("%d", &x);

	sort(H.rbegin(), H.rend());

	long long ans = 0;
	for (int i = K; i < N; ++i) {
		ans += H[i];
	}

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


	return 0;
}
 

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n+1),b(n);
    for(ll i=0;i<n+1;i++) cin >> a.at(i);
    for(ll i=0;i<n;i++) cin >> b.at(i);
    ll count = 0;
    for(int i=0;i<n;i++){
        if(a.at(i) > b.at(i)){
            count += b.at(i);
        }else{
            count += a.at(i);
            ll nokori = b.at(i) - a.at(i);
            if(a.at(i+1) < nokori){
                count += a.at(i+1);
                a.at(i+1) = 0;
            }else{
                count += nokori;
                a.at(i+1) -= nokori;
            }
        }
        //cout << count << endl;
    }
    cout << count << endl;
}

Measured memory_bytes: 4776
N = int(input())
status = []
for i in range(N):
    S = str(input())
    status.append(S)

print('AC x %d'% status.count("AC"))
print('WA x %d'% status.count('WA'))
print('TLE x %d'% status.count('TLE'))
print('RE x %d'% status.count('RE'))

Measured memory_bytes: 16248
import sys
readline = sys.stdin.readline
from collections import deque

def solve():
    N = int(readline())
    A = list(map(int, readline().split()))

    A.sort(reverse=True)

    q = deque()

    q.append(A[0])

    ans = 0
    for i in range(1, len(A)):
        v = q.popleft()
        ans += v
        q.append(A[i])
        q.append(A[i])

    print(ans)

solve()

Measured memory_bytes: 105040
#include <iostream>
#include<string>
using namespace std;
int main()
{
    int m,n;
    string s[50][50];
    cin>>n>>m;
    int num;
    char ans;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>s[i][j];
            if(s[i][j]=="snuke")
            {
                ans=char(65+j);
                num=i+1;
            }
        }
    }
    cout<<ans<<num;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>

int main(void) {
  int n;
  std::cin >> n;
  bool found = false;
  for (int i = 1; i <= 9; i++) {
    if (n % i == 0 && n / i >= 1 && n / i <= 9) {
      found = true;
    }
  }
  std::cout << (found ? "Yes" : "No") << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long h,w,ans=0x7fffffffffffffff,a,b,c;
int main(){
	cin>>h>>w;
	if(h%3==0||w%3==0){cout<<0<<endl;return 0;}
	for(long i=1;i<=h/2;i++){
		a=w*i;
		b=w/2*(h-i);
		c=h*w-a-b;
		ans=min(ans,max({a,b,c})-min({a,b,c}));
	}
	for(long i=1;i<=h/2;i++){
		a=w*i;
		b=(h-i)/2*w;
		c=h*w-a-b;
		ans=min(ans,max({a,b,c})-min({a,b,c}));
	}
	for(long i=1;i<=w/2;i++){
		a=h*i;
		b=h/2*(w-i);
		c=h*w-a-b;
		ans=min(ans,max({a,b,c})-min({a,b,c}));
	}
	for(long i=1;i<=w/2;i++){
		a=h*i;
		b=(w-i)/2*h;
		c=h*w-a-b;
		ans=min(ans,max({a,b,c})-min({a,b,c}));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

int main(){
   int n;
   cin>>n;
   
   vector<int> a(n);

   rep(i,n){
      cin>>a[i];
   }
   vector<ll> b(n);
   b[0]=0;
   ll ans=0;

   rep(i,n){
      if(i==0) continue;

      if(a[i]<a[i-1]){
          b[i]=abs((ll)a[i]-a[i-1]);
          ans+=(ll)b[i];
          a[i]=a[i]+b[i];
      }
   }

   cout<<ans;

   return 0;
}


Measured memory_bytes: 5564
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
ll dp[3][3333][3333];
ll n,m,k;
ll v[3333][3333];
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	cin>>n>>m>>k;
	rep(i,k)
	{
		ll a,b,c;
		cin>>a>>b>>c;
		v[a-1][b-1]=c;
	}
	memset(dp,0,sizeof(dp));
	rep(i,n)
	{
		rep(j,m)
		{
			dp[0][i][j]=max(dp[0][i][j],v[i][j]);
			dp[1][i][j]=max(dp[1][i][j],dp[0][i][j]);
			dp[2][i][j]=max(dp[2][i][j],dp[1][i][j]); 
			if(i>0)
			{
				dp[0][i][j]+=max(dp[0][i-1][j],max(dp[1][i-1][j],dp[2][i-1][j]));	
			}
			if(j>0)
			{
				dp[0][i][j]=max(dp[0][i][j],dp[0][i][j-1]); 
				dp[1][i][j]=max(dp[1][i][j-1],dp[0][i][j-1]+v[i][j]);
				dp[2][i][j]=max(dp[2][i][j-1],dp[1][i][j-1]+v[i][j]); 
			}
		}
	}
	cout<<max(dp[2][n-1][m-1],max(dp[1][n-1][m-1],dp[0][n-1][m-1]))<<endl;
	return 0;
}
 

Measured memory_bytes: 341892
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

N,M = map(int,input().split())

A = [[] for i in range(N)]

for i in range(N):
    A[i] = list(map(int,input().split()))

B = [[0]*1 for i in range(M)]

for i in range(M):
    B[i] = int(input())


for row in range(N):
    tmp = 0
    for col in range(M):
        tmp += A[row][col]*B[col]
    print("%d"%(tmp))



Measured memory_bytes: 5992
#include<bits/stdc++.h>//参考tourist
using namespace std;
string sl;
long long k;
int main(){
	cin >> sl >> k;
	long long l=sl.size();
	if(string(l,sl[0])==sl){
		cout<< l*k/2 << endl;
	}
	else{
		long long ans1=0;
		for(int i=0;i<l-1;i++){
			if(sl[i%l]==sl[(i+1)%l]){
				ans1++;
				i++;
			}
		}
		sl=sl+sl;
		long long n=l*2;
		long long ans2=0;
		for(int i=0;i<n-1;i++){
			if(sl[i%n]==sl[(i+1)%n]){
				ans2++;
				i++;
			}
		}
		printf("%lld\n",ans1+(ans2-ans1)*(k-1));	
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main(void){
    int a=0,b=0;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
      int x;
      cin>>x;
      if(x%2==1)a++;
      else if(x%4==0)b++;
  }
  if(a<=b||(a==b+1&&a+b==n))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
K=int(input())

def dfs(d,val,all):
    all.append(val)
    if d==10:
        return
    add=0
    for i in range(-1,2):
        add=(val%10)+i
        if 0<=add<=9:
            dfs(d+1,val*10+add,all)
all=[]
for i in range(1,10):
    dfs(0,i,all)
print(sorted(all)[K-1])

Measured memory_bytes: 100984
k = int(input())
cand = [[1,2,3,4,5,6,7,8,9]]
for i in range(9):
  tmp = []
  for val in cand[-1]:
    if val % 10 != 0:
      tmp.append(val*10 + (val%10 - 1))
    tmp.append(val*10 + (val % 10))
    if val % 10 != 9:
      tmp.append(val*10 + (val%10 + 1))
  cand.append(tmp)

ans = []
for j in range(len(cand)):
  for val in cand[j]:
    ans.append(val)
ans = sorted(ans)

print(ans[k - 1])


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

#define mp     make_pair
#define pb     push_back
#define all(v) v.begin(),v.end()

#define endl    "\n"
#define peek(x) cout<<#x<<" = "<<x<<"\n";
#define FAST    ios_base::sync_with_stdio(0);cin.tie(0);

typedef long long     ll;
typedef long double   ld;
typedef pair<int,int> ii;

const int    inf = 2e9;
const ll     INF = 4e17;
const int    mod = 1e9+7;
const double eps = 1e-9;

void solveA() {
	string s;
	cin >> s;
	int ans = 0, streak = 0;
	char prev;
	for(int i = 0; i < 4; i++) {
		if(i == 0) {prev = s[i]; continue;}
		if(prev == s[i]) streak++;
		ans = max(ans, streak);
		if(prev != s[i]) streak = 0, prev = s[i];
	}
	if(ans >= 2) cout << "Yes\n";
	else cout << "No\n";
}

void solveB() {
	int N;
	cin >> N;
	ll a = 2, b = 1;
	if(N == 0) {puts("2");return;}
	if(N == 1) {puts("1");return;}
	for(int i = 2; i <= N; i++) {
		ll tmp = a+b;
		a = b;
		b = tmp;
	}
	cout << b << endl;
}

int arr[4];
string res;
void f(int pos, int sum, string s) {
	if(pos >= 3) {
		if(sum == 7) res = s;
		return;
	}
	f(pos+1, sum+arr[pos+1], s+"+");
	f(pos+1, sum-arr[pos+1], s+"-");
}

void solveC() {
	string s;
	cin >> s;
	for(int i = 0; i < 4; i++) arr[i] = s[i]-'0';
	f(0,arr[0],"");
	f(0,-arr[0],"-");
	res += "=";
	if(res.size() == 4) for(int i = 0; i < 4; i++) cout << arr[i] << res[i];
	else{
		for(int i = 0; i < 4; i++) cout << res[i] << arr[i];
		cout << res[4];
	}
	cout << "7";

}
int n, m, c[10][10], dp[10], mat[210][210];
int opt(int x) {
	if(x == 1) return 0;
	if(dp[x] != -1) return dp[x];
	int ret = inf;
	for(int i = 0; i <= 9; i++) {
		if(i == x) continue;
		ret = min(ret, c[x][i] + opt(i));
	}
	return dp[x] = ret;
}

void solveD() {
	cin >> n >> m;
	for(int i = 0; i <= 9; i++) 
		for(int j = 0; j <= 9; j++) 
			cin >> c[i][j];
	memset(dp,-1,sizeof dp);
	for(int i = 0; i <= 9; i++) opt(i);
	for(int i = 0; i <= 9; i++) cout << dp[i] << " ";
	long long ans = 0;
	for(int i = 0; i < n; i++) { 
		for(int j = 0; j < m; j++) {
			cin >> mat[i][j];
			if(mat[i][j] == -1) continue;
			ans += dp[mat[i][j]];
		}
	}
	cout << ans << endl;
}

int main() {
	FAST
	//solveA();
	solveB();
	//solveC();
	//solveD();
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<vector>

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

using namespace std;

int f[128];

bool isAce11(const vector<char> &hand){
	int sc=0,acecnt=0;
	rep(i,hand.size()){
		sc+=f[hand[i]];
		if(hand[i]=='A')	acecnt++;
	}
	return (acecnt>0 && sc<=11);
}

int score(const vector<char> &hand){
	int sc=0,acecnt=0;
	rep(i,hand.size()){
		sc+=f[hand[i]];
		if(hand[i]=='A')	acecnt++;
	}
	if(acecnt>0 && sc<=11)	sc+=10;
	return sc;
}

int main(){
	f['A']=1;	f['2']=2;	f['3']=3;	f['4']=4;	f['5']=5;	f['6']=6;
	f['7']=7;	f['8']=8;	f['9']=9;	f['T']=10;	f['J']=10;	f['Q']=10;
	f['K']=10;

	int T;	scanf("%d",&T);
	while(T--){
		vector<char> hand(2);	scanf(" %c %c",&hand[0],&hand[1]);
		char card[8];
		rep(i,8)	scanf(" %c",card+i);
		int sc=score(hand);
		if(sc==21){ puts("blackjack"); continue; }
		for(int i=0;;i++){
			sc=score(hand);
			if(sc>21){ puts("bust"); break; }
			if(sc>17 || (!isAce11(hand) && sc==17)){ printf("%d\n",sc); break; }
			hand.pb(card[i]);
		}
	}

	return 0;
}

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

void Main()
{
    int n, k;
    cin >> n >> k;
    int d, a;
    vector<int> n_okashi(n+1); //i番目のすぬけ君が持っているお菓子の数
    for (int i = 0; i < k; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> a;
            n_okashi[a]++;
        }
    }
    int n_itazura = 0;
    for (int i = 0; i < n; i++)
    {
        if(n_okashi[i+1] == 0){
            n_itazura++;
        }
    }
    cout << n_itazura << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 3616
import java.util.*;
public class Main {
    public void solve() {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        for(int i=0;i<=B/K;i++){int C = K*i;
            if(A<=C && C<=B)
            {System.out.println("OK");return;}
        }System.out.println("NG");
    }
    public static void main(String[] args) {
        new Main().solve();
    }
    }

Measured memory_bytes: 35620
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class t>
using table = vector<vector<t>>;
const ld eps=1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.answer"
int main() {
	int N; cin >> N;
	long long int ans = 1;
	while (N) {
		ans *= N;
		N--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2988
#include <iostream>
using namespace std;
int main(){
    int n;
    int x;
    while(1){
        cin >> n >> x;
        if (n == 0&& x ==0) break;int a = 0;
        for(int i=1;i<=n;i++){
            for (int j = i+1; j<=n; j++) {
                for (int k = j+1;k<=n;k++){
                    if (i+j+k == x) a++;
                }
            }
        }
        cout << a << endl;
    }
    
}






Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(int i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w;cin>>h>>w;
  vector<vector<ll>>a(h,vector<ll>(w));
  auto b=a;
  rep(i,h)rep(j,w)cin>>a[i][j];
  rep(i,h)rep(j,w)cin>>b[i][j];
  const ll geta=80*160,sz=geta*2+7;
  vector<bitset<sz>>dp(w);
  auto tdp=dp;
  ll d=a[0][0]-b[0][0];
  tdp[0][geta-d]=1;
  tdp[0][geta+d]=1;
  rep(i,h){
    if(i!=0)rep(j,w)tdp[j]=0;
    rep(j,w){
      d=abs(a[i][j]-b[i][j]);
      if(i>0){
        tdp[j]|=dp[j]<<d;
        tdp[j]|=dp[j]>>d;
      }
      if(j>0){
        tdp[j]|=tdp[j-1]<<d;
        tdp[j]|=tdp[j-1]>>d;
      }
    }
    swap(dp,tdp);

  }
  ll res=1e9;
  rep(i,sz){
    if(dp[w-1][i])chmin(res,abs(i-geta));
  }
  cout<<res<<endl;


  return 0;

}


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

int main() {
  int N;
  cin >> N;
  int a[N],b[N];
  int count = 0;
  int s = 1;
  
  for(int i = 0; i < N; i++) {
    cin >> a[i];
    b[i] = 0;
  }
  b[0] =1;
  
  while(s != 2){
    s = a[s-1];
    if (b[s-1] == 0) b[s-1] = 1;
    else break;
    count++;
  }
  
  if (s==2) cout << count;
  else cout << -1;
  
  return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int v[MAXN];
ll dp[MAXN][5];

void add(int it, int ind1, int ind2, ll val) {
	dp[it + 1][ind2] = min(dp[it + 1][ind2], dp[it][ind1] + val);
}

void solve(){
	int n;
	scanf("%d", &n);
	ll sum = 0ll;
	REPN(i, 1, n) {
		scanf("%d", &v[i]);
		sum += v[i];
		/*if (v[i] != 0) {
			cout << i << " " << v[i] << endl;
		}*/
	}
	REP(i, 0, n) {
		int add_even, add_odd;
		if (v[i + 1] == 0) {
			add_even = 2, add_odd = 1;
		} else if (v[i + 1] % 2 == 1) {
			add_even = 1, add_odd = 0;
		} else {
			add_even = 0, add_odd = 1;
		}
		REP(j, 0, 5) {
			dp[i + 1][j] = LL_INF;
		}
		add(i, 0, 0, v[i + 1]);
		add(i, 0, 1, add_even);
		add(i, 0, 2, add_odd);
		add(i, 0, 3, add_even);
		
		add(i, 1, 1, add_even);
		add(i, 1, 2, add_odd);
		add(i, 1, 3, add_even);
		add(i, 1, 4, add_even);
		
		add(i, 2, 2, add_odd);
		add(i, 2, 3, add_even);
		add(i, 2, 4, add_even);
		
		add(i, 3, 3, add_even);
		add(i, 3, 4, add_even);
		
		add(i, 4, 4, v[i + 1]);
		
		REP(j, 1, 5) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i + 1][j - 1]);
		}
		
		/*REP(j, 0, 5) {
			printf("%lld ", dp[i + 1][j]);
		}
		putchar('\n');*/
	}
	ll ans = INF;
	cout << dp[n][4] << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 8832
//package ACL;
/*
Name       :  Md. Tanver Ahammed
Institution:  Mawlana Bhashani Science and Technology University(MBSTU)
Dept.      :  ICT
Language   :  JAVA
*/
//A Repeat ACL

import java.util.Scanner;

public class Main {
    private static void DisplayACL(int n){
        String st = "ACL";
        for (int i = 0; i < n-1; i++) {
            System.out.print(st);
        }
        if (n>0)
            System.out.println(st);
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            DisplayACL(scanner.nextInt());
        }
    }
}


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

int main() {
    string s;
    vector<pair<int, int>> d;
    cin >> s;
    char ch = s[0];
    int cnt = 1;
    for (int i=1; i<s.size(); ++i) {
        if (ch == s[i]) {
            cnt++;
        }
        else {
            d.emplace_back(cnt, ch);
            cnt = 1;
            ch = s[i];
        }
    }
    d.emplace_back(cnt, ch);

    vector<int> ans(s.size(), 0);
    int cur = 0;
    rep(i, d.size()) {
        int cnt = d[i].first;
        char ch = d[i].second;
        rep(x, cnt) {
            if (ch == 'R') {
                if (x%2 == 0) ans[cur + cnt - 1]++;
                else ans[cur + cnt]++;
            }
            else {
                if (x%2 == 0) ans[cur]++;
                else ans[cur-1]++;
            }
        }
        cur += cnt;
    }

    rep(i, s.size()) cout << ans[i] << " ";
    cout << endl;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 100010;

int nx[26][maxn * 2];

int main() {
	string s, t; cin >> s >> t;
	int n = s.size();
	s += s;

	rep(c, 26) nx[c][n * 2] = n * 2;

	for (int i = n * 2 - 1; i >= 0; --i) {
		rep(c, 26) nx[c][i] = nx[c][i+1];
		nx[s[i] - 'a'][i] = i;
	}

	ll p = 0;
	for (char c : t) {
		int pp = p % n;
		if (nx[c - 'a'][pp] == n * 2) {
			puts("-1");
			return 0;
		}
		p = nx[c - 'a'][pp] - pp + p + 1;
	}
	cout << p << endl;

	return 0;
}


Measured memory_bytes: 21120
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########
    

def main():
    N = i_inpl()
    G = defaultdict(dict)
    for _ in range(N-1):
        ai, bi, ci = l_inpl()
        ai, bi = ai-1, bi-1
        G[ai][bi] = ci
        G[bi][ai] = ci
    
    Q, K = l_inpl()
    K = K-1
    qlist = [l_inpl() for _ in range(Q)]

    cost = [INF] * N
    cost[K] = 0

    # dfs
    queue = deque([K])
    while queue:
        s = queue.pop()
        for t in G[s]:
            if cost[t] > cost[s] + G[s][t]:
                cost[t] = cost[s] + G[s][t]
                queue.append(t)
    
    for xi, yi in qlist:
        print(cost[xi-1]+cost[yi-1])


 
if __name__ == "__main__":
    main()


Measured memory_bytes: 82592
#include "bits/stdc++.h"
#include <queue>

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;



void solve() {
	ll h, w;
	cin >> h >> w;

	ll ans = 0;
	if (h == 1 && w == 1) {
		ans = 1;
	}
	else if (h == 1) {
		ans = w - 2;
	}
	else if (w == 1) {
		ans = h - 2;
	}
	else {
		ans = (h - 2) * (w - 2);
	}
	cout << ans << endl;
}


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

	solve(); 
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;

void Main()
{
	int N;
	std::cin >> N;
	std::multiset<int> maxes;
	int first;
	std::cin >> first;
	maxes.emplace(first);
	for (int i : boost::irange(1, N))
	{
		int a;
		std::cin >> a;
		auto ite = maxes.lower_bound(a);
		if (ite != maxes.cbegin())
		{
			--ite;
			maxes.erase(ite);
		}
		maxes.emplace(a);
	}
	std::cout << maxes.size() << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d.at(i);
  sort(d.begin(),d.end());
  long ans = 0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      int p = d.at(i) + d.at(j);
      int iter;
      if(p > d.at(n-1)) iter = n;
      else{
        iter = lower_bound(d.begin(),d.end(),p) - d.begin();
      }
      ans += (iter - j - 1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

nums = inputs[1]

# body
if $debugFlag
end

if nums.inject(:+) % 2 == 0
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 11532
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define N 10000

int cnt = 0;
int main()
{
    int n;
    int i,j;
    int A[N];

    scanf("%d",&n);
    if(n < 1 || n > N)exit(1);
    cnt = n;

    for(i = 0 ; i < n ; i++){
        scanf("%d",&A[i]);
	if(A[i] % 2 == 0 &&  A[i] != 2){
	  cnt--;
	  continue;
	}
	if(A[i] % 3 == 0 &&  A[i] != 3){
	  cnt--;
	  continue;
	}
        if(A[i] >= 2 && A[i] <= 100000000){
	  for(j = 5 ; j <= sqrt(A[i]) ; j = j + 2){
	    if(A[i] % j == 0 && A[i] != j){
	      cnt--;
	      break;
	    }
        }
	}
    }
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 2108
#include<iostream>
#include<cstdio>
#include<set>
#include<map>
#include<cstring>
using namespace std;
int main()
{  int a,i,b,k,n;
   cin>>a>>b>>k;
    n=b-a+1;
    if(2*k>=n)
    {
        for(i=a;i<=b;i++)
            cout<<i<<endl;
    }
    else {

        for(i=a;i<a+k;i++)
            cout<<i<<endl;

        for(i=b-k+1;i<=b;i++)
            cout<<i<<endl;

    }


    return 0;
}



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

#define ll long long

using namespace std;

const int N = 200000 + 10;
const int mod = 1e9 + 7;
ll n,k;

ll num[N];

int main()
{
	cin>>n>>k;
	for(int i=0; i<n; i++) scanf("%lld", &num[i]);
	sort(num, num+n);
	ll ans = 1;
	ll w = 1;
	int l = 0, r = n-1;
	if(k & 1) ans = num[r--],k--;
	if(ans < 0) w = -1;
	while(k)
	{
		ll x = num[l] * num[l+1];
		ll y = num[r] * num[r-1];
		if(x*w > y*w) ans = (ans * (x % mod)) % mod, l+=2;
		else ans = (ans * (y % mod)) % mod, r-=2;
		k-=2;
	}
	cout<<(ans % mod + mod)% mod;
	return 0;
}

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

const int maxn=2e5+10;
int a[maxn];
int b[maxn];

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    int n;
    cin>>n;
    for(int i=0;i<n;++i) scanf("%d",&a[i]);
    for(int i=0;i<n;++i) scanf("%d",&b[i]);
    int ans=0;
    for(int v=(1<<28);v;v>>=1){
        int tp=0;
        for(int i=0;i<n;++i){
            a[i]&=((v<<1)-1);
            b[i]&=((v<<1)-1);
        }
        sort(a,a+n);
        sort(b,b+n);
        for(int i=0;i<n;++i){//枚举a
            int v1=lower_bound(b,b+n,v-a[i])-b;
            int v2=lower_bound(b,b+n,2*v-a[i])-b;
            int v3=lower_bound(b,b+n,3*v-a[i])-b;
            tp+=v2-v1+n-v3;
            tp&=1;
        }
        if(tp) ans|=v;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1792
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int bb[1000000];

int
main(void){  
  ios_base::sync_with_stdio(false);

  //int n;
  string s;
  cin >> s;
  ll ans = 0LL;  
  ll cnt = 0LL;
  /*
  for(int i = s.size()-1; i > 0; i--){
    if(s[i] == 'W') cnt++;    
    cout << s[i-1] << " " << s[i] << " cnt: " << cnt  << endl;
    if( (s[i-1] == 'B') && (s[i] == 'W') ){
      ans += cnt;
      cnt = 0;
      s[i-1] = 'W';
      s[i] = 'B';
    }
  }
  */
  
  ll itr = 0;
  ll sum = 0LL;
  ll summ = 0LL;
  REP(i, s.size()){
    if(s[i] == 'B') {
      cnt++;
      bb[itr] = i;
      summ += i;
      itr++;
    }
  }

  //cout << summ << endl;
  
  for(int i = 0; i < cnt; i++){
    //cout << "should be at :" <<  s.size() - 1 - i << endl;
    sum += s.size()-1-i;
  }
  
  ans = sum - summ;
  
  //REP(i, itr) cout << bb[i] << endl;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1300
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//-------------------------------Template--Above------------------------------------------------
vector<ll> v[100001];
ll dp[100001];
ll n,m;
ll pre[100001],suf[100001];
ll dfs(ll ver,ll p)
{
	ll prod=1;
	for(ll i=0;i<v[ver].size();i++)
	{
		if(v[ver][i]!=p)
		{
			pre[v[ver][i]]=prod;
			prod=(prod*((dfs(v[ver][i],ver)+1)%m))%m;
		}
	}
	ll temp=1;
	for(ll i=v[ver].size()-1;i>=0;i--)
	{
		if(v[ver][i]!=p)
		{
			suf[v[ver][i]]=temp;
			temp=(temp*((dp[v[ver][i]]+1)%m))%m;
		}
	}
	dp[ver]=prod%m;
	//debug2(ver,dp[ver]);
	return prod%m;
}
void dfs2(ll ver,ll p,ll ppar)
{
	//debug2(ver,p);
	if(p!=-1)
	{
		dp[ver]=(dp[ver]*((((pre[ver]*suf[ver])%m)*ppar)%m+1)%m)%m;
	}
	for(ll i=0;i<v[ver].size();i++)
	{
		//debug2(ver,((((((pre[ver])%m)*((suf[ver])%m))%m))%m)*(ppar)%m+1);
		//debug2(pre[ver],suf[ver]);
		if(v[ver][i]!=p)
		{
			dfs2(v[ver][i],ver,((((((pre[ver])%m)*((suf[ver])%m))%m))%m)*(ppar)%m+1);
		}
	}
}
int main()
{
	boost
	cin>>n>>m;
	for(ll i=0;i<n-1;i++)
	{
		ll a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	dfs(1,-1);
	dfs2(1,-1,0);
	for(ll i=1;i<=n;i++)
	{
		cout<<dp[i]%m<<endl;
	}
	return 0;
}


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

ll comb[99][99];

int main(){
  comb[0][0] = 1;
  for(int i=1;i<=60;i++){
    comb[i][0] = comb[i][i] = 1;
    for(int j=1;j<i;j++)comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
  }

  ll n,m;
  while(cin >> n >> m, n){
    m--;
    int k = 0;
    while(comb[n][k]<=m)m -= comb[n][k++];

    string res = "";
    for(int i=0;i<n;i++){
      int rem = n-i-1;
      if(comb[rem][k]<=m){
	m -= comb[rem][k--];
	res += "1";
      }else res += "0";
    }
    cout << res << endl;
  }
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int s;
  cin >> s;

  auto f = [](int n) {
    if (n % 2 == 0) {
      return n / 2;
    } else {
      return 3 * n + 1;
    }
  };

  set<int> nums;
  nums.insert(s);
  int i = 1, prev_n = s, ans;
  while (true) {
    int n = f(prev_n);
    if (nums.count(n) > 0) {
      ans = i;
      break;
    }

    nums.insert(n);
    prev_n = n;
    i++;
  }

  cout << ans + 1 << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	#define xxx ios::sync_with_stdio(),cin.tie(0),cout.tie(0)
	#define rep(i,n) for(int i=0;i<n;i++)
	#define int long long
	int bp(int a, int b, int m) {
   		a %= m;
   		int res = 1;
    	while (b > 0) {
        	if (b & 1)
            	res = res * a % m;
       		a = a * a % m;
       	 	b >>= 1;
 	    }
    return res;
	}
	int max(int a, int b){
		return (a>b)?a:b;	
	}
	int csb( int n) 
{ 
    int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 
	int solve(int x){
		int r=0;
		while(x>0){
			int t=csb(x);
			x%=t;
			r++;
		}
		return r;
	}

	signed main(){
		int test=1;
		//cin>>test;
		while(test--){
			int n;
			cin>>n;
			int x=1;
			int nom=n-1;
			if(n==0) {cout<<"No"<<endl;}
			else while(true){
				if(x>sqrt(n)) {break;}
				if(n%x==0) {
					int t=n/x;
					if(t+x-2 < nom)  nom=t+x-2;
					
				}
				x++;
			}		
			cout<<nom<<endl;
		}
		return 0;
	}

Measured memory_bytes: 3596
#include<stdio.h>
int main(){
  int a,b,i,j,k=0,l=0,m=0,h;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    k=m=l=h=0;
    for(j=0;j<10;j++){
      scanf("%d",&b);
      if(k<b)k=b;
      else if(l<b){
	l=b;
	if(l>k){
	  m=l;
	  l=k;
	  k=m;
	}
      }else h=1;
    }
    if(h==0)printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 580