akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

struct DAYS
{
	int a,b,c,x,y,z;
};
typedef struct DAYS days;

int uruu(int year);/*うるう年を判定する関数*/
int pdays(int a,int b, int c, int x, int y, int z);/*a年b月c日からx年y月z日までの日数を取得する関数*/

int main()
{
	int i=0;
	int sp;
	int day[100];
	days data[100];
	while(1){
		scanf("%d %d %d %d %d %d",&data[i].a, &data[i].b, &data[i].c, &data[i].x, &data[i].y, &data[i].z);
		if(data[i].a<0 || data[i].b<0 || data[i].c<0 || data[i].x<0 || data[i].y<0 || data[i].z<0){
			break;
		}
		i++;
	}
	sp=i;
	for(i=0; i<sp; i++){
		day[i]=pdays(data[i].a, data[i].b, data[i].c, data[i].x, data[i].y, data[i].z);
	}
	for(i=0; i<sp; i++){
		printf("%d\n",day[i]);
	}
	return 0;
}

int pdays(int a,int b, int c, int x, int y, int z)
{	
	int i;
	int days=0;
	while(1){
		if(a==x&&b==y&&c==z){
			break;
		};
		if(b==12){
			if(c==31){
				b=1;
				a++;
				c=0;
			}
		}
		if(b==4||b==6||b==9||b==11){
			if(c==30){
				c=0;
				b++;
			}
		}
		else if(b!=2&&b!=12){
			if(c==31){
				c=0;
				b++;
			}
		}
		if(b==2){
			if(uruu(a)){
				if(c==29){
					c=0;
					b++;
				}
			}
			else{
				if(c==28){
					c=0;
					b++;
				}
			}
		}
		c++;
		days++;
	}
	return days;
}

int uruu(int year)
{
	int result;
	if(year%400==0){
		result=1;
	}
	else if(year%100==0){
		result=0;
	}
	else if(year%4==0){
		result=1;
	}
	else{
		result=0;
	}
	return result;
}

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

typedef long long ll;

const int N = 1e2+5 , M = 1e5+5 , MOD = 1e9+7;;

int n , k;
ll A[N] , sum[N] , bit[N][M] , dp[N][M];

void add(int x , int y , int val){
  for(int i = y ; i < M  ; i+=i&-i) bit[x][i] = (bit[x][i]+val)%MOD;
}

ll query(int x , int y){
  ll r = 0;
  for(int i = y ; i > 0 ; i-=i&-i) r = (r+bit[x][i])%MOD;
  return r;
}

int main(){

  ios_base::sync_with_stdio(0),cin.tie(0);

  cin >> n >> k;

  for(int i = 1 ; i <= n ; i++){cin >> A[i]; sum[i] = (sum[i-1]+A[i])%MOD;}

  for(int i = 0 ; i <= n ; i++) dp[i][0] = 1;

  for(int i = 1 ; i <= n ; i++)
    for(int j = 1 ; j <= min(sum[i],(ll)k) ; j++){
      dp[i][j] = ((query(i-1,j)-query(i-1,max((ll)0,j-A[i]-1))+MOD)%MOD + (A[i] >= j))%MOD;
      //cout << query(i-1,j)-query(i-1,max((ll)0,j-A[i]-1)) << " " << (A[i] >= j) << "\n";
      //cout << i << " " << j << ": " << dp[i][j] << "\n";;
      add(i,j,dp[i][j]); 
    }

  cout << dp[n][k] << "\n";

}


Measured memory_bytes: 159824
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
edge=[[] for i in range(n)]
for i in range(m):
  x,y,z=map(int,input().split())
  edge[x-1].append([z,y-1])
  edge[y-1].append([z,x-1])
for i in range(1,n):
  edge[i].append([0,i-1])

import heapq
def dijkstra_heap(s):
  d=[float("inf")]*n
  used=[True]*n 
  d[s]=0
  used[s]=False
  edgelist=[]
  for e in edge[s]:
    heapq.heappush(edgelist,e)
  while len(edgelist):
    minedge=heapq.heappop(edgelist)
    if not used[minedge[1]]:
      continue
    v=minedge[1]
    d[v]=minedge[0]
    used[v]=False
    for e in edge[v]:
      if used[e[1]]:
        heapq.heappush(edgelist,[e[0]+d[v],e[1]])
  return d

x=dijkstra_heap(0)[n-1]
if x==float("inf"):
  print(-1)
else:
  print(x)

Measured memory_bytes: 100704
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
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; }

int main()
{
  int N;
  cin >> N;
  if((N%10==7)||(N/10%10==7)||(N/100==7)){
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  string S, T;
  cin >> S >> T;
  queue<int> s, t;
  for(int i = 0; i < S.size(); i++){
    s.push(S.at(i));
  }
  for(int i = 0; i < T.size(); i++){
    t.push(T.at(i));
  }
  bool flag = false;
  for(int i = 0; i < S.size(); i++){
    if(s == t){
      flag = true;
      break;
    }
    else{
      s.push(s.front());
      s.pop();
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int L, R;
    cin >> L >> R;
    int ans = 1e15;
    FOR(i, L, min(R + 1, L + 2020)) {
        FOR(j, i + 1, min(R + 1, L + 2020)) {
            // 2019でループし、0は含めると最小になる
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main()
{
	int n, number,k,num;
	char kind;
	bool cards[4][13];
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			cards[i][j] = false;
		}
	}
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> kind >> number;
		if (kind == 'S') k = 0;
		else if (kind == 'H') k = 1;
		else if (kind == 'C') k = 2;
		else if (kind == 'D') k = 3;
		num = number - 1;
		cards[k][num] = true;
	}
	
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (cards[i][j] == false) {
				if (i == 0) cout << "S " << (j + 1) << endl;
				else if (i == 1) cout << "H " << (j + 1) << endl;
				else if (i == 2) cout << "C " << (j + 1) << endl;
				else cout << "D " << (j + 1) << endl;
			}
		}
	}
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define MOD 1000000007
#define PI acos(-1)
int main()
{
	IOS
  int n;
  cin>>n;
   int a[n];
   int i;
   for(i=0;i<n;i++)
   cin>>a[i];
   vector<int> dp(n,INT_MAX);
   dp[1]=abs(a[0]-a[1]);
   dp[0]=0;
   for(i=2;i<n;i++)
   {
   	dp[i]=min(dp[i],dp[i-1]+abs(a[i-1]-a[i]));
   	dp[i]=min(dp[i],dp[i-2]+abs(a[i-2]-a[i]));
	   }	
	   cout<<dp[n-1];
	   return 0;
}

Measured memory_bytes: 1024
a = int(input())+1
b = int(input())+1
c = int(input())+1
x = int(input())

counter = 0

for _a in range(a):
    for _b in range(b):
        for _c in range(c):
            ans = 500*_a + 100*_b + 50*_c
            if ans == x:
                counter += 1

print(counter)

Measured memory_bytes: 3188
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
          cin >> a[i];
    }
    long ans = 0;
    for(int i = 1;i < n;i++){
          if(a[i - 1] > a[i]){
                ans += a[i - 1] - a[i];
                a[i] = a[i - 1];
          }
    }
    cout << ans << endl;
}


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

long long dp[100100];
int n,l;
int a[100100];

long long rec(int p){
  if(0<=dp[p])return dp[p];

  if(a[p-1] < a[p] && a[p] < a[p]){
    return dp[p] = l-a[p];
  }

  long long tmp = 0;
  if(a[p]<a[p-1])tmp = max(tmp,dp[p-1]);
  if(a[p]<a[p+1])tmp = max(tmp,rec(p+1));
  return dp[p]= l-a[p] + tmp;
}
  
int main(){
  long long ans;
  cin >> n >> l;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    dp[i] = -1;
  }
  a[0] = a[n+1] = dp[0] = dp[n+1] = 0;

  ans = 0;
  for(int i=1;i<=n;i++)ans = max(ans,rec(i));

  cout << ans << endl;
}

Measured memory_bytes: 1992
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;



int main(){
  int N;
  cin >> N;
  int A;
  for (int i = 0; i < N; ++i) {
    cin >> A;
    if (A%2==0) {
      if (A%3!=0 && A%5!=0) {
        std::cout << "DENIED" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "APPROVED" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
using namespace std;
map <int ,int> mpa,mpb;
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a, int b){
  return a<b?a:b;
}

int main(){
  int elaps=0;
  int i,q,c;
  P u;
  scanf("%d %d", &n,&q);

  for(int i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head =1, tail=1+n;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0)enqueue(u);
    else{
      printf("%s %d\n", &u.name,elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 13240
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func readStringIntArray(rd *bufio.Reader, n int) ([]int, error) {
	nums := make([]int, 0, n)
	s, _, err := rd.ReadLine()
	if err != nil {
		return nums, err
	}

	arr := strings.Split(string(s), " ")
	for _, i := range arr {
		n, err := strconv.Atoi(i)
		if err != nil {
			return nums, err
		}
		nums = append(nums, n)
	}
	return nums, nil
}

func main() {
	rd := bufio.NewReader(os.Stdin)
	nums, err := readStringIntArray(rd, 2)
	if err != nil {
		return
	}

	m, n := nums[0], nums[1]
	a := make([][]int, m)
	b := make([]int, n)

	for i := 0; i < m; i++ {
		arr, _ := readStringIntArray(rd, n)
		a[i] = arr
	}
	for i := 0; i < n; i++ {
		arr, _ := readStringIntArray(rd, 1)
		b[i] = arr[0]
	}

	result := make([]int, m)
	for i := 0; i < m; i++ {
		for j := 0; j < n; j++ {
			result[i] += a[i][j] * b[j]
		}
		fmt.Println(result[i])
	}
}




Measured memory_bytes: 1412
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) return false;
	}
	return n != 1;  // 1の場合は例外
}

int main() {
	int Q; cin >> Q;
	vector<int> r(Q), l(Q);
	for(int i=0; i<Q; i++) cin >> r[i] >> l[i];

	vector<int> s(100001);
	s[0] = 0;
	for (int i = 1; i <= 100000; i++) {
		if (i % 2 == 0) {
			s[i] = s[i-1];
			continue;
		}
		if (is_prime(i) && is_prime((i + 1) / 2)) {
			s[i] = s[i-1]+1;
		}
		else {
			s[i] = s[i-1];
		}
	}

	for (int i = 0; i < Q; i++) {
		cout << s[l[i]] - s[r[i]-1] << endl;
	}

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define NL cerr << endl;
#define chmax(a, b) a=(((a)<(b))?(b):(a))
#define chmin(a, b) a=(((a)>(b))?(b):(a))
#define F first
#define S second
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const P<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T> ostream& operator << (ostream& s, const set<T>& st) {
   s << "{";
   for (auto i = st.begin(); i != st.end(); ++i) {
      s << *i;
      if (next(i) != st.end()) s << ", ";
   }
   s << "}";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

signed main()
{
   int N, M; cin >> N >> M;
   V<V<int>> p(N, V<int>(3));
   REP(i, N) {
      cin >> p[i][0] >> p[i][1] >> p[i][2];
   }

   V<V<int>> val(1<<3, V<int>(N));
   // val[s][i]: the value of the i-th cake, when the final state is s
   REP(s, 1<<3) {
      REP(i, N) {
         REP(k, 3) {
            if (s >> k & 1) val[s][i] += -p[i][k];
            else            val[s][i] +=  p[i][k];
         }
      }
      RSORT(val[s]);
   }

   int ans = -INF;
   REP(s, 1<<3) {
      int sum = 0;
      REP(i, M) {
         sum += val[s][i];
      }
      chmax(ans, sum);
   }
   cout << ans << endl;
   DUMP(ans)

   return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " -> " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" -> ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    map<int, pii> mp;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a + i].fi++;
        mp[i - a].se++;
    }
    ll ans = 0;
    for(auto p : mp) {
        ans += 1LL * p.se.se * p.se.fi;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 26228
#include<stdio.h>
#include<stdlib.h>

long func(long h);

int main(){
  long h, n_attack;
  
  scanf("%ld", &h);
  
  n_attack = func(h);
  
  printf("%ld", n_attack);
}

long func(long h){
  if(h == 1){
    return 1;
  }
  
  return 2*func(h/2)+1;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const double eps = 1e-8;

inline int dcmp(double x){if(-eps<x && x<eps)return 0;return x>0?1:-1;}

struct points
{
	double x,y;
	points(double _x=0,double _y=0){x=_x,y=_y;}

	inline friend points operator + (points a,points b){return points(a.x+b.x,a.y+b.y);}
	inline friend points operator - (points a,points b){return points(a.x-b.x,a.y-b.y);}
	inline friend points operator * (points a,double b){return points(a.x*b,a.y*b);}
	inline friend points operator / (points a,double b){return points(a.x/b,a.y/b);}

	inline friend int operator == (points a,points b){return dcmp(a.x-b.x)==0 && dcmp(a.y-b.y)==0;}

	void takein(){x=ty(),y=ty();}
	void print(char ends='\n'){printf("%.12lf %.12lf",x,y),putchar(ends);}
};

inline double dox(points a,points b){return a.x*b.x+a.y*b.y;}
inline double cox(points a,points b){return a.x*b.y-a.y*b.x;}
inline double length(points a){return sqrt(dox(a,a));}
inline double distan(points a,points b){return length(a-b);}

inline points pervec(points a){if(dcmp(length(a))<=0)return points(0,0);return a/length(a);}

inline int isponl(points p,points a,points b)
{
	return dcmp(cox(p-a,p-b))==0 && distan(a,p)<=distan(a,b) && distan(b,p)<=distan(a,b);
}

inline int iscrashed(points al,points ar,points bl,points br)
{
	double amix=min(al.x,ar.x),amxx=max(al.x,ar.x),amiy=min(al.y,ar.y),amxy=max(al.y,ar.y);
	double bmix=min(bl.x,br.x),bmxx=max(bl.x,br.x),bmiy=min(bl.y,br.y),bmxy=max(bl.y,br.y);
	
	if(amxx<bmix || bmxx<amix || amxy<bmiy || bmxy<amiy)return 0;
	if(isponl(al,bl,br) || isponl(ar,bl,br) || isponl(bl,al,ar) || isponl(br,al,ar))return 1;

	if(dcmp(cox(al-bl,br-bl))!=dcmp(cox(ar-bl,br-bl))
		&& dcmp(cox(bl-al,ar-al))!=dcmp(cox(br-al,ar-al)))return 1;
	return 0;
}

inline points crash(points al,points ar,points bl,points br)
{
	points a=ar-al,b=br-bl;
	double bas=cox(al-bl,b)/cox(b,a);
	return al+a*bas;
}

inline points ortho(points p,points a,points b)
{
	points c=a+pervec(b-a);
	double dis=dox(p-a,c-a);
	points tar=a+(c-a)*dis;
	return tar;
}

inline double distanpl(points p,points a,points b)
{
	if(isponl(p,a,b))return 0;
	points ort=ortho(p,a,b);
	if(isponl(ort,a,b))return distan(p,ort);
	return min(distan(p,a),distan(p,b));
}

const int _ = 107;

int n;
points p[_];

int main()
{
	n=ty();
	for(int i=1;i<=n;i++)p[i].takein();
	p[0]=p[n],p[n+1]=p[1];

	double ans=0;
	for(int i=1;i<=n;i++)ans+=cox(p[i+1],p[i]);
	printf("%.1lf\n",fabs(ans)/2);
	
	return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define bfl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(ll i=0;i<n;i++)
#define bf(i,n)    for(ll i=n-1;i>=0;i--)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < ll ,ll ,ll > > ;
// #define vector< ll ,ll > pv;
// vector< pair <ll,ll> > vect;


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

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

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

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

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

// ll n;cin>>n;ll a[n];for(ll i=0;i<n;i++)cin>>a[i];    
// for(ll i=0;i<n;i++)cout<<a[i];
// ll a,b;cin>>a>>b;   

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

// vector< tuple < ll ,ll ,ll > > tv;
// vector< ll ,ll > pv;


//----------------------------------------------------------------------------
const ll N=1e7+5;
std::vector <ll> prime;
ll is_composite[N];

void sieve ( )
{
//	std::fill (is_composite, is_composite + n, false);
	for (ll i = 2; i < N; ++i)
	{
	//	if (is_composite[i]==0) prime.push_back (i);
		for (ll j = 2; i * j < N; ++j)
			is_composite[i * j]++;
	}
	fl(i,1,N)
	{
	    is_composite[i]++;is_composite[i]++;
	    is_composite[i]=is_composite[i-1]+(is_composite[i]*i);
	}
	
}


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	ll tt=1;
   // cin>>tt;
   sieve();
	while(tt--)
	{
	    ll n;
	    cin>>n;
	    cout<<(is_composite[n]-1)<<bn;
	   
	   
	   
	    
	}
	
	return 0;
}


Measured memory_bytes: 81768
#include <iostream>
using namespace std;
int main()
{
	int N;

	cin >> N;
	for (int i = 0; i < 3; i++) {
		if (N % 10 == 7) {
			cout << "Yes";
			return 0;
		}
		else {
			N=N / 10;
		}
		
	}
	
	cout << "No";
	return 0;





}



Measured memory_bytes: 3632
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

pub fn gcd<T: PrimInt>(a: T, b: T) -> T {
    if b == zero() {
        a
    } else {
        gcd(b, a % b)
    }
}
pub fn gcd_list<T: PrimInt>(vec: Vec<T>) -> T {
    assert!(vec.len() > 1);
    vec.iter().fold(vec[0], |acc, x| gcd(*x, acc))
}

fn _make_sieve<T: PrimInt>(mut maxu: usize) -> Vec<T> {
    maxu += 1;
    let mut sieve: Vec<T> = (0..maxu).map(|x| T::from(x).unwrap()).collect();

    let mut i = 2;
    while i*i < maxu {
        if sieve[i].to_usize().unwrap() < i { i+=1; continue; }
        for j in (i*i..maxu).step_by(i) {
            if sieve[j].to_usize().unwrap() == j { sieve[j] = T::from(i).unwrap() }
        }
        i += 1;
    }

    sieve
}

#[derive(Debug, Clone)]
pub struct OsaK<T: PrimInt + std::hash::Hash + NumAssign > {
    sieve: Vec<T>
}

impl<T: PrimInt + std::hash::Hash + NumAssign > OsaK<T> {
    pub fn new(max: T) -> Self {
        let maxu = max.to_usize().unwrap();
        let sieve = _make_sieve(maxu);

        Self { sieve }
    }

    pub fn from(vec: &Vec<T>) -> Self {
        let max = vec.iter().max().unwrap();
        let maxu = max.to_usize().unwrap();
        let sieve = _make_sieve(maxu);
        
        Self { sieve }
    }

    pub fn is_prime(&self, x: T) -> bool {
        if x == one() { return false }
        self.sieve[x.to_usize().unwrap()] == x
    } 

    pub fn prime_factorize(&self, mut n: T) -> std::collections::HashMap<T, T> {
        let mut res: std::collections::HashMap<T, T> = std::collections::HashMap::new();
        while n > one() {
            *res.entry(self.sieve[n.to_usize().unwrap()]).or_insert(zero()) += one();
            n /= self.sieve[n.to_usize().unwrap()]
        }
        res
    }
}

#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
        a_vec: [usize; n]
    }

    let osa_k: OsaK<usize> = OsaK::from(&a_vec);

    let mut prime_count: HashMap<usize, usize> = HashMap::new();
    for &a in a_vec.iter() {
        let prime_factors = osa_k.prime_factorize(a);
        // dbg!(&prime_factors);
        for k in prime_factors.keys() {
            *prime_count.entry(*k).or_insert(0) += 1;
        }
    }

    if prime_count.values().all(|x| *x == 1) {
        println!("pairwise coprime");
    } else if gcd_list(a_vec) == 1 {
        println!("setwise coprime");
    } else {
        println!("not coprime")
    }
    
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 27804
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100010;
int n,m;
int a[N];
long long ans=0ll,anss=0ll,sum=0ll;
int main()
{
	scanf("%d%d",&n,&m);
	for(int k=1;k<=n;k++)
	{
		scanf("%d",&a[k]);
		if(a[k]>0) ans+=a[k];
		if(a[k]<0) anss+=a[k];
		sum+=a[k];
	}
	long long x=0ll,y=0ll;
	for(int k=1;k<=m;k++)
	{
		if(a[k]>0) x+=a[k];
		else y+=a[k];
	}
	long long min1=x,min2=y;
	int u=m,v=m;
	for(int k=m+1;k<=n;k++)
	{
		if(a[k]>0) x+=a[k];
		else y+=a[k];
		if(a[k-m]>0)x-=a[k-m];
		else y-=a[k-m];
		if(x<min1)
		{
			min1=x;
			u=k;	
		}
		if(y>min2)
		{
			min2=y;
			v=k;
		}
	}
	for(int k=u;k>u-m;k--)
		if(a[k]>0)
			ans-=a[k];
	for(int k=v;k>v-m;k--)
		if(a[k]<0)
			anss-=a[k];
	printf("%lld",max(ans,sum-anss));
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int n,flag=0;
  cin >> n;
  
  for(int i=0;i<3;i++){
    if(n%10==7){
      cout << "Yes" << endl;
      break;
    }
    else{
      flag++;
    }
    n/=10;
  }
  if(flag==3) cout << "No" << endl;
}

Measured memory_bytes: 3612
import queue
q=queue.Queue()
N=int(input())
searched=set()
info=list()
edges={}
dict={}

for i in range(N):
    edges[i]=[]

for i in range(N-1):
    u,v,w=list(map(int,input().split()))
    edges[u-1].append([v-1,w])
    edges[v-1].append([u-1,w])

dict[0]=0

q.put(0)

while not q.empty():
    a=q.get()
    if a in searched:
        continue

    tmplist=edges[a]
    for l in tmplist:
        if l[0] not in searched:
            v,w=l
            q.put(v)
            if w%2==0:
                dict[v]=dict[a]
            else:
                dict[v]=(dict[a]+1)%2
    searched.add(a)


di=sorted(dict.items(), key=lambda x:x[0])

for d in di:
    print(d[1])


Measured memory_bytes: 72156
import numpy as np
import collections
n = int(input())
A = np.array(list(map(int,input().split())))
B = np.array([i+1 for i in range(n)])
C,D = A+B,B-A
ans = 0

c = collections.Counter(C)
d = collections.Counter(D)
ans = 0
for i in c.keys():
    ans += c[i]*d[i]
print(ans)


Measured memory_bytes: 75124
import itertools
N,M,Q=map(int,input().split())
a=[0]*Q
b=[0]*Q
c=[0]*Q
d=[0]*Q

for i in range(Q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
    a[i]-=1
    b[i]-=1

ans=0
for seq in itertools.combinations_with_replacement(range(M),N):
    tmp=0
    for i in range(Q):
        if seq[b[i]]-seq[a[i]]==c[i]:
            tmp+=d[i]
    ans=max(ans,tmp)

print(ans)


Measured memory_bytes: 9048
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 縦K、横2*Kの長方形に全ての希望をWとして入れる
# numpyの累積和、最後にmaxをとる
N, K = lr()
table = [[0] * 2*K for _ in range(K)]
for _ in range(N):
    x, y, c = sr().split()
    x = int(x); y = int(y)
    if c == 'B':
        x -= K  # ここで全てWとして扱える
    x %= 2 * K; y %= 2 * K
    if x >= K and y >= K:
        x -= K; y -= K
    elif y >= K:
        x += K; y -= K
    # 長方形に入った
    table[y][x] += 1

table = np.array(table, dtype=np.int32)
table = np.concatenate([table, table], axis=1)
table2 = np.roll(table, K, axis=1)
table = np.concatenate([table, table2], axis=0)
table_cum = table.cumsum(axis=1).cumsum(axis=0)
prev = table_cum.copy()
table_cum[:, K:] -= prev[:, :-K]
table_cum[K:, :] -= prev[:-K, :]
table_cum[K:, K:] += prev[:-K, :-K]
answer = table_cum.max()
print(answer)


Measured memory_bytes: 196552
while True:
    m,f,r=map(int,input().split())
    sum_b = m + f
    sum_n = m + f + r
    if sum_n == -3:
        break
    elif m == -1 or f == -1:
        print('F')
    elif sum_b >= 80:
        print('A')
    elif sum_b >= 65 and sum_b < 80:
        print('B')
    elif sum_b >= 50 and sum_b < 65:
        print('C')
    elif sum_b >= 30 and sum_b < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    elif sum_b < 30:
        print('F')


Measured memory_bytes: 5592
// ITP1_4

import java.util.Scanner;
import java.io.*;

class Main
{
	public static void main ( String[] args ) {
		Scanner sc = new Scanner ( System.in );

		double a = 0.0;
		double b = 0.0;
		int d = 0;
		int r = 0;
		double f = 0.0;

		a = sc.nextInt ();
		b = sc.nextInt ();
		
		d = ( int )a / ( int )b;
		r = ( int )a % ( int )b;
		f = a / b;

		System.out.println ( d + " " + r + " " + String.format ( "%7f", f ) );
	}
}

Measured memory_bytes: 26348
# 解説は動的計画法がわからなかった
# https://drken1215.hatenablog.com/entry/2019/06/15/202200 参照
# 可能なパターンの必要条件として、c=a-bとして、左右からcごとに取る,途中打ち切りも可
#「この必要条件が十分条件」(以下のl<rとなるrの最小値をaとする,n-1がcで割れたら例外)
n=int(input())
*s,=map(int, input().split())
n-=1
tmp=0
ans=0
for c in range(1,n+1):
    if n%c==0:
        l=0;r=n
        tmp=0
        while l<r:
            tmp+=s[l]+s[r]
            l+=c;r-=c
            ans=max(tmp,ans)###

        ans=max(tmp,ans)
    else:
        l=0;r=n
        tmp=0
        while l<n and r>c:
            tmp+=s[l]+s[r]
            l+=c;r-=c
            ans=max(tmp,ans)###

        ans=max(tmp,ans)
print(ans)

Measured memory_bytes: 63216
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),sum=0;
    String a=sc.next(),b=sc.next(),c=sc.next();
    Set<String> set = new HashSet<>();
    for(int i=0;i<n;i++) {
    	set.add(a.substring(i, i+1));
    	set.add(b.substring(i, i+1));
    	set.add(c.substring(i, i+1));
    	sum+=set.size()-1;
    	set.clear();
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int a, b;
  cin >> a >> b;

  int ans[3] = {1, 2, 3};

  ans[a - 1] = -1;
  ans[b - 1] = -1;

  for (int i = 0; i < 3; i++) {
    if (ans[i] != -1) {
      cout << ans[i] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 3
using namespace std;
typedef unsigned long long ull;
bool im[1010][1010],pa[110][110];
int w,h,p,ans;
vector<ull> used;

void ppp(){
 ull a=0;
 ull roll[1001][1001]={};
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)a=a*N+pa[i][j];
 for(int i=0;i<used.size();i++)
   if(used[i]==a)return;
 used.push_back(a);
 for(int j=0;j<h;j++){
   ull b=0,g=1;
   for(int i=0;i<p;i++)b=b*N+im[j][i],g*=N;
   roll[j][p-1]=b;
   for(int i=p;i<w;i++){
     b=b*N+im[j][i]-im[j][i-p]*g;
     roll[j][i]=b;
   }
 }
 for(int j=p-1;j<w;j++){
   ull b=0,g=1,n=1;
   for(int i=0;i<p;i++)n*=N;
   for(int i=0;i<p;i++)b=b*n+roll[i][j],g*=n;
   if(b==a)ans++;
   for(int i=p;i<h;i++){
     b=b*n+roll[i][j]-roll[i-p][j]*g; 
     if(b==a)ans++;
   }
 }
}

void ch(){
 bool npa[110][110];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)npa[i][j]=pa[j][p-i-1];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)pa[i][j]=npa[i][j];
}

void ch1(){
 for(int i=0;i<p;i++)
   for(int j=0;j<p/2;j++)swap(pa[i][j],pa[i][p-j-1]);
}

int main(){
 int D[256];
 for(int i='A';i<='Z';i++)D[i]=i-'A';
 for(int i='a';i<='z';i++)D[i]=i-'a'+26;
 for(int i='0';i<='9';i++)D[i]=i-'0'+52;
 D['+']=62,D['/']=63;
 while(cin>>w>>h>>p,w){
   string s;
   used.clear();
   for(int i=0;i<h;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
       int t=D[s[j]],a=6;
	while(a--)im[i][j*6+a]=t%2,t/=2;
     }
   }
   for(int i=0;i<p;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
       int t=D[s[j]],a=6;
	while(a--)pa[i][j*6+a]=t%2,t/=2;
     }
   }
   ans=0;
    for(int i=0;i<4;i++){
     ppp();
     ch1();
     ppp();
     ch1();
     ch();
   }
   cout<<ans<<endl;
 }
 return 0;
}

Measured memory_bytes: 11952
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

int main() {
    string s,t;
    cin >> s >> t;
    if(t.size() > s.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    list<string> l;
    for(int i=0;i<=s.size()-t.size();i++){
        bool match=true;
        for(int j=0;j<t.size();j++){
            if(t[j] != s[i+j] && s[i+j] != '?') match=false;
        }
        if(match){
            string s0 = s;
            for(int k=0;k<i;k++){
                if(s[k]=='?') s0[k]='a';
            }
            for(int k=i;k<i+t.size();k++) s0[k]=t[k-i];
            for(int k=i+t.size();k<s.size();k++){
                if(s[k]=='?') s0[k]='a';
            }
            l.push_front(s0);
        }
    }
    if(l.empty()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    l.sort();
    cout << l.front() << endl;
}

Measured memory_bytes: 256
A,B,C,D,E,F = map(int,input().split())
wl = set()
for ia in range(F//A+1):
    for ib in range(F//B+1):
        ww = ia*A*100+ib*B*100
        if 0 < ww <= F:wl.add(ww)

ws = set()
for ic in range((F*E)//(100*C) + 1):
    for idd in range((F*E)//(100*D)+1):
        ss = ic*C + idd*D
        if ss <= (F*E)/100:ws.add(ss)

g = 0
sw = sg = 0
for www in sorted(wl):
    ms = (www * E) // 100
    for c in sorted(ws):
        if c > ms:break
        else:
            if (c/www) <= E and (www+c) <=F:
                if g < c/(c+www):
                    g = c/(c+www)
                    sw = www
                    sg = c
if g == 0:
    print(100*A,0)
else:
    print(sg+sw,sg)

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

int main() {
 int H,W;
 cin >> H>> W;
vector<vector<char>> data1(H, vector<char>(W));
  for(int i = 0;i<H;i++){
    for(int j = 0;j<W;j++){
      cin >> data1.at(i).at(j);
    }
  }
  vector<vector<char>> data2(H+2, vector<char>(W+2,'-'));
   for(int i = 1;i<H+1;i++){
    for(int j = 1;j<W+1;j++){
     data2.at(i).at(j) = data1.at(i-1).at(j-1);
   }
  }
  
  for(int i = 1;i<H+1;i++){
    for(int j = 1;j<W+1;j++){
      char c = '0';
      if(data2.at(i).at(j) == '.'){
        if(data2.at(i-1).at(j-1) == '#') c++;
        if(data2.at(i-1).at(j) == '#') c++;
        if(data2.at(i-1).at(j+1) == '#') c++;
        if(data2.at(i).at(j-1) == '#') c++;
        if(data2.at(i).at(j+1) == '#') c++;
        if(data2.at(i+1).at(j-1) == '#') c++;
        if(data2.at(i+1).at(j) == '#') c++;
        if(data2.at(i+1).at(j+1) == '#') c++;
        data2.at(i).at(j) = c;
      }
    }
  }
  
  for(int i = 1;i<H+1;i++){
    for(int j = 1;j<W+1;j++){
   cout << data2.at(i).at(j);
    if(j == W) cout << endl;
    }
 }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

char solve(const string& S, ll K)
{
    for (const auto& c : S)
    {
        if (c != '1')
            return c;

        if (not (--K))
            break;
    }

    return '1';
}

int main()
{
    ios::sync_with_stdio(false);

    string S;
    ll K;

    cin >> S >> K;
    
    cout << solve(S, K) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  int b(n);
  rep(i,n){
    cin >> a[i];
  }
  vector<int> acount(n);
  rep(i,n){
    acount[a[i]-1]++;
  }
  sort(acount.begin(),acount.end());
  int ans=0;
  rep(i,n-k){
    ans += acount[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
int prime = 10e9+7;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;




signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n;
    printD((double)n*2*PI);
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 3800
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

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

const int N = 0, mod = 0;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int l, r;
    cin >> l >> r;
    if (l <= 0 && 0 <= r) {
        cout << "Zero";
        return 0;
    }
    if (r < 0) {
        if ((abs(l) - abs(r) + 1) % 2 != 0) {
            cout << "Negative";
        } else {
            cout << "Positive";
        }
    } else {
        cout << "Positive";
    }





}








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

int search(int a[], int n, int key){
  int i = 0;
  a[n] = key;
  while(a[i] != key) i++;
  return i != n;
}

int main(void){
  int n; cin >> n;
  int s[n];
  rep(i,n) scanf("%d",&s[i]);
  int q; scanf("%d",&q);
  int key;
  int count = 0;
  rep(i,q){
    scanf("%d",&key);
    if(search(s,n,key)) count++;
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 3240
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
  int n,i,m;
  cin >> n;

  int kazu[n],suzi;

  for(i = 0;i < n;i++){

    cin >> suzi;
    kazu[i] = suzi;
  }

  for(m = n-1;m > 0;m--){
    cout << kazu[m] << " ";
  }
  cout << kazu[0];
  cout << "\n";
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	string s = "";
	long long d[100005];
	long long k;

	cin >> s;
	/*
	for(int i=0; i<100000; i++){
		s = s + 'z';
	}
	*/
	cin >> k;

	for(int i=0; i<s.size(); i++){
		if(s[i] != 'a'){
			d[i] = 'z' - s[i] + 1;
		}else{
			d[i] = 0;
		}
	}

	for(int i=0; i<s.size(); i++){
		if(d[i] <= k){
			s[i] = 'a';
			k -= d[i];
		}
	}
	if(k > 0){
		s[s.size()-1] = 'a' + (long long)((s[s.size()-1] - 'a') + k) % 26;
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 1408
l=[]
t=1
l.append(int(input()))
l.append(int(input()))
l.append(int(input()))
l.append(int(input()))
l.append(int(input()))
k=int(input())
for i in range(4):
    for j in range(i+1,5):
        if abs(l[i]-l[j])>k:
            t=0
            print(':(')
            break
    break
if t:
    print('Yay!')

Measured memory_bytes: 3064
from collections import deque
A = deque(list(map(str,input())))
B = deque(list(map(str,input())))
C = deque(list(map(str,input())))

def turn(play):
    if play=="a":
        if len(A) == 0: return "A"
        play = A.popleft()
    elif play=="b":
        if len(B) == 0: return "B"
        play = B.popleft()
    else:
        if len(C) == 0: return "C"
        play = C.popleft()
    return turn(play)
print(turn(A.popleft()))

Measured memory_bytes: 3444
// Created by  Ambesh kumar
#include "bits/stdc++.h"

//I already compile this file in my computer system to save the time
//if get the compiler error then you should change this header to
// #include "bits/stdc++.h"  ---> #include <bits/stdc++.h>

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0, lim - 1);
	return uid(rang);
}
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=================================================================================================================================//

vi g[N];
int a[N];

void solve() {
	int i, j, n, m;

	cin >> n;


	ll count = 0;

	Fo(i, 1, n + 1)
	{

		Fo(j, 1, n + 1)
		{

			if (i * j > n)
				break;
			int p = n - (i * j);



			if (p > 0)
				count++;

		}


	}



	cout << count << '\n' ;


}





int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

	return 0;
}







Measured memory_bytes: 10688
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
import itertools
x = list(itertools.accumulate(a))
y = list(itertools.accumulate(b))

import bisect
ans = bisect.bisect(y,k)
for i in range(n):
    if k-x[i]>=0:
        buf = i + 1 + bisect.bisect(y,k-x[i])
        ans = max(ans,buf)
    else:
        break
print(ans)


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

using namespace std;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define pb			    push_back

typedef long long ll;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	ll l, r;
	cin >> l >> r;
	for (ll i = l; i <= r; ++i) {
		if (i % 2019 == 0) {
			cout << 0;
			return 0;
		}
	}
	ll res = LLONG_MAX;
	for (ll i = l; i <= r; ++i) {
		for (ll j = i+1; j <= r; ++j) {
			res = min(res, (ll)(i*j)%2019);
		}
	}

	cout << res;
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
#include <math.h>
#include <sstream>

using namespace std;
int main(void){
    while(true){
        int n;
        cin>>n;
        if(n==0)break;
        int inx,iny;
        bool  takara[21][21]={0};
        for(int i=0;i<n;i++){
            cin>>inx>>iny;
            takara[inx][iny]=1;
        }
        int k,cnt=0;
        cin>>k;
        int x=10,y=10,oldx=10,oldy=10;
        string houi;
        int idou;
        for(int i=0;i<k;i++){
            oldx=x;oldy=y;
            cin>>houi>>idou;
            if(houi=="N"){
                for(int s=0;s<idou;s++){
                    y++;
                    if(takara[x][y]==1){
                        takara[x][y]=0;
                        cnt++;
                    }
                }
            }else if(houi=="S"){
                for(int s=0;s<idou;s++){
                    y--;
                    if(takara[x][y]==1){
                        takara[x][y]=0;
                        cnt++;
                    }
                }
            }else if(houi=="E"){
                for(int s=0;s<idou;s++){
                    x++;
                    if(takara[x][y]==1){
                        takara[x][y]=0;
                        cnt++;
                    }
                }
            }else if(houi=="W"){
                for(int s=0;s<idou;s++){
                    x--;
                    if(takara[x][y]==1){
                        takara[x][y]=0;
                        cnt++;
                    }
                }
            }
            
        }
        if(cnt==n)cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}

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

int main(){

  int n, i, r, l;
  string str;

  cin >> n >> str;

  r = l =0;
  for(i = 0; i < n; i++){
    if(str[i] == '('){
      l++;
    }else{
      if(l > 0){
        l--;
      }else{
        r++;
      }
    }
  }
  for(i = 0; i < l; i++) str = str + ")";
  for(i = 0; i < r; i++) str = "(" + str;
  cout << str <<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = 0
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1==D2:
        a += 1
    else:
        a = 0
    if a == 3:
        print("")
        print("Yes")
        break
    if i == N-1 and a != 3:
        print("No")

Measured memory_bytes: 62596
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int n;
string s;
ll dp[100005][13];

int main () {
  int ki;
  ll res = 0;
  cin >> s;
  n = sz(s);

  dp[0][0] = 1;
  rep(i,n) {
    int c;
    if (s[i] == '?') c = -1;
    else c = s[i] - '0';

    rep(j,10) {
      if (c != -1 && c != j) continue;
      rep(ki,13) {
        dp[i+1][(ki*10+j)%13] += dp[i][ki];
      }
    }
    rep(j,13) dp[i+1][j] %= mod;
  }
  res = dp[n][5];
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}
ll func(ll n) {
  if (n % 2 == 0) return n / 2;
  else return 3 * n + 1;
}
ll coll(ll n, ll s) {
  if (n == 1) return s;
  else return func(coll(n - 1, s));
}

int main() {
  int s;
  cin >> s;
  vector<ll> a(1, coll(1, s));
  a.push_back(coll(2, s));
  ll cnt = 3;
  while (a.at(a.size() - 1) != 1) {
    a.push_back(coll(cnt, s));
    cnt++;
  }
  if (a.at(0) == a.at(1)) cout << 2 << endl;
  else if (s == 1) cout << a.size() << endl;
  else if (s == 2) cout << 4 << endl;
  else cout << a.size() + 1 << endl;
}

Measured memory_bytes: 256