akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
  int a,b;
  cin >> a >> b;
  string s[100];
  for(int i = 0; i < 100; i++){
    for(int j = 0; j < 100; j++){
      if(i<50) s[i].push_back('.');
      else s[i].push_back('#');
    }
  }
  int cnt = 0;
  for(int i = 0; i < 50; i += 2){
    if(cnt == b-1) break;
    for(int j = 0; j < 100; j += 2){
      if(cnt == b-1) break;
      s[i][j] = '#';
      cnt++;
    }
  }
  cnt = 0;
  for(int i = 51; i < 100; i += 2){
    if(cnt == a-1) break;
    for(int j = 0; j < 100; j += 2){
      if(cnt == a-1) break;
      s[i][j] = '.';
      cnt++;
    }
  }
  cout << 100 << " " <<  100 << endl;
  for(int i = 0; i < 100; i++){
    cout << s[i] << endl;
  }

  return 0;
}

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

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	int dx[] = { 0,-1,0,1 };
	int dy[] = { -1,0,1,0 };
	int x, y;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				bool ok = false;
				for (int k = 0; k < 4; k++) {
					x = i + dx[k];
					y = j + dy[k];
					if (x >= 0 && x < h&&y >= 0 && y < w&&s[x][y] == '#') {
						ok = true;
					}
				}
				if (!ok) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{

    long long n,k,q,a[100000],i,score[100000];

    scanf("%lld %lld %lld",&n,&k,&q);
    for (i = 0; i < n; i++)
    {
        score[i] = k - q;
    }
    for (i = 0; i < q; i++)
    {
        scanf("%lld",&a[i]);
        score[a[i] - 1] ++;
    }

    for (i = 0; i < n; i++)
    {
        if (score[i] > 0)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
        
    }
    
}


Measured memory_bytes: 2048
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    bool ok = true;
    ll left = 2;
    ll right = 2;
    for (int i = N-1; i >= 0; i--) {
        if (left / A[i] == right / A[i] && left % A[i] != 0) {
            ok = false;
            break;
        }
        left = (left + A[i]-1LL) / A[i] * A[i];
        right = right / A[i] * A[i] + A[i] - 1LL;
    }
    if (ok) cout << left << " " << right << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 1024
result = (0..9).to_a.repeated_permutation(4).map {|a,b,c,d| [a,b,c,d].inject(:+) }.inject(Hash.new(0)) {|a, e| a[e] += 1; a}
STDIN.read.split("\n").map(&:chomp).map(&:to_i).each do |n|
  puts result[n] || 0
end

Measured memory_bytes: 9124
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define INF 2140000000
#define MOD 1000000007

int main() {
	int a, b, c, d, e, k;

	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;
	cin >> k;

	if (e - a <= k) {
		cout << "Yay!";
	}
	else {
		cout << ":(";
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for(int i = 0 ; i < 2 ; i++) {
			if(s.charAt(i) == '9') {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21716
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 100000)
	strByte := make([]byte, 100000)
	readLen, _ := reader.Read(strByte)
	ans := make([]byte, 0, readLen/2)
	for i := 0; i < readLen; i += 2 {
		ans = append(ans, strByte[i])
	}
	fmt.Println(string(ans))
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ii pair <int, int>
#define x first
#define y second
#define db(x) cerr << #x << " = " << x << endl;

using namespace std;

inline void read(int &x){register int c = getchar();x = 0; int neg = 0;for (;((c<48 || c>57) && c != '-') ;c = getchar());if(c=='-') {neg=1;c=getchar();}for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}if(neg) x=-x;}
inline void read(long long &x){register int c = getchar();x = 0; int neg = 0;for (;((c<48 || c>57) && c != '-') ;c = getchar());if(c=='-') {neg=1;c=getchar();}for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}if(neg) x=-x;}
inline void writeln(long long x){char buffor[21];register int i=0;int neg=0; if (x<0) {neg=1; x= -x;}do{buffor[i++]=(x%10)+'0';x/=10;} while(x);i--;if (neg) putchar('-');while(i>=0) putchar(buffor[i--]);putchar('\n');}
inline void write(long long x){char buffor[21];register int i=0;int neg=0; if (x<0) {neg=1; x= -x;}do{buffor[i++]=(x%10)+'0';x/=10;} while(x);i--;if (neg) putchar('-');while(i>=0) putchar(buffor[i--]);putchar(' ');}

const int N = 107;
const int oo = 1e9 + 7;

int n;
int x;
long long res;

struct edge{
	int v, f, c;
	edge() {}
	edge(int v, int f, int c): v(v), f(f), c(c) {}
}e[10 * N];

struct flow{
	int Time, deg[N], s, t, d[N];
	int q[4 * N], lo, hi;
	int Now[N];
	vector <int> adj[N];

	inline void AddEdge(int id, int u, int v, int c){
		e[id * 2] = edge(v, 0, c);
		e[id * 2 + 1] = edge(u, 0, 0);
		adj[u].push_back(id * 2);
		adj[v].push_back(id * 2 + 1);
	}

	bool bfs(){
		lo = hi = 1;
		memset(d, 0, sizeof(d));
		q[1] = s;
		d[s] = 1;
		while (lo <= hi){
			int u = q[lo];
			lo++;
			if (u == t) return true;
			for (int id: adj[u]){
				int v = e[id].v;
				if (!d[v] && e[id].f < e[id].c){
					d[v] = d[u] + 1;
					q[++hi] = v;
				}
			}
		}
		return false;
	}	

	int dfs(int u, int mn){
		if (u == t) return mn;
		if (deg[u] != Time)
			deg[u] = Time;
		else
			return 0;
		for (int i = Now[u]; i < adj[u].size(); i++){
			Now[u] = i;
			int id = adj[u][i];
			int v = e[id].v;
			if (e[id].f < e[id].c)
				if (deg[v] != Time && d[v] == d[u] + 1)
					if (int x = dfs(v, min(mn, e[id].c - e[id].f))){
						e[id].f += x;
						e[id ^ 1].f -= x;
						return x;
					}
		}
		return 0;
	}

	long long MaxFlow(){
		long long sum = 0;
		while (bfs()){
			fill(Now, Now + n + 1, 0);
			while (int x = (Time++, dfs(s, oo)))
				sum += x;
		}
		return sum;
	}
}Flow;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	read(n);
	Flow.s = 0; Flow.t = n + 1;
	for (int i = 1; i <= n; i++){
		read(x);
		if (x >= 0){
			Flow.AddEdge(i, i, n + 1, x);
			res += x;
		}
		else
			Flow.AddEdge(i, 0, i, -x);
	}
	int g = n;
	for (int i = 1; i <= n; i++)
		for (int j = 2 * i; j <= n; j += i){
			Flow.AddEdge(++g, i, j, oo);
		}
	write(res - Flow.MaxFlow());
}

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

int main(void)
{
	string O, E, ans = "";
	cin >> O >> E;

	for (int i = 0; i < E.size(); ++i) {
		ans += O[i];
		ans += E[i];
	}
	if (O.size() > E.size()) {
		ans += O[O.size() - 1];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[300100];
int w[300100];
int e[300100];
int main()
{
	int n;
	cin>>n;
	scanf(" %s",&s[1]);
	for(int i = 1;i <= n; i++)
	{
		if(s[i]=='W')
		{
			w[i]++;
		}
			w[i]+=w[i-1];
		if(s[n-i+1]=='E')
		{
			e[n-i+1]++;
		}
			e[n-i+1]+=e[n-i+2];
	}
	int ans=1e9;
	for(int i = 1; i <= n; i++)
	{
		ans=min(ans,w[i-1]+e[i+1]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2944
n, p = map(int, input().split())
s = input()

if p == 2 or p == 5:
    ans = 0
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i+1
    print(ans)
else:
    s_inv = s[::-1]
    lst = [0 for i in range(n+1)]
    n_amari = [0 for i in range(p)]
    amari = 1
    ans = 0
    for i in range(n):
        amari = (amari * 10) % p
        lst[i+1] = (amari * int(s_inv[i]) + lst[i]) % p
        if lst[i+1] != 0:
            ans += n_amari[lst[i+1]]
            n_amari[lst[i+1]] += 1
        else:
            n_amari[lst[i+1]] += 1
            ans += n_amari[lst[i+1]]
    print(ans)

Measured memory_bytes: 11484
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0',ch=getchar();}
    return x*f;
}
const int mod=1e9+7;
int n;
ll a[N],s[N];
void solve()
{
	n=read();
	for(int i=1; i<=n; i++) a[i]=read(),s[i]=s[i-1]+a[i],s[i]%=mod;
	ll ans=0;
	for(int i=2; i<=n; i++) {
		ans+=a[i]*s[i-1]; ans%=mod;
	}
	cout<<ans<<endl;
}
int main()
{
	int T=1;
	while(T--) solve();
}

Measured memory_bytes: 6752
# int(input())
N,K=list(map(int,input().split()))
inl = [int(input()) for i in range(N)]
inl.sort()

res = 1000000000000
for i in range(N-K+1):
    res = min(res, inl[i+K-1] - inl[i])

print(res)


Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;

const ld pi = acos(-1.);
const ll INF = 1000000000;

int main() {
    ios_base::sync_with_stdio(false);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a > c){
        swap(a, c);
        swap(b, d);
    }
    bool inv = false;
    if(b > d){
        swap(b, d);
        inv = true;
    }
    ll n;
    cin >> n;
    vector<pll> p;
    ll o, oo;
    for(ll i = 0; i < n; ++i){
        cin >> o >> oo;
        if(o >= a && o <= c && oo >= b && oo <= d){
            p.push_back({o, oo});
        }
    }
    if(a == c || b == d){
        ld ans = ((d - b) + (c - a)) * 100;
        ld fo = pi * 10 - 20;
        ans += min((ld)200, fo * p.size());
        cout << setprecision(18) << fixed << ans << endl;
        return 0;
    }
    ld ans = (c - a) + (d - b);
    ans *= 100;
    ld foun = -20 + 5 * pi;
    sort(p.begin(), p.end());
    ll cur = 0;
    if(!inv) {
        vector<ll> mx(p.size() + 1, INF);
        for (ll i = 0; i < p.size(); ++i) {
            ll l = 0, r = p.size(), mid;
            while (r - l > 1) {
                mid = (r + l) >> 1LL;
                if (mx[mid] > p[i].second) {
                    r = mid;
                } else {
                    l = mid;
                }
            }
            mx[r] = p[i].second;
            cur = max(cur, r);
        }
    }else{
        vector<ll> mx(p.size() + 1, INF);
        for (ll i = 0; i < p.size(); ++i) {
            ll l = 0, r = p.size(), mid;
            while (r - l > 1) {
                mid = (r + l) >> 1LL;
                if (mx[mid] > -p[i].second) {
                    r = mid;
                } else {
                    l = mid;
                }
            }
            mx[r] = -p[i].second;
            cur = max(cur, r);
        }
    }
    ans += foun * cur;
    if(cur == min(c - a, d - b) + 1){
        ans += 5 * pi;
    }
    cout << setprecision(18) << fixed << ans << endl;
    return 0;
}

Measured memory_bytes: 6256
#include<stdio.h>
#include<string.h>
int main(){
  char a[10],b[10],c[10];
  scanf("%s%s%s",a,b,c);
  if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])
    printf("YES");
  else
    printf("NO");
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

#define COLOR_MAX 9

int colors[COLOR_MAX][3] = {
	{1, 399, 0},
	{400, 799, 0},
	{800, 1199, 0},
	{1200, 1599, 0},
	{1600, 1999, 0},
	{2000, 2399, 0},
	{2400, 2799, 0},
	{2800, 3199, 0},
	{3200, 9999, 0},
};

int main(void)
{
	int N, a;
	int mincount, maxcount;
	int topcoder;
	int i, j;

	scanf("%d", &N);

	topcoder = 0;
	i = 0;
	while (i < N)
	{
		scanf("%d", &a);

		j = 0;
		while (j < COLOR_MAX)
		{
			if (colors[j][0] <= a && a <= colors[j][1])
			{
				colors[j][2]++;
			}
			j++;
		}
		i++;
	}

	i = mincount = maxcount = 0;
	while (i < COLOR_MAX)
	{
		if (i != COLOR_MAX -1 && 0 < colors[i][2])
		{
			mincount++;
		}
		i++;
	}

	topcoder = colors[COLOR_MAX - 1][2];

	if (mincount == 0 && 0 < topcoder)
	{
		mincount = 1;
		maxcount = topcoder;
	}
	else
	{
		maxcount = mincount;
		if (0 < topcoder)
		{
			maxcount += topcoder;
		}
	}

	printf("%d %d", mincount, maxcount);

	return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int i = 0, n, maxi = 0; cin >> n;
    string s; cin >> s;
    for(auto it:s){
        if(it=='I') i++;
        else i--;
        maxi = max(maxi, i);
    }

    cout << maxi;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct s
{
    string a;int b;
    bool operator< (s s1)
    {
        if (b == s1.b) return a < s1.a;
        else return b > s1.b;
    }
};
map<string, int> mp;
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string ss;
        cin >> ss;
        if (mp.count(ss) > 0)
        {
            mp[ss]++;
        }
        else
        {
            mp[ss] = 1;
        }
    }
    vector
 vec;
    for (auto iter = mp.begin(); iter != mp.end(); iter++)
    {
        vec.push_back({iter->first, iter->second});
    }
    sort(vec.begin(), vec.end());
    int f = vec[0].b;
    for (auto iter = vec.begin(); iter != vec.end(); iter++)
    {
        if (iter->b == f) cout << iter->a << endl;
        else break;
    }
    return 0;
}

Measured memory_bytes: 29680
#include<iostream>
#include<cstdio>
using namespace std;
int a,b;
int gcd(int a,int b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
int main()
{
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        int x=gcd(a,b);
        int y=a/x*b;
        printf("%d %d\n",x,y);
    }
}

Measured memory_bytes: 1188
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, long long m, std::vector<long long> h, std::vector<long long> a, std::vector<long long> b){
    vector<i64> ma(n, -INF);
    for(int i = 0; i < m; ++i){
        --a[i], --b[i];
        chmax(ma[a[i]], h[b[i]]);
        chmax(ma[b[i]], h[a[i]]);
    }
    int cnt = 0;
    for(int i = 0; i < n; ++i)
        cnt += (ma[i] < h[i]);
    cout << cnt << endl;
}


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


Measured memory_bytes: 6408
N = int(input())
H = list(map(int,input().split()))
y = 0
z = H[0]
ans = 0
while len(H) != 0:
    z = H[0]
    f = 1
    while z == 0:
        H.pop(0)
        if len(H) != 0:
            z = H[0]
        else:
            break
    for i in range(len(H)):
        x = H[i]
        if x == 0:
            ans += z
            for j in range(i):
                H[j] -= z
            z = H[0]
            f = 0
            break
        z = min(x,z)
    if f == 1:
        ans += z
        for i in range(len(H)):
            H[i] -= z
print(ans)

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

int main() {
    std::ios::sync_with_stdio(false);
    int x;cin >> x;
    int k;cin >> k;
    vector<int> r, a, b, c;
    r.push_back(0);
    a.push_back(0);
    b.push_back(x);
    c.push_back(0);
    for(int i=0;i<k;i++){
        int rr;cin >> rr;
        int d = rr-r[i];
        int aa, bb, cc;
        if(i%2 == 0){
            aa = min(b[i], a[i] + max(0, 0-(c[i]-d)));
            bb = b[i];
            cc = max(0, c[i]-d);
        }else{
            aa = a[i];
            bb = max(a[i], b[i] - max(0, c[i]+(b[i]-a[i])+d-x));
            cc = min(x, c[i]+d);
        }
        r.push_back(rr);
        a.push_back(aa);
        b.push_back(bb);
        c.push_back(cc);
    }
    int q;cin >> q;
    for(int i=0;i<q;i++){
        int t, aa;cin >> t >> aa;
        int j = int(upper_bound(r.begin(), r.end(), t) - r.begin()) - 1;
        int d = t-r[j];
        int f;
        if(aa <= a[j]){
            f = c[j];
        }else if(aa <= b[j]){
            f = c[j] + (aa - a[j]);
        }else{
            f = c[j] + (b[j]-a[j]);
        }
        if(j%2 == 0){
            cout << max(0, f-d) << endl;
        }else{
            cout << min(x, f+d) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2916
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<cstring>
#include<cstdlib>
#include <ctime>
#include <math.h>
#include <queue>

using namespace std;
int main(void)
{
	int a[100001],i,j,n,l,t,flg=0;
	cin >> n >> l;
	for(i=0;i<n;i++) cin >> a[i];
	for(i=0;i<n-1;i++){
		if(a[i]+a[i+1]>=l){
			t=i+1;
			cout << "Possible" << endl;
			for(j=1;j<t;j++) cout << j << endl;
			for(j=n-1;j>t;j--) cout << j << endl;
			cout << t << endl;
			flg=1;
		}
		if(flg==1) break;
	}
	if(flg==0) cout << "Impossible" << endl;
}

Measured memory_bytes: 1152
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

a,b,k=map(int,input().split())
l=[]
g=gcd(a,b)

if a==1 and b==1:
  print(1)
else:
  for i in range(1,g):
    if g%i==0:
      l.append(i)
  l.append(g)
  print(l[(-1)*k])
  

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


int main(){
    int n;
    cin>>n;
    int a[30];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<=n-3;i++){
        int b[3];
        b[0]=a[i];
        b[1]=a[i+1];
        b[2]=a[i+2];
        sort(b,b+3);
        if(b[1]==a[i+1])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
long long dp[200001];//到第i个数取到i/2个数的最大值
long long sum[200001];//隔一个选一个的和到第i个位置的和为多少
int a[200001];
int main(){
    int n;
    int len = 1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        sum[i] = (i>1?sum[i-2]:0)+a[i];
    }
    for(int i=2;i<=n;i++){
        if(i%2==0){
            dp[i] = max(dp[i-2]+a[i],sum[i-1]);
        }else{
            dp[i] = max(dp[i-2]+a[i],dp[i-1]);
        }
    }
    printf("%lld\n",dp[n]);
    return 0;
}


Measured memory_bytes: 5576
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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;}

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(a,b);
  if(a >= 10){
    OUT(b);
  }else {
    OUT(b+100*(10-a));
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
#define ll long long
#define Vector Point
const int MOD=998244353;
const int MAXN=200;
void M(int& a){((a%=MOD)+=MOD)%=MOD;}
struct Point{int x,y;};
Vector operator-(const Point& a,const Point& b){return (Vector){a.x-b.x,a.y-b.y};}
int cross(const Vector& a,const Vector& b){return a.x*b.y-a.y*b.x;}
int n,ans;
Point p[MAXN+10];
int quickpow(int x,int y)
{
	int res=1;
	for(;y;y>>=1,x=(ll)x*x%MOD)if(y&1)res=(ll)res*x%MOD;
	return res;
}
int main()
{
	scanf("%d",&n);M(ans=quickpow(2,n)-n-1);
	for(int i=1;i<=n;++i)scanf("%d%d",&p[i].x,&p[i].y);
	Point a,b;int cnt;bool flag;
	for(int i=1;i<=n;++i)
	{
		for(int j=i+1;j<=n;++j)
		{
			flag=true;a=p[i];b=p[j];
			for(int k=1;k<j;++k)if(k!=i&&cross(a-p[k],b-p[k])==0){flag=false;break;}
			if(!flag)continue;
			cnt=2;
			for(int k=j+1;k<=n;++k)if(cross(a-p[k],b-p[k])==0)++cnt;
			M(ans-=quickpow(2,cnt)-cnt-1);
		}
	}
	printf("%d",ans);
	return 0;
}

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

int main() {
  // ここにプログラム
  int a, b;
  cin >> a >> b;
  if(b % a == 0) {
    cout << a + b << endl;
  }
  else {
    cout << b - a << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <deque>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
// #define mp make_pair
// #define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define show(x) cout << #x << " = " << x << endl;

int memo[301];

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

}


int main(){
  int n;
  cin >> n;
  ll a, ans = 1;
  int a1 = 0,a2=0,a4=0;
  REP(i,n){
    cin >> a;
    if(a % 4 == 0){
      a4++;
    }else if(a % 2 == 0){
      a2++;
    }else{
      a1++;
    }
  }
  if(a2 == 0){
    if(a1 <= a4+1){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    if(a1 <= a4){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	string N; cin>>N;
	char t = N[N.size()-1];
	if(t == '2' || t == '4' || t == '5' || t == '7' || t == '9'){
		cout<<"hon"<<endl;
	}else if(t == '3'){
		cout<<"bon"<<endl;
	}else {
		cout<<"pon"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3628
D,G = map(int,input().split())
pc = [list(map(int,input().split())) for _ in range(D)]
from itertools import permutations
#%%
import math
INF = 1<<30
ans = INF
A = [i for i in range(D)]

permu = permutations(A)

for pp in permu:
    points = 0
    count = 0
    for i in pp:
        if points>=G:
            break
        if points+(i+1)*100*pc[i][0]>=G:
            count += math.ceil((G-points)/(100*(i+1)))
            break
        else:
            count += pc[i][0]
            points += (i+1)*100*pc[i][0]+pc[i][1]
        
    ans = min(ans,count)

print(ans)

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

int main(){
  int n;
  cin>>n;
  int ans;
  ans = n%10;
  
  if(ans==2||ans==4)
    cout<<"hon"<<endl;
  if(ans==5||ans==7)
    cout<<"hon"<<endl;
  if(ans==9)
    cout<<"hon"<<endl;
  if(ans==0||ans==1)
    cout<<"pon"<<endl;
  if(ans==6||ans==8)
    cout<<"pon"<<endl;
  if(ans==3)
    cout<<"bon"<<endl;
}

Measured memory_bytes: 3584
import java.util.*;
 
class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int hmn = sc.nextInt();
        int nam[] = new int[200000];
        
        for(int i = 0;i < hmn;i++ ){
         int now = sc.nextInt();
             nam[now]++;
             nam[now + 1]++;
             nam[now + 2]++;
        }
        Arrays.sort(nam);
        System.out.println(nam[200000-1]);
    }
}

Measured memory_bytes: 59340
def generate_transposed_grid(grid):
    t_grid = [[None] * len(grid) for i in range(len(grid[0]))]
    for i in range(len(grid)):
        for j in range(len(grid[0])):
            t_grid[j][i] = grid[i][j]
    return t_grid


def generate_compressed_grid(grid):
    return [s for s in grid if not s == ['.'] * len(s)]


H, W = map(int, input().split())
grid = [list(input()) for _ in range(H)]

for _ in range(2):
    grid = generate_compressed_grid(grid)
    grid = generate_transposed_grid(grid)

for s in grid:
    print(''.join(s))


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


/*//______OPTIMISATION______//
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/

//________________MACROS_______________//
#define   fast 	 		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define   int   		long long int
#define   pb  			push_back
#define   f     		first
#define   s     		second
#define   deb(x) 		cerr << #x << " " << x << endl;
#define   debb(x, y) 		cerr << #x << " = " << x << "," << #y << " = " << y << endl <<endl;
#define   in            	insert
#define   lb            	lower_bound
#define   ub            	upper_bound
#define   all(x)        	x.begin(), x.end()
#define   endl              '\n'
bool isPrime(int n)
{
	for(int i = 2; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			return false;
		}
	}
	return true;
}

bool isPowerOfTwo (int x)
{
    return (x && (!(x&(x-1))));
}

int countDigit(int num)
{
	return (floor(log10(num)) + 1);
}
signed main()
{
    int l , r  ,d;
    cin >> l >> r >> d ;

    int ans = r/d - ( l -1) / d;
    cout << ans << endl;
}



Measured memory_bytes: 3628
xs = [int(input()) for i in range(5)]
ps = []
for x in xs:
	ps.append(((x-1)%10+1, x))
ps.sort()
ans = 0
ans += ps[0][1]
for i in range(1, 5):
	ans += (ps[i][1] + 9) // 10 * 10
print(ans)


Measured memory_bytes: 3060
function Main(input) {
  var inputs = input.split("\n");
  var n = parseInt(inputs[0], 10), m = parseInt(inputs[n + 1], 10);
  var obj = new Map([]);
  var s;
  for (var i = 1; i <= n; i++) {
    s = inputs[i];
    if (obj.has(s)) {
      obj.set(s, obj.get(s) + 1);
    } else {
      obj.set(s, 1)
    }
  }
  for (var i = n + 2; i <= n + 1 + m; i++) {
    s = inputs[i];
    if (obj.has(s)) {
      obj.set(s, obj.get(s) - 1);
    } else {
      obj.set(s, -1);
    }
  }
  var max = 0;
  for (var value of obj.values()) {
    max = value > max ? value:max;
  }
  console.log(max);
}

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

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

public class Main {

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

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        int k = Integer.valueOf(mylist.get(0));
        int a = Integer.valueOf(mylist.get(1).split(" ")[0]);
        int b = Integer.valueOf(mylist.get(1).split(" ")[1]);

        Boolean chkflg = false;
        for (int i = a; i <= b; i++) {
            if (i % k == 0) {
                chkflg = true;
                break;
            }
        }
        System.out.println(chkflg ? "OK" : "NG");

    }

}


Measured memory_bytes: 32668
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

int N;
string S;
bool C(int mid){
    map<string,vector<int> > mp;
    for(int i=0;i<N-mid+1;i++){
        mp[S.substr(i,mid)].push_back(i);
    }
    for(auto p: mp){
        vector<int> v=p.second;
        int l=v[0];
        int r=l+mid-1;
        if(v.size()>=2){
            rep(i,v.size()){
                if(i==0) continue;
                if(v[i]>r) return true;
            }
        }
    }
    return false;
}

int main(){
    cin >> N >> S;
    int l=0,r=S.size()+1;
    while(l+1<r){
        int mid=(l+r)/2;
        if(C(mid)) l=mid;
        else r=mid;
    }
    cout << l << endl;
}

Measured memory_bytes: 9664
import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break;
    students = []
    for i in range(n):
        students.append(list(map(int, sys.stdin.readline().rstrip().split(' '))))
    s_list=[[min(row)==s for s in row] for row in students]
    t_list=[[max(col)==s for s in col] for col in zip(*students)]
    ret = [0]
    for i,data in enumerate(zip(s_list, zip(*t_list))):
        for j,d in enumerate(zip(*data)):
            if all(d):
                ret.append(students[i][j])
    print(max(ret))

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

typedef pair<int, int> P;

int main() {

    ll n[5];
    rep(i,4){
        cin >> n[i];
    }
    n[4] = n[2]*n[3]/__gcd(n[2],n[3]);

    ll t[4];
    
    rep(i,3){
        t[i] = n[1] / n[i+2];
        t[i] -= (n[0] -1)/ n[i+2];
    }


    ll ans = 0;
    ans = n[1] - n[0] + 1 - t[0] - t[1] + t[2];


    cout << ans << endl;


    return 0;
}

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


/*
int main(){


 long long h,w;
cin>>h>>w;

 string board[50];

 for(int i=0;i<h;i++) cin>>board[i];

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

 for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){

     if(board[i][j] == '#') continue;

      int num=0;

      for(int d=0;d<8;d++){
        const int a1 = i+dy[d];
        const int b1 = j+dx[d];

        if(a1 < 0 || a1>=h) continue;
        if(b1 < 0 || b1>= w) continue;

        if(board[a1][b1] == '#') num++;
      }

      board[i][j] = char(num+'0');

    }
 }


 for(int i=0;i<h;i++)
    cout<<board[i]<<endl;


return 0;
}

*/

/*
int main(){

 int a,b,c;
 cin>>a>>b>>c;

 if(a == b)
    cout<<c<<endl;
 else if(b == c)
    cout<<a<<endl;
 else if(a == c)
    cout<<b<<endl;



 return 0;
}

int main(){

 int n,x,free=0;
  cin>>n;
 set<int>s;

 for(int i=0;i<n;i++)
 {
   cin>>x;

   if(x >=3200) free++;
   else{
    for(int j=0;j<8;j++){
        if(400*j <= x && x<400*(j+1) && x<3200)
         s.insert(j); }
   }

 }

 cout<<s.size()<<" "<<s.size()+free<<endl;


return 0;
}

*/
int main(){

 int n;
 cin>>n;
 
 int a[n];
 
 for(int i=0;i<n;i++)
    cin>>a[i];
 
 sort(a,a+n);
 
 cout<<a[n-1]-a[0]<<endl;


return 0;
}









Measured memory_bytes: 256
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) int __VA_ARGS__; in(__VA_ARGS__)
//オーバーフロー対策
#define INL(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using Bint = boost::multiprecision::checked_cpp_int;
Bint modpow(Bint a, Bint n, Bint mod)
{
    Bint res = 1;
    while (n > 0)
    {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

void solve()
{
    IN(n);
    cout << n * n << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18, MAX_N = 200000;

lint N, A;
plint arr[100000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		cin >> A;
		arr[i] = { A, i };
	}
	sort(arr, arr + N);
	lint cnt = 0;
	REP(i, N) {
		if (i % 2 == 0) continue;
		if (arr[i].second%2 != 1) cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 1792
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static class Fast {
        BufferedReader br;
        StringTokenizer st;

        public Fast() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String args[]) throws Exception {
        Fast in = new Fast();
        int n=in.nextInt();
        char arr[]=in.nextLine().toCharArray();
        int w[]=new int [n];
        int e[]= new int[n];
        if(arr[0]=='W'){
            w[0]=1;
        }else{
            e[0]=1;
        }
        for (int i = 1; i < n; i++) {
            if(arr[i]=='E'){
                e[i]=e[i-1]+1;
                w[i]=w[i-1];
            }else if(arr[i]=='W'){
                w[i]=w[i-1]+1;
                e[i]=e[i-1];
            }
        }
        int min=1000000000;
        for (int i = 0; i < arr.length; i++) {
            int sum=0;
            if(i==0){
                if(arr[i]=='W'){
                    sum=w[n-1]-w[i];
                }else{
                    sum=w[n-1]-w[i];
                }
            }else{
                if(arr[i]=='W'){
                    sum=e[i-1]+w[n-1]-w[i];
                }else{
                    sum=e[i-1]+w[n-1]-w[i];
                }
            }
            int ans=n-sum-1;
            if(ans<min){
                min=ans;
            }
        }
        System.out.println(min);
    }
}






Measured memory_bytes: 30456
def main():
    n, x, m = map(int, input().split())
    a = x
    s = a
    seen = {a}
    seq = [a]
    for i in range(n - 1):
        if a == pow(a, 2, m):
            print(s + a * (n - i - 1))
            return
        else:
            a = pow(a, 2, m)
            if a in seen:
                si = seq.index(a)
                sl = i - si + 1
                ps = s - sum(seq[:si])
                ln = (n - i - 1) // sl
                lm = (n - i - 1) % sl
                print(s + ps * ln + sum(seq[si:si + lm]))
                return
            s += a
            seen.add(a)
            seq.append(a)
    print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12984
import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();
		int a = Math.min(p, q);
		int b = Math.min(Math.max(p, q), r);
		out.println(a + b);

	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }

int gcd(int a,int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    int sum=0;
    vector<int> v;
    while(t--){
        int n;
        cin>>n;
        double c;
        string s;
        float money=0;
        while(n--){
            cin>>c>>s;
            if(s[0]=='J') money+=c;
            else money+=c*(380000.0);
        }
        cout<<money;
    }
}
    

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<sys/mman.h>
#define read() Read<int>()
#define lowbit(i) i&(-i)
using namespace std;
typedef long long ll;
const int N=1e6+5;
namespace pb_ds{   
    namespace io{
        const int MaxBuff=1<<15;
        const int Output=1<<23;
        char B[MaxBuff],*S=B,*T=B;
		#define getc() ((S==T)&&(T=(S=B)+fread(B,1,MaxBuff,stdin),S==T)?0:*S++)
        char Out[Output],*iter=Out;
        inline void flush(){
            fwrite(Out,1,iter-Out,stdout);
            iter=Out;
        }
    }
    template<class Type> inline Type Read(){
        using namespace io;
        register char ch;
        register Type ans=0; 
        register bool neg=0;
        while(ch=getc(),(ch<'0' || ch>'9') && ch!='-');
        ch=='-'?neg=1:ans=ch-'0';
        while(ch=getc(),'0'<= ch && ch<='9') ans=ans*10+ch-'0';
        return neg?-ans:ans;
    }
    template<class Type> inline void Print(register Type x,register char ch='\n'){
        using namespace io;
        if(!x) *iter++='0';
        else{
            if(x<0) *iter++='-',x=-x;
            static int s[100]; 
            register int t=0;
            while(x) s[++t]=x%10,x/=10;
            while(t) *iter++='0'+s[t--];
        }
        *iter++=ch;
    }
}
using namespace pb_ds;
int a[N],p[N];	
int n,l,r,ans;
inline bool chk(int x){
	for (int i=1;i<(n<<1);++i) p[i]=a[i]>x;
	for (int i=0;i<n-1;++i){
		if ((!p[n-i] && !p[n-i-1]) || (!p[n+i] && !p[n+i+1])) return 0;
		if ((p[n-i] && p[n-i-1]) || (p[n+i] && p[n+i+1])) return 1;
	}
	return p[1];
}
int main(){
	//freopen("pyramid.in","r",stdin);
	//freopen("pyramid.out","w",stdout);
	n=read();
	for (int i=1;i<(n<<1);++i) a[i]=read();
	l=1,r=(n<<1)-1;
	while (l<=r){
		int mid=(l+r)>>1;
		if (chk(mid)) l=mid+1;
		else r=mid-1,ans=mid;	
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n,m;
    cin>>n>>m;
    vector<pair<int,pii>> e(m);
    REP(i,m) {
        int x,y,z;
        cin>>x>>y>>z;
        x--,y--;
        e[i]={x,{y,z}};
    }
    vi d(n,-INF);
    d[0]=0;
    REP(i,n) {
        int prv=d[n-1];
        REP(j,m) {
            int v=e[j].first;
            int u=e[j].second.first;
            int c=e[j].second.second;
            if(d[v]!=-INF && d[v]+c>d[u]) {
                d[u]=d[v]+c;
            }
        }
        if(d[n-1]!=prv) {
            if(i==n-1) {
                cout<<"inf"<<endl;
                return 0;
            }
        }
    }
    cout<<d[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N, P = [int(_) for _ in input().split()]

X = defaultdict(int)
SP = int(P ** 0.5)+1
for i in range(2, SP+1):
    while P % i == 0:
        X[i] += 1
        P //= i
if P != 1:
    X[P] += 1

ans = 1
for i in X:
    ans *= i ** (X[i] // N)
print(ans)


Measured memory_bytes: 3444
n,m=map(int,input().split())
cand=set(range(1,m+1)) #set型で候補の番号一覧
for _ in [0]*n:
    _,*A=map(int,input().split()) #最初のデータを飛ばして配列Aの中に数字を格納
    cand &= set(A) # 集合の共通部分をとる操作は&で行う.
print(len(cand))

Measured memory_bytes: 3060
n = int(input())
ws = []
flag = 0
for i in range(n):
  w = input()
  if ws != []:
    if w in ws:
      print("No")
      flag = 1
      break
    elif ws[-1][-1] != w[0]:
      print("No")
      flag = 1
      break
    else:
      ws.append(w)
  else:
    ws.append(w)

if flag == 0:
  print("Yes")

Measured memory_bytes: 3064
import sys
n=input()
n=list(n)

if n[0]>n[1]:
  print(n[0]*3)
  sys.exit()

if n[0]<n[1]:
  print(str((int(n[0])+1))*3)
  sys.exit()
  
if n[0]==n[1]>=n[2]:
  print(n[0]*3)
  sys.exit()

if n[0]==n[1]<n[2]:
  print(str((int(n[0])+1))*3)
  sys.exit()


Measured memory_bytes: 9092
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

a, b, c = MAP()
print(max(0, c - (a - b)))

Measured memory_bytes: 3892
N = int(input())
C = input()
a = 0
rr = 0
lw = 0

for i in range(N):
    if C[i] == 'R':
        rr += 1
a = rr
for i in range(0, N):
    if C[i] == 'W':
        lw = lw+1
    else:
        rr = rr-1
    a = min(a, max(lw, rr))

print(a)


Measured memory_bytes: 9320