akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long K, X;
  cin >> K >> X;
  bool flag = false;
  for (long i = X - K + 1; i <= X + K - 1; i++) {
    if (flag) cout << " ";
    flag = true;
    cout << i;
  }
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n,a,b;
  cin>>n>>a>>b;
  string s;
  cin>>s;
  long long int go=0;
  long long int fore=0;
  for(long long int i=0; i<n; i++){
    if(s[i]=='c'){
      cout<<"No"<<endl;
    }else if(s[i]=='a'){
      if(go<a+b){
        go++;
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
    }else if(s[i]=='b'){
      if(go<a+b&&fore<b){
        go++;
        fore++;
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
    }
  }
}

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

int main(){
      int a, b, c, k;
      cin >> a >> b >> c >> k;

      int ans;
      if(a >= k) ans = k;
      else if(a + b >= k) ans = a;
      else ans = a - (k-a-b);

      cout << ans <<endl;
}


Measured memory_bytes: 3640
s = raw_input()
l =[]
l.append( s == s[::-1])
tn = (len(s)-1)/2
l.append(s[:tn] == s[:tn][::-1])
nn = (len(s)+3)/2
l.append(s[nn-1:] == s[nn-1:][::-1])
print "No" if False in l else "Yes"

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int k;
  cin >> k;
  if((k%2) == 0 || (k%5) == 0){
    cout << -1 << endl;
    return 0;
  }
  ll n = 7;
  ll m = 70;
  int cnt = 1;
  rep(i,10000000){
    if((n%k) == 0){
      cout << cnt << endl;
      return 0;
    }
    (n += m)%= k;
    (m *= 10)%= k;
    cnt++;
  }
  

  return 0;
}

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

int main(void){
    int n, m;
    while (cin >> n >> m) {
        if (n == 0) return 0;
        
        int a[1010];
        for (int i = 0; i < n; i++) cin >> a[i];
        
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (a[i] + a[j] <= m) ans = max(a[i] + a[j], ans);
            }
        }
        if (ans == 0) cout << "NONE" << endl;
        else cout << ans << endl;
    }
}



Measured memory_bytes: 3080
#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#define MOD 1000000007
#define pi acos(-1)
#define iil pair<int,int>
#define vii vector<ii>
#define ll  long long int
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;i--)
#define REP(i,a,b) for(ll i=a;i<=b;i++)
#define loop(i,n) for(ll i=0;i<n;i++)
#define ll  long long int
#define LL long long int
#define loop2(i,n) for(ll i=1;i<=n;i++)
#define MIN(a,b) (a) < (b) ? (a) : (b)
#define MAX(a,b) (a) > (b) ? (a) : (b)
#define ABS(a) (a) > 0 ? (a) : -(a)
#define rep1(i,a,n) for(i=a;i<(n);i++)
#define pii pair< ll, ll >
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for (int _n(b), i(a); i <= _n; i++)
#define rept(i,n) FOR(i,0,(n)-1)
#define edge pair<int ,int >
#define CLEAR(a) memset((a),0,sizeof(a))
ll add(ll a, ll b) { return a+b-(a+b>=MOD)*MOD; }
ll sub(ll a, ll b) { return a-b+(a-b<0)*MOD; }
ll mult(ll a, ll b) { return (1LL*a*b)%MOD; }
#define all(x)                  (x).begin(),(x).end()
inline ll gcd(ll a, ll b){ ll t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
ll exponentmod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
#define dis(x,y,a,b) sqrt((x-a)*(x-a)+(y-b)*(y-b));
#define maxn 100005
#define rep(i,a,n) for (int i=a;i<n;i++)
#define digits(n)  (floor(log10(n))+1)
#define ll long long int
#define OUT_RT cerr << (float(clock()) / CLOCKS_PER_SEC) << endl
#define ARRAY_SIZE(a) sizeof(a)/sizeof(a[0])
#define gc getchar_unlocked
#define reset(dp) memset(dp,-1,sizeof(dp))
#define midoftwo(x , y) (x+y)/2
using namespace std;
//US :- 67 S :- 34
//find the holy grail in an  adventure frought with danger
//The bigger the occasion, the better the response.
// Never giving in, fighting to the end



int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,x;
    cin>>n>>x;
    cout<<3*(n-gcd(n,x));
    //OUT_RT;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  double s=0;
  int n,a,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    s+=1.0/a;
  }
  printf("%.10lf\n",1.0/s);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[200005] = {}, b[200005] = {}, w = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    sort(b + 1, b + n + 1);
    for (int i = 0; i < 29; i++) {
        int c[200005] = {}, z = 0;
        for (int j = 1; j <= n; j++) c[j] = b[j] % (1 << (i + 1));
        sort(c + 1, c + n + 1);
        for (int j = 1; j <= n; j++) {
            int d = a[j] % (1 << (i + 1));
            z += n + 1 - (int)(lower_bound(c + 1, c + n + 1, 3 * (1 << i) - d) - c);
            z -= n + 1 - (int)(lower_bound(c + 1, c + n + 1, 2 * (1 << i) - d) - c);
            z += n + 1 - (int)(lower_bound(c + 1, c + n + 1, 1 * (1 << i) - d) - c);
            z %= 2;
        }
        if (z) w += (1 << i);
    }
    cout << w;
}


Measured memory_bytes: 2688
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);

  for( i = 1; i <= n; i++ ){

    key = A[i];
    j = i - 1;

    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }

    A[j+1] = key;

    trace(A, n);
  }

  return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) { 
	String line = sc.nextLine();
	String answer = "";
int length = line.length();
for (int i = 0; i < length; i++) {
	char ch=line.charAt(i); 
if(Character.isLowerCase(ch)){
	ch=Character.toUpperCase(ch);
}
// Character.isLowerCase で小文字かどうか判断可能
else {
ch=Character.toLowerCase(ch);
}
// Character.toUpperCase, Character.toLowerCase で変換
// 記号は上記メソッドで変換にかけても変化しない
answer=String.valueOf(ch);
System.out.print(answer); }
System.out.println();
} }}


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

using namespace std;

typedef long long ll;

const int maxn=1e6+5,mod=1e4+7;
const double pi=acos(-1);

int main()
{
    double L;
    while(~scanf("%lf",&L))
    {
        printf("%lf\n",L*L*L/27);
    }
    return 0;
}


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

int main(){
  string O, E;
  cin >> O >> E;
  for (int i=0; i<O.size()-1; i++){
    cout << O[i] << E[i];
  }
  if (O.size()==E.size()){
    cout << O[O.size()-1] << E[E.size()-1];
  }else{
    cout << O[O.size()-1];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int X, Y;
    cin >> X >> Y;
    if (Y - 2 * X < 0) {
        cout << "No";
        return 0;
    }
    int p = Y - 2*X;
    if (p % 2) {
        cout << "No";
        return 0;
    }
    int y = p / 2;
    int x = X - y;
    if (x < 0 || y < 0) {
        cout << "No";
        return 0;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, even = 0;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  for (int i=0; i<N; i++) {
    if (A[i]%2==0) even++;
  }
  int ans = pow(3, N)-pow(2, even);
  cout << ans << endl;
}

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

int kai(string S, int64_t s, int64_t e) {
  int64_t i = s - 1;
  int64_t j = e - 1;
  
  while ( i < j ) {
    if ( S.at(i) != S.at(j) )  return 0;
    i++;
    j--;
  } 
  return 1;
}

int main() {
  string S;
  cin >> S;
  int64_t N = S.size();

  if ( kai( S, 1, N ) && kai( S, 1, (N-1)/2 ) && kai( S, (N+3)/2 , N) ) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "D"
char f[2001][2001];
char c[]={'R', 'Y', 'B', 'G'};
int n, m, d;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    read(m);
    read(d);
    int x=0;
    for(int i=0; i<1200; i+=d){
        int c=(x%2)?2:0;
        for(int j=0; j<1200; j+=d){
            FFOR(k, 0, d) FFOR(l, 0, d) f[i+k][j+l]=c;
            c=(c+1)%4;
        }
        x++;
    }
    FFOR(i, 0, n){
        FFOR(j, 0, m){
            putchar(c[f[i+j][j+499-i]]);
        }
        putchar('\n');
    }
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
	int n;
	int i,j,k,l;
	
	while(cin >> n){
		// countを0で初期化
		int count = 0;
		
		for(i=0;i<=9;i++){
			for(j=0;j<=9;j++){
				for(k=0;k<=9;k++){
					for(l=0;l<=9;l++){
						if(i+j+k+l == n){
							count++;
						}
					}
				}
			}
		}
		
		cout << count << endl;
		
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
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; }

int main()
{
    int N;
    cin >> N;
    ll sum = 0;
    rep2(i, 1, N+1){
        if(i%3 ==0 || i%5 == 0) continue;
        sum += i;
    }
    cout << sum << endl;
    
    return 0;
}

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

typedef std::pair<int,int>P;

int main(int argc, char *argv[])
{
  int H,W,K;
  char A[800][800];
  int d[800][800];
  P start;
  int distance=800;
  int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
  scanf("%d %d %d",&H,&W,&K);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      scanf(" %c",&A[i][j]);
      if(A[i][j]=='S'){
	d[i][j]=0;
	start.first=i;
	start.second=j;
	distance=std::min(std::min(i,H-i-1),std::min(j,W-j-1));
      }
    }
  }
  std::queue<P> que;
  que.push(start);
  while(!que.empty()){
    P now =que.front();que.pop();
    for (int i = 0; i < 4; i++) {
      int nx=now.first+dx[i];int ny=now.second+dy[i];
      if(nx>=0&&nx<H&&ny>=0&&ny<W&&A[nx][ny]=='.'){
	P next;
	next.first=nx;next.second=ny;
	que.push(next);
	d[nx][ny]=d[now.first][now.second]+1;
	A[nx][ny]='S';
	if(d[nx][ny]<=K){
	  distance=std::min(distance,std::min(std::min(nx,H-nx-1),std::min(ny,W-ny-1)));
	}
      }
    }
  }
  if (distance==0) {
    printf("1\n");
  }else{
    printf("%d\n",1+(distance+K-1)/K);
  }
  
  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int cal[12]={31,29,31,30,31,30,31,31,30,31,30,31};//2は29,4,6,9,11は30
string ta[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};//1月１日が木曜日
int main(){
	int n,m,sum=0,now=0;
	while(cin>>n>>m,n||m){
	sum=0;
	for(int i=0;i<n;i++){
	if(i!=n-1)for(int j=0;j<cal[i];j++)sum++;
	else for(int j=0;j<m;j++)sum++;
	}
	cout<<ta[sum%7]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
using namespace std;

int main()
{
long long int n,i,j,k,curtime=0;
cin>>n;
vector<pair<long long int,long long int> > V;
for(i=0;i<n;i++)
{
	cin>>k>>j;
	V.push_back({j,k});
}
sort(V.begin(),V.end());
for(i=0;i<n;i++){
curtime=curtime+V[i].second;
if(curtime>V[i].first)break;
}
if(i==n)cout<<"Yes";
else cout<<"No";
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
const int N = 2e5 + 54;
int k, n, a[N], ans;
int main() {
	scanf("%d%d%d", &k, &n, &a[1]);
	for (int i = 2; i <= n; ++i) scanf("%d", &a[i]), ans = std::max(ans, a[i] - a[i - 1]);
	ans = std::max(ans, a[1] + k - a[n]);
	printf("%d\n", k - ans);
}


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

ll INF = 1e+18;
int iINF = 1e9;

vector<ll> memo(51, 0);

int 
main()
{

  int N, K; cin >> N >> K;
  vector<int> arr(N, 0);
  rep(i, 0, N) cin >> arr[i];

  sort(arr.begin(), arr.end(), greater<int>());
  ll ans = 0;
  rep(i, K, N){
    ans += arr[i];
  }

  cout << ans << endl;

}

Measured memory_bytes: 4060
import itertools
x=list(map(int,input().split()))
k=int(input())
L=list(itertools.combinations_with_replacement([0,1,2],k))
for l in L:
    X=x.copy()
    for i in l:
        X[i] = X[i]*2
    if X[0]<X[1] and X[1]<X[2]:
        print("Yes")
        break
else:
    print("No")

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

using namespace std;
#define mod 1000000007
int main()
{
    int n;
    cin >> n;
    int m;
    cin >> m;
    long long f[n+1];
    for(int i=0;i<=n;i++)
    {
        f[i]=1000000000000000000;
    }
    f[1]=1;
    f[2]=2;
    for(int i=0;i<m;i++)
    {
        int x;
        cin >> x;
        f[x]=0;
    }
    if(f[1]==0 && f[2]!=0)f[2]=1;
    for(int i=3;i<=n;i++)
    {
        if(f[i]==0)continue;
        f[i]=(f[i-1]+f[i-2])%mod;
        //cout << f[i] <<endl;
    }
    cout << f[n];
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define MAX 2000000

int H,A[MAX];

void maxHeapify(i)
{
  int temp,largest,l,r;

  l = 2*i;
  r = 2*i+1;

  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  if( r <= H && A[r] > A[largest] ) largest = r;

  if( largest != i )// i の子の方が値が大きい場合
  {
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(largest); // 再帰的に呼び出し
  }
}

int main()
{
  scanf("%d",&H);
  for(int i=1;i<=H;i++)scanf("%d",&A[i]);
  for(int i=H/2;i>=1;i-- )maxHeapify(i);
  for(int i=1;i<=H;i++)printf(" %d",A[i]);
  printf("\n");
  return 0;
}



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

int main() {
  int A, B;
  cin >> A >> B;
  int first, last, reversed, counter = 0;
  
  for(int i = A; i<=B; i++){
  	first = i/1000;
    last = i%100;
    
    reversed = 0;
  	reversed += (first%10) * 10 + (first/10);

    if(reversed == last) counter++;
  }
  
  cout << counter << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<climits>
#include<algorithm>
#include<vector>
#include<valarray>
#include<string>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iostream>
#include<iomanip>
using namespace std;


#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define DREP(i,n) for(int i=n;i>0;i--)
#define Rep(i,m,n) for(int i=m;i<n;i++)
#define ReP(i,m,n) for(int i=m;i<=n;i++)
#define scani(a) scanf("%d",&a)
#define scand(a) scanf("%lf",&a)
#define scans(s) scanf("%s",s)
#define readi(a) int a;scanf("%d",&a)
#define printi(a) printf("%d",a)
#define prints(s) printf("%s",s)
#define even(n) (((n)+1)%2)
#define odd(n) ((n)%2)
#define sg(x) ((x)?1:0)
#define LF printf("\n")
#define SPACE printf(" ")
#define pb push_back
#define mp make_pair
#define bs binary_search
#define all(a) (a).begin(),(a).end()
#define forall(itr,a) for(auto itr=(a).begin();itr!=(a).end();++itr)

typedef long long LL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<double,double> pdd;
typedef pair<int,int> pii;

const double pi = acos(-1.0);
double rad(double t){return t*pi/180.0;}
double deg(double d){return d*180.0/pi;}
template<typename T>T GCD(T x,T y){return y?GCD(y,x%y):x;}
template<typename T>T LCM(T x,T y){return x/GCD(x,y)*y;}
template<class T>ostream& operator<<(ostream& os,const set<T>& s){os<<"{";for(auto itr=s.begin();s.end() != itr;++itr){if(itr!=s.begin())os<<',';os<<*itr;}os<<"}";return os;}
template<class S,class T>ostream& operator<<(ostream& os,const pair<S,T>& p){os<<'('<<p.first<<','<<p.second<<')';return os;}
const int MOD = (int)pow(10,9) +7;


//begin global variable
//


//
//end   global variable

int main(){
  ios::sync_with_stdio(false);
  //begin main()
  //

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

  vector<bool> flag(N,false),flagT(N,false),flagA(N,false);
  rep(i,N-1){
    if(T[i] != T[i+1]) flagT[i+1] = true;
    if(A[i] != A[i+1]) flagA[i] = true;
  }
  flagT[0] = true;
  flagA[N-1] = true;

  // 0 check
  bool fault = false;
  rep(i,N){
    if( flagT[i] && flagA[i] && (T[i]!=A[i]) ) fault = true;
    if( flagT[i] && T[i] > A[i] ) fault = true;
    if( flagA[i] && T[i] < A[i] ) fault = true;
  }
  if( fault || T[N-1] != A[0] ) { cout << 0 << endl; return 0; }
  // end
  
  rep(i,N) flag[i] = flagT[i] || flagA[i];
  
  LL ans = 1;
  rep(i,N){
    //cout << "flagT" << i << " " << flagT[i] << endl;
    //cout << "flagA" << i << " " << flagA[i] << endl;
    if(!flag[i]) ans = (ans * min(T[i],A[i]))%MOD;
  }

  cout << ans << endl;
  //
  //end   main()
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>

int debt = 100000;

int main(void)
{
    int n;
    std::cin >> n;

    for (int i = 0; i < n; i++) {
        debt *= 1.05;
        if (debt % 1000 != 0) {
            debt = (debt / 1000 + 1) * 1000;
        }
    }

    std::cout << debt << std::endl;
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

ll rev(ll x,int n){
  ll ret=0;
  repeat(i,n){
    ret *= 10;
    ret += x%10;
    x /= 10;
  }
  return ret;
}

ll dfs(ll D,int n,int cnt,int dig,ll N){
  if(cnt>=n/2){
    return rev(N,n)==N+D? N:-1;
  }
  if(cnt>=0){
    if(dig>=0){
      ll d=dig;
      repeat(c,n-1-cnt) d*=10;
      N += d;
    }else{
      ll d=-dig;
      repeat(c,cnt) d*=10;
      N += d;
    }
  }
  ll ret = -1;
  for(int i=-9;i<=(cnt<0? 0:9);i++){
    ret = max(ret,dfs(D,n,cnt+1,i,N));
  }
  return ret;
}

int main(){
  ll D;cin >> D;
  if(D%9!=0){
    cout << 0 << endl;
    return 0;
  }
  int num10=0;
  while(D%10==0){
    D/=10;
    num10++;
  }
  string Dstr=to_string(D);
  int n = Dstr.length();
  //debug(n);
  ll ans = 0;
  repeat(d,7){
    int m = n+d;
    ll N=0;
    if(d>0){
      if(D%10!=9)break;
      if(d>1 && D%100!=89)break;
      repeat(c,d-1){
        N*=10;
        N+=9;
      }
      repeat(c,n){
        N*=10;
      }
      N+=1;
    }
    //debug(N);
    N = dfs(D,m,d-1,0,N);
    debug(N);
    if(N>0){
      string Nstr = to_string(N);
      while(Nstr.length()<m) Nstr = "0"+Nstr;
      ll a=1;
      repeat(j,(m+1)/2){
        int mi=Nstr[j]-'0',ma=Nstr[m-1-j]-'0';
        if(mi>ma)swap(mi,ma);
        a *= j==0? 9-ma+ (num10>0):10-(ma-mi);
      }
      debug(a);
      ans += a;
    }
  }
  if(ans>0&&num10>0){
    repeat(c,num10-1)ans *= 10;
    ans *= 9;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;
int good[100005],H[100005];

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
        scanf("%d",H+i);
    for(int i=1;i<=m;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        if(H[a]>H[b])   good[b]++;
        else if(H[a]==H[b])     {good[a]++;good[b]++;}
        else    good[a]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(!good[i])
            ans++;
    }
    printf("%d",ans);
	return 0;
}


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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n, arr[105], out[105];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &arr[i]);
	}
	for(int i = n; i >= 1; i--){
		bool ok = false;
		for(int j = i; j > 0; j--){
			if(arr[j] == j){
				out[i] = j;
				for(int k = j; k < i; k++){
					arr[k] = arr[k + 1];
				}
				ok = true;
				break;
			}
		}
		if(!ok){
			printf("-1\n");
			return 0;
		}
	}
	for(int i = 1; i <= n; i++){
		printf("%d\n", out[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<cstdio>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  long double ans = 0;

  for(int i=n-1; i>=0; i--){
    int a = 0, j = i + 1;
    while(j<k){
      j *= 2;
      a++;
    }
    ans += powl(0.50, (double)a);
  }
  ans = (long double)ans / n;
  printf("%.12f\n", (double)ans);
  return 0;
}

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

int main () {
    int x[5];
    int ans = 0;
    for (int i = 0; i < 5; ++i) {
        int t = 0;
        cin >> t;
        if (t == 0) ans = i+1;
    }
    cout << ans << endl;
}




Measured memory_bytes: 3592
#include <iostream>

int main(){
	for (int i = 0; i < 9; i++)
	{
		for (int j = 0; j < 9; j++)
		{
			std::cout << i + 1 << "x" << j + 1 << "=" << (i + 1) * (j + 1) << '\n';
		}
	}
}


Measured memory_bytes: 3080
import math

a, b, C = map(float, input().split())

C = math.radians(C)

S = 0.5 * a * b * math.sin(C)

c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(C))

L = a + b + c

h = 2 * S / a

print("{0}\n{1}\n{2}".format(S, L, h))

Measured memory_bytes: 7648
import bisect
n = int(input())
a = list(map(int, input().split()))
a.sort()

maxi = a[-1]
mini = 1000000001
for i in range(n-1):
    if abs(maxi/2 - a[i]) < mini:
        minindex = i
        mini = abs(maxi/2 - a[i])
print(maxi, a[minindex])


Measured memory_bytes: 62704
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> VL;
typedef set<ll> SL;
typedef pair<ll, ll> p2;
const ll M = 1000000007;
const ll M2= 998244353;

void solve()
{
	ll a;
	cin>>a;
	string b; cin>>b;
	ll ans=a*stoll(b.substr(0, 1)) + (a*(stoll(b.substr(2))))/100;
	cout<<ans;
	
		
}
 
int main()
{
    IOS
    int _=1;
    //cin>>_;
    while(_--)
    {
	    solve();
    }
    
    return 0;
}


Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll h, w, a;
  in2(h, w);
  vector<vector<ll>> c(10, vector<ll> (10));
  vector<vector<ll>> d(h, vector<ll> (w));
  rep(i, 10){
    rep(j, 10)
      in(c[i][j]);
  }
  rep(i, h){
    rep(j, w)
      in(d[i][j]);
  }
  vector<ll> e(10, 0);
  rep(i, h){
    rep(j, w){
      if(d[i][j] == -1)
        continue;
      else
        e[d[i][j]]++;
    }
  }
  rep(l, 1000){
    rep(i, 10){
      rep(j, 10){
        rep(k, 10){
          c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
        }
      }
    }
  }
  a = 0;
  rep(i, 10)
    a += e[i] * c[i][1];
  out(a);
  memi;
}

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

using namespace std;

struct Mod {
    static constexpr auto kMod = 1000000007L;
    static constexpr auto kIMod = 1000000005L;

    // can be implicitly converted
    Mod(int64_t n) : n(n) {}

    Mod operator*(Mod m) const {
        return (n * (m.n % kMod)) % kMod;
    }

    Mod& operator*=(Mod m) {
        *this = *this * m;
        return *this;
    }

    Mod pow(int64_t p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }

        int64_t r = this->pow(p/2).n;
        if (p % 2 == 0) {
            return r * r % kMod;
        } else {
            return (r * r % kMod) * n % kMod;
        }
    }

    Mod operator/(Mod m) const {
        if (n == 0) {
            return 0;
        }

        return *this * m.pow(kIMod);
    }

    Mod& operator/=(Mod m) {
        *this = *this / m;
        return m;
    }

    Mod operator+(Mod m) const {
        return (n + m.n) % kMod;
    }

    Mod& operator+=(Mod m) {
        *this = *this + m;
        return *this;
    }

  int64_t n;
};

long solve(int32_t n) {
  vector<int> f(n + 1, 0);
  vector<bool> p(n, true);
  p[0] = false;
  p[1] = false;
  
  for (int32_t i = 2; i <= n/2; ++i) {
    if (!p[i]) {
      // not prime
      continue;
    }
    
    f[i] += 1;
    for (int32_t j = i + 1; j <= n; ++j) {
      int d = 0;
      int jj = j;
      while (jj % i == 0) {
        jj /= i;
        ++d;
      }
      f[i] += d;
      if (d > 0) {
        p[j] = false;
      }
    }
  }
  for (int32_t i = n/2 + 1; i <= n; ++i) {
    if (p[i]) {
      f[i] += 1;
    }
  }
  
  auto ans = Mod(1);
  for (auto ff : f) {
    ans *= ff + 1;
  }
  
  return ans.n;
}

int main() {
  int n;

  cin >> n;
  cout << solve(n) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef pair<int, int> pii;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class C {
	int n;
	vector<int> a;
public:
	C()
	{
		cin >> n;
		a.resize(n);

		REP(i, n)
			cin >> a[i];

	}
	void solve()
	{
		sort(ALL(a));

		int ans{ 0 };
		int now{ 0 };
		int cnt{ 0 };

		REP(i, n)
		{
			if (i == n - 1)
			{
				cnt++;
				now = a[i];
				if (cnt > now)
					ans += (cnt - now);
				else if (cnt < now)
					ans += cnt;
			}
			else if (a[i] != now)
			{
				if (cnt > now)
					ans += (cnt - now);
				else if (cnt < now)
					ans += cnt;

				cnt = 1;
				now = a[i];
			}
			else
				++cnt;


		}

		cout << ans << endl;
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=5e3+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int p[N],c[N],vis[N];
vector<ll> val;
vector<int> G[N];
void dfs(int s,ll sum=0)
{
  vis[s]=1;
  for(auto v:G[s])
  {
    sum+=c[v];
    val.pu(sum);
    if(!vis[v])
    {
      // sum+=c[v];
      // val.pu(sum);
      dfs(v,sum);
    }
  }
}
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int n,k;
  ll ans=-INF;
  cin>>n>>k;
  for(int i=1;i<=n;i++) cin>>p[i];
  for(int i=1;i<=n;i++) cin>>c[i];
  for(int i=1;i<=n;i++)
  {
    int u=i;
    while(!vis[u])
    {
      vis[u]=1;
      int v=p[u];
      G[u].push_back(v);
      u=v;
    }
  }
  for(int i=1;i<=n;i++)
  {
    memset(vis,0,sizeof(vis));
    val.clear();
    dfs(i);
    int sz=val.size();
    sz=min(sz,k);
    ll cyc_mx=-INF;
    for(int j=0;j<sz;j++)
    {
      // cout<<val[j]<<endl;
      ans=max(ans,val[j]);
      cyc_mx=max(cyc_mx,val[j]);
    }
    // cout<<cyc_mx<<endl;
    // cout<<ans<<endl;
    ll cycle=val.back();
    sz=val.size();
    if(k>sz)
    {
      int r=k%sz;
      ll q=k/sz;
      ll temp=-INF;
      for(int j=0;j<r;j++) temp=max(temp,val[j]);
      if(cycle<0)
      {
        // ll temp=-INF;
        // for(int j=0;j<r;j++) temp=max(temp,val[j]);
        temp+=cycle;
        // ans=max(ans,temp);
      }
      else if(cycle>=0)
      {
        temp+=cycle*q;
        temp=max(temp,cycle*(q-1)+cyc_mx);
      }
      ans=max(ans,temp);
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  rep(i,3) {
    rep(j,3) {
      cin >> c[i][j];
    }
  }

  int a[3], b[3];
  a[0] = 0;
  rep(i,3) {
    b[i] = c[0][i] - a[0];
    a[i] = c[i][0] - b[0];
  }

  string result = "Yes";
  rep(i,3) {
    rep(j,3) {
      if (c[i][j] != a[i]+b[j]) result = "No";
    }
  }

  cout << result << endl;
  return 0;
}

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

using namespace std;

int main(){
    int N = 0;
    while(cin >> N){
        vector<string> vs(N);
        for(auto& s : vs) cin >> s;
        int res = 0;
        for(int s=0;s<N;s++){
            bool ok = true;
            for(int j=0;j<N;j++){
                for(int k=j+1;k<N;k++){
                    if(vs[(j+s)%N][k] != vs[(k+s)%N][j]) ok = false;
                }
            }
            if(ok) res += N;
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		string ans = "No";
		for(var i=0;i<3;i++){
			if(str.Substring(i,1)=="7"){
				ans = "Yes";
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 17368
#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> L(n);
  rep(i,n) cin >> L[i];

  sort(L.begin(), L.end());
  int ans = 0;
  for (int b = 0; b < n; b++) {
    for (int a = 0; a < b; a++) {
      int ab = L[a] + L[b];
      int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
      int l = b+1;
      // c = [l,r)
      ans += r-l;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(),vl.end()
#define sor sort 
#define cl clear
#define m_p make_pair 
#define sz(a) a.size()
#define lb lower_bound
#define up upper_bound
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
typedef map<string,ll> mapstl;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	vector<ll> vl;
	map<ll,P> mp;
	ll he = 0;
	for(int i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		mp[a].first = a;
		mp[a].second++;
		he+=a;
	}
	ll q;
	cin>>q;
	for(int i=0;i<q;i++)
	{
		ll a,b;
		cin>>a>>b;
		ll k = mp[a].second;
		ll cha = b-mp[a].first;
		mp[mp[a].first+cha].first = mp[a].first+cha;
		mp[mp[a].first+cha].second += mp[a].second;
		ll cnt = cha*k;
		he+=cnt;
		cout<<he<<endl;
		mp[a].second = 0;
		mp[a].first = 0;
	}
	return 0;
}

Measured memory_bytes: 9512
#include<bits/stdc++.h>
#define lli long long int
#define rep(i,a,b)	for(i=a;i<b;i++)
using namespace std;
int main()
{
	lli t,i,n,ans,k,a;
	cin >> n;
	a=n%10;
	if(a==2||a==4||a==5||a==7||a==9){
		cout<<"hon";
	}
	else if(a==3){
		cout<<"bon";
	}
	else	cout<<"pon";
	return 0;
}

Measured memory_bytes: 3596
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] order = new int[N+1];
        for (int i = 1; i <= N; i++) {
        	order[sc.nextInt()] = i;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= N; i++) {
        	sb.append(order[i]).append(" ");
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 50592
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define loop(i,n) for(ll i=0;i<(ll)(n);i++)
#define change(a,b) do{ll c=a; a=b; b=c;}while(0)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        change(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N,M,X;
  ll ans=0;
  ll post;
  cin>>N>>M>>X;
  loop(i,M){
    cin>>post;
    if(post<X) ans++;
  }
  cout<<min(ans,M-ans)<<endl;
}


Measured memory_bytes: 256
n,t=map(int,input().split())
a=[]
b=[]
c=0
for i in range(n):
    a,b=map(int,input().split())
    if b<=t:
        if c==0:
            c=a
        else:
            if a<=c:
                c=a
    a=0
    b=0
if c==0:
    print('TLE')
else:
    print(c)


Measured memory_bytes: 3060
#include<cstdio>

using namespace std;

int a, b, c;

int solve(){
	for(int i = 1; i <= b; i++) if(i * a % b == c) return 1;
	return 0;
}

int main(){
	scanf("%d %d %d", &a, &b, &c);
	puts(solve() ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

const int mod = 1000000007;
char s[100100];
int nya[100100][13] = {};

int modpow(int n, int m){
	if(m == 0) return 1;
	int res = 1, tmp = n;
	while(m){
		if(m & 1) res = res * tmp % 13;
		tmp = tmp * tmp % 13;
		m >>= 1;
	}
	return res;
}

int main(){
	scanf("%s", s);
	int l = strlen(s);
	nya[0][0] = 1;
	for(int i=0; i<l; i++){
		if(s[l-1-i] != '?'){
			int t = s[l-1-i] - 48;
			for(int j=0; j<13; j++){
				nya[i+1][(t*modpow(10, i)+j)%13] = nya[i][j];
			}
		}else {
			for(int j=0; j<13; j++){
				for(int k=0; k<10; k++){
					nya[i+1][(k*modpow(10, i)+j)%13] = (nya[i+1][(k*modpow(10, i)+j)%13] + nya[i][j]) % mod;
				}
			}
		}
	}
	printf("%d\n", nya[l][5]);
	return 0;
}

Measured memory_bytes: 5376
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
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;
}
int main() {
    string S;
    cin >> S;
    string temp = S;
    int count;
    int answer = INF;
    rep(j, 0, 2) {
        S = temp;
        count = 0;
        if (j == 0) {
            if (S[0] != '0') {
                ++count;
            }
            S[0] = '0';
        } else {
            if (S[0] != '1') {
                ++count;
            }
            S[0] = '1';
        }
    rep(i, 0, S.length()-1) {
        if (S[0] == '1') {
            if (i % 2 == 0) {
                if (S[i] == S[i+1]) {
                    S[i+1] = '0';
                    ++count;
                }
            } else {
                if (S[i] == S[i+1]) {
                    S[i+1] = '1';
                    ++count;
                }
            }
        } else {
            if (i % 2 == 0) {
                if (S[i] == S[i+1]) {
                    S[i+1] = '1';
                    ++count;
                }
            } else {
                if (S[i] == S[i+1]) {
                    S[i+1] = '0';
                    ++count;
                }
            }
        }
    }
    answer = min(count, answer);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include<stack>
#include<string>
#include<algorithm> 
#include <set>
#include<list>
#include <bit>
#include <bitset>
#include <cstdint>
#include <initializer_list>
using namespace std;
int main() {
	string S, T;
	cin >> S >> T;
	int ans = 0;
	int length = S.size();
	for (int i = 0; i < length; i++) {
		if (S[i] != T[i])ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3808
#include<iostream>
#include<cmath>

using namespace std;
int main()
{
    int n;
    cin >> n;
    int a=1;
    while(n>pow(2,a)){
        a++;
    }
    
    if(n==pow(2,a)){
        cout << pow(2,a) << endl;
    }else{
        cout << pow(2,a-1) << endl;
    }
    return 0;
}



Measured memory_bytes: 3448
///In the name of God
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define y1 def1
#define X first
#define Y second
#define endl '\n'
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
map<int,int> mp;
main(){
    string s;
    cin >> s;
    int cur = 0;
    mp[0] = 0;
    for(int i=0; i<s.size(); i++){
        cur ^= ((1LL)<<(s[i]-'a'));
        int mn = 1e9;
        for(int j=-1; j<26; j++){
            int ne = cur;
            if(j >= 0) ne = cur ^ ((1LL)<<j);
            if(mp.count(ne))
                mn = min(mn, mp[ne] + 1);
        }
        if(i == s.size() - 1)
            cout << mn << endl;
        if(mp.count(cur))
            mp[cur] = min(mp[cur], mn);
        else
            mp[cur] = mn;
    }
}


Measured memory_bytes: 12932
import sys
import math
from collections import deque

def insertion_sort(a, n, g):
    ct = 0
    for i in range(g,n):
        v = a[i]
        j = i-g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j-g
            ct += 1
        a[j+g] = v
    return ct

n = int(input())
a = list(map(int, sys.stdin.readlines()))
b = 701
ct= 0
g = deque([x for x in [701,301,132,57,23,10,4,1] if x <= n])
while True:
    b = math.floor(2.25*b)
    if b > n:
        break
    g.appendleft(b)

for i in g:
    ct += insertion_sort(a, n, i)

print(len(g))
print(*g, sep=" ")
print(ct)
print(*a, sep="\n")

Measured memory_bytes: 119076
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#define  STATE  30
using namespace std;
int dp[STATE][STATE][STATE][STATE];
vector <int> A, B, Y, Z, X;
stack <int> stk;
int n, m, r, state;
inline void init (void)
{
    Y.clear();
    Z.clear();
    X.clear();      
    A.resize(n);
    B.resize(m);
    for (int i=0;i<n;++i) cin>>A[i];
    for (int i=0;i<m;++i) cin>>B[i];
    state = STATE;
}
inline void toChomskyForm (int y)
{
    for (;;)
    {
        Z.push_back(stk.top()); stk.pop();
        Y.push_back(stk.top()); stk.pop();      
        if (stk.empty())
        {
           X.push_back(y);
           return ;
        }
        else
        {
            X.push_back(++state);     
            stk.push(state); 
        }
    }          
}
inline void makeGrammar (void)
{
    int k, y, tmp;
    for (int i=0;i<r;++i)          
    {
        cin>>k;    
        for (int j=0;j<k;++j)
        {
            cin>>tmp;    
            stk.push(tmp);
        }
        cin>>y;
        toChomskyForm (y);
    }   
}
inline vector < vector < set<int> > > CYK ( const vector <int> &A )
{
    int n = A.size();          
    vector < vector< set<int> > > dp(n,vector< set<int> >(n+1));
    for (int i=0;i<n;++i) dp[i][1].insert(A[i]);
    
    for (int len=2;len<=n;++len)
    for (int i=0;i<n;++i)
    for (int j=0;j<X.size();++j)
    for (int k=1;k<len;++k)
    {
        int ii = (i+k)%n;    
        if (dp[i][k].count(Y[j])&&dp[ii][len-k].count(Z[j])) 
           dp[i][len].insert(X[j]);
    }      
    return dp;   
}
inline vector < vector<int> > makeBitset ( const vector < vector < set<int> > > &A )
{
    int n = A.size();
    vector < vector<int> > ans(n,vector<int>(n+1,0));
    for (int i=0;i<n;++i)
    for (int w=0;w<=n;++w)
    for (int k=0;k<=STATE;++k)
        if (A[i][w].count(k)) ans[i][w] |= 1<<k;
    return ans;
}

inline void solve (void)
{
    vector < vector<int> > ai = makeBitset( CYK(A) );
    vector < vector<int> > bi = makeBitset( CYK(B) );
    memset (dp,-1,sizeof(dp));
    for (int i=0;i<n;++i)
    for (int j=0;j<m;++j) dp[i][0][j][0] = 0;
    
    for (int nn=0;nn<n;++nn)
    for (int mm=0;mm<m;++mm)
    for (int i=0;i<n;++i)
    for (int j=0;j<m;++j)
    {
        if (dp[i][nn][j][mm] == -1) continue;    
        for (int p=nn+1;p<=n;++p)
        for (int q=mm+1;q<=m;++q)
        {
            int ii = (i+nn)%n;
            int jj = (j+mm)%m;
            if (ai[ii][p-nn] & bi[jj][q-mm])
               dp[i][p][j][q] = max(dp[i][p][j][q],dp[i][nn][j][mm]+1);
        }
    }
    int ans = -1;
    for (int i=0;i<n;++i)
    for (int j=0;j<m;++j) ans = max(ans,dp[i][n][j][m]);   
    cout<<ans<<endl;
}
int main(void)
{
    ios_base :: sync_with_stdio(0);
    while (cin>>n>>m>>r && n && m && r)
    {
          init ();
          makeGrammar ();
          solve ();
    }
    return 0;    
}

Measured memory_bytes: 4592
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n;
    scanf("%d",&n);
    int m = n/100;
    n = n%10;
    if(m == n) puts("Yes");
    else       puts("No");
    return 0;
}


Measured memory_bytes: 128
import queue

N = int(input())
edges = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

from1 = [N] * N
fromN = [N] * N

que = queue.Queue()
que.put((0, 0))
while (not que.empty()):
    vertex, dist = que.get()
    if from1[vertex] != N:
        continue
    from1[vertex] = dist
    for to in edges[vertex]:
        que.put((to, dist + 1))
que.put((N - 1, 0))
while (not que.empty()):
    vertex, dist = que.get()
    if fromN[vertex] != N:
        continue
    fromN[vertex] = dist
    for to in edges[vertex]:
        que.put((to, dist + 1))

black = 0
white = 0
for i in range(N):
    if from1[i] <= fromN[i]:
        black += 1
    else:
        white += 1

print("Fennec" if black > white else "Snuke")


Measured memory_bytes: 105428