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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector <int> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int ans=0;
    int step=0;
    for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1]){
            step++;
        }
        else{
            ans=max(ans, step);
            step=0;
        }
    }
    cout<<max(ans, step)<<endl;
    return 0;
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
const long long mod = 1000000007;
const double eps = 1e-11;
const int inf = 1ll << 61;
int dp[5005][5005];//現在i回目でj文字ある
signed main() {
	int n; cin >> n; string s; cin >> s;
	dp[0][s.size()]++;
	rep(i, n) {
		rep(j, 5002) {
			dp[i+1][j + 1] += dp[i][j] * 2;
			dp[i+1][max(0ll,j - 1)] += dp[i][j];
			dp[i + 1][j + 1] %= mod;
			dp[i + 1][max(0ll,j - 1)] %= mod;
		}
	}
	cout << dp[n][0] << endl;
}

Measured memory_bytes: 195712
#include <iostream>
#include <queue>
#include <algorithm>
#include <climits>
#include <stack>
#include <vector>
#include <random>
#include <string.h>
#include <stdio.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef pair<int, int> ii;
typedef pair<long double, int> id;
typedef pair<long long, long long> llp;
const int N = 1e5+1;
int n, k, t;
int h[N], dp[N];
int main() {
    //freopen("ee.inp", "r", stdin);
    //freopen("ee.OUT", "w", stdout);
    fastIO;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>h[i];
    dp[1] = dp[0] = 0;
    for(int i=2;i<=n;i++) {
        dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
        for(int j=max(1, i-k);j<i-1;j++) dp[i] = min(dp[i], dp[j]+abs(h[i]-h[j]));
    }
    cout << dp[n];
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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++)
using namespace std;
typedef long long ll;

int N, M, C;
int B[30];
int A[30][30];

int main(){
  cin >> N >> M >> C;
  rep(i, M) cin >> B[i];
  rep(i, N){
    rep(j, M) cin >> A[i][j];
  }

  int ans = 0;
  rep(i, N){
    int sums = 0;
    rep(j, M){
      sums += B[j] * A[i][j];
    }
    if (sums + C > 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
def main():
  S = input()
  Q = int(input())
  Query=[input().split() for q in range(Q)]
  cnt=0
  prefix, suffix = '', ''
  for q in Query:
    if q[0]=='1':
      cnt=1^cnt
      prefix, suffix = suffix, prefix
      #print(cnt)
    else:
      if q[1]=='1':
        prefix=prefix+q[2]
      else:
        suffix=suffix+q[2]
  if cnt:
    S=S[::-1]
  print(prefix[::-1]+S+suffix)

main()

Measured memory_bytes: 43292
import collections
n=int(input())
a=dict(collections.Counter(list(map(int,input().split()))))
q=int(input())
ans=0
for i in a:
  ans+=i*a[i]
for i in range(q):
  b,c=map(int,input().split())
  ans+=a.get(b,0)*(c-b)
  print(ans)
  a[c]=a.get(b,0)+a.get(c,0)
  a[b]=0

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

int main() {
	int r, g, b, sum;

	cin >> r >> g >> b;

	sum = 100 * r + 10 * g + b;

	if (sum % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

}

Measured memory_bytes: 256
import numpy as np
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(n):
  A=list(map(int,input().split()))
  if np.dot(np.array(B),np.array(A))+c>0:
    ans+=1
print(ans)


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


void solve(std::string S, std::string T){
    int cnt = 0;
    for(int i = 0; i < S.size(); ++i){
        if(S[i] == T[i]) cnt++;
    }
    cout << cnt << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3548
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    #include<set>
    #include<string>
    #include<stdlib.h>
    using namespace std ;

    int gcd(int a, int b){
      if(a%b==0)return b;
      else return gcd(b,a%b);
    }
    int main(){
      int n,ans=0;
      cin>>n;
      int p[21];
      for(int i=0;i<n;i++){
        cin>>p[i];
      }
      for(int i=1;i<n-1;i++){
        if((p[i-1]<=p[i]&&p[i]<=p[i+1])||(p[i+1]<=p[i]&&p[i]<=p[i-1]))ans++;
      }
      cout<<ans<<endl;
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<vector<ll>> Matrix;
const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};
vector<ll> A;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a, b);}
vector<pair<ll, ll>> factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll i = 2; i * i <= n; ++i) {
        if (n%i) continue;
        res.emplace_back(i, 0);
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if ( n != 1) res.emplace_back(n, 1);
    return res;
}
long long fastpow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x;
        x *= x;
        n >>= 1;
    }
    return ret;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<P> fact = factorize(n);
    map<ll, ll> mp;
    vector<ll> candidates;
    set<ll> s;
    for(auto f: fact) {
        rep1(i, f.second) {
            s.insert(fastpow(f.first, i));
        }
    }
    ll ans = 0;
    for(auto z: s) {
        if (n % z) continue;
        n /= z;
        ans++;
        if (n < z) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>();
	map<char,int> M;
	M['a']=M['b']=M['c']=0;
	int N=S.size();
	if(N==1){
		out("YES");
	}
	else if(N==2){
		if(S[0]==S[1]){
			out("NO");
		}
		else{
			out("YES");
		}
	}
	else{
		REP(i,N){
			M[S[i]]++;
		}
		if(abs(M['a']-M['b'])<=1 && abs(M['c']-M['b'])<=1 && abs(M['a']-M['c'])<=1)	out("YES");
		else out("NO");
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  char c;cin>>c;
  switch(c){
    case 'A':
      cout<<'T'<<endl;
      break;
    case 'T':
      cout<<'A'<<endl;
      break;
    case 'G':
      cout<<'C'<<endl;
      break;
    case 'C':
      cout<<'G'<<endl;
      break;
  }
}

Measured memory_bytes: 256
/*input
hihi
*/
/**
    Author: Kristopher Paul
    Date Created: 06-03-2020
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

//Uncomment for File I/O
/*
ifstream fin("cave.in");
ofstream fout("cave.out");
*/
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    string s;
    cin >> s;
    int n = s.length();
    if((n %2) == 1){
        cout << "No" << endl;
        return;
    }
    FOR(i,0,n){
        if(((i % 2) == 0) && (s[i] != 'h')){
            cout << "No" << endl;
            return;
        }
        if(((i % 2) == 1) && (s[i] != 'i')){
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


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

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

    int score = 0;
    rep(i,n-1) {
        if (s[i] == s[i+1]) score++;
    }
    int ans = min(score+2*k, n-1);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

bool a[101];

int main() {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    int n, k, d, x;
    
    cin >> n >> k;

    for (int i = 0 ; i < k; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> x;
            a[x-1] = 1;
        }
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cnt += (1 - a[i]);
    }
    cout << cnt;

}



Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;
	double ans = 0;

	double x;
	string u;
	while (n--) {
		cin >> x >> u;

		if (u == "BTC") {
			x *= 380000;
			ans += x;

		}
		else {
			ans += x;
		}
	}
	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string> 
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

bool equal(vi a, vi b)
{
	rep(i, sz(a))
	{
		if (a[i] != b[i])return 0;
	}
	return 1;
}

int main()
{
	int n; cin >> n;
	vi p(n), q(n);
	rep(i, n)cin >> p[i];
	rep(i, n)cin >> q[i];
	vi perm;
	int a = 0, b = 0, cnt = 0;
	reps(i, n)perm.push_back(i);
	do
	{
		if (equal(p, perm))a = cnt;
		if (equal(q, perm))b = cnt;
		cnt++;
	} while (next_permutation(all(perm)));
	co(abs(a - b));
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int count = 0;
    for (int i = a; i <= b; i++) {
      for (int j = c; j <= d; j++) {
        if (i == j) {
          count++;
        }
      }
    }
    if (count == 0) {
      System.out.println(count);
    } else {
      System.out.println(count - 1);
    }
  }
}

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

typedef long long LL;

int gcd(int a, int b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}

LL lcm(LL a, LL b, LL g)
{
    return (a / g) * b;
}

int main()
{
    int a, b;
    while(~scanf("%d%d",&a,&b))
    {
        int g = gcd(a,b);
        LL l = lcm(a,b,g);
        printf("%d %lld\n",g,l);
    }
    return 0;
}

Measured memory_bytes: 1188
import heapq
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    a = 0
    b = 0
    ba = 0
    ans = 0
    for _ in range(N):
        s = input()[:-1]
        ans += s.count("AB")
        if s[-1:]=="A" and s[:1]=="B":
            ba += 1
        elif s[-1:]=="A":
            a += 1
        elif s[:1]=="B":
            b += 1

    if ba==0:
        ans += min(a,b)
    else:
        if a+b==0:
            ans += ba - 1
        else:
            ans += ba + min(a,b)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 39408
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

constexpr int64_t kZero = 0;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int64_t> s(n + 1);
  vector<int64_t> w(n + 1);
  for (int i = 0; i < n; i++) {
    s[i + 1] = s[i] + (int64_t)a[i];
    w[i + 1] = w[i] + (int64_t)max(a[i], 0);
  }
  int64_t ans = numeric_limits<int64_t>::lowest();
  for (int i = 0; i <= n - k; i++) {
    int64_t sum = w[n] - (w[i + k] - w[i]);
    sum += max(s[i + k] - s[i], kZero);
    ans = max(ans, sum);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2176
#include <algorithm>
#include <array>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <string>
#include <string_view>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int64_t read_int() {
    int64_t ret = 0, sgn = 1;
    int ch = getchar_unlocked();
    while (isspace(ch)) { ch = getchar_unlocked(); }
    if (ch == '-') { sgn = -1; ch = getchar_unlocked(); }
    for (; isdigit(ch); ch = getchar_unlocked())
        ret = (ret * 10) + (ch - '0');
    ungetc(ch, stdin);
    return sgn * ret;
}

char read_char() {
    int ch = getchar_unlocked();
    while (isspace(ch)) { ch = getchar_unlocked(); }
    return ch;
}

string read_word() {
    string ret;
    int ch = getchar_unlocked();
    while (isspace(ch)) { ch = getchar_unlocked(); }
    for (; ch != EOF && !isspace(ch); ch = getchar_unlocked())
        ret += ch;
    ungetc(ch, stdin);
    return ret;
}

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()

template <typename T> inline void assign_min(T& x, const T& value) noexcept { x = min(x, value); }
template <typename T> inline void assign_max(T& x, const T& value) noexcept { x = max(x, value); }

constexpr char LF = '\n';

int main() {
    int N = read_int();
    string C = read_word();

    int total_w = 0, total_r = 0;
    REP(i, N) {
        if (C[i] == 'W')
            ++total_w;
        else
            ++total_r;
    }

    // 0~iをすべてRにし、i+1~N-1をWにしたい
    // max(前半のWの数, 後半のRの数)
    auto ans = min(total_w, total_r);
    int n_w = 0, n_r = 0;
    REP(i, N) {
        if (C[i] == 'W')
            ++n_w;
        else
            ++n_r;
        assign_min(ans, max(n_w, total_r - n_r));
    }
    cout << ans << LF;
}


Measured memory_bytes: 3472
Q = int(input())
lr = []
maxr = 0
for i in range(Q):
    l,r = map(int,input().split())
    maxr = max(maxr,r)
    lr.append([l,r])
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(3,n + 1) if is_prime[i] and is_prime[(i+1)//2]]
prime = primes(maxr)
import bisect
for l,r in lr:
    print(bisect.bisect_right(prime,r)-bisect.bisect_right(prime,l-1))
    
    

Measured memory_bytes: 20508
import java.util.Scanner;

public class Main{
  static int A,B,Q;
  static Long[] S,T,X;
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    A = sc.nextInt();
    B = sc.nextInt();
    Q = sc.nextInt();
    S = new Long[A+2];
    T = new Long[B+2];
    X = new Long[Q];
    for(int i=1;i<=A;i++){
      S[i]=sc.nextLong();
    }
    S[0]=-100000000000000000L;
    S[A+1]=100000000000000000L;
    for(int i=1;i<=B;i++){
      T[i]=sc.nextLong();
    }
    T[0]=-100000000000000000L;
    T[B+1]=100000000000000000L;
    for(int i=0;i<Q;i++){
      X[i]=sc.nextLong();
    }
    for(int i=0;i<Q;i++){
      System.out.println(Qanswer(i));
    }
  }



  static int binary_search(Long[] Array,Long key,int r,int l){
    int mid = 0;
    if(l-r<=1){
      return r;
    }
    else{
    if(Math.abs(r-l)%2==0){
      mid = (r+l)/2;
    }
    else{
      mid = (r+l)/2+1;
    }
    if(Array[mid]<=key){
      return binary_search(Array,key,mid,l);
    }
    else{
      return binary_search(Array,key,r,mid);
    }
   }
  }

  static Long Qanswer(int i){
    int Snear = binary_search(S,X[i],0,S.length-1);
    int Tnear = binary_search(T,X[i],0,T.length-1);

    return minimum(caliculate(i,Snear,Tnear),caliculate(i,Snear,Tnear+1),caliculate(i,Snear+1,Tnear),caliculate(i,Snear+1,Tnear+1));
    /*if((Snear<=X[i] && Tnear<=X[i]) || (Snear>=X[i] && Tnear>=X[i])){
      return Math.max(Math.abs(X[i]-Snear),Math.abs(X[i]-Tnear));
    }
    else{
      return Math.max(Math.abs(X[i]-Snear),Math.abs(X[i]-Tnear))+2*Math.min(Math.abs(X[i]-Snear),Math.abs(X[i]-Tnear));
    }
    */
  }

   static Long caliculate(int i,int r,int l){
    return Math.min(Math.abs(X[i]-S[r]) + Math.abs(T[l]-S[r]), Math.abs(X[i]-T[l]) + Math.abs(S[r]-T[l]));
  }

  static Long minimum(Long a,Long b,Long c,Long d){
    Long ans = 100000000000000000L;
    Long[] Arra= new Long[4];
    Arra[0] = a;
    Arra[1] = b;
    Arra[2] = c;
    Arra[3] = d;
    for(int i=0;i<4;i++){
      if(ans>=Arra[i]){
        ans = Arra[i];
      }
    }
      return ans;
    }

}

Measured memory_bytes: 104724
n, m = map(int, input().split())
od = (m + 1) // 2
x = 2 * od + 1
for i in range(1, od + 1):
    print(i, x - i)
ev = m - od
y = 2 * ev
for i in range(m - od):
    print(x + i, x + y - i)


Measured memory_bytes: 9212
# https://atcoder.jp/contests/abc102/tasks/arc100_b

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    al = list(map(int, input().split()))

    l, c, r = 1, 2, 3
    P = sum(al[:l])
    Q = sum(al[l:c])
    R = sum(al[c:r])
    S = sum(al[r:])

    ans = max(P, Q, R, S) - min(P, Q, R, S)

    while c <= n - 2:
        while True:
            if l == c - 1:
                break
            if abs(P - Q) < abs((P + al[l]) - (Q - al[l])):  # これ以上差が縮まらないなら break
                break

            P += al[l]
            Q -= al[l]
            l += 1

        while True:
            if r == n - 1:
                break
            if abs(R - S) < abs((R + al[r]) - (S - al[r])): # これ以上差が縮まらないなら break
                break

            R += al[r]
            S -= al[r]
            r += 1

        ans = min(max(P, Q, R, S) - min(P, Q, R, S), ans)

        # center を一つ右に進める
        Q += al[c]
        R -= al[c]
        c += 1

    print(ans)

if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v),v.end()))
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define dbg(x);
#define dbgv(v);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa
#ifdef ALEXPC
#define dbg(x); cout<<#x<<" = "<<x<<endl
#define dbgv(v); cout<<#v<<" = ["; trav(tv,v)cout<<"tv,";cout<<"]"<<endl
#endif

//const int N=100,M=N*N;
const ll MOD=1000*1000*1000+7;

const int N=1e6+6;

ll get(ll a,ll b,ll c){

    //cout<<a<<" "<<b<<" "<<c<<endl;
    b-=b%c;

    //cout<<a<<" "<<b<<" "<<c<<endl;
    if (a>b)return 0;
    //cout<<a<<" "<<b<<" "<<c<<endl;
    ll k=b-a;
    //cout<<k/c+1<<endl;
    return k/c+1;
}

int main(){
    fastio;
    srng;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<b-a+1-(get(a,b,c)+get(a,b,d)-get(a,b,c*d/__gcd(c,d)))<<endl;
    return 0;
}


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

void main()
{
  readln;
  auto a = readln.chomp.split.map!(to!int);
  writeln = a.reduce!max - a.reduce!min;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5)

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

readline = sys.stdin.readline

def process():
    sx, sy, tx, ty = map(int, readline().rstrip().split())
    dx = tx-sx
    dy = ty-sy

    ans = ""
    # covers going both up and down
    ans += 'U'*dy + 'R'*dx + 'D'*dy + 'L'*dx
    # now going up again
    ans += 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
    ans += 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'

    return ans

#for _ in range(int(readline().rstrip())):
print(process())

Measured memory_bytes: 9084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

#define int long long

signed main()
{
	int n, m;
	priority_queue<int> q;

	cin >> n >> m;

	for(int i = 0; i < n; ++i)
	{
		int ai;
		cin >> ai;
		q.push(ai);
	}

	for(int i = 0; i < m; ++i)
	{
		int a = q.top(); q.pop();

		q.push(a / 2);
	}

	int sum = 0;
	for(int i = 0; i < n; ++i)
	{
		sum += q.top(); q.pop();
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653

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

}

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

def selectionSort(a:list, n:int):
    count = 0
    for i in range(n):
        flag = 0
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
                flag = 1
        if flag:
            a[i], a[minj] = a[minj], a[i]
            count += 1
    return a, count

selectionsort_a, count = selectionSort(a, n)
print(" ".join(map(str, selectionsort_a)))
print(count)


Measured memory_bytes: 5600
#include <iostream>
using namespace std;
int main(void){
  int H, N, A[100000];
  int sumA = 0;
  cin >> H >> N;
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++) sumA += A[i];
  if(sumA >= H) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	unordered_map<string,int>m;
	string fs,s; cin>>fs; ++m[fs];
	bool yes=true;
	for(int i=1;i<n;++i){
		cin>>s;
		if(fs.back()!=s.front())yes=false;
		fs=s;
		++m[s];
	}
	for(auto&i:m)if(i.second!=1)yes=false;
	cout<<(yes?"Yes"s:"No"s)<<"\n"s;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{
			//アルファベットのリストを作成。
			char[] chAlf = new char[26];
			char chSubAlf = 'a';
			for(int i = 0; i < chAlf.length; i++){
				chAlf[i] = chSubAlf;
				chSubAlf++;
			}


			//文字を読み取る。
			char[] chLine = new char[1200];
			List<String> list = new ArrayList<String>();
			while(true){
				String strLine = insBR.readLine();
				if(strLine != null && !"".equals(strLine)){
					String[] strLine2 = strLine.split("");
					for(int j = 0; j < strLine2.length; j++){
						list.add(strLine2[j]);
					}
				}else{
					break;
				}
			}

				/*chLine[i] = strLine[i].charAt(i);
				chLine[i] = Character.toLowerCase(chLine[i]);
				System.out.println("chLine" + chLine[i]);*/


			for(int i = 0; i <list.size(); i++){
				chLine[i] = list.get(i).charAt(0);
				chLine[i] = Character.toLowerCase(chLine[i]);
			}

			//文字を数える。
			int[] intCount = new int[chAlf.length];
			for(int i = 0; i < chLine.length; i++){
				for(int j = 0; j < chAlf.length; j++){
					if(chLine[i] == chAlf[j]){
						intCount[j]++;
					}
				}
			}

			//出力。
			for(int i = 0; i < chAlf.length; i++){
				System.out.println(chAlf[i] + " : " + intCount[i]);
			}

		}catch(IOException e){
			e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}
	}

}



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

std::vector<int> s;

bool binarySearch(int left, int right, int value){
	if(left >= right){
		return false;
	}
	int mid = (left + right) / 2;
	if(s[mid] == value){
		return true;
	}else if(s[mid] < value){
		binarySearch(mid+1, right, value);
	}else{
		binarySearch(left, mid, value);
	}
}


int main(void){
	int n;
	std::cin >> n;
	s.resize(n);
	for(int i = 0; i < n; i++){
		std::cin >> s[i];
	}

	int q, value, cnt;
	std::cin >> q;
	cnt = 0;
	for(int i = 0; i < q; i++){
		std::cin >> value;
		if(binarySearch(0, n, value)){
			cnt++;
		}
	}

	std::cout << cnt << std::endl;



	return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 2 == 0) {
			if (a % 3 == 0 || a % 5 == 0) {

			}
			else {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}

	cout << "APPROVED" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
ll a,b;
char op;
int main(){ //srand((unsigned)time(NULL));
  while(1){
    cin >> a >> op >> b;
    if(op == '+')cout << a+b;
    else if(op == '-')cout << a-b;
    else if(op == '*')cout << a*b;
    else if(op == '/')cout << a/b;
    else break;
    cout << endl;
  }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define M 1000000000+7
#define pie 3.141592653589793238
using namespace std;

signed main(){
    int n;cin>>n;
    cout<<pow(n,3);
    return 0;
}

Measured memory_bytes: 384
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N, Q = mi()

Events = []
#イベントを格納する配列
#各要素はタプルで、(s-x or t-x, 1or-1, x)が入っている
#意味は、「時間s-xもしくはt-xに出発する人が」「座標xで」
# 「1:通行止めにぶつかる -1:通行止めにぶつかりそうだったが、助かる」を表す

for _ in range(N):
  s, t, x = mi()
  #1つめの要素がマイナスになることはないので、max(0, hoge)をとる。
  #どちらもマイナスといったコーナーケースでも、「0で通行止めになり0で解除される」となってから時間0に出発する人が処理されるので、影響は出ない
  Events.append((max(0,s-x), 1, x))
  Events.append((max(0,t-x), -1, x))

#イベント配列は「影響を受ける人（の出発時間）」で降順ソートする
#降順ソートなので、pop()でとっていく
from operator import itemgetter
Events = sorted(Events, key=itemgetter(0))
Events = Events[::-1] #降順にする reverseを使うのは、「ひっくり返した状態で」安定じゃないとイベントの入力順がズレてエラーが出るため。reverseを使うと、キーが重複している場合は元の順番を保ってしまう（ひっくり返すと、キーが重複している部分に限っては元の順番と反対になってしまい、「存在しない値を集合からひこうとする」というエラーになる）

#イベント配列ができたので、今度は各人について処理していく
#出力する答えはAnss配列に入れていき、最後にfor文で一気に出力する
Anss = []

#制約より、Diは最初から昇順ソートされている
Ds = [int(input()) for _ in range(Q)]

nowkeptout = set() #今通行止めになっている座標を格納するset。常に昇順ソートする
nextevent = Events.pop()  #次に見るイベント
minstop = 10**9+1
for d in Ds:
  #各ループにおいて、「未処理の人のうち、最も出発時間が早い人」がdに入る
  #ということは、時間dまでのEventsを全て処理すれば、その人がぶつかる場所が分かる
  while nextevent[0]<=d: #dを越えたら止まるし、イベントがなくなっても番兵で止まる
    a, b, c = nextevent
    if b==1: #座標xが通行止めになる
      nowkeptout.add(c)
      minstop = min(c, minstop)
    else: #座標xの通行止めが解除される
      try:
          nowkeptout.remove(c)
      except: 
          pass
      if c==minstop and nowkeptout: minstop = min(nowkeptout)
      elif not nowkeptout: minstop = 10**9+1
    try: nextevent = Events.pop()
    except:
      nextevent = (10**9+1, 1, 1) #要素がなくなったらもう処理が起きないようにする
      break
  #この時点で、nowkeptoutに値が入っている場合も、入っていない場合もある
  #値が入っていれば、dはその最小値の座標で通行止めにぶつかる
  #値が入っていなければ歩き続けるので、-1にする
  if nowkeptout: Anss.append(minstop)
  else: Anss.append(-1)

for ans in Anss:
  print(ans)



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

int main() {
  int X;
  cin >> X;

  switch (X) {
    case 3:
    case 5:
    case 7:
      cout << "YES" << endl;
      break;

    default:
      cout << "NO" << endl;
      break;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();
      int C = in.nextInt();
      int K = in.nextInt();
      long max = Math.max(A, Math.max(B, C));
      long replacedMax = max;

      while (K-- > 0){
        replacedMax *= 2;
      }
  
      System.out.println(replacedMax + A + B + C - max);
    }
  }
}

Measured memory_bytes: 21332
def e_knapsack2(N, W, Goods):
    """
    Dと同じ設定だが、制約が違う(1 <= v_i <= 10^3 と価値の制約がゆるめ)
    """
    import numpy as np
    # dp[v]: 価値vを達成するのに必要な重量の最小値
    # dpの長さは、すべての荷物を入れたときの価値+1で十分
    # 各要素の初期値は、Wを超える値ならよい(np.infだとうまく動作しないが)
    max_value = np.sum(np.array(Goods), axis=0)[1]
    dp = np.full(max_value + 1, W + 1, dtype='int64')
    dp[0] = 0  # 価値0を達成する荷物の重量は0とする
    for w, v in Goods:
        # 価値i(0<=i<=max_value-v)のときの重さの最小値に対し
        # 注目している荷物を入れて、価値i+vのときの重さの最小値を更新
        np.minimum(dp[:-v] + w, dp[v:], out=dp[v:])
    return np.max(np.where(dp <= W))

N, W = [int(i) for i in input().split()]
Goods = [[int(i) for i in input().split()] for j in range(N)]
print(e_knapsack2(N, W, Goods))

Measured memory_bytes: 13604
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n;
 	cin>>n;
 	ll sum=0;
 	for(ll i=1;i<=n;i++)
 	{
 		if(i%3!=0 && i%5!=0)
 		{
 			sum+=i;
 		}
 	}
 	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3640
def check(l):
  n=len(l)
  ret="Yes"
  for i in range(int(n/2)):
    if l[i]!=l[n-1-i]:
      ret="No"
      break
  return ret

S=list(map(str,input()))
N=len(S)
S1=[]
S2=[]
for i in range(N):
  if i<=int((N-1)/2)-1:
    S1.append(S[i])
  if i>=int((N+3)/2)-1:
    S2.append(S[i])

if check(S)=="Yes" and check(S1)=="Yes" and check(S2)=="Yes":
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

int N, K;

long long int x[100005];

long long int L[100005], R[100005];

int main(void) {

	cin >> N >> K;
	long long int tmp;
	for (int i = 1; i <= N; i++) {
		cin >> tmp;
		x[i] = tmp;
	}

	int I;
	for (I = 1; I <= N; I++) {
		if (x[I] >= 0) { break; }
	}

	for (int i = 1; i <= K; i++) { L[i] = 30000000000006; }
	L[0] = 0;
	for (int i = 1; i <= K; i++) { R[i] = 30000000000006; }
	R[0] = 0;

	for (int j = 1; j <= K; j++) {
		if (I - j < 1 ) { break; }
		L[j] =  abs(x[I - j]);
	}

	for (int j = 1; j <= K; j++) {
		if (I + j - 1 > N) { break; }
		R[j] = x[I+j-1];
	}

	long long int ans= 30000000000006;

	for (int m = 0; m <= K; m++) {
		ans = min(ans, L[m]*2 + R[K - m]);
	}
	for (int m = 0; m <= K; m++) {
		ans = min(ans, L[m] + R[K - m]*2);
	}


	/*cout << "I= " << I << endl;
	for (int i = 0; i <= K; i++) {
		cout << "L[" << i << "]= " << L[i] << endl;
	}

	for (int i = 0; i <= K; i++) {
		cout << "R[" << i << "]= " << R[i] << endl;
	}*/

	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 2560
using System;
using System.Linq;
using System.Collections.Generic;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      int A=int.Parse(str[0]);
      int B=int.Parse(str[1]);
      int sum=(3*A)+B;
      Console.WriteLine(sum/2);
    }
    
  }

}


Measured memory_bytes: 27388
import sys
a,b,c,d = [int(num) for num in input().split()]
a_b = abs(b - a)
b_c = abs(c - b)
a_c = abs(a - c)

if a_c <= d:
  print('Yes')
  sys.exit(0)
if a_b <= d and b_c <= d: 
  print('Yes')
  sys.exit(0)
else:
  print('No')

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(vec) (vec).begin(), (vec).end()
#define SUM(...) accumulate(ALL(__VA_ARGS__),0LL)
#define DSUM(...) accumulate(ALL(__VA_ARGS__),0.0)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 便利関数
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;}
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const int INF = 2002002002;
const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x = 0): x((x % mod + mod) % mod) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) {
            x -= mod;
        }
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) {
            x -= mod;
        }
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        return mint(*this) += a;
    }
    mint operator-(const mint a) const {
        return mint(*this) -= a;
    }
    mint operator*(const mint a) const {
        return mint(*this) *= a;
    }
    mint pow(long long t) const {
        if (!t) {
            return 1;
        }
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) {
            a *= *this;
        }
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return *this *= a.inv();
    }
    mint operator/(const mint a) const {
        return mint(*this) /= a;
    }
};
istream& operator>>(istream& is, const mint& a) {
    return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
    return os << a.x;
}

void solve(int N){
    mint ans = 1;
    for (int i = 1; i <= N; i++)
        ans *= i;
    print(ans);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#include <string.h>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define debug2(x, y) cout << #x << " : " << x  << ", " << #y << " : " << y << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;


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


Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
int arr[5][5];
bool vis[5][5];

int main(){
	IOS
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			cin >> arr[i][j];
		}
	}
	int n;
	cin >> n;
	while(n--){
		int x;
		cin >> x;
		for(int i=1;i<=3;i++){
			for(int j=1;j<=3;j++){
				if(arr[i][j]==x){
					vis[i][j]=1;
				}
			}
		}
	}
	if(vis[1][1] and vis[2][2] and vis[3][3]){
		cout << "Yes" << '\n'; return 0;
	}
	if(vis[1][3] and vis[2][2] and vis[3][1]){
		cout << "Yes" << '\n'; return 0;
	}
	for(int i=1;i<=3;i++){
		if(vis[i][1] and vis[i][2] and vis[i][3]){
			cout << "Yes" << '\n'; return 0;
		}
	}
	for(int j=1;j<=3;j++){
		if(vis[1][j] and vis[2][j] and vis[3][j]){
			cout << "Yes" << '\n'; return 0;
		}
	}
	cout << "No" << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int a[200010];

int main() {
    ios_base::sync_with_stdio(0);
    int n; cin >> n;
    for (int i=0;i<n;i++) cin >> a[i];

    int p = 1;
    for (int i=0;i<n;i++) {
        if (a[i]==p) p++;
    }
    cout << (p==1? -1: n-p+1) << endl;
}


Measured memory_bytes: 4404
N = int(input())
A = [int(x) for x in input().split()]

cnt = 0

while True:
    flag = False
    for i in A:
        if i % 2 != 0:
            flag = True
    
    if flag:
        break

    for i in range(len(A)):
        A[i] /= 2
        
    cnt += 1
    
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long i;
  long sorrow = 0;
  long minSorrow = 1000000000;
  vector<long> a(n);
  vector<long> aa(n);
  long maxx=-200000;
  long b=0;
  long avr=0;
  for(i=0;i<n;i++){
    cin >> a[i];
    aa[i] = a[i]-i-1;
  }
  sort(aa.begin(),aa.end());
  if(n%2==0){
    for(i=0;i<n;i++){
      sorrow += abs(aa[i]-(aa[n/2]+aa[n/2-1])/2);
    }
  }else{
    for(i=0;i<n;i++){
      sorrow += abs(aa[i]-aa[n/2]);
    }
  }
  cout << sorrow;

}


Measured memory_bytes: 3328
import java.util.Scanner;


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

        String str;
        str = scan.nextLine();
        char[] charA;
        charA = str.toCharArray();   //char????????????
        
        
        for (int count = 0; count < charA.length; count++){
        	if( Character.isUpperCase(charA[count])){
        		charA[count] = Character.toLowerCase(charA[count]);
        	}
        	else if(Character.isLowerCase(charA[count])){
        		charA[count] = Character.toUpperCase(charA[count]);
            }
        }
        System.out.println(charA);
    }
}     

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

template<class T> T lcm(T a,T b){
	return a/__gcd(a,b)*b;
}

int main(){
	string s,t;
	cin >> s >> t;

	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


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

double W, H, x, y;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> W >> H >> x >> y;
    cout << setprecision(10) << W * H / 2 << " ";
    if (W / 2 == x && H / 2 == y) {
        cout << 1 << "\n";
    } else {
        cout << 0 << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=0
b=0
both=0
ans=0
for i in range(n):
  hoge=input()
  ans+=hoge.count("AB")
  if(hoge[0]=="B" and hoge[-1]=="A"):
    both+=1
  elif(hoge[0]=="B"):
    b+=1
  elif(hoge[-1]=="A"):
    a+=1
if(a==0 and b==0):
  print(ans+max(0,both-1))
else:
  print(ans+both+min(a,b))

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
using namespace std;

int a[222222], b[222222];

int main(void)
{
	int n, i, amid, bmid;

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

	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);

	if (n % 2)
		amid = a[n / 2 + 1] * 2, bmid = b[n / 2 + 1] * 2;
	else
		amid = a[n / 2] + a[n / 2 + 1], bmid = b[n / 2] + b[n / 2 + 1];

	printf("%d" ,(bmid - amid) / (n % 2 + 1) + 1);
	return 0;
}


Measured memory_bytes: 3300
// syakyo http://d.hatena.ne.jp/simezi_tan/20120906/1346880190

#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

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

int n;
vector<int> x, y, v;

inline double d(int i, double a, double b){
    return sqrt((x[i] - a)*(x[i] - a) + (y[i] - b)*(y[i] - b));
}

inline double g(double a, double b){
    double res = 0;
    rep(i, n){
        res = max(res, d(i, a, b)/v[i]);
    }
    return res;
}

inline double f(double x){
    double l = 0, r = 100, a, b;
    rep(i, 100){
        a = (l * 2 + r) / 3;
        b = (l + r * 2) / 3;
        if (g(x, a)>g(x, b)) l = a;
        else r = b;
    }
    return g(x, l);
}

int main(){
    while (cin >> n, n){
        x = vector<int>(n), y = vector<int>(n), v = vector<int>(n);
        rep(i, n){
            cin >> x[i] >> y[i] >> v[i];
        }
        double l = 0, r = 100, a, b;
        rep(i, 100){
            a = (l * 2 + r) / 3;
            b = (l + r * 2) / 3;
            if (f(a) > f(b)) l = a;
            else r = b;
        }
        cout << fixed << setprecision(20);
        cout << f(l) << endl;
    }
}

Measured memory_bytes: 1264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ARC77_C
{
    class Program
    {
        static void Main(string[] args)
        {

            var n = int.Parse(Console.ReadLine());

            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var ans = new int[10000000];
            int left = 10000000 / 2;
            int right = left + 1;
            for (int i = 0; i < n; i++)
            {
                if (i % 2 == (n - 1) % 2)
                {
                    ans[left--] = a[i];
                }
                else
                {
                    ans[right++] = a[i];
                }
            }
            for (int i = left+1; i < right; i++)
            {
                Console.Write(ans[i] + " ");
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 33472