akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;

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

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

ll mod(ll val, ll M) {
    ll res = val % M;
    if(res < 0) {
        res += M;
    }
    return res;
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    int cnt = vec.at(0);
    for(int i = 1;i < N;i++) {
        cnt = gcd(cnt,vec.at(i));
    }
    vector<int> cnt2(1000000);
    for(int i = 0;i < N;i++) {
        for(int j = 2;j * j <= vec.at(i);j++) {
            if(vec.at(i) % j == 0) {
                cnt2.at(j)++;
                while(vec.at(i) % j == 0) {
                    vec.at(i) /= j;
                }
            }
        }
        if(vec.at(i) != 1) {
            cnt2.at(vec.at(i))++;
        }
    }
    bool ret = true;
    for(int i = 0;i < 1000000;i++) {
        if(cnt2.at(i) >= 2) {
            ret = false;
        }
    }
    if(ret == true) {
        cout << "pairwise coprime" << endl;
    }
    else if(cnt == 1) {
        cout << "setwise coprime" << endl;
    }
    else {
        cout << "not coprime" << endl;
    }
}

Measured memory_bytes: 11180
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n,m,i,j,k;(n=s.nextInt())>0;){long[][][]a=new long[m=s.nextInt()][m][2];long l;for(i=0;i<m;++i)for(j=0;j<m;++j)for(k=0;k<2;++k)a[i][j][k]=Integer.MAX_VALUE;for(;n-->0;a[i][j][1]=a[j][i][1]=s.nextInt())a[i=s.nextInt()-1][j=s.nextInt()-1][0]=a[j][i][0]=s.nextInt();for(n=0;n<m;++n)for(i=0;i<m;++i)for(j=0;j<m;++j)for(k=0;k<2;++k)if(a[i][j][k]>(l=a[i][n][k]+a[n][j][k]))a[i][j][k]=a[j][i][k]=l;for(n=s.nextInt();n-->0;)System.out.println(a[s.nextInt()-1][s.nextInt()-1][s.nextInt()]);}}}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll N,A,B,max,min;
    cin >> N >> A >> B;
    max = B;
    if(A < B)
        max = A;
    min = 0;
    if(N < (A+B))
        min = A + B - N;
    cout << max << " " << min << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main()
{
    int N;  cin >> N;
    ll cnt = 0;
    vector<ll> A(N), B(N);
    for(int i=0; i<N; i++)  cin >> A[i] >> B[i];
    for(int i=N-1; i>=0; i--){
        if((A[i] + cnt) % B[i] != 0){
            cnt += ((A[i] + cnt) / B[i] + 1) * B[i] - A[i] - cnt;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 4844
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        while(true) {
            String line;
            try {
                line = sc.nextLine();
            }catch(Exception e){
                break;
            }
            String[] linesp = line.split(" ");
            double p0x = Double.parseDouble(linesp[0]);
            double p0y = Double.parseDouble(linesp[1]);
            double p1x = Double.parseDouble(linesp[2]);
            double p1y = Double.parseDouble(linesp[3]);
            double p2x = Double.parseDouble(linesp[4]);
            double p2y = Double.parseDouble(linesp[5]);
            double px = Double.parseDouble(linesp[6]);
            double py = Double.parseDouble(linesp[7]);
            
            double Area = 0.5 *(-p1y*p2x + p0y*(-p1x + p2x) + p0x*(p1y - p2y) + p1x*p2y);
            double s = 1/(2*Area)*(p0y*p2x - p0x*p2y + (p2y - p0y)*px + (p0x - p2x)*py);
            double t = 1/(2*Area)*(p0x*p1y - p0y*p1x + (p0y - p1y)*px + (p1x - p0x)*py);
            if((0 < s && s < 1) && (0 < t && t < 1) && (0 < 1-s-t && 1-s-t < 1)) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            } 
        }    
    }
}



Measured memory_bytes: 26796
#include<stdio.h>
int main(){
    int a,b,c,x;
    scanf("%d %d %d", &a,&b,&c);
    if(a > b){
        x = a;
        a = b;
        b = x;
    }
    if(a > c){
        x = a;
        a = c;
        c = x;
    }
    if(b > c){
        x = b;
        b = c;
        c = x;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2108
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            String S = in.next();
            out.println(a >= 3200 ? S : "red");

        }

    }
}



Measured memory_bytes: 22608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a[3] = {};
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[0] == a[1] && a[1] != a[2]) cout << "Yes";
    else if (a[0] != a[1] && a[1] == a[2]) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <queue>


using namespace std;

const int N = 3;

struct Puzzle {
    array<array<int, N>, N> board;
    array<int, 2> empty;
    int turn;

    bool operator < (const Puzzle &p) const {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                if (board[i][j] != p.board[i][j])
                    return board[i][j] < p.board[i][j];
            }
        }
        return false;
    }
};


vector<array<int, 2>> dir = {
    {-1, 0}, // left
    {0, -1}, // up
    {1, 0},  // right
    {0, 1},  // down
};

bool solved(const Puzzle& p) {
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            int x = i == 2 && j == 2 ? 0 : i * 3 + j + 1;
            if (p.board[i][j] != x) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    Puzzle start;
    start.turn = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            int x;
            cin >> x;
            if (x == 0) {
                start.empty = {i, j};
            }
            start.board[i][j] = x;
        }
    }

    Puzzle ans;
    set<Puzzle> visited;
    queue<Puzzle> Q;
    Q.push(start);
    while (!Q.empty()) {
        auto u = Q.front();
        Q.pop();
        if (solved(u)) {
            ans = u;
            break;
        }
        for (auto& d : dir) {
            auto tx = u.empty[0] + d[0];
            auto ty = u.empty[1] + d[1];
            if (tx < 0 || ty < 0 || tx >= N || ty >= N) {
                continue;
            }
            auto v = u;
            swap(v.board[v.empty[0]][v.empty[1]], v.board[tx][ty]);
            v.empty = {tx, ty};
            if (visited.find(v) == visited.end()) {
                ++v.turn;
                visited.insert(v);
                Q.push(v);
            }
        }
    }
    cout << ans.turn << endl;

    return 0;
}


Measured memory_bytes: 20508
import sys
x,n=map(int,input().split())
ans=10000
ansaa=10000
ans1=[]
ans2=[]
ans3=[]
if n>0:
    l=list(map(int,input().split()))
else:
    print(x)
    sys.exit()
for i in range(len(l)):
    if abs(ans-l[i])<ans:
        ans1.append(l[i])
        ans1.append(l[i]-1)
        ans1.append(l[i]+1)
ans1=sorted(ans1)
for j in range(len(ans1)):
    if abs(x-ans1[j])<ans and ans1[j] not in l:
        ans2.append(ans1[j])
        ans=min(ans,x-ans1[j])
print(max(ans2))

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
int main() {
    int k, s, ans = 0;
    cin >> k >> s;
    for(int i = 0; i <= s; i++) {
        for(int j = i; j <= s; j++) {
            if(i <= k && j - i <= k && s - j <= k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); (i)++)
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x, T) sort(ALL(x), greater<(T)>())
#define REVERCE(x) reverce(ALL(x))

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

	int n;

	cin >> n;

	vector<int> len(n);

	REP(i, n) {
		cin >> len[i];
	}

	int cnt = 0;

	SORT(len);

	REP(i, n - 2) {
		REP2(j, i + 1, n - 1) {
			REP2(k, j + 1, n) {
				if (len[k] < len[i] + len[j]) {
					cnt++;
				}
			}
		}
	}

	cout << cnt;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int n,a[20];
int solve(int i, int m){
  if( m==0 ) return 1;
  if( i >= n) return 0;
  int res =solve(i+1,m) || solve(i+1,m-a[i]);
  return res;
}

int main(){
  int q,m,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m )) printf("yes\n");
    else printf("no\n");
  }

  return 0;

}



Measured memory_bytes: 2080
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string S;
    cin >> S;
    string akiba = "AKIHABARA";
    while(S.size() < akiba.size()) {
        rep(i, S.size()) {
            if(S[i] != akiba[i]) {
                S.insert(i, "A");
                break;
            }
            if (i == S.size() - 1) {
                S += "A";
                break;
            }
        }
    }
    if(S == akiba) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.sort()
A.reverse()
cntA = 0
cntB = 0
flag = 0
for a in A:
    if flag == 0:
        cntA += a
        flag = 1
    else:
        cntB += a
        flag = 0
print(cntA-cntB)

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

using ll = long long;
#define rep(n, i) for(ll i = 0; i < n; ++i)

void solve(void){
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;

  ll bottleneck = min(a, min(b, min(c, min(d, e))));
  ll res = (n % bottleneck == 0) ? n / bottleneck : n / bottleneck + 1;

  cout << res + 4 << endl;
}

int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

void solve(long long N) {
  float cnt=0;
  REP(i, N){
    if((i+1)%2==0){}
    else{cnt++;}
  }
  cout<<cnt/(float)N<<endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int tasu(int x)
{
	if (x < 10)
		return x;
	else
		return x % 10 + tasu(x / 10);
}

int main()
{

	int n;
	cin >> n;
	
	if (tasu(n) == 1)
		cout << 10 << endl;
	else
		cout << tasu(n) << endl;
}


Measured memory_bytes: 256
package main                     

import "fmt"

func main() {
  var n int
  fmt.Scan(&n)

  a := make(map[string]struct{})

  for i := 0; i < n; i++ {
    var s string
    fmt.Scan(&s)
    a[s] = struct{}{}

  }


  fmt.Printf("%d\n", len(a))

}


Measured memory_bytes: 512
//
//  main.cpp
//  OnlineJudge
//
//  Created by Shirin on 2020/3/21.
//  Copyright © 2020 SinYun. All rights reserved.
//
#include <bits/stdc++.h>
//
//#include "stdc++.h"
#include <stdio.h>
//#include <iostream>
using namespace std;

int gcd(int m, int n) {
    if(n == 0) {
        return m;
    }
    else {
        return gcd(n, m % n);
    }
}
int main(){
    int n, t, t1;
    int ans = 0;
    scanf("%d", &n);
    int a, b, c = 1;
    for(a = 1; a <= n; a ++){
        for(b = 1; b <= n; b ++){
            for(c = 1; c <= n; c++){
                t = gcd(a, b);
                t1 = gcd(t, c);
                ans = ans + t1;
            }
        }
    }
    printf("%d\n", ans);
}





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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    string S;
    cin >> S;

    const string keyence="keyence";

    if(S==keyence){
        cout << "YES" << endl;
        return;
    }

    rep(i,0,S.size()){
        rep(j,i,S.size()){
            string tmp;
            rep(k,0,S.size()){
                if(i<=k and k<=j) continue;
                tmp+=S[k];
            }
            if(tmp==keyence){
                cout << "YES" << endl;
                return;
            }
        }
    }

    cout << "NO" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

 
int32_t main() {
  ios_base::sync_with_stdio(false);
 int n,d;

  cin >> n;
  d= n%10;
  if(d==2||d==4 ||d==5||d==7||d==9)
  cout << "hon";
  else if(d==0||d==1||d==6||d==8)
  cout <<"pon";
  else
  cout <<"bon";
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int X;
		cin >> X;
		cout << 8 - (X-400)/200 << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


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

#define f first 
#define s second 
#define pb push_back               
#define all(x) x.begin(), x.end())

using namespace std;                    

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

const int N = (int)1e6 + 123, mod = (int)1e9 + 7, inf = (int)1e9, LOG = 18;
const ll INF = (ll)1e8;
const double eps = 1e-9;

int n, a[N], b[N];
bool check(int x){
	for(int i = 1; i <= n; i++)
		if(a[i] <= x)
			b[i] = 0;
		else
			b[i] = 1;
	
	bool ok1, ok2;
	ok1 = 1;         
	ok2 = 1;        
	for(int i = 1; i <= n; i++)
		if(b[i] == i % 2)
			ok1 = 0;
	 	else
			ok2 = 0;
    
    if(ok1 || ok2){
		int cnt = (n + 1) / 2 - 1;
        return b[n/2 + 1] ^ (cnt & 1);
	}
	for(int i = 1; ; i++){
		if(b[n / 2 + 1 + i] == b[n / 2 + 1 - i] && b[n / 2 + 1 + i] != b[n / 2  + i])
			continue;               
		if(b[n / 2 + 1 + i] == b[n / 2  + i])
			return b[n / 2 + 1 + i];
		else
			return b[n / 2 + 1 - i]; 
	}
}
int main(){
	cin >> n;
	n = n + n - 1;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int l = 1, r = n;
	while(l <= r){
		int m = l + r >> 1;
		if(check(m))
			l = m + 1;
		else
			r = m - 1;
	}
	cout << l;
}

Measured memory_bytes: 5120
#include <cstdio>

int dp[5005][5005];
char a[5005];

inline int max(int x, int y) {return x > y ? x : y;}

inline int min(int x, int y) {return x < y ? x : y;}

int main()
{
    int n, ans = 0; 
    scanf("%d", &n); scanf("%s", a);
    for(int i = 1; i < n; i++)
    for(int j = i + 1; j <= n; j++)
    if(a[i - 1] == a[j - 1])
    {
        dp[i][j] = dp[i - 1][j - 1] + 1;
        ans = max(ans, min(j - i, dp[i][j]));
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 96768
def cal(n):
    m = n
    ret = 0
    while n != 0:
        ret += n % 10
        n //= 10
    return m/ret

# n以上で s(n) が最小となる整数値
def f(n):
    cand = []
    s = str(n)
    for i in range(len(s)-1,-1,-1):
        if s[i] == "9":
            continue
        for j in range(int(s[i]), 10):
            t = int(s[:i] + str(j) + s[i+1:])
            cand += [ t ]
        s = s[:i] + "9" + s[i+1:]

    ret = n
    for x in cand:
        if cal(x) < cal(ret):
            ret = x
    return ret 


k = int(input())
ans = 1

for _ in range(k):
    print(ans)
    ans = f(ans+1)


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

a_sum=0
b_sum=0
for i in range(n):
    cnt=0
    max_a=0
    for i in range(n):
        if (a[i]>=max_a):
            max_a=a[i]
            cnt=i
    a_sum = a_sum+a[cnt]
    #print(a_sum,cnt)
    a[cnt]=0
    cnt=0
    max_a=0
    for i in range(n):
        if (a[i]>=max_a):
            max_a=a[i]
            cnt=i
    b_sum = b_sum+a[cnt]
    #print(b_sum)
    a[cnt]=0
print(a_sum-b_sum)
    


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    string S;
    cin >> S;
    
    int count = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'o') {
            count++;
        }
    }
    count=count+15-S.length();
    
    if (count >= 8) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 987654319 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main()
{
	ll n;
	cin >> n;
	ll ans = INF;
	for (ll i = 1; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			ans = min(ans, i + n / i);
		}
	}
	cout << ans - 2;
}


Measured memory_bytes: 256
s = input()
n = len(s)+1
st = 1
lst = []
for i in range(n-2):
  if s[i] == s[i+1]:
    st += 1
  else:
    lst.append([s[i],st])
    st = 1
lst.append([s[n-2],st])
m = len(lst)
ans = [0]*n
now = 0
for l in lst:
  if l[0] == '<':
    for i in range(l[1]+1):
      ans[now+i] = max(i,ans[now+i])
  else:
    for i in range(l[1]+1):
      ans[now+i] = max(l[1]-i,ans[now+i])
  now += l[1]
print(sum(ans))

Measured memory_bytes: 32924
//AtCoder ABC129
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
	vector<ll> tbl(3);
    cin>>tbl[0]>>tbl[1]>>tbl[2];
    sort(tbl.begin(),tbl.end());
    cout<<tbl[0]+tbl[1]<<endl;
	return 0;
}

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K-a[i]:
        j -= 1
    
    ans = max(ans, i+j)
    
print(ans)

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

typedef long long ll;

const int N = 50;
ll K;
ll A[N];

int main(void) {
	cin >> K;
	ll min_val = K / N;
	int stt_idx = (int)(K % N);

	int idx = stt_idx;
	ll val = min_val;
	for (int i = 1; i <= N; ++i) {
		A[idx++] = val++;
		if (idx > N - 1) {
			idx = 0;
			++val;
		}
	}

	cout << N << '\n';
	for (int i = 0; i < N; ++i) {
		cout << A[i];
		if (i == N - 1)
			cout << '\n';
		else
			cout << " ";
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstdlib>
using namespace std;
int N;
long long int a[200005];

int main(){
  long long int sum=0,Min=20002000000000;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a[i];
    sum+=a[i];
  }
  long long int x=0;
  for(int i=0;i<N-1;i++){
    x+=a[i];
    Min=min(Min,abs(x+x-sum));
    
  }
  cout << Min << endl;
  return 0;
}


Measured memory_bytes: 1792
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string myStr = Console.ReadLine();

// 1文字の文字列をchar型へ（その1）
//
char c = myStr[0];
      if (char.IsUpper(c)) {
    Console.WriteLine("A");
}else{
        Console.WriteLine("a");
      }

    
    }
    
  }

}

Measured memory_bytes: 25652
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define cbn(x,y) ((ll)fac[x]*inv[y]%mod*inv[(x)-(y)]%mod)
#define N 1000005
using namespace std;

int n,A,B,C,pw[N],fac[N],inv[N];
int main(){
	scanf("%d%d%d",&A,&B,&C); n=A+B+C;
	fac[0]=inv[0]=inv[1]=pw[0]=1;
	int i;
	for (i=1; i<=n; i++) pw[i]=(ll)pw[i-1]*3%mod;
	for (i=1; i<=n; i++) fac[i]=(ll)fac[i-1]*i%mod;
	for (i=2; i<=n; i++) inv[i]=mod-(ll)inv[mod%i]*(mod/i)%mod;
	for (i=2; i<=n; i++) inv[i]=(ll)inv[i-1]*inv[i]%mod;
	int ans=0,tmp=1;
	for (i=0; i<=B+C; i++){
		if (i){
			tmp=(tmp<<1)%mod;
			if (i>B) tmp=(tmp-cbn(i-1,B)+mod)%mod;
			if (i>C) tmp=(tmp-cbn(i-1,C)+mod)%mod;
		}
		ans=(ans+(ll)pw[B+C-i]*cbn(A-1+i,i)%mod*tmp)%mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 11520
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,K,v;
	while(cin>>N>>M) {
		VI w(M);
		REP(i, N) {
			cin>>K;
			REP(j, K) {
				cin>>v;
				w[v-1]++;
			}
		}
		ll ans = 0;
		REP(i, M) if(w[i]==N) ans++;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    loop {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let mut iter = s.split_whitespace();
        let e: i64 = iter.next().unwrap().parse().unwrap();

        if e == 0 {
            break;
        }

        let mut min_ = 1e8 as i64;
        let mut flag: bool = false;
        for z in 0..101 as i64 {
            for y in 0..1001 as i64 {
                let x = e - z.pow(3) - y.pow(2);
                //println!{"{}, {}, {}", x, y, z};
                if x < 0 {
                    break;
                }
                if min_ > x + y + z {
                    min_ = x + y + z;
                }
            }
        }
        println!("{}", min_);
    }
}


Measured memory_bytes: 5036
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

type Weight = i32;
#[derive(Clone, Debug)]
struct Edge {
    index: usize,
    src: usize,
    dest: usize,
    weight: Weight,
}
impl Edge {
    fn new(index: usize, src: usize, dest: usize, weight: Weight) -> Edge {
        Edge {
            index: index,
            src: src,
            dest: dest,
            weight: weight,
        }
    }
}
type Edges = Vec<Edge>;
type Graph = Vec<Edges>;
fn add_uni_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    *index += 1;
}

fn dfs(g: &Graph, from: usize, visited: &mut Vec<Option<usize>>, start_index: usize) {
    if visited[from] != None { return; }
    visited[from] = Some(start_index);
    for edge in g[from].iter() {
        dfs(g, edge.dest, visited, start_index);
    }
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut g: Graph = vec![vec![]; n];
    let mut edges = vec![];
    let mut visitable = vec![vec![false; n]; n];
    let mut edge_delete_visitable = vec![true; m];
    let mut e = 0;
    for _ in 0..m {
        let mut f: usize = read();
        let mut t: usize = read();
        f -= 1; t -= 1;
        edges.push(Edge::new(e, f, t, 0));
        add_uni_edge(&mut g, &mut e, f, t, 0);
    }
    for from in 0..n {
        let mut min_value = vec![None; n];
        let mut max_value = vec![None; n];
        min_value[from] = Some(0);
        max_value[from] = Some(0);
        for edge in g[from].iter() {
            dfs(&g, edge.dest, &mut min_value, edge.index);
        }
        for edge in g[from].iter().rev() {
            dfs(&g, edge.dest, &mut max_value, edge.index);
        }
        for edge in g[from].iter() {
            edge_delete_visitable[edge.index] = min_value[edge.dest].unwrap() != max_value[edge.dest].unwrap();
        }
        for to in 0..n {
            visitable[from][to] = min_value[to] != None;
        }
    }
    for edge in edges {
        // println!("{} {}", visitable[edge.dest][edge.src], edge_delete_visitable[edge.index]);
        println!("{}", if visitable[edge.dest][edge.src] == edge_delete_visitable[edge.index] { "same" } else { "diff" });
    }
}

Measured memory_bytes: 29460
using System;

namespace abc067A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = A + B;
            if (A % 3 == 0 || B % 3 == 0 || C % 3 == 0)
                Console.WriteLine("Possible");
            else
                Console.WriteLine("Impossible");
        }
    }
}


Measured memory_bytes: 11092
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] chara = str.toCharArray();
		int a = 0;
		int z = 0;
		int ans = 0;
		
		for(int i=str.length()-1; i>=0; i--){
		    if(chara[i]=='A'){
		        a = i;
		    }
		}
		
		for(int i=0; i<str.length(); i++){
            if(chara[i]=='Z'){
                z = i;
            }
		}
		
		System.out.println(z-a+1);
	}
}


Measured memory_bytes: 40876
package main

import (
  "fmt"
)


func main() {
  var a int
  var b int
  var c int
  var n int
  fmt.Scan(&n)
  for _, err := fmt.Scan(&a, &b, &c); err == nil; _, err = fmt.Scan(&a, &b, &c) {
    if a*a == b*b+c*c {
      fmt.Println("YES")
    } else if b*b == c*c+a*a {
      fmt.Println("YES")
    } else if c*c == a*a+b*b {
      fmt.Println("YES")
    } else {
      fmt.Println("NO")
    }
  }
}


Measured memory_bytes: 1176
s = input()
N = len(s)
flag0 = 0
flag1 = 0
A = float("inf")
Z = -float("inf")
for i in range(N):
    t1 = s[i]
    t2 = s[N-1-i]
    if t1 == "A" and flag0 == 0:
        A = i
        flag0 = 1
    if t2 == "Z" and flag1 == 0:
        Z = N-1-i
        flag1 = 1
print(max(0,Z-A+1))

Measured memory_bytes: 41564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, N) for (int i = 0; i < (N); ++i)

int N;
vector<int> graph[100100];

int grundy(int cur, int prv = -1) {
    int ret = 0;
    for (auto& nxt: graph[cur]) {
        if (nxt == prv) continue;
        ret ^= grundy(nxt, cur) + 1;
    }
    return ret;
}

signed main() {
    cin >> N;
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    if (grundy(0)) cout << "Alice" << endl;
    else cout << "Bob" << endl;
}


Measured memory_bytes: 13724
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
const u32 P=1e9+7;
inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}

const int N=25000, K=401;
int n, k, m, a[N], cnt[K];
u32 f[N], g[N], h[K];
void dp(u32 *res, int j0) {
	memset(h, 0, 4*k);
	h[j0]=res[0]=1;
	for(int i=1; i<=n-m; ++i) {
		u32 s=0;
		for(int j=k; --j; ) inc(res[i], h[j]=((k-j+1llu)*h[j-1]+inc(s, h[j]))%P);
	}
}
int main() {
	int pre, suf;
	u32 ans;
	n=rd(), k=rd(), m=rd();
	std::generate(a, a+m, rd);
	ans=power(k, n-m)*(n-m+1)%P;
	for(int i=0, tot=0; i<m; ++i) {
		if(++cnt[a[i]]==1) ++tot;
		if(i>=k&&--cnt[a[i-k]]==0) --tot;
		if(tot==k) {
			printf("%u\n", ans);
			return 0;
		}
	}
	memset(cnt+1, 0, k*sizeof(int));
	for(pre=0; pre<m&&++cnt[a[pre]]==1; ++pre);
	if(pre==m) {
		u32 sub=0;
		f[0]=1;
		for(int i=1; i<=n; ++i) {
			u32 s=0;
			for(int j=k; --j; ) f[j]=((k-j+1llu)*f[j-1]+inc(s, f[j]))%P;
			s=f[0]=0;
			for(int j=k; --j; ) g[j]=((k-j+1llu)*g[j-1]+inc(s, g[j]))%P;
			for(int j=m; j<k; ++j) inc(g[j], f[j]);
		}
		for(int i=1; i<k; ++i) inc(sub, g[i]);
		for(int i=0; i<m; ++i) sub=sub*power(k-i, P-2)%P;
		printf("%u\n", dif(ans, sub));
		return 0;
	}
	memset(cnt+1, 0, k*sizeof(int));
	for(suf=m; ++cnt[a[suf-1]]==1; --suf);
	dp(f, pre);
	dp(g, m-suf);
	for(int i=0; i<=n-m; ++i) ans=(ans+(u64)(P-f[i])*g[n-m-i])%P;
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String str1 = s.next(), t = s.next();
		System.out.println(str1.equals(t.substring(0, t.length() - 1)) ? "Yes" : "No");

	}

}


Measured memory_bytes: 35800
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n ;
string s ;
int main()
{
	IO;
	cin>>s;
	n=s.size();
	for (int i=1; i<n; i++)
	{
		if (s[i]==s[i-1])
			return cout<< i<<" "<<i+1, 0;
		if (i>1&&s[i]==s[i-2])
			return cout<< i-1<<" "<<i+1, 0;
	}
	cout<<-1<<" "<<-1;


}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;
long long A[100000];
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    long long ans = A[0] / 2;
    A[0] = A[0] % 2;
    for(int i = 1; i < N; i++){
        if(A[i] == 0){
            continue;
        }
        ans += (A[i - 1] + A[i]) / 2;
        A[i] = (A[i - 1] + A[i]) % 2;
        //cout << "ans: " << ans << endl;
        
    }
    cout << ans << endl;
    return 0;
}


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

bool isHamming(int x){
  while(x % 2 == 0) x /= 2;
  while(x % 3 == 0) x /= 3;
  while(x % 5 == 0) x /= 5;
  return x == 1;
}

int main(){
  while(1){
    int m, n;
    cin >> m;
    if(m == 0) break;
    cin >> n;

    int ans = 0;

    for(int i = m; i <= n; i++){
      if(isHamming(i)){
        ans++;
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)


int main()
{
    int n,m;cin>>n>>m;
    int a[105], b[105];
    cin >> a[0]>>b[0];
    int amax = a[0]; int bmin = b[0];
    for(int i = 1; i<= n; i++) {
        cin >> a[i];
        amax = max(amax, a[i]);
    }    
    for(int i = 1; i<= m; i++) {
        cin >> b[i];
        bmin = min(bmin, b[i]);
    }
    cout << (amax < bmin ? "No War" : "War") << endl;
    return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> cnt(N+1, 0);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }
    for (int i = 1; i <= N; i++) {
        if (cnt[i]%2==1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=1000000007;
const long long int INF=99999999999999999;


long long int n,m,a[300000],b[300000],c[300000],res=0,cou=1000;
string str;
int main() {
	cout << fixed << setprecision(10);
	cin>>n;
	
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	for(int i=0;i<n-1;i++){
		cin>>c[i];
	}
	for(int i=0;i<n;i++){
		res+=b[a[i]];
		if(a[i]==cou+1){
			res+=c[cou];
		}
		cou=a[i];
	}
	cout<<res<<endl;
} 


Measured memory_bytes: 4352
n,m,x,y = map(int,input().split())
xn = list(map(int,input().split()))
yn = list(map(int,input().split()))
for z in range(-100,102):
    temp1 = 0
    if not(x < z <= y):
        continue
    for i in range(len(xn)):
        if not(xn[i] < z):
            temp1 = 1
            break
    for i in range(len(yn)):
        if not(yn[i] >= z):
            temp1 = 1
            break
    if temp1 == 1:
        continue
    else:
        break
print("War" if z == 101 else "No War")


Measured memory_bytes: 3064
import sys

n = int(input())

"""子情報を入れる'c'、親情報を入れる'p'、深さを記録する'd'の、3つの辞書を作る"""
c, p, d = {}, {}, {}

"""根のid, depthを引数とすることで、全てのnodeの深さを'd'に記録する関数"""
def checkdepth(id, depth):
    d[id] = depth
    for child in c[id]:
        checkdepth(child, depth+1)

for i in sys.stdin:
    i = i.split()
    """i[0]=id, i[1]=k, i[2:]=children"""
    c[i[0]] = i[2:]
    for j in i[2:]:
        p[j] = i[0]

"""親の集合から子の集合を差し引いて残ったものは根（root）になる"""
root = (set(c) - set(p)).pop()
p[root] = '-1'
checkdepth(root, 0)

for i in range(n):
    i = str(i)
    if p[i] == '-1':
        nodetype = 'root'
    else:
        if c[i]:
            nodetype = 'internal node'
        else:
            nodetype = 'leaf'
    children = ', '.join(c[i])
    print('node {}: parent = {}, depth = {}, {}, [{}]'.format(i, p[i], d[i], nodetype, children))


Measured memory_bytes: 44100
import Control.Applicative
import Control.Monad
import Data.Array

f :: Array (Int, Int) Char -> Int -> (Int, Int) -> String
f as m (h, w) = do
    i <- [h .. h + m - 1]
    j <- [w .. w + m - 1]
    return $ as ! (i, j)

main :: IO ()
main = do
    [n, m] <- fmap read . words <$> getLine
    as <- listArray ((1, 1), (n, n)) . concat <$> replicateM n getLine
    bs <- concat <$> replicateM m getLine
    let ps = [(i, j) | i <- [1 .. n - m + 1], j <- [1 .. n - m + 1]]
    if any ((== bs) . f as m) ps
        then putStrLn "Yes"
        else putStrLn "No"

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n, m;
int vis[N], dist[N], ways[N], ans[N];
vector<int> g[N];

void bfs(int k)
{
	queue<int> q;
	q.push(k);
	vis[k] = 1;
	while(!q.empty())
	{
		int node=q.front();
		q.pop();
		for(auto it:g[node])
		{
			if(!vis[it])
			{
				dist[it] = dist[node] + 1;
				vis[it] = 1;
				ans[it] = node;
				q.push(it);
			}
		}
	}
	for(int i = 1; i <= n; i++)
	{
		if(!vis[i])
		{
			cout << "No";
			exit(0);
		}
	}
}


int32_t main()
{
	IOS;
	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	bfs(1);
	cout << "Yes" << endl;
	for(int i = 2; i <= n; i++)
		cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 16992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  while(true) {
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3676
n,p=map(int,input().split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a=factorization(p) 
ans=1
for i in range(len(a)):
    if n<=a[i][1]:
        while a[i][1]>=n:
            ans=ans*a[i][0]
            a[i][1]-=n      
print(ans)

Measured memory_bytes: 9368
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String S = sc.next();
		char[] sInfo = new char[N];
		for(int i = 0; i < N; i++) {
			sInfo[i] = S.charAt(i);
		}

		String[] ans = new String[N];
		int passingPeople = 0;
		int foreignRank = 1;
		for(int i = 0; i < N; i++) {
			if(sInfo[i] == 'c') {
				ans[i] = "No";
			} else if(sInfo[i] == 'a' && passingPeople < A+B) {
				ans[i] = "Yes";
				passingPeople++;
			} else if(sInfo[i] == 'b' && passingPeople < A+B && foreignRank <= B) {
				ans[i] = "Yes";
				passingPeople++;
				foreignRank++;
			} else {
				ans[i] = "No";
			}
		}
		for(int i = 0; i < N; i++) {
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 42116
import sys
input = sys.stdin.readline

def main():
  
  N = int(input())
  ls_H = list(map(int, input().split()))
  
  max_,tmp = 0, 0
  for i,j in zip(ls_H[:-1], ls_H[1:]):
    if i >= j:
      tmp += 1
      if max_ < tmp:
        max_ = tmp
    else:
      tmp = 0
  print(max_)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 14168
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if( a < b ){
        cout<<"a < b"<<endl;
    }else if( a > b ){
        cout<<"a > b"<<endl;
    }else if( a = b ){
        cout<<"a == b"<<endl;
    }
}



Measured memory_bytes: 3096
def main():
    import sys
    def input():
        return sys.stdin.readline()[:-1]
    X=list(map(int,input().split()))
    A=list(map(int,input().split()))
    N=X[0]
    syojikin=1000
    kabu=0
    A.append(-1)
    for i in range(N):
        if A[i]<A[i+1]:
            kabu+=syojikin//A[i]
            syojikin=syojikin%A[i]
        elif A[i]>A[i+1]:
            syojikin+=kabu*A[i]
            kabu=0
    print(syojikin)






if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
# 第一回日本最強プログラマー学生選手権-予選-: A – Takahashi Calendar
M, D = [int(i) for i in input().split()]

seki_no_hi = 0

for m in range(1, M + 1):
    for d in range(10, D + 1):
        d1 = d % 10
        d10 = d // 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == m:
            seki_no_hi += 1

print(seki_no_hi)

Measured memory_bytes: 9196
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;


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

    int h,n; cin >> h >> n;
    std::vector<int> a(n); rep(i,n) cin >> a[i];

    int x = 0; rep(i,n) x+= a[i];

    if(h<=x) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MAX 55
#define MAXV 400000005
using namespace std;
 
int main(){
  int n, m, a[2][MAX], c[2][MAX], i, j, mi, ans, x;
  scanf("%d%d", &n, &m);
  for(i = 0; i < n; i++) scanf("%d%d", &a[0][i], &a[1][i]);
  for(j = 0; j < m; j++) scanf("%d%d", &c[0][j], &c[1][j]);
  for(i = 0; i < n; i++){
    mi = MAXV;
    for(j = 0; j < m; j++){
      x = abs(a[0][i] - c[0][j]) + abs(a[1][i] - c[1][j]);
      if(mi > x){
        ans = j;
        mi = x;
      }
    }
    printf("%d\n", ans+1);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int n,m;cin >> n >> m;
  vector<int> a(n);
  int tot,cnt;
  tot = cnt = 0;
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++) tot += a[i];
  for(int i=0;i<n;i++){
    if(a[i]*4*m>=tot) cnt++;
  } 
  if(cnt>=m) cout << "Yes\n";
  else cout << "No\n";
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    int n = 3;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 1e9;
    do {
        int cur = 0;
        for (int i = 1; i < n; i++) {
            cur += abs(a[i] - a[i-1]);
        }
        ans = min(ans, cur);

    } while (next_permutation(a.begin(), a.end()));
    cout << ans << endl;
}

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

int main(){
 int n, m, i, j, max=0;
 cin>>n;
 string *blue = new string[n];
 int *num = new int[n];
 for(i=0; i<n; i++){
  cin>>blue[i];
  num[i]=1;
 }
 cin>>m;
 string *red = new string[m];
 for(i=0; i<m; i++)cin>>red[i];
 for(i=0; i<n; i++){
  for(j=i+1; j<n; j++)
   if(blue[i]==blue[j])num[i]++;
  for(j=0; j<m; j++)
   if(blue[i]==red[j])num[i]--;
  if(num[i]>max)max=num[i];
 }
 cout<<max<<endl;
}

Measured memory_bytes: 256