akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int w;
	while (scanf("%d", &w), w != -1)
	{
		int charge = 1150;
		if (w > 10)
			charge += 125 * min(10, w - 10);
		if (w > 20)
			charge += 140 * min(10, w - 20);
		if (w > 30)
			charge += 160 * (w - 30);
		printf("%d\n", 4280 - charge);
	}

	return 0;
}

Measured memory_bytes: 0
/* ex 5_4
series2 */
#include <stdio.h>
#include <string.h>
#include <regex.h>

int main(void){
    char str[11];
    char count=0;
    char max=0;
    scanf("%s",str);
    for(int i=0;i<strlen(str);i++){
        if(str[i]=='A'||str[i]=='C'||str[i]=='G'||str[i]=='T'){
            count++;
        }else{
            if(count>max){
                max=count;
            }
            count=0;
        }
    }
    if(count>max){
        max=count;
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 1724
n = int(input())
li = list(map(int, input().split()))

all_sum = sum(li)
x = 0
y = all_sum
ans = 10**18

for i in range(n):
    x += li[i]
    y -= li[i]

    if ans >= abs(x-y):
        ans = abs(x-y)

    if i == n - 2:
        break

print(ans)

Measured memory_bytes: 24820
from collections import deque

class Dice():
    # def __init__(self, sequence):
    #     self.v = deque([seq[5], seq[4], seq[0], seq[1]])
    #     self.h = deque([seq[3], seq[0], seq[2], seq[5]])

    def __init__(self, seq):
        self.v = deque([seq[5], seq[4], seq[0], seq[1]])
        self.h = deque([seq[3], seq[0], seq[2], seq[5]])

    def lotate(self, direction):

        if   direction == "E":
            self.h.rotate()
            self.v[2] = self.h[1]
            self.v[0] = self.h[3]

        elif direction == "W":
            self.h.rotate(-1)
            self.v[2] = self.h[1]
            self.v[0] = self.h[3]

        elif direction == "N":
            self.v.rotate(-1)
            self.h[1] = self.v[2]
            self.h[3] = self.v[0]

        elif direction == "S":
            self.v.rotate()
            self.h[1] = self.v[2]
            self.h[3] = self.v[0]

        else:
            pass

    def disp_top_face(self):
        return self.v[2]

    def disp_front_face(self):
        return self.v[3]

    def disp_back_face(self):
        return self.v[1]

    def disp_right_face(self):
        return self.h[2]

    def disp_left_face(self):
        return self.h[0]

    def disp_bottom_face(self):
        return self.h[3]

if __name__ == "__main__":

    param = input().split(" ")

    seq = [int(a) for a in param]
    d = Dice(seq)

    n = int(input())

    for _ in range(n):

        param = input().split()
        top = int(param[0])
        front = int(param[1])

        flag = 1

        while(flag):

            for _ in range(4):
                d.lotate("S")

                if d.disp_front_face() == front :
                    flag = 0
                    break

            if flag != 0:
                d.lotate("E")


        flag = 1

        while(flag):

            for _ in range(4):
                d.lotate("E")

                if d.disp_top_face() == top :
                    flag = 0
                    break

        print(d.disp_right_face())



Measured memory_bytes: 6016
n=int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
lis=make_divisors(n)
x=lis[-1]
if n%x**2==0:
    print(x*2-2)
    exit()
print(lis[-1]+lis[-2]-2)

Measured memory_bytes: 3268
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

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

int main()
{
	int sum = 0;
	char str[128];
	while(scanf("%s", str) != EOF){
		int diglen = 0;
		int n = strlen(str);
		rep(i, n+1){
			if(isdigit(str[i])){
				++diglen;
			}else if(diglen){
				str[i] = '\0';
				sum += atoi(str+i-diglen);
				diglen = 0;
			}
		}
	}
	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <stdio.h>
#define mm 1000000000

using namespace std;

int a[100000];
int W(int m,int b)
{
        return abs(a[m]-a[b]);

}

int F(int num, int k)
{
    int dp[num+1];
    dp[0]=0;
    dp[1]=W(0,1);

   for(int i=2;i<=num;i++)
   {
    int mi=mm;
    for(int j=i-1;j>=i-k;j--)
    {
        if(j>=0)
      {
          mi=min(mi,(dp[j]+W(i,j)));
          //cout<<"value of mi for "<<i<<" is :"<<mi<<"\n";
      }

    }
    dp[i]=mi;
    //cout<<"value at "<<i<<" is :"<<dp[i]<<"\n";

   }

    return dp[num];
}


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

int ans=F(n-1,k);
cout<<ans;
return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	int n, m = 5000 * 500;
	cin >> n;
	if (n == 0){
		return 0;
	}
	for (int i = n / 500; i >= 0; i--) {
		for (int j = n / 300; j >= 0; j--) {
			for (int k = n / 200; k >= 0; k--) {
				int w = i * 500 + j * 300 + k * 200;
				if (w == n) {
					int p = (i / 3 * 3 * 0.88 + i % 3) * 850 + (j / 4 * 4 * 0.85 + j % 4) * 550 + (k / 5 * 5 * 0.8 + k % 5) * 380;
					if (p < m) {
						m = p;
					}
				}
			}
		}
	}
	cout << m << endl;
	return main();
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
 
typedef long long ll;

using namespace std;
using Graph = vector<vector<int>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;

const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

const double PI=3.14159265358979323846; // or M_PI


void Main() {
    ll n, m, a;
    cin >> n >> m;

    REP(i, m) {
        cin >> a;
        n = n - a;
    }
    if (n < 0) {
        COUT("-1")
    }
    else{
        COUT(n)
    }
}

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



Measured memory_bytes: 3576
n, d = list(map(int, input().split()))
points = []
for i in range(n):
  points.append(list(map(int, input().split())))
  
cnt = 0
import numpy as np
for p in points:
  distance = np.linalg.norm(p)
  if distance <= d:
    cnt += 1
print(cnt)
   

Measured memory_bytes: 63332
#include<iostream>

int main(){
  int prime[1000000]={0};
  int number[1000000];
  int k,n;

  number[1] = 0;

  for(int i=2;i<1000000;i++){
    if(prime[i]==0){
      for(int j=2;i*j<1000000;j++){
        prime[i*j] = 1;
      }
    }
    if(prime[i]==0){
      number[i] = number[i-1] + 1;
    }else{
      number[i] = number[i-1];
    }
  }
  while(std::cin >> n){
    std::cout << number[n] << std::endl;
  }
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  // 隣接グラフ表現
  vector<vector<bool>> G(N, vector<bool>(N, false));
  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G.at(a).at(b) = true;
    G.at(b).at(a) = true;
  }

  int ans = 0;
  vector<int> order(N - 1);
  for (int i = 0; i < N - 1; i++)
  {
    order.at(i) = i + 1;
  }
  // O(N(N!))のアルゴリズム
  do
  {
    int exist = true;
    if (G.at(0).at(order.at(0)))
    {
      for (int i = 0; i < N - 2; i++)
      {
        if (!G.at(order.at(i)).at(order.at(i + 1)))
        {
          exist = false;
          break;
        }
      }
    }
    else
    {
      exist = false;
    }
    if (exist)
    {
      ans++;
    }
  } while (next_permutation(order.begin(), order.end()));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

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

  int result = 0;
  rep(i, N) {
    int x[26]={}, y[26]={};
    int tmp = 0;
    rep(j, N) {
      if (j<=i) x[S[j]-'a']++;
      else y[S[j]-'a']++;
    }
    rep(i, 26) if (x[i]!=0 && y[i]!=0) tmp++;
    result = max(result, tmp);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let mut s:Vec<char> = read::<String>().chars().collect();
    s.dedup();
    let ans = if s.len()  == 1 {
        0
    } else {
        s.len() -1
    };
    println!("{}",ans );
}


Measured memory_bytes: 4352
def lunlun(head,keta,now):
    if keta==1:
        A.append(int(now))
        return 0
    else:
        for i in range(-1,2):
            if 0<=head+i<=9:
                lunlun(head+i,keta-1,now+str(head+i))
A = []
for i in range(1,10):
    for j in range(1,11):
        lunlun(i,j,str(i))
#print(A)
#print(len(A))
A.sort()
K = int(input())
print(A[K-1])

Measured memory_bytes: 68700
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <cstring>
#include <iomanip>
using namespace std;

#define double long double
#define int long long
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << '\n';
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; };
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; };

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}

const int N = 4e5 + 10;
int dp[N];

signed main() {
	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'x') dp[i] = dp[i + 1];
		else dp[i] = dp[i + c + 1] + 1;
	}
	if (dp[0] != k) return 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'o') {
			if (dp[i] > dp[i + 1]) {
				cout << i + 1 << ' ';
			}
			i += c;
		}
	}
	return 0;
}

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

using i64 = int64_t;

using Graph = vector<vector<int>>;

constexpr i64 INF = 1e9;

int main(){
    int n, m;
    cin >> n >> m;
    Graph graph(n+1, vector<int>());
    for(int i=0;i<m;++i){
        int u, v;
        cin >> u >> v;
        graph[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;

    vector<vector<int>> mini(n+1, vector<int>(3, INF));
    mini[s][0] = 0;
    deque<tuple<int, int, int>> deq;
    deq.push_front(make_tuple(s, 0, 0));
    bool ok = false;
    while(!deq.empty()){
        auto cur = deq.front(); deq.pop_front();
        if(get<0>(cur) == t && get<2>(cur) == 0){
            cout << get<1>(cur) << endl;
            ok = true;
            break;
        }
        for(auto to: graph[get<0>(cur)]){
            if(get<2>(cur) < 2){
                if(mini[to][get<2>(cur)+1] <= get<1>(cur))continue;
                mini[to][get<2>(cur)+1] = get<1>(cur);
                deq.push_front(make_tuple(to, get<1>(cur), get<2>(cur) + 1));
            }else{
                if(mini[to][0] <= get<1>(cur) + 1)continue;
                mini[to][0] = get<1>(cur) + 1;
                deq.push_back(make_tuple(to, get<1>(cur) + 1, 0));
            }
        }
    }

    if(!ok)cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 11136
#define D(i,a,b)for(int i=a;i>=b;--i)
f[2005],n,k,M=1e9+7;main(){scanf("%d%d",&n,&k);f[n+1]=1;D(i,n,n-k+1)D(j,n,1)f[j]=j>i?0:(f[j]+f[j+1])%M;D(i,n-k,2)f[1]=f[1]*2%M;printf("%d\n",f[1]);}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
int main(){
	ll in[3],gomi,a;
	cin>>in[0]>>a>>gomi>>in[2]>>in[1]>>gomi>>gomi;
	ll out=a;
	rep(i,3)if(in[i]>2){
		in[i]-=1;
		out+=in[i]/2*2;
		in[i]%=2;
		in[i]+=1;
	}
	int co0=0,co1=0,co2=0;
	rep(i,3)if(in[i]==2)co2++;
	else if(in[i]==1)co1++;
	else co0++;
	if(co0){
		out+=co2*2;
	}else if(co2>1){
		out+=co2*2;
	}else{
		out+=3;
	}
	cout<<out<<endl;
}










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

int main() {
    int k, len;
    string s;
    cin >> s >> k;
    len = s.length();
    for(int i=0;i<len;i++){
        int c = ('z' - s[i] + 1) % 26;
        if(k >= c){
            s[i] = 'a';
            k -= c;
        }
        if(i == len-1){
            k %= 26;
            s[i] = (s[i] - 'a' + k)%26 + 'a';
        }
    }
    cout << s << endl;
	return 0;
}

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

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

int main() {
  _upgrade;
  int k;
  cin >> k;
  LL sum = 0;
  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        int d = gcd(a, b);
        sum += gcd(d, c);
      }
    }
  }
  cout << sum << "\n";
  return 0;
}

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

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ll n,k;
    cin>>n>>k;
    ll t,res=0;
    for(auto i=0;i<n;++i)
    {
        cin>>t;
        if(t>=k)
            ++res;
    }
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 256
#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++)
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;

int main(){
  int n,m;
  cin >> n >> m;
  
  int r[n]={ 0 },a,b;
  rep(i,m){
    cin >> a >> b;
    r[a-1]++;
    r[b-1]++;
  }
  
  rep(i,n) cout << r[i] << endl;
    
    
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

int n, m, l, r, d;
vector<pair<int, int>> g[100000];
pair<int, bool>gp[100000];
bool flag;

int dfs(int x) {
	if (flag) return 0;
	lp(g[x].size()) {
		if (gp[g[x][i].first].second) {
			if (gp[x].first + g[x][i].second != gp[g[x][i].first].first) {
				flag = true;
				return 0;
			}
		}
		else {
			gp[g[x][i].first] = make_pair(gp[x].first + g[x][i].second, true);
			dfs(g[x][i].first);
		}
	}
	return 0;
}



int main() {
	cin >> n >> m;
	lp(m) {
		cin >> l >> r >> d;
		g[l - 1].push_back(make_pair(r - 1, d));
		g[r - 1].push_back(make_pair(l - 1, -d));
	}
	lp(n)
		gp[i].second = false;
	flag = false;
	lp(n) {
		if (!gp[i].second) {
			gp[i] = make_pair(0, true);
			dfs(i);
			if (flag) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 13312
import java.util.*

fun main(args: Array<String>) {
    val result = solve(Scanner(System.`in`))
    if (result.isNotEmpty()) println(result)
}

fun solve(`in`: String) = solve(Scanner(`in`))

fun solve(sc: Scanner): String {
    val S = sc.next()
    val T = sc.next()
    var A = sc.nextInt()
    var B = sc.nextInt()
    val U = sc.next()

    if (U == S) A -= 1 else B -= 1

    return "%d %d".format(A, B)
}


Measured memory_bytes: 31144
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

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

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            List<Long> H = new ArrayList<>();
            H.add(Long.parseLong(in.next()));
            int cnt = 0;
            long cnt2 = 1;
            long ans = 0;

            while (true) {
                if (H.get(cnt) == 1) {
                    ans++;
                    break;
                }

                if (H.get(cnt) > 1) {
                    H.add((long) Math.floor(H.get(cnt) / 2));
                    cnt++;
                    ans = ans + cnt2 * 2;
                    cnt2 *= 2;
                }
            }


            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23124
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
#define min(...) minn(__VA_ARGS__)
#define max(...) maxx(__VA_ARGS__)
#define stringio() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
char _;
template<typename t>constexpr const t minn(const t x,const t y){return x<y?x:y;}
template<typename t,typename ...r>constexpr const t minn(const t x,const r ...xs){return minn(x,minn(xs...));}
template<typename t>constexpr const t maxx(const t x,const t y){return x>y?x:y;}
template<typename t,typename ...r>constexpr const t maxx(const t x,const r ...xs){return maxx(x,maxx(xs...));}
template <typename t> void scan (t& x) {do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0);}
template <typename t, typename ...r> void scan (t& x, r&... xs) {scan(x); scan(xs...);}
ll n,d;
void solve(){
	scan(n);
	int j=0;
	int mx1=0,mx2=0;
	rep(i,0,n){
		ll t;
		scan(t);
		if(t>mx1){
			mx1 = t;
			j = i;
		}else if(t>mx2){
			mx2 = t;
		}
	}
	rep(i,0,n)if(i==j)printf("%d\n",mx2);else printf("%d\n",mx1);
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 1664
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> C(N);
  for (int64_t i = 0; i < N; ++i) {
    int64_t a;
    cin >> a;
    C[i] = a - (i + 1);
  }
  nth_element(C.begin(), C.begin() + N / 2, C.end());
  const int64_t median = *(C.begin() + N / 2);
  int64_t result = 0;
  for (int64_t i = 0; i < N; ++i) {
    result += abs(C[i] - median);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 4768
import java.util.*

fun main(args: Array<String>) {
    try {
        val sc = Scanner(System.`in`)
        val n = sc.nextInt()
        if (n < 1 || n > 2_000_000) {
            throw Exception("Illegal input")
        }
        val a = IntArray(n)
        for (i in 0 until n) {
            a[i] = sc.nextInt()
            if (a[i] < 0 || a[i] > 10000) {
                throw Exception("Illegal input")
            }
        }
        val maxv = 10001
        val c = IntArray(maxv)
        for (i in 0 until n) {
            c[a[i]]++
        }
        for (i in 1 until maxv) {
            c[i] = c[i] + c[i-1]
        }
        val b = IntArray(n)
        for (j in n downTo 1) {
            b[c[a[j- 1]] - 1] = a[j-1]
            c[a[j-1]]--
        }
        println(b.joinToString(" "))
    } catch(e: Exception) {
        println(e)
    }
}



Measured memory_bytes: 554940
import sys

X = int(input())
tmp1 = X // 100
tmp2 = X % 100
ans = 1

if X < 100:
    print(0)
    sys.exit()
if tmp1 == 0:
    print(ans)
    sys.exit()

for i in range(5, 0, -1):
    t1 = tmp2 // i
    t2 = tmp2 % i
    tmp2 = t2
    tmp1 -= t1
    if tmp1 < 0:
        ans = 0
        break

if t2 != 0:
    ans = 0

print(ans)

Measured memory_bytes: 3064
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		double a = sc.nextInt();
		double b = sc.nextInt();
		double c = sc.nextInt();
		double d = sc.nextInt();
		double e = sc.nextInt();
		double f = sc.nextInt();
		a *= 100;
		b *= 100;
		double retleft = 0;
		double retright = 0;
		double retsuiyou = 0;
		for(double inb=0;inb*b<f;inb++){
			for(double ina=0;;ina++){
				double iwater = inb * b + ina * a;
				if(iwater == 0){
					continue;
				}
				if(iwater >= f){
					break;
				}
				double imaxsugar = e*(iwater/100);
				for(double ind=0;ind*d<=imaxsugar;ind++){
					for(double inc=0;;inc++){
						double isugar = ind * d + inc * c;
						if((iwater+isugar)>f){
							break;
						}
						if(isugar>imaxsugar){
							break;
						}
						double isuiyou = 100 * isugar / (iwater + isugar);
						if(isuiyou > retsuiyou){
							retleft = iwater + isugar;
							retright = isugar;
							retsuiyou = isuiyou;
						}
					}
				}
			}
		}
		if(retleft==0){
			retleft = a;
		}
		System.out.println((int)retleft+" "+(int)retright);
    }
}


Measured memory_bytes: 22996
n,m,l = gets.split(" ").map{|x| x.to_i}
l_mat =Array.new()
r_mat=Array.new()
n.times do |i|
    l_mat[i]=gets.split(" ").map{|x| x.to_i}
end
m.times do |i|
    r_mat[i]=gets.split(" ").map{|x| x.to_i}
end
ans_mat=Array.new()
n.times do |i|
    ans_mat[i]=Array.new(l)
    l.times do |j|
        ans_mat[i][j]=0
        m.times do |k|
            ans_mat[i][j]+=l_mat[i][k]*r_mat[k][j]
        end
    end
end
n.times do|i|
    l.times do |j|
        print(ans_mat[i][j])
        if(j!=l-1)
            print(" ")
        end
    end
    puts()
end


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

#define ll long long

using namespace std;
const ll INF = 1e18;
const int SIZE_LIMIT = 1e3+5;
char maze[SIZE_LIMIT][SIZE_LIMIT];

ll dp[SIZE_LIMIT][SIZE_LIMIT];

int main() {
  //memset(maze, 0, sizeof(maze));
 // memset(dp, 0x3f, sizeof(dp));

  int h = 0, w = 0, ch, cw, dh, dw;
  scanf("%d%d%d%d%d%d", &h, &w, &ch, &cw, &dh, &dw);
  ch--;cw--;dh--;dw--;

   for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>maze[i][j];
          dp[i][j]=INF;
        }
    }

  deque<pair<int, int>> q;
  q.push_back({ch, cw});
  dp[ch][cw]=0;

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


    while (!q.empty())
    {
   // auto p = q.front();
    ll ux=q.front().first;
    ll uy=q.front().second;
    q.pop_front();


    for (int i = 0; i < 4; ++i)
    {
      int nx = dx[i]+ux, ny = dy[i]+uy;
      if (nx>=0 and nx<h and ny>=0 and ny<w and maze[nx][ny] == '.' && dp[nx][ny] > dp[ux][uy]+0)
      {
        dp[nx][ny] = dp[ux][uy]+0;
        q.push_front({nx, ny});
      }
    }
    // jump
    for (int i = -2; i <= 2; ++i) 
    {
      for (int j = -2; j <= 2; ++j) 
      {
        int nx = ux+i, ny = uy+j;
        if (nx>=0 && nx<h && ny>=0 && ny<w && maze[nx][ny] == '.' && dp[nx][ny] > dp[ux][uy]+1) {
          dp[nx][ny] = dp[ux][uy]+1;
          q.push_back({nx, ny});
        }
      }
    }

  }

  if (dp[dh][dw] == INF) printf("-1\n");
  else printf("%d\n", dp[dh][dw]);



  return 0;
}


Measured memory_bytes: 12596
l, r = map(int, input().split())

l2 = l // 2019
r2 = r // 2019

if l2 != r2:
  print(0)
else:
  ans=2019
  for i in range(l, r):
    for j in range(i+1, r + 1):
      ans = min(ans, (i * j) % 2019)
  print(ans)
  

Measured memory_bytes: 2940
def main():
  can_get_cnt = int(input())
  jewel_values = list(map(int, input().split(" ")))
  jewel_costs = list(map(int, input().split(" ")))
  
  jewel_profits = []
  
  for i in range(0, len(jewel_values)):
    jewel_profits.append(jewel_values[i] - jewel_costs[i])
  
  sorted_jewel_profits = sorted(jewel_profits, reverse=True)
  
  ret = 0
  
  for i in range(0, can_get_cnt):
    if sorted_jewel_profits[i] > 0:
      ret = ret + sorted_jewel_profits[i]
    else:
      break
  
  
  print (ret)


main()


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

#define endl '\n'
#define int ll
typedef long long ll;

const int MAX_N = 1e5 + 87;

int h[MAX_N] = {};
int dp[MAX_N] = {};

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

    int N, K;
    cin >> N >> K;
    for (int i = 1; i <= N; i++)
        cin >> h[i];
    for (int i = 1; i <= N; i++)
        dp[i] = -1;
    
    dp[1] = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= K; j++) {
            int pos = i + j;
          	
            int cost = dp[i] + abs(h[i] - h[pos]);
            if (dp[pos] > cost || dp[pos] == -1) {
                dp[pos] = cost;
            }
        }
    }

    cout << dp[N];

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef double db;

#define mp make_pair
#define pb push_back
#define pt(i) printf("%lld\n",(ll)i)
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1.0)

ll in() { ll a;scanf("%lld",&a); return a;}
db din(){ db a;scanf("%lf",&a); return a; }
ll bigmod(ll b, ll p,ll md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {ll y=bigmod(b,p/2,md);return (y*y)%md;}}
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b);}

long long getRandom(long long a,long long b){
    long long ret = (long long)rand()*(long long)rand();
    ret %= (b - a + 1);
    ret += a;
    return ret;
}

int dp[100005];
vi adj[100005];

int dfs(int u)
{
	if(dp[u]!=-1)
		return dp[u];
	dp[u]=0;
	for(int i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i];
		dp[u]=max(dp[u],1+dfs(v));
	}
	return dp[u];
}

int main()
{
	//freopen("in.c","r",stdin);
	//freopen("out.c","w",stdout);
	int n=in(),m=in();
	for(int i=0;i<m;i++)
	{
		int u=in(),v=in();
		adj[u].pb(v);
	}
	memset(dp,-1,sizeof dp);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,dfs(i));
	}
	pt(ans);
}



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

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if ((n | m) == 0) {
            break;
        }
        int* field = new int [n];
        for (int i = 0; i < n; i++) {
            cin >> field[i];
        }
        int* dices = new int [m];
        for (int i = 0; i < m; i++) {
            cin >> dices[i];
        }
        int pos = 0, diceRoll = 0;
        while (pos < n && diceRoll < m) {
            pos += dices[diceRoll++];
            if (n <= pos) {
                break;
            }
            pos += field[pos];
        }
        cout << diceRoll << endl;
        delete[] field;
        delete[] dices;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n , m , l , r , x , y;
int main()
{
    cin >> n >> m;
    x = 1 ; y = n;
    for (int i = 1 ; i <= m ; i++)
    {
        cin >> l >> r;
        x = max(x , l);
        y = min(y , r);
        if (x > y)
        {
            y = -1;
            x = 0;
            break;
        }
    }
    cout << y - x + 1;
    return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int> >;
using vii = vector<pair<int, int> >;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	cout << pow(n, 3) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	int A,B;
	cin>>A>>B;
	if(A%2==1&&B%2==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
#137_C
from collections import Counter
n = int(input())
w = []
for _ in range(n):
    s = sorted(input())
    w.append(''.join(s))
w.sort()
w = Counter(w)
ans = 0
for t, idx in w.items():
    ans += idx * (idx - 1) // 2
print(ans)

Measured memory_bytes: 19816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

ll X, Y;

void simulate() {
  const int M = 21;
  int memo[M][M];
  rep(i, M) rep(j, M) memo[i][j] = -1;

  function<bool(int, int)> win = [&](int x, int y) {
    assert(x >= 0 && y >= 0 && x <= M && y <= M);
    if (memo[x][y] != -1) return memo[x][y];
    if (x <= 1 && y <= 1) return memo[x][y] = false;
    bool res = false;
    for (int i = 1; 2 * i <= x && y + i < M; ++i) res |= !win(x - 2 * i, y + i);
    for (int i = 1; 2 * i <= y && x + i < M; ++i) res |= !win(x + i, y - 2 * i);

    return memo[x][y] = res;
  };

  rep(i, M) {
    rep(j, M) cout << win(i, j);
    cout << endl;
  }
}

int main() {
  cin >> X >> Y;
  cout << (abs(X - Y) <= 1 ? "Brown" : "Alice") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int distance(int x, int y){
    int dis;
    dis = x-y;
    if(dis>=0){
        return x-y;
    }else{
        return y-x;
    }
}

int main(){
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c ,&d);
    if(distance(a,c)<=d){
        printf("Yes\n");
    }else{
        if((distance(a,b)<=d) && (distance(b,c)<=d)){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }

    return 0;
}

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

using namespace std;

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

	int l;

	cin >> l;
	
	cout << fixed;
	cout.precision(15);

	double res = (l/3.0);
	cout << pow(res,3) << '\n';
    return 0;
}

Measured memory_bytes: 384
from collections import deque

H, W = map(int, input().split())
sy, sx = map(lambda x: int(x)-1, input().split())
gy, gx = map(lambda x: int(x)-1, input().split())
maze = [input() for _ in range(H)]

INF = float("INF")
cnt = [[INF]*W for _ in range(H)]

q = deque()
q.append([sy, sx])
cnt[sy][sx] = 0
move = [[1, 0], [-1, 0], [0, 1], [0, -1]]

while q:
    y, x = q.popleft()
    for dy, dx in move:
        ny = y + dy
        nx = x + dx
        if ny < 0 or ny > H-1 or nx < 0 or nx > W-1:
            continue
        if maze[ny][nx] == "." and cnt[ny][nx] > cnt[y][x]:
            cnt[ny][nx] = cnt[y][x]
            q.appendleft([ny, nx])
    for i in range(-2, 2+1):
        for j in range(-2, 2+1):
            wy = y + i
            wx = x + j
            if wy < 0 or wy > H-1 or wx < 0 or wx > W-1:
                continue
            if maze[wy][wx] == "." and cnt[wy][wx] > cnt[y][x] + 1:
                cnt[wy][wx] = cnt[y][x] + 1
                q.append([wy, wx])

ans = cnt[gy][gx] if cnt[gy][gx] != INF else -1
print(ans)

Measured memory_bytes: 115252
from itertools import combinations
n=int(input())
march=[0,0,0,0,0]
for i in range(n):
  k=input()
  if k[0]=="M":
    march[0]+=1
  if k[0]=="A":
    march[1]+=1
  if k[0]=="R":
    march[2]+=1
  if k[0]=="C":
    march[3]+=1
  if k[0]=="H":
    march[4]+=1
ans=0
for (i,j,k) in combinations(march,3):
  ans+=i*j*k
print(ans)
  
  

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

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

#define INF 1e9

int main(){
  int N;
  string S;
  cin >> N >> S;
  ll cnt =0;
  REP(i, 10){
    REP(j, 10){
      REP(k, 10){
        int id[] = {i, j, k};
        int idx = 0;
        REP(n, N){
          if(S[n]-'0' == id[idx]){
            idx++;
            if(idx == 3){
              cnt++;
              break;
            }
          }
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a1 = list(map(int, input().split()))
a2 = []
if n == 1:
    print(1)
else:
    for i in a1:
        a2.append(i)
        a2.append(i+1)
        a2.append(i-1)
    from collections import Counter
    a = Counter(a2).most_common()
    print(a[0][1])

Measured memory_bytes: 34872
n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2, a))
m1 = a2[0]
for i in range(1, n):
    if i % 2 == 1:
        m1 -= a2[i]
    else:
        m1 += a2[i]
ans = [m1//2]
for i in range(n-1):
    ans.append(a2[i]-ans[i])
print(*ans)




Measured memory_bytes: 17632
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/22 16:16:30 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	ll	k, a, b;
	cin >> k >> a >> b;

	if (k < a + 1)
	{
		cout << k + 1 << endl;
		return ;
	}
	ll	sum;
	sum = 1;
	if (b > a + 1)
	{
		k -= (a + 1);
		sum += (b - 1);
		sum += (b - a) * (k / 2);
		k %= 2;
	}
	sum += k;
	cout << sum << endl;
}
// END

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


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)

int i, j, k;
int main() {
	int N, K;
	vector<int> A;
	cin >> N >> K;
	//負の最後のやつ Index + 1 は０か正
	int Index = -1;
	rep(i, 0, N) {
		int tmp;
		cin >> tmp;
		if (tmp < 0)
			Index++;
		if (tmp == 0) {
			K--;
			N--;
		}
		else
			A.push_back(tmp);
	}
	N = A.size();
	int ans = 1000000000;
	if (K == 0) {
		cout << 0;
		return 0;
	}
	for (i = 0; i < N - K + 1 && K>0; i++) {
		if (i + K - 1 <= Index) {
			int tmp = abs(A[i]);
			ans = MIN(ans, tmp);
		}
		else if (i <= Index) {
			int tmp = MIN(abs(A[i]), abs(A[i + K - 1])) * 2;
			tmp += MAX(abs(A[i]), abs(A[i + K - 1]));
			ans = MIN(ans, tmp);
		}
		else {
			int tmp = abs(A[i + K - 1]);
			ans = MIN(ans, tmp);
		}
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 892
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();

    int res = 0;
    int concateA = 0;
    int concateB = 0;
    int concateAB = 0;
    for (int i=0;i<n;i++) {
      String line = cin.next();

      int fromIndex = 0;

      while ((fromIndex = line.indexOf("AB", fromIndex)) != -1 ){
//        System.out.println("Found at index: " + fromIndex);
        res++;
        fromIndex++;
      }

      if (line.lastIndexOf('A') == line.length()-1 && line.indexOf('B') != 0)
        concateA++;
      if (line.indexOf('B') == 0 && line.lastIndexOf('A') != line.length()-1)
        concateB++;
      if (line.lastIndexOf('A') == line.length()-1 && line.indexOf('B') == 0)
        concateAB++;
    }
//    System.out.println("A "+concateA+" B "+concateB+" BA "+concateAB);
//    if (concateA==n&&concateB==n) {
//      System.out.println(res+n-1);
//    }
//    else {
//      res = res + Math.min(concateA, concateB);
//      System.out.println(res);
//    }
    res = res + Math.min(concateA, concateB) + concateAB;
    if (concateA==0&&concateB==0&&concateAB!=0){
      System.out.println(res-1);
    }
    else
      System.out.println(res);

  }

}

Measured memory_bytes: 29312
#include <stdio.h>
int main()
{
    int a,b,c;
    scanf(" %d%d%d",&a,&b,&c);
    -100<=a&&a<=100;
    -100<=b&&b<=100;
    -100<=c&&c<=100;

        if(c>=a&&c<=b)
            {
                printf("Yes");
        }
        else {printf("No");}


    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,Q; cin >> N >> Q;
    string S; cin >> S;
    vector<ll> cusum(S.length()+1);
    for(int i = 1; i < S.length();i++){
        cusum[i] = cusum[i-1];
        if(S[i]=='C' && S[i-1]=='A') cusum[i]++;
    }
    for(int i = 0; i < Q;i++){
        int l,r; cin >> l >> r;
        l--; r--;
        cout << cusum[r] - cusum[l] << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    //cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main(){
    int H; cin >> H;
    int W; cin >> W;
    int N; cin >> N;
    
    int a=max(H,W);
    int ans;
    if (N%a!=0){
        ans=N/a+1;
    }else{
        ans=N/a;
    }
    cout << ans;
}

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

int main() {
  int n;
  std::stack<int> st;
  while (std::cin >> n) {
    if (n) {
      st.push(n);
    } else {
      std::cout << st.top() << std::endl;
      st.pop();
    }
  }
}


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int m,n;
	while(scanf("%d%d",&m,&n)!=EOF)
	{
		int t,s=m+n;
		t=0;
		while(s)
		{
			s/=10;
			t++;
		}
		printf("%d\n",t);
	}
	return 0;
} 

Measured memory_bytes: 600
import sys
num = [0 for i in range(26)]
for str in sys.stdin:
    st=str.lower()
    for k in range(len(st)):
        if ord(st[k])<=122 and ord(st[k])>=97:
            num[ord(st[k])-97]+=1
for i in range(26):
    print("{0} : {1}".format(chr(i+97),num[i]))

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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
inline void solve () {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll g = __gcd(b, d);
	if (a < b || d < b || (a - (a - c - 1) / g * g) - b < 0) {
		cout << "No\n";
		return;
	}


	cout << "Yes\n";
}


int main () {
	SpeedForce;
	int t;
	cin >> t;
	while(t--) solve();
   	return Accepted;
}

// B...a

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
map<ll,ll> p;
int main(){
    ll x;
    cin>>x;
    for(ll i=-1000;i<=1000;i++){
        p[i*i*i*i*i]=i;
    }
    for(ll i=-1000;i<=1000;i++){
        ll num=i*i*i*i*i;
        if(p[num-x]){
            cout<<i<<" "<<p[num-x]<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3832