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

using namespace std;
#define INF 1000007
#define MOD 1000000007
#define maxn 101
#define maxh 1001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
const int dx[4] = {0, 1, -1, 0}, dy[4] = {1, 0, 0, -1};
typedef std::pair<int, int> P;
#define int long long

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

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; }

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    while (x) {
        a++;
        b = x;
        x /= 10;
    }
}

signed main() {
    int A, B, N;
    cin >> A >> B >> N;
    if (N >= B) {
        N = B - 1;
    }
    long double Ax = A * N;
    cout << floor(Ax / (long double) B) << endl;
}



Measured memory_bytes: 3876
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

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

  vector<int> dp(n, 0);
  for (int i = 1; i < n; ++i) {
    dp[i] = dp[i-1] + abs(h[i-1] - h[i]);
    for (int j = 2; j <= k; ++j) {
      if (j > i) { break; }
      dp[i] = min(dp[i], dp[i-j] + abs(h[i-j] - h[i]));
    }
  }

  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  const [a, b, c] = input.trim().split(" ").map(Number);
  return a <= c && c <= b ? "Yes" : "No";
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 30380
#ABC109B
n = int(input())
w = [0]*n
for i in range(n):
    w[i] = input() #文字列なのでintはいらない
    
flag = False
for i in range(n-1):
    if w[i][len(w[i])-1] != w[i+1][0]:
        flag = True

s = set()
for i in range(n):
    if w[i] in s:
        flag = True
    else:
        s.add(w[i])

print('No' if flag else 'Yes')

Measured memory_bytes: 3064
def CircleinRectangle(W,H,x,y,r):
    if x+r <= W and x-r >= 0 and y+r <= H and y-r >= 0:
        print('Yes')
    else:
        print('No')

def main():
    W,H,x,y,r= map(int, input().split())
    CircleinRectangle(W,H,x,y,r)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5600
N = int(input());
W = [int(n) for n in input().split()];
Sum = 0;

for i in range(N):
    Sum += W[i];

AuxSum = 0;
Diff = 10000000000000000000000000000000000000000000;

for i in range(N):
    AuxSum += W[i];
    Sum -= W[i];
    Diff = min(Diff, abs(AuxSum - Sum));
print(Diff);


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(a == 0){
        break;
      }else{
        for(int i=0;i<a;i++){
          if(i==0||i==a-1){
            for(int j=0;j<b;j++){
              System.out.print("#");
            }
            System.out.println("");
          }else{
          for(int j=0;j<b;j++){
            if(j==0||j==b-1){
              System.out.print("#");
            }else{
              System.out.print(".");
            }
          }
          System.out.println("");
          }
        }
        System.out.println("");
      }
    }
    sc.close();
  }
}


Measured memory_bytes: 33504
#include<stdio.h>
#define MAX 2000000
#define MIN -2147483648
void Insert(int *,int,int);
void swap(int *,int *);
void ExtractMax(int *,int);
void maxHeapify(int *,int,int);
int main(){
  char c[10];
  int queue[MAX+1],n,key,count=0,i;
  while(1){
    /*for(i=0;i<count;i++){
      printf("%d\n",queue[i]);
    }
    printf("\n");*/
    scanf("%s",c);
    if(c[2]=='s'){//insert
      scanf("%d",&key);
      Insert(queue,key,count);
      count++;
    }
    else if(c[2]=='t'){//extract
      ExtractMax(queue,count);
      count--;
    }
    else if(c[2]=='d'){//end
      break;
    }
  }
  
  return 0;
}
void Insert(int *A,int key,int count){
  int i=count;
  A[i]=key;
  while(i>0 && A[i/2]<A[i]){
    swap(&A[i],&A[i/2]);
    i=i/2;
  }
}
void swap(int *x,int *y){
  int z;
  z=*x;
  *x=*y;
  *y=z;
}
void ExtractMax(int *A,int n){
  int max=A[0];
  printf("%d\n",max);
  A[0]=A[n-1];
  maxHeapify(A,0,n-1);
}
void maxHeapify(int *A,int i,int H){
  int l,r,largest;
  l = 2*i;
  r = 2*i+1;
  if(l<=H && A[l]>A[H]) largest = l;
  else largest = i;
  if(r<=H && A[r]>A[largest]) largest = r;
  if(largest != i){
    swap(&A[i],&A[largest]);
    maxHeapify(A,largest,H);
  }
}



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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

#define all(x) x.begin(),x.end()

int main() {

    int N,M;
    Scd2(N,M);

    vi a(N);
    Rep(i,N){
        Scd(a[i]);
    }

    sort( all(a) );

    vii b(M);
    int x,y;
    Rep(i,M){
        Scd2(x,y);
        b[i].first = y;
        b[i].second = x;
    }

    sort( all(b) );
    reverse( all(b) );

    int bi = 0;
    Rep(i,N){
        if( b[bi].second == 0 ){
            bi++;
            if( bi == M ) break;
        }
        if( a[i] < b[bi].first ){
            a[i] = b[bi].first;
            b[bi].second--;
        }else{
            break;
        }
    }

    ll ans = 0;
    Rep(i,N) ans += a[i];

    printf ("%lld\n", ans );

    return 0;
}





Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
const ll MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main() {
    int N;
    cin >> N;
    vi h(N);
    rep(i, N)cin >> h[i];
    int ans = 0;
    int k = 0;
    while(k<N) {
        int min = 101;
        bool frag = false;
        if (h[k] != 0) {
            int index = k;
            frag = true;
        }int j = k;
        while (j < N && h[j] != 0) {
            if (h[j] < min)min = h[j];
            j++;
        }
        if (k != j) for (int i = k; i <= j - 1; i++)h[i] -= min;
        else {
            min = h[k];
            h[k] = 0;
        }
        ans += min;
        if(!frag) k++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

ll get(int p) {
  ll res = 1LL;
  while(p--) res *= 26LL;
  return res;
}

void solve() {
  ll n; cin >> n;
  int cur = 1;
  while(n > get(cur)) {
    n -= get(cur);
    cur++;
  }
  int have = cur;
  string ans = "";
  for(int i = 0; i < cur; i++) {
    have--;
    ll koi = (n + get(have) - 1) / get(have);
    //cout << n << ' ' << get(have) << '\n';
    koi--;
    n %= get(have);
    if(n == 0 and koi == -1) koi = 25;
    ans += char('a' + koi);
  }
  print(ans);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}




Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=nxt(),b=nxt();
    if(a+b>=10)
        cout<<"error\n";
    else
        cout<<a+b<<endl;
    
    return 0;   
}




 
 


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int main() {
  std::cout << std::setprecision(20);
  int64_t N;
  cin >> N;
  int64_t n = (N + 1) / 2.0;
  double ans = (n / (double)N);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

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

  int32_t A, B, C;
  std::cin >> A >> B;
  if (A + B == 3) C = 3;
  else if (A + B == 4) C = 2;
  else C = 1;
  std::cout << C << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	struct S{int i,j,k,r;}s[1000],t;
	int a,b,c,n,i,x[301]={0},y,sc;
	while(scanf("%d%d%d",&a,&b,&c),a)
	{
		for(i=0;i<=a+b+c;++i)x[i]=2;
		scanf("%d",&n);
		for(sc=i=0;i<n;++i)
		{
			scanf("%d%d%d%d",&t.i,&t.j,&t.k,&t.r);
			if(t.r) x[t.i]=x[t.j]=x[t.k]=1;
			else s[sc++]=t;
		}
		for(i=0;i<sc;++i)
		{
			y=(x[s[i].i]==1)+(x[s[i].j]==1)+(x[s[i].k]==1);if(y==2)
			{
				if(x[s[i].i]!=1)x[s[i].i]=0;
				if(x[s[i].j]!=1)x[s[i].j]=0;
				if(x[s[i].k]!=1)x[s[i].k]=0;
			}
		}
		for(i=1;i<=a+b+c;++i)printf("%d\n",x[i]);
	}
	return 0;
}

Measured memory_bytes: 0
H, W, K = map(int, input().split())

def swap(l, a, b):
    # print("s", a, b)
    l[a], l[b] = l[b], l[a]

def check_row(m):
    l = list(range(W))
    b = 0
    for i in range(W-1):
        c = (m>>i)%2
        # print(b, c)
        if b == c == 1:
            return False
        if c == 1:
            swap(l, i, i+1)
        b = c
    return l


# i行目までで1がjにいる組み合わせの数
dp = [[0 for j in range(W)] for i in range(H+1)]
dp[0][0] = 1

for i in range(1, H+1):
    for j in range(1<<(W-1)):
        r = check_row(j)
        if r == False:
            continue
        # print(r)
        for k, r_i in enumerate(r):
            # print(i, k, r_i)
            dp[i][r_i] = (dp[i][r_i] + dp[i-1][k]) % (10**9+7)

# print(*dp, sep="\n")
print(dp[H][K-1])


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int a,b;
    cin>>a>>b>>s;
    bool ok=true;
    if(s[a]!='-') ok=false;
    if(s.length()!=a+b+1) ok=false;
    if(!ok) 
	{
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<a+b;i++)
	if(i!=a&&(s[i]<'0'||s[i]>'9'))
	ok=false;
	if(!ok)
	{
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    ll x, y;
    cin >> x >> y;
    if (x % y == 0) cout << -1 << '\n';
    else cout << x << '\n';
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18;
const int maxn=305;
int n,k;
ll a[maxn],dp[maxn][maxn];
int main(){
	scanf("%d%d",&n,&k);
	memset(dp,0x3f,sizeof(dp));
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		dp[i][0]=0;
		dp[i][1]=a[i];
	}
	for(int j=2;j<=n-k;j++)
		for(int i=j;i<=n;i++)
			for(int l=1;l<=i-1;l++)
			    dp[i][j]=min(dp[i][j],dp[l][j-1]+max(0ll,a[i]-a[l]));
	ll ans=INF;
	for(int i=1;i<=n;i++) ans=min(ans,dp[i][n-k]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    int h[n + 1];
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    int dp[n + 1] = {
        0,
    };
    for(int i=0;i<=n;i++)
        dp[i] = INT_MAX;
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; i++)
    {
        for(int j=1;j<=k;j++){
        if(i >j)
             dp[i] = min(dp[i-j] + abs(h[i-j] - h[i]) , dp[i]);
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int seat[17] = {0};
	int X = 0;
	int stop[100] = {0};
	int time = 0;
	queue<int> Q;
	while(X < 100){
		int x;
		if(time%5 == 0 && time < 500){
			Q.push(time/5);
		}
		while(1){
			if(Q.size())x = Q.front();
			else x = -1;
			bool f = false;
			
			if(~x){
				int people = (x%5==1?5:2);
				int use = 19 + 3 * (x%3) + 17 * (x%2);
				rep(i,17-people+1){
					bool flag = true;
					rep(j,people){
						flag &= seat[i+j] == 0;
					}
					if(flag){
						rep(j,people){
							seat[i+j] = use;
						}
						f = true;
						break;
					}
				}
			}
			if(f){	
				stop[x] = time - x * 5;
				Q.pop();
				X++;
			}
			if(!f)break;
		}
		rep(i,17){
			seat[i] = max(0,seat[i]-1);
		}
		time++;
	}
	int n,c=0;
	while(cin >> n){
		cout << stop[n] << endl;
		c++;
	}
	while(c<9){};
	
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;
const int mod = 1e5;
const int MAX = 1e6;

int main() {
    int n;
    cin >> n;
    if (n == 0) {cout << 0 << endl; return 0;}
    vint ans;
    int keta = 1;
    while (n != 0) {
        if (n % 2 != 0) {
            ans.push_back(1);
            n -= 1;
        }
        else ans.push_back(0);
        n /= -2;
    }
    reverse(ans.begin(),ans.end());
    rep(i,ans.size()) cout << ans[i];
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll; 
typedef pair<int, int> P;
int main() { cin.tie(0); ios::sync_with_stdio(false);

int n, k;
cin >> n>> k;
int u=k;
for (int i = 0; i <n-1; i++) { 
u *= k-1;
}
cout << u << endl; return 0; }


Measured memory_bytes: 384
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

x = int(input())
print(int(x!=1))

Measured memory_bytes: 64976
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int x1 = Integer.parseInt(tokens[0]);
		int y1 = Integer.parseInt(tokens[1]);
		int x2 = Integer.parseInt(tokens[2]);
		int y2 = Integer.parseInt(tokens[3]);
		int dx = x2 - x1;
		int dy = y2 - y1;
		int x3 = x2 - dy;
		int y3 = y2 + dx;
		int x4 = x1 - dy;
		int y4 = y1 + dx;
		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
		in.close();
	}
}

Measured memory_bytes: 21716
def main():
    K = int(input())
    N = 50
    ans = [i for i in range(N)]
    d = K//50
    r = K % 50
    if K != 0:
        for i in range(r):
            for j in range(N):
                if i == j:
                    ans[j] += N
                else:
                    ans[j] -= 1
        for i in range(N):
            ans[i] += d
    print(N)
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
import sys
input=sys.stdin.readline
import collections

def main():
    N,C,K = map(int,input().split())
    T = []
    for _ in range(N):
        T.append(int(input()))
    T.sort()
    q = collections.deque(T)

    ans = 1
    n = 1
    t0 = q.popleft()
    while q:
        t1 = q.popleft()
        if t1 <= t0 + K and n < C:
            n += 1
        else:
            ans += 1
            n = 1
            t0 = t1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8108
// ていねいにやる 前回の情報を覚えておく
// 初期値で一瞬混乱した
package main
import "fmt"
func main(){
	var N int
	var S1, S2 string
	fmt.Scan(&N, &S1, &S2)
	S, T := make([]string, N), make([]string, N)
	for i, c := range []rune(S1){
		S[i] = string(c)
	}
	for i, c := range []rune(S2){
		T[i] = string(c)
	}
	MOD := int(1e9)+7
	pre := -1	// 0..縦*1 1..横*2
	ans := -1
	idx := -1
	if S[0]==T[0]{
		pre = 0
		idx = 1
		ans = 3
	}else{
		pre = 1
		idx = 2
		ans = 6
	}
	for idx < N{
		if pre == 0{
			if S[idx] == T[idx]{
				ans *= 2
				idx++
			}else{
				pre = 1
				ans *= 2
				idx+=2
			}
		}else{
			if S[idx] == T[idx]{
				pre = 0
				idx++
			}else{
				// aa								bb    bb		 cc
				// bb	の横に並べるのは cc or aa or  aa の3種類
				ans *= 3
				idx+=2
			}
		}
		ans %= MOD
	}
	fmt.Println(ans)
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll n,a;
    cin >> n >> a;
    cout << n*n-a << "\n";
    return 0;
}

Measured memory_bytes: 256
h, w = list(map(int, input().split()))
s = []
up, down, right, left = [
    [[0 for _ in range(w)] for _ in range(h)] for _ in range(4)]
for _ in range(h):
    s.append(list(input()))

for j in range(w):
    for i in range(h - 1, -1, -1):
        if s[i][j] == ".":
            if i == h - 1:
                down[i][j] = 1
            else:
                down[i][j] = down[i + 1][j] + 1

for j in range(w):
    for i in range(h):
        if s[i][j] == ".":
            if i == 0:
                up[i][j] = 1
            else:
                up[i][j] = up[i - 1][j] + 1

for i in range(h):
    for j in range(w - 1, -1, -1):
        if s[i][j] == ".":
            if j == w - 1:
                right[i][j] = 1
            else:
                right[i][j] = right[i][j + 1] + 1

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            if j == 0:
                left[i][j] = 1
            else:
                left[i][j] = left[i][j - 1] + 1

res = 0
for i in range(h):
    for j in range(w):
        lit = up[i][j] + down[i][j] + right[i][j] + left[i][j] - 3
        res = max(res, lit)
print(res)


Measured memory_bytes: 359464
#include <iostream>

using namespace std;

int main(){
	int N, i, j, k, key;
	cin >> N;
	int a[N];
	for(i = 0; i < N; i++){
		cin >> a[i];
	}

	cout << a[0];
	for(k = 1; k < N; k++){
		cout << ' ' << a[k];
	}
	cout << endl;

	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;

		cout << a[0];
		for(k = 1; k < N; k++){
			cout << ' ' << a[k];
		}
		cout << endl;
	}

	return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

vector< vector<int> > g;
int dp[100000];

template<typename T>
bool chmax(T &_a, T _b){
    if(_a < _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

int solve(int v){
    if(dp[v] >= 0){
        return dp[v];
    }

    int res = 0;
    for(auto to : g[v]){
        chmax(res, solve(to) + 1);
    }

    return dp[v] = res;
}

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

    int n, m;
    cin >> n >> m;

    g.resize(n);
    rep(i, m){
        int x, y;
        cin >> x >> y;
        g[--x].emplace_back(--y);
    }

    fill(dp, dp + n, -1);
    int ans = 0;
    rep(i, n){
        chmax(ans, solve(i));
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define ll long long
#define pi pair<ll,ll>
 
vector<ll>v[200005];
ll arr[500005];
ll brr[500005];
 
map<char,ll>mp;
map<char,ll>cnt;
ll digits[13];
vector<string>names;
int main()
{
   ll i=1,j,k,l,p=2,q,r,s=0,t,n=3,money,sum=0;
   cin>>n;
   if(n%2==1)
   {
     cout<<"0";
     return 0;	
    }
    n=n/2;
    while(n>0)
    {
       sum=sum+n/5;
       n=n/5;	
     } 
     cout<<sum;	
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  int res=0;
  rep(i,s.length())repi(j,i,s.length())
  {
    int flag=1;

    repi(k,i,j+1)
    {
      auto c=s[k];
      //cout<<c;
      if(c=='C'||c=='A'||c=='G'||c=='T'){}
      else flag=0;
    }
    //cout<<j-i<<endl;
    if(flag)chmax(res,j-i+1);
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define true 1
#define false 0

typedef unsigned long long int ulli;


int main() {
	int n;
	int ans = 0;
	int zero = 0, one = 0, two = 0;
	int temp = 0;
	ulli s[100000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%llu", &s[i]);
		if (s[i] % 4 == 0) {
			zero++;
		}
		else if (s[i] % 4 == 2) {
			two++;
		}
		else {
			one++;
		}
	}
	if (two > 0) {
		two = 0;
		one++;
	}
	if (one <= zero + 1) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return 0;
}

/*

void MergeSort(int n, int x[], int y[]) {

	int buffer[1000];
	int buffer2[1000];

	int i, j, k, m;
	if (n <= 1) {
		return;
	}

	m = n / 2;

	MergeSort(m, x, y);
	MergeSort(n - m, x + m, y + m);

	for (i = 0; i < m; i++) {
		buffer[i] = x[i];
		buffer2[i] = y[i];
	}
	j = m;
	i = k = 0;
	while (i < m && j < n) {
		if (buffer[i] <= x[j]) {
			y[k] = buffer2[i];
			x[k++] = buffer[i++];
		}
		else {
			y[k] = y[j];
			x[k++] = x[j++];
		}
	}
	while (i < m) {
		y[k] = buffer2[i];
		x[k++] = buffer[i++];
	}
	return;
}*/

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
int a[50];
int main() {
    int N;
    cin >> N;
    int max_id = 0;
    int min_id = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        if (a[max_id] < a[i]) max_id = i;
        if (a[min_id] > a[i]) min_id = i;
    }
    if(a[max_id] + a[min_id] >= 0) {
        cout << 2*N-1 << endl;
        for(int i = 0; i < N; i++) {
            cout << max_id+1 << " " << i+1 << endl;
        }
        for(int i = 0; i+1 < N; i++) {
            cout << i+1 << " " << i+2 << endl;
        }
    }else {
        cout << 2*N-1 << endl;
        for(int i = 0; i < N; i++) {
            cout << min_id+1 << " " << i+1 << endl;
        }
        for(int i = N-1; i > 0; i--) {
            cout << i+1 << " " << i << endl;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int a,b,c,m;

  scanf("%d%d",&a,&b);

  if(a<b){
    c = a;
    a = b;
    b = c;
  }

  while(1){
    c = a%b;
    if(c==0){
      m = b;
      break;
    }
    a = b;
    b = c;
  }

  printf("%d\n",m);

  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

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

  ll ans = 0;
  ans += 1000 * (x / 500);

  x = x % 500;
  ans += 5 * (x/ 5);

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 5e5+17;
int a[MAXN];
int main(int argc ,char const *argv[])
{
	#ifdef noob
	freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
	#endif
	string str;
	cin>>str;
	int n = str.size()+(str[0]==str[str.size()-1]);
	if(n%2==0)
	{
		cout<<"Second"<<endl;
	}
	else
		cout<<"First"<<endl;
	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef vector<ll> vec;
typedef vector<vec> mat;

ostream &operator<<(ostream &os, const vec &a) {
  FOR(it, a) os << setw(6) << *it << " ";
  return os;
}
ostream &operator<<(ostream &os, const mat &a) {
  FOR(it, a) os << *it << endl;
  return os;
}

mat mul(const mat &A, const mat &B, ll mod) {
  mat C(A.size(), vec(B[0].size()));
  REP(i,A.size())
    REP(j,B[0].size())
    REP(k,B.size())
    C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod;
  return C;
}

mat pow(mat A, ll n, ll mod) {
  mat B(A.size(), vec(A.size()));
  REP(i,A.size())
    B[i][i] = 1;
  while(n) {
    if (n&1) B = mul(B, A, mod);
    A = mul(A,A,mod);
    n >>= 1;
  }
  return B;
}

const ll mod = 1e9+7;
mat A;
ll fib(ll n) {
  mat res = pow(A,n,mod);
  return res[0][0] + res[0][1];
}

ll sum(ll n) {
  ll res = (n+1)/2 * ((n+1)/2+1);
  if (n&1) res -= (n+1)/2;
  return res;
}

int main() {
  A = mat(2,vec(2,1));
  A[1][1] = 0;
  ll K;
  while(cin>>K) {
    ll low=0,high=1LL<<31;
    while(low+1<high) {
      ll mid = (low+high)/2;
      if (sum(mid) < K) low = mid;
      else high = mid;
    }
    K -= sum(low);
    K--;
    ll a;
    ll num = (low+2)/2;
    ll num2 = (num+1)/2;
    if (K < num2) {
      a = K*2;
    } else {
      ll t = num-1-K;
      a = t*2+1;
    }
    cout << fib(a)*fib(low-a)%mod << endl;
  }
}

Measured memory_bytes: 1216
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int N,M;
    cin >> N >> M;
//    vector<pair<int,int>> cmd(M);
    vector<int> box(N+1,1);
    vector<bool> red(N,false);
    red[1] = true;

    REP(i,0,M){
//        cin >> cmd[i].first >> cmd[i].second;
        int x,y;
        cin >> x >> y;
        box[x]--;
        box[y]++;
        if(red[x]){
            red[y] = true;
            if(box[x] == 0) red[x] = false;
        }

    }

    int cnt = 0;
    REP(i,1,N+1){
        if(red[i]) cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int slectionSort(vector<int> &A, int N) {
	int cnt=0;
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i+1; j < N; j++) {
			if (A[j] < A[minj]) minj = j;
		}
		if (i != minj) {
			swap(A[i], A[minj]);
			cnt++;
		}
	}
	return cnt;
}

int main() {
	int N; cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >>A[i];
	}
	int ans; ans = slectionSort(A, N);

	for (int i = 0; i < N - 1; i++) {
		cout << A[i] << " ";
	}
	cout <<A[N - 1] << endl;
	cout << ans << endl;
}


Measured memory_bytes: 3092
# ABC071D - Coloring Dominoes (ARC081D)
def main():
    """
    Vertical (V): a
                  a
    Horizontal (H): aa
                    bb
    """
    N = int(input())
    S1 = input().rstrip()
    S2 = input().rstrip()
    MOD = 10 ** 9 + 7
    a, b = S1[0], S2[0]
    ans = 3 if a == b else 6
    for i, j in zip(S1[1:], S2[1:]):
        if a != i and b != j:  # new dominos
            if a == b:  # V + H (2)
                ans *= 2
            else:  # H + V (1) or H + H (3)
                ans *= 1 if i == j else 3
            ans %= MOD
        a, b = i, j
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<bitset>
#include<algorithm>
#include<climits>
#include<vector>
#include<deque>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> P;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define dump(a) rep(i,a.size()){ cout<<a[i]<<" "; } cout<<endl;
#define dumparr(a,n) rep(i,n){ cout<<a[i]<<" "; } cout<<endl;
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define INF INT_MAX/3
#define FINF DBL_MAX/3
#define EPS 1e-7
#define OUT1(n1) cout<<n1<<endl
#define OUT2(n1,n2) cout<<n1<<" "<<n2<<endl
#define OUT3(n1,n2,n3) cout<<n1<<" "<<n2<<" "<<n3<<endl
#define OUT4(n1,n2,n3,n4) cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<endl
#define OUT5(n1,n2,n3,n4,n5) cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<endl
#define OUT6(n1,n2,n3,n4,n5,n6) cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<" "<<n6<<endl
#define OUT(n, ...) OUT##n(__VA_ARGS__)

/* 状態遷移するタイプ: t -> t+1のことを考える
 * 詰まったら数式に起こす
 */

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


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#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 <memory.h>
#include <queue>

#define fr first
#define sc second
#define mk make_pair

using namespace std;

long long n;
vector<int> vec;

int main()
{
    deque<int> ans;
    cin >> n;
    while(n)
    {
        if(n % 2 == 1)
        {
            vec.push_back(1);
            n = n / 2;
        }else
        {
            vec.push_back(0);
            n--;
        }
    }

    int p = 1;
    for(int i = vec.size() - 1; i >= 0; i--)
    {
        if(vec[i] == 1)
        {
            ans.push_back(p);
        }else
        {
            ans.push_front(p);
        }
        p++;
    }
    cout << ans.size() * 2 << endl;
    while(!ans.empty())
    {
        cout << ans.front() << " ";
        ans.pop_front();
    }

    for(int i = 1; i < p; i++)
        cout << i << " ";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#define P pair<int, int>

using namespace std;
const int MAX = 1<<30;

int main(){
  int n, d[109];
  vector<P> G[109];
  queue<int> Q;
  cin >> n;
  for(int i=0;i<n;i++){
    int u, k, v, c;
    cin >>u >> k;
    for(int j=0;j<k;j++){
      cin >> v >> c;
      G[u].push_back(P(v, c));
    }
    d[i] = MAX;
  }
  d[0] = 0;
  Q.push(0);
  while(!Q.empty()){
    int cur = Q.front();Q.pop();
    for(int i=0;i<G[cur].size();i++){
      int next = G[cur][i].first, weight = G[cur][i].second;
      if(weight + d[cur]< d[next]){
        d[next] = weight + d[cur];
        Q.push(next);
      }
    }
  }
  for(int i=0;i<n;i++)cout << i << ' ' << d[i] << endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define v(T) vector<T>
#define yn {puts("Yes");}else{puts("No");}
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double eps = 1e-10;

void solve() {
  int n;
  cin >> n;
  v(v(int)) d;
  rep(i, n) {
    int t1, t2;
    cin >> t1 >> t2;
    v(int) a = {t1, t2};
    d.push_back(a);
  }

  int zorome = 0;
  rep(i, n)
  {
    if (d[i][0] == d[i][1]) {
      zorome++;
      if (zorome > 2) {
        cout << "Yes" << endl;
        return;
      }
    } else {
      zorome = 0;
    }
  }
  cout << "No" << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}


Measured memory_bytes: 3648
N = int(input())
p = [int(i) - 1 for i in input().split()]

f = 0
ans = 'YES'
for i, v in enumerate(p):
    if i == v:
        continue
    if i != v and f:
        ans = 'NO'
        break
    else:
        p[i], p[v] = p[v], p[i]
        f = 1
            
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<bitset>
int main()
{
	static std::bitset<500>c[500][500];	//[x][y][z]
	int i,j,k,n,h,s,a,b;
	char _[9];
	while(scanf("%d%d",&n,&h),n)
	{
		for(i=0;i<n;++i)for(j=0;j<n;++j)c[i][j].reset();
		while(h--)
		{
			scanf("%s%d%d",_,&a,&b),a--,b--;
			if(!strcmp(_,"xy"))for(i=0;i<n;++i)c[a][b][i]=1;
			else if(!strcmp(_,"xz"))for(i=0;i<n;++i)c[a][i][b]=1;
			else if(!strcmp(_,"yz"))for(i=0;i<n;++i)c[i][a][b]=1;
		}
		for(s=i=0;i<n;++i)for(j=0;j<n;++j)s+=n-c[i][j].count();
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 16000
k=int(input())
s=input()
l=len(s)

n=k+l
mod=10**9+7
fac = [1, 1]  # fact[n] = (n! mod p)
finv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, n + 1):
    fac.append((fac[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    finv.append((finv[-1] * inv[-1]) % mod)
# fac[n] = n! mod in o(n)

def comb(n, r, mod):
    if n < r or r < 0:
        return 0
    elif r==0 or r==n:
        return 1
    else:
        return fac[n] * finv[r] * finv[n - r] % mod
print( sum( (comb(k+l,m,mod) * pow(25,m,mod))%mod for m in range(k+1) )%mod )

Measured memory_bytes: 218816
s = input()
n = len(s)
if n == 7:
    if s == "keyence":
        print("YES")
    else:
        print("NO")
else:
    if s[n-7:n] == "keyence" or (s[0]+s[n-6:n]) == "keyence" or (s[0:2]+s[n-5:n]) == "keyence" or (s[0:3]+s[n-4:n]) == "keyence" or (s[0:4]+s[n-3:n]) == "keyence" or (s[0:5]+s[n-2:n]) == "keyence" or  (s[0:6]+s[n-1:n]) == "keyence"  or (s[0:7]) == "keyence":
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000

int long dp [MAX_N];

int main() {
  int n;
  cin>>n;
  int step[n];
  for(int i=0;i<n;i++){
    cin>>step[i];
  }
  dp[0]=0;
  dp[1]=dp[0]+abs(step[1]-step[0]);
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(step[i]-step[i-1]),dp[i-2]+abs(step[i]-step[i-2]));
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
ll n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    ll ans=0;
    cin>>n;
    ans+=n/500*1000;
    n-=n/500*500;
    ans+=n/5*5;
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
 
using namespace std;
int main() {
 
	int a, b, c;
	cin >> a>> b>> c;
 
	if ((a + b + c) == 17) {
		if ((a == 5 || a == 7) && (b == 5 || b == 7) && (c == 5 || c == 7)) {
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
 
		}
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
H, N = map(int, input().split())
ATK = []

for i in range(N):	
  ATK.append(list(map(int, input().split())))
mp_min = [0]
for hp in range(1, H+1):
  mp_min.append(min([mp_min[max(0, hp-ATK[i][0])] + ATK[i][1] for i in range(N)]))

 # print(mp_min)

print(mp_min[-1])


Measured memory_bytes: 43868
s =input()
l = len(s)
s = list(s)
revs=s[::-1]



if s[:int((l-1)/2)] == revs[-int((l-1)/2):] and s[int((l+2)/2):] == revs[:-int((l+2)/2)] and s == revs:
    print('Yes')
else: 
    print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
map<ll,bool>mp;
ll tot,cnt,num;
int main()
{
    cin>>cnt;
    for(register int i=0;i<cnt;i++)
    {
        cin>>num;
        if(mp[num]==1)
        {
            tot--;
            mp[num]=0;
        }
        else
        {
            tot++;
            mp[num]=1;
        }
    }
    cout<<tot<<endl;
}

Measured memory_bytes: 6528
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    if (tail == LEN) {
        //TODO: Head overwrite
        tail = 0;
    } else {
        tail++;
    }
}

P dequeue(){
    P p = Q[head];
    if (head == LEN) {
        head = 0;
    } else {
        head++;
    }
    return p;
}

int count() {
    if (tail >= head) {
        return tail - head;
    } else {
        return (tail + LEN) - head + 1;
    }
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  tail = 0; head = 0;
  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    tail++;
  }

  while (count() > 0) {
      u = dequeue();
      u.t -= q;
      if (u.t <= 0) {
          elaps += q + u.t;
          printf("%s %d\n", u.name, elaps);
      } else {
          elaps += q;
          enqueue(u);
      }
  }

  
  return 0;
}


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

int main() {
  int N = 0, Al = 0, Bo = 0, x = 0;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i < N; i++){
    cin >> A.at(i);
  }
  
  for(int i=0; i < N; i++){
    for(int j=0; j < N; j++){
      if(x < A.at(j)){
        x = A.at(j);
      }
    }

    if(i%2 == 0){ 
      Al += x;
    }
    else{ 
      Bo += x;
    }
    for(int j=0; j < N; j++){
      if(x == A.at(j)){
        A.at(j) = 0;
        x = 0;
        break;
      }
    }
  }
  cout << Al - Bo << endl;
}


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

struct node{
  struct node *p;
  struct node *r;
  struct node *l;
  int key;
};

typedef struct node * Node;

Node root;

void insert(int);
void inorder(Node);
void preorder(Node);
Node find(Node,int);

int main(){
  int a,b,i;
  char com[20];
 
  scanf("%d",&a);
 
  for(i=0;i<a;i++){
    scanf("%s",com);
 
    if(com[0]=='i'){
        scanf("%d",&b);
        insert(b);
    }

    else if(com[0]=='p'){
        inorder(root);
        printf("\n");
        preorder(root);
        printf("\n");
    }

    else if(com[0]=='f'){
        scanf("%d",&b);
        Node s=find(root,b);
        if(s!=NULL) printf("yes\n");
        else printf("no\n");
    }
  }
  return 0;
}

void insert(int v){
  Node y=NULL;
  Node x=root;
  Node c;
  c=malloc(sizeof(struct node));
  c->key=v;
  c->l=NULL;
  c->r=NULL;
  while(x!=NULL){
    y=x;
    if(c->key < x->key) x=x->l;
    else x=x->r;
  }
    c->p=y;
    if(y==NULL) root=c;
    else if(c->key < y->key) y->l=c;
    else y->r=c;
}

void inorder(Node w){
  if(w!=NULL){
    inorder(w->l);
    printf(" %d",w->key);
    inorder(w->r);
  }
}
 
void preorder(Node w){
  if(w!=NULL){
    printf(" %d",w->key);
    preorder(w->l);
    preorder(w->r);
  }
}
 
Node find(Node a,int b){
  if (a==NULL || b==a->key) return a;
  if(b < a->key) return find(a->l,b);
  else return find(a->r,b);
}


Measured memory_bytes: 20464
package main

import (
	"fmt"
	"sort"
)

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

	xl := make([]int, n + 1)
	for i := 0; i < n; i++ {
		fmt.Scan(&xl[i])
	}
	xl[n] = x

	sort.Ints(xl)

	for i := n; i > 0; i-- {
		xl[i] = xl[i] - xl[i-1]
	}

	xl = xl[1:]

	sort.Ints(xl)

	for i := xl[0]; i > 0; i-- {
		found := true
		for j := 0; j < n; j++ {
			if xl[j] % i != 0 {
				found = false
				break
			}
		}
		if found {
			fmt.Println(i)
			return
		}
	}
}

Measured memory_bytes: 5504