akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
   int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
   
   long int min=999999999999999999;
   for(int i=0;i<=x;i++){
        long int sum=0;
        int k=(x-i)*2;
        int j=y-k/2;
        if(j<0) j=0;
        sum+=a*i+b*j+c*k;
        if(min>sum){
            min=sum;
        }
   }
    for(int j=0;j<=y;j++){
        long int sum=0;
        int k=(y-j)*2;
        int i=x-k/2;
        if(i<0) i=0;
        sum+=a*i+b*j+c*k;
        if(min>sum){
            min=sum;
        }
    }
    cout <<min<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template < typename T > std::string to_string( const T& n ){
	std::ostringstream stm ;
	stm << n ;
	return stm.str() ;
}


int main(void){
	char s,s_,s__;
	int sum = 0;while(true){
	while(s!=10){
		s__ =s_;
		s_=s;
		scanf("%c",&s);
		sum += s-48;
	}
	if(s__==0&&s_==48&&s==10)break;
	printf("%d\n",sum+38);
	s = 0;
	sum = 0;
	}
	return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <cstdio>
#include <deque>
#include <algorithm>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <stack>

using namespace std;
int n;
double a[1001];
double T, A;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n;
	cin >> T >> A;
	int idx = -1;
	double ans = -1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		double cnt = T - a[i] * (double)0.006;
		if (i == 0 || ans > abs(A - cnt)) {
			ans = abs(cnt - A);
			idx = i;
		}
	}
	cout << idx + 1 << '\n';


}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);

ll mod = 998244353;
template<typename T> void add(T &a,T b){a=(a+b)%mod;}
template<typename T> void sub(T &a,T b){a=(a+mod-b)%mod;}

ll dp[333][333][333];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    string s;
    int k;
    cin>>s>>k;
    int n = s.size();
    int sum[n+1]={};
    int z = 0;
    int o = 0;
    for(int i=0;i<n;i++){
        if(s[i] == '0'){
            z++;
            sum[z+1] = sum[z];
        }
        else o++;
        sum[z+1] = o;
    }
    
    dp[0][0][0] = 1;
    for(int i=0;i<z;i++){
        for(int y=0;y<=min(k,o);y++){
            for(int j=sum[i];j<=min(o,sum[i]+k);j++){
                for(int p=max(j,sum[i+1]);p<=min(sum[i+1]+k,o);p++){
                    ll ret = dp[i][j][y];
                    int cnt = y;
                    int dif = p - j;
                    dif -= sum[i+1] - sum[i];
                    dif = max(0,dif);
                    cnt += dif;
                    if(cnt <= k){
                        add(dp[i+1][p][cnt],ret);
                    }
                }
            }
        }
    }
    ll ans = 0;
    for(int i=sum[z];i<=o;i++){
        for(int y=0;y<=min(o,k);y++){
            add(ans,dp[z][i][y]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 33608
#include <bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX
#define LINF LLONG_MAX
#define mod 1000000007
#define pie 3.141592653589793238462643383279
#define P pair<int,int>
#define prique priority_queue
#define F first
#define S second
using namespace std;
signed main(){
	string s;
	cin>>s;
	cout<<s.substr(0,4)<<" "<<s.substr(4,8)<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,S=0,n;cin>>N;n=N;
  while(n>0){
    S+=n%10;n/=10;
  }
  if(N%S==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
    int n, m;
    int p[1000];
    int i, j;
    int t;
    int sum;
    
    while (1){
        scanf ("%d%d", &n, &m);
        if (n == 0 && m == 0){
            break;
        }
        memset(p, 0, sizeof(p));
        for (i = 0; i < n; i++){
            scanf("%d", &p[i]);
        }
        
        for (i = 0; i < n; i++){
            for (j = 0; j < n - 1; j++){
                if (p[j] < p[j + 1]){
                    t = p[j];
                    p[j] = p[j + 1];
                    p[j + 1] = t;
                }
            }
        }
        
        sum = 0;
        for (i = 0; i < n; i++){
            if (i % m != m - 1){
                sum += p[i];
            }
        }
        printf("%d\n", sum);
    }
    
    return (0);
}

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

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

    sort(a.begin(),a.end());

    double ans=0.0;
    ans=((double)a[0]+a[1])/2.0;

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

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-10;

int elementaryMatrix(vector<vector<double> >& mat)
{
    const int n = mat.size();
    const int m = mat[0].size();
    int y = 0;
    int x = 0;
    while(y < n && x < m){
        int tmp = y;
        for(int i=y+1; i<n; ++i){
            if(abs(mat[i][x]) > abs(mat[tmp][x]))
                tmp = i;
        }
        if(abs(mat[tmp][x]) > EPS){
            mat[y].swap(mat[tmp]);
            for(int i=y+1; i<n; ++i){
                for(int j=m-1; j>=x; --j){
                    mat[i][j] -= mat[y][j] * (mat[i][x] / mat[y][x]);
                }
            }
            ++ y;
        }
        ++ x;
    }
    mat.resize(y);
    return y;
}

bool linearSystem(vector<vector<double> >& mat, vector<double>& x)
{
    int n = mat[0].size() - 1;
    if(elementaryMatrix(mat) != n || mat[n-1][n-1] == 0)
        return false;

    x.resize(n);
    for(int i=n-1; i>=0; --i){
        x[i] = mat[i][n];
        for(int j=i+1; j<n; ++j)
            x[i] -= mat[i][j] * x[j];
        x[i] /= mat[i][i];
    }
    return true;
}

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

    vector<vector<int> > edges(n);
    for(int i=0; i<m; ++i){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    vector<vector<double> > prob(1<<n);
    prob[(1<<n)-1] = vector<double>(n, 0.0);

    for(int i=(1<<n)-2; i>0; --i){
        vector<vector<double> > mat(n, vector<double>(n+1, 0.0));
        for(int j=0; j<n; ++j)
            mat[j][j] = mat[j][n] = 1.0;

        for(int j=0; j<n; ++j){
            for(unsigned k=0; k<edges[j].size(); ++k){
                int next = edges[j][k];
                bitset<10> bs(i);
                if(bs[next]){
                    mat[j][next] = -1.0 / edges[j].size();
                }else{
                    bs[next] = true;
                    mat[j][n] += prob[bs.to_ulong()][next] / edges[j].size();
                }
            }
        }

        linearSystem(mat, prob[i]);
    }

    printf("%.10f\n", prob[1][0]);

    return 0;
}

Measured memory_bytes: 1364
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

const int INF = 1e9;

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

int H, W;
VV a;
set<P> dead;
int ans;

bool inside(int x, int y) {
    return 0 <= x && x < H && 0 <= y && y < W;
}

void dfs(int x, int y, int c) {
    if (c > 10) return;

    rep(k, 4) {
        int nx = x + dx[k], ny = y + dy[k];
        if (!inside(nx, ny)) continue;
        if (a[nx][ny] == 1 && !dead.count(P(nx, ny))) continue;
        while (true) {
            if (!inside(nx, ny)) break;
            if (a[nx][ny] == 1 && !dead.count(P(nx, ny))) {
                dead.insert(P(nx, ny));
                dfs(nx - dx[k], ny - dy[k], c + 1);
                dead.erase(P(nx, ny));
                break;
            }
            else if (a[nx][ny] == 3) {
                ans = min(ans, c);
                break;
            }

            nx += dx[k], ny += dy[k];
        }
    }
}

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

    while (cin >> W >> H, H) {
        a.clear();
        a.resize(H, V(W));
        int sx, sy;
        rep(i, H) rep(j, W) {
            cin >> a[i][j];
            if (a[i][j] == 2) {
                sx = i, sy = j;
            }
        }

        dead.clear();
        ans = INF;
        dfs(sx, sy, 1);

        cout << (ans == INF ? -1 : ans) << endl;
    }
}

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

int main() {
	int a;
	int b;
	int c;
	int count;
	
	cin >> a;
	cin >> b;
	cin >> c;
	
		
	int i=1;
	for(i=a;i<=b;i++){
		if(c%i == 0) {
			count++;
		}
	}
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<map>
#include<queue>
#include<stack>

using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int a,x=0,y=0,ou=0;
        for(int i=0; i<n; i++)
        {
            scanf("%d",&a);
            if(a%4==0)
                y++;
            else
            {
                if(a%2==0)
                    ou++;
                else
                    x++;
            }

        }
        if(ou==0)
        {
            if(x>y+1)
                printf("No\n");
            else
                printf("Yes\n");
        }
        else
        {
            if(ou==1)
            {
                if(x<=y&&y>0)
                    printf("Yes\n");
                else
                    printf("No\n");
            }
            else
            {
                if(x<=y)
                    printf("Yes\n");
                else
                    printf("No\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner scan = new Scanner(System.in);
		
		int r = scan.nextInt();
		int c = scan.nextInt();
		
		int A[][] = new int[r][c];
		// ?????????????´?
		for(int i=0; i<r; i++){
			for(int i2=0; i2<c; i2++){
				int x = scan.nextInt();
				A[i][i2] = x;
			}
		}
		// ??????
		int total = 0;
		for(int i=0; i<r; i++){
			int sumr = 0;
			for(int i2=0; i2<c; i2++){
				System.out.print(A[i][i2] + " ");
				sumr = sumr + A[i][i2];
			}
			System.out.println(sumr);
			total = total + sumr;
		}
		for(int i=0; i<c; i++){
			int sumc = 0;
			for(int i2=0; i2<r; i2++){
				sumc = sumc + A[i2][i];
			}
			System.out.print(sumc + " ");
		}
		System.out.println(total);
			
		
	}

}

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

void solve(int n, int m){
	int v[m+1][1300];
	for(int i=0; i<m+1; ++i)
		for(int j=0; j<1300; ++j)
			v[i][j] = 0;
	int r, q;
	cin >> r;
	for(int i=0; i<r; ++i){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if(d == 1) ++v[c][a];
		else --v[c][a];
	}
	for(int i=1; i<m+1; ++i)
		for(int j=1; j<1300; ++j)
			v[i][j] += v[i][j-1];
	cin >> q;
	for(int i=0; i<q; ++i){
		int a, b, c;
		cin >> a >> b >> c;
		int ans = 0;
		for(int j=a; j<b; ++j)
			if(v[c][j] > 0)
				++ans;
		cout << ans << "\n";
	}
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int n, m;
		cin >> n >> m;
		if(n == 0 && m == 0) return 0;
		solve(n, m);
	}
}


Measured memory_bytes: 52276
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int N, a;
    int p = 0, q = 0, r = 0;
    cin >> N;
    rep(i, N) {
        cin >> a;
        a %= 4;
        if(a == 0) {
            r++;
        } else if(a == 2) {
            q++;
        } else {
            p++;
        }
    }
    if(q > 0) p++;
    cout << (p <= r + 1 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B;
  cin >> A >> B;
  int Bhalf = B / 2;
  if (A <= 5) {
    cout << 0 << endl;
  }
  else if (A >= 13) {
    cout << B << endl;
  }
  else {
	cout << Bhalf << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    string S, T; cin >> S >> T;
    sort(ALL(S));
    sort(ALL(T), greater<char>());
    if(S < T) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
a=0
b=0
for i in range(n//2):
  a+=max(x)
  x.remove(max(x))
  b+=max(x)
  x.remove(max(x))

if n%2:
  a+=x[0]
dif=a-b
print(dif)

Measured memory_bytes: 38256
#include<stdio.h>
int main(void){
  int a,i,j,k,x,y,n;
  y=0;
  while(1){
  scanf("%d%d",&n,&x);
  if(n==0&&x==0)break;
  for(i=1;i<=n-2;i++){
    for(j=i+1;j<=n-1;j++){
      for(k=j+1;k<=n;k++){
	a=i+j+k;
	if(a==x){
	  y++;
	}
      }
    }
  }
  printf("%d\n",y);
y=0;
    }
    return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
#define N_MAX 10
#define D_MAX 10

int isSquare(int n){
    int k = 0;
    while(k * k < n) k ++;
    return (k * k == n);
}
int main(void){
    // Your code here!
    int x[N_MAX * D_MAX];
    int n,d;
    scanf("%d %d", &n, &d);
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < d; j ++) scanf("%d", x + i*d + j);
    }
    
    int num = 0;
    for(int j = 1; j < n; j ++){
        for(int i = 0; i < j; i ++){
            int distance = 0;
            for(int k = 0; k < d; k ++){
                int dif = x[i*d+k] - x[j*d+k];
                distance += dif * dif;
            }
            if (isSquare(distance)) num ++;
        }
    }
    printf("%d", num);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>

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

int main() {
	int N;
	int A[100000];
	cin >> N;
	int i;
	int min = 1000000001;
	int nextmin = -1;
	int k = -1, m = -1;
	int sum = 1;
	rep(i, N) {
		cin >> A[i];
		if (min > A[i]) {
			min = A[i];
			k = i;
		}
		
	}
	while(sum>0){
		sum = 0;
		nextmin = min;
		m = k;
		rep(i, N) {
			if (i == k)continue;
			A[i] %= min;
			sum += A[i];
			if (nextmin > A[i] && A[i]!=0) {
				nextmin = A[i];
				m = i;
			}
		}
		min = nextmin;
		k = m;
	}
	cout << min;
	return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int x,y,i,cnt,b;
	cnt=0;
	scanf("%d %d",&x,&y);
	for(i=1;i<x;i++){
		if(i*y%x==0){
			cnt++;
		}
	}
	b=x+y-cnt;
	printf("%d\n",b);
	return 0;
}


Measured memory_bytes: 2760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aman Kumar Singh
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APassword solver = new APassword();
        solver.solve(1, in, out);
        out.close();
    }

    static class APassword {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            pn((int) Math.pow(ni(), 3));

        }

        int ni() {
            return in.nextInt();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new UnknownError();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

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

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n;
  cin >> n;
  n--;
  cout << ((n/111) + 1)*111 << endl;
}

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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pii pair<int, pi>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 3001

signed main()
{
  int a , b , c ;
  cin >> a >> b >> c ;
  cout << c << " " << a << " " << b << endl ;
  return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef long double ld;

const int N = 100006;


int main() {

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

    ll n;

    cin >> n;

    ll x = 7 % n;

    for(int i = 1; i <= 1e7; i++) {

        if(x == 0) {
            cout << i << '\n';
            return 0;
        }

        x = x * 10 + 7;
        x %= n;

    }
    
    cout << "-1\n";
    
    return 0; 
}


Measured memory_bytes: 3624
use std::cmp;
use std::collections::BTreeSet;

const INF: usize = 1e16 as usize;

fn main() {
    let sc = std::io::stdin();
    let mut sc = Scanner { reader: sc.lock() };
    let n: usize = sc.read();
    let p: Vec<usize> = sc.read_vec(n - 1);
    let x: Vec<usize> = sc.read_vec(n);

    let mut graph = vec![vec![]; n];
    for i in 1..n {
        let parent = p[i - 1] - 1;
        graph[i].push(parent);
        graph[parent].push(i);
    }

    if dfs(0, 0, &graph, &x) < INF {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}

fn dfs(v: usize, p: usize, tree: &Vec<Vec<usize>>, x: &Vec<usize>) -> usize {
    if tree[v].len() == 1 && v != 0 {
        return 0;
    }

    let mut set: BTreeSet<(usize, usize)> = BTreeSet::new();
    set.insert((0, 0));
    for &next in tree[v].iter() {
        if next != p {
            let mut next_set = BTreeSet::new();
            let black = x[next];
            let white = dfs(next, v, tree, x);
            for &(b, w) in set.iter() {
                next_set.insert((b + black, w + white));
                next_set.insert((w + black, b + white));
            }
            set = next_set;
        }
    }

    let min1 = set
        .iter()
        .filter(|&&(_, y)| y <= x[v])
        .map(|&(x, _)| x)
        .min()
        .unwrap_or(INF);
    let min2 = set
        .iter()
        .filter(|&&(y, _)| y <= x[v])
        .map(|&(_, y)| y)
        .min()
        .unwrap_or(INF);
    cmp::min(min1, min2)
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8444
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type point struct {
	X, Y       int
	IsSelected bool
}

type pointList []point

type redList struct{ pointList }
type blueList struct{ pointList }

func (a pointList) Len() int      { return len(a) }
func (a pointList) Swap(i, j int) { a[i], a[j] = a[j], a[i] }

func (a redList) Less(i, j int) bool  { return a.pointList[i].Y > a.pointList[j].Y }
func (a blueList) Less(i, j int) bool { return a.pointList[i].X < a.pointList[j].X }

func isClose(red, blue point) bool {
	if red.X < blue.X && red.Y < blue.Y {
		return true
	}
	return false
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	R, B := redList{make(pointList, N)}, blueList{make(pointList, N)}
	for i := 0; i < N; i++ {
		R.pointList[i].X, R.pointList[i].Y = scanInt(), scanInt()
	}
	for i := 0; i < N; i++ {
		B.pointList[i].X, B.pointList[i].Y = scanInt(), scanInt()
	}
	sort.Sort(R)
	sort.Sort(B)

	ans := 0
	for _, blue := range B.pointList {
		for i, red := range R.pointList {
			if isClose(red, blue) && !red.IsSelected {
				ans++
				R.pointList[i].IsSelected = true
				break
			}
		}
	}

	fmt.Println(ans)
}


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll V, E;
struct Edge {
    ll from, to, cost;
};
vector<Edge> Edges;

//通常
struct UnionFind {
    VL par, rank;
    UnionFind(int size) { init(size); }
    void init(int size) {
        par.clear();
        rank.clear();
        REP(i, size) {
            par.push_back(i);
            rank.push_back(0);
        }
    }
    int root(int x) {
        if(par[x] == x)
            return x;
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) {
            swap(x, y);
        } else {
            if(rank[x] == rank[y]) rank[x]++;
        }
        par[y] = x;
    }
    bool same(int x, int y) { return root(x) == root(y); }
};

signed main() {
    while(1) {
        cin >> V >> E;
        if(V == 0 && E == 0) break;
        REP(i, E) {
            LCIN(s, t, w);
            Edges.push_back({s, t, w});
        }
        sort(All(Edges),
             [](const Edge &x, const Edge &y) { return x.cost < y.cost; });
        auto uf = UnionFind(V);
        ll ans = 0;
        REP(i, E) {
            Edge e = Edges[i];
            if(!uf.same(e.from, e.to)) {
                uf.unite(e.from, e.to);
                ans += e.cost;
            }
        }
        cout << ans << "\n";
        Edges.clear();
    }
}



Measured memory_bytes: 3088
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;
 
int N;
LL A[100000];
 
int ans = 0;
 
void solve(){
	vector<vector<LL>> seq;//各数列を保管
	map<LL,queue<int>> seq_end;//例えばseq[5]の末尾が27ならseq_end[27]={5}
	multiset<LL> seq_tail_set;//各数列の末尾の数字を昇順に保管する

	seq.push_back(vector<LL>(1,A[0]));
	seq_end[A[0]].push(0);
	seq_tail_set.insert(A[0]);
	for(int i=1;i<N;i++){
		// cout <<endl <<  "------" << endl;
		// cout << "=now seqs=" << endl;
		// for(int i=0;i<seq.size();i++){
		// 	for(int j=0;j<seq[i].size();j++) cout << seq[i][j] << " ";
		// 	cout << endl;
		// }
		// cout << "==tail set==" << endl;
		auto nearest = seq_tail_set.lower_bound(A[i]);
		// for(auto val:seq_tail_set) cout << val << " ";
		// 		cout << endl;
		// cout << "==========" << endl;
		// printf("A[%d]=%lld\n",i,A[i]);
		if(nearest==seq_tail_set.begin() && (*nearest)>=A[i]){
			seq.push_back(vector<LL>(1,A[i]));
			seq_end[A[i]].push(seq.size()-1);
			seq_tail_set.insert(A[i]);
		}else{
			nearest--;
			int target_num = *nearest;
			// cout << "target_num=" << target_num << endl;
			int target_seq = seq_end[target_num].front();
			seq_end[target_num].pop();
			seq[target_seq].push_back(A[i]);
			seq_end[A[i]].push(target_seq);
			seq_tail_set.insert(A[i]);
			seq_tail_set.erase(seq_tail_set.find(target_num));//一個だけ消す
		}
	}
	// cout << "------" << endl;
	// 	for(int i=0;i<seq.size();i++){
	// 		for(int j=0;j<seq[i].size();j++) cout << seq[i][j] << " ";
	// 		cout << endl;
	// 	}
	ans = seq.size();
}
 
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
 
	solve();
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 81840
s = gets
a = gets.split.map! {|x| x.to_i}
b = gets.split.map! {|x| x.to_i}
d = []
minus = 0
c = 0
a.size.times { |i|
  v = a[i] - b[i]
  d << v
  if (v < 0)
    minus += v
    c += 1
  end
}
d.sort!
i = d.size - 1
while (minus < 0) and (i != -1)
  minus += d[i]
  i -= 1
  c += 1
end
if i < 0
  puts -1
else
  puts c
end

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back

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

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

//library----------------------------------------------

int main() {
    CIN(N,K);
    vector<ll> h(N);
    rep(i,N)cin>>h[i];
    sort(all(h));
    ll ans=0;
    if(N>K){
        rep(i,N-K) ans+=h[i];
    }
    printf("%lld\n",ans);
    return 0;
}

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

int main(int argc, char **argv)
{
  int N;
  long long W;
  cin >> N >> W;
  vector<int> value[4];
  long long w0;
  for (int i = 0; i < N; ++i) {
    int w, v;
    cin >> w >> v;
    if (i == 0) w0 = w;
    value[w - w0].push_back(v);
  }

  // for (int i = 0; i < 4; ++i)
  //   cout << value[i].size() << endl;

  for (int i = 0; i < 4; ++i) {
    sort(value[i].begin(), value[i].end(), greater<int>());
  }

  // for (int i = 0; i < 4; ++i)
  //   cout << value[i].size() << endl;

  int maxValue = 0;
  for (int n1 = 0; n1 <= value[0].size(); ++n1) {
    for (int n2 = 0; n2 <= value[1].size(); ++n2) {
      for (int n3 = 0; n3 <= value[2].size(); ++n3) {
        for (int n4 = 0; n4 <= value[3].size(); ++n4) {
          if (w0*n1 + (w0+1)*n2 + (w0+2)*n3 + (w0+3)*n4 > W) continue;
          int sum = 0;
          for (int j = 0; j < n1; j++) {
            sum += value[0][j];
          }
          for (int j = 0; j < n2; j++) {
            sum += value[1][j];
          }
          for (int j = 0; j < n3; j++) {
            sum += value[2][j];
          }
          for (int j = 0; j < n4; j++) {
            sum += value[3][j];
          }
          // cout << sum << endl;
          maxValue = (sum > maxValue) ? sum : maxValue;
        }
      }
    }
  }
  cout << maxValue << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        
        if(k%2 == 0){
            long x = 0;
            long y = 0;
            for(int i = 1; i <= n; i++){
                if(i%k == 0){
                    x++;
                }else if(i%k == k/2){
                    y++;
                }
            }
            System.out.println(x*x*x + y*y*y);
        }else{
            long x = 0;
            for(int i = 1; i <= n; i++){
                if(i%k == 0){
                    x++;
                }
            }
            System.out.println(x*x*x);
        }
    }
}

Measured memory_bytes: 21588
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                continue
            if l[k] < l[i] + l[j]:
                ans += 1
print(ans)


Measured memory_bytes: 9180
import math

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


def enough(T):
    atack = B * T
    diff = A - B
    count = 0
    for i in h:
        tmp = math.ceil((i - atack) / diff)
        if tmp > 0:
            count += tmp

    return count<=T


def tree():
    low = 0
    high = 10 ** 9
    while high - low > 1:
        mid = (low + high) // 2
        if enough(mid):
            high = mid
        else:
            low = mid
    return high


print(tree())


Measured memory_bytes: 7124
h, w = 66, 65
a, b = map(int,input().split())

c = [['#' if i < h//2 else '.']*w for i in range(h)]

for i in range(a-1):
    c[i//((h-1)//2)*2+1][i%((h-1)//2)*2+1] = '.'
for i in range(b-1):
    c[i//((h-1)//2)*2+h//2+1][i%((h-1)//2)*2+1] = '#'


print(h,w)
for i in range(h):
    for j in range(w):
        print(c[i][j],end='')
    print()


Measured memory_bytes: 3828
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * What is the Most Popular Shop in Tokaichi?
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		short[] sales = null;
		short sale, idx, max;
		while (!(line = br.readLine()).equals("0 0")) {
			sales = new short[5];

			sale = Short.parseShort(line.substring(0, line.indexOf(' ')));
			sale += Short.parseShort(line.substring(line.indexOf(' ') + 1));
			sales[0] = max = sale;
			idx = 0;

			for (short i = 1; i < 5; i++) {
				line = br.readLine();
				sale = Short.parseShort(line.substring(0, line.indexOf(' ')));
				sale += Short.parseShort(line.substring(line.indexOf(' ') + 1));
				sales[i] = sale;
				if (sale > max) {
					max = sale;
					idx = i;
				}
			}
			System.out.println((char) (idx + 'A') + " " + max);
		}

	}

}

Measured memory_bytes: 17104
#include<map>
#include<set>
#include<list>
#include<ctime>
#include<cmath>
#include<deque>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define Rep(i,s,t) for(register int i=s;i<t;++i)
#define go(x) for(register int e=las[x];e;e=nxt[e])
#define re register
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define insert is
#define erase es
#define pii pair<int,int>
#define ms(f,x) memset(f,x,sizeof f)
#define mc(f,x) memcpy(f,x,sizeof f)
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define gi(x) read(x)
#define gii(x,y) read(x),read(y)
#define giii(x,y,z) read(x),read(y),read(z)
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]);return;
    }
}
using IO::read;
using IO::write;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
int n,cnt,ans;
const int N=1e6+11;
int a[N];
int main(){
	gi(n);
	rep(i,1,n)
		gi(a[i]);
	rep(i,1,n+1)
		if(a[i]==a[i-1])
			++cnt;
		else{
			ans+=cnt/2;
			cnt=1;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include<algorithm>
#include <queue>
#include <cmath>
#include <limits>
#include <map>
using namespace std;
//i番目以下にある最も近いiのところまで砕く
int main(){
  int n;
  cin >> n;
  int brick[n+1];
  for (int i = 1; i <= n; i++){
    cin >> brick[i];
  }
  int broke = 0;
  int count = 1;
  for (int i = 1; i <= n; i++){
    if(brick[i]==count){
      count++;
    }else{
      broke++;
    }
  }
  if(n==broke&&count==1)
    broke = -1;
  cout << broke << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
string s;
int ans,ansi;
int main(){	
	cin>>s;
	for(int i=0;i<3;i++){
		if(s[i]=='R')
			ansi++;
		if(ansi>=ans)
			ans=ansi;
	}
	if(s=="RSR")
		ans--;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main()
{
	int i, j,k, N, A[2][100],sum[100],S;
	cin >> N;
	/*アメを配置*/
	for (i = 0; i < 2; i++)
	{
		for (j = 0; j < N; j++)
		{
			cin >> A[i][j];
		}
	}
	/*全探索*/
		for (j = 0; j < N; j++)
		{
			sum[j] = 0;
			for (k = 0; k < N; k++)
			{
				if (k < j)
					sum[j] += A[0][k];
				else if (k == j)
					sum[j] += A[0][k] + A[1][k];
				else
					sum[j] += A[1][k];
			}
		}
		/*比較*/
		S = sum[0];
		for (j = 0; j < N; j++)
		{
			if (S < sum[j])
				S = sum[j];
			else
				S = S;
		}
		cout << S<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

def lcm(n, m):
    return n * m // gcd(n, m)

L = A[0]
for a in A:
    L = lcm(L, a)

ans = 0
for a in A:
    ans += L // a

print(ans % MOD)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

vector<int> solve(int n,int a,int b) {
	if (__builtin_popcount(a^b)%2==0) return {};
	
	if (n==1) return {a,b};

	int bit=1<<(n-1);
	if ((a&bit)==(b&bit)) {
		auto r1=solve(n-1,a,b);
		auto r2=solve(n-1,a^bit,r1[1]^bit);
		r1.insert(r1.begin()+1,r2.begin(),r2.end());
		return r1;
	} else {
		auto r1=solve(n-1,a,b^1^bit);
		auto r2=solve(n-1,b^1,b);
		r1.insert(r1.end(),r2.begin(),r2.end());
		return r1;
	}
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N,A,B;
	cin>>N>>A>>B;
	
	auto res=solve(N,A,B);
	if (res.empty()) {
		cout<<"NO\n";
	} else {
		cout<<"YES\n";
		for (int x:res) cout<<x<<" ";
		cout<<"\n";
	}
}


Measured memory_bytes: 1648
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cmath>
#include <limits>
#include <math.h>
#include <cassert>

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

// べき乗

ll mod_pow(ll x, ll n)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * x % INF;
        x = x * x % INF;
        n >>= 1;
    }
    return res;
}

int main()
{
    int N;
    cin >> N;
    int c = 0;
    int a, b;
    bool flag = false;
    REP(i, N)
    {
        if (scanf("%d %d", &a, &b) == 1)
        {
        }
        if (a == b)
        {
            c++;
        }
        else
        {
            c = 0;
        }

        if (c == 3)
        {
            if (!flag)
                flag = true;
        }
    }
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

//

Measured memory_bytes: 3744
# coding: utf-8


def solve(*args: str) -> str:
    n, m, k = map(int, args[0].split())
    mod = 998244353

    if m == 1 and n-1 == k:
        return str(1)

    iR = [1]*(k+1)
    C = [1]*(k+1)
    for i in range(1, k+1):
        iR[i] = max(1, (-(mod//i) * iR[mod % i]) % mod)
        C[i] = (n-i)*C[i-1]*iR[i] % mod

    ret = 0
    p = m*pow(m-1, n-1-k, mod) % mod
    for i in range(1, k+1):
        ret += p*C[-i] % mod
        p = p*(m-1) % mod
    ret += p

    return str(ret % mod)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

#define ll long long
#define mp make_pair
#define rep(i, a, b) for(int i = (a);i <= (b);i++)
#define per(i, a, b) for(int i = (a);i >= (b);i--)

using namespace std;

typedef pair<int, int> pii;
typedef double db;
const int N = 1e6 + 50;
int n, k, a[N], cnt = 0, flag = 0; 
int ans = 0, maxx, minn, pmax, pmin;
int vis[N], f[N];
priority_queue < int, vector<int>, greater<int> > q;
priority_queue < int, vector<int>, less<int> > p;
inline int read(){
	int x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-') f = -1; ch = getchar();}
	while(ch >='0' && ch <='9'){x = (x<<3)+(x<<1)+(ch^48); ch = getchar();}
	return x*f;
}
void init(){
	cin >> n >> k;
	rep(i, 1, n) cin >> a[i];
	rep(i, 1, k){
		p.push(a[i]); q.push(a[i]);
	}
	rep(i, 2, n){
		if(a[i] > a[i-1]){
			int sum = 0;
			while(a[i] > a[i-1] && i <= n){
				i++;
				sum++;
			}
			if(sum >= k-1){
				cnt ++;
			}
		}
	}
	ans = n-k+1;
	int l = 1, r = k;
	while(r <= n){
		r++;
		if(r > n) break;
		while(vis[q.top()]) q.pop(); 
		while(f[p.top()]) p.pop();
		if(a[l] == q.top() && a[r] > p.top()){
			q.pop(); p.push(a[r]);
			q.push(a[r]);
			f[a[l]] = 1;
			ans --;
		}
		else if(a[l] == q.top() && a[r] < p.top()){
			q.pop(); p.push(a[r]);
			q.push(a[r]);
			f[a[l]] = 1;
		}
		else if(a[l] == p.top()){
			p.pop(); p.push(a[r]);
			q.push(a[r]);
			vis[a[l]] = 1;
		}
		else if(a[l] != q.top() && a[l] != p.top()){
			p.push(a[r]); q.push(a[r]);
			f[a[l]] = 1, vis[a[l]] = 1;
		}
		l++;
	}
	if(!cnt) printf("%d\n", ans);
	else printf("%d\n", ans - cnt+1);
}
int main(){
//	freopen("input.in","r",stdin);
//	freopen("output.out","w",stdout);
	init();
	return 0;
}
/*
10 5
1 8 3 2 4 6 7 5 9 10
*/

Measured memory_bytes: 10996
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T; cin >> T;
    rep(casenum, T){
        string a; cin >> a;
        int n = a.size();
        set<string> train;
        train.insert(a);
        REP(i, 1, n){
            string b = "", c = "";
            rep(j, i) b += a[j];
            REP(j, i, n) c += a[j];
            train.insert(c + b);
            reverse(b.begin(), b.end());
            train.insert(b + c);
            train.insert(c + b);
            reverse(c.begin(), c.end());
            train.insert(b + c);
            train.insert(c + b);
            reverse(b.begin(), b.end());
            train.insert(b + c);
            train.insert(c + b);
        }
        cout << train.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
#include <immintrin.h>
#include <omp.h>

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x)(x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


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

  cout << (n-1)/2 << endl;


  return 0;
}


Measured memory_bytes: 256
/*input
5 3
10 30 40 50 20
*/
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long 
#define vl vector<ll> 
#define pl pair<ll,ll> 
#define vpl vector<pl> 
#define vvl vector<vl> 
using namespace std;
const ll N = 1e5 +5;
vl t;
ll frog(vl& v,ll n,ll k)
{
   	
   	ll cst;

	t [0] =  0;
	for(ll i = 1;i <= n;i++)
	{	
		ll mn = LONG_MAX;
		for(ll j = 1;j <= k;j++){
			if(i >= j)cst = abs(v[i-j]-v[i])+t[i-j];
			mn = min(mn,cst);
		}
		 t[i] = mn;

	}
	return t[n];

	// if(t[n] != -1)return t[n];
	// if(n == 0)return 0;
	// cst1 = (abs(v[n-1]-v[n])+frog(v,n-1));
	// if(n >= 2){
	// cst2 = (abs(v[n-2]-v[n])+frog(v,n-2));}
	// else cst2 = INT_MAX;
	// return t[n]  = min(cst1,cst2);

	
 
}

int main()

{
	ios_base::sync_with_stdio(false); 
    cin.tie(0); cout.tie(0);
   
   ll n,h,k ;
   vl v;

   cin >> n >> k;
   t.resize(n);
   for(auto x = 0 ;x< n;x++)cin >> h,v.pb(h),t[x] = -1;
  	ll cst =  frog(v,n-1,k);
   cout << cst;


        

  return 0;
   		
}


Measured memory_bytes: 5064
#include <stdio.h>
#include <string.h>

char s[20];

int main(){
	scanf("%s", s);
	int n = strlen(s);
	if(n & 1) puts("No");
	else{
		for(int i=0; i<n; i+=2){
			if(s[i] != 'h' || s[i + 1] != 'i'){
				puts("No");
				return 0;
			}
		}
		puts("Yes");
	}
	return 0;
}


Measured memory_bytes: 128