akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

int main()
{
	ll n;
	string s,t,ans="Yes";

	cin >> s;
	cin >> t;

	forll(i, 0, s.size())
		if (s[i] != t[i])
			ans = "No";

	cout << ans;

}


Measured memory_bytes: 3596
// WA.

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <vector>
#include <functional>
#include <cassert>
#include <cmath>
#include <map>
#include <set>
#include <queue>

using namespace std;

vector<vector<int>> e;
vector<pair<int, int>> ret;

vector<int> parent;

int n, m;


int main() {
	ios_base::sync_with_stdio(false);

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

	if (m % 2 != 0) {
		cout << -1 << endl;
		return 0;
	}

	queue<int> Q;
	Q.push(0);
	vector<int> visited(n, 0);
	vector<int> childcnt(n, 0);
	visited[0] = 1;
	parent[0] = -1;
	while (!Q.empty()) {
		int x = Q.front();
		Q.pop();
		for (int y : e[x]) {
			if (!visited[y]) {
				parent[y] = x;
				Q.push(y);
				childcnt[x]++;
				visited[y] = 1;
			}
		}
	}
	//for (int i = 0; i < n; i++) {
	//	cout << parent[i] << " ";
	//}
	//cout << endl;
	//for (int i = 0; i < n; i++) {
	//	cout << childcnt[i] << " ";
	//}
	cout << endl;
	vector<int> out(n, 0);
	for (int i = 0; i < n; i++) {
		for (int x : e[i]) {
			if (parent[i] != x && parent[x] != i && i < x) {
				ret.emplace_back(i, x);
				out[i]++;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		if (childcnt[i] == 0) {
			Q.push(i);
		}
	}

	while (!Q.empty()) {
		int x = Q.front();
		Q.pop();
		if (x == 0) break;
		if (out[x] & 1) {
			ret.emplace_back(x, parent[x]);
		}
		else {
			ret.emplace_back(parent[x], x);
			out[parent[x]]++;
		}
		childcnt[parent[x]]--;
		if (childcnt[parent[x]] == 0) {
			Q.push(parent[x]);
		}
	}

	for (auto& p : ret) {
		cout << p.first + 1 << " " << p.second + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 9596
main = interact $ process 1 . map read . tail . words
process y (x0:x1:xs)
    | x0 - x1 > y = "No"
    | x0 - x1 < 0 = process 1 (x1:xs)
    | otherwise = process (y-x0+x1) (x1:xs)
process _ _ = "Yes"


Measured memory_bytes: 2428
operand = []
for x in raw_input().split():
  if x.isdigit():
    operand.append(int(x))
  else:
    a1 = operand.pop()
    a2 = operand.pop()
    if  x == '+' :
      operand.append(a2 + a1)
    elif  x == '-':
      operand.append(a2 - a1)
    elif  x == '*':
      operand.append(a2 * a1)

print operand.pop()

Measured memory_bytes: 6236
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int k, t;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> k >> t;
    vii a(t);
    int vmax = 0, itr = 0;
    rep(i, 0, t) {
        cin >> a[i];
        if (vmax < a[i]) vmax = a[i], itr = i;
    }   
    int ans = vmax - 1;
    rep(i, 0, t) {
        if (vmax >= a[i] && i != itr) ans -= a[i];
    }
    if (ans < 0) ans = 0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	string key[]={"AC","WA","TLE","RE"};
	map<string,int> mp;
	REP(i,n){
		string s;
		cin>>s;
		mp[s]++;
	}
	
	REP(i,4){
		cout<<key[i]<<" x "<<mp[key[i]]<<endl;
	}
}

Measured memory_bytes: 3600
S=input()

T=''
S=S[::-1]
l,r=0,7
while l<len(S):
  if S[l:r]=='remaerd':
    l=r
    r+=7
  elif S[l:r-1]=='resare':
    l=r-1
    r+=6
  elif S[l:r-2]=='maerd':
    l=r-2
    r+=5
  elif S[l:r-2]=='esare':
    l=r-2
    r+=5
  else:
    print('NO')
    exit()
print('YES')

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    ll x;
    cin>>x;
    rep(i,-500,500){
        rep(j,-500,500){
            if(pow(i,5)-pow(j,5)==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int main() {
  
  long long a, aa, aaa;
  
  int n;
  cin >> n;
  
  aa=1;
  aaa=2;
  
  a=aa+aaa;
  for (int i=0; i<n-1; i++) {
    a=aa+aaa;
    aaa=aa;
    aa=a;
  }
  
  if (n==1) cout << 1 << endl;
  else cout << a << endl;
}

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


int main() {
  cout<<fixed<<setprecision(10);
  int N;cin>>N;
 /* vector<double> v(N);
  for(int i=0;i<N;i++) cin>>v.at(i);*/
  priority_queue<double,vector<double>,greater<double>> v;
  for(int i=0;i<N;i++){
    double X;cin>>X;
    v.push(X);
  }
  while(v.size()>1){
    double y=v.top();
    v.pop();
    double z=v.top();
    v.pop();
    double S=(y+z)/2;
    v.push(S);
  }
  cout<<v.top()<<endl;
}




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

int main(){
  ll n,i,m,l,s,d,t;
  cin >> n;
  m=1000;
  ll a[n];
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  for(i=0;i<n;i++){
    if((a[i]<a[i+1])&&(m/a[i]>0)){
      t=m/a[i];
      m-=t*a[i];
      s+=t;
      d=i;
    }
    if(a[i]>a[i+1]){
      m+=s*a[i];
      s=0;
    }
    if(i==n-1){
      m+=s*max(a[d],a[i]);
    }
  }
  cout << m;
}

Measured memory_bytes: 3632
n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
cc = list(map(int, input().split()))
aa = [a-1 for a in aa]

sat = 0
before = -2
for a in aa:
    sat += bb[a]
    if a == before + 1:
        sat += cc[before]
    before = a  
print(sat)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
public class Main {
public static void main(String [] args)throws Exception{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String str = br.readLine();
	int ans = 0;
	String var = "CODEFESTIVAL2016";
	for(int i = 0;i < str.length();i++){
		if(str.charAt(i) != var.charAt(i))++ans;
	}
	System.out.print(ans);
}
}

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



int main(){
    int ans=0;
    int A[5];
    int M=0;
    for(int i=0;i<5;i++){
        cin>>A[i];
        if(A[i]%10!=0){
          	M=max(M,10-A[i]%10);
            A[i]=A[i]+(10-A[i]%10);
            
        }
      //  cout<<A[i]<<" ";
        ans+=A[i];
       // cout<<ans<<endl;
    }
    cout<<ans-M<<endl;
    //cout<<M<<endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<double> v;
    for (int i = 0; i < N; i++) {
        double _v;
        cin >> _v;
        v.push_back(_v);
    }
    sort(v.begin(), v.end());
    double ans = v[0];
    for (int i = 1; i < N; i++) {
        ans += v[i];
        ans /= 2.0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main() {
    long a,b,c;
    cin>>a>>b>>c;
    cout<<a+b+c-max(a,max(b,c))<<endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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;}
const ll INF = 1e18+1;


vector<pair<int,int> > G[100000];
bool visited[100000];

void dfs(int i, vector<int> &x) {
    visited[i] = true;
    for (int k = 0; k < G[i].size(); k++) {
        if (!visited[G[i][k].first]) {
            x[G[i][k].first] = x[i] + G[i][k].second;
            dfs(G[i][k].first, x);
        }
    }
}

int main() {
    int N, M; cin >> N >> M;
    vector<int> L(M), R(M), D(M), x(N,0);
    for (int i = 0; i < M; i++) cin >> L[i] >> R[i] >> D[i];
    for (int i = 0; i < M; i++) {
        G[L[i]-1].push_back(make_pair(R[i]-1, D[i]));
        G[R[i]-1].push_back(make_pair(L[i]-1, -D[i]));
    }
    typedef pair<int,int> P;
    for (int i = 0; i < N; i++) {
        if (!visited[i]) {
            dfs(i,x);
        }
    }

    for (int i = 0; i < M; i++) {
        if (x[R[i]-1] - x[L[i]-1] != D[i]) {
            cout << "No\n"; return 0;
        }
    }
    cout << "Yes\n";

}



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

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

template<class T>
class DequeSlide {
  T *data;
  int *deq;
  int n, l, s, t;
  int cur;

public:
  DequeSlide(int n, int l) {
    data = new T[n];
    deq = new int[n];
    this->n = n;
    this->l = l;
    s = t = cur = 0;
  }

  void push(T x) {
    if(s<t && deq[s] == cur-l) s++;
    while(s<t && data[deq[t-1]] >= x) t--;
    deq[t++] = cur;
    data[cur++] = x;
  }

  T get() {
    return data[deq[s]];
  }

  void debug() {
    cout << s << " " << t << " [";
    repl(i, s, t-1) {
      cout << " " << data[deq[i]];
    }
    cout << " ]" << endl;
  }
};

#define N 1000007
int n, l, a;

int main() {
  cin >> n >> l;
  DequeSlide<int> sd(n, l);
  rep(i, l-1) {
    cin >> a;
    sd.push(a);
  }
  vector<int> ans;
  rep(i, n-l+1) {
    cin >> a;
    sd.push(a);
    cout << (i ? " " : "") << sd.get();
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 10904
program canh_toan;
uses math;
const minn=0;
      maxn=trunc(1e5)+5;
      vao='CONNECT.INP';
      ra='CONNECT.OUT';
      module=trunc(1e9)+7;
var n:longint;
    a,b:array[minn..maxn] of longint;
procedure sorta(l,r:longint);
var i,j,k,tg:longint;
begin
i:=l;j:=r;tg:=a[random(r-l+1)+l];
repeat
while (a[i]<tg) do inc(i);
while (tg<a[j]) do dec(j);
if not(i>j) then
   begin
     k:=a[i];
     a[i]:=a[j];
     a[j]:=k;
     inc(i);
     dec(j);
   end;
until i>j;
if (l<j) then sorta(l,j);
if (i<r) then sorta(i,r);
end;
procedure sortb(l,r:longint);
var i,j,k,tg:longint;
begin
i:=l;j:=r;tg:=b[random(r-l+1)+l];
repeat
while (b[i]<tg) do inc(i);
while (tg<b[j]) do dec(j);
if not(i>j) then
   begin
     k:=b[i];
     b[i]:=b[j];
     b[j]:=k;
     inc(i);
     dec(j);
   end;
until i>j;
if (l<j) then sortb(l,j);
if (i<r) then sortb(i,r);
end;
function nhannp(x,y:int64):int64;
var tg:int64;
begin
if y=0 then exit(0)
else if y=1 then exit(x mod module)
else
  begin
    tg:=nhannp(x,y div 2) mod module;
    tg:=(2*tg) mod module;
    if y mod 2=1 then tg:=(tg+x) mod module;
    exit(tg mod module);
  end;
end;
procedure main();
var i,j,x,y:longint;
    kq:int64;
begin
readln(n);
for i:=1 to n do read(a[i]);
readln;
for j:=1 to n do read(b[j]);
sorta(1,n);sortb(1,n);
i:=1;j:=1;x:=0;y:=0;kq:=1;
while (i<=n) and (j<=n) do
  begin
    if (a[i]<b[j]) then
       begin
         y:=x+1;
         inc(i);
       end
    else
       begin
         y:=x-1;
         inc(j);
       end;
    if (abs(x)>abs(y)) then kq:=nhannp(kq,abs(x)) mod module;
    x:=y;
  end;
while (i<=n) do
  begin
    kq:=nhannp(kq,abs(x)) mod module;
    inc(x);
    inc(i);
  end;
while (j<=n) do
  begin
    kq:=nhannp(kq,abs(x)) mod module;
    dec(x);
    inc(j);
  end;
write(kq);
end;
BEGIN
  main();
END.

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    static void solve(Scanner sc) {
        int n = sc.nextInt();
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (a % 2 != 0) {
                System.out.println(0);
                return;
            }

            int count = 0;
            while (a % 2 == 0) {
                a /= 2;
                count++;
            }

            min = Math.min(min, count);
        }
        System.out.println(min);
    }
}

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

int main() {
    char C;
    cin >> C;

    if (C == 'a' || C == 'e' || C == 'i' || C == 'o' || C == 'u') {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }

    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int A, B, N; std::cin >> A >> B >> N;
    std::vector<int> a(A), b(B), x(N), y(N), c(N);
    for (int i = 0; i < A; i++) std::cin >> a[i];
    for (int i = 0; i < B; i++) std::cin >> b[i];
    for (int i = 0; i < N; i++) std::cin >> x[i] >> y[i] >> c[i];
    int ans = *std::min_element(a.begin(), a.end())
        + *std::min_element(b.begin(), b.end());
    for (int i = 0; i < N; i++) {
        ans = std::min(ans, a[x[i] - 1] + b[y[i] - 1] - c[i]);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N,M,V,P,a;
    vector<int> A;
    cin >> N >> M >> V >> P;
    REP(i,N){
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    
    
    int L=-1,R=N,mid;
    while((R-L)>1){
        mid=(L+R)/2;
        vector<int> B;REP(i,N){B.push_back(0);}
        for(int i=0;i<=mid;i++){
            B[i]+=M;
        }
        for(int i=mid+1;i<N;i++){
            B[i]+=max(0ll,A[mid]+M-A[i]);
        }
        
        //REP(i,N){cout << B[i] << " ";}cout << endl;
        
        int Bsum=0;
        REP(i,N){Bsum+=B[i];}
        for(int i=N-1;i>=0;i--){
            if(Bsum>=M*V)break;
            Bsum+=M-B[i];
            B[i]=M;
        }
        //REP(i,N){cout << B[i] << " ";}cout << endl;
        int judge=A[mid]+M;
        REP(i,N){B[i]+=A[i];}
        sort(B.begin(),B.end());
        //REP(i,N){cout << B[i] << " ";}cout << endl;
        decltype(B)::iterator it = upper_bound(B.begin(), B.end(), judge);
        it--;
        int loc=(it-B.begin());
        
        //cout << L MM R MM mid MM loc<< endl;
        if(loc>=N-P){
            R=mid;
        }else{
            L=mid;
        }
    }
    cout << N-R << endl;
    return 0;
}



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


int main(){
  char in[120];
  pair<pair<string,int>,int> p[110];
  
  int a;
  cin >> a;
  
  for(int i=0 ; i<a ; i++){
    int t;
    cin >> in >> t ;
    //string tmp = in;
    p[i] =make_pair(make_pair(in,-t),i);
  }

//sort(a, a+N); // 配列
//sort(ar.begin(), ar.end()); // array
//sort(v.begin(), v.end()); // vector
  
  sort(p,p+a);
  
  for(int i=0 ; i<a ; i++) {
    cout << p[i].second+1 << endl ;
  }
}

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

int main(){
	int n,c=0,a;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a%2==0){
			if(a==2) c++;
			continue;
		}
		int j=sqrt(a)+1;
		if(j%2==0) j--;
		while(j>=3){
			if(a%j==0) goto f;
			j=j-2;
		}
		c++;
		f:;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    string s;
    cin >> s;

    int o = 0;
    REP(i, 3) {
        if (s[i] == 'o')
            o++;
    }

    cout << 700 + o * 100 << endl;

    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

int calc(int k, int[] ws) {
    bool match(int limit) {
        int n = 0;
        int sum = 0;
        foreach (w; ws) {
            if (sum + w <= limit) {
                sum += w;
            }
            else {
                sum = w;
                n++;
                if (n > k)
                    return false;
            }
        }
        return n + 1 <= k;
    }

    int lo = ws.reduce!max;
    int hi = 1_000_000_000;
    int ans = hi;
    while (lo <= hi) {
        int m = (lo + hi) / 2;
        if (match(m)) {
            ans = min(ans, m);
            hi = m - 1;
        }
        else {
            lo = m + 1;
        }
    }
    return ans;
}

void main() {
    auto nk = readints();
    int n = nk[0], k = nk[1];

    int[] ws;
    for (int i = 0; i < n; i++) {
        ws ~= readint();
    }
    writeln(calc(k, ws));
}

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


int main (){
    int n;
    cin >> n;
    vector<int> a(n);

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

    int k=1;
    int ans=0;
    int no=0;

    for (int i = 0; i < (int)(n); i++){
        if (a[i] == k){
            k++;
            ans++;
        }
        if (a[i] != 1) no++;
    }

    if (no == n) cout << "-1" << endl;

    if (no != n) cout << n-ans << endl;
}

Measured memory_bytes: 4040
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int H, W;
    cin >> H >> W;
    cout << (N - H + 1) * (N - W + 1) << endl;
    return 0;
}


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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }

    vector<vector<int>> db;
    db.push_back(a);
    int j = 0;
    for(ll i = 2; i <= k; i *= 2) {
        vector<int> cur(n);
        rep(i, n) {
            cur[i] = db[j][db[j][i]];
        }
        db.push_back(cur);
        ++j;
    }

    int now = 0;
    for(int dg = 0; k > 0; dg++) {
        if(k % 2) {
            now = db[dg][now];
        }
        k /= 2;
    }
    cout << now + 1 << endl;
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

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


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define COUT(x) cout << x << endl

int N, M;
vector<vector<int>> graph;
vector<bool> visited;
int visited_count = 0;
int ans = 0;

void dfs(int src){
    visited[src] = true;
    visited_count++;
    for (auto dst: graph[src]) {
        if (visited[dst]) continue;
        dfs(dst);
    }
    if (visited_count == N){
        ans++;
    }
    visited[src] = false;
    visited_count--;
}

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

    graph.assign(N, vector<int>{});
    REP(i, M){
        int a, b;
        cin >> a >> b; a--;b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }

    visited.assign(N, false);
    dfs(0);

    COUT(ans);

    return 0;
}


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

int main() {
  int a[] = {1, 3, 5, 7, 8, 10, 12}, b[] = {4, 6, 9, 11}, c[] = {2};

  int x, y;
  std::cin >> x >> y;

  const auto check = [&] (const auto v) {
    if (std::find(std::begin(a), std::end(a), v) != std::end(a)) {
      return 0;
    } else if (std::find(std::begin(b), std::end(b), v) != std::end(b)) {
      return 1;
    } else {
      return 2;
    }
  };

  if (check(x) == check(y)) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    set<P> st;
    st.insert({0, INF});
    map<int, vector<P>> mp;
    while(n > 0) {
      n--;
      char q; cin >> q;
      if(q == 'W') {
        int idx, sz; cin >> idx >> sz;
        vector<P> ers;
        for(auto &e: st) {
          int l = e.first, r = e.second;
          if(r - l > sz) {
            mp[idx].push_back({l, l+sz});
            ers.push_back(e);
            st.insert({l+sz, r});
            break;
          } else if(r - l == sz || r == INF) {
            mp[idx].push_back({l, r});
            ers.push_back(e);
            break;
          } else {
            mp[idx].push_back({l, r});
            ers.push_back(e);
            sz -= r - l;
          }
        }
        for(auto &e: ers) {
          st.erase(e);
        }
      } else if(q == 'D') {
        int idx; cin >> idx;
        for(auto &e: mp[idx]) {
          st.insert(e);
        }
        mp[idx].clear();
      } else if(q == 'R') {
        int pos; cin >> pos;
        int ans = -1;
        for(auto &e: mp) {
          auto it = upper_bound(e.second.begin(), e.second.end(), make_pair(pos, INF));
          if(it == e.second.begin()) continue;
          it--;
          if((*it).first <= pos && pos < (*it).second) {
            ans = e.first;
            break;
          }
        }
        cout << ans << endl;
      }
    }
    cout << endl;
  }
}



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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main(int argc, char *argv[]) { _
    ll n, k, friendly = 0;
    vector<ll> a;

    cin >> n;

    a.assign(n, -1);
    for (auto i = 0; i < n; i++) {
        cin >> k;
        a[i] = k - 1;
        if (a[k - 1] == i) {
            friendly++;
        }
    }

    cout << friendly;
    cout << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[1000000];
int main()
{	int n,b=0; ll ans=0; cin>>n;
	for(rint i=1;i<=n;i++) scanf("%d",&a[i]),a[i]-=i;
	nth_element(a+1,a+(n+1)/2,a+n+1); b=a[(n+1)/2];
	for(rint i=1;i<=n;i++) ans+=abs(a[i]-b);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
A = [int(i) for i in input().split()]
ans = 0
for num in A:
    while num % 2 == 0:
        num //= 2
        ans += 1
print(ans)

Measured memory_bytes: 4084
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse=True)
bi = [0]*(A[0]+1)
for a in A:
  bi[a]+=1
  
cum = [0]*(A[0]+1)
for i in range(1,A[0]+1):
  cum[i]=cum[i-1]+bi[i]

cum_max=cum[-1]
left = 0
right = A[0]*2+1
while right-1!=left:
  x = (right+left)//2
  num = 0
  for a in A:
    b = max(x-a,1)
    if b<=A[0]:
      num += cum_max-cum[b-1]
    
  if num>=M:
    left=x
  else:
    right=x

ans = 0
cum_A = [0]*(N+1)
for i in range(1,N+1):
  cum_A[i]=cum_A[i-1]+A[i-1]
for a in A:
  b = max(right-a,1)
  if b>A[0]:
    break
  c = cum_max-cum[b-1]
  M-=c
  ans+=(a*c)+cum_A[c]
  

ans+=M*left
print(ans)


Measured memory_bytes: 16764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//int n,q,i,t,x,ansa[200005],ansb[200005],mna,mnb;
int a[200005];

set<int>::iterator it;
int main()
{
	int n,x;
	cin>>n>>x;
	for(int i=1;i<=n;i++) cin>>a[i];
	ll ans=0;
	for(int i=2;i<=n;i++){
        if(a[i-1]+a[i]>x){
            ans+=a[i]+a[i-1]-x;
            if(a[i-1]>x){
                a[i]=0;
            }
            else{
                a[i]-=a[i]+a[i-1]-x;
            }

        }
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3984
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<sstream>
using namespace std;
int n,a[10],b[10],c[10];
int main()
{
	cin>>n;	
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=1;i<=n;i++)
		c[i]=i;	
	int x,y,sum=1;	
	do
	{
		int f=1;
		for(int i=1;i<=n;i++)
			if(a[i]!=c[i])
			{
				f=0;
				break;
			}
		if(f==1)
			x=sum;	
		f=1;
		for(int i=1;i<=n;i++)
			if(b[i]!=c[i])
			{
				f=0;
				break;
			}
		if(f==1)
			y=sum;
		sum++;
	}while(next_permutation(c+1,c+n+1));
	cout<<abs(x-y);
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#ifdef LOCAL
    #define _GLIBCXX_DEBUG
    #define dbg(x) cerr << #x << " = " << x << char(10);
#else
    #define dbg(x) ;
    #define cerr if(0) cerr
    #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#endif
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mkt make_tuple
using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
const ld eps = 1e-8l;
const int INF = 1e9 + 10;
const ll INFL = 9 * 1e18;
const ll MOD = 1e9 + 7;
const ld Pi = acosl(-1.0l);

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(9);
    cout << fixed;
    #ifdef LOCAL
        assert(freopen("in", "r", stdin));
        assert(freopen("out", "w", stdout));
        assert(freopen("err", "w", stderr));
    #endif

    map<char, int> mp;
    string s;
    cin >> s;
    for(auto i: s)
        mp[i] = 1;
    dbg(mp['N']);
    dbg(mp['S']);
    if(mp['N'] ^ mp['S'] || mp['E'] ^ mp['W'])
        cout << "No";
    else
        cout << "Yes";
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = 1e9 + 7;

int main()
{
    ll n;
    int w;
    cin>> n >> w;
    vector<ll> dp(w + 1, 0);
    for(ll i = 0; i < n; i++){
        ll iw, ic;
        cin>> iw >> ic;
        for(ll j = w; j >= iw; j--){
            dp[j] = max(dp[j], dp[j - iw] + ic);
        }
    }
    cout<< dp[w];
    return 0;
}


Measured memory_bytes: 1024
a = []
b = []
n , m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
for k in range(m): 
    b.append(int(input()))

for t in range(n):
    x = 0
    for s in range(m):
        x += a[t][s]*b[s]
    print(x)


Measured memory_bytes: 6020
N, X, M = map(int, input().split())

if N < M:
    ans = 0
    val = X
    for i in range(N):
        ans += val
        val = (val%M)*(val%M)%M
        
    print(ans)
    exit()

until_start_loop = 0
loop_len = 0
cum_sum = [0]
until_start_loop_sum = 0
loop_sum = 0

ls = [0]*M
val = X
cnt = 0 #TimeStamp
while True:
    if ls[val]:
        until_start_loop = ls[val] - 1
        loop_len = cnt - until_start_loop
        # until_start_loop -= 1
        until_start_loop_sum = cum_sum[until_start_loop]
        loop_sum = cum_sum[cnt] - until_start_loop_sum
        break
    cnt += 1
    ls[val] = cnt
    cum_sum.append(cum_sum[-1] + val)
    val = (val%M)*(val%M)%M


how_many_loop = (N-until_start_loop)//(loop_len)
ans = until_start_loop_sum + how_many_loop * loop_sum
remained = N - how_many_loop * loop_len - until_start_loop
ans += cum_sum[until_start_loop + remained] - cum_sum[until_start_loop]
print(ans)

Measured memory_bytes: 67720
from collections import deque

N, M=map(int,input().split())
A=[""]*(N+1)
S=[[] for i in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    #A[int(a)]=A[int(a)]+b
    #A[int(b)]=A[int(b)]+a
    #print(A)
    S[a].append(b)
    S[b].append(a)

ans = [-1] * (N + 1)
que = deque([1])

while len(que) != 0:
    q = que.popleft()
    for i in S[q]:
        if ans[i] == -1: 
            que.append(i)
            ans[i] = q

print("Yes")
for i in range(2, N + 1): print(ans[i])




Measured memory_bytes: 34896
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int m = sc.nextInt();
		int [][] in = new int [m][n+1]; 
        int [] p = new int [m];
        int [] light = new int [n];
        int ans = 0;
        for(int i=0;i<m;i++){in[i][0] = sc.nextInt();
                             for(int j=1;j<=in[i][0];j++)
                             {in[i][j] = sc.nextInt();}
                            }
        for(int i=0;i<m;i++){p[i]=sc.nextInt();}      
        for(int i=0;i<Math.pow(2,n);i++){int count = 0;int b = i;for(int j=0;j<n;j++){light[j]=b%2;
                                                                       b/=2;}
                                         for(int j=0;j<m;j++){int count2 = 0;
                                           for(int k=1;k<=in[j][0];k++){if(light[in[j][k]-1]==1){count2++;}
                                                                       }
                                                             if(count2%2==p[j]){count++;}
                                                             }
                                        if(count==m){ans++;}}                        
		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
const int N=1e5+10;
struct dabt{
	int next,to;
}e[N];
int n,m,head[N],k,fa[N],ans;
inline void add(int from,int to){e[++k]=(dabt){head[from],to}; head[from]=k;}
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline I mx(const I&a,const I&b){return a>b ? a : b;}
int dfs(int st,int dep)
{
	int tt=dep;
	for(int i=head[st];i;i=e[i].next)
	{
		int v=e[i].to;
		tt=mx(tt,dfs(v,dep+1));
	}
	if(tt-dep+1==m && fa[st]!=1) 
	{
		ans++;
		fa[st]=1;
		return 0;
	}
	return tt;
}
int main()
{
//	freopen("Teleporter.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n,m);
	for(int i=1;i<=n;i++) read(fa[i]);
	for(int i=2;i<=n;i++) add(fa[i],i);
	if(fa[1]!=1) ans++;
	fa[1]=1;
	dfs(1,0);
	printf("%d\n",ans);
	//fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int h,w;
const int mod=(int)1e9+7;
vector<vector<int>> grid;
vector<vector<int>> dp;
int solve(int i,int j){
	if(i>=h or j>=w) return 0;
	else if(dp[i][j]!=-1) return dp[i][j];
	else{
		dp[i][j]=(solve(i+1,j)%mod +solve(i,j+1)%mod)%mod;
	}
return dp[i][j];
}

int main(){
cin>>h>>w;
grid.assign(h,vector<int>(w,0));
dp.assign(h,vector<int>(w,-1));
for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
		char x;
		cin>>x;
		if(x=='#') {grid[i][j]=1; dp[i][j]=0;}
	}
}
dp[h-1][w-1]=1;
cout<<solve(0,0);
return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;
using VL = vector<long long>;
using VVL = vector<VL>;

const int mod = 998244353;

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

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

	VVL dp(n + 1, VL(s + 1, 0));

	for (int i = 0; i < n; i++) {
		dp[i][0]++;
		for (int j = 0; j <= s; j++) {
			if (dp[i][j] == 0) {
				continue;
			}

			dp[i+1][j] += dp[i][j];
			dp[i+1][j] %= mod;

			int nval = j + a[i];
			if (nval <= s) {
				dp[i+1][nval] += dp[i][j];
				dp[i+1][nval] %= mod;
			}
		}
	}

	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += dp[i][s];
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;



int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int c = 0;
  rep(i, n-1) if (s[i] == s[i+1]) c++;
  int ans = min(c+2*k, n-1);
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
int main(){
    int i,n,tyou,tan;
    double a,b,a2=1.00,hiki;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d:%d",&tyou,&tan);
        a=(30.0*tyou)+(tan/2.0);
        b=6.0*tan;
        hiki=a-b;
        a2 = fabs(hiki);
        if(a2>180){
            a2=360-a2;
        }
        if(a2<30){
            puts("alert");
        }else if(a2>=90&&a2<=180){
            puts("safe");
        }else{
            puts("warning");
        }
        a=0;a2=0;b=0;
    }
    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using lint = long long int;
using Graph = std::vector<std::vector<lint>>;

template<class T>
struct edge
{
	T dist;
	lint to;
	edge(){}
	edge(const T &a_dist,const lint &a_to) : dist(a_dist), to(a_to) {}
	~edge(){}
};

int main(int argc,char *argv[])
{
	lint n;
	std::cin >> n;

	std::vector<lint> d(n);
	for(int i = 0;i < n;i++) std::cin >> d[i];

	lint sum = 0;
	for(int i = 0;i < n;i++)
	{
		for(int j = i+1;j < n;j++) sum += (d[i] * d[j]);
	}

	std::cout << sum << std::endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = 0
for i in range(1, N+1):
  if i % 3 == 0 and i % 5 == 0:
    pass
  elif i % 3 == 0:
    pass
  elif i % 5 == 0:
    pass
  else:
    ans += i
print(ans)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int a, b;
    cin >> a >> b;
    if(a<=5){
        cout << 0 << endl;
    }else{
        if(a>=13){
            cout << b << endl;
        }else{
            cout << b / 2 << endl;
        }
    }
    return 0;
}

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

int main(){
    string S;
    cin >> S;
    int i;
    int a = 1;
    int j = 0;
    if(S.at(0) != 'A') a = 0;
    if(S.at(1)>='A'&&S.at(1)<='Z') a = 0;
    for(i=2;i<S.length()-1;i++){
        if(S.at(i)=='C'){
            if(j*i) a = 0;
            else j = i;
        }
        else if(S.at(i)>='A'&&S.at(i)<='Z') a = 0;
    }
    if(S.at(S.length()-1)>='A'&&S.at(S.length()-1)<='Z') a = 0;
    if(j == 0) a = 0;
    if(a) cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    from math import factorial
    n, m = map(int, input().split())
    n, m = max(n, m), min(n, m)
    mod = 10 ** 9 + 7
    if -1 <= n - m <= 1:
        ans = factorial(n) % mod
        ans *= (-n + m + 2) * factorial(m)
        ans %= mod
        print(ans)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10044
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
#define p 998244353
using namespace std;
inline ll read(){
    ll x = 0; char zf = 1; char ch = getchar();
    while (ch != '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int i,j,k,m,n,x,y,z,cnt,sum;
ll a[105],b[105],c;
int main(){
	n=r;m=r;c=r;
	for(rt i=1;i<=m;i++)b[i]=r;
	for(rt i=1;i<=n;i++){
		int now=0;
		for(rt j=1;j<=m;j++)now+=b[j]*r;
		if(now+c>0)cnt++;
		
	}
	cout<<cnt;
    return 0;
}








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

def get_divisors(num):
    f_divs, l_divs = [], []
    for i in range(1, int(num**0.5)+1):
        if not num % i:
            f_divs.append(i)
            l_divs.append(num // i)
    return f_divs, l_divs

div1, div2 = get_divisors(n)
ans = float("inf")
for i in range(len(div1)):
    ans = min(ans, max(len(str(div1[i])), len(str(div2[i]))))
print(ans)


Measured memory_bytes: 3064
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

x1, y1, x2, y2 = lr()
P2 = np.array([x2, y2])  # 2つ目の点
A = np.array([[0, -1], [1, 0]])
vec = np.array([x2-x1, y2-y1])
vec2 = np.dot(A, vec)
vec3 = np.dot(A, vec2)
P3 = P2 + vec2
P4 = P3 + vec3
answer = np.concatenate([P3, P4])
print(*answer)


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

int main() {
  int x1, y1, x2, y2;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

  int dx = x2 - x1;
  int dy = y2 - y1;

  printf("%d %d %d %d", x2 - dy, y2 + dx, x1 - dy, y1 + dx);
  return 0;
}


Measured memory_bytes: 256
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 998244353
//#define mod2 20071027
//#define MOD 998244353
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case %lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=300010, M=1000005;
ll n,k, a[N],b[N], res;
map<ll, ll>mp;
int main()
{
    in1(n);
    for(int i=0;i<n;i++)
    {
        in1(a[i]);
        b[i]=a[i];
    }
    sort(a, a+n);
    for(int i=0;i<n;i++)
    {
        mp[a[i]]=i%2;
    }
    for(int i=0;i<n;i++)
    {
        if(mp[b[i]]!=i%2)
            res++;
    }
    printf("%lld\n",res/2);
    return 0;
}
/*

*/


Measured memory_bytes: 9344
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a); i >= (b); --i)
#define sz(a) int((a).size())
#define pconent(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;
const ll MOD =  1e9+7;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(v) (cout<<#v<<" = "<<v<<endl)
#define endln (cout<<endl)
template <class T> inline void dbv(T a) {  for(auto x : a){ cout<<x<<", " ;} cout<<endl;}
void output(ll tx)
{
    ll a,b;
    cin>>a>>b;
    if(a*b==15)
    {
        cout<<"*";
    }
    else if(a+b==15)
    {
        cout<<"+";
    }
    else
    {
        cout<<"x";
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t =1;
    // cin>>t;
    FOR(i,0,t)
    {
        output(i+1) ;
    }
    return 0 ;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
index = len(A)
det =True
count = 0
while det:
    for i in range(index):
        if (A[i] % 2) != 0:
            det = False
            break
        A[i] = A[i] // 2
    if det != False:
        count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;
typedef pair<int,int> P;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  int64_t s;
  cin >> s;
  if (s > pow(10,9)){
    int64_t x2 = ceil(sqrt(s));
    int64_t y3 = ceil(sqrt(s));
    int64_t y2 = x2 * y3 - s;
    int64_t x3 = 1;
    cout << "0 0 " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
  }else{
    cout << "0 0 " << s << " 0 " << s <<  " 1" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

int main() 
{

    fast();
      

        
    ll n;
    cin>>n;
    vec q(n);
    f(i,0,n)
    {
        cin>>q[i];
    }
    if(n==1)
    {
        cout<<"Yes";
        return 0;
    }
    ll q1[n]={0};
    f(i,1,n)
    { 
        if(q[i]>q[i-1])
        {
            q[i]--;
        }
     }   
     f(i,0,n-1)
     {
        if(q[i]>q[i+1])
            {
                cout<<"No";
                return 0;
            }

     }      
     cout<<"Yes";








  


    
    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
    }

 

Measured memory_bytes: 1792