akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>

#define SIZE 100005
#define MOD 1000000007
#define INF 100000000

using namespace std;

class DDisjointSetOfCommonDivisors {
public:

    void PrimeFactorize(int64_t N, set<int64_t> &vec) {
        for (int64_t i = 2; i * i <= N; i++) {
            while (N % i == 0) {
                vec.insert(i);
                N /= i;
            }
        }
        vec.insert(N);
        vec.insert(1);
    }

    void solve(std::istream &cin, std::ostream &cout) {
        long a, b;
        cin >> a >> b;
        set<int64_t> a_vec;
        set<int64_t> b_vec;
        PrimeFactorize(a, a_vec);
        PrimeFactorize(b, b_vec);
        int64_t cnt = 0;
        for (const auto &a_item : a_vec) {
            for (const auto &b_item : b_vec) {
                if (a_item == b_item) {
                    cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
};


int main() {
    DDisjointSetOfCommonDivisors solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int d = n%10;
    if (d == 3) puts("bon");
    else if (d == 0 || d == 1 || d == 6 || d == 8) puts ("pon");
    else puts ("hon");
    return 0;
}




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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

map<ii,int>mp;

ii f(int x){
	int a = x%10;
	int b = 0;
	while(x){
		b = x;
		x /= 10;
	}
	return ii(a,b);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	for(int i=1; i<=n; i++){
		ii x = f(i);
		mp[x]++;
	}
	ll ans = 0LL;
	for(int i=1; i<=n; i++){
		ii now = f(i);
		ii opp(now.se,now.fi);
		ans += mp[opp];
	}
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

int main() {
  vector<int> x(3);
  rep(i, 3) cin >> x.at(i);
  int cnt = 0;
  rep(i, 3) rep(j, 3) {
    if(i == j) continue;
    else if(x.at(i) == x.at(j)) cnt++;
  }
  if(cnt == 2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
    char C;
    cin >> C;
    vector<char> alp = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

    for(int i=0;i<alp.size()-1;i++) {
        if(C==alp.at(i)) {
            cout << alp.at(i+1) << endl;
        }
    }
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

    string s; cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
}

Measured memory_bytes: 3652
const main = (input) => {
  const [a, ...b] = input.trim().split('\n')
  const [N, M, X] = a.split(' ').map(v => parseInt(v, 10))
  const q = b.map(v => v.split(' ').map(x => parseInt(x, 10)))

  let ans = Infinity

  const r = (bought, books) => {
    if (!books.length) {
      let sum = 0
      const arr = new Array(M).fill(0)
      for (let b of bought) {
        sum += b[0]
        for (let i=1; i<=M; i++) arr[i-1] += b[i]
      }
      if (Math.min(...arr) >= X) ans = Math.min(ans, sum)
      return null
    }

    const [first, ...rest] = books
    r(bought, rest)
    r([...bought, first], rest)
  }

  r([], q)

  return console.log(ans === Infinity ? -1 : ans)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

int main(){
    string S;
    cin >> S;
    int result = 0 ;
    for(int i=0; i < S.length(); i++){
        if (S[i] == '+'){
            result++;
        }
        else if(S[i] == '-'){
            result--;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 3604
import sys
a = [1]
for i in range(2,34):
    for j in range(2,13):
        if i**j <= 1000 : 
            a.append(i**j)   
x = int(input())
for k in range(x,0,-1):
    if k in a:
        print(k)
        sys.exit()

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int main(){
  int n,a[SIZE],b[SIZE],c[SIZE];
  int ans = 0;
  vector<int> vec;
  map<int,int> dic;

  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",c+i);
    vec.push_back(c[i]);
  }

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

  for(int i=0;i<n;i++){
    dic[vec[i]] = i;
  }

  for(int i=0;i<n;i++){
    c[i] = dic[c[i]];
  }  

  for(int i=0;i<n;i++){
    if(i%2==0 && c[i]%2==1) ans++;
  }

  printf("%d\n",ans);
  
  return 0;
}


Measured memory_bytes: 5752
import java.util.Scanner;

public class Main {

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

		for(int i = 1 ; i <= N ; i++){
			S[i] = sc.nextInt();
		}
		sc.close();

		int ans = 0;
		for(int i = 1 ; i <= N ; i++){
			ans+=S[i]-1;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 26196
#include<stdio.h>
int main()
{  
   int a,b,c,d; 
   while(scanf("%d%d%d%d",&a,&b,&c,&d)!=-1)
     {  
        if(a+b>c+d)printf("Left\n");
        else if(a+b<c+d)printf("Right\n");
         else printf("Balanced\n");
	 }
 } 


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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int x,n,d;
        cin>>x>>n>>d;
        x = abs(x);
        int can = min(x/d,n);
        x -= can*d;
        n -= can;
        if(n%2)x = d-x;
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
void Length(char *,char *);
int main(){
  int i, len;//n-len,X-a,Y-b
  char a[1001],b[1001];
  scanf("%d", &len);
  for(i=0; i<len; i++){
    scanf("%s%s", a, b);
    Length(a, b);
  }
  return 0;
}
void Length(char *a, char *b){
  int c[1001][1001];
  int i, j, A,B;//m-A,n-B
  A = strlen(a);
  B = strlen(b);
  for(i = 1; i <= A; i++) 
    c[i][0] = 0;
  for(j = 0; j <= B; j++) 
    c[0][j] = 0;
  for(i = 1; i <= A; i++){
    for(j = 1; j <= B; j++){
      if(a[i-1] == b[j-1])
	c[i][j] = c[i-1][j-1] + 1;
      else if(c[i-1][j] >= c[i][j-1])
	c[i][j] = c[i-1][j];
      else 
	c[i][j] = c[i][j-1];
    }
  }
  printf("%d\n",c[A][B]);
}

Measured memory_bytes: 4520
N, M, *AB = map(int, open(0).read().split())
# print('N={0}, M={1}, AB={2}'.format(N, M, AB))
from_1, to_N = set(), set()
for a, b in zip(*[iter(AB)] *2):
#     print('a={0}, b={1}'.format(a,b))
    if a == 1:
        from_1.add(b)
    if b == N:
        to_N.add(a)
flg = from_1 & to_N
print("POSSIBLE" if flg else "IMPOSSIBLE")

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

int main(){
  int n;
  cin >> n;
  int a[n],b[n],c[n];
  for(int i = 0;i < n;i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  int dp[n][4];//a = 1,b = 2,c = 3
  dp[0][1] = a[0]; dp[0][2] = b[0]; dp[0][3] = c[0];
  for(int i = 1;i < n;i++){
    dp[i][1] = max(dp[i-1][2] + a[i],dp[i-1][3] + a[i]);
    dp[i][2] = max(dp[i-1][1] + b[i],dp[i-1][3] + b[i]); 
    dp[i][3] = max(dp[i-1][2] + c[i],dp[i-1][1] + c[i]); 
  }
  int kekka = -1;
  for(int i = 1;i <= 3;i++){
    if(kekka < dp[n-1][i]){
      kekka = dp[n-1][i];
    }
  }
  cout << kekka << endl;
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <cstring>
#include <iostream>
using namespace std;
char a[20];
int main(){
//    freopen("tabs.in","r",stdin);
    while(~scanf("%s",a)){
        int n = strlen(a);
        bool flag = true;
        for(int i=1;i<n;i++){
            if(a[i]!='9')
                flag = false;
        }
        if(flag){
            cout<<(n-1)*9+a[0]-'0'<<endl;
        }
        else{
            cout<<(n-1)*9+a[0]-'1'<<endl;
        }
    }
}

Measured memory_bytes: 256
N = int(input())

E = [[] for i in range(N + 1)]
ans = {}
First = 0
edges = 0
q = []
visited = [False] * (N + 1)


for i in range(N - 1):
    A, B = map(int, input().split())
    E[A].append(B)
    E[B].append(A)
    if len(E[A]) > edges:
        First = A
        edges = len(E[A])

    if len(E[B]) > edges:
        First = B
        edges = len(E[B])

C = list(map(int, input().split()))
C.sort()
max = sum(C) - C[-1]
q.append(First)

for i in range(1, N + 1):
    x = q.pop(0)
    visited[x] = True
    ans[x] = C[-i]
    for xx in E[x]:
        if not visited[xx]:
            q.append(xx)

print(max)

s = ""
for i in range(1, N + 1):
    s += str(ans[i])
    if i != N:
        s += " "

print(s)

Measured memory_bytes: 6392
/*
 * GCA : "Computer is artificial subject absolutely,Math is God"
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cctype>
#include <utility>
#include <ctime>
using namespace std;
#ifdef DEBUG
#define VAR(a,b) __typeof(b) a=(b)
#define debug(...) printf("DEBUG: "),printf(__VA_ARGS__)
#else
#define VAR(a,b) __typeof(b) a=(b)
#define debug(...)
#endif
typedef unsigned int uint;
typedef long long int Int;
typedef unsigned long long int UInt;
#define Set(a,s) memset(a,s,sizeof(a))
#define Pln() printf("\n")
#define For(i,x)for(int i=0;i<x;i++)
#define CON(x,y) x##y
#define M 25
#define PB push_back
#define oo INT_MAX
#define FOR(a,b) for(VAR(a,(b).begin());a!=(b).end();++a)
#define eps 1e-9
#define X first
#define Y second
inline bool xdy(double x,double y){return x>y+eps;}
inline bool xddy(double x,double y){return x>y-eps;}
inline bool xcy(double x,double y){return x<y-eps;}
inline bool xcdy(double x,double y){return x<y+eps;}
const Int mod=1000000007;
int nx,ny;
char mz[M][M];
set<string> sid;
int dx[8]={0,1,1,1,0,-1,-1,-1};
int dy[8]={1,1,0,-1,-1,-1,0,1};
char store[M*M];
int ox,oy;
string ans;
bool vis[M][M];
void dfs(int x,int y,int d,int dep){

	store[dep]=mz[y][x];
	int nex=(x+dx[d]+nx)%nx;
	int ney=(y+dy[d]+ny)%ny;
	store[dep+1]=0;
	string ss(store);
	if(sid.count(ss)&&ss.length()>=2){
		if(ss.length()>ans.length())ans=ss;
		else if(ss.length()==ans.length()&&ss<ans){
			ans=ss;
		}
	}
	sid.insert(ss);
	vis[x][y]=1;
	if(!vis[nex][ney])dfs(nex,ney,d,dep+1);
	vis[x][y]=0;

}
void solve(){
	Set(vis,0);
	for(int i=0;i<ny;i++){
		for(int j=0;j<nx;j++){
			for(int k=0;k<8;k++){
				vis[j][i]=1;
				dfs(j,i,k,0);
				vis[j][i]=0;
			}
		}
	}
	if(ans.size())
		puts(ans.c_str());
	else puts("0");
}
int main() {
	ios_base::sync_with_stdio(0);
	while(~scanf("%d%d",&ny,&nx)&&ny&&nx){
		sid.clear();
		ans="";
		for(int i=0;i<ny;i++)scanf("%s",mz[i]);
		solve();

	}

















}

Measured memory_bytes: 27204
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    if(k>=a){
        ans+=a;
        k-=a;
    }
    else{
        cout<<k<<endl;
        return 0;
    }
    if(k>=b){
        k-=b;
    }
    else{
        cout<<ans<<endl;
        return 0;
    }
    cout<<ans-k<<endl;
    return 0;
}


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

int main()
{
    // 入力
    int N;
    cin >> N;

    vector<int> A(N);
    rep (i, N) {
        cin >> A[i];
    }

    vector<int> colors;
    rep (i, N) {
        if (i == 0) {
            colors.push_back(A[i]);
        } else {
            if (colors[colors.size() - 1] >= A[i]) {
                colors.push_back(A[i]);
            } else {
                bool newVector = true;

                rep (j, colors.size()) {
                    if (colors[j] < A[i]) {
                        colors[j] = A[i];
                        newVector = false;
                        break;
                    }
                }

                if (newVector) {
                    colors.push_back(A[i]);
                }
            }
        }
    }

    // 出力
    cout << colors.size() << endl;
    return 0;
}


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

int main(void){
  int n;cin >> n;
  int h[n];rep(i,n)cin >> h[i];
  int up = 0,ans = 0;
  for(int lok=0;lok <= *max_element(h,h+n);++lok){
    for(int i=0;i<n;++i){
      if(lok < h[i])up = 1;
      else if(up == 1){ans += 1;up = 0;}
    }
    if(up == 1)ans += 1;
    up = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let mut s = read_vec::<i32>();
    s.sort();
    s.dedup();
    let ans = s.len();
    println!("{}",ans);
}


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

int main() {
  string S, T;cin >> S >> T;
  int A, B;cin >> A >> B;
  string U;cin >> U;
  
  map<string, int> Ball;
  Ball[S] = A;Ball[T] = B;
  Ball[U] -= 1;
  
  cout << Ball[S] << " " << Ball[T] << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] A = new int [N];
        int P = sc.nextInt();
        int sum=0;
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            sum+=A[i];
        }
        long [] dp = new long [sum+1];
        dp[0] = 1;
        for(int i=0; i<N; i++){
            for(int j=sum; j>=0; j--){
                if(dp[j]!=0)dp[j+A[i]]+=dp[j];
            }
        }
        long ans=0;
        for(int j=P; j<=sum; j+=2){
            ans+=dp[j];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23508
#include <iostream>

using namespace std;

int main(){
	int HP[2], ATK[2];
	cin >> HP[0] >> ATK[0] >> HP[1] >> ATK[1];

	int turn = 0;
	while(true){
		if(HP[1 - turn] <= ATK[turn]){
			break;
		}
		HP[1 - turn] -= ATK[turn];
		turn = 1 - turn;
	}
	cout << ((turn) ? "No" : "Yes") << endl;
	return 0;
}


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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 100010;
int u[N], v[N], fa[N], sz[N];
long long ans[N];

int find(int cur) { return fa[cur] == cur ? cur : fa[cur] = find(fa[cur]); }

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int vn, en;
  cin >> vn >> en;
  for (int i = 0; i < en; ++i) {
    scanf("%d%d", &u[i], &v[i]);
    --u[i]; --v[i];
  }
  for (int i = 0; i < vn; ++i) {
    fa[i] = i;
    sz[i] = 1;
  }

  ans[en] = (long long) vn * (vn - 1) / 2;
  for (int i = en - 1; i >= 0; --i) {
    long long connected;
    int rtu = find(u[i]), rtv = find(v[i]);
    // cerr << "node " << u[i] << " , size " << sz[rtu] << "...." 
    //  << "node " << v[i] << " , size " << sz[rtv] << '\n';
    if (rtu == rtv) connected = 0;
    else {
      connected = (long long) sz[rtu] * sz[rtv];
      fa[rtu] = rtv;
      sz[rtv] += sz[rtu];
    }
    ans[i] = ans[i + 1] - connected;
  }
  for (int i = 1; i <= en; ++i) cout << ans[i] << '\n';
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int Max = 100000;
  for(int i=0; i<N; i++){
    int A;
    cin >> A;
    int count = 0;
    while(A % 2 == 0){
      A /= 2;
      count++;
    }
    Max = min(Max, count);
  }
  cout << Max << endl;
}

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

void ans(bool judge) { cout << ((judge) ? "POSSIBLE" : "IMPOSSIBLE") << endl; }

int main(){
    int N; long long K;
    cin >> N >> K;
    vector<long long> A(N);
    set<long long> se;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        se.insert(A[i]);
        if (A[i] == K) { ans(true); return 0; }
    }
    sort(A.begin(), A.end());
    if (A[N-1] < K) { ans(false); return 0; }
    
    bool judge = false;
    for (auto s : se) {
        long long t = K - s;
        if (se.count(t)) judge = true;
    }
    ans(judge);
    return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <math.h>
 
int main(void){
  int i, n, s[1000];
  double x, a;
 
  while(1){
    scanf("%d", &n);
    if(n == 0){
      break;
    }
    x = 0;
    a = 0;
    for(i = 0; i < n; i++){
      scanf("%d", &s[i]);
      x += s[i];
    }
    x /= n;
    for(i = 0; i < n; i++){
      a += (s[i]-x) * (s[i]-x);
    }
    a = sqrt(a/n);
    printf("%f\n", a);
  }
  return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e5; int n, m;
char s[maxN + 2];

int main()
{
  while (scanf("%d %d", &n, &m) != EOF)
  {
    scanf(" %s", s);
    vector<int> ans;
    int at = n;
    while (at > m)
    {
      bool done = false;
      for (int j = m; j >= 1; j --)
        if (s[at - j] == '0')
        {
          at -= j;
          ans.push_back(j);
          done = true;
          break;
        }
      if (!done)
        break;
    }
    if (at > m) printf("-1\n");
    else
    {
      ans.push_back(at);
      reverse(ans.begin(), ans.end());
      for (int i = 0; i < ans.size(); i ++)
        printf("%d%c", ans[i], i < ans.size() - 1 ? ' ' : '\n');
    }
  }
  return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;
  while(cin >> n >> m && n && m){
    ll pos = 1;
    vary(ll,v,n+2,0);
    rep(i,n){
      cin >> v[i+1];
    }
    ll a;
    bool f = true;
    rep(i,m){
      cin >> a;
      pos += a;
      if(pos < n){
        if(pos < 1) pos = 1;
        pos += v[pos];
      }
      if(pos >= n && f){
        cout << i+1<<endl;
        f = false;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3120
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String p = sc.next();
		printIsString(s, p);
	}

	private static void printIsString(String s, String p) {
		String S = s + s;
		Pattern pa = Pattern.compile(p);
		Matcher m = pa.matcher(S);
		if (m.find()) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26272
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define endl "\n"
#define print(X) cout << (X) << "\n"
#define answer(p) printf("Case #%lld:\n",(p)+1);
// #define input(X) getline(cin,X)
static const int INF = 1e+9+7;
static const ll INFL = 1e+18+7;
ll n,m,l;
string s,t;
ll d[200010],dp[1001][1001];
int field[200][200];

int main(){
  double ans = 0, temp = INF;
  cin >> n;
  cin >> m >> l;
  rep(i,0,n){
    int a;
    cin >> a;
    if(abs(double(m-a*0.006)-l) < temp){
      temp = abs(double(m-a*0.006)-l);
      ans = i+1;
    }
  }
  print(ans);
  return 0;
}

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

import sys
import math

for data in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, data.split()))

    abV = (x1 - x2, y1 - y2)
    bpV = (x2 - xp, y2 - yp)

    bcV = (x2 - x3, y2 - y3)
    cpV = (x3 - xp, y3 - yp)

    caV = (x3 - x1, y3 - y1)
    apV = (x1 - xp, y1 - yp)

    c1 = abV[0] * bpV[1] - abV[1] * bpV[0]
    c2 = bcV[0] * cpV[1] - bcV[1] * cpV[0]
    c3 = caV[0] * apV[1] - caV[1] * apV[0]

    if (c1 < 0 and c2 < 0 and c3 < 0) or (c1 > 0 and c2 > 0 and c3 > 0):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 6816
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100LL
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
#define FILEIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);

using namespace std;

ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int cnt[3][33];
int arr[33][33];
int colour[502][502];
int main()
{
	int n,i,j,k,c;
	sd(n);sd(c);
	for(i=1;i<=c;i++)for(j=1;j<=c;j++)sd(arr[i][j]);
	for(i=1;i<=n;i++)for(j=1;j<=n;j++){
		sd(colour[i][j]);
		cnt[(i+j)%3][colour[i][j]]++;
	}
	int answer=INF;
	for(i=1;i<=c;i++)for(j=1;j<=c;j++)for(k=1;k<=c;k++)if(i!=j && j!=k && k!=i){
		int temp=0;
		for(int ind=1;ind<=c;ind++){
			temp+=cnt[0][ind]*arr[ind][i];
			temp+=cnt[1][ind]*arr[ind][j];
			temp+=cnt[2][ind]*arr[ind][k];
		}
		answer=min(answer,temp);
	}
	pdn(answer);
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>

int main() {
	int N;
	int K;
	int a[100000];
	std::cin >> N>> K;
	for (int i = 0; i < N; ++i) std::cin >> a[i];

	int output = (N-1) / (K-1);
	if ((N-1) % (K-1)) output++;
	std::cout << output << std::endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb emplace_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define deb(x) cout << #x << " - " << x << endl;

using namespace std;

vector<int>adj[1000001];
int vis[1000001];
int dist[1000001];
map<int, int>my;

void bfs(int node) {
	queue<int>q;
	q.push(node);
	vis[node] = 1;
	dist[node] = 0;
	while (!q.empty()) {
		int c = q.front();
		q.pop();
		for (int child : adj[c]) {
			if (!vis[child]) {
				q.push(child);
				vis[child] = 1;
				dist[child] = dist[c] + 1;
				my[dist[child]]++;
			}
		}
	}
}


int main()
{	IOS;
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	int n, x, y; cin >> n >> x >> y;
	for (int i = 1; i < n; i++) {
		adj[i].pb(i + 1) , adj[i + 1].pb(i);
	}
	adj[x].pb(y);
	adj[y].pb(x);
	for (int i = 1; i <= n; i++) {
		bfs(i);
		for (int i = 1; i <= n; i++) {
			vis[i] = 0, dist[i] = 0;
		}
	}
	for (int i = 1; i <= n - 1; i++) {
		cout << my[i] / 2 << "\n";
	}
	return 0;
}

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

bool isSame(vector<int> a, vector<int> b) {
	for (int i = 0; i < 6; ++i) {
		if (a[i] != b[i]) return false;
	}
	return true;
}

bool areSame(vector<int> s, vector<int> b) {
	string com = "NNNNEEEE";
	int tmp;
	for (int n = 0; n < 8; ++n) {
		do {
			for (int i = 0; i < n; ++i) {
				if(isSame(s, b)) {
					return true;
				}

				if (com[i] == 'N') {
					tmp = s[5];
					s[5] = s[4];
					s[4] = s[0];
					s[0] = s[1];
					s[1] = tmp;
				}
				else if (com[i] == 'E') {
					tmp = s[5];
					s[5] = s[2];
					s[2] = s[0];
					s[0] = s[3];
					s[3] = tmp;
				}
			}
		} while (next_permutation(com.begin(), com.end()));
	}
	return false;
}

signed main() {
	vector<int> s(6), b(6);
	for (int i = 0; i < 6; ++i) {
		cin >> s[i];
	}
	for (int i = 0; i < 6; ++i) {
		cin >> b[i];
	}

	if (areSame(s, b)) cout << "Yes" << endl;
	else cout << "No" << endl;
}



Measured memory_bytes: 3196
import itertools
N = int(input())
S = input()
dp = [[0] * N for _ in range(N)]
ans = 0
for i, j in itertools.combinations(range(N), 2):
    if S[i] == S[j]:
        dp[i][j] = dp[i - 1][j - 1] + 1
    else:
        dp[i][j] = 0
    ans = max(ans, min(j - i, dp[i][j]))
print(ans)


Measured memory_bytes: 230024
#include<stdio.h>
#include <string.h>
#include<iostream>
using namespace std;

int main()
{
    char S[200010], T[200010];
    int count = 0;


    cin >> S>> T;

    for (int i = 0; i < 200010; i++) {
        if (S[i] == '\0')
            break;
        if (S[i] != T[i])
            count++;

    }

    cout << count << endl;


    return 0;
}

Measured memory_bytes: 3984
s = input()
Q = int(input())
count = 0
right = []
left = []
for i in range(Q):
    q = input().split()
    if int(q[0]) == 1:
        count += 1
    else:
        if count%2 == 0:
            if int(q[1]) == 1:
                left.append(q[2])
            else:
                right.append(q[2])
        else:
            if int(q[1]) == 1:
                right.append(q[2])
            else:
                left.append(q[2])

left = "".join(left)
right = "".join(right)
if count%2 == 0:
    left = left[::-1]
    print(left+s+right)
else:
    s = s[::-1]
    right = right[::-1]
    print(right+s+left)            

Measured memory_bytes: 70564
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <unordered_map>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=200010;
int n;
ll k;
ll a[N],b[N];
unordered_map<ll,int> lsh;

class BIT
{
public:
    BIT(int n):N(n),c(vector<int>(n)){}
    int f (int x) { return x & -x; }
    void add (int x) { for (int i = x; i < N; i += f (i)) c[i]++; }
    void clear (int x) { for (int i = x; i < N; i += f (i)) c[i] = 0; }
    int qry (int x) { int r = 0; for (int i = x; i; i -= f (i)) r += c[i]; return r; }    
private:
    vector<int> c;
    int N;
};

int main() {
	scanf("%d",&n);
	scanf("%lld",&k);
	for (int i=0;i<n;i++) {
		scanf("%lld",a+i);
		a[i]-=k;
	}
	b[n-1]=a[n-1];
	for (int i=n-2;i>=0;i--) {
		a[i]+=a[i+1];
		b[i]=a[i];
	}
	a[n]=0;
	b[n]=0;
	sort(b,b+n+1);
	for (int i=0;i<n+1;i++) {
		if (lsh.find(b[i])==lsh.end()) {
			lsh[b[i]]=i+1;
		}
	}
	ll ans=0;
	BIT bit(N);
	for (int i=0;i<n;i++) {//printf("%lld ",a[i]);
		bit.add(lsh[a[i]]);
		int val=lsh[a[i+1]];
		ans+=(ll)(i+1)-bit.qry(val-1);
	}//printf("\n");
	printf("%lld\n",ans);
}

Measured memory_bytes: 12360
# -*- coding: utf-8 -*-
from collections import deque


n = int(input().strip())
a_list = [int(i) for i in input().rstrip().split()]
#-----

dq = deque()

flag=1
for i in a_list:
    if flag == 1:
        dq.append(i)
    else:
        dq.appendleft(i)
    
    flag *= -1

if n%2 == 0:
    ans = list(dq)
else:
    ans = list(dq)[::-1]
    
print(*ans)


Measured memory_bytes: 25412
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] L = new int[N];
        for (int i = 0; i < N; i += 1) {
            L[i] = sc.nextInt();
        }

        int sum = 0;
        int max = 0;
        for (int Li : L) {
            if (max < Li) {
                max = Li;
            }
            sum += Li;
        }

        if (max < sum - max) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 24148
// PCK2018 Yosen Q8 Taxi
// YAMADA Terushige 2018.9.30.

#include <iostream>
#include <set>
#include <vector>

using namespace std;

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

  multiset <int> s;
  for(int i=1;i<=N;i++){
    cin >> M;
    for(int j=0;j<M;j++){
      int c;
      cin >> c;
      s.insert(c);
      if(s.size()>i) s.erase(s.begin()); 
    }
  }

  unsigned long long sum=0;
  for(multiset<int>::iterator it=s.begin();it!=s.end();it++){
    sum+=*it;
  }
  cout << sum << endl;
  return 0;
}



Measured memory_bytes: 17176
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
    string S;
    cin>>S;

    if(S[S.size()-1]=='s'){
        cout<<S<<"es"<<endl;
    }
    else{
        cout<<S<<'s'<<endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main() {
  int n;
  cin >> n;
  int MAX_C = 100 / 4;
  int MAX_D = 100 / 7;
  rep(i, MAX_C + 1) {
    rep(j, MAX_D + 1) if(i * 4 + j * 7 == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
    int L;
     L = a.at(i);
    for(int j = i - 1; j > -1; j--){
      if(L > a.at(j)){
        a.at(j+1) = a.at(j);
        a.at(j) = L;
      }
    }
  }
  int A = 0, B = 0;
  for(int i = 0; i < N; i += 2)
    A += a.at(i);
  for(int i = 1; i < N; i += 2)
    B += a.at(i);
  cout << A - B << endl;
}
 

Measured memory_bytes: 384
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 

 
void solve()
{
	string s , t ; 
	cin>>s>>t ;
	int ans = 0  ;
	rep(i  ,s.size()){
		if(s[i]==t[i]){
			ans++ ;
		}
	}
	cout<<ans<<endl;

}
 
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

#define ll long long
#define p pair<ll,ll>
#define mp(a, b) make_pair(a,b)
using namespace std;


int n;
vector<vector<ll>> graph;
vector<bool> reachable;

void backdfs(int next) {
    reachable[next] = true;
    for (int i = 0; i < n; i++) {
        if (reachable[i])continue;
        if (graph[i][next] > -1e10) {
            backdfs(i);
        }
    }
}


bool inf = false;

ll bfs() {
    queue<p > vertex;
    vertex.push(mp(0, 0));
    vertex.push(mp(-1, 0));
    int depth = 0;
    vector<ll> maxpoint(n, -3643641919810114514);

    while (true) {
        p next = vertex.front();
        ll nextv = next.first;
        vertex.pop();
        if (nextv == -1) {
            if (vertex.empty())break;
            depth++;
            vertex.push(mp(-1, -1));
        } else {
            if (maxpoint[nextv] <= next.second) {
                maxpoint[nextv] = next.second;
                if (nextv == n - 1 && depth > 1000) {
                    inf = true;
                    cout << "inf" << endl;
                    return -1;
                }
                for (int to = 0; to < n; to++) {
                    ll point = next.second + graph[nextv][to];
                    if (point > maxpoint[to] && reachable[to]) {
                        maxpoint[to] = point;
                        vertex.push(mp(to, point));
                    }
                }
            }
        }
    }

    return maxpoint[n - 1];
}


int main() {
    int m;
    cin >> n >> m;
    graph = vector<vector<ll>>(n, vector<ll>(n, -1145141919810364364));
    for (int i = 0; i < m; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        graph[a][b] = c;
    }
    reachable = vector<bool>(n);
    backdfs(n - 1);
    ll ret = bfs();
    if (!inf) cout << ret << endl;
    return 0;
}

Measured memory_bytes: 8192
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

int main() {
	char s, t, u;
	cin >> s >> t >> u;
	if (s == u) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

int dp[3001][3001];
int main() {
	string s,str;
	cin>>s;
	cin>>str;
	int a=s.size(),b=str.size();
	string x="";
	for(int i=0;i<=a;i++)
	{
		for(int j=0;j<=b;j++)
		{
			if(i==0||j==0)dp[i][j]=0;
			else if(s[i-1]==str[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			
			else{
				if(dp[i-1][j]>dp[i][j-1])dp[i][j]=dp[i-1][j];
				else dp[i][j]=dp[i][j-1];
			}
		}
	}
	string ans="";
	int i=a,j=b;
	while(i>0 && j>0)
	{
		if(dp[i][j]>dp[i-1][j]&&dp[i][j]>dp[i][j-1])
		{
			ans=ans+s[i-1];
			i=i-1;
			j=j-1;
		}
		else if(dp[i][j]==dp[i-1][j])
			i=i-1;
		else
			j=j-1;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 1e9+7;


int main(){
  int n;
  bool flag = true;
  cin >> n;
  vector<ll> h(n,0);
  
  rep(i,n) cin >> h[i];
  ll now = h[0];
  for(int i=0;i<n;i++){
   if(now - 1 > h[i]){
     flag = false;
     break;
   } 
   chmax(now,h[i]);
  } 
  cout << (flag ? "Yes" : "No")<< endl;
}


Measured memory_bytes: 1024
#define ll long long
#include "bits/stdc++.h"
using namespace std;
vector<pair<ll ,ll >>vc;


int main() {
    ll a,b,n;
    cin>>a>>b>>n;
    ll res=min(b-1,n);
    cout<<(a*res)/b - (a*((res)/b));
}


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

#define MOD 998244353

using namespace std;

long extgcd(long a, long b, long &x, long &y) {
    long g = a;
    x = 1;
    y = 0;
    if (b != 0) {
        g = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    return g;
}

long modinv(long a, long m) {
    long x, y;
    extgcd(a, m, x, y);
    return (x % m + m) % m;
}

long fact[300010];
void init_facts(long n) {
    fact[0] = 1;
    for (long i = 1; i <= n; i++) {
        fact[i] = fact[i - 1] * i % MOD;
    }
}

long mod_fact(long n, long p, long &e) {
    e = 0;
    if (n == 0) return 1;

    long res = mod_fact(n / p, p, e);
    e += n / p;

    if (n / p % 2 != 0) return res * (p - fact[n % p]) % p;
    return res * fact[n % p] % p;
}

long mod_comb(long n, long k, long p) {
    if (n < 0 || k < 0 || n < k) return 0;
    long e1, e2, e3;
    long a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
    if (e1 > e2 + e3) return 0;
    return a1 * modinv(a2 * a3 % p, p) % p;
}

int main() {
    long N, A, B, K;
    cin >> N >> A >> B >> K;
    init_facts(N);
    long ans = 0;

    long x = (K - B * N) / A;
    if (x < 0) x = 0;
    long xlim = K / A;
    if (xlim > N) xlim = N;
    for (; x <= xlim; x++) {
        long y = (K - A * x) / B;
        if (A * x + B * y != K || y < 0 || y > N) continue;
        ans = (ans + mod_comb(N, x, MOD) * mod_comb(N, y, MOD) % MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

int main() {
	ll n; cin >> n;
	ll mini = (ll)1e15;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0) {
			mini = min(mini, i + (n / i) - 2);
		}
	}
	cout << mini << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
vector<int> to_exit;

void bfs(int start) {
    queue<int> que;
    que.push(start);
    while (!que.empty())
    {
        int cur = que.front();
        que.pop();
        for (auto nex: G[cur]) {
            if (to_exit[nex] != -1) continue;
            to_exit[nex] = cur;
            que.push(nex);
        }
    }
    
}


int main() {
    int N, M;
    cin >> N >> M;
    G.assign(N, vector<int>());
    to_exit.assign(N, -1);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    to_exit[0] = -2;
    bfs(0);
    cout << "Yes" << endl;
    for (auto i: to_exit) {
        if (i == -2) continue;
        cout << i + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10084
/*
  AOJ 0621
  Title:Russian Flag
  @kankichi573
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

#define min(x,y) (((x)<(y))?(x):(y))

int N,M;
char flag[51];
int  White[50],Blue[50],Red[50];

#define Paint2White(i) (Blue[i] +Red[i])
#define Paint2Blue(i)  (White[i]+Red[i])
#define Paint2Red(i)   (White[i]+Blue[i])


int init()   // ALL Red
{
  int i,ret;

  for(i=0;i<N;i++)
    ret += Paint2Red(i);
  return(ret);
}


main()
{
  int i,j,ret,init_v,min_;
  

  scanf("%d %d",&N,&M);
  
  memset(White,0,sizeof(White));
  memset(Blue ,0,sizeof(Blue));
  memset(Red  ,0,sizeof(Red));

  for(i=0;i<N;i++)
    {
      scanf("%s",flag);
      for(j=0;j<M;j++)
	{
	  if(flag[j]=='W')
	    White[i]++;
	  if(flag[j]=='B')
	    Blue[i]++;
	  if(flag[j]=='R')
	    Red[i]++;
	}
    }

  ret=init_v=min_=init();

    
  ret=INT_MAX;
  for(i=0;i<N-2;i++)
    {
      init_v += Paint2White(i)-Paint2Red(i);
      ret=init_v;

      for(j=i+1;j<N-1;j++)
	{
	  ret +=(Paint2Blue(j) -Paint2Red (j));
	  min_ = min(min_,ret);
	}
    }
  
 
  printf("%d\n",min_);
  
  return(0);
 }

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define reps(i,s,n) for(int i = (s); i < (n); ++i)
long long gcd(long long x, long long y) {
    return y ? gcd(y, x%y) : x;
}
int main(){
  int m1,m2,d1,d2; cin >> m1 >> d1 >> m2 >> d2;
  
  if(m1!=m2) cout << 1 << endl;
  else cout << 0 << endl;
  
  return 0;
 }

Measured memory_bytes: 256