akhauriyash/Code-Regression huggingface dataset:
n = input()
s = input()
ans = 0
tmp = 0
old = []
for i in range(1, len(s)):
    tmp = 0
    old = []
    for j in range(i):
        if s[j] in s[i:] and not(s[j] in old):
            tmp += 1
            old.append(s[j])
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),X = in()-1,Y = in()-1;
    vector<int> dist(N-1);
    REP(i,N-1){
        for (int j = i+1; j < N; j++){
            dist[min(j-i,abs(i-X) + 1 + abs(j-Y))-1]++;
        }
    }
    REP(i,N-1)cout << dist[i] << "\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010

int main(){
	lint n;cin>>n;
	liv a(n);rep(i,n)cin>>a[i];
	lint ans=0;
	rep(i,n-1){
		if(a[i]==a[i+1])++ans,++i;
	}cout<<ans<<endl;
}

//sub-EOF


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

int main(){
  int A,B;
  string S;
  cin >>A>>B>>S;
 
  string ans = "Yes";
  rep(i,0,A) if(S[i]=='-') ans = "No";
  if(S[A]!='-') ans = "No";
  rep(i,A+1,A+B+1) if(S[i]=='-') ans = "No";
  
  cout <<ans<< endl;
}

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

using namespace std;

#define int long long


#define MAX 2000*2000 + 5



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

	bitset<MAX> b;

	for(int i = 0; i < n; i++){
		b |= (b<<(a[i]));
		b.set(a[i]);
	}
	// for(int i = 0; i < 102; i++){
	// 	cout<<b[i];
	// }
	// cout<<endl;
	double half = sum/2.00 + 0.1;
	int ans = -100;
	for(int i = 0; i < MAX; i++){
		if(b[i] == 1){
			if(abs(half - i) < abs(half - ans)){
				ans = i;
			}
			
		}
	}
	cout<<ans<<endl;
}

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

int main(void){
  int i=0,j,k;
  int n[1000]={0};
  int counter[1000]={0};
  char str[200][3010];
  int right[3000]={0};
  int left[3000]={0};
  int state[10000] = {0};

  while(1){
    scanf("%d%*c",&n[i]);
    if(n[i] != 0){
      gets(str[i]);
    }
    else{
      break;
    }
    i++;

  }
  for(j=0;j<i;j++){
    for(k=0;k<n[j]*3;k+=3){
      if(str[j][k] == 'l'){
	left[j]++;
      }
      else
	right[j]++;

      if(right[j] % 2 == 0 && left[j] % 2 == 0 && state[j] % 2 == 1){
	counter[j]++;
	state[j]++;
	  }
      else if(right[j] % 2 == 1 && left[j] % 2 == 1 && state[j] % 2 == 0){
	counter[j]++;
	state[j]++;
      }

    }
    printf("%d\n",counter[j]);


  }

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

string s, t;
int dp[1001][1001];

int main(void){
    cin >> s >> t;
    int ls = s.size(), lt = t.size();

    for(int i = 0; i <= ls; i++) dp[i][0] = i;
    for(int i = 0; i <= lt; i++) dp[0][i] = i;

    for(int i = 0; i < ls; i++){
        for(int j = 0; j < lt; j++){
            if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j];
            else dp[i+1][j+1] = dp[i][j] + 1;
            dp[i+1][j+1] = min(dp[i+1][j+1], min(dp[i][j+1] + 1, dp[i+1][j] + 1));
            // printf("dp(%d, %d) = %d\n", i+1, j+1, dp[i+1][j+1]);
        }
    }

    cout << dp[ls][lt] << '\n';

    return 0;
}


Measured memory_bytes: 7088
def main():
    from sys import stdin
    n = int(input())
    a = list(map(int, stdin.readline().split()))
    a.sort()
    amax = max(a)+1
    e = [True]*amax
    Alice = set()
    Bob = set()
    ans = 0
    
    for i in range(n):
        if e[a[i]] == True:
            Alice.add(a[i])
            for j in range(a[i], amax, a[i]):
                e[j] = False
        else:
            if a[i] in Alice:
                Bob.add(a[i])
    
    print(len(Alice - Bob))
if __name__ == "__main__":
    main()

Measured memory_bytes: 42956
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a)); reverse(all(a));

    map<ll, ll> m;
    rep(i, n) m[a[i]]++;

    ll ans = 0;
    rep(i, n) {
        if (!m[a[i]]) continue;
        m[a[i]]--;
        ll p = 1;
        while (p <= a[i]) p *= 2;
        if (m[p - a[i]]) {
            m[p - a[i]]--;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;


const ll MOD = 1e9+7;

signed main(){
    ll n,m;
    cin >> n >> m;
    if(n == 1 || m == 1){
        cout << 1 << endl;
    }
    else if(n % 2 && m % 2){
        cout << (n*m)/2+1 << endl;
    }
    else{
        cout << (n*m)/2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3],i,num5=0,num7=0;
  cin>>a[0];
  cin>>a[1];
  cin>>a[2];
  for(i=0;i<3;i++){
    if(a[i]==5){num5++;}
    if(a[i]==7){num7++;}
  }
  if(num5==2&&num7==1){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
}


Measured memory_bytes: 3600
N = int(input())
A = []
A.append(list(map(int,input().split())))
A.append(list(map(int,input().split())))
B = [[0 for i in range(N+1)] for j in range(2)]
for i in range(1,N+1):
    B[0][i] = B[0][i-1] + A[0][i-1]
    B[1][i] = max(B[0][i] + A[1][i-1], B[1][i-1] + A[1][i-1])
print(B[1][N])

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
#define ii pair<int,int>

int main(){
    int k;cin>>k;
    vector<ii> c(k);
    for(int i=0;i<k;i++){
        int x,y;cin>>x>>y;
        c[i]=make_pair(x,y);
    }
    vector<int> f(8);
    for(int i=0;i<8;i++) f[i]=i;
    do{
        bool flag=true;
        for(int i=0;i<k;i++){
            if(f[c[i].first]!=c[i].second){
                flag=false;
                break;
            }
        }
        for(int i=0;i<8;i++){
            for(int j=i+1;j<8;j++){
                if(abs(f[i]-f[j])==j-i){
                    flag=false;
                    break;
                }
            }
            if(!flag) break;
        }
        if(flag){
            for(int i=0;i<8;i++){
                for(int j=0;j<8;j++){
                    if(j!=f[i]) cout<<'.';
                    else cout<<'Q';
                }
                cout<<endl;
            }
            return 0;
        }
    }while(next_permutation(f.begin(),f.end()));
}


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

int main(){
  int N ; 
  cin >> N ; 
  map<long long , long long>  M ; 
  for(int i = 0 ; i < N ; i++){
    int a ; 
    cin >> a ;
    M[a]++ ; 
    
  }
  long long cnt = 0 ; 
  for(auto p : M ){
    if(p.first > p.second ) cnt += p.second ;
    else cnt += p.second - p.first ; 
  }
  cout << cnt << endl ;
}

Measured memory_bytes: 9492
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main(){
    int N; cin >> N;
    vector<int> A(N);
    for(int &a:A)
        cin >> a;
    
    int ans = 0;
    int cur = A[0];
    int up = 0;
    int down = 0;
    for(int i=1; i<N; i++){
        if(A[i]>cur) up = 1;
        if(A[i]<cur) down = 1;
        if(up && down){
            up = 0;
            down = 0;
            ans++;
        }
        cur = A[i];
    }
    cout << ans+1 << endl;
    return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int a, b, c;
	char s[101];
	// 整数の入力
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	// スペース区切りの整数の入力
	a -= b;
	int d = a / c;
	// 出力
	printf("%d\n",a-c*d);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdbool.h>

int a[1005];
bool don[1005];

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    int ans = 0;
    for (int i = 0; i < n; i++)
        scanf("%d", a + i);
    for (int i = 0; i < k; i++) {
        int mn = 1001, p;
        for (int j = 0; j < n; j++) {
            if (mn > a[j] && !don[j]) mn = a[j], p = j;
        }
        ans += mn, don[p] = 1;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
#define fs first
#define sc second

const int nmax = 100;
int t = 1;
int n;
string A[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
string s;

void INPUT()
{
     cin >> s;
}

void INIT()
{

}

void SOLVE()
{
     for(int i = 0; i < 7; i++) if(s == A[i]) {
          cout << 7 - i; return;
     }
}

int main()
{
    //freopen("test.inp","r",stdin);
    INPUT();
    INIT();
    while (t--) SOLVE();
    return 0;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n,k,r,s,p;
    string t;
    cin >>n>>k>>r>>s>>p>>t;
    ll ans=0;vector<char>memo(n);
    for (int i = 0; i < n; ++i) {
        bool flg=true;char win;
        ll val;
        if(t[i]=='r'){
            win='p';val=p;
        }
        if(t[i]=='s'){
            win='r';val=r;
        }
        if(t[i]=='p'){
            win='s';val=s;
        }
        if(i>=k&&memo[i-k]==win)flg=false;
        if(flg){
            memo[i]=win;
            ans+=val;
        }
        else {
            memo[i]='a';
        }
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<string> vs;
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    rep(i, S.size()) {
        if (S[i] != T[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
#define el putchar('\n')
#define ta putchar('	')
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=200010;
int n,a[N],b[N];
set<pii>st;

inline void no(){puts("-1");exit(0);}

int main()
{
	n=rd();
	fo(i,1,n)a[i]=rd();
	fo(i,1,n)b[i]=rd();
	fo(i,1,n)if(a[i]!=b[i]){
		if(a[i]>b[i])no();
		st.insert(pii(b[i],i));
	}
	ll ans=0;
	while(!st.empty()){
		pii x=*st.rbegin();st.erase(x);
		int pre=x.second-1,now=pre+1,nxt=now+1;
		if(pre<=0)pre+=n;
		if(nxt>n)nxt-=n;
		int hh=max(a[now],b[pre]+b[nxt]);
		int step=(b[now]-hh)/(b[pre]+b[nxt]);
		ans+=step;b[now]-=step*(b[pre]+b[nxt]);
		if(b[now]==a[now])continue;
		b[now]-=b[pre]+b[nxt];++ans;
		if(b[now]==a[now])continue;
		if(b[now]>a[now]){
			st.insert(pii(b[now],now));
			continue;
		}
		no();
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}



int main() {

    int N; // 点の数
    int M; // 辺の数 
    cin >> N >> M;
    
    long a[M]; // 辺の繋がり開始点
    long b[M]; // 辺の繋がり終了点


    vector<int> nums;

    vector<int> a_vec;
    vector<int> b_vec;

    for (int i = 0; i < M ; i++) {
        //cin >> a[i] >> b[i];
        cin >> a[i] >> b[i];

        a_vec.push_back(a[i]);
        b_vec.push_back(b[i]);

        //cout << "aaa:  " << a[i] << "  bbb: " << b[i] <<  endl;

        //nums.push_back(i+1);
    }

    for (int i = 0; i < N ; i++) {

        nums.push_back(i+1);
    }

    // 頂点 1を始点として、全ての頂点を1度だけ訪れるパスは何通りありますか。
    // 1. 1 スタート
    // 2. 一度通った点は、２度訪れない
    // 3. N 個

    int cnt = 0;
    //int path_cnt = 0;


    // vector順列総当たりループ
    do {
        //printVector(nums);

        int path_cnt = 0;

        // vector要素数分の処理
        for (int i = 1; i < N ; i++) {
            // 1　スタートのみ
            if (nums.at(0) != 1){
                continue;
            }

            int now = nums.at(i-1);
            int next = nums.at(i);
            //cout << "now:  " << now << "  next: " << next <<  endl;

            // 辺の定義分ループ
            bool route_flg = false;
            for (int j = 0; j < M ; j++) {

                //cout << "a:  " << a_vec.at(j) << "  b: " << b_vec.at(j) <<  endl;

                //[now-next]間の辺の存在チェック
                if ((now == a_vec.at(j) && next == b_vec.at(j)) || (now == b_vec.at(j) && next == a_vec.at(j))){
                    route_flg = true;
                    //break;
                }
            }
            if(route_flg){
                 path_cnt++;
            }
        }

        if(path_cnt == N -1){
            //cout << "cnt up " << endl;
            cnt++;
        }
        //printVector(nums);

    } while (next_permutation(nums.begin()+1, nums.end()));


    cout << cnt << endl;

}

Measured memory_bytes: 3604
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict
import math

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	R = int(input())
	P = math.pi
	ans = 2 * P * R
	print(ans)



if __name__ == '__main__':
	main()

Measured memory_bytes: 65256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n,m;
  cin >> n >> m;

  vector<ll> a(n,-1);

  rep(i,m)
  {
    ll s,c;
    cin >> s >> c;
    if(s == 1 && c == 0 && n != 1)
    {
      cout << -1 << endl;
      return 0;
    }
    if(a[s-1] == -1)
    {
      a[s-1] = c;
    }
    else if(a[s-1] != c)
    {
      cout << -1 << endl;
      return 0;
    }
  }

  ll ans = 0;
  rep(i,n)
  {
    if(i == 0 && a[0] == -1 && n != 1)
    {
      cout << 1 ;
    }
    else
    {
      if(a[i] != -1)
        cout << a[i];
      else
      {
        cout << 0;
      }
    }
  }

  cout << endl;



  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k,ans=1e9+7,a[100005];
int main(){
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for(int i=0;i<n;i++)
    	cin >> a[i];
    sort(a,a+n);
    for(int i=0;i+k<=n;i++)
    	ans=min(ans,a[i+k-1]-a[i]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
from fractions import gcd
import sys
#input = sys.stdin.readline()
sys.setrecursionlimit(4100000)

def ols(): return input()
def oli(): return map(int, input().split())
def olai(): return list(map(int, input().split()))
def olas(): return list(input().split())
def mlai(L): return [int(input()) for _ in range(L)]
def mlas(L): return [input() for _ in range(L)]

def palindrome(S):
    return S == S[::-1]

s = ols()

if palindrome(s) and palindrome(s[:-len(s)//2]) and palindrome(s[len(s)//2+1:]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5520
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int K = reader.nextInt();
		int[] arr = new int[26];

		String S = reader.next();
		for (int j = 0; j < S.length(); j++) {
			arr[(int)S.charAt(j) - 97]++;
		}

		for (int i = 1; i < K; i++) {
			S = reader.next();
			for (int j = 0; j < 26; j++) {
				if (arr[j] > 0) {
					int gap = arr[j] - countOf(S, (char) (j + 97));
					if (gap > 0) {
						arr[j] -= gap;
					}
				}

			}
		}

		String result = "";

		for (int j = 0; j < 26; j++) {
			for (int i = 0; i < arr[j]; i++) {
				result += (char) (j + 97);
			}
		}


		reader.close();
		System.out.print(result);
	}
	 static int countOf(String str, char target){
			int count = 0;

			for(char x: str.toCharArray()){
				if(x == target){
					count++;
				}
			}

			return count;
		}

}



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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	
	char c;cin >> c;
	if(c == 'A')cout << 'T' << endl;
	if(c == 'T')cout << 'A' << endl;
	if(c == 'C')cout << 'G' << endl;
	if(c == 'G')cout << 'C' << endl;
	
	return 0;
}


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int r,g,b,n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  for(int i = 0; i <= 3000; i++) for(int j = 0; j <= 3000; j++) {
    int k = n - i * r - g * j;
    if(k >= 0 && k % b == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;

const int mod = 998244353;
inline int inc(int x, int y) {x += y; return x >= mod ? x - mod : x;}
inline void add(int &x, int y) {x += y; if (x >= mod) x -= mod;}
inline int mul(int x, int y) {return (ll)x * y % mod;}
inline int qpow(int x, int y)
{
	int res = 1;
	for (; y; y >>= 1, x = mul(x, x))
		if (y & 1) res = mul(res, x);
	return res;
}
int n, a[305], f[2][305 * 305], g[2][305 * 305];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i ++)
		cin >> a[i];
	int ans = qpow(3, n), sum = 0;
	for (int i = 1; i <= n; i ++)
		sum += a[i];
	// R + G - B <= 0
	f[0][0] = g[0][0] = 1;
	for (int i = 0; i < n; i ++)
	{
		int np = i & 1, p = np ^ 1;
		memcpy(g[p], g[np], sizeof g[p]);
		for (int j = 0; j <= sum; j ++)
			f[p][j] = inc(f[np][j], f[np][j]);
		for (int j = 0; j <= sum; j ++) if (f[np][j])
			add(f[p][j + a[i + 1]], f[np][j]),
			add(g[p][j + a[i + 1]], g[np][j]);
	}
	int mid = (sum + 1) >> 1;
	for (int i = mid; i <= sum; i ++)
		ans = inc(ans, mul(3, mod - f[n & 1][i]));
	if (!(sum & 1))
		ans = inc(ans, mul(3, g[n & 1][mid]));
	cout << ans << endl;
	return 0;
}


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

int main(){
  string a,b,c;
  cin >>a >>b >>c;
  cout << a[0] << b[1] << c[2] << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define mp make_pair
#define int long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
typedef long double f80;
#define all(x) x.begin(), x.end()

const int mod = 1e9 + 7;

const int N = 1e5 + 5;
string s;
int dp[N][2];

void upd(int &x,int y) {
    x = (x + y) % mod;
}

signed main()
{
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> s;
    int n = sz(s);
    s = '0' + s;
    dp[0][1] = 1;
    fr(i, 0, n - 1) {
        upd(dp[i + 1][0], (dp[i][0] * 3) % mod);
        int val = s[i + 1] - '0';
        if(!val)
            upd(dp[i + 1][1], dp[i][1]);
        else
            upd(dp[i + 1][0], dp[i][1]), upd(dp[i + 1][1], (dp[i][1] * 2) % mod);
    }
    cout << (dp[n][0] + dp[n][1]) % mod;
    return 0;
}

Measured memory_bytes: 1900
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=1e9,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const long long llinf=1e18;
const int A=100005,B=200005,C=305,D=105,E=1005;
int n,pos,p,d[A],ans;
int main(){
	cin>>n>>pos;
	for(int i=1;i<=n;i++)
	{
		cin>>p;
		d[i]=abs(p-pos);
	}
	ans=d[1];
	for(int i=2;i<=n;i++)
		ans=__gcd(ans,d[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
int N;
const int MX = 100000;
int a[100000];
int c[MX + 1];

int main() {
	cin >> N;
	rep(i, N) cin >> a[i];

	rep(i, MX+1) c[i] = 0;
	rep(i, N) c[a[i]]++;

	int ret = 0;
	rep(i, MX+1){
		if(c[i]>0) ret++;
	}
	if (ret % 2 == 0) ret--;

	cout << ret << endl;
}

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

bool f(long long int n){
	long long int i=sqrt(n);
	if(i*i==n){
		return true;
	}
	else{
		return false;
	}
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int a,b;
	cin>>a>>b;
	long long int dig=log10(b)+1;
	long long int ten=pow(10,dig);
	a*=ten;
	a+=b;
	if(f(a)){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <decimal/decimal>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

ll INF=1001001001001;
ll MAX_E=100005; //問題に応じて
struct edge{ll u,v,cost;};
bool comp(const edge& e1,const edge& e2){
    return e1.cost<e2.cost;
}
vector<edge> es(MAX_E,{0,0,INF});
ll v,e; //頂点数と辺数
ll kruskal(){
    sort(es.begin(),es.end(),comp); //edge.costが小さい順にソート
    UnionFind tree(v); //Union-Findの初期化
    ll res=0;
    for(ll i=0;i<e;i++){
        edge e=es[i];
        if(!tree.same(e.u,e.v)){
            tree.unite(e.u,e.v);
            res+=e.cost;
        }
    }
    return res;
}

int main(){
    cin>>v>>e;
    //vector<edge> es(e);
    rep(i,e){
        ll s,t,w;
        cin>>s>>t>>w;
        es[i]={s,t,w};
    }
    //cout<<es[0].u<<es[0].v<<es[0].cost<<endl;
    ll ans=kruskal();
    cout<<ans<<endl;
}


Measured memory_bytes: 5048
A = list(input())
A1 = list(reversed(A))
#print((len(A)-1)/2-1)
 
B = A[:(len(A)-1)//2]
B1 = list(reversed(B))
 
C = A[(len(A)+3)//2-1:]
C1 = list(reversed(C))
 
if A == A1 and B == B1 and C == C1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ll a,b,k; cin>>a>>b>>k;

    if(a<=k) {
        k=k-a;
        a=0;
        if(b<=k){
            b=0;
        }
        else
            b=b-k;
    }
    else
    {
        a-=k;
    }
    cout<<a<<" "<<b;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    int count = 0;
    rep(i, n){
        cin >> p[i];
        if(p[i] != i+1)count++;
    }
    if(count <= 2)cout << "YES";
    else cout << "NO"; 
}


Measured memory_bytes: 256
def rate(m, f, r)
  return :F if m == -1 || f == -1
  a = m + f
  return :A if 80 <= a
  return :B if 65 <= a && a < 80
  return :C if 50 <= a && a < 65 || r >= 50
  return :D if 30 <= a && a < 50
  return :F
end
readlines.each do |line|
  m, f, r = line.split.map(&:to_i)
  break if m == -1 && f == -1 && r == -1
  puts rate(m, f, r)
end

Measured memory_bytes: 6100
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int dp[114514];
signed main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for (int i = k; i >= 1; i--) {
		int memo1 = mod_pow(k / i, n, mod);
		int memo2 = 0;
		for (int j = 1; j <= k / i; j++) {
			if (j >= 2)memo2 += dp[i * j];
			memo2 %= mod;
		}
		dp[i] = (memo1 - memo2 + mod) % mod;
	}
	for (int i = 1; i <= k; i++) {
		ans += dp[i] * i % mod;
		ans %= mod;
	}
	cout << ans << endl;
	ggr
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
#define set_null(a,n) memset(a,0,sizeof(a))
#define pi acos(-1)
#define ll long long int
#define fr(a,b) for(int i=a;i<b;i++)
#define modulo 1000000007

int main()
{
    ll n,k,m;
    cin>>n>>k;
    ll ans=n%k;
    m=abs(k-ans);
    if(ans<m)
    {
        cout<<ans<<endl;
    }
    else{
        cout<<m<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,A[100001];
	vpint x;
	scan(N);
	rep(i,N){
		scan(A[i]);
		x.push_back({A[i],i});
	}
	sort(ALL(x));
	rep(i,N){
		printf("%d ",x[i].second+1);
	}
	kaigyo;
	return 0;
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
#define INF 1e9
typedef long long ll;
typedef pair<int, int> P;


int main(){
  int n;
  cin>>n;
  double x[n];
  double y[n];
  rep(i,n){
    cin>>x[i]>>y[i];
  }
  double ans=0;
  rep(i,n){
    rep(j,n){
      ans+=sqrt(((x[i]-x[j])*(x[i]-x[j]))+((y[i]-y[j])*(y[i]-y[j])));
    }
  }
  double avg=ans/n;
  printf("%7f\n",avg);
  return 0;
}
    
  

        
    
     
      
    
  
  
  
 



Measured memory_bytes: 256
#define N 101
#define INF 100000000
void mco();
int n;
int m[N][N];
int p[N];
int main()
{
  int i;

  scanf("%d",&n);
  for(i=1; i<=n; i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }
  
  mco();
  
  printf("%d\n",m[1][n]);
  
  return 0;
}

void mco()
{
  int i,j,l,k;
  int q=0;
  
  for(i=1; i<=n; i++){
    m[i][i] = 0;
  }
  
  for(l=2; l<=n; l++){
    for(i=1; i<=n-l+1; i++){
      j = i+l-1;
      m[i][j] = INF;
      for(k=i; k<=j-1; k++){
	q = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(m[i][j] > q){
	  m[i][j] = q;
	}
      }
    }
  }
}

Measured memory_bytes: 636
N,W=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(N)]
m=sum([v[1] for v in wv])+1
dp=[[float('inf')] * (m+1) for _ in range(N+1)]
dp[0][0]=0
for i in range(N):
  w,v = wv[i]
  for j in range(m):
    dp[i+1][j] = dp[i][j]
    if j < v:
      dp[i+1][j] = dp[i][j]
    else:
      dp[i+1][j] = min(dp[i][j], dp[i][j-v]+w)
ans=0
for k in range(m):
  if dp[N][k]<=W:
    ans=k
print(ans)

Measured memory_bytes: 308168
class SegmentTree :
    def __init__(self, n) :
        self.n = n
        self.N0 = 1 << n.bit_length()
        self.data = [10**15] * (self.N0*2)
 
    def update(self, l, r, val) :
        l += self.N0
        r += self.N0
        while l < r:
            if l & 1 :
                self.data[l] = min(self.data[l], val)
                l += 1
            if r & 1:
                self.data[r-1] = min(self.data[r-1], val)
                r -= 1
            l //= 2
            r //= 2
 
    def query(self, i) :
        i += len(self.data) // 2
        ret = self.data[i]
        while i > 0 :
            i //= 2
            ret = min(ret, self.data[i])
        return ret if ret < 10**15 else -1
import bisect
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
roads = []
for _ in range(N):
    s, t, x = map(int, input().split())
    roads.append((x, s, t))
compress_list = []
query = []
for _ in range(Q):
    d = int(input())
    compress_list.append(d)
S = SegmentTree(Q)
for x, s, t in roads:
    l = bisect.bisect_left(compress_list, s-x)
    r = bisect.bisect_left(compress_list, t-x)
    S.update(l, r, x)
for i in range(Q):
    print(S.query(i))   

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

using namespace std;

int main()
{
    int a;
cin>>a;
while(a!=0)
{
    int x=a%10;
    if(x==7)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    a=a/10;
}
cout<<"No"<<endl;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,k,mi = INF,h[100010];
	cin >> n >> k;
	for(int i = 0;i < n;i++) cin >> h[i];
	sort(h,h + n);
	for(int i = 0;i < n - k + 1;i++){
		chmin(mi,h[i + k - 1] - h[i]);
	}
	cout << mi << endl;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;
   
fn read<T: FromStr>() -> T {
	let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let S: Vec<char> = read_line().chars().collect();
    let odd = ['R', 'U', 'D'];
    let even = ['L', 'U', 'D'];
    let mut ok = true;
    for i in 0..S.len() {
        if ((i+1) % 2 == 0 && !even.contains(&S[i]))
            || ((i+1) % 2 == 1 && !odd.contains(&S[i])) {
            ok = false;
            break;
        }
    }
    if ok {
        println!("Yes");
    } else {
        println!("No");
	}
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        int count = 0;
        while (s.contains("ABC")) {
            s = s.substring(0, s.lastIndexOf("ABC"));
            count++;
        }
        System.out.println(count);
        sc.close();
    }
}


Measured memory_bytes: 35144
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define PB push_back
#define loop(i,x,y) for(int i=x;i<y;i++)
#define rloop(i,x,y) for(int i=x;i>y;i--)
#define NL cout<<"\n"
#define ans(x) cout<<x<<"\n"
#define out(x) cout<<x<<" "
#define F first
#define S second
#define ansf(x,y) cout<<fixed<<setprecision(y)<<x<<endl;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
  int a,b;
  cin>>a>>b;
  ans(max({a+b,a-b,a*b}));
}
signed main()
{
  // FAST;
  int T=1;
  // cin>>T;
  while(T--) solve();
  return 0;
}

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

int main()
{
    int n, t, a, b;
    vector<int> cost;
    cin >> n >> t;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        if (b <= t)
        {
            cost.push_back(a);
        }
    }
    if (cost.empty() == 1)
    {
        cout << "TLE";
    }
    else
    {
        sort(cost.begin(), cost.end());
        cout << cost[0];
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define iso ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define make_pair mp
#define clr(x,n) memset((x), n, sizeof(x))
#define mod 1000000007
#define MAX 1000005
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_tree;*/
double dp[3005][3005];
double arr[3005];
int n;
int cnt;
double fans=0;
double fun(int cur, int hc)
{

   if(cur>=n && hc>=cnt)
        return 1;
   if(cur>=n)
        return 0;
    if(dp[cur][hc]!=-1)
        return dp[cur][hc];
    double ans;
    ans= arr[cur]*fun(cur+1,hc+1)+(1.0-arr[cur])*fun(cur+1,hc);
    return dp[cur][hc]=ans;

}
int main()
{
    iso;
    int i,j;
    for(i=0;i<3005;i++)
        for(j=0;j<3005;j++)
            dp[i][j]=-1;


    cin>>n;
    for(i=0;i<n;i++)
        cin>>arr[i];
    cnt=n/2+1;
    cout<<setprecision(12)<<fun(0,0);

    return 0;
}


Measured memory_bytes: 71040
program mogmog2020E
    implicit none
    integer(8)::N,A,B,i,ans
    integer(8),allocatable,dimension(:)::X
    read*,N,A,B
    allocate(X(N))
    read*,X
    ans=0

    do i=2,N
        ans=ans+min(A*(X(i)-X(i-1)),B)
    end do
    print'(i0)',ans
contains
    recursive function iqsort(ix) result(ires)
      integer(8), allocatable :: ires(:)
      integer(8), intent(in)  :: ix(:)
      integer :: k
      if (size(ix) <= 1) then 
        ires = ix
      else  
        k = ix(size(ix) / 2)
        ires = [iqsort(pack(ix, ix < k)), pack(ix, ix == k), iqsort(pack(ix, ix > k))] 
      end if
    end function iqsort
end program mogmog2020E

Measured memory_bytes: 1536
n = int(input())
A = list(map(int, input().split()))

check = ''
ans = 0

for i in range(n-1):
    diff = A[i] - A[i+1]
    if check == '':
        if diff < 0:
            check = '+'
        elif diff > 0:
            check = '-'
    elif check != '':
        if check == '+' and diff > 0:
            ans += 1
            check = ''
        elif check == '-' and diff < 0:
            ans += 1
            check = ''

print(ans+1)


Measured memory_bytes: 14224
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){
   	string s;
	cin>>s;
	int maxcons=0;
	int cons=0;
	for(int i=0;i<s.size();i++){
	 if(s[i]==82){
		cons+=1;
			if(cons>maxcons)maxcons=cons;
    	}
	else{
		cons=0;
		}
	}
	cout<<maxcons;
}

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

Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]

ans = 10**10
h.sort()
for i in range(N-K+1) :
    temp = h[i+K-1] - h[i]
    ans = min(ans, temp)

print(ans)


Measured memory_bytes: 7388
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
S = s()

max_common = 0
for i in range(1, N-1):
    X = set(S[:i])
    Y = set(S[i:])
    common = len(X.intersection(Y))
    if max_common < common:
        max_common = common
print(max_common)


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int n,m,i,j,k,s,temp;
	int t[105],p[105],x[105];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&t[i]);
	scanf("%d",&m);
	for(i=1;i<=m;i++)
		scanf("%d %d",&p[i],&x[i]);
	for(i=1;i<=m;i++){
		s=0;
		for(j=1;j<=n;j++)
			if(p[i]==j){
				k=j;
				temp=t[j];
				t[j]=x[i];
			}
		for(j=1;j<=n;j++)
			s=s+t[j];
		printf("%d\n",s);
		t[k]=temp;
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayDeque<String> ans = new ArrayDeque<String>();

		while(sc.hasNext()){
			double[] x = new double[4];
			double[] y = new double[4];
			for(int i=0;i<4;i++){			
				x[i] = sc.nextDouble();
				y[i] = sc.nextDouble();
			}
			double a = (y[0]-y[1]);
			double b = (x[0]-x[1]);
			double c = (y[2]-y[3]);
			double d = (x[2]-x[3]);
			if((a*c)/(b*d)==-1 || (a==0 && d==0) || (b==0 && c==0)){
				ans.push("YES");
			}else{
				ans.push("NO");
			}
			
		}
		int num = ans.size();
		for(int i=0;i<num;i++){
			System.out.println(ans.pollLast());
		}
	}
}

Measured memory_bytes: 23208
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>


using namespace std;


int main() {
	int n = 0;
	cin >> n;
	if(n == 25) {
		cout << "Christmas" << endl;
	}
	else if(n == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if(n == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (n == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  double a,b,c,d,e,f,x,y;
  while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)+1){
  if(floor(a*e-b*d)==0){x=0.000;}
  else {x=(e*c-f*b)/(a*e-b*d);
    x=x+0.005;
    x=x*100;
    x=floor(x);
    x=x/100;
  }

 if(floor(b*d-a*e)==0){y=0.000;}
 else {y=(c*d-a*f)/(b*d-a*e);
    y=y+0.005;
    y=y*100;
    y=floor(y);
    y=y/100;
  }
 printf("%.3lf %.3lf\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 652
n, k = gets.split.map &:to_i
a = []
n.times do |i|
	a[i] = gets.to_i
end

a.sort!
min_h = 10**10
(a.length-k+1).times do |i|
	h = a[i..i+k-1]
	if (h[k-1].to_i - h[0].to_i) < min_h
		min_h = h[k-1].to_i - h[0].to_i
	end
end

puts min_h

Measured memory_bytes: 4036
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int sum = 0, n;
  rep(i, 5){
    scanf("%d", &n);
    if(n < 40) n = 40;
    sum += n;
  }
  printf("%d\n", sum/5);
  return 0;
}

Measured memory_bytes: 1188
N=int(input())
A=[0]+list(map(int,input().split()))+[0]
cost=sum(abs(A[i+1]-A[i]) for i in range(N+1))
for i in range(1,N+1):
    print(cost-abs(A[i+1]-A[i])-abs(A[i]-A[i-1])+abs(A[i+1]-A[i-1]))

Measured memory_bytes: 14048
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const string YES = "YES";
const string NO = "NO";

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    vector<int> d(N + 1);
    for(int i = 0; i < M; ++i) {
        d[a[i]]++;
        d[b[i]]++;
    }
    bool f = true;
    for(int i = 0; i <= N; ++i) {
        f = f && d[i] % 2 == 0;
    }
    cout << (f ? YES : NO) << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}

Measured memory_bytes: 2560
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    long n, a, b;
    readlnTo(n, a, b);
    if(a > b) {
        writeln(0);
        return;
    }
    if(n == 1) {
        if(a != b) {
            writeln(0);
        } else {
            writeln(1);
        }
        return;
    }
    writeln((b * (n-1) + a) - (b + a * (n-1)) + 1);
}




Measured memory_bytes: 256