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

using ll = long long;

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int a, b, c, d, e, f, ansx, ansy;
bool water[3001], suger[3001];

int main() {
    cin >> a >> b >> c >> d >> e >> f;
    a *= 100;
    b *= 100;

    water[0] = suger[0] = true;

    for (int i = 0; i <= f; ++i) {
        if (i >= a) water[i] = water[i] | water[i - a];
        if (i >= b) water[i] = water[i] | water[i - b];
        if (i >= c) suger[i] = suger[i] | suger[i - c];
        if (i >= d) suger[i] = suger[i] | suger[i - d];
    }

    ansx = a, ansy = 0;

    for (int x = 0; x <= f; x+=100) {
        if (water[x]) {
            for (int y = 0; y <= f - x; ++y) {
                if (suger[y]) {
                    if (x * e < y * 100) break;

                    if ((x + y) * ansy < y * (ansx + ansy)) {
                        ansx = x;
                        ansy = y;
                    }
                }
            }
        }
    }

    cout << ansx + ansy << " " << ansy << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    ll N;
    cin >> N;
    int ans = 0;
    for (ll k = 1; k * k <= N - 1; k++) {
        if ((N - 1) % k == 0) {
            ans++;
            if ((N - 1) / k != k) {
                ans++;
            }
        }
    }
    for (ll k = 1; k * k <= N; k++) {
        if (N % k == 0) {
            ll n = N;
            while (n % k == 0 && k != 1) {
                n /= k;
            }
            if (n % k == 1) {
                ans++;
            }

            if (N / k != k) {
                ll kk = N / k;
                n = N;
                while (n % kk == 0 && kk != 1) {
                    n /= kk;
                }
                if (n % kk == 1) {
                    ans++;
                }
            }
        }
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define Mod 1000000007
using namespace std;
bool vis[610];
int A[310],B[310];
int val[610];
int n,k;
bool check(int a,int b,int x,int y)
{
	return (x<=a&&a<=y)^(x<=b&&b<=y);
}
int dp[610][610],Dp[610][610];
int f(int,int);
int F(int,int);
int f(int x,int y)
{
	if(y<=x)return 0;
	if(dp[x][y]!=-1)return dp[x][y];
	dp[x][y]=0;
	for(int i=1;i<=k;i++)
		if(check(A[i],B[i],x,y))return 0;
	int cnt=0;
	for(int i=x;i<=y;i++)
		if(!vis[i])cnt++;
	dp[x][y]=val[cnt];
	for(int i=y-1;i>x;i--)
		dp[x][y]=(dp[x][y]-(long long)f(i,y)*F(x,i-1)%Mod+Mod)%Mod;
	return dp[x][y];
}
int F(int x,int y)
{
	if(y<=x)return 0;
	if(Dp[x][y]!=-1)return Dp[x][y];
	Dp[x][y]=0;int cnt=0;
	for(int i=y;i>=x;i--)
	{
		Dp[x][y]=(Dp[x][y]+(long long)f(x,i)*val[cnt])%Mod;
		if(!vis[i])cnt++;
	}
	return Dp[x][y];
}
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d %d",&A[i],&B[i]);
		vis[A[i]]=vis[B[i]]=true;
	}
	val[0]=1;
	for(int i=2;i<=n*2;i+=2)
		val[i]=(long long)val[i-2]*(i-1)%Mod;
	memset(dp,-1,sizeof(dp));
	memset(Dp,-1,sizeof(Dp));
	int ans=0;
	for(int i=1;i<n*2;i++)
		for(int j=i+1;j<=n*2;j++)
		{
			int cnt=0;
			for(int k=1;k<i;k++)
				if(!vis[k])cnt++;
			for(int k=j+1;k<=n*2;k++)
				if(!vis[k])cnt++;
			ans=(ans+(long long)f(i,j)*val[cnt])%Mod;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long int llint;

llint K;
llint N, M;

int main() {
	cin >> N >> M >> K;
	vector<llint> A(N + 1);
	A[0] = 0;

	llint ans = 0;
	llint now = 0;
	llint a_num = 0;//Ａを何冊目まで読むか
	bool flag = false;//読むのを中止
	for (int i = 1; i < N + 1; i++) {
		cin >> A[i];
		if (now + A[i] <= K && !flag) {
			now += A[i];
			a_num++;
			//cout << "A" << a_num << " " << now << endl;
		}
		else {
			flag = true;
		}
	}
	ans = a_num;

	llint next = ans;
	for (int i = 0; i < M; i++) {
		llint B;
		cin >> B;
		now += B;
		if (now <= K) {
			next++;
		}
		//cout << "B" << next << " " << now << endl;
		if(now > K) {
			while (now > K && a_num > 0) {
				now -= A[a_num];
				a_num--;
				next--;
				//cout << "B" << next << " " << now << endl;
			}
			if (now <= K) { next++; }
		}

		ans = max(ans, next);
	}
	cout << ans << endl;
}


Measured memory_bytes: 4848
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
l = [i + a[i] for i in range(n)]
r = [i - a[i] for i in range(n)]
countl = Counter(l)
countr = Counter(r)
ans = sum([countl[i]*countr[i] for i in countl.keys()])
print(ans)

Measured memory_bytes: 63348
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , M=0;
  cin >> N;
  vector<int> vec(N);
  for(int i=0 ; i<N ; i++)
    cin >> vec.at(i);
  sort(vec.begin() , vec.end());
  for(int j=0 ; j<N-1 ; j++)
    M+=vec.at(j);
  if(vec.at(N-1)<M)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  1000005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
ll spf[N]; 
void seive() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<N; i++) 
        spf[i] = i; 
    for (ll i=4; i<N; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<N; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<N; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
vi getFactorization(ll x) 
{ 
    vi ret; 
    while (x != 1) 
    { 
        ret.pb(spf[x]);
        ll p=spf[x];
        while(x%p==0) 
            x=x/p; 
    } 
    return ret; 
} 
void solve()
{
  seive();
  ll n;
  cin>>n;
  ll a[n];
  ll g=0;
  rep(i,0,n) cin>>a[i],g=__gcd(g,a[i]);
  if(g!=1){
    cout<<"not coprime";
    return;
  }
  set <ll> s;
  repr(i,0,n){
    vi tmp=getFactorization(a[i]);
    bool f=1;
    for(auto j:tmp) if(s.count(j)) {
      cout<<"setwise coprime";
      return ;
    }
    else s.insert(j);
  }
  cout<<"pairwise coprime";
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

Measured memory_bytes: 19392
n = int(input())
h = [None] + list(map(int, input().split(' ')))

dp = [None for _ in range(n+1)]
# dp[0], dp[1], ..., dp[n] が用意される

for k in range(1, n+1): # 1, 2, ..., n
  if k == 1:
    dp[k] = 0
  elif k == 2:
    dp[k] = abs(h[2] - h[1])
  else:
    dp[k] = min(
      dp[k-1] + abs(h[k] - h[k-1]),
      dp[k-2] + abs(h[k] - h[k-2])
    )

print(dp[n])



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

length = sum(a)

x = 0
for i in range(n):
  if x+a[i] > length /2:
    y = length - (x + a[i])
    break
  x += a[i]

z = min(y+a[i]-x,x+a[i]-y)
print(z)


Measured memory_bytes: 26764
#include<cstdio>
int C[499],S[499],F[499],N,i=-1,j,t;int main(){scanf("%d",&N);for(;++i<N-1;)scanf("%d%d%d",C+i,S+i,F+i);for(i=0;i<N;i++){t=0;for(j=i;j<N-1;j++){if(t<S[j])t=S[j];else t=(t-S[j]+F[j]-1)/F[j]*F[j]+S[j];t+=C[j];}printf("%d\n",t);}return 0;}

Measured memory_bytes: 128
import java.util.Scanner;

//20180510
//01

public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int r = scanner.nextInt();
		int c = scanner.nextInt();
		int[][] output = new int[100+1][100+1];

		for(int i = 0;i < r;i++) {
			int ans_r = 0;
			for(int j = 0;j < c;j++) {
				output[i][j] = scanner.nextInt();
				ans_r += output[i][j];
				output[r][j] += output[i][j];
			}
			output[i][c] += ans_r;
		}

		for(int y = 0;y < c;y++) {
			output[r][c] += output[r][y];
		}

		scanner.close();

		for(int i = 0;i <= r;i++) {
			for(int j = 0;j < c;j++) {
					System.out.printf("%d ",output[i][j]);
			}
			System.out.println(output[i][c]);
		}
    }
}


Measured memory_bytes: 52904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
#define forn(i,n) for(int i=0; i < int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define fst first
#define snd second

int main() {
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vll cnt(k);
    for (int i = 1; i <= n; ++i)
        ++cnt[i % k];
    ll ans = 0;
    ans += cnt[0] * cnt[0] * cnt[0];
    if (k % 2 == 0)
        ans += cnt[k/2] * cnt[k/2] * cnt[k/2];
    cout << ans << '\n';
}


Measured memory_bytes: 1792
n, k = list(map(int, input().split(" ")))
s = input()
str_list = list(s)

# リストの3番目の要素を'z'で上書き
str_list[k - 1] = s[k - 1].lower()

# またリストから文字列へ戻す
str_changed = "".join(str_list)
print(str_changed)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define PB push_back
#define F first
#define S second
#define MP m ake_pair
#define LB lower_bound
#define UB upper_bound

using namespace std;
typedef long long ll;
typedef pair<int , int> pii;
typedef long double DB;

int main(){

	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	ll a , b , c , k;
	cin >> a >> b >> c >> k;
	
	if(k%2)
	   cout << b-a << endl;
	else
	   cout << a-b << endl;

	return 0;
}

Measured memory_bytes: 256
import math
from decimal import *
import random

def pf(n):
    ans = [1]
    if(n%2==0):
        if(n!= 2):
            ans.append(2)
        while(n%2==0):
            n//=2
    p = 3
    while(n>1):
        if(n%p==0):
            ans.append(p)
            while(n%p==0):
                n//=p
        p+=1
    return ans

n,x,k = map(int, input().split())
print(math.ceil(n/x)*k)


Measured memory_bytes: 77204
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
    int a,b,c,d;
    string s;
    cin >> s;
    if(s.at(0)==s.at(1) && s.at(1)==s.at(2)){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> in_degree;
vector<int> vis;
vector<int> dist;

void dfs(vector<vector<int> >& edge,int start){
	
	vis[start] = 1;
	for(auto b : edge[start]){
		in_degree[b]--;
		dist[b] = max(dist[b],dist[start] + 1);
		if(in_degree[b]==0 )
		dfs(edge,b);
	}
	
}


int main(){
	
	int n,m;
	cin>>n>>m;
	vector<vector<int> > edge(n+1);
	in_degree.resize(n+1,0);
	vis.resize(n+1,0);
	dist.resize(n+1,0);
	int aa,bb;
	for(int i=0;i<m;i++){
		cin>>aa>>bb;
		edge[aa].push_back(bb);
		in_degree[bb]++;
	}
	
	for(int i=1;i<=n;i++){
		if(vis[i]==0 && in_degree[i]==0){
			dfs(edge,i);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans = max(ans,dist[i]);
	}
	cout<<ans;
	
	return 0;
	
	
	
}


Measured memory_bytes: 11520
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 4050;

class Fenwick {
private:
  vector <long long> f;
public:
  void init(int n) {
    f.assign(n, 0);
  }
  void update(int pos, int delta) {
    for (; pos < sz(f); pos = (pos | (pos + 1))) {
      f[pos] += delta;
    }
  }
  long long sum(int pos) {
    long long res = 0;
    for (; pos >= 0; pos = (pos & (pos + 1)) - 1) {
      res += f[pos];
    }
    return res;
  }
  long long sum(int l, int r) {
    return sum(r) - sum(l - 1);
  }
};

int n;
int a[MAXN];
int col[MAXN];
int apos[MAXN][2];
int dp[MAXN][MAXN][2];
Fenwick f[2];
int inv[MAXN];
int sum[MAXN][MAXN];

int calc(int pos, int num, int col) {
  int& res = dp[pos][num][col];
  if (res != -1) {
    return res;
  }
  res = 0;
  int otherNum = pos + 1 - num;
  if (pos == n) {
    return res;
  }
  if (otherNum > n / 2 || num > n / 2) {
    res = 1e9;
    return res;
  }
  int curPos = apos[num][col];
  res = inv[curPos];
  res += sum[curPos][otherNum + 1];
  res += min(calc(pos + 1, num + 1, col), calc(pos + 1, otherNum + 1, 1 - col));
  return res;
}

int main() { 

  scanf("%d\n", &n);
  n *= 2;
  for (int i = 0; i < n; i++) {
    char c;
    scanf("%c %d\n", &c, &a[i]);
    col[i] = (c == 'W');
    apos[a[i]][col[i]] = i;
  }

  f[0].init(n); f[1].init(n);

  for (int i = 0; i < n; i++) {
    for (int j = i - 1; j >= 0; j--) {
      if (col[i] == col[j] && a[j] > a[i]) {
        inv[i]++;
      }
    }
    for (int j = 1; j <= n; j++) {
      sum[i][j] = f[1 - col[i]].sum(j - 1, n - 1);
    }
    f[col[i]].update(a[i] - 1, 1);
  }

  memset(dp, -1, sizeof(dp));

  cout << min(calc(0, 1, 0), calc(0, 1, 1)) << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

ll mod = 1e9 + 7;
ll ans;
ll n,k;
vvi graph;


void dfs(int node, int parent, ll pos) {
    if (!ans) return;
    ans = ans * max(0LL,pos);
    ans %= mod;
    int x = k - ((parent == 0) ? 1 : 2);
    for (auto u : graph[node]) {
        if (u == parent) continue;
        dfs(u, node, x);
        x--;
    }
}

void solve() {
   cin >> n >> k;
   graph = vvi(n+1);
   ans = 1;

   for (int i = 1; i < n; ++i) {
       int a, b; cin >> a >> b;
       graph[a].push_back(b);
       graph[b].push_back(a);
   }
   dfs(1,0,k);
   cout << ans << endl;
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 9216
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
int n,k;
cin>>n>>k;
string s;
cin>>s;
int l=0,r=0,ans=0;
while(r<n){
	while(r<n&&s[r]=='1')r++;
	chmax(ans,r-l);
	while(r<n&&s[r]=='0')r++;
	k--;
	if(k<0){
		while(l<n&&s[l]=='1')l++;
		while(l<n&&s[l]=='0')l++;
	}
	chmax(ans,r-l);
}
cout<<ans<<endl;
}



Measured memory_bytes: 512
dice = input().split()
q = int(input())
for x in range(q):
    n, m = input().split()
    # 上面を合わせる
    d1 = {dice[0]: "123456", dice[1]: "263415", dice[2]: "326154", dice[3]: "421653", dice[4]: "513462",
          dice[5]: "653421"}
    dice = [dice[int(i) - 1] for i in d1[n]]
    # 側面を合わせる
    d2 = {dice[1]: "123456", dice[2]: "135246", dice[3]: "142536", dice[4]: "154326"}
    dice = [dice[int(i) - 1] for i in d2[m]]
    print(dice[2])



Measured memory_bytes: 5600
x1, y1, x2, y2 = map(int, input().split())
x3 = y1 - y2 + x2
y3 = -(x1 - x2) + y2
x4 = -(y2 - y1) + x1
y4 = x2 - x1 + y1
print(x3, y3, x4, y4)

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

int main()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;

	double k = abs(h*30+(double)(m/2)-m*6);
	k = min(k,360-k);
	double pi = acos(-1.0);
	cout<<fixed<<setprecision(15)<<sqrt(abs(a*a+b*b-a*b*2*cos(k/180.0*pi)));
	return 0;
}

Measured memory_bytes: 4124
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};
const main=()=>{
  let[n,m,x,y]=tnn(4)
  let[xx,yy]=[tnn(n),tnn(m)]
  let f;
  for(let j=x+1;j<=y;j++){
    f=false
    for(let i=0;i<n;i++){
      if(xx[i]>=j){
        f=true
        break
      }
    }
    for(let i=0;i<m;i++){
      if(yy[i]<j){
        f=true
        break
      }
    }
    if(!f){break}
  }
  to(f?'War':'No War')
}
main()

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N, L;
    cin >> N >> L;
    
    int taste = L;
    int sum_taste = L;
    for (int i = 1; i < N; i++) {
        if (abs(taste) > abs(L+i)) {
            taste = L+i;
        }
        sum_taste += L+i;
    }
    cout << sum_taste - taste << endl;
}

Measured memory_bytes: 256
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())

n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n):
    if p[i] != i+1:
        cnt += 1
print('YES') if cnt <= 2 else print('NO')

Measured memory_bytes: 5076
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

const int MAXV = 100005;
const int BLACK = 1;    // odd
const int WHITE = 0;    // even

vector<vector<P>> to(MAXV);
vector<int> col(MAXV);
void dfs(int v, int p, int len) {
  col[v] = p < 0 ? WHITE : (col[p] + len) % 2;
  for(auto u : to[v]) {
    if(u.first == p) continue;
    dfs(u.first, v, u.second);
  }
}

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

  col.resize(n);
  rep(i, n) col[i] = -1;

  rep(i, n - 1) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    to[u].push_back(make_pair(v, w));
    to[v].push_back(make_pair(u, w));
  }
  dfs(0, -1, 0);
  rep(i, n) printf("%d\n", col[i]);
  return 0;
}

Measured memory_bytes: 8448
n,x,y=map(int,input().split())
def dist(i,j):
  if i>=j:
    d=0
  else:
    d=min(abs(j-i),abs(y-j)+1+abs(x-i),abs(y-i)+1+abs(x-j))
  return d
distmap=[0]*n
for l in range(2,n+1):
  for k in range(1,l):
    distmap[dist(k,l)]+=1
print('\n'.join(map(str,distmap[1:])))

Measured memory_bytes: 3188
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(len(l)-2):
    t = []
    t.append(l[i])
    t.append(l[i+1])
    t.append(l[i+2])
    if (max(t) != t[1] and min(t) != t[1]):
        ans += 1

print(ans)



Measured memory_bytes: 3060
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
MOD = 10**9+7
K1 = ((K-1)*(K)//2)%MOD
K2 = ((K+1)*(K)//2)%MOD
for i in range(N):
    for j in range(i):
        if A[i] > A[j]:
            ans += K1
    for j in range(i+1,N):
        if A[i] > A[j]:
            ans += K2
print(ans%MOD)

Measured memory_bytes: 41836
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (100000 + 2)
#define MAX_M (200000 + 2)

ll pos[MAX_N];
bool is_check[MAX_N];
int l[MAX_M], r[MAX_M], d[MAX_M];
int n, m;

vector<ipair> edge[MAX_N];

bool check(int node, ll dist){
  if (is_check[node]) {
    if (pos[node] != dist) {
      return false;
    }
    return true;
  }

  is_check[node] = true;
  pos[node] = dist;

  for (int i = 0; i < edge[node].size(); i++){
    int dest = edge[node][i].first;
    ll distance = edge[node][i].second;

    bool result = check(dest, pos[node] + distance);
    if (!result) {
      return false;
    }
  }

  return true;
}

void exec(){
  cin >> n >> m;

  for (int i = 0; i < m; i++){
    scanf("%d%d%d", &l[i], &r[i], &d[i]);
    edge[l[i]].push_back(ipair(r[i], d[i]));
    edge[r[i]].push_back(ipair(l[i], -d[i]));
  }

  bool result = true;
  for (int i = 1; i <= n; i++){
    if (!is_check[i]) {
      bool tmp = check(i, 0);
      if (!tmp) {
        result = false;
        break;
      }
    }
  }

  cout << (result ? "Yes" : "No") << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


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

int main(){
    int a,b,c,n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a >> b >> c ;
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > b) swap(a, b);
        if(a * a + b * b == c * c) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 2988
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
	public static long sumXOR(long arr[], int n) 
    { 
    	long mod= (long)1e9+7;
        long sum = 0; 
        for (long i = 0; i < 63; i++)  
        { 
            long zc = 0;  
            long idsum = 0;  
            long k=(long)(1l << i);
            for (int j = 0; j < n; j++) 
            { 
                if ((arr[j]&k)==0) 
                    {zc++;}  
            }             
            k%=mod;
            long x=(long)zc*(n-zc);
            x%=mod;
            idsum = (long) x*k;  
            sum = (long)(sum+idsum)%mod;  
        } 
        return sum; 
    } 
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
      int n=s.nextInt();
      long[] arr=new long[n];
      for(int i=0;i<n;i++){
      	arr[i]=s.nextLong();
      } 	
      long res=sumXOR(arr,n);
      System.out.println(res);
      }
        }
    


Measured memory_bytes: 99524
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define ll long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const ll MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
int N;
vector<ll> A, X;






//サブ関数
//入力
void input()
{
	cin >> N;
	A.resize(N + 1);
	REP(i, N)cin >> A[i + 1];
	X = A;
}

void transform()
{
	REP(i, N)A[i + 1] += A[i];
	REP(i, N)X[i + 1] ^= X[i];
}

bool same(int l, int r)
{
	ll a = A[r] - A[l];
	ll x = X[r] ^ X[l];
	return x == a;
}

//計算
void calc()
{
	transform();
	ll res = 0;
	REP(i, N) {
		int l = i;
		int r = N;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (same(i, mid))l = mid;
			else r = mid;
		}
		if (same(i, r))res += r - i;
		else res += l - i;
	}
	cout << res << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 3328
while 1 :
    n=int(input())
    if n==-1:
        break
    else:
        if n<=10:
            w=1150
        elif 10<n<=20:
            w=1150+(n-10)*125
        elif 20<n<=30:
            w=2400+(n-20)*140
        else:
            w=3800+(n-30)*160
        print(4280-w)


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

using namespace std;

unordered_set<string> seen;
bool visited[26];

int main()
{
    string s;
    int k;
    cin >> s >> k;
    int n = (int) s.length();
    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j <= k && i + j <= n; j++)
        {
            seen.insert(s.substr(i, j));
        }
    }
    vector<string> vec;
    for (string str : seen)
        vec.push_back(str);
    sort(vec.begin(), vec.end());
    cout << vec[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(){
    int i=0,t=0;
    char s[1001]={};
    for(;scanf("%s",s),s[0]!='0';printf("%d\n",t))
        for(i=0,t=0;s[i]!='\0';i++){
            t+=s[i]-'0';
        }
}

Measured memory_bytes: 1800
#include<iostream>
#include<string>

using namespace std;

int main(){
    int N;
    string S;

    cin>>N;
    cin>>S;

    int ans = 0;

    for(int i=0; i<N-2; i++){
        if(S.substr(i,3) =="ABC"){
            ans++;
        }
    }

    cout<<ans;
    return 0;
}

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

using namespace std;

bool check(int a, int b, int c) {
    if (a == b || b == c || c == a) return false;
    if (a + b <= c || b + c <= a || c + a <= b) return false;
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int& x : l) cin >> x;
    int ans = 0;
    for (int i = 0; i < n - 2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            for (int k = j + 1; k < n; k++) {
                if (check(l[i], l[j], l[k])) ans++;
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3612
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define rrep(i,n) for(ll i=(ll)n-1;i>=0;--i)
#define vin(v,n) rep(i,n)cin>>v[i];
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define sz size()
#define fi first
#define se second
#define pb push_back
#define prqueue priority_queue<ll,vector<ll>,greater<ll>>
#define print(s) cout<<s<<endl;
#define inp(s) cin>>s;
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll a, b, c, d, e,ans,ct,v[100010];
string s, ss, sss;
int main() {
	inp(a>>b>>c);
	v[0] = abs(a - b);
	v[1] = abs(b - c);
	v[2] = abs(c - a);
	sort(v, v + 3);
	print(v[0]+v[1]);
	return 0;
}

Measured memory_bytes: 256
n = str(input())
if n[len(n) - 1] == '3':
    print('bon')
elif n[len(n) - 1] == '0' or n[len(n) - 1] == '1' or n[len(n) - 1] == '6' or n[len(n) - 1] == '8':
    print('pon')
else:
    print('hon')

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

const int MAX = 100000;
int n, pa[MAX], le[MAX], ri[MAX], cnt, H[MAX];

void makeH(){
  fill(H,H+MAX,-1);
  for(int i=0;i<n;i++){
    int cnt = 0;
    for(int j=i; j!=-1; j=pa[j]){
      if(H[j] < cnt) H[j] = cnt;
      cnt++;
    }
  }
}

void solve(){
  for(int i=0;i<n;i++){
    cout << "node " << i << ": parent = " << pa[i] << flush;

    if(pa[i] == -1) cout << ", sibling = " << -1 << flush;
    else if(le[pa[i]] != i) cout << ", sibling = " << le[pa[i]] << flush;
    else cout << ", sibling = " << ri[pa[i]] << flush;

    cnt = 0;
    if(le[i] != -1) cnt++;
    if(ri[i] != -1) cnt++;
    cout << ", degree = " << cnt << flush;

    cnt = 0;
    for(int j=pa[i]; j!=-1; j=pa[j]) cnt++;
    cout << ", depth = " << cnt << flush;

    cout << ", height = " << H[i] << flush;

    if(pa[i] == -1) cout << ", root" << endl;
    else if(le[i] == -1 && ri[i] == -1) cout << ", leaf" << endl;
    else cout << ", internal node" << endl;
  }

}

int main(){
  cin >> n;
  fill(pa,pa+MAX,-1);
  fill(le,le+MAX,-1);
  fill(ri,ri+MAX,-1);
  for(int i=0;i<n;i++){
    int a,b,c;
    cin >> a >> b >> c;
    le[a] = b;
    ri[a] = c;
    pa[b] = a;
    pa[c] = a;
  }
  makeH();
  solve();
}

Measured memory_bytes: 2724
import sys
s = int(input())
A = [False] * 1_000_001
cnt = 1
A[s] = True


def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


while True:
    s = f(s)
    cnt += 1
    if A[s]:
        print(cnt)
        sys.exit()
    else:
        A[s] = True


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

using namespace std;

struct pos{
  int x, y;
};
struct rect{
  pos lt, rb;
};

int H, W;
char pjt[55][55];

map<char, rect> bg;

bool judge(const vector<char> &vec)
{
  string ex = "";
  for(auto &v : vec){
    ex += v;
    for(int i = bg[v].lt.y; i <= bg[v].rb.y; i++){
      for(int j = bg[v].lt.x; j <= bg[v].rb.x; j++){
	if(ex.find(pjt[i][j]) == string::npos) return false;
      }
    }
  }
  return true;
}

int main()
{
  int N; cin >> N;
  while(N--){
    bg.clear();
    cin >> H >> W;
    vector<char> mtl;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
	cin >> pjt[i][j];
	if(pjt[i][j] == '.') continue;
	if(bg.count(pjt[i][j]) == 0){	  
	  mtl.push_back(pjt[i][j]);
	  bg[pjt[i][j]].lt.x = j;
	  bg[pjt[i][j]].lt.y = i;
	  bg[pjt[i][j]].rb.x = j;
	  bg[pjt[i][j]].rb.y = i;
	} else {
	  bg[pjt[i][j]].lt.x = min(bg[pjt[i][j]].lt.x, j);
	  bg[pjt[i][j]].lt.y = min(bg[pjt[i][j]].lt.y, i);
	  bg[pjt[i][j]].rb.x = max(bg[pjt[i][j]].rb.x, j);
	  bg[pjt[i][j]].rb.y = max(bg[pjt[i][j]].rb.y, i);
	}
      }
    }
    sort(mtl.begin(), mtl.end());
    bool flag = false;
    do{
      flag |= judge(mtl);
      if(flag) break;
    }while(next_permutation(mtl.begin(), mtl.end()));
    if(!flag) cout << "SUSPICIOUS" << endl;
    else cout << "SAFE" << endl;
  }
  return 0;
}

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

#define ll long long
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

int check(string i){
    int num = stoi(i);
    int check7 = 0;
    int check5 = 0;
    int check3 = 0;
    while(num!=0){
        if(num%10==7) check7 = 1;
        if(num%10==5) check5 = 1;
        if(num%10==3) check3 = 1;
        num/=10;
    }
    if(check7*check5*check3==1) return 1;
    return 0;
}

int search(string i, int N){
    int cnt = 0;
    if(stol(i)>N) return 0;  
    if(check(i)) cnt++;

    cnt += search(i+"7", N);
    cnt += search(i+"5", N);
    cnt += search(i+"3", N);

    return cnt;
}

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

    cout << search("3", N) + search("5", N) + search("7", N)<< endl;
    return 0;
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }



signed main() {

	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> A(Q);
	vector<int> cnt(N, 0);
	rep(i, Q) {
		cin >> A[i];
		A[i]--;

		cnt[A[i]]++;
	}

	rep(i, N) {
		if (K <= Q - cnt[i]) cout << "No" << endl;
		else cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    vector<long long> V(3);
    for ( int i = 0; i < 3; i++ ) {
        cin >> V[i];
    }
    int K;
    cin >> K;
    sort( V.begin(), V.end() );
    for ( int i = 0; i < K; i++ ) {
        V[2] *= 2;
    }
    long long ans = 0;
    for ( int i = 0; i < 3; i++ ) {
        ans += V[i];
    }

    cout << ans << endl;

    return 0;
}

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

#include<stdlib.h>
#include<iostream>
#include<math.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define INF 2000000000
#define Min(a,b) (a<b?a:b)
#define Max(a,b) (a>b?a:b)
#define PI 3.1415926535897932
using namespace std;

int main()
{
IOS;
int t;
cin>>t;
if(t>=30){
	cout<<"Yes"<<endl;
}
else{
		cout<<"No"<<endl;
}

	


return 0;
}

Measured memory_bytes: 3656
X,Y,A,B,C=map(int,input().split())
P=sorted(list(map(int,input().split())))
Q=sorted(list(map(int,input().split())))
R=sorted(list(map(int,input().split())))
S=sorted(P[A-X:]+Q[B-Y:])
ans=sum(S)
for i in range(min(len(R),len(S))):
    if S[i]<R[-1-i]:
        S[i]=R[-1-i]
    else:
        break
print(sum(S))

Measured memory_bytes: 23200
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskD {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int t = in.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
			}

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

			long[] suff = new long[n];
			boolean[] peak = new boolean[n];
			for (int i = n - 1; i >= 0; i--) {
				suff[i] = a[i];
				if (i + 1 < n && suff[i] < suff[i + 1]) {
					suff[i] = suff[i + 1];
				} else {
					peak[i] = true;
				}
			}

			long min = Integer.MAX_VALUE;
			List<Long> v = new ArrayList<>();
			for (int i = 0; i + 1 < n; i++) {
				if (peak[i]) {
					min = Integer.MAX_VALUE;
					continue;
				}

				min = Math.min(min, a[i]);
				if (peak[i + 1]) {
					v.add(a[i + 1] - min);
				}
			}

			Collections.sort(v);
			Collections.reverse(v);
			int ans = 0;
			for (int i = 0; i < v.size(); i++) {
				if (v.get(i).equals(v.get(0))) {
					++ans;
				}
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 29472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl
const ll INF = 1e18;
using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
    auto c3 = [](const P &a, const P &b, const P &c){
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b){
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c){
        return norm(a - c.pnt) <= c.rad*c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}



int n,m;
ld r[111], mb[111];
 
bool used[111];

bool chk(int s){
    vector<int> b;
    rep(i,n)if(!used[i]) b.emplace_back(r[i]);
    vector<ld> a;
    for(int i = s; i < m; ++i) a.emplace_back(mb[i]);
    sort(all(a));
    sort(all(b));
    int last = -1;
    rep(i,a.size()){
        bool found = false;
        for(int j = last+1; j < (int)b.size(); ++j){
            if(a[i] < b[j] + eps){
                found = true;
                last = j;
                break;
            }
        }
        if(!found)return false;
    }
    return true;
}

int main(){
    ll N;
    cin >> N;
    double x[55], y[55];
    rep(i,N) cin >> x[i] >> y[i];
    vector<P> v;
    rep(i,N){
        P c1(x[i], y[i]);
        v.push_back(c1);
    }
    auto res = smallest_enclosing_disc(v);
    double ans = res.first;
    cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q1(){
	string s;	cin>>s;
	if(s[0]=='S'){
		if(s[1]=='A'){
			cout<<"1";
		} else{
			cout<<"7";
		}
	} else if(s[0]=='M'){
		cout<<"6";
	} else if(s[0]=='T'){
		if(s[1]=='U'){
			cout<<"5";
		} else{
			cout<<"3";
		}
	} else if(s[0]=='W'){
		cout<<"4";
	} else if(s[0]=='F'){
		cout<<"2";
	}
}
void q2(){
	int n; string s; cin>>n>>s;
	for(int i=0;i<(int)s.size();++i){
		int tp=s[i]-'A';
		tp+=n;
		tp%=26;
		tp+='A';
		s[i]=tp;
	}
	cout<<s;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q2();
	return 0;
}
	


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

int main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	rep(i, n)  {
		int a;
		cin >> a;
		if (a >= k) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import math


def main():
    s = input().split(" ")
    a = float(s[0])
    b = float(s[1])
    x = float(s[2])
    if(a * a * b / 2 < x):
        print(math.atan(2 * (a * a * b - x) / a / a / a) / math.pi * 180)
    else:
        print(math.atan(a * b * b / 2 / x) / math.pi * 180)


if(__name__ == "__main__"):
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX;
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;




int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	ll n,i,j;
	string s;
	cin>>n>>s;
	vector<char> alpha;
	vector<int> alnum;
	vector<char>::iterator it;
	for(i=0;i<n;i++){
		it=find(alpha.begin(),alpha.end(),s[i]);
		if(it!=alpha.end()){
			alnum[it-alpha.begin()]++;
		}
		else{
			alpha.push_back(s[i]);
			alnum.push_back(1);
		}
	}
	ll ans=1;
	for(i=0;i<alpha.size();i++){
		ans*=alnum[i]+1;
		ans%=1000000007;
	}
	cout<<ans-1<<endl;
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 512
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int A = sc.nextInt();
		int B = sc.nextInt();
		if((B-1)%(A-1)==0){
			System.out.println((B-1)/(A-1));
		}else{
			System.out.println((B-1)/(A-1)+1);
		}
		sc.close();
	}
};


Measured memory_bytes: 22100
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <string>
#include <unordered_set>
using namespace std;



int main(void){
	int n;
	string word;
	typedef unordered_set<string> set_t;
	set_t A;

	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> word;
		if(word == "find"){
			string S;
			cin >> S;
			if(A.count(S)){
				cout << "yes" << endl;
			}else{
				cout << "no" << endl;
			}
		}else{
			string S;
			cin >> S;
			A.insert(S);
		}
	}
	
    return 0;
}

Measured memory_bytes: 31936
#include <stdio.h>

int main(){

    int a,b;

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

    if(a<b){
       printf("a < b\n");
      }else if(a>b){
       printf("a > b\n");
        }else{
       printf("a == b\n");
    }
    
    
    return 0;
}

Measured memory_bytes: 580