akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
  input = input.split("\n");
  var arr = input[1].split(' ');
  var newArr = arr.map(value => +value );

  console.log(Math.max.apply(null, newArr) - Math.min.apply(null, newArr));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
  
        static void Main(string[] args)
        {
            int[,] n = new int[3, 3];
            bool[,] check = new bool[3, 3];
            int N;
            // = int.Parse(Console.ReadLine()); //標準入力
            string[] str1 = Console.ReadLine().Split(' ');
            string[] str2 = Console.ReadLine().Split(' ');
            string[] str3 = Console.ReadLine().Split(' ');
            string[] num = Console.ReadLine().Split(' ');

            n[0, 0] = int.Parse(str1[0]);
            n[1, 0] = int.Parse(str1[1]);
            n[2, 0] = int.Parse(str1[2]);
            n[0, 1] = int.Parse(str2[0]);
            n[1, 1] = int.Parse(str2[1]);
            n[2, 1] = int.Parse(str2[2]);
            n[0, 2] = int.Parse(str3[0]);
            n[1, 2] = int.Parse(str3[1]);
            n[2, 2] = int.Parse(str3[2]);

            N = int.Parse(num[0]);
            for (int i = 0; i < N; i++)
            {
                string[] b = Console.ReadLine().Split(' ');
                int bn = int.Parse(b[0]);
                for (int k = 0; k < 3; k++)
                {
                    for (int l = 0; l < 3; l++)
                    {
                        if (bn == n[k, l])
                        {
                            check[k, l] = true;
                        }
                    }
                }
            }
            bool bing = false;
            for (int i = 0; i < 3; i++)
            {
                if (check[i, 0] && check[i, 1] && check[i, 2]) bing = true;
                if (check[0, i] && check[1, i] && check[2, i]) bing = true;
            }
            if (check[0, 0] && check[1, 1] && check[2, 2]) bing = true;
            if (check[2, 0] && check[1, 1] && check[0, 2]) bing = true;

            Console.WriteLine(bing ? "Yes" : "No");//改行付き出力
        }
    }
}




//int n = int.Parse(Console.ReadLine());
//int[] N = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

Measured memory_bytes: 13140
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let _ = get_line().parse::<u8>().unwrap();
    let s = get_line().chars().collect::<Vec<char>>();
    let mut count = 0;
    for i in 0..s.len() {
        if s[i] == 'A' && i + 2 < s.len() {
            if s[i + 1] == 'B' && s[i + 2] == 'C' {
                count += 1;
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def main():
    A,B = map(int, input().split())

    if A > B:
        A,B = B,A
    k = A + (abs(A-B) // 2)

    if abs(A - k) == abs(B - k):
        print(k)
    else:
        print('IMPOSSIBLE')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,p;
    cin>>n>>m>>p;
    int a[n],sum=0;
    for(int i=1;i<=n;i++){
            cin>>a[i];
            if(a[i]%2==0){for(int j=1;j<=m;j=j+a[i])
                {
                    sum++;
                }
            }
            else if(a[i]%2!=0){for(int j=1;j<=m;j=j+a[i])
                {
                    sum++;
                }}
            else sum=sum+1;
    }cout<<sum+p<<endl;
    return 0;
}





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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  string s;cin>>s;

  int n = sz(s);

  vi L, R;
  rep(i, n){
    if (s[i]=='L') L.pb(i);
    if (s[i]=='R') R.pb(i);
  }
  dump(L);
  dump(R);

  vi ans(n, 0);

  rep(i, n){
    if (s[i]=='R'){
      int fli = L[lb(all(L), i) - L.begin()];
      if ((fli-i)%2==0) ans[fli]++;
      else ans[fli-1]++;
    }
    else{
      int j = R[--lb(all(R), i) - R.begin()];
      if ((i-j)%2==0) ans[j]++;
      else ans[j+1]++;
    }
  }
  dump(ans);
  rep(i, sz(ans)) cout << ans[i] << (i!=sz(ans)-1 ? " " : "\n");

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

int D(int x,int y) {
	return max(x - y, y - x);
}


int main() {
	int N,X,Y;
	cin >> N >> X >> Y;
	X--;
	Y--;
	vector<int>Ans(N);
	for (int i = 0;i<N;++i) {
		for (int j = i + 1; j < N; ++j) {
			int num = min(min(j - i, D(X, i) + 1 + D(Y, j)), D(X, j) + 1 + D(Y, i));
			Ans[num]++; 
		}
	}
		for (int i = 1;i < N;++i) {
		cout <<Ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
typedef long long ll;
using namespace std;
const int inf=1e9;
int dp[(1<<16)];
bool visited[(1<<16)];
int main(){
	int N,M,K;
	cin>>N>>M>>K;
	int D[16];
	REP(i,0,M) {
		cin>>D[i];
		D[i]--;
	}
	vector<int> root[110];
	int a;
	REP(i,0,N){
		REP(j,0,K){
			cin>>a;
			a--;
			root[i].push_back(a);
		}
	}
	REP(i,0,(1<<M)) dp[i]=inf;
	REP(i,0,(1<<M)) visited[i]=false;
	dp[(1<<M)-1]=0;
	visited[(1<<M)-1]=true;
	
	queue<int> q;
	q.push((1<<M)-1);
	
	while(!q.empty()){
		int now=q.front();	q.pop();
		REP(j,0,K){
			int nstate=0;
			REP(i,0,M){
				if(now&(1<<i)) {
					int next=root[D[i]][j];
					int dr=-1;
					REP(k,0,M)	if(D[k]==next) dr=k;
					if(dr!=-1) nstate|=(1<<dr);
				}
			}
			if(!visited[nstate]) q.push(nstate);
			visited[nstate] = true;
			dp[nstate] = min(dp[nstate],dp[now]+1);
		}
	}
	p(dp[0]);
	return 0;
}

Measured memory_bytes: 3608
n=int(input())
s=input()

alph=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
c_list=list(s)
next_s=list()

for c in c_list:
    for i in range(len(alph)):
        if c==alph[i]:
            if i+n>25:
                next_s.append(alph[i+n-26])
                break
            else:
                next_s.append(alph[i+n])
                break

mojiretu = ''

for x in next_s:
    mojiretu += x

print(mojiretu)


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

int main(){
    stack<int> st;
    string c;
    int a,b;
    while(cin>>c){
        if(c=="+"){
            a=st.top();st.pop();
            b=st.top();st.pop();
            st.push(a+b);
        }
        else if(c=="-"){
            a=st.top();st.pop();
            b=st.top();st.pop();
            st.push(b-a);
        }
        else if(c=="*"){
            a=st.top();st.pop();
            b=st.top();st.pop();
            st.push(a*b);
        }
        else{
            st.push(stoi(c));
        }
    }
    cout<<st.top()<<endl;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int64_t n, y;
  cin >> n >> y;
  REP(i,n+1){
    REP(j,n+1){
      int k = n - (i+j);
      if (k >= 0){
        int t = 10000 * i + 5000 * j + 1000 * k;
        if (t == y){
          cout << i << " " << j << " " << k << endl;
          return 0;
        }
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <map>
#include <vector>
#include <array>
#include <cstring>
#include <utility>
using namespace std;

int memo[1 << 24];
array<int,16> need;
const int MOD = 1000000007;

int dfs(int u, int r, int S){
	if(r == 0){
		if(u == 15){
			return (S == 0);
		}
		return dfs(u + 1, need[u + 1], S);
	}

	int &ret = memo[S];
	if(ret < 0){
		ret = 0;
		for(int i = 0; i < 4; ++i){
			if(u >> i & 1 && (S >> (i * 6) & 63) > 0){
				int T = S - (1 << (i * 6));
				ret = (ret + dfs(u, r - 1, T)) % MOD;
			}
		}
	}
	return ret;
}

int main(){
	memset(memo, -9, sizeof memo);
	
	int limit = 52;

	int S = 0;
	int n;
	for(int i = 0; i < 4; ++i){
		cin >> n;
		S |= n << (i * 6);
	}

	int m;
	cin >> m;
	cin.ignore();
	vector<string> rls(m);
	for(int i = 0; i < m; ++i){
		getline(cin, rls[i]);
	}
	
	char nametbl[128] = {};
	nametbl['A'] = 1;
	nametbl['T'] = 2;
	nametbl['G'] = 4;
	nametbl['C'] = 8;

	map<string,array<int,16> > cnts;
	char buf[32];
	string name;
	for(int i = m - 1; i >= 0; --i){
		const char *p = rls[i].c_str();
		int d = 0;
		sscanf(p, "%[^:]:%n", buf, &d);
		p += d;
		name = buf;

		array<int,16> ar{};
		while(sscanf(p, " %s%n", buf, &d) > 0){
			p += d;
			if(buf[0] == '['){
				int r = 0;
				for(int j = 1; buf[j] != ']'; ++j){
					r |= nametbl[buf[j]];
				}
				ar[r] = min(ar[r] + 1, limit);
			}
			else{
				const auto &other = cnts.at(buf);
				for(int j = 0; j < 16; ++j){
					ar[j] = min(ar[j] + other[j], limit);
				}
			}
		}

		if(i == 0){
			need = ar;
		}
		else{
			cnts.insert(make_pair(name, ar));
		}
	}

	cout << dfs(0, need[0], S) << endl;
}

Measured memory_bytes: 66840
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define CloseIO std::ios::sync_with_stdio(false)
const ll N = 8e6+1000;
const ll Mod = 100;
const ll INF = 0x3f3f3f3f3f;
int main(){
  int a[100] = {0};
  string s;
  cin>>s;
  for(int i = 0; i < s.length(); i++){
    a[s[i]- 'A']++;
  }
  int sum = 0;
  int flag = 0;
  for(int i = 0; i < 28; i++){
    if(a[i] > 0){
      sum++;
    }
    if(a[i] > 1) flag++;
  }
  if(flag == 2 && sum == 2){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 50 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int M,N,A,B,C,T;
int s[MAXN];

struct Matrix{
    LL a[MAXN][MAXN];
}st,mp;

Matrix Matrix_Multiply(const Matrix& a,const Matrix& b,int MOD){
    Matrix c;
    memset(c.a,0,sizeof(c.a));
    for(int k=1;k<=N;k++){
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                c.a[i][k]+=a.a[i][j]*b.a[j][k];
            }
        }
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++) c.a[i][j]%=MOD;
    }
    return c;
}

void Power(int X,int MOD){
    while(X){
        if(X&1) st=Matrix_Multiply(st,mp,MOD);
        mp=Matrix_Multiply(mp,mp,MOD);
        X>>=1;
    }
}

void work(){
    while(~scanf("%d%d%d%d%d%d",&N,&M,&A,&B,&C,&T)){
        for(int i=1;i<=N;i++) scanf("%d",&s[i]);
        memset(mp.a,0,sizeof(mp.a));
        for(int i=1;i<=N;i++){
            mp.a[i][i-1]=A;
            mp.a[i][i]=B;
            mp.a[i][i+1]=C;
        }
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++) st.a[i][j]=(i==j);
        }
        Power(T,M);
        for(int i=1;i<=N;i++){
            LL ans=0;
            for(int j=1;j<=N;j++){
                ans=(ans+st.a[i][j]*s[j]);
            }
            printf("%lld%s",ans%M,i==N ? "\n" : " ");
        }
    }
}

int main(){
#ifdef NNever
    freopen("data.in","r",stdin);
//    freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}










Measured memory_bytes: 3248
#include <iostream>
using namespace std;
 
int main() {
    //Recieve the inputs
    int D, T, S;
    cin >> D >> T >> S;
 
    //Calculate the duration of Takahashi's journey
    double time = (double)D / S;
 
    //Output depending on the inequality between T and time
    if (T >= time) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

namespace _1_8_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string _readLine = Console.ReadLine();
            char[] chars = _readLine.ToCharArray();
            string[] _readInitial = new string[_readLine.Length];
            for (int i = 0; i < _readLine.Length; i++) _readInitial[i] = _readLine.Substring(i, 1);
            string[] _largeInitial = { "A","B","C","D","E","F","G",
                                       "H","I","J","K","L","M","N","O","P","Q","R",
                                       "S","T","U","V","W","X","Y","Z"};
            string[] _smallInitial = { "a","b","c","d","e","f","g",
                                       "h","i","j","k","l","m","n","o","p","q","r",
                                       "s","t","u","v","w","x","y","z"};
            string answer = null;

            for (int j = 0; j < _readInitial.Length; j++)
            {
                for (int i = 0; i < 26; i++)
                {
                    if (_readInitial[j] == _largeInitial[i])
                    {
                        answer += _smallInitial[i];
                    }
                }
                for (int i = 0; i < 26; i++)
                {
                    if (_readInitial[j] == _smallInitial[i])
                    {
                        answer += _largeInitial[i];
                    }
                }

                if (_readInitial[j] == ","| _readInitial[j] == " "| _readInitial[j] == "."
                    | _readInitial[j] == "-"| _readInitial[j] == "("| _readInitial[j] == ")"
                    | _readInitial[j] == "1"| _readInitial[j] == "2"| _readInitial[j] == "3"
                    | _readInitial[j] == "4"| _readInitial[j] == "5"| _readInitial[j] == "6"
                    | _readInitial[j] == "7"| _readInitial[j] == "8"| _readInitial[j] == "9"
                    | _readInitial[j] == "0"| _readInitial[j] == "'")
                {
                    answer += _readInitial[j];
                }

            }
            Console.WriteLine(answer);
        }
    }
}



Measured memory_bytes: 15868
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =
				new BufferedReader( new InputStreamReader(System.in) );

		int n = Integer.parseInt( br.readLine() );

		String[] data = br.readLine().split(" ");
		int[] A = new int[n];
		for (int i=0; i < n; i++) {
			A[i] = Integer.parseInt(data[i]);
		}

		int q = Integer.parseInt( br.readLine() );

		data = br.readLine().split(" ");
		int[] M = new int[q];
		for (int i=0; i < q; i++) {
			M[i] = Integer.parseInt(data[i]);
		}

		for (int i=0; i < q; i++) {
			if ( solve(0, M[i], A) )
				System.out.println("yes");
			else
				System.out.println("no");
		}
	}

	static boolean solve(int i, int m, int[] A) {
		if (m == 0) return true;
		if (i >= A.length) return false;
		boolean res = solve(i+1, m, A) || solve(i+1, m-A[i], A);
		return res;
	}
}

Measured memory_bytes: 24704
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 4000000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int uni[100010];
int root(int a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]); 
}
bool connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(uni[a]>uni[b]){
        swap(a,b);
    }
    uni[a]=uni[a]+uni[b];
    uni[b]=a;
    return true;
}
signed main(void){
    int n;cin>>n;
    string s;cin>>s;
    
    vector<set<int>>Alpha(26);//26のindex集合
    
    //初めの設定
    rep(i,26)Alpha[i].insert(n+1);
    rep(i,n){
        Alpha[(int)(s[i]-'a')].insert(i);
    }

    int q;cin>>q;
    rep(i,q){
        int judge;cin>>judge;
        if(judge==1){
            int now;char Alphabet;cin>>now>>Alphabet;now--;
            Alpha[(int)(s[now]-'a')].erase(now);
            Alpha[(int)(Alphabet-'a')].insert(now);
            s[now]=Alphabet;
            
        }else{
            int ans=0;
            int l,r;cin>>l>>r;l--;r--;
            rep(j,26){//各Alphabetについて,それがl~rに含まれるか確認
                int right=*Alpha[j].lower_bound(l);
                if(right<=r)ans++;
            }
            cout<<ans<<endl;
        }
    }
}
        


Measured memory_bytes: 24196
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
	int h, w;
	cin >> h >> w;

	vector<vector<char> > s;

	vector<char> kari;
	for (int i = 0; i < w+2; i++) {
		kari.push_back('.');
	}
	s.push_back(kari);
	for (int i = 0; i < h; i++) {
		vector<char> gyou;
		gyou.push_back('.');
		for (int j = 0; j < w; j++) {
			char ness;
			cin >> ness;
			gyou.push_back(ness);
		}
		gyou.push_back('.');
		s.push_back(gyou);
	}
	s.push_back(kari);

	bool able = true;

	for (int i = 1; i < h+1; i++) {
		for (int j = 1; j < w+1; j++) {
			if (s[i][j] == '#') {
				if (s[i - 1][j] == '.' && s[i + 1][j] == '.' && s[i][j - 1] == '.' && s[i][j + 1] == '.') {
					able = false;
				}
			}
		}
	}

	if (able) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

ll n;

struct fastio {
  fastio() {
    ios::sync_with_stdio(false);
    cout << setprecision(10) << fixed;
    cin.tie(0);
  }
};
fastio _fast_io;

int main() {
  cin >> n;
  string res = "";
  while (n > 0) {
    n--;
    int a = n % 26;
    res = char('a' + a) + res;
    n /= 26;
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li n,k;

    cin>>n>>k;

    li a[n];

    f(i,0,n-1)
    {
    	cin>>a[i];
    }

    f(i,k,n-1)
    {
    	if(a[i]>a[i-k])
    		cout<<"Yes\n";
    	else
    		cout<<"No\n";
    }
}

int main()
{    
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll a, b, c, x, y, n, m; string s, t;

  vl ve = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll k;
  cin >> k;
  cout << ve[k-1] << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll k;
  cin >> k;
  vector<ll> a(50);
  rep(i, 50) a[i] = i+(k/50);
  rep(i, k%50) ++a[49-i];
  cout << 50 << endl;
  rep(i, 50) cout << a[i] << " ";
  cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<iostream>
#include<functional>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

template <typename Monoid=ll> class SegmentTree {
    public:
    using Monoid_func = function<Monoid(Monoid, Monoid)>;
    ll size;
    std::vector<Monoid> segment;  // 1-indexed 葉ノードは size ~ 2*size-1
    Monoid Monoid_unit;
    Monoid_func Monoid_calc;

    SegmentTree(ll N, 
                Monoid Monoid_unit = 0,
                Monoid_func Monoid_calc = [](ll a, ll b){return a+b;}) 
            : size(1), Monoid_unit(Monoid_unit), Monoid_calc(Monoid_calc) {
        while(size < N) size <<= 1;
        segment.assign(size*2, Monoid_unit);
    }

    void set(ll k, Monoid a){
        segment[k+size] = a;
    }
    void build(){  // 全てのノードを再計算
        for(ll k=size-1; k>0; k--) segment[k] = Monoid_calc(segment[k*2], segment[k*2+1]);
    }
    void update(ll k, Monoid a){
        k += size;
        segment[k] = a;
        while(k >>= 1) segment[k] = Monoid_calc(segment[k*2], segment[k*2+1]);
    }
    Monoid query(ll a, ll b){ // [a, b)の演算結果
        Monoid l=Monoid_unit, r=Monoid_unit;
        for(a+=size, b+=size; a<b; a>>=1, b>>=1){
            if(a % 2 == 1) l = Monoid_calc(l, segment[a++]);
            if(b % 2 == 1) r = Monoid_calc(segment[--b], r);
        }
        return Monoid_calc(l,r);
    }

    Monoid operator[](const ll &k) const{
        return segment[k+size];
    }
};

int main(){
    int n,q, com, x, y;

    cin >> n >> q;
    SegmentTree<ll> st(n, 2147483647, [](ll a, ll b){return std::min(a,b);});
    REP(i,q){
        cin >> com >> x >> y;
        if(com==0){
            st.update(x,y);
        }
        else{
            cout << st.query(x,y+1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4868
using System;
using System.Linq;
class P
{
  static void Main()
  {
    for(int[]n;(n=Console.ReadLine().Split().Select(int.Parse).ToArray()).All(x=>x!=0);)
    {
      int i=0;
      for(n[0]-=n[3];(n[0]+=n[3])/n[1]<n[2];++i);
      Console.WriteLine(i);
    }
  }
}


Measured memory_bytes: 16428
n, x, y = map(int, input().split())

dst = [0 for _ in range(n-1)]
for i in range(1, n+1):
    for j in range(i+1, n+1):
        dst[min(abs(i-j), abs(x-i)+1+abs(y-j))-1] += 1

for d in dst:
    print(d)


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

int main() {
	int H, W; cin >> H >> W;
	char board[8][8];
	int num_sharp = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> board[i][j];
			if (board[i][j] == '#') {
				num_sharp++;
			}
		}
	}

	if (num_sharp != W + H - 1) {
		cout << "Impossible" << endl;
		return 0;
	}


	string s = "";
	for (int i = 0; i < H-1; i++) {
		s += 'D';
	}
	for (int i = 0; i < W-1; i++) {
		s += 'R';
	}

	do {
		int i = 0;
		int j = 0;
		for (int k = 0; k < H + W; k++) {
			if (s[k] == 'D') {
				i++;
			}
			else {
				j++;
			}
			if (board[i][j] == '.') {
				break;
			}
			if (k == H + W - 3) {
				cout << "Possible" << endl;
				return 0;
			}
		}
	} while (next_permutation(s.begin(), s.end()));


	cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
A = [[int(a) for a in input().split()] for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]


card = [[False for _ in range(3)] for _ in range(3)]

for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                card[i][j] = True

bingo = False
for i in range(3):
    if (card[i][0] and card[i][1] and card[i][2]) or (card[0][i] and card[1][i] and card[2][i]):
        bingo = True
        break
if (card[0][2] and card[1][1] and card[2][0]) or (card[0][0] and card[1][1] and card[2][2]):
    bingo = True

ans = "Yes" if bingo else "No"
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll bit[1 << 18]; int n;
void add(int a, ll w) {
	for (int i = a; i <= n+1; i += i & -i)bit[i] += w;
}
ll sum(int a) {
	ll ret = 0;
	for (int i = a; i > 0; i -= i & -i)ret += bit[i];
	return ret;
}
ll a[200000];
ll s[200001]; pair<ll, int> p[200001];
int main() {
	cin >> n; ll k; cin >> k; ll out = 0;
	rep(i, n) {
		cin >> a[i]; a[i] -= k;
	}
	s[0] = 0; p[0] = { 0,0 };
	rep1(i, n) {
		s[i] = s[i - 1] + a[i-1];
		p[i] = { s[i],i };
	}
	sort(p, p + n+1);
	rep(i, n+1) {
		s[p[i].second] = i + 1;
	}
	rep(i, n + 1) {
		out += sum(s[i]);
		add(s[i], 1);
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>
 
int rot[24][7] = {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
int assign[7];
 
int main()
{
    int i, j;
    int a[7], b[7], dice[7];
 
    for (i = 1; i <= 6; i++) scanf("%d", assign+i);
    for (i = 1; i <= 6; i++) scanf("%d", a+i);
    for (j = 0; j < 24; j++) {
        for (i = 1; i <= 6; i++) dice[i] = rot[j][i];
        for (i = 1; i <= 6; i++) b[i] = assign[dice[i]];
        for (i = 1; ; i++) {
            if (i > 6) { puts("Yes"); return 0; }
            if (a[i] != b[i]) break;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 2112
#include<vector>
#include<iostream>
#include<numeric>

using namespace std;
template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}

int main(){
    double n, t,a;
    cin>>n>>t>>a;
    vector<int> ar(n) ;
    for(auto &a : ar) cin>>a;

    int closest_index  = 0;
    double min = 9999999;
    for(int x = 0 ; x < ar.size() ; x++){
        auto i = ar[x];
        double temp = max( (t - i*0.006 )  - a, a - (t - i*0.006) ) ;
        if( temp < min )
        {
            min = temp;
            closest_index = x;
        }

    }
    cout<<closest_index + 1 ;
  

    return 0;
}

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

using ll = long long;

int main()
{
  ll N, K;
  std::cin >> N >> K;

  ll mod = N % K;
  ll ans = std::min(mod, K - mod);

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


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


int main() {
	// ios_base::sync_with_stdio(0);
	// cin.tie(0);
	
	using ll = long long;
	int n;
	string s;
	cin >> n >> s;
	ll r = 0, g = 0, b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') r++;
		else if (s[i] == 'G') g++;
		else b++;
	}
	long long ans = r * g * b;

	for (int i = 0; i < n; i++) {
		for (int j = 1; ; j++) {
			if (i - j < 0 || i + j >= n) break;
			if (s[i] != s[i - j] && s[i - j] != s[i + j] && s[i + j] != s[i]) ans--;
		}
	}

	cout << ans << "\n";
}

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

using namespace std;

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

  int pos = 0;
  int ans = 0;
  for (ans=1; ans<=x; ans++) {
    pos = (ans + pos);
    if (pos >= x) {
      break;
    }
  }
  cout << ans << endl;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int A[N];
    int min = INT32_MAX;
    int minIndex;
    REP(i, N)
    {
        cin >> A[i];
        if (min > A[i])
        {
            min = A[i];
            minIndex = i;
        }
    }
    bool isKilled[N] = {false};
    while(true)
    {
        bool isAllKilled = true;
        REP(i, N)
        {
            if (i != minIndex) A[i] = A[i] % min;
            if (A[i] == 0) isKilled[i] = true;
        }
        REP(i, N)
        {
            if (i != minIndex) isAllKilled = isAllKilled && isKilled[i];
            if (!isKilled[i] && min > A[i])
            {
                min = A[i];
                minIndex = i;
            }
        }
        if (isAllKilled) break;
    }

    cout << min << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
int main()
{
	int n;cin>>n;
	int a=0,b=0,c=0,d=0;
	while(n--)
	{
		string s;cin>>s;
		if(s=="AC")
		a++;
		else if(s=="WA")
		b++;
		else if(s=="TLE")
		c++;
		else if(s=="RE")
		d++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;
	
}



Measured memory_bytes: 3556
cnt = 0

def insertionsort(A,n,g):
    global cnt
    for i in range(g,n):
        v = A[i]
        j = i-g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v

def shellsort(A,n):
    h = 1
    G = []
    while h <= len(A):
        G.append(h)
        h = h*3+1
    G.reverse()
    m = len(G)
    for i in range(m):
        insertionsort(A,n,G[i])
    return m,G
def main():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(int(input()))
    m,G = shellsort(A,n)
    ##print("-----------")
    print(m)
    print(*G)
    print(cnt)
    for i in A:
        print(i)

if __name__ == "__main__":
    main()


Measured memory_bytes: 45516
function perm(xs, n, s, callback) {
  var
  x, i, len = xs.length;
  s = s || [];
  if(n === 0) {
    callback(s);
  }else{
    for(i = 0; i < len; i++){
      x = xs.shift();
      s.push(x);
      perm(xs, n - 1, s, callback);
      s.pop();
      xs.push(x);
    }
  }
}

function main() {
  var
  i,
  dp = {},
  fact = [1];
  perm([0,1,2,3,4,5,6,7,8,9], 10, [], function(xs) {
    var
    i,
    t = 0;
    for(i = 0; i < 10; i++) {
      t += xs[i] * (i + 1);
      dp[i] = dp[i] || [];
      dp[i][t] = (dp[i][t] || 0) + 1;
    }
  });
  for(i = 1; i <= 9; i++) {
    fact[i] = fact[i - 1] * i;
  }
  
  input.forEach(function(line) {
    var
    n, s;
    if(line.trim() === '') return;
    line = line.split(' ').map(parseFloat);
    n = line[0]; s = line[1];
    if(n < 0 || s >= 331) {
      console.log(0);
    }else if(n === 0) {
      if(s === 0) console.log(1);
      else console.log(0);
    }else{
      console.log(~~(dp[n - 1][s] / fact[10 - n]));
    }
  });
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 10840
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  ll N;
  cin >> N;
  vector<string> names(N);

  for (ll i = 0; i < N; i++) {
    cin >> names[i];
  }

  ll m = 0;
  ll a = 0;
  ll r = 0;
  ll c = 0;
  ll h = 0;
  for (auto name : names) {
    if (name[0] == 'M') {
      m++;
    } else if (name[0] == 'A') {
      a++;
    } else if (name[0] == 'R') {
      r++;
    } else if (name[0] == 'C') {
      c++;
    } else if (name[0] == 'H') {
      h++;
    }
  }

  ll ans = 0;
  // mar
  ans += m * a * r;
  // mac
  ans += m * a * c;
  // mah
  ans += m * a * h;
  // mrc
  ans += m * r * c;
  // mrh
  ans += m * r * h;
  // mch
  ans += m * c * h;
  // arc
  ans += a * r * c;
  // arh
  ans += a * r * h;
  // ach
  ans += a * c * h;
  // rch
  ans += r * c * h;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5760
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int a, b, x;
    cin >> a >> b >> x;
    if (a<=x && x<=a+b) cout << "YES" << endl;
    else cout  << "NO" << endl;
}

Measured memory_bytes: 256
def main():

    N = int(input())
    A =list(map(int, input().split()))
    su = 0

    for i in range(N):
        su = su ^ A[i]


    
    for i in range(N):
        A[i] = su ^ A[i]
    
    print(*A)

if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;

ll calc_dst(vector<ll> next, ll p, ll K){
  vector<ll> path;
  ll p_tmp = p;
  do {
    path.push_back(p_tmp);
    p_tmp = next[p_tmp];
  } while (p_tmp != p);
  for (ll a : path){
    cerr << a << " ";
  }
  cerr << "\n";
  return path[K % path.size()];
}

int main(){
  ll N, K, a;
  cin >> N >> K;
  vector<ll> next;
  for (ll i=0; i<N; i++){
    cin >> a;
    next.push_back(a - 1);
  }
  vector<bool> visited(N, false);
  int p = 0;
  while (true){
    p = next[p];
    K--;
    if (K == 0){
      break;
    }
    if (visited[p]){
      p = calc_dst(next, p, K);
      break;
    }
    visited[p] = true;
  }
  cout << p + 1 << "\n";
}

Measured memory_bytes: 8288
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: Traveling Plan
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

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

/* global variables */

int as[MAX_N + 2];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  as[0] = as[n + 1] = 0;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &as[i]);
    sum += abs(as[i] - as[i - 1]);
  }
  sum += abs(as[n + 1] - as[n]);

  for (int i = 1; i <= n; i++) {
    int c =
      sum
      - (abs(as[i - 1] - as[i]) + abs(as[i + 1] - as[i]))
      + abs(as[i + 1] - as[i - 1]);
    printf("%d\n", c);
  }
  return 0;
}


Measured memory_bytes: 1664
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;

/**
 * main
 */
int main () {
  ll N;
  cin >> N;

  bool denied = false;

  while (N--) {
    ll A;
    cin >> A;

    if (A % 2 == 0 && !(A % 3 == 0 || A % 5 == 0)) {
      denied = true;
    }
  }

  cout << (denied ? "DENIED" : "APPROVED") << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <cmath>
#include <queue>
#define in std::cin
#define out std::cout
#define end std::endl
#define REP(i, A, N) for(int i=A;i<N;++i)
typedef long long int ll;

int main()
{
	ll x;
	in >> x;
	if((x == 7) || (x == 5) || (x == 3)){
		out << "YES" << end;
	}else{
		out << "NO" << end;
	}

	return 0;
}


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

int main () {
  int D,N;
  cin >> D >> N;
  if(D==0){
    if(N!=100){
      cout << N << endl;
    }
    else{
      cout << 101 << endl;
    }
  }
  else if(D==1){
    if(N!=100){
      cout << N*100 << endl;
    }
    else{
      cout << 10100 << endl;
    }
  }
  else{
    if(N!=100){
      cout << N*10000 << endl;
    }
    else{
      cout << 1010000 << endl;
    }
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a[3];
  int five = 0,seven = 0;
  if(scanf("%d%d%d",a,a+1,a+2)){
    for(int cnt = 0;cnt < 3;cnt++){
      if(a[cnt] == 5) five += 1;
      else if(a[cnt] == 7) seven += 1;
    }
    if(five == 2 && seven == 1) printf("YES");
    else printf("NO");
  }
  return 0;
}


Measured memory_bytes: 1708
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = (a+b)/2;
		
		if((a+b)%2 == 0) {
			System.out.println(k);
		}else {
			System.out.println("IMPOSSIBLE");
		}
	}
}

Measured memory_bytes: 23892
#include<stdio.h>
#define min(a,b) (a)<(b)?(a):(b)
int main(void)
{
  int n,T,c[101],t[101],min=10000;
  scanf("%d%d",&n,&T);
  for(int i=0;i<n;i++){
    scanf("%d%d",&c[i],&t[i]);
    if(t[i]<T+1){
      min=min(min,c[i]);
    }
  }
  if(min==10000){
    puts("TLE");
  }else{
    printf("%d",min);
  }
  return 0;
}


Measured memory_bytes: 128
///
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Mar 24 02:14:06 2018
//
package main

import (
	"fmt"
	"sort"
)

var N int

type point struct {
	x, y int
}

func (p point) isLessThan(q point) bool {
	if p.x < q.x && p.y < q.y {
		return true
	}
	return false
}

type points []point

type reds struct {
	points
}

func (p reds) Len() int {
	return len(p.points)
}

func (p reds) Swap(i, j int) {
	p.points[i], p.points[j] = p.points[j], p.points[i]
}

func (p reds) Less(i, j int) bool {
	return p.points[j].y < p.points[i].y
}

type blues struct {
	points
}

func (p blues) Len() int {
	return len(p.points)
}

func (p blues) Swap(i, j int) {
	p.points[i], p.points[j] = p.points[j], p.points[i]
}

func (p blues) Less(i, j int) bool {
	return p.points[i].x < p.points[j].x
}

func main() {
	fmt.Scan(&N)

	ps := make(points, N)
	for i := range ps {
		fmt.Scan(&ps[i].x, &ps[i].y)
	}
	reds := reds{ps}
	sort.Sort(reds)

	ps = make(points, N)
	for i := range ps {
		fmt.Scan(&ps[i].x, &ps[i].y)
	}
	blues := blues{ps}
	sort.Sort(blues)

	count := 0
	pairs := make([]bool, N)
	for _, r := range reds.points {
		for i, b := range blues.points {
			if !pairs[i] && r.isLessThan(b) {
				count++
				pairs[i] = true
				break
			}
		}
	}

	fmt.Println(count)
}


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

int main() {
	int n[10],top,tap,min,h=0;
	for(int i=0;i<10;i++){
		cin>>n[i];
	}
	for(int j=0;j<10;j++){
				if(top<n[j]){
					h=top;
					min=tap;
					top=n[j];
					tap=h;
					h=0;
				}
				else if(tap<n[j]){
					min=tap;
					tap=n[j];
				}
				else if(min<n[j]){
					min=n[j];
				}
			}
	cout<<top<<"\n"<<tap<<"\n"<<min<<endl;
	return 0;
}


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

int n,t;
vector<pair<int,int> >vec;
int mem[3002][3002];

int solve(int cur,int T)
{
    if(cur==n)return 0;
    if(T>=t)return 0;
    int &ret=mem[cur][T];
    if(ret!=-1)return ret;

    int x=solve(cur+1,T),y=0;
    y=solve(cur+1,T+vec[cur].first)+vec[cur].second;
    return ret=max(x,y);

}

int main()
{
    cin>>n>>t;
    int a,b;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        vec.push_back({a,b});
    }
    memset(mem,-1,sizeof(mem));
    sort(vec.begin(),vec.end());
    int ans=solve(0,0);
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 35712
//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

fn main() {
    input! {
        k: i64,
        s: i64,
    }

    let ans: u64 = (0..k + 1)
        .map(|x| {
            (0..k + 1)
                .filter(|y| s - x - y >= 0 && s - x - y <= k)
                .count() as u64
        })
        .sum();

    println!("{}", ans);
}

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

ll mod_pow(ll n, ll p, ll mod){
    n %= mod;
    // return (n^p) % mod
    if(p==0) return 1;
    ll res = mod_pow(n*n%mod, p/2, mod);
    if(p%2==1) res = res * n % mod;
    return res;
}

int main(){
    int N;  cin >> N;
    vector<ll> D(N);
    for(int i=0; i<N; i++)
        cin >> D[i];
    if(D[0] != 0){
        cout << 0 << endl;
        return 0;
    }
    vector<ll> cnt(N, 0);
    ll d = 0;
    for(int i=0; i<N; i++){
        cnt[D[i]]++;
        d = max(d, D[i]);
    }
    if(cnt[0] != 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i=1; i<=d; i++){
        if(cnt[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 1;
    ll mod = 998244353;
    for(int i=1; i<=d; i++){
        ll m = mod_pow(cnt[i-1], cnt[i], mod);
        ans *= m;
        ans %= mod;
    }
    cout << ans%mod << endl;
}


Measured memory_bytes: 1792