akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int flag = 0;
    for(int i = A; i<=B; i++){
            if(i%K == 0){
              flag++;
              break;
            }
    }
    if(flag==0){
      System.out.println("NG");
    }else if(flag==1){
      System.out.println("OK");
    }
  }
}

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

int main(){
  string s;
  cin >> s;
  
  int first = 10 * static_cast<int>( s[0] - '0' ) + static_cast<int>( s[1] - '0' );
  int last = 10 * static_cast<int>( s[2] - '0' ) + static_cast<int>( s[3] - '0' );
    
  if ( 1 <= first && first <= 12 && 1 <= last && last <= 12 ) cout << "AMBIGUOUS" << endl;
  else if ( 1 <= first && first <= 12 ) cout << "MMYY" <<endl;
  else if ( 1 <= last && last <= 12 ) cout << "YYMM" << endl;
  else cout << "NA" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

int const MAXN = 1e5 + 5, mod = 1e9 + 7;
int f[MAXN];

inline int qpow(int a, int k) {
  int re = 1;
  for (; k; k >>= 1, a = a * a % mod)
    if (k & 1) re = re * a % mod;
  return re;
}

signed main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n, k; cin >> n >> k;
  for (RI i = k; i; --i) {
    f[i] = qpow(k / i, n);
    for (RI j = i + i; j <= k; j += i)
      f[i] = (f[i] - f[j] + mod) % mod;
  }
  int ans = 0;
  for (RI i = 1; i <= k; ++i)
    ans = (ans + f[i] * i % mod) % mod;
  cout << ans;

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 4364
S['= r'],m[4]['= r'],W,z,d[4]={1,-1},k,i;

f(i){
	m[k][i]=S[i]+47?0:m[k][i]?:1+f(i+d[k]);
}

main(t){
	for(d[2]-=d[3]=scanf("%*d%d ",&W)+W;S[i-~W]=~getchar();++i);
	for(;i--;z=fmax(z,t))for(t=k=0;k<4;++k)t+=f(i-~W);
	printf("%d",z-3);
}


Measured memory_bytes: 78464
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd( T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint power(lint N, lint P, lint M){if(P==0) return 1;if(P%2==0){lint t = power(N, P/2, M);return t*t % M;}return N * power(N, P-1, M);}
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**/int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	int s;
	in(s);
	int h=s/3600;
	int m=(s%3600)/60;
	int sec=s%60;
	cout<<h<<':'<<m<<':'<<sec;
	out("");
	return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

string a, b;

string dfs(int l, int r, int p, int q){
    if(r-l == 0 || q-p == 0) return "";
    int m1 = l, m2 = p, v1 = 0, v2 = 0;
    int sum = 0;
    while(true){
        if(a[m1] == '(') ++sum;
        else if(a[m1] == ')') --sum;
        ++m1;
        if(sum == 0) break;
    }
    while(true){
        if(b[m2] == '(') ++sum;
        else if(b[m2] == ')') --sum;
        ++m2;
        if(sum == 0) break;
    }
    string L = "(" + dfs(l+1, m1-1, p+1, m2-1) + ")";

    ++m1;
    while(isdigit(a[m1])){
        v1 = v1*10 + a[m1]-'0';
        ++m1;
    }
    m1 += 2;
    ++m2;
    while(isdigit(b[m2])){
        v2 = v2*10 + b[m2]-'0';
        ++m2;
    }
    m2 += 2;
    string M = "[" + to_string(v1+ v2) + "]";
    string R = "(" + dfs(m1, r-1, m2, q-1) + ")";

    return L + M + R;
}

int main(){
    cin >> a >> b;
    cout << dfs(0, a.size(), 0, b.size()) << "\n";
}


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

'''
全探索
'''
cost_tmp = 0
cost_min = 10**8

for i in range(min(a),max(a)+1):
    for j in range(n):
        cost_tmp += pow(a[j]-i,2)
    if cost_tmp < cost_min:
        cost_min = cost_tmp
    cost_tmp=0

print(cost_min)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<set>
signed main(){
  int n;
  std::cin>>n;
  std::vector<int> a(n);
  for(auto& ai:a)std::cin>>ai;
  std::multiset<int> s;
  for(auto ai:a){
    auto itr = s.lower_bound(ai);
    if(itr==std::begin(s)){
      s.emplace(ai);
      continue;
    }
    --itr;
    s.erase(itr);
    s.emplace(ai);
  }
  std::cout<< std::size(s) <<std::endl;
}

Measured memory_bytes: 8272
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;

int main()
{
//	ios::sync_with_stdio(false);
//	cin.tie(0);cout.tie(0);
	string s,t;
	cin>>s>>t;
	int cnt=0;
	int len=s.length();
	for(int i=0;i<len;i++){
		if(s[i]!=t[i]){
			cnt++;
		}
	}
	cout<<cnt<<endl;
 	return 0;
}



Measured memory_bytes: 3796
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    ll n;
    cin >> n;
    cout << (n%2==0 ? n/2 : (n+1)/2) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,num=0;
	cin>>n;
	for(int i=1;i<=n;i=i+2){
		int k=0,j;
		for(j=1;j<i;j++){
			if(i%j==0) k++;
		}		
		if(k==7) num++;
	}
	cout<<num<<endl;
}

Measured memory_bytes: 256
using System;
    class Program
    {
        static void Main()
        {
            string inputString, outputString = "";
            int length;
            inputString = Console.ReadLine();
            length = inputString.Length - 1;
                while (0 <= length)
                {
                    outputString = outputString + inputString[length];
                    length--;

                }
                Console.WriteLine(outputString);
        }
    }

Measured memory_bytes: 8652
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    char s[5];
    scanf("%s", s);
    if (s[0] == s[1] && s[1] == s[2]) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
}


Measured memory_bytes: 128
import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()
C.sort()

ans = 0

for b in B:
    n_lower_B = bisect.bisect_left(A, b)
    n_higher_B = N - bisect.bisect_right(C, b)
    ans += n_lower_B * n_higher_B

print(ans)


Measured memory_bytes: 29528
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readline(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}

signed main(){

    int N;
    cin >> N;

    vector<int> a(N);
    readline(N, a);

    int ans = 0;

    for(int i = 0; i < N; i++){
        while(a[i] % 2 == 0){
            ans++;
            a[i] /= 2;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits.h>
#include <cmath>

using namespace std;


int main(int argc, char const *argv[]) {
	int N,temp,push;
	std::cin >> N;
	int F[1023][N][10];
	for (size_t i = 0; i < N; i++) {
		for (size_t j = 0; j < 10; j++) {
			std::cin >> temp;
			for (size_t k = 0; k < 1023; k++) {
				F[k][i][j] = temp;
			}
		}
	}
	int P[N][11];
	for (size_t i = 0; i < N; i++) {
		for (size_t j = 0; j < 11; j++) {
			std::cin >> temp;
			P[i][j] = temp;
		}
	}

	int binary[1023][10];
	for (size_t i = 0; i < 1023; i++) {
		temp = i+1;
		for (size_t j = 0; j < 10; j++) {
			push = temp / pow(2,(9-j));
			binary[i][j] = push;
			temp = temp - push * pow(2,(9-j));
		}
	}

	int ans = INT_MIN;
	int kari = 0;

	for (size_t i = 0; i < 1023; i++) {
		kari = 0;
		for (size_t j = 0; j < N; j++) {
			temp = 0;
			for (size_t k = 0; k < 10; k++) {
				temp = temp + F[i][j][k] * binary[i][k];
			}
			kari = kari + P[j][temp];
		}
		ans = max(ans, kari);
	}

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


	return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll inf=17441744174417;
ll dp[(1<<18)+5][55]={0};
int main(){
  ll n;
  cin>>n;
  vector<P> vec;
  vector<ll> kvec;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    kvec.push_back(a);
  }
  for(int i=0;i<n;i++){
    ll b;
    cin>>b;
    vec.push_back(P(kvec[i],b));
  }
  for(int i=0;i<(1<<18);i++){
    for(int j=0;j<55;j++) dp[i][j]=inf;
  }
  dp[0][0]=0;
  for(int i=0;i<(1<<n);i++){
    vector<ll> kv;
    for(int j=0;j<n;j++){
      kv.push_back((i>>j)&1);
    }
    for(int k=0;k<n;k++){
      if(kv[k]==0){
        int cnt=0;
        for(int l=k+1;l<n;l++){
          cnt+=kv[l];
        }
        ll us_idx=(n-1)-k-cnt;
        ll now_idx=n-1-us_idx;
        ll all_cnt=0;
        for(int l=0;l<n;l++) all_cnt+=kv[l];
        ll ov=((now_idx-all_cnt)+(now_idx-k))%2;
        ll val=0;
        if(ov==0) val=vec[k].first;
        else val=vec[k].second;
        for(int j=0;j<55;j++){
          if(j<=val){
            dp[i|(1<<k)][val]=min(dp[i|(1<<k)][val],dp[i][j]+max((ll)0,(now_idx-all_cnt)));
          }
        }

      //  cout<<i<<" "<<k<<" "<<val<<" "<<now_idx<<" "<<all_cnt<<endl;
      }

    }
  }

/*  for(int i=0;i<(1<<n);i++){
    for(int j=0;j<=4;j++) cout<<dp[i][j]<<" ";
    cout<<endl;
  }
*/
  ll ans=inf;
  for(int i=0;i<55;i++) ans=min(ans,dp[(1<<n)-1][i]);
  cout<<(ans==inf?-1:ans)<<endl;
}


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

int main(){
  long long int n;
  cin>>n;
  vector<long long int> r(n+2);
  r[0]=2;
  r[1]=1;

  for(int i=2;i<=n;i++)r[i]=r[i-1]+r[i-2];

  cout<<r[n]<<endl;

  return 0;
}


Measured memory_bytes: 256
N, C = map(int, input().split())

tt = [[0] * (2 * 10 ** 5 + 1) for _ in range(30)]
for _ in range(N):
    s, t, c = map(int, input().split())
    ttc = tt[c - 1]
    for i in range(s * 2 - 1, t * 2):
        ttc[i] = 1

ct = [0] * (2 * 10 ** 5 + 1)
for i in range(30):
    tti = tt[i]
    for j in range(2 * 10 ** 5 + 1):
        ct[j] += tti[j]

print(max(ct))


Measured memory_bytes: 53492
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  //小数点以下12ケタを表示させるためのおまじない
  cout<<fixed<<setprecision(12);
   
  double a,b,C;
  cin>>a>>b>>C;
 
  double PI=acos(-1.0);
 
  //Cをラジアンに直す
  C=C/180.0*PI;
   
  cout<< a*b*sin(C)/2.0 <<endl;
   
  // c*c = a*a + b*b - 2*a*b*cosC
  double cc=a*a+b*b-2*a*b*cos(C);
  cout<< a+b+sqrt(cc) <<endl;
   
  cout<< b*sin(C) <<endl;
   
  return 0;  
}


Measured memory_bytes: 3536
a, b, c, k = map(int, input().split())
_sum = 0

if a > k:
  _sum += k
else:
  k -= a
  _sum += a
  if b > k:
    b = 0
  else:
    k -= b
    if c > k:
      _sum -= k
    else:
      _sum -= c

print (_sum)

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

#define pb push_back
#define ff first
#define ss second

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

ll a, b, c;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b >> c;
	cout << b + min(a + b + 1, c) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	double a, b, c, d, e, f;
	
	while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		double x, y, xx;
		
		x = 1 / (a * e - b * d) * ((e * c) + (-b * f)) + 0.00005;
		y = 1 / (a * e - b * d) * ((-d * c) + (a * f)) + 0.00005;
		
		printf("%.3lf %.3lf\n", x, y);
	}
	
	return 0;
}

Measured memory_bytes: 656
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

typedef long long int lli;
lli INF = 1000000LL;

int main() {

  array<array<lli, 10>, 10> table;
  
  while( true ){
	int n;
	cin >> n;
	if ( n == 0 ) break;

	for ( int i = 0; i < 10; i++ ) {
	  for ( int j = 0; j < 10; j++ ) {
		table[ i ][ j ] = INF;
	  }
	}
	
	int m = -1;
	for ( int i = 0; i < n; i++ ) {
	  int v1, v2, c;
	  cin >> v1 >> v2 >> c;
	  table[ v1 ][ v2 ] = c;
	  table[ v2 ][ v1 ] = c;
	  m = max( max( v1, v2 ), m );
	}
	for ( int i = 0; i < 10; i++ ) {
	  table[ i ][ i ] = 0LL;
	}

	for ( int k = 0; k <= m; k++ ) {
	  for ( int i = 0; i <= m; i++ ) {
		if ( table[ i ][ k ] >= INF ) continue;
		for ( int j = 0; j <= m; j++ ) {
		  if ( table[ i ][ j ] > table[ i ][ k ] + table[ k ][ j ] ) {
			table[ i ][ j ] = table[ i ][ k ] + table[ k ][ j ];
		  }
		}
	  }
	}
	lli ans = INF;
	int num = -1;
	for ( int i = 0; i <= m; i++ ) {
	  lli sum = 0;
	  for ( int j = 0; j <= m; j++ ) {
		sum += table[ i ][ j ]; 
	  }
	  if ( ans > sum ) {
		ans = sum;
		num = i;
	  }
	}
	cout << num << " " << ans << endl;
  }
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int input;
	vector<int> stack;
	while(cin >> input){
		if (input != 0){
			stack.push_back(input);
		}else{
			cout << stack.back() << endl;
			stack.pop_back();
		}

	}

}

Measured memory_bytes: 3140
#include <stdio.h>
int main(void){
int H,W;

while(1){
scanf("%d %d",&H,&W);

if(H==0 && W==0)break;

for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
printf("#");
}
printf("\n");
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2040
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int highest = 0;
		int count = 0;
		
		for(int i = 0; i < num; i++) {
			int heigh = sc.nextInt();
			if (highest <= heigh) {
				highest = heigh;
				count++;				
			}
		}
		
		System.out.print(count);
	}	
}

Measured memory_bytes: 23892
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <bitset>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;

int n;double L,R,P,E,T;
double ans = 0;
void dfs(int now,double l,double r,double p,double e,double t)
{

    if(l>(T+E)&&(r>(T+E)))
        return;
    if(l<(T-E)&&r<(T-E))
        return;
    if(l<=(T+E)&&l>=(T-E)&&r<=(T+E)&&r>=(T-E))
    {
        ans+=p;
        return;
    }
    double h = (l+r)/2.0;
    if(now == n)
    {
        if(fabs(h-T)<=E)
            ans += p;
        return;
    }
    if(h-T>=-1e-10)
    {
        dfs(now+1,h,r,p*(P),e,t);
        dfs(now+1,l,h,p*(1-P),e,t);
    }
    else
    {
        dfs(now+1,l,h,p*(P),e,t);
        dfs(now+1,h,r,p*(1-P),e,t);
    }
}
int main()
{
    scanf("%d",&n);
    scanf("%lf%lf%lf%lf%lf",&L,&R,&P,&E,&T);
    dfs(0,L,R,1,E,T);
    printf("%.10lf\n",ans);
    return 0;
}

Measured memory_bytes: 1228
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, l;
	cin >> n >> l;
	int bad = -1, mabs = 1e9;
	for (int i = 1; i <= n; i++) {
		if (abs(l + i - 1) < mabs) {
			bad = i;
			mabs = abs(l + i - 1);
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i != bad) ans += l + i - 1;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
  
int main(){
  int N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector < vector<int> > vec(Q, vector<int>(2));
  vector<int> dp(N);
  for(int i = 0; i < Q; i++){
    int l,r; cin >> l >> r;
    vec[i][0] = --l;
    vec[i][1] = --r;
  }
  int cnt = 0;
  for(int i = 1; i < N; i++){
    if(S[i-1] == 'A' && S[i] == 'C'){
      cnt++;
    }
    dp.at(i) = cnt;
  }
  for(int i = 0; i < Q; i++){
    cout << dp[vec[i][1]] - dp[vec[i][0]] << endl;
  }
}


Measured memory_bytes: 6784
//git pull --rebase origin master
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int 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
#define wi(t) int t;cin>>t;while(t--)
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];
ll int gcd(ll int a, ll int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
int tc=1;
void solve()
    { 
        int x;
        cin>>x;
        if(x==0) cout<<"1";
        else
        {
            cout<<"0";
        }
        
    }

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

   // wi(t)
    {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
    u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}







Measured memory_bytes: 10680
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
int V,E,s,t,w;
vector<vector<pair<int,int>>> v(100001);
int visited[100001] = {0};
int ans[100001] = {0},d[100001] = {0};

void di(int n){
	visited[n] = 1;
	for(int i=0;i<v[n].size();i++){
		if(visited[v[n][i].first]==0){
			d[v[n][i].first] = d[n]+v[n][i].second;
			di(v[n][i].first);
		}
	}
}

/*void dfs(int n){
	visited[n] = 1;
	for(int i=0;i<v[n].size();i++){
		if(visited[v[n][i].first]==0){
			dfs(v[n][i].first);
			d[n] = max(d[n],d[v[n][i].first]+v[n][i].second);
		}
	}
}
*/
int main(){
	cin >> V;
	for(int i=0;i<V-1;i++){
		cin >> s >> t >> w;
		v[s].push_back({t,w});
		v[t].push_back({s,w});
	}
	di(0);
	int a = 0,b = 0,va = 0,vb = 0;
	for(int i=0;i<V;i++){
		if(va<d[i]){
			a = i;
			va = d[i];
		}
	}
	for(int i=0;i<V;i++){
		visited[i] = 0;
		d[i] = 0;
	}
	di(a);
	for(int i=0;i<V;i++){
		if(vb<d[i]){
			b = i;
			vb = d[i];
		}
	}
	for(int i=0;i<V;i++){
		visited[i] = 0;
		ans[i] = d[i];
		d[i] = 0;
	}
	di(b);
	int res = 0;
	for(int i=0;i<V;i++){
	    res = max(res,d[i]);
	}
	cout << res << endl;
}



Measured memory_bytes: 12400
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var abck = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (a, b, c, k) = (abck[0], abck[1], abck[2], abck[3]);

        var max = 0;
        max += Math.Min(k, a);
        k = Math.Max(0, k - a - b);
        max -= Math.Min(k, c);

        Console.WriteLine(max);
    }
}


Measured memory_bytes: 28248
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter

# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int, readline().split()))

    ans = min(n % k, abs(((n % k) - k)))

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
int N,ans;
cin>>N;
int mina = 1000;
int maxa = 0;
int tmp;
for(int i = 0;i<N;i++){
  cin>>tmp;
  if(mina>tmp)mina=tmp;
  if(maxa<tmp)maxa=tmp;
}
  ans=maxa-mina;
  cout<<ans<<endl;
}


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

void trace(int a[], int n) {
    for (int i = 0; i < n; ++i) {
        if (i) cout << ' ';
        cout << a[i];
    }
    cout << endl;
}

int bubbleSort(int a[], int n) {
    int count = 0;
    bool flag = true;
    while (flag) {
        flag = false;
        for (int i = n-1; i > 0; --i) {
            if (a[i] < a[i-1]) {
                swap(a[i], a[i-1]);
                count++;
                flag = true;
            }
        }
    }
    return count;
}

int main() {
    int a[100], n; cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int c = bubbleSort(a, n);
    trace(a, n);
    cout << c << endl;
}

Measured memory_bytes: 3100
S=input()
i=len(S)-1
flag=0
T1='dream'
T2='dreamer'
T3='erase'
T4='eraser'

while i>=0:
    if S[i]=='m':
        k=0
        for j in reversed(range(i-4,i+1)):
            #print(S[j],T1[4-k])
            if S[j]!=T1[4-k]:
                flag=1
            k+=1
        i-=5
    elif S[i]=='e':
        kk=0
        for j in reversed(range(i-4,i+1)):
            #print(S[j], T3[4 - kk])
            if S[j]!=T3[4-kk]:
                flag=1
            kk+=1
        i-=5
    elif S[i]=='r' and S[i-1]=='e':
        if S[i-2]=='m':
            kkk=0
            for j in reversed(range(i-6,i+1)):
                #print(S[j], T2[6 - kkk])
                if S[j] != T2[6-kkk]:
                    flag = 1
                kkk+=1
            i-=7
        elif S[i-2]=='s':
            kkkk=0
            for j in reversed(range(i-5,i+1)):
                #print(S[j], T4[5 - kkkk])
                if S[j] != T4[5-kkkk]:
                    flag = 1
                kkkk+=1
            i-=6
        else:
            i-=1
    else:
        i-=1
if flag==0:
    print('YES')
else:
    print('NO')

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

int main(){
    string s;
    cin >> s;
    int n = s.length();
    vector<vector<ll>> dp(n+1, vector<ll>(2, 0));
    dp[0][0] = 1;
    rep(i, n) {
        if ( s[i] == '0' ) {
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][1]; 
        }
        else {
            dp[i+1][1] = ( dp[i][0] + dp[i][1] ) % mod;
        }

        if ( s[i] == '0') {
            dp[i+1][1] = ( dp[i+1][1] + dp[i][1] * 2 % mod ) % mod;
        }
        else {
            dp[i+1][0] = ( dp[i+1][0] + dp[i][0] * 2 % mod ) % mod;
            dp[i+1][1] = ( dp[i+1][1] + dp[i][1] * 2 % mod ) % mod;
        }
    }
    ll ans = ( dp[n][0] + dp[n][1] ) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a;
  cin>>a;
  int check=0;
  for(int i=0;i<a.length();i++){
    if(i%2){
      if(a[i]=='R'){
        check++;
        break;
      }
    }else{
      if(a[i]=='L'){
        check++;
        break;
      }
    }
  }
  cout<<(check?"No":"Yes");
    
  
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N+1);
  repeat(i,N+1) cin >> A[i];
  
  vector<int> B(N);
  repeat(i,N) cin >> B[i];
 
  long long ans = 0;
  repeat(i,N){
    int e1 = min(A[i],B[i]); 
    ans += e1;
    B[i] -= e1;
    
    int e2 = min(A[i+1],B[i]);
    ans +=  e2;
    A[i+1] -= e2;
  }
  
  cout << ans << endl;
}

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

int compare(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int solv(int n, int h) {
  int i, a, amax = 0;
  int *b, *p;

  b = (int *)malloc(sizeof (int) * n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &a, b + i);
    if (amax < a) {
      amax = a;
    }
  }
  b[i] = 0; // 番兵
  qsort(b, n, sizeof (int), compare);

  for (i = 0, p = b; h > 0 && amax < *p; i++, p++) {
    h -= *p;
  }
  if (h > 0) {
    i += (h - 1) / amax + 1;
  }

  free(b);

  return i;
}

int main(int argc, char **argv) {
  int n, h;

  while (scanf("%d %d", &n, &h) != EOF) {
    printf("%d\n", solv(n, h));
  }

  return 0;
}


Measured memory_bytes: 892
n, a, b = list(map(int, input().split()))
h = [int(input()) for i in range(n)]
h.sort()

def check(k):
    top = 0
    tmp = h[::]
    for i in range(n):
        amari = tmp[i] - b*k
        if amari > 0:
            top += -(-amari//(a-b))
    return top <= k

# 二分探索
left = 0
right = -(-1*sum(h)//b)
while(right-left>1):
    next_ind = (left + right)//2
    if check(next_ind):
        right = next_ind
    else:
        left = next_ind
print(right)

Measured memory_bytes: 7892
#include <bits/stdc++.h>
#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(){
  ll n,k;
  cin>>n>>k;
  cout<<min({n%k,(n+k-1)/k*k-n,n})<<endl;
  return 0;
}



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

int main(){
  int n;
  double a[110],sum=0;
  cin>>n;
  for(int i=0;i<n;++i)cin>>a[i];
  for(int i=0;i<n;++i)sum+=1/a[i];
  cout<<1/sum;
}

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};


string s[7],a[7];
int n,m,k;

int fn(int x,int y)
{
    for(int i=0;i<n;i++)
    {
        a[i] = s[i];
    }
    for(int i=0;i<n;i++)
    {
        if((1<<i)&x)
        {
            for(int j=0;j<m;j++)
            {
                a[i][j]='R';
            }
        }
    }
    for(int i=0;i<m;i++)
    {
        if((1<<i)&y)
        {
            for(int j=0;j<n;j++)
            {
                a[j][i]='R';
            }
        }
    }
    int c = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i][j]=='#')c++;
        }
    }
    return c==k;
}
int main()
{
    sf(n);sf(m);sf(k);
    int c = 0;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }

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

        for(int j=0;j<(1<<m);j++)
        {
            if(fn(i,j))
            {
                c++;
            }
        }
    }
    pf("%d\n",c);
}


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

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

lint lcm(lint x, lint y) { return abs(x-y)/gcd(x,y); }


int main() {
  lint n; cin >> n;
  vector<lint> a(n); for(lint i=0;i<n;i++) { cin >> a[i]; }

  lint ans=a[0];
  for(lint i=1;i<n;i++) { ans=gcd(ans,a[i]); }

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

Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    ll n;
    ll a[5];
    scanf("%lld%lld%lld%lld%lld%lld", &n, &a[0], &a[1], &a[2], &a[3], &a[4]);

    ll min = LINF;
    long i;
    for(i=0; i<5; i++) {
        min = MIN(min, a[i]);
    }

    ll m = (n-1)/min+1;

    printf("%lld\n", 5+(m-1));

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
using namespace std;
 
double p1[2]={0.0,0.0},p2[2]={100.0,0.0};
 
#define A 1.0471975511965
 
void koch(int d,double p1[],double p2[]){
    if(d==0){return;}
    double p3[2],p4[2],p5[2];
    p3[0]=p1[0]+(p2[0]-p1[0])*1.0/3.0;
    p3[1]=p1[1]+(p2[1]-p1[1])*1.0/3.0;
    p5[0]=p1[0]+(p2[0]-p1[0])*2.0/3.0;
    p5[1]=p1[1]+(p2[1]-p1[1])*2.0/3.0;
    p4[0]=(p5[0]-p3[0])*cos(A)-(p5[1]-p3[1])*sin(A)+p3[0];
    p4[1]=(p5[0]-p3[0])*sin(A)+(p5[1]-p3[1])*cos(A)+p3[1];
    koch(d-1,p1,p3);
    cout<<p3[0]<<' '<<p3[1]<<endl;
    koch(d-1,p3,p4);
    cout<<p4[0]<<' '<<p4[1]<<endl;
    koch(d-1,p4,p5);
    cout<<p5[0]<<' '<<p5[1]<<endl;
    koch(d-1,p5,p2);
}
 
int main(){
    int n;
    cin>>n;
    cout<<p1[0]<<' '<<p1[1]<<endl;
    koch(n,p1,p2);
    cout<<p2[0]<<' '<<p2[1]<<endl;
    return 0;
}


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

const int mod=1e9+7;
const int maxn=200000+5;
int Next[maxn][27];
int dep[maxn];
char shit[maxn];
char ans[maxn];
int top;
int main()
{
    scanf("%s",shit+1);
    shit[0]='a';
    int l=strlen(shit);
    for(int i=0;i<26;i++)
        Next[l][i]=l;
    for(int i=l-1;i>=0;i--)
    {
        int tmp=shit[i]-'a';
        for(int j=0;j<26;j++)
            Next[i][j]=Next[i+1][j];
        if(i);
        Next[i][tmp]=i;
    }
    dep[l]=0;
    for(int i=l-1;i>=0;i--)
    {
        dep[i]=mod;
        for(int j=0;j<26;j++)
        {
            dep[i]=min(dep[i],dep[Next[i+1][j]]+1);
        }
    }
    int i=0;top=0;
    //printf("%d\n",dep[0]);
    while(i!=l)
    {
        //printf("%d\n",i);
        int tmin=mod;
        for(int j=0;j<26;j++)
        {
            if(dep[Next[i+1][j]]==dep[i]-1){
                ans[top]=j+'a';
                i=Next[i+1][j];
                //printf("%d %d %c %d\n",i,j,ans[top],top);
                break;
            }
        }
        top++;
    }
    ans[top]=0;
    printf("%s\n",ans);
    return 0;
}


Measured memory_bytes: 22272
s = input().split('/')
s = [int(i) for i in s]
if s[0] == 2019:
    if s[1] == 4:
        if s[2] <= 30:
            print("Heisei")
        else:
            print("TBD")
    elif s[1] < 4:
        print("Heisei")
    else:
        print("TBD")
elif s[0] < 2019:
    print("Heisei")
else:
    print("TBD")


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

using namespace std;

using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"
const int N = 2e5, K = 10;
const int MOD = 998244353;
int dp[1 + N];
int sumDp[1 + N];
void add (int &a, int b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}
int l[1 + K], r[1 + K];
int main () {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);

    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= k; i++)
        cin >> l[i] >> r[i];
    dp[1] = 1;
    sumDp[1] = 1;
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            int start = max (1, i - r[j]);
            int finish = max (0, i - l[j]);
            if (finish && start <= finish) {
                add (dp[i], (sumDp[finish] - sumDp[start - 1] + MOD) % MOD);
            }
        }
        add (sumDp[i], sumDp[i - 1]);
        add (sumDp[i], dp[i]);
    }
    cout << dp[n] << "\n";
    return 0;
}


Measured memory_bytes: 5172
#pragma GCC optimize("O3")
#pragma GCC target("avx")
int N,K,C;
char*S;
int R[2<<17];
char buf[2<<17],out[3<<19];sz;outsz;
char c[6];
main()
{
	read(0,buf,2<<17);
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		K=K*10+k-'0';
	}
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		C=C*10+k-'0';
	}
	S=buf+sz;
	int now=K;
	for(int i=N;i-->0;)
	{
		if(S[i]=='o')
		{
			R[i]=now--;
			i-=C;
		}
	}
	now=0;
	for(int i=0;i<N;i++)
	{
		if(S[i]=='o')
		{
			if(R[i]==++now)
			{
				int t=i+1;
				int cs=6;
				do{
					c[--cs]=t%10+'0';
				}while(t/=10);
				for(;cs<6;)out[outsz++]=c[cs++];
				out[outsz++]='\n';
			}
			i+=C;
		}
	}
	write(1,out,outsz);
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    ll N, res;
    cin >> N;
    res = 1;
    
    // calculation
    REPN(i, N) {
        res *= i;
        res %= MOD;
    }
    cout << res << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void gen_prime(char prime[]);

int main(void)
{
    int a, d, n;
    int i, c;
    char prime[1000000] = {0};

    gen_prime(prime);

    for (;;) {
        scanf("%d %d %d", &a, &d, &n);
        if (a == 0 && d == 0 && n == 0)
            break;

        c = 0;
        for (i = a; ; i += d) {
            if (prime[i] == 0) {
                ++c;
                if (c == n) {
                    printf("%d\n", i);
                    break;
                }
            }
        }

    }

    return 0;
}

void gen_prime(char prime[])
{
    int i, j;

    prime[0] = prime[1] = 1;
    for (i = 2; i < 1000; ++i) {
        if (prime[i] == 1) {
            continue;
        }
        for (j = i * 2; j < 1000000; j += i) {
            prime[j] = 1;
        }
    }

    /*
    for (i = 1; i < 100; ++i) {
        if (prime[i] == 0) {
            printf("%d\t", i);
        }
    }
    printf("\n");
    */
}

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

const int mod = 1e9+7;
void tlfclwx(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
const int maxn=1e6+10;

int main()
{
    ll n; cin >> n;
    if(n&1) cout << 0 << endl;
    else {
        n /= 2;
        ll sum = 0;
        while(n) {
           sum += n/5;
           n/=5;
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 256
// abc100_d
#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; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << 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

    ll N;
    int M;
    cin >> N >> M;
    vector<ll> X(N), Y(N), Z(N);
    REP(i, N) cin >> X[i] >> Y[i] >> Z[i];

    ll ans = 0;
    REP(p, 1 << 3){

        int a = p & 1 ? 1 : -1;
        int b = (p >> 1) & 1 ? 1 : -1;
        int c = (p >> 2) & 1 ? 1 : -1;

        vector<ll> vec;
        REP(i, N){
            ll s = a * X[i] + b * Y[i] + c * Z[i];
            vec.emplace_back(s);
        }
        sort(ALL(vec), greater<ll>());
        ll tmp = accumulate(vec.begin(), vec.begin() + M, 0ll);
        ans = max(ans, tmp);
    }

    print(ans);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  int a, b, k;
  cin >> a >> b >> k;
  for(int i = 1000; true; i--) {
    if(a%i == 0 && b%i == 0) {
      if(--k == 0) {
        cout << i << endl;
        break;
      }
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}

template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

int main() {
  int n, x = 0, r = 0;
  string s;
  cin >> n >> s;
  for (char c : s) {
    if (c == 'I') ++x;
    else --x;
    chmax(r, x);
  }
  cout << r << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
int main()
{ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    cin>>n;
    ll cur=0;
    for(int i=1;i<=1000*1000*10;i++){
        cur=(cur*10+7)%n;
        if(cur==0){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


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

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

using ll = long long;
const long long MOD = 1e9+7;

const double INF = 1ll << 60;
const double EPS = 1e-10;
using point = complex<double>;
double dot(point p, point q) { return p.real() * q.real() + p.imag() * q.imag(); }

double cross(point p, point q) { return p.real() * q.imag() - p.imag() * q.real(); } // left turn > 0
double arg(point p, point q){ return atan2(cross(p,q), dot(p,q)); }

double sec(double d) { return min(1.0, max(0.0, d)); }

point circumcenter(point a, point b, point c) {
    double A = acos(sec(dot(a - b, a - c) / (abs(a - b) * abs(a - c))));
    //double A = arg(a - b, a - c);
    double B = acos(sec(dot(b - a, b - c) / (abs(b - a) * abs(b - c))));
    //double B = arg(b - a, b - c);
    double C = acos(sec(dot(c - a, c - b) / (abs(c - a) * abs(c - b))));
    //double C = arg(c - a, c - b);
    double D = sin(2 * A) + sin(2 * B) + sin(2 * C);
    
    if (D < EPS) return point(INF, INF);
    return (sin(2 * A) * a + sin(2 * B) * b + sin(2 * C) * c) / D;
}

int main() {
    int n;
    cin >> n;
    vector<point> ps(n);
    for (int i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y;
        ps.at(i).real(x);
        ps.at(i).imag(y);
    }
    
    double min_r = INF;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                point c = circumcenter(ps.at(i), ps.at(j), ps.at(k));
                if (c.real() == INF) continue;
                
                double max_r = 0;
                for (point p: ps) chmax(max_r, abs(c - p));
                chmin(min_r, max_r);
            }
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            point c = (ps.at(i) + ps.at(j)) / 2.0;
            if (c.real() == INF) continue;
            
            double max_r = 0;
            for (point p: ps) chmax(max_r, abs(c - p));
            chmin(min_r, max_r);
        }
    }

    printf("%.10lf\n", min_r);
}   

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;


#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz(x)           (int)x.size()
#define db(x)           cout<<x<<"\n";

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

	
//////////////////////////////code//////////////////////////////

void solve()
{
   // cout << "-------------------" << "\n";
    
    int n;
    cin>>n;
    
    int temp = 0;
    
    for(int i=1;i<=50000000;i++)
    {
        temp = (temp*10+7)%n;
        
        if(temp == 0)
        {
            cout<<i;
            return;
        }
    }
    
    db(-1)
  
 

 //   cout << "-------------------" << "\n";

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

    int t = 1;
  //  cin >> t;

    while (t--)
        solve();

}

// check out for following mistakes-
// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only
// is using prime sieve make sure it fits
// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values


Measured memory_bytes: 3608