akhauriyash/Code-Regression huggingface dataset:
//BISMILLAH
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,n,x,flag=0,res,choto,boro,lower;
    cin>>a>>b>>n;
    if(n<b-1) //ei x er jonnoi max value pabo, eitai x er amon man j b er kacher choto value
    {
        cout<< floor(a*n/b)-a*floor(n/b)<<endl;
    }
    else if(b-1<n)// mane x>b case :  x  er amon man khujbo ja b er kacher choto . jehutu x>b thle x er kacher choto hobe b er 1 kom
    {
        choto=b-1; //kacher choto always b-1 hobe
        cout<< floor(a*choto/b)-a*floor(choto/b)<<endl;
    }
    else cout<< floor(a*n/b)-a*floor(n/b)<<endl;
    return 0;
}


Measured memory_bytes: 3776
import java.util.Scanner;


class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		
		ReversePolishNotation(scanner);
		
		scanner.close();
	}
	
	public static enum Operator
	{
		plus(43),
		times(42),
		minus(45);
		
		private final int mark;
		
		private Operator(final int mark) {
			this.mark = mark;
		}
		
		public int getInt(){
			return this.mark;
		}
	}
	public static Operator getMark(final int id) {
		Operator[] marks = Operator.values();
		for (Operator type : marks) {
			if (type.getInt() == id) {
				return type;
			}
		}
		return null;
	}

	public static void ReversePolishNotation(Scanner scanner ){ // N個の要素を含む0-オリジンの配列A
		String num;
		int sub;
		int array_num[] = new int[100];
		int count = 0;
		int count_num = 0;
		int i;
		byte[] oper = new byte[200];
		
		
		while( scanner.hasNext() ){
			num = scanner.next();
			try {
				oper = num.getBytes("US-ASCII");
			} catch (Exception e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		
			sub = (int)oper[0];
			
			if(sub < 42 || sub > 45){
				array_num[count_num] = Integer.parseInt(num);
				count_num ++;
			
			}else{
				count_num -= 2;
				if( count_num >= 0 ){
					switch( getMark(sub) ) {
						case plus:
							array_num[count_num] = array_num[count_num] + array_num[count_num + 1];
							count_num ++;
							break;
						case times:
							array_num[count_num] = array_num[count_num] * array_num[count_num + 1];
							count_num ++;
							break;
						case minus:
							array_num[count_num] = array_num[count_num] - array_num[count_num + 1];
							count_num ++;
					}
				}else {
					break;
				}
			
			count ++;
			}
		
		}
		System.out.println(array_num[0]);
	}
}


Measured memory_bytes: 26256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int X = 1e6;

//head

int n, q, m, m_;
int c[X];
int l[X], r[X];
int ans[X];
int cnt[X];
vector<tuple<int, int, int> > a[int(1e3)];

bool co1(tuple<int, int, int> &a, tuple<int, int, int> &b) {
  return get<1>(a) < get<1>(b);
}
bool co2(tuple<int, int, int> &a, tuple<int, int, int> &b) {
  return get<2>(a) < get<2>(b);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> q;
	rep(i, n) cin >> c[i];
	rep(i, q) cin >> l[i] >> r[i];
	m = sqrt(n);
	m_ = (n+m-1)/m;
	rep(i, q) {
		l[i]--;
		r[i]--;
		int lh = l[i]/m;
		a[lh].emplace_back(l[i], r[i], i);
	}
	rep(i, m_) {
		if(a[i].empty()) continue;
		int kin = 0;
		memset(cnt, 0, sizeof(cnt));
		sort(all(a[i]), co1);
		for(int j = get<0>(a[i][0]); j <= get<1>(a[i][0]); j++) {
			if(!cnt[c[j]]) kin++;
			cnt[c[j]]++;
		}
		ans[get<2>(a[i][0])] = kin;
		for(int j = 1; j < a[i].size(); j++) {
			int l, r, ii;
			tie(l, r, ii) = a[i][j];
			int lh, rh;
			tie(lh, rh, ignore) = a[i][j-1];
			if(lh < l) {
				for(int k = lh; k < l; k++) {
					cnt[c[k]]--;
					if(!cnt[c[k]]) kin--;
				}
			} else {
				for(int k = l; k < lh; k++) {
					if(!cnt[c[k]]) kin++;
					cnt[c[k]]++;
				}
			}
			for(int k = r; k > rh; k--) {
				if(!cnt[c[k]]) kin++;
				cnt[c[k]]++;
			}
			ans[ii] = kin;
		}
	}

	rep(i, q) {
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 24412
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

MOD = 10 ** 4 + 7

N = int(input())
k = 1
while True:
    if N * k % 360 == 0:
        print(k)
        break
    k += 1

Measured memory_bytes: 9308
#include<stdio.h>
#define min(a,b) a<b?a:b
#define max(a,b) a>b?a:b
int main()
{
    int n,m,a,b,mx=0,mn=1e6;
    scanf("%d%d",&n,&m);
    while(m--)
    {
        scanf("%d%d",&a,&b);
        mx=max(mx,a);
        mn=min(mn,b);
    }
    printf("%d\n",max(mn-mx+1,0));
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {

	var N, M int
	fmt.Scan(&N, &M)
	sum := 0

	votesList := make([]int, 0, N)
	for i := 0; i < N; i++ {
		var votes int
		fmt.Scan(&votes)
		sum += votes
		votesList = append(votesList, votes)
	}

	count := 0
	border := float64(sum) / (4.0 * float64(M))
	for i := 0; i < N; i++ {
		if float64(votesList[i]) >= border {
			count++
		}
	}

	if count >= M {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

const int mod = 1000000007;
// const int mod = 998244353;

struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<vector<int>> sum;
    sum.resize(n + 1, vector<int>(60));

    rep(i, 60) sum[0][i] = 0;

    rep(i, n)
    {
        rep(j, 60)
        {
            sum[i + 1][j] = sum[i][j];
            if (a[i] & (ll(1) << j))
                ++sum[i + 1][j];
        }
    }

    mint ans = 0;
    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j < 60; ++j)
        {
            int length = n - i;
            int num = sum[n][j] - sum[i][j];
            mint bit = (ll(1) << j);
            if (a[i - 1] & (ll(1) << j))
                ans += bit * (length - num);
            else
                ans += bit * num;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 87600
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl;}
void soutl(ll x) { cout << x << endl;}
void outs(string x) { cout << x << endl;}
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
//---------------------------------------------------------------

int main() {
	int n;
	cin >> n;
	int p[55];
	rep(i, n) cin >> p[i];

	int k = 0;
	rep(i, n) {
		if (p[i] != i + 1) {
			k++;
		}
	}

	if (k <= 2) outs("YES");
	else outs("NO");
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	while(1){
	int H, W;
	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++) {
		    if((i + j) % 2 == 0) printf("#");
			else printf(".");
		}
		printf("\n");
	}
	printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;
int main(){
  static const double pi = 3.141592653589793;
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double Atheta = 2*pi/12*(h-3+m/60);
  double Btheta = 2*pi/60*(m-15);
  double ax = a*cos(Atheta);
  double ay = a*sin(Atheta);
  double bx = b*cos(Btheta);
  double by = b*sin(Btheta);
  double dist2 = (ax-bx)*(ax-bx)+(ay-by)*(ay-by);
  cout << setprecision(20) << sqrt(dist2) << endl;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    st s ;
    lli s1 , s2 ;
    cin >> s ;
    s1 = (s[0] - '0') * 10 + (s[1] - '0') ;
    s2 = (s[2] - '0') * 10 + (s[3] - '0') ;

    if ((s1 > 12 || s1 < 1 )&& (s2 >= 1 && s2 <= 12))
        cout << "YYMM" << endl ;
    else if ((s1 >= 1 && s1 <= 12) && (s2 > 12 || s2 < 1))
        cout << "MMYY" << endl ;
    else if ((s1 > 12 || s1 < 1) && (s2 > 12 || s2 < 1) )
        cout << "NA" << endl ;
    else if ((s1 >= 1 && s1 <= 12 )&& (s2 >= 1 && s2 <= 12))
        cout << "AMBIGUOUS" << endl ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

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

  int N, K;

  while (cin >> N >> K) {
    int cnt[26];
    memset(cnt, 0, sizeof(cnt));
    
    for (int i = 0; i < N; i++) {
      string s;
      cin >> s;
      cnt[s[0] - 'A']++;
    }

    int ans = 0;
    
    while (true) {
      sort(cnt, cnt + 26);
      int rem = K;

      for (int i = 25; rem > 0 && i >= 0; i--) {
        if (cnt[i] > 0) {
          cnt[i]--;
          rem--;
        }
      }

      if (rem == 0) {
        ans++;
      } else {
        break;
      }
    }

    cout << ans << endl;
  }
}


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

double dist(int x, int y){
	double distance;
	distance = sqrt(pow(x, 2) + pow(y, 2));
	return distance;
}

int main(){
	int N, D;
	cin>>N>>D;
	int count = 0;
	int a[N][2];
	for(int i = 0; i<N; i++){
		cin>>a[i][0]>>a[i][1];
		if(dist(a[i][0], a[i][1])<= D){
			count++;
		}
	}
	cout<<count;
	return 0;
	
}

Measured memory_bytes: 5216
#include <stdio.h>

int main(int argc, char **argv){
	int i;
	int len,data[100];

	// Input
	scanf("%d",&len);
	for(i=0;i<len;i++){
		scanf("%d",data+i);
	}
	// Output
	for(i=len-1;i>=0;i--){
		if( i==0){
			printf("%d\n",data[i]);
		} else {
			printf("%d ",data[i]);
		}
	}
	
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=powerm(2,n);
    //cout<<ans<<endl;
    ll prod=1;
    fr(i,0,a)
    {
        prod*=(n-i);
        prod%=mod;
    }
    fr(i,1,a+1)
    {
        prod*=powerm(i,mod-2);
        prod%=mod;
    }
    ans-=prod;
    ans+=mod;
    ans%=mod;
    prod=1;
    fr(i,0,b)
    {
        prod*=(n-i);
        prod%=mod;
    }
    fr(i,1,b+1)
    {
        prod*=powerm(i,mod-2);
        prod%=mod;
    }
    ans-=prod;
    ans+=mod;
    ans-=1;
    ans%=mod;
    cout<<ans%mod<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  double x, y, arg;
  ST(double x, double y, double arg):x(x),y(y),arg(arg){}
};
bool operator<(const ST& a, const ST& b){
  return a.arg < b.arg;
}


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

  vector<ST> v;
  rep(i,N){
    int a, b;
    cin >> a >> b;
    if(a == 0 && b == 0){
      v.emplace_back((double)a,(double)b,0);
    }else{
      v.emplace_back((double)a,(double)b,atan2(b,a));
    }
  }
  sort(ALLOF(v));
  //rep(i,N){
  //  cout << " " << v[i].x << " " << v[i].y << " " << v[i].arg << endl;
  //}
  
  vector<ST> w;
  rep(i,N){
    w.push_back(v[i]);
  }
  rep(i,N){
    w.push_back(v[i]);
  }
  
  double ret = 0.0;
  
  rep(i,w.size()){
    double sumx = 0, sumy = 0;
    REP(j,i,i+N){
      sumx += w[j].x;
      sumy += w[j].y;
      ret = max(ret, sqrt(sumx*sumx + sumy*sumy));
    }
  }
  
  printf("%.12lf\n", ret);
  
  return 0;
}



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

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a == b) {
        if (a == c) cout << "No" << endl;
        else cout << "Yes" << endl;
    } else if (b == c) cout << "Yes" << endl;
    else if (a == c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int H = sc.nextInt(), W = sc.nextInt();
            if(H==0 && W==0) {
                break;
            }
            for(int i=0; i<H; i++) {
                for(int j=0; j<W; j++) {
                    System.out.printf(i==0 || i==H-1 || j==0 || j==W-1 ? "#" : ".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


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

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

	if(d==0){
		if(n==100)
			cout<<101<<endl;
		else
		cout<<n<<endl;
	}else if(d==1){
		if(n==100)
			cout<<10100<<endl;
		else
			cout<<n*100<<endl;
	}else if(d==2){
		if(n==100)
			cout<<1010000<<endl;
		else
			cout<<n*10000<<endl;
	}else{
		return 0;
	}
} 

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    s = input()
    t = input()
    ans = len(t)
    for i in range(len(s)-len(t)+1):
        cnt = 0
        for j in range(len(t)):
            if s[i+j] != t[j]:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
import java.util.Scanner;

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

		long mod = 1000000007;
		long[] cnt = new long[26];
		for (int i = 0; i < N; i++) {
			cnt[S.charAt(i) - 'a']++;
		}
		long ans = 1;
		for (long i : cnt) {
			ans = (i+1)*ans%mod;
		}
		ans -= 1;
		System.out.println(ans);
	}
}


Measured memory_bytes: 25700
#include <algorithm>
#include <cstdio>
#include <climits>
#include <vector>
using namespace std;

int main() {
    while(true) {
        int w,h; scanf("%d%d", &w, &h);
        if(w==0) break;

        int n; scanf("%d", &n);
        static int xComp[2002], yComp[2002];
        static int x1s[2000], y1s[2000], x2s[2000], y2s[2000];
        xComp[0] = 0;
        xComp[1] = w;
        yComp[0] = 0;
        yComp[1] = h;
        for(int i = 0; i < n; i++) {
            scanf("%d%d%d%d", x1s+i, y1s+i, x2s+i, y2s+i);
            xComp[2+i*2+0] = x1s[i];
            xComp[2+i*2+1] = x2s[i];
            yComp[2+i*2+0] = y1s[i];
            yComp[2+i*2+1] = y2s[i];
        }
        sort(xComp, xComp+2+n*2);
        sort(yComp, yComp+2+n*2);
        int xCompLen = unique(xComp, xComp+2+n*2)-xComp;
        int yCompLen = unique(yComp, yComp+2+n*2)-yComp;
        int cw = lower_bound(xComp, xComp+xCompLen, w)-xComp;
        int ch = lower_bound(yComp, yComp+yCompLen, h)-yComp;
        static int tim[2010][2010];
        for(int x = 0; x <= cw; x++)
            for(int y = 0; y <= ch; y++)
                tim[x][y] = 0;
        for(int i = 0; i < n; i++) {
            int x1 = lower_bound(xComp, xComp+xCompLen, x1s[i])-xComp;
            int y1 = lower_bound(yComp, yComp+yCompLen, y1s[i])-yComp;
            int x2 = lower_bound(xComp, xComp+xCompLen, x2s[i])-xComp;
            int y2 = lower_bound(yComp, yComp+yCompLen, y2s[i])-yComp;
            tim[x1][y1]++;
            tim[x1][y2]--;
            tim[x2][y1]--;
            tim[x2][y2]++;
        }
        for(int x = 0; x < cw; x++)
            for(int y = 0; y < ch; y++)
                tim[x][y] += (y>0?tim[x][y-1]:0)+(x>0?tim[x-1][y]:0)-(y>0&&x>0?tim[x-1][y-1]:0);
        int cnt = 0;
        for(int x = 0; x < cw; x++) {
            for(int y = 0; y < ch; y++) {
                if(tim[x][y]) continue;
                cnt++;
                static int q[2010*2010];
                int qs=0,qe=0;
                q[qe++] = y*cw+x;
                tim[x][y] = 1;
                while(qs<qe) {
                    int cur_x = q[qs]%cw;
                    int cur_y = q[qs]/cw;
                    qs++;
                    if(0<cur_x && !tim[cur_x-1][cur_y]) {
                        tim[cur_x-1][cur_y] = 1;
                        q[qe++] = cur_y*cw+(cur_x-1);
                    }
                    if(0<cur_y && !tim[cur_x][cur_y-1]) {
                        tim[cur_x][cur_y-1] = 1;
                        q[qe++] = (cur_y-1)*cw+cur_x;
                    }
                    if(cur_x+1<cw && !tim[cur_x+1][cur_y]) {
                        tim[cur_x+1][cur_y] = 1;
                        q[qe++] = cur_y*cw+(cur_x+1);
                    }
                    if(cur_y+1<ch && !tim[cur_x][cur_y+1]) {
                        tim[cur_x][cur_y+1] = 1;
                        q[qe++] = (cur_y+1)*cw+cur_x;
                    }
                }
            }
        }
        printf("%d\n", cnt);
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
// 	cout<<"GfG!";
ll n,h,i;
cin>>n;
ll mi=n;
for(i=1;i<=sqrt(n);i++)
{
    if(n%i==0)
    {
        h=(i+(n/i)-2);
        mi=min(h,mi);
    }
}
cout<<mi<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int h,w,n;
int x[1<<18],y[1<<18];
pair<int,int>X[1<<18];
main()
{
	cin>>h>>w>>n;
	int ans=h;
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i];
		X[i]=make_pair(x[i],y[i]);
	}
	sort(X,X+n);
	int nowx=1,nowy=1;
	for(int i=0;i<n;i++)
	{
		while(nowx+1<X[i].first)nowx++,nowy++;
		if(nowx>=X[i].first)continue;
		if(nowx+1==X[i].first&&nowy>=X[i].second)
		{
			cout<<nowx<<endl;
			return 0;
		}
		else if(nowx+1==X[i].first&&nowy+1==X[i].second)nowx++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[10001];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];
    int cnt=0;
    rep(i,n){
        while(a[i]%2==0){
            a[i]/=2;
            ++cnt;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[200005];
ll dsu_sz[200005];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
void merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return;
 
    if(dsu_sz[root1]>dsu_sz[root2]){
    dsu_arr[root2]=root1;
    dsu_sz[root1]+=dsu_sz[root2];
    }
    else
    {
         dsu_sz[root2]+=dsu_sz[root1];
        dsu_arr[root1]=root2;
    }
    
}


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

for(ll i=0;i<m;i++)
{
    ll u,v;
    cin>>u>>v;
    merge(u,v);
}
ll ans=0;
set<ll>roots;
for(ll i=1;i<=n;i++)
{
    roots.insert(dsu_arr[i]);
}

for(auto it=roots.begin();it!=roots.end();it++)
{
    ans=max(ans,dsu_sz[*it]);
}
cout<<ans<<endl;


}



   
      
    
        



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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}


int main() {
  int A, B;
  cin >> A >> B;
  cout << max({A + B, A + A - 1, B + B - 1}) << endl;
}





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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, x, d;
    scanf("%d %d %d", &n, &x, &d);
    if (d == 0) {
        if (x == 0) {
            return printf("1"), 0;
        }
        return printf("%d", n + 1), 0;
    }
    ll res = 0;
    map <int, vector <pair <ll, ll> > > mp;
    for (int i = 0; i <= n; i++) {
        ll mn = (ll)i * x + (ll)i * (i - 1) / 2 * d;
        ll mx = (ll)i * x + (ll)i * (n + n - i - 1) / 2 * d;
        if (mn > mx) swap(mn, mx);
        mp[((mn%abs(d))+abs(d))%abs(d)].pb({mn, mx});
    }
    auto it = mp.begin();
    while (it != mp.end()) {
        sort(it->se.begin(), it->se.end());
        /*printf("%d: ", x.fi);
        for (auto y : x.se) {
            printf("%lld %lld\n", y.fi, y.se);
        }*/
        ll hold = -9e18, mx = hold, mn;
        for (auto y : it->se) {
            if (mx == hold) {
                mn = y.fi;
                mx = y.se;
                continue;
            }
            if (y.fi > mx) {
                res += (mx - mn) / abs(d) + 1;
                mn = y.fi;
                mx = y.se;
            } else {
                mx = max(mx, y.se);
            }
        }
        res += (mx - mn) / abs(d) + 1;
        it++;
    }
    printf("%lld", res);
    return 0;
}

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

int main(){
int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  if(a[0] == 5 && a[0]==a[1] && a[2] == 7){
  cout<<"YES";
  }
  else{
  cout<<"NO";
  }
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
 
int main(void) {
   int a, b, c, d, e, k;
   cin >> a >> b >> c >> d >> e >> k;
   if(abs(a - b) <= k && abs(a - c) <= k && abs(a - d) <= k && abs(a - e) <= k){
       if(abs(b - c) <= k && abs(b - d) <= k && abs(b - e) <= k){
           if(abs(c - d) <= k && abs(c - e) <= k){
               if(abs(d - e) <= k){
                   cout << "Yay!" << endl;
               }else{
                   cout << ":(" << endl;
               }
           }else{
               cout << ":(" << endl;
           }
       }else{
           cout << ":(" << endl;
       }
   }else{
       cout << ":(" << endl;
   }
    return 0;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  vector<int> t(3);
  rep(i, 3) cin >> t[i];
  sort(t.begin(), t.end());
  pr(t[0] * t[1] / 2);
  return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

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

    int happy = 1000 * (x / 500);
    x -= 500 * (x / 500);
    happy += 5 * (x / 5);
    cout << happy << endl;

    return 0;
}


Measured memory_bytes: 256
#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 N;
long long dp[100050];

int main()
{
  cout << fixed << setprecision(10);
  int N,M;
  cin >> N >> M;
  vector<int> a(M);
  rep(i,M) cin >> a[i];
  rep(i,100010) dp[i] = 0;
  rep(i,M) dp[a[i]] = -1;
  dp[0] = 1;
  if(M==0||a[0]!=1)
  {
    dp[1] = 1;
  }
  else
  {
    dp[1] = 0;
  }
  for(int i=2;i<N+1;i++)
  {
    if(dp[i]!=-1)
    {
      dp[i] = dp[i-2] + dp[i-1]; 
    }
    else
    {
      dp[i] = 0;
    }
    dp[i] = dp[i]%P;
  }
  cout << dp[N]%P << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstring>
#include <cmath>

using namespace std;

int main(){

 int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
 string s; 
  cin >> s;
  int dis=1;
  
  if(c>d){
    for(int i=b-1;i<d;i++)
      if(s[i-1]=='.'&& s[i]=='.'&& s[i+1]=='.'){
      dis=1;
        break;
      }
      else{
      dis=0;
      }
  }
  
  
  int e;
  
  e=max(c,d);
  
  for(int i=a-1;i<e-1;i++){
    if(s[i]=='#'&& s[i+1]=='#'){
      dis=0;
    }
  }
  
  
  
  if(dis){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
 
int N, a, b, c[100000], res[100000];
ll ans;
bool vis[100000];
priority_queue<int>q;
vector<int>v[100000];
 
void dfs(int x) {
	vis[x] = true;
	res[x] = q.top();
	ans += q.top();
	q.pop();
	for (int i : v[x]) {
		if (!vis[i]) {
			dfs(i);
		}
	}
}
 
 
int main() {
	cin >> N;
	for (int i = 1; i < N; ++i) {
		cin >> a >> b; --a; --b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for (int i = 0; i < N; ++i) {
		cin >> c[i];
		q.push(c[i]);
	}
	ans = -q.top();
	dfs(0);
	cout << ans << endl;
	for (int i = 0; i < N; ++i) {
		cout << res[i];
		if(i!=N-1)cout << ' ';
		else cout << endl;
	}
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define int long
using namespace std;
using pi=pair<int,int>;
main(){
  int h,w,n,s=0,k=0;
  cin>>h>>w>>n;
  vector<pi> v;
  map<int,int> r;
  while(n--){
    int x,y;
    cin>>x>>y;
    x--;y--;
    for(int i=-1;i<=1;++i)for(int j=-1;j<=1;++j)if(0<x+i&&x+i<h-1&&0<y+j&&y+j<w-1)v.emplace_back(x+i,y+j);
  }
  sort(v.begin(),v.end());
  v.emplace_back(-1,-1);
  n=v.size();
  for(int i=0,c=0;i<n;++i){
    if(!i){c++;k=1;continue;}
    if(v[i]==v[i-1])c++;
    else r[c]++,c=1,k++;
  }
  k--;
  cout<<(h-2)*(w-2)-k<<"\n";
  for(int i=1;i<=9;++i)cout<<r[i]<<"\n";
}

Measured memory_bytes: 18664
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int N, M;

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

    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> s(M);
    REP(i, M) {
        cin >> k.at(i);
        REP(j, k[i]) {
            int t;
            cin >> t;
            s[i].push_back(t);
        }
    }
    vector<int> p(M);
    REP(i, M) cin >> p.at(i);

    int ans = 0;
    REP(bit, 1 << N) {
        int flag = true;
        REP(i, M) {
            int on = 0;
            REP(j, k[i]) {
                if (bit & (1 << (s[i][j] - 1))) on++;
            }
            if (on % 2 != p[i]) {
                flag = false;
                break;
            }
        }
        if (flag) ans++;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    for(int i=0;i<=n-3;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
      int N;
	  cin >> N;
  	  
  	  int A[N+1];
  	  for(int i=0;i<N;i++){
        cin >> A[i];
      }
  
  	  int max = 0, min =1000000001;
  
 	  for(int i=0; i<N; i++){
        if(max < A[i])
          max = A[i];
        if(min > A[i])
          min = A[i];
      }
     
  	  cout << max - min <<endl;
  

    }
        

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

using namespace std;

template<typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template<typename T> void read(T &x)
{
	x = 0;
	char c = getchar();
	bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int n, k;
vector<int> p, q;

vector<int> operator + (vector<int> a, vector<int> b)
{
	vector<int> c(n+1);
	for(int i=1; i<=n; i++) c[i] = a[b[i]];
	return c;
}

vector<int> operator * (vector<int> a, int num)
{
	vector<int> c(n+1), vis(n+1);
	for(int i=1; i<=n; i++)
	{
		if(vis[i]) continue;
		int x = i;
		vector<int> loop;
		while(!vis[x])
		{
			loop.push_back(x);
			vis[x] = 1;
			x = a[x];
		}
		for(int j=0; j<loop.size(); j++) c[loop[j]] = a[loop[(j+num-1+loop.size())%loop.size()]];
	}
	return c;
}

vector<int> rev(vector<int> a)
{
	vector<int> c(n+1);
	for(int i=1; i<=n; i++) c[a[i]] = i;
	return c;
}

void print(vector<int> a)
{
	for(int i=1; i<=n; i++) printf("%d ", a[i]);
	putchar('\n');
}

int main()
{
	read(n), read(k), k--;
	p.resize(n+1), q.resize(n+1);
	for(int i=1; i<=n; i++) read(p[i]);
	for(int i=1; i<=n; i++) read(q[i]);
	int pre = k/6;
	vector<int> id(n+1);
	for(int i=1; i<=n; i++) id[i] = i;
	auto l = (q+rev(p)+rev(q)+p)*pre;
	switch (k % 6)
	{
	case 0:
		print(l+p+rev(l));
		break;
	case 1:
		print(l+q+rev(l));
		break;
	case 2:
		print(l+q+rev(p)+rev(l));
		break;
	case 3:
		print(l+q+rev(p)+rev(q)+rev(l));
		break;
	case 4:
		print(l+q+rev(p)+rev(q)+p+rev(q)+rev(l));
		break;
	case 5:
		print(l+q+rev(p)+rev(q)+p+p+rev(q)+rev(l));
		break;
	default:
		break;
	}
	return 0;
}

Measured memory_bytes: 9028
#include <iostream>

using namespace std;

int main(){
    bool numbers[10001];
    for(int i=0; i<10001; i++) {
        numbers[i] = false;
    }
    numbers[2] = true;
    numbers[3] = true;
    for(int i=5; i<10001; i+=2) {
        if(i % 3 != 0)
            numbers[i] = true;
    }
    int p = 5;
    int num = 0;
    while(true) {
        while(true) {
            if(numbers[p]) break ;
            p++;
        }
        for(int i=10000; i>0; i--) {
            if(!numbers[i]) {
                num = i;
                break ;
            }
        }
        if(p*p > num) break ;
        for(int i=p+1; i<10001; i++) {
            if(i % p == 0) numbers[i] = false;
        }
        p++;
    }

    int n;
    while(cin >> n, n != 0) {
        for( ; n>=5; n--) {
            if(numbers[n] && numbers[n-2]) {
                cout << n - 2 << " " << n << endl;
                break ;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    string s;
    cin >> s;
    if ((s[2] == s[3]) && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

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

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

int main() 
{
    fastio();

    ll n,k;
    cin>>n>>k;

    cout<<min( mod(n,k), k - mod(n,k) ),nl;    

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 256
N,W=map(int,input().split())
wv=[[0,0]]+[list(map(int,input().split())) for _ in range(N)]

dp=[[10**11+1 for i in range(100*10**3+1)] for j in range(N+1)]

dp[0][0]=0

for i in range(1,N+1):
    for j in range(100*10**3+1):
        dp[i][j]=dp[i-1][j]
        if j - wv[i][1] >= 0:
            dp[i][j]=min(dp[i][j],dp[i-1][j-wv[i][1]]+wv[i][0])

            
res=0
for i in range(100*10**3+1):
    if dp[N][i]<=W:
        res=i
            
print(res)


Measured memory_bytes: 173576
#import copy
N = int(input())
a = []
s = []
for i in range(N):
    a.append(int(input()))
    tmp = []
    for j in range(a[i]):
        tmp.append(list(map(int,input().split())))
    s.append(tmp)
#print(a)
#print(s)
def dfs(i,honest):
    if i==N:
        #print(honest)
        for h in honest:
            for j in range(a[h-1]):
                #print("{},{},{}".format(s[a[h-1]][j][0],s[a[h-1]][j][1],j))
                if s[h-1][j][1] == 1:
                    if s[h-1][j][0] not in honest:
                        return 0
                else:
                    if s[h-1][j][0] in honest:
                        return 0
        return len(honest)
    return max([dfs(i+1, honest+[i+1]),dfs(i+1, honest)])

print(dfs(0,[]))


Measured memory_bytes: 3064
def examB():
    St = S()
    N = len(St)
    is_evenl = True
    cur = 0
    for i in range((N-1)//2):
        is_evenl = True
        for j in range(i+1):
            if St[j]!=St[i+j+1]:
                is_evenl = False
#                print(j, i + j + 1)
        if is_evenl:
            cur = (i+1)*2
    print(cur)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 3444
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX_H 100
#define MAX_W 100
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int H, W;
char a[MAX_H][MAX_W];

void putline()
{
  for (int i = 0; i < W + 2; i++) cout << "#";
  cout << endl;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> H >> W;
  REP(i, H) REP(j, W) cin >> a[i][j];

  putline();
  REP(i, H)
  {
    cout << "#";
    REP(j, W) cout << a[i][j];
    cout << "#" << endl;
  }
  putline();

  return 0;
}


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

void main_()
{
    int D, N;
    cin >> D >> N;

    cout << (N + (N == 100 ? 1 : 0)) * static_cast<int>(pow(100, D)) << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
//29
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int n;
  cin>>n;
  while(n--){
    int h,m;
    (cin>>h).ignore()>>m;
    double hh=h/12.+m/60./12;
    double mm=m/60.;
    double d=fabs(hh-mm);
    if(d>.5){
      d=1-d;
    }
    if(d<30./360){
      cout<<"alert"<<endl;
    }else if(d<90./360){
      cout<<"warning"<<endl;
    }else{
      cout<<"safe"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
N, K = map(int, input().split())
A = list(map(int, input().split()))

ma = [-1] * N
ma[0] = 0
now = 1
ne = 0

hazi = -1
for i in range(K):
    ne = A[ne] - 1
    if ma[ne] >= 0:
        hazi = ma[ne]
        break

    ma[ne] = now
    now += 1

if hazi == -1:
    print(ne + 1)
    exit()

ans = (K - hazi) % (now - hazi)

for i in range(ans):
    ne = A[ne] - 1

print(ne + 1)

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

int main(){
  int n;
  int C[50];
  int V[50];
  cin >> n;
  for(int i = 0; i < n; i++){
    int elemv;
    cin >> elemv;
    V[i] = elemv;
  }
  for(int i = 0; i < n; i++){
    int elemc;
    cin >> elemc;
    C[i] = elemc;
  }

  int m = 0;
  for(int i = 0; i < n; i++){
    if(V[i] > C[i]){
      m += V[i] - C[i];
    }
  }
  cout << m << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=2e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
}
int n,a[N];
void input()
{
	n=read<int>();
	For(i,1,n)a[i]=read<int>();
}
ll ans;
void work()
{
	if(a[1]){puts("-1");return;}
	For(i,2,n)if(a[i]>a[i-1]+1){puts("-1");return;}
	
	int j;
	For(i,1,n)
	{
		for(j=i;j<n&&a[j+1]==a[j]+1;j++);
		ans+=a[j];i=j;
	}
	write(ans,'\n');
}
int main()
{
	//file();
	input();
	work();
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int K;
  cin >> K;
  int ans = -1;
  int modK = 7 % K;
  if (modK == 0)
    cout << 1 << endl;
  else
  {
    for (int i = 1; i < K; i++)
    {
      modK = ((modK * 10) % K + 7) % K;
      if (modK == 0) {
        ans = i + 1;
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3632